blob: aef3826e56c729352a3a4d2e30a4212eba53a3a7 [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
237 /*
238 * session context may or may not be present, when probe request needs to be sent out.
239 * following cases exist:
240 * --heartbeat failure: session needed
241 * --join req: session needed
242 * --foreground scan: no session
243 * --background scan: no session
244 * --schBeaconProcessing: to get EDCA parameters: session needed
245 * If session context does not exist, some IEs will be populated from CFGs,
246 * e.g. Supported and Extended rate set IEs
247 */
248 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
249
250 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
251 // and then hand it off to 'dot11fPackProbeRequest' (for
252 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530253 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700254
255 // & delegating to assorted helpers:
256 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
257
Jeff Johnson295189b2012-06-20 16:38:30 -0700258 if( nAdditionalIELen && pAdditionalIE )
259 {
260 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
261 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700262 /* Don't include 11b rate only when device is doing P2P Search */
263 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
264 ( p2pIe != NULL ) &&
265 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
266 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
267 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
268 ( ( psessionEntry != NULL ) &&
269 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
270 )
271 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 {
273 /* In the below API pass channel number > 14, do that it fills only
274 * 11a rates in supported rates */
275 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
276 }
277 else
278 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 PopulateDot11fSuppRates( pMac, nChannelNum,
280 &pr.SuppRates,psessionEntry);
281
282 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
283 {
284 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
285 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700286 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288#if defined WLAN_FEATURE_VOWIFI
289 //Table 7-14 in IEEE Std. 802.11k-2008 says
290 //DS params "can" be present in RRM is disabled and "is" present if
291 //RRM is enabled. It should be ok even if we add it into probe req when
292 //RRM is not enabled.
293 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
294 //Call RRM module to get the tx power for management used.
295 {
296 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
297 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
298 }
299#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700300
301 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700302 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700303 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700304 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700306 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700308 } else { //psessionEntry == NULL
309 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700311 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700312 }
313 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800314
Sandeep Puligilla60342762014-01-30 21:05:37 +0530315 /* Get HT40 capability for 2.4GHz band */
316 wlan_cfgGetInt(pMac,WNI_CFG_CHANNEL_BONDING_24G,&chanbond24G);
317 if( (nChannelNum <= SIR_11B_CHANNEL_END) && chanbond24G != TRUE)
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800318 {
319 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
320 pr.HTCaps.shortGI40MHz = 0;
321 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700322#ifdef WLAN_FEATURE_11AC
323 if (psessionEntry != NULL ) {
324 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
325 //Include HT Capability IE
326 if (psessionEntry->vhtCapability)
327 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700328 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
329 }
330 } else {
331 if (IS_DOT11_MODE_VHT(dot11mode))
332 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700333 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
334 }
335 }
336#endif
337
Jeff Johnson295189b2012-06-20 16:38:30 -0700338
339 // That's it-- now we pack it. First, how much space are we going to
340 // need?
341 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
342 if ( DOT11F_FAILED( nStatus ) )
343 {
344 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700345 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700346 // We'll fall back on the worst case scenario:
347 nPayload = sizeof( tDot11fProbeRequest );
348 }
349 else if ( DOT11F_WARNED( nStatus ) )
350 {
351 limLog( pMac, LOGW, FL("There were warnings while calculating"
352 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700353 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 }
355
356 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
357
358 // Ok-- try to allocate some memory:
359 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
360 ( tANI_U16 )nBytes, ( void** ) &pFrame,
361 ( void** ) &pPacket );
362 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
363 {
364 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700365 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 return eSIR_MEM_ALLOC_FAILED;
367 }
368
369 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530370 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700371
372 // Next, we fill out the buffer descriptor:
373 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530374 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 if ( eSIR_SUCCESS != nSirStatus )
376 {
377 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700378 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 nSirStatus );
380 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
381 ( void* ) pFrame, ( void* ) pPacket );
382 return nSirStatus; // allocated!
383 }
384
385 // That done, pack the Probe Request:
386 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
387 sizeof( tSirMacMgmtHdr ),
388 nPayload, &nPayload );
389 if ( DOT11F_FAILED( nStatus ) )
390 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700391 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 nStatus );
393 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
394 return eSIR_FAILURE; // allocated!
395 }
396 else if ( DOT11F_WARNED( nStatus ) )
397 {
398 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800399 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 }
401
402 // Append any AddIE if present.
403 if( nAdditionalIELen )
404 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530405 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 pAdditionalIE, nAdditionalIELen );
407 nPayload += nAdditionalIELen;
408 }
409
410 /* If this probe request is sent during P2P Search State, then we need
411 * to send it at OFDM rate.
412 */
413 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700414 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
415 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530416 /* For unicast probe req mgmt from Join function
417 we don't set above variables. So we need to add
418 one more check whether it is pePersona is P2P_CLIENT or not */
419 || ( ( psessionEntry != NULL ) &&
420 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 )
422 {
423 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
424 }
425
Jeff Johnson295189b2012-06-20 16:38:30 -0700426 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
427 HAL_TXRX_FRM_802_11_MGMT,
428 ANI_TXDIR_TODS,
429 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
430 limTxComplete, pFrame, txFlag );
431 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
432 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700433 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700434 //Pkt will be freed up by the callback
435 return eSIR_FAILURE;
436 }
437
438 return eSIR_SUCCESS;
439} // End limSendProbeReqMgmtFrame.
440
Jeff Johnson295189b2012-06-20 16:38:30 -0700441tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
442 tANI_U8* addIE, tANI_U16 *addnIELen,
443 tANI_U8 probeReqP2pIe)
444{
445 /* If Probe request doesn't have P2P IE, then take out P2P IE
446 from additional IE */
447 if(!probeReqP2pIe)
448 {
449 tANI_U8* tempbuf = NULL;
450 tANI_U16 tempLen = 0;
451 int left = *addnIELen;
452 v_U8_t *ptr = addIE;
453 v_U8_t elem_id, elem_len;
454
455 if(NULL == addIE)
456 {
457 PELOGE(limLog(pMac, LOGE,
458 FL(" NULL addIE pointer"));)
459 return eSIR_FAILURE;
460 }
461
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530462 tempbuf = vos_mem_malloc(left);
463 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 {
465 PELOGE(limLog(pMac, LOGE,
466 FL("Unable to allocate memory to store addn IE"));)
467 return eSIR_MEM_ALLOC_FAILED;
468 }
469
470 while(left >= 2)
471 {
472 elem_id = ptr[0];
473 elem_len = ptr[1];
474 left -= 2;
475 if(elem_len > left)
476 {
477 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700478 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530480 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 return eSIR_FAILURE;
482 }
483 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
484 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
485 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530486 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 tempLen += (elem_len + 2);
488 }
489 left -= elem_len;
490 ptr += (elem_len + 2);
491 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530492 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530494 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 }
496 return eSIR_SUCCESS;
497}
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
499void
500limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
501 tSirMacAddr peerMacAddr,
502 tpAniSSID pSsid,
503 short nStaId,
504 tANI_U8 nKeepAlive,
505 tpPESession psessionEntry,
506 tANI_U8 probeReqP2pIe)
507{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700508 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530509 tSirRetStatus nSirStatus;
510 tANI_U32 cfg, nPayload, nBytes, nStatus;
511 tpSirMacMgmtHdr pMacHdr;
512 tANI_U8 *pFrame;
513 void *pPacket;
514 eHalStatus halstatus;
515 tANI_U32 addnIEPresent;
516 tANI_U32 addnIE1Len=0;
517 tANI_U32 addnIE2Len=0;
518 tANI_U32 addnIE3Len=0;
519 tANI_U16 totalAddnIeLen = 0;
520 tANI_U32 wpsApEnable=0, tmp;
521 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530523 tANI_U8 *pP2pIe = NULL;
524 tANI_U8 noaLen = 0;
525 tANI_U8 total_noaLen = 0;
526 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530528 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700529
530 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
531 {
532 return; // in this case.
533 }
534
535 if(NULL == psessionEntry)
536 {
537 return;
538 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530539
540 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
541 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700542 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530543 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700544 return;
545 }
546
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 // Fill out 'frm', after which we'll just hand the struct off to
548 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530549 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700550
551 // Timestamp to be updated by TFP, below.
552
553 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
555 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700556 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 }
558 else
559 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800560 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
561 if (eSIR_SUCCESS != nSirStatus)
562 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700563 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800564 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530565 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800566 return;
567 }
568 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800569 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700570
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700571 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
572 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700574 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700575
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700576 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
577 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700578
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
581 {
582 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
583 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700584 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 }
586 }
587 else
588 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800589 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700590 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700591
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800592 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700593
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800594 if (wpsApEnable)
595 {
596 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
597 }
598
599 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
600 {
601 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
602 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
603 }
604
605 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
606 {
607 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
608 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
609 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700611
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700612 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
613 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700614
Jeff Johnson295189b2012-06-20 16:38:30 -0700615
616 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700617 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700618
619
620 // N.B. In earlier implementations, the RSN IE would be placed in
621 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
622 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700623 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700624
625 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700626 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700628 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700629 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700631#ifdef WLAN_FEATURE_11AC
632 if(psessionEntry->vhtCapability)
633 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800634 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700635 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
636 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700637 // we do not support multi users yet
638 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Sandeep Puligilla60342762014-01-30 21:05:37 +0530639 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700640 }
641#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700642
Sandeep Puligilla60342762014-01-30 21:05:37 +0530643
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 if ( psessionEntry->pLimStartBssReq )
645 {
646 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700647 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700648 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
649 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 }
651
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700652 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700653
654#if defined(FEATURE_WLAN_WAPI)
655 if( psessionEntry->pLimStartBssReq )
656 {
657 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700658 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 }
660
661#endif // defined(FEATURE_WLAN_WAPI)
662
663
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700664 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 if ( DOT11F_FAILED( nStatus ) )
666 {
667 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700668 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 nStatus );
670 // We'll fall back on the worst case scenario:
671 nPayload = sizeof( tDot11fProbeResponse );
672 }
673 else if ( DOT11F_WARNED( nStatus ) )
674 {
675 limLog( pMac, LOGW, FL("There were warnings while calculating"
676 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700677 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 }
679
680 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
681
682 addnIEPresent = false;
683
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 if( pMac->lim.gpLimRemainOnChanReq )
685 {
686 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
687 }
688 //Only use CFG for non-listen mode. This CFG is not working for concurrency
689 //In listening mode, probe rsp IEs is passed in the message from SME to PE
690 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 {
692
693 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
694 &addnIEPresent) != eSIR_SUCCESS)
695 {
696 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530697 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 return;
699 }
700 }
701
702 if (addnIEPresent)
703 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530704
705 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
706 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 {
708 PELOGE(limLog(pMac, LOGE,
709 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530710 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 return;
712 }
713
714 //Probe rsp IE available
715 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
716 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
717 {
718 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530719 vos_mem_free(addIE);
720 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 return;
722 }
723 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
724 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
725 {
726 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
727 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
728 &addnIE1Len) )
729 {
730 limLog(pMac, LOGP,
731 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530732 vos_mem_free(addIE);
733 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 return;
735 }
736 }
737
738 //Probe rsp IE available
739 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
740 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
741 {
742 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530743 vos_mem_free(addIE);
744 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 return;
746 }
747 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
748 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
749 {
750 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
751 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
752 &addnIE2Len) )
753 {
754 limLog(pMac, LOGP,
755 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530756 vos_mem_free(addIE);
757 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 return;
759 }
760 }
761
762 //Probe rsp IE available
763 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
764 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
765 {
766 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530767 vos_mem_free(addIE);
768 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 return;
770 }
771 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
772 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
773 {
774 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
775 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
776 &addIE[addnIE1Len + addnIE2Len],
777 &addnIE3Len) )
778 {
779 limLog(pMac, LOGP,
780 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530781 vos_mem_free(addIE);
782 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 return;
784 }
785 }
786 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
787
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
789 {
790 limLog(pMac, LOGP,
791 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530792 vos_mem_free(addIE);
793 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 return;
795 }
796 nBytes = nBytes + totalAddnIeLen;
797
798 if (probeReqP2pIe)
799 {
800 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
801 if (pP2pIe != NULL)
802 {
803 //get NoA attribute stream P2P IE
804 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
805 if (noaLen != 0)
806 {
807 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
808 &noaStream[0], noaLen);
809 nBytes = nBytes + total_noaLen;
810 }
811 }
812 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 }
814
815 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
816 ( tANI_U16 )nBytes, ( void** ) &pFrame,
817 ( void** ) &pPacket );
818 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
819 {
820 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700821 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 if ( addIE != NULL )
823 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530824 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530826 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 return;
828 }
829
830 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530831 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700832
833 // Next, we fill out the buffer descriptor:
834 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
835 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
836 if ( eSIR_SUCCESS != nSirStatus )
837 {
838 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700839 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 nSirStatus );
841 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
842 ( void* ) pFrame, ( void* ) pPacket );
843 if ( addIE != NULL )
844 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530845 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530847 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 return;
849 }
850
851 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
852
853 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
854
855 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700856 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 nPayload, &nPayload );
858 if ( DOT11F_FAILED( nStatus ) )
859 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700860 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 nStatus );
862 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
863 if ( addIE != NULL )
864 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530865 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530867 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 return; // allocated!
869 }
870 else if ( DOT11F_WARNED( nStatus ) )
871 {
872 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800873 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 }
875
876 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
877 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
878
879 pMac->sys.probeRespond++;
880
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 if( pMac->lim.gpLimRemainOnChanReq )
882 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530883 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
885 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700886
887 if ( addnIEPresent )
888 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530889 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 if (noaLen != 0)
892 {
Krunal Soni81b24262013-05-15 17:46:41 -0700893 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 {
895 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +0530896 FL("Not able to insert NoA because of length constraint."
897 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530898 vos_mem_free(addIE);
899 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -0700900 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
901 ( void* ) pFrame, ( void* ) pPacket );
902 return;
903 }
904 else
905 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530906 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -0700907 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 }
909 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700910
911 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
913 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 )
915 {
916 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
917 }
918
919 // Queue Probe Response frame in high priority WQ
920 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
921 ( tANI_U16 ) nBytes,
922 HAL_TXRX_FRM_802_11_MGMT,
923 ANI_TXDIR_TODS,
924 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
925 limTxComplete, pFrame, txFlag );
926 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
927 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700928 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 //Pkt will be freed up by the callback
930 }
931
932 if ( addIE != NULL )
933 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530934 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 }
936
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530937 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700938 return;
939
940
Jeff Johnson295189b2012-06-20 16:38:30 -0700941} // End limSendProbeRspMgmtFrame.
942
943void
944limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
945 tSirMacAddr peerMacAddr,
946 tSirAddtsReqInfo *pAddTS,
947 tpPESession psessionEntry)
948{
949 tANI_U16 i;
950 tANI_U8 *pFrame;
951 tSirRetStatus nSirStatus;
952 tDot11fAddTSRequest AddTSReq;
953 tDot11fWMMAddTSRequest WMMAddTSReq;
954 tANI_U32 nPayload, nBytes, nStatus;
955 tpSirMacMgmtHdr pMacHdr;
956 void *pPacket;
957#ifdef FEATURE_WLAN_CCX
958 tANI_U32 phyMode;
959#endif
960 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530961 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700962
963 if(NULL == psessionEntry)
964 {
965 return;
966 }
967
968 if ( ! pAddTS->wmeTspecPresent )
969 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530970 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700971
972 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
973 AddTSReq.DialogToken.token = pAddTS->dialogToken;
974 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
975 if ( pAddTS->lleTspecPresent )
976 {
977 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
978 }
979 else
980 {
981 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
982 }
983
984 if ( pAddTS->lleTspecPresent )
985 {
986 AddTSReq.num_WMMTCLAS = 0;
987 AddTSReq.num_TCLAS = pAddTS->numTclas;
988 for ( i = 0; i < pAddTS->numTclas; ++i)
989 {
990 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
991 &AddTSReq.TCLAS[i] );
992 }
993 }
994 else
995 {
996 AddTSReq.num_TCLAS = 0;
997 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
998 for ( i = 0; i < pAddTS->numTclas; ++i)
999 {
1000 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1001 &AddTSReq.WMMTCLAS[i] );
1002 }
1003 }
1004
1005 if ( pAddTS->tclasProcPresent )
1006 {
1007 if ( pAddTS->lleTspecPresent )
1008 {
1009 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1010 AddTSReq.TCLASSPROC.present = 1;
1011 }
1012 else
1013 {
1014 AddTSReq.WMMTCLASPROC.version = 1;
1015 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1016 AddTSReq.WMMTCLASPROC.present = 1;
1017 }
1018 }
1019
1020 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1021 if ( DOT11F_FAILED( nStatus ) )
1022 {
1023 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001024 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 nStatus );
1026 // We'll fall back on the worst case scenario:
1027 nPayload = sizeof( tDot11fAddTSRequest );
1028 }
1029 else if ( DOT11F_WARNED( nStatus ) )
1030 {
1031 limLog( pMac, LOGW, FL("There were warnings while calculating"
1032 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001033 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 }
1035 }
1036 else
1037 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301038 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001039
1040 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1041 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1042 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1043
1044 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1045 WMMAddTSReq.StatusCode.statusCode = 0;
1046
1047 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1048#ifdef FEATURE_WLAN_CCX
1049 limGetPhyMode(pMac, &phyMode, psessionEntry);
1050
1051 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1052 {
1053 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1054 }
1055 else
1056 {
1057 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1058 }
1059 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1060#endif
1061 // fillWmeTspecIE
1062
1063 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1064 if ( DOT11F_FAILED( nStatus ) )
1065 {
1066 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001067 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001068 nStatus );
1069 // We'll fall back on the worst case scenario:
1070 nPayload = sizeof( tDot11fAddTSRequest );
1071 }
1072 else if ( DOT11F_WARNED( nStatus ) )
1073 {
1074 limLog( pMac, LOGW, FL("There were warnings while calculating"
1075 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001076 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 }
1078 }
1079
1080 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1081
1082 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1083 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1084 ( void** ) &pPacket );
1085 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1086 {
1087 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001088 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001089 return;
1090 }
1091
1092 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301093 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001094
1095 // Next, we fill out the buffer descriptor:
1096 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1097 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1098 if ( eSIR_SUCCESS != nSirStatus )
1099 {
1100 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001101 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 nSirStatus );
1103 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1104 ( void* ) pFrame, ( void* ) pPacket );
1105 return;
1106 }
1107
1108 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1109
1110 #if 0
1111 cfgLen = SIR_MAC_ADDR_LENGTH;
1112 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1113 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1114 {
1115 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001116 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001117 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1118 ( void* ) pFrame, ( void* ) pPacket );
1119 return;
1120 }
1121 #endif //TO SUPPORT BT-AMP
1122
1123 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1124
Chet Lanctot186b5732013-03-18 10:26:30 -07001125#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001126 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001127#endif
1128
Jeff Johnson295189b2012-06-20 16:38:30 -07001129 // That done, pack the struct:
1130 if ( ! pAddTS->wmeTspecPresent )
1131 {
1132 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1133 pFrame + sizeof(tSirMacMgmtHdr),
1134 nPayload, &nPayload );
1135 if ( DOT11F_FAILED( nStatus ) )
1136 {
1137 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001138 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 nStatus );
1140 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1141 return; // allocated!
1142 }
1143 else if ( DOT11F_WARNED( nStatus ) )
1144 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001145 limLog( pMac, LOGW, FL("There were warnings while packing "
1146 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 }
1148 }
1149 else
1150 {
1151 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1152 pFrame + sizeof(tSirMacMgmtHdr),
1153 nPayload, &nPayload );
1154 if ( DOT11F_FAILED( nStatus ) )
1155 {
1156 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001157 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001158 nStatus );
1159 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1160 return; // allocated!
1161 }
1162 else if ( DOT11F_WARNED( nStatus ) )
1163 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001164 limLog( pMac, LOGW, FL("There were warnings while packing "
1165 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 }
1167 }
1168
1169 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1170 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1171
1172 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1174 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 )
1176 {
1177 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1178 }
1179
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301180 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1181 psessionEntry->peSessionId,
1182 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001183 // Queue Addts Response frame in high priority WQ
1184 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1185 HAL_TXRX_FRM_802_11_MGMT,
1186 ANI_TXDIR_TODS,
1187 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1188 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301189 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1190 psessionEntry->peSessionId,
1191 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1193 {
1194 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001195 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 //Pkt will be freed up by the callback
1197 }
1198
1199} // End limSendAddtsReqActionFrame.
1200
Jeff Johnson295189b2012-06-20 16:38:30 -07001201
1202
1203void
1204limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1205 tANI_U16 statusCode,
1206 tANI_U16 aid,
1207 tSirMacAddr peerMacAddr,
1208 tANI_U8 subType,
1209 tpDphHashNode pSta,tpPESession psessionEntry)
1210{
1211 static tDot11fAssocResponse frm;
1212 tANI_U8 *pFrame, *macAddr;
1213 tpSirMacMgmtHdr pMacHdr;
1214 tSirRetStatus nSirStatus;
1215 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1216 tHalBitVal qosMode, wmeMode;
1217 tANI_U32 nPayload, nBytes, nStatus;
1218 void *pPacket;
1219 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301220 tUpdateBeaconParams beaconParams;
1221 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 tANI_U32 addnIEPresent = false;
1223 tANI_U32 addnIELen=0;
1224 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1225 tpSirAssocReq pAssocReq = NULL;
1226
1227 if(NULL == psessionEntry)
1228 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301229 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 return;
1231 }
1232
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301233 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001234
1235 limGetQosMode(psessionEntry, &qosMode);
1236 limGetWmeMode(psessionEntry, &wmeMode);
1237
1238 // An Add TS IE is added only if the AP supports it and the requesting
1239 // STA sent a traffic spec.
1240 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1241
1242 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1243
1244 frm.Status.status = statusCode;
1245
1246 frm.AID.associd = aid | LIM_AID_MASK;
1247
1248 if ( NULL == pSta )
1249 {
1250 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1251 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1252 }
1253 else
1254 {
1255 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1256 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1257 }
1258
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1260 {
1261 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1262 {
1263 pAssocReq =
1264 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1266 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1267 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 }
1270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001271
1272 if ( NULL != pSta )
1273 {
1274 if ( eHAL_SET == qosMode )
1275 {
1276 if ( pSta->lleEnabled )
1277 {
1278 lleMode = 1;
1279 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1280 {
1281 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1282
1283// FramesToDo:...
1284// if ( fAddTS )
1285// {
1286// tANI_U8 *pAf = pBody;
1287// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1288// tANI_U32 tlen;
1289// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1290// &tlen, bufLen - frameLen);
1291// } // End if on Add TS.
1292 }
1293 } // End if on .11e enabled in 'pSta'.
1294 } // End if on QOS Mode on.
1295
1296 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1297 {
1298 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1299 {
1300
Jeff Johnson295189b2012-06-20 16:38:30 -07001301 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001302
1303 if ( pSta->wsmEnabled )
1304 {
1305 PopulateDot11fWMMCaps(&frm.WMMCaps );
1306 }
1307 }
1308 }
1309
1310 if ( pSta->aniPeer )
1311 {
1312 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1313 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1314 {
1315 edcaInclude = 1;
1316 }
1317
1318 } // End if on Airgo peer.
1319
1320 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001321 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001323 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001326
1327#ifdef WLAN_FEATURE_11AC
1328 if( pSta->mlmStaContext.vhtCapability &&
1329 psessionEntry->vhtCapability )
1330 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001331 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001332 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1333 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Sandeep Puligilla60342762014-01-30 21:05:37 +05301334 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001335 }
1336#endif
1337
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 } // End if on non-NULL 'pSta'.
1339
1340
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301341 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001342
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1344 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1345 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001347
1348 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1349 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1350
1351 beaconParams.bssIdx = psessionEntry->bssIdx;
1352
1353 //Send message to HAL about beacon parameter change.
1354 if(beaconParams.paramChangeBitmap)
1355 {
1356 schSetFixedBeaconFields(pMac,psessionEntry);
1357 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1358 }
1359
1360 // Allocate a buffer for this frame:
1361 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1362 if ( DOT11F_FAILED( nStatus ) )
1363 {
1364 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001365 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 nStatus );
1367 return;
1368 }
1369 else if ( DOT11F_WARNED( nStatus ) )
1370 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001371 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001373 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 }
1375
1376 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1377
1378 if ( pAssocReq != NULL )
1379 {
1380 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1381 &addnIEPresent) != eSIR_SUCCESS)
1382 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301383 limLog(pMac, LOGP, FL("Unable to get "
1384 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 return;
1386 }
1387
1388 if (addnIEPresent)
1389 {
1390 //Assoc rsp IE available
1391 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1392 &addnIELen) != eSIR_SUCCESS)
1393 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301394 limLog(pMac, LOGP, FL("Unable to get "
1395 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 return;
1397 }
1398
1399 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1400 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1401 {
1402 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1403 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1404 {
1405 nBytes = nBytes + addnIELen;
1406 }
1407 }
1408 }
1409 }
1410
1411 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1412 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1413 ( void** ) &pPacket );
1414 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1415 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001416 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 return;
1418 }
1419
1420 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301421 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001422
1423 // Next, we fill out the buffer descriptor:
1424 nSirStatus = limPopulateMacHeader( pMac,
1425 pFrame,
1426 SIR_MAC_MGMT_FRAME,
1427 ( LIM_ASSOC == subType ) ?
1428 SIR_MAC_MGMT_ASSOC_RSP :
1429 SIR_MAC_MGMT_REASSOC_RSP,
1430 peerMacAddr,psessionEntry->selfMacAddr);
1431 if ( eSIR_SUCCESS != nSirStatus )
1432 {
1433 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001434 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 nSirStatus );
1436 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1437 ( void* ) pFrame, ( void* ) pPacket );
1438 return;
1439 }
1440
1441 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1442
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1444
1445 nStatus = dot11fPackAssocResponse( pMac, &frm,
1446 pFrame + sizeof( tSirMacMgmtHdr ),
1447 nPayload, &nPayload );
1448 if ( DOT11F_FAILED( nStatus ) )
1449 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301450 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1451 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1453 ( void* ) pFrame, ( void* ) pPacket );
1454 return; // allocated!
1455 }
1456 else if ( DOT11F_WARNED( nStatus ) )
1457 {
1458 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001459 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 }
1461
1462 macAddr = pMacHdr->da;
1463
1464 if (subType == LIM_ASSOC)
1465 {
1466 PELOG1(limLog(pMac, LOG1,
1467 FL("*** Sending Assoc Resp status %d aid %d to "),
1468 statusCode, aid);)
1469 }
1470 else{
1471 PELOG1(limLog(pMac, LOG1,
1472 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1473 statusCode, aid);)
1474 }
1475 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1476
1477 if ( addnIEPresent )
1478 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301479 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 }
1481
1482 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001483 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1484 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001485 )
1486 {
1487 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1488 }
1489
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301490 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1491 psessionEntry->peSessionId,
1492 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 /// Queue Association Response frame in high priority WQ
1494 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1495 HAL_TXRX_FRM_802_11_MGMT,
1496 ANI_TXDIR_TODS,
1497 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1498 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301499 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1500 psessionEntry->peSessionId,
1501 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1503 {
1504 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001505 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 nSirStatus);
1507
1508 //Pkt will be freed up by the callback
1509 }
1510
1511 // update the ANI peer station count
1512 //FIXME_PROTECTION : take care of different type of station
1513 // counter inside this function.
1514 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1515
1516} // End limSendAssocRspMgmtFrame.
1517
1518
1519
1520void
1521limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1522 tSirMacAddr peer,
1523 tANI_U16 nStatusCode,
1524 tSirAddtsReqInfo *pAddTS,
1525 tSirMacScheduleIE *pSchedule,
1526 tpPESession psessionEntry)
1527{
1528 tANI_U8 *pFrame;
1529 tpSirMacMgmtHdr pMacHdr;
1530 tDot11fAddTSResponse AddTSRsp;
1531 tDot11fWMMAddTSResponse WMMAddTSRsp;
1532 tSirRetStatus nSirStatus;
1533 tANI_U32 i, nBytes, nPayload, nStatus;
1534 void *pPacket;
1535 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301536 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001537
1538 if(NULL == psessionEntry)
1539 {
1540 return;
1541 }
1542
1543 if ( ! pAddTS->wmeTspecPresent )
1544 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301545 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001546
1547 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1548 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1549 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1550 AddTSRsp.Status.status = nStatusCode;
1551
1552 // The TsDelay information element is only filled in for a specific
1553 // status code:
1554 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1555 {
1556 if ( pAddTS->wsmTspecPresent )
1557 {
1558 AddTSRsp.WMMTSDelay.version = 1;
1559 AddTSRsp.WMMTSDelay.delay = 10;
1560 AddTSRsp.WMMTSDelay.present = 1;
1561 }
1562 else
1563 {
1564 AddTSRsp.TSDelay.delay = 10;
1565 AddTSRsp.TSDelay.present = 1;
1566 }
1567 }
1568
1569 if ( pAddTS->wsmTspecPresent )
1570 {
1571 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1572 }
1573 else
1574 {
1575 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1576 }
1577
1578 if ( pAddTS->wsmTspecPresent )
1579 {
1580 AddTSRsp.num_WMMTCLAS = 0;
1581 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1582 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1583 {
1584 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1585 &AddTSRsp.TCLAS[i] );
1586 }
1587 }
1588 else
1589 {
1590 AddTSRsp.num_TCLAS = 0;
1591 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1592 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1593 {
1594 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1595 &AddTSRsp.WMMTCLAS[i] );
1596 }
1597 }
1598
1599 if ( pAddTS->tclasProcPresent )
1600 {
1601 if ( pAddTS->wsmTspecPresent )
1602 {
1603 AddTSRsp.WMMTCLASPROC.version = 1;
1604 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1605 AddTSRsp.WMMTCLASPROC.present = 1;
1606 }
1607 else
1608 {
1609 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1610 AddTSRsp.TCLASSPROC.present = 1;
1611 }
1612 }
1613
1614 // schedule element is included only if requested in the tspec and we are
1615 // using hcca (or both edca and hcca)
1616 // 11e-D8.0 is inconsistent on whether the schedule element is included
1617 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1618 // pg 46, line 17-18 says something else. So just include it and let the
1619 // sta figure it out
1620 if ((pSchedule != NULL) &&
1621 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1622 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1623 {
1624 if ( pAddTS->wsmTspecPresent )
1625 {
1626 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1627 }
1628 else
1629 {
1630 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1631 }
1632 }
1633
1634 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1635 if ( DOT11F_FAILED( nStatus ) )
1636 {
1637 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001638 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 nStatus );
1640 // We'll fall back on the worst case scenario:
1641 nPayload = sizeof( tDot11fAddTSResponse );
1642 }
1643 else if ( DOT11F_WARNED( nStatus ) )
1644 {
1645 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001646 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001647 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 }
1649 }
1650 else
1651 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301652 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001653
1654 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1655 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1656 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1657 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1658
1659 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1660
1661 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1662 if ( DOT11F_FAILED( nStatus ) )
1663 {
1664 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001665 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 nStatus );
1667 // We'll fall back on the worst case scenario:
1668 nPayload = sizeof( tDot11fWMMAddTSResponse );
1669 }
1670 else if ( DOT11F_WARNED( nStatus ) )
1671 {
1672 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001673 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001674 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 }
1676 }
1677
1678 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1679
1680 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1681 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1682 {
1683 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001684 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 return;
1686 }
1687
1688 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301689 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001690
1691 // Next, we fill out the buffer descriptor:
1692 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1693 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1694 if ( eSIR_SUCCESS != nSirStatus )
1695 {
1696 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001697 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 nSirStatus );
1699 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1700 return; // allocated!
1701 }
1702
1703 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1704
1705
1706 #if 0
1707 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1708 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1709 {
1710 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001711 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1713 return; // allocated!
1714 }
1715 #endif //TO SUPPORT BT-AMP
1716 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1717
Chet Lanctot186b5732013-03-18 10:26:30 -07001718#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001719 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001720#endif
1721
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 // That done, pack the struct:
1723 if ( ! pAddTS->wmeTspecPresent )
1724 {
1725 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1726 pFrame + sizeof( tSirMacMgmtHdr ),
1727 nPayload, &nPayload );
1728 if ( DOT11F_FAILED( nStatus ) )
1729 {
1730 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001731 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 nStatus );
1733 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1734 return;
1735 }
1736 else if ( DOT11F_WARNED( nStatus ) )
1737 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001738 limLog( pMac, LOGW, FL("There were warnings while packing "
1739 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 }
1741 }
1742 else
1743 {
1744 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1745 pFrame + sizeof( tSirMacMgmtHdr ),
1746 nPayload, &nPayload );
1747 if ( DOT11F_FAILED( nStatus ) )
1748 {
1749 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001750 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 nStatus );
1752 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1753 return;
1754 }
1755 else if ( DOT11F_WARNED( nStatus ) )
1756 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001757 limLog( pMac, LOGW, FL("There were warnings while packing "
1758 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001759 }
1760 }
1761
1762 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1763 nStatusCode );
1764 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1765
1766 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1768 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 )
1770 {
1771 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1772 }
1773
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301774 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1775 psessionEntry->peSessionId,
1776 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 // Queue the frame in high priority WQ:
1778 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1779 HAL_TXRX_FRM_802_11_MGMT,
1780 ANI_TXDIR_TODS,
1781 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1782 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301783 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1784 psessionEntry->peSessionId,
1785 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1787 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001788 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 nSirStatus );
1790 //Pkt will be freed up by the callback
1791 }
1792
1793} // End limSendAddtsRspActionFrame.
1794
1795void
1796limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1797 tSirMacAddr peer,
1798 tANI_U8 wmmTspecPresent,
1799 tSirMacTSInfo *pTsinfo,
1800 tSirMacTspecIE *pTspecIe,
1801 tpPESession psessionEntry)
1802{
1803 tANI_U8 *pFrame;
1804 tpSirMacMgmtHdr pMacHdr;
1805 tDot11fDelTS DelTS;
1806 tDot11fWMMDelTS WMMDelTS;
1807 tSirRetStatus nSirStatus;
1808 tANI_U32 nBytes, nPayload, nStatus;
1809 void *pPacket;
1810 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301811 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001812
1813 if(NULL == psessionEntry)
1814 {
1815 return;
1816 }
1817
1818 if ( ! wmmTspecPresent )
1819 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301820 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001821
1822 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1823 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1824 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1825
1826 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1827 if ( DOT11F_FAILED( nStatus ) )
1828 {
1829 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001830 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 nStatus );
1832 // We'll fall back on the worst case scenario:
1833 nPayload = sizeof( tDot11fDelTS );
1834 }
1835 else if ( DOT11F_WARNED( nStatus ) )
1836 {
1837 limLog( pMac, LOGW, FL("There were warnings while calcula"
1838 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001839 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 }
1841 }
1842 else
1843 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301844 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001845
1846 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1847 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1848 WMMDelTS.DialogToken.token = 0;
1849 WMMDelTS.StatusCode.statusCode = 0;
1850 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1851 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1852 if ( DOT11F_FAILED( nStatus ) )
1853 {
1854 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001855 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 nStatus );
1857 // We'll fall back on the worst case scenario:
1858 nPayload = sizeof( tDot11fDelTS );
1859 }
1860 else if ( DOT11F_WARNED( nStatus ) )
1861 {
1862 limLog( pMac, LOGW, FL("There were warnings while calcula"
1863 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001864 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 }
1866 }
1867
1868 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1869
1870 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1871 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1872 {
1873 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001874 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 return;
1876 }
1877
1878 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301879 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001880
1881 // Next, we fill out the buffer descriptor:
1882 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1883 SIR_MAC_MGMT_ACTION, peer,
1884 psessionEntry->selfMacAddr);
1885 if ( eSIR_SUCCESS != nSirStatus )
1886 {
1887 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001888 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 nSirStatus );
1890 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1891 return; // allocated!
1892 }
1893
1894 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1895
1896 #if 0
1897
1898 cfgLen = SIR_MAC_ADDR_LENGTH;
1899 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1900 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1901 {
1902 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001903 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1905 return; // allocated!
1906 }
1907 #endif //TO SUPPORT BT-AMP
1908 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1909
Chet Lanctot186b5732013-03-18 10:26:30 -07001910#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001911 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001912#endif
1913
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 // That done, pack the struct:
1915 if ( !wmmTspecPresent )
1916 {
1917 nStatus = dot11fPackDelTS( pMac, &DelTS,
1918 pFrame + sizeof( tSirMacMgmtHdr ),
1919 nPayload, &nPayload );
1920 if ( DOT11F_FAILED( nStatus ) )
1921 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001922 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 nStatus );
1924 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1925 return; // allocated!
1926 }
1927 else if ( DOT11F_WARNED( nStatus ) )
1928 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001929 limLog( pMac, LOGW, FL("There were warnings while packing "
1930 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 }
1932 }
1933 else
1934 {
1935 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1936 pFrame + sizeof( tSirMacMgmtHdr ),
1937 nPayload, &nPayload );
1938 if ( DOT11F_FAILED( nStatus ) )
1939 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001940 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001941 nStatus );
1942 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1943 return; // allocated!
1944 }
1945 else if ( DOT11F_WARNED( nStatus ) )
1946 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001947 limLog( pMac, LOGW, FL("There were warnings while packing "
1948 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 }
1950 }
1951
1952 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1953 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1954
1955 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1957 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 )
1959 {
1960 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1961 }
1962
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301963 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1964 psessionEntry->peSessionId,
1965 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001966 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1967 HAL_TXRX_FRM_802_11_MGMT,
1968 ANI_TXDIR_TODS,
1969 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1970 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301971 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1972 psessionEntry->peSessionId,
1973 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1975 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001976 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 nSirStatus );
1978 //Pkt will be freed up by the callback
1979 }
1980
1981} // End limSendDeltsReqActionFrame.
1982
1983void
1984limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1985 tLimMlmAssocReq *pMlmAssocReq,
1986 tpPESession psessionEntry)
1987{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001988 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 tANI_U16 caps;
1990 tANI_U8 *pFrame;
1991 tSirRetStatus nSirStatus;
1992 tLimMlmAssocCnf mlmAssocCnf;
1993 tANI_U32 nBytes, nPayload, nStatus;
1994 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1995 void *pPacket;
1996 eHalStatus halstatus;
1997 tANI_U16 nAddIELen;
1998 tANI_U8 *pAddIE;
1999 tANI_U8 *wpsIe = NULL;
2000#if defined WLAN_FEATURE_VOWIFI
2001 tANI_U8 PowerCapsPopulated = FALSE;
2002#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302003 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302004 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002005
2006 if(NULL == psessionEntry)
2007 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302008 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 return;
2010 }
2011
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 /* check this early to avoid unncessary operation */
2013 if(NULL == psessionEntry->pLimJoinReq)
2014 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302015 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 return;
2017 }
2018 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2019 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2020
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302021 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2022 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002023 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302024 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002025 return;
2026 }
2027
2028
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302029 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002030
2031 caps = pMlmAssocReq->capabilityInfo;
2032 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2033 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2034#if defined(FEATURE_WLAN_WAPI)
2035 /* CR: 262463 :
2036 According to WAPI standard:
2037 7.3.1.4 Capability Information field
2038 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2039 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2040 Reassociation management frames. */
2041 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2042 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2043#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002044 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002045
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002046 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2047 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002049 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002050
2051 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2052 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2053
2054 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2055 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2056
2057 // We prefer .11e asociations:
2058 if ( fQosEnabled ) fWmeEnabled = false;
2059
2060 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2061 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2062
2063 if ( psessionEntry->lim11hEnable &&
2064 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2065 {
2066#if defined WLAN_FEATURE_VOWIFI
2067 PowerCapsPopulated = TRUE;
2068
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002069 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002070#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002071 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002072
2073 }
2074
2075#if defined WLAN_FEATURE_VOWIFI
2076 if( pMac->rrm.rrmPEContext.rrmEnable &&
2077 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2078 {
2079 if (PowerCapsPopulated == FALSE)
2080 {
2081 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002082 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 }
2084 }
2085#endif
2086
2087 if ( fQosEnabled &&
2088 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002089 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002090
2091 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002092 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002093
2094#if defined WLAN_FEATURE_VOWIFI
2095 if( pMac->rrm.rrmPEContext.rrmEnable &&
2096 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2097 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002098 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 }
2100#endif
2101 // The join request *should* contain zero or one of the WPA and RSN
2102 // IEs. The payload send along with the request is a
2103 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2104
2105 // typedef struct sSirRSNie
2106 // {
2107 // tANI_U16 length;
2108 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2109 // } tSirRSNie, *tpSirRSNie;
2110
2111 // So, we should be able to make the following two calls harmlessly,
2112 // since they do nothing if they don't find the given IE in the
2113 // bytestream with which they're provided.
2114
2115 // The net effect of this will be to faithfully transmit whatever
2116 // security IE is in the join request.
2117
2118 // *However*, if we're associating for the purpose of WPS
2119 // enrollment, and we've been configured to indicate that by
2120 // eliding the WPA or RSN IE, we just skip this:
2121 if( nAddIELen && pAddIE )
2122 {
2123 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2124 }
2125 if ( NULL == wpsIe )
2126 {
2127 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002128 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002130 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002131#if defined(FEATURE_WLAN_WAPI)
2132 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002133 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002134#endif // defined(FEATURE_WLAN_WAPI)
2135 }
2136
2137 // include WME EDCA IE as well
2138 if ( fWmeEnabled )
2139 {
2140 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2141 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002142 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002143 }
2144
2145 if ( fWsmEnabled &&
2146 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2147 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002148 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 }
2150 }
2151
2152 //Populate HT IEs, when operating in 11n or Taurus modes AND
2153 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002154 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 pMac->lim.htCapabilityPresentInBeacon)
2156 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002157 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002158#ifdef DISABLE_GF_FOR_INTEROP
2159
2160 /*
2161 * To resolve the interop problem with Broadcom AP,
2162 * where TQ STA could not pass traffic with GF enabled,
2163 * TQ STA will do Greenfield only with TQ AP, for
2164 * everybody else it will be turned off.
2165 */
2166
2167 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2168 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302169 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2170 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002171 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 }
2173#endif
2174
2175 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002176#ifdef WLAN_FEATURE_11AC
2177 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002178 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002179 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002180 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002181 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
Jeff Johnsone7245742012-09-05 17:12:55 -07002182 }
2183#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302184 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002185
2186#if defined WLAN_FEATURE_VOWIFI_11R
2187 if (psessionEntry->pLimJoinReq->is11Rconnection)
2188 {
2189#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002190 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2192 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2193 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2194#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302195 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2196 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302198 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 {
2200 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302201 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 }
2203#endif
2204
2205#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302206 /* For CCX Associations fill the CCX IEs */
2207 if (psessionEntry->isCCXconnection &&
2208 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002210#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002211 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002212#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302213 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 }
2215#endif
2216
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002217 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 if ( DOT11F_FAILED( nStatus ) )
2219 {
2220 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002221 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 nStatus );
2223 // We'll fall back on the worst case scenario:
2224 nPayload = sizeof( tDot11fAssocRequest );
2225 }
2226 else if ( DOT11F_WARNED( nStatus ) )
2227 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002228 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002230 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002231 }
2232
2233 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2234
2235 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2236 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2237 ( void** ) &pPacket );
2238 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2239 {
2240 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002241 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002242
2243 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002244 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002245
2246
2247 /* Update PE session id*/
2248 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2249
2250 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2251
2252 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2253 ( void* ) pFrame, ( void* ) pPacket );
2254
2255 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2256 ( tANI_U32* ) &mlmAssocCnf);
2257
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302258 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 return;
2260 }
2261
2262 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302263 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002264
2265 // Next, we fill out the buffer descriptor:
2266 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2267 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2268 if ( eSIR_SUCCESS != nSirStatus )
2269 {
2270 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002271 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 nSirStatus );
2273 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302274 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 return;
2276 }
2277
2278
Abhishek Singh57aebef2014-02-03 18:47:44 +05302279 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002280 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 sizeof(tSirMacMgmtHdr),
2282 nPayload, &nPayload );
2283 if ( DOT11F_FAILED( nStatus ) )
2284 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302285 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002286 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 nStatus );
2288 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2289 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302290 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 return;
2292 }
2293 else if ( DOT11F_WARNED( nStatus ) )
2294 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302295 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2296 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 }
2298
2299 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002300 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002301 nBytes );)
2302 // limPrintMacAddr( pMac, bssid, LOG1 );
2303
2304 if( psessionEntry->assocReq != NULL )
2305 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302306 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 psessionEntry->assocReq = NULL;
2308 }
2309
2310 if( nAddIELen )
2311 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302312 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2313 pAddIE,
2314 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 nPayload += nAddIELen;
2316 }
2317
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302318 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2319 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302321 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2322 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 }
2324 else
2325 {
2326 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302327 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 psessionEntry->assocReqLen = nPayload;
2329 }
2330
2331 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2333 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 )
2335 {
2336 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2337 }
2338
Ganesh K08bce952012-12-13 15:04:41 -08002339 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2340 {
2341 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2342 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302343
2344 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2345 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2346 psessionEntry->peSessionId,
2347 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2349 HAL_TXRX_FRM_802_11_MGMT,
2350 ANI_TXDIR_TODS,
2351 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2352 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302353 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2354 psessionEntry->peSessionId,
2355 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2357 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002358 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 halstatus );
2360 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302361 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 return;
2363 }
2364
2365 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302366 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002367 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302368 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002369 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002370} // End limSendAssocReqMgmtFrame
2371
2372
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002373#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002374/*------------------------------------------------------------------------------------
2375 *
2376 * Send Reassoc Req with FTIEs.
2377 *
2378 *-----------------------------------------------------------------------------------
2379 */
2380void
2381limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2382 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2383{
2384 static tDot11fReAssocRequest frm;
2385 tANI_U16 caps;
2386 tANI_U8 *pFrame;
2387 tSirRetStatus nSirStatus;
2388 tANI_U32 nBytes, nPayload, nStatus;
2389 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2390 void *pPacket;
2391 eHalStatus halstatus;
2392#if defined WLAN_FEATURE_VOWIFI
2393 tANI_U8 PowerCapsPopulated = FALSE;
2394#endif
2395 tANI_U16 ft_ies_length = 0;
2396 tANI_U8 *pBody;
2397 tANI_U16 nAddIELen;
2398 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002399#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 tANI_U8 *wpsIe = NULL;
2401#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302402 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302403 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002404
2405 if (NULL == psessionEntry)
2406 {
2407 return;
2408 }
2409
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 /* check this early to avoid unncessary operation */
2411 if(NULL == psessionEntry->pLimReAssocReq)
2412 {
2413 return;
2414 }
2415 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2416 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002417 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2418 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002419
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302420 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002421
2422 caps = pMlmReassocReq->capabilityInfo;
2423 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2424 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2425#if defined(FEATURE_WLAN_WAPI)
2426 /* CR: 262463 :
2427 According to WAPI standard:
2428 7.3.1.4 Capability Information field
2429 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2430 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2431 Reassociation management frames. */
2432 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2433 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2434#endif
2435 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2436
2437 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2438
2439 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302440 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2442
2443 PopulateDot11fSSID2( pMac, &frm.SSID );
2444 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2445 &frm.SuppRates,psessionEntry);
2446
2447 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2448 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2449
2450 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2451 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2452
2453 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2454 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2455
2456 if ( psessionEntry->lim11hEnable &&
2457 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2458 {
2459#if defined WLAN_FEATURE_VOWIFI
2460 PowerCapsPopulated = TRUE;
2461
2462 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2463 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2464#endif
2465 }
2466
2467#if defined WLAN_FEATURE_VOWIFI
2468 if( pMac->rrm.rrmPEContext.rrmEnable &&
2469 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2470 {
2471 if (PowerCapsPopulated == FALSE)
2472 {
2473 PowerCapsPopulated = TRUE;
2474 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2475 }
2476 }
2477#endif
2478
2479 if ( fQosEnabled &&
2480 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2481 {
2482 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2483 }
2484
2485 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2486 &frm.ExtSuppRates, psessionEntry );
2487
2488#if defined WLAN_FEATURE_VOWIFI
2489 if( pMac->rrm.rrmPEContext.rrmEnable &&
2490 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2491 {
2492 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2493 }
2494#endif
2495
2496 // Ideally this should be enabled for 11r also. But 11r does
2497 // not follow the usual norm of using the Opaque object
2498 // for rsnie and fties. Instead we just add
2499 // the rsnie and fties at the end of the pack routine for 11r.
2500 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002501#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 //
2503 // The join request *should* contain zero or one of the WPA and RSN
2504 // IEs. The payload send along with the request is a
2505 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2506
2507 // typedef struct sSirRSNie
2508 // {
2509 // tANI_U16 length;
2510 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2511 // } tSirRSNie, *tpSirRSNie;
2512
2513 // So, we should be able to make the following two calls harmlessly,
2514 // since they do nothing if they don't find the given IE in the
2515 // bytestream with which they're provided.
2516
2517 // The net effect of this will be to faithfully transmit whatever
2518 // security IE is in the join request.
2519
2520 // *However*, if we're associating for the purpose of WPS
2521 // enrollment, and we've been configured to indicate that by
2522 // eliding the WPA or RSN IE, we just skip this:
2523 if (!psessionEntry->is11Rconnection)
2524 {
2525 if( nAddIELen && pAddIE )
2526 {
2527 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2528 }
2529 if ( NULL == wpsIe )
2530 {
2531 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2532 &frm.RSNOpaque );
2533 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2534 &frm.WPAOpaque );
2535 }
2536
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002537#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302538 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 {
2540 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2541 &frm.CCXCckmOpaque );
2542 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002543#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 }
2545
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002546#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302548 if (psessionEntry->isCCXconnection &&
2549 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002551#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002553#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302554 PopulateDot11fCCXVersion(&frm.CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302556#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002557#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002558
2559 // include WME EDCA IE as well
2560 if ( fWmeEnabled )
2561 {
2562 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2563 {
2564 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2565 }
2566
2567 if ( fWsmEnabled &&
2568 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2569 {
2570 PopulateDot11fWMMCaps( &frm.WMMCaps );
2571 }
2572#ifdef FEATURE_WLAN_CCX
2573 if (psessionEntry->isCCXconnection)
2574 {
2575 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2576
2577 // Populate the TSRS IE if TSPEC is included in the reassoc request
2578 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2579 {
2580 tANI_U32 phyMode;
2581 tSirMacCCXTSRSIE tsrsIE;
2582 limGetPhyMode(pMac, &phyMode, psessionEntry);
2583
2584 tsrsIE.tsid = 0;
2585 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2586 {
2587 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2588 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302589 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 {
2591 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2592 }
2593 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2594 }
2595 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302596#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 }
2598
Jeff Johnsone7245742012-09-05 17:12:55 -07002599 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 pMac->lim.htCapabilityPresentInBeacon)
2601 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002602 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 }
2604
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002605#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302606 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2607#if defined FEATURE_WLAN_CCX
2608 && !psessionEntry->isCCXconnection
2609#endif
2610 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002611 {
2612 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2613 }
2614#endif
2615
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002616#ifdef WLAN_FEATURE_11AC
2617 if ( psessionEntry->vhtCapability &&
2618 psessionEntry->vhtCapabilityPresentInBeacon)
2619 {
2620 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2621 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002622 }
2623#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302624 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002625
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2627 if ( DOT11F_FAILED( nStatus ) )
2628 {
2629 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002630 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 nStatus );
2632 // We'll fall back on the worst case scenario:
2633 nPayload = sizeof( tDot11fReAssocRequest );
2634 }
2635 else if ( DOT11F_WARNED( nStatus ) )
2636 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002637 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002638 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002639 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 }
2641
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002642 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002643
2644#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002645 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002646 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2647#endif
2648
2649#if defined WLAN_FEATURE_VOWIFI_11R
2650 if (psessionEntry->is11Rconnection)
2651 {
2652 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2653 }
2654#endif
2655
2656 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2657 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2658 ( void** ) &pPacket );
2659 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2660 {
2661 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002662 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002664 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 goto end;
2666 }
2667
2668 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302669 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002670
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002671#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002672 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002673#endif
2674 // Next, we fill out the buffer descriptor:
2675 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2676 SIR_MAC_MGMT_REASSOC_REQ,
2677 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2678 if ( eSIR_SUCCESS != nSirStatus )
2679 {
2680 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002681 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 nSirStatus );
2683 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2684 goto end;
2685 }
2686
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302687 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 // That done, pack the ReAssoc Request:
2689 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2690 sizeof(tSirMacMgmtHdr),
2691 nPayload, &nPayload );
2692 if ( DOT11F_FAILED( nStatus ) )
2693 {
2694 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002695 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 nStatus );
2697 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2698 goto end;
2699 }
2700 else if ( DOT11F_WARNED( nStatus ) )
2701 {
2702 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002703 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 }
2705
2706 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002707 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 nBytes, nPayload );)
2709 if( psessionEntry->assocReq != NULL )
2710 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302711 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002712 psessionEntry->assocReq = NULL;
2713 }
2714
2715 if( nAddIELen )
2716 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302717 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2718 pAddIE,
2719 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 nPayload += nAddIELen;
2721 }
2722
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302723 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2724 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 {
2726 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002727 }
2728 else
2729 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302731 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002734
2735 if (psessionEntry->is11Rconnection)
2736 {
2737 {
2738 int i = 0;
2739
2740 pBody = pFrame + nBytes;
2741 for (i=0; i<ft_ies_length; i++)
2742 {
2743 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2744 pBody++;
2745 }
2746 }
2747 }
2748
2749#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002750 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2751 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002752 (tANI_U8 *)pFrame,
2753 (nBytes + ft_ies_length));)
2754#endif
2755
2756
2757 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2759 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 )
2761 {
2762 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2763 }
2764
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002765 if( NULL != psessionEntry->assocReq )
2766 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302767 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002768 psessionEntry->assocReq = NULL;
2769 }
2770
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302771 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2772 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002773 {
2774 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002775 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002776 }
2777 else
2778 {
2779 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302780 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2781 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002782 psessionEntry->assocReqLen = (ft_ies_length);
2783 }
2784
2785
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302786 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2787 psessionEntry->peSessionId,
2788 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2790 HAL_TXRX_FRM_802_11_MGMT,
2791 ANI_TXDIR_TODS,
2792 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2793 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302794 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2795 psessionEntry->peSessionId,
2796 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2798 {
2799 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002800 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 nSirStatus );
2802 //Pkt will be freed up by the callback
2803 goto end;
2804 }
2805
2806end:
2807 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302808 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 psessionEntry->pLimMlmReassocReq = NULL;
2810
2811}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002812
2813void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2814 tLimMlmReassocReq *pMlmReassocReq,
2815 tpPESession psessionEntry)
2816{
2817 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2818 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2819 if(NULL == pTmpMlmReassocReq)
2820 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302821 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2822 if ( NULL == pTmpMlmReassocReq ) goto end;
2823 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2824 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002825 }
2826
2827 // Prepare and send Reassociation request frame
2828 // start reassoc timer.
2829 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2830 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002831 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002832 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2833 != TX_SUCCESS)
2834 {
2835 // Could not start reassoc failure timer.
2836 // Log error
2837 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002838 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002839 // Return Reassoc confirm with
2840 // Resources Unavailable
2841 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2842 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2843 goto end;
2844 }
2845
2846 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2847 return;
2848
2849end:
2850 // Free up buffer allocated for reassocReq
2851 if (pMlmReassocReq != NULL)
2852 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302853 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002854 pMlmReassocReq = NULL;
2855 }
2856 if (pTmpMlmReassocReq != NULL)
2857 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302858 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002859 pTmpMlmReassocReq = NULL;
2860 }
2861 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2862 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2863 /* Update PE sessio Id*/
2864 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2865
2866 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2867}
2868
Jeff Johnson295189b2012-06-20 16:38:30 -07002869#endif /* WLAN_FEATURE_VOWIFI_11R */
2870
2871
2872void
2873limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2874 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2875{
2876 static tDot11fReAssocRequest frm;
2877 tANI_U16 caps;
2878 tANI_U8 *pFrame;
2879 tSirRetStatus nSirStatus;
2880 tANI_U32 nBytes, nPayload, nStatus;
2881 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2882 void *pPacket;
2883 eHalStatus halstatus;
2884 tANI_U16 nAddIELen;
2885 tANI_U8 *pAddIE;
2886 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302887 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002888#if defined WLAN_FEATURE_VOWIFI
2889 tANI_U8 PowerCapsPopulated = FALSE;
2890#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302891 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002892
2893 if(NULL == psessionEntry)
2894 {
2895 return;
2896 }
2897
2898 /* check this early to avoid unncessary operation */
2899 if(NULL == psessionEntry->pLimReAssocReq)
2900 {
2901 return;
2902 }
2903 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2904 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2905
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302906 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002907
2908 caps = pMlmReassocReq->capabilityInfo;
2909 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2910 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2911#if defined(FEATURE_WLAN_WAPI)
2912 /* CR: 262463 :
2913 According to WAPI standard:
2914 7.3.1.4 Capability Information field
2915 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2916 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2917 Reassociation management frames. */
2918 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2919 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2920#endif
2921 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2922
2923 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2924
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302925 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2926 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002927
2928 PopulateDot11fSSID2( pMac, &frm.SSID );
2929 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2930 &frm.SuppRates,psessionEntry);
2931
2932 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2933 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2934
2935 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2936 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2937
2938 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2939 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2940
2941
2942 if ( psessionEntry->lim11hEnable &&
2943 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2944 {
2945#if defined WLAN_FEATURE_VOWIFI
2946 PowerCapsPopulated = TRUE;
2947 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2948 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2949#endif
2950 }
2951
2952#if defined WLAN_FEATURE_VOWIFI
2953 if( pMac->rrm.rrmPEContext.rrmEnable &&
2954 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2955 {
2956 if (PowerCapsPopulated == FALSE)
2957 {
2958 PowerCapsPopulated = TRUE;
2959 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2960 }
2961 }
2962#endif
2963
2964 if ( fQosEnabled &&
2965 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2966 {
2967 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2968 }
2969
2970 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2971 &frm.ExtSuppRates, psessionEntry );
2972
2973#if defined WLAN_FEATURE_VOWIFI
2974 if( pMac->rrm.rrmPEContext.rrmEnable &&
2975 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2976 {
2977 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2978 }
2979#endif
2980 // The join request *should* contain zero or one of the WPA and RSN
2981 // IEs. The payload send along with the request is a
2982 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2983
2984 // typedef struct sSirRSNie
2985 // {
2986 // tANI_U16 length;
2987 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2988 // } tSirRSNie, *tpSirRSNie;
2989
2990 // So, we should be able to make the following two calls harmlessly,
2991 // since they do nothing if they don't find the given IE in the
2992 // bytestream with which they're provided.
2993
2994 // The net effect of this will be to faithfully transmit whatever
2995 // security IE is in the join request.
2996
2997 // *However*, if we're associating for the purpose of WPS
2998 // enrollment, and we've been configured to indicate that by
2999 // eliding the WPA or RSN IE, we just skip this:
3000 if( nAddIELen && pAddIE )
3001 {
3002 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3003 }
3004 if ( NULL == wpsIe )
3005 {
3006 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3007 &frm.RSNOpaque );
3008 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3009 &frm.WPAOpaque );
3010#if defined(FEATURE_WLAN_WAPI)
3011 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3012 &frm.WAPIOpaque );
3013#endif // defined(FEATURE_WLAN_WAPI)
3014 }
3015
3016 // include WME EDCA IE as well
3017 if ( fWmeEnabled )
3018 {
3019 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3020 {
3021 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3022 }
3023
3024 if ( fWsmEnabled &&
3025 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3026 {
3027 PopulateDot11fWMMCaps( &frm.WMMCaps );
3028 }
3029 }
3030
Jeff Johnsone7245742012-09-05 17:12:55 -07003031 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 pMac->lim.htCapabilityPresentInBeacon)
3033 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003034 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003036#ifdef WLAN_FEATURE_11AC
3037 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003038 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003039 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003040 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003041 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303042 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003043 }
3044#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003045
3046 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3047 if ( DOT11F_FAILED( nStatus ) )
3048 {
3049 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003050 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 nStatus );
3052 // We'll fall back on the worst case scenario:
3053 nPayload = sizeof( tDot11fReAssocRequest );
3054 }
3055 else if ( DOT11F_WARNED( nStatus ) )
3056 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003057 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003059 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 }
3061
3062 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3063
3064 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3065 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3066 ( void** ) &pPacket );
3067 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3068 {
3069 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003070 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003072 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 goto end;
3074 }
3075
3076 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303077 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003078
3079 // Next, we fill out the buffer descriptor:
3080 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3081 SIR_MAC_MGMT_REASSOC_REQ,
3082 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3083 if ( eSIR_SUCCESS != nSirStatus )
3084 {
3085 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003086 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 nSirStatus );
3088 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3089 goto end;
3090 }
3091
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303092 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 // That done, pack the Probe Request:
3094 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3095 sizeof(tSirMacMgmtHdr),
3096 nPayload, &nPayload );
3097 if ( DOT11F_FAILED( nStatus ) )
3098 {
3099 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003100 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 nStatus );
3102 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3103 goto end;
3104 }
3105 else if ( DOT11F_WARNED( nStatus ) )
3106 {
3107 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003108 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 }
3110
3111 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003112 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 nBytes );)
3114
3115 if( psessionEntry->assocReq != NULL )
3116 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303117 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 psessionEntry->assocReq = NULL;
3119 }
3120
3121 if( nAddIELen )
3122 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303123 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3124 pAddIE,
3125 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 nPayload += nAddIELen;
3127 }
3128
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303129 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3130 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 {
3132 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003133 }
3134 else
3135 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303137 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003140
3141 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3143 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 )
3145 {
3146 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3147 }
3148
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003149 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003150 {
3151 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3152 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003153
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303154 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3155 psessionEntry->peSessionId,
3156 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3158 HAL_TXRX_FRM_802_11_MGMT,
3159 ANI_TXDIR_TODS,
3160 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3161 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303162 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3163 psessionEntry->peSessionId,
3164 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3166 {
3167 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003168 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 nSirStatus );
3170 //Pkt will be freed up by the callback
3171 goto end;
3172 }
3173
3174end:
3175 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303176 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 psessionEntry->pLimMlmReassocReq = NULL;
3178
3179} // limSendReassocReqMgmtFrame
3180
3181/**
3182 * \brief Send an Authentication frame
3183 *
3184 *
3185 * \param pMac Pointer to Global MAC structure
3186 *
3187 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3188 * to be sent
3189 *
3190 * \param peerMacAddr MAC address of the peer entity to which Authentication
3191 * frame is destined
3192 *
3193 * \param wepBit Indicates whether wep bit to be set in FC while sending
3194 * Authentication frame3
3195 *
3196 *
3197 * This function is called by limProcessMlmMessages(). Authentication frame
3198 * is formatted and sent when this function is called.
3199 *
3200 *
3201 */
3202
3203void
3204limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3205 tpSirMacAuthFrameBody pAuthFrameBody,
3206 tSirMacAddr peerMacAddr,
3207 tANI_U8 wepBit,
3208 tpPESession psessionEntry
3209 )
3210{
3211 tANI_U8 *pFrame, *pBody;
3212 tANI_U32 frameLen = 0, bodyLen = 0;
3213 tpSirMacMgmtHdr pMacHdr;
3214 tANI_U16 i;
3215 void *pPacket;
3216 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303217 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003218
3219 if(NULL == psessionEntry)
3220 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303221 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 return;
3223 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303224
3225 limLog(pMac, LOG1,
3226 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3227 pAuthFrameBody->authTransactionSeqNumber,
3228 pAuthFrameBody->authStatusCode,
3229 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3230 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 if (wepBit == LIM_WEP_IN_FC)
3232 {
3233 /// Auth frame3 to be sent with encrypted framebody
3234 /**
3235 * Allocate buffer for Authenticaton frame of size equal
3236 * to management frame header length plus 2 bytes each for
3237 * auth algorithm number, transaction number, status code,
3238 * 128 bytes for challenge text and 4 bytes each for
3239 * IV & ICV.
3240 */
3241
3242 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3243
3244 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3245 } // if (wepBit == LIM_WEP_IN_FC)
3246 else
3247 {
3248 switch (pAuthFrameBody->authTransactionSeqNumber)
3249 {
3250 case SIR_MAC_AUTH_FRAME_1:
3251 /**
3252 * Allocate buffer for Authenticaton frame of size
3253 * equal to management frame header length plus 2 bytes
3254 * each for auth algorithm number, transaction number
3255 * and status code.
3256 */
3257
3258 frameLen = sizeof(tSirMacMgmtHdr) +
3259 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3260 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3261
3262#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003263 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3264 {
3265 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003267 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003268 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003269 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003271 else
3272 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303273 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3274 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003275 frameLen += (2+SIR_MDIE_SIZE);
3276 }
3277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003278#endif
3279 break;
3280
3281 case SIR_MAC_AUTH_FRAME_2:
3282 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3283 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3284 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3285 {
3286 /**
3287 * Allocate buffer for Authenticaton frame of size
3288 * equal to management frame header length plus
3289 * 2 bytes each for auth algorithm number,
3290 * transaction number and status code.
3291 */
3292
3293 frameLen = sizeof(tSirMacMgmtHdr) +
3294 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3295 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3296 }
3297 else
3298 {
3299 // Shared Key algorithm with challenge text
3300 // to be sent
3301 /**
3302 * Allocate buffer for Authenticaton frame of size
3303 * equal to management frame header length plus
3304 * 2 bytes each for auth algorithm number,
3305 * transaction number, status code and 128 bytes
3306 * for challenge text.
3307 */
3308
3309 frameLen = sizeof(tSirMacMgmtHdr) +
3310 sizeof(tSirMacAuthFrame);
3311 bodyLen = sizeof(tSirMacAuthFrameBody);
3312 }
3313
3314 break;
3315
3316 case SIR_MAC_AUTH_FRAME_3:
3317 /// Auth frame3 to be sent without encrypted framebody
3318 /**
3319 * Allocate buffer for Authenticaton frame of size equal
3320 * to management frame header length plus 2 bytes each
3321 * for auth algorithm number, transaction number and
3322 * status code.
3323 */
3324
3325 frameLen = sizeof(tSirMacMgmtHdr) +
3326 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3327 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3328
3329 break;
3330
3331 case SIR_MAC_AUTH_FRAME_4:
3332 /**
3333 * Allocate buffer for Authenticaton frame of size equal
3334 * to management frame header length plus 2 bytes each
3335 * for auth algorithm number, transaction number and
3336 * status code.
3337 */
3338
3339 frameLen = sizeof(tSirMacMgmtHdr) +
3340 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3341 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3342
3343 break;
3344 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3345 } // end if (wepBit == LIM_WEP_IN_FC)
3346
3347
3348 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3349
3350 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3351 {
3352 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003353 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003354
3355 return;
3356 }
3357
3358 for (i = 0; i < frameLen; i++)
3359 pFrame[i] = 0;
3360
3361 // Prepare BD
3362 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3363 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3364 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303365 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3366 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3368 return;
3369 }
3370
3371 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3372 pMacHdr->fc.wep = wepBit;
3373
3374 // Prepare BSSId
3375 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3376 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303377 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3378 (tANI_U8 *) psessionEntry->bssId,
3379 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 }
3381
3382 /// Prepare Authentication frame body
3383 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3384
3385 if (wepBit == LIM_WEP_IN_FC)
3386 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303387 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003388
3389 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303390 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303392 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3393 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003394
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 }
3396 else
3397 {
3398 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3399 pBody += sizeof(tANI_U16);
3400 bodyLen -= sizeof(tANI_U16);
3401
3402 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3403 pBody += sizeof(tANI_U16);
3404 bodyLen -= sizeof(tANI_U16);
3405
3406 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3407 pBody += sizeof(tANI_U16);
3408 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003409 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3410 sizeof (pAuthFrameBody->length) +
3411 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303412 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003413
3414#if defined WLAN_FEATURE_VOWIFI_11R
3415 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3416 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3417 {
3418
3419 {
3420 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3422 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003423#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003424 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3425 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 (tANI_U8 *)pBody,
3427 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003428#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003429 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3430 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003431 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3432 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003433 }
3434 }
3435 else
3436 {
3437 /* MDID attr is 54*/
3438 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003440 *pBody = SIR_MDIE_SIZE;
3441 pBody++;
3442 for(i=0;i<SIR_MDIE_SIZE;i++)
3443 {
3444 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3445 pBody++;
3446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 }
3448 }
3449 }
3450#endif
3451
3452 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303453 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 pAuthFrameBody->authTransactionSeqNumber,
3455 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303456 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3457 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 }
3459 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3460
3461 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3463 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003464#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303465 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003466 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3467#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 )
3469 {
3470 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3471 }
3472
Ganesh K08bce952012-12-13 15:04:41 -08003473 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3474 {
3475 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3476 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003477
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303478 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3479 psessionEntry->peSessionId,
3480 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 /// Queue Authentication frame in high priority WQ
3482 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3483 HAL_TXRX_FRM_802_11_MGMT,
3484 ANI_TXDIR_TODS,
3485 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3486 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303487 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3488 psessionEntry->peSessionId,
3489 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3491 {
3492 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003493 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 halstatus);
3495
3496 //Pkt will be freed up by the callback
3497 }
3498
3499 return;
3500} /*** end limSendAuthMgmtFrame() ***/
3501
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003502eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3503{
3504 tANI_U16 aid;
3505 tpDphHashNode pStaDs;
3506 tLimMlmDeauthReq *pMlmDeauthReq;
3507 tLimMlmDeauthCnf mlmDeauthCnf;
3508 tpPESession psessionEntry;
3509
3510 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3511 if (pMlmDeauthReq)
3512 {
3513 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3514 {
3515 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3516 }
3517
3518 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3519 {
3520
3521 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003522 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003523 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3524 goto end;
3525 }
3526
3527 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3528 if (pStaDs == NULL)
3529 {
3530 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3531 goto end;
3532 }
3533
3534
3535 /// Receive path cleanup with dummy packet
3536 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3537 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303538 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003539 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3540 }
3541 return eHAL_STATUS_SUCCESS;
3542end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303543 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003544 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3545 sizeof(tSirMacAddr));
3546 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3547 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3548 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3549
3550 // Free up buffer allocated
3551 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303552 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003553
3554 limPostSmeMessage(pMac,
3555 LIM_MLM_DEAUTH_CNF,
3556 (tANI_U32 *) &mlmDeauthCnf);
3557 return eHAL_STATUS_SUCCESS;
3558}
3559
3560eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3561{
3562 tANI_U16 aid;
3563 tpDphHashNode pStaDs;
3564 tLimMlmDisassocCnf mlmDisassocCnf;
3565 tpPESession psessionEntry;
3566 tLimMlmDisassocReq *pMlmDisassocReq;
3567
3568 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3569 if (pMlmDisassocReq)
3570 {
3571 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3572 {
3573 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3574 }
3575
3576 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3577 {
3578
3579 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003580 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003581 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3582 goto end;
3583 }
3584
3585 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3586 if (pStaDs == NULL)
3587 {
3588 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3589 goto end;
3590 }
3591
3592 /// Receive path cleanup with dummy packet
3593 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3594 {
3595 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3596 goto end;
3597 }
3598
3599#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003600 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303601 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003602#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303603 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003604#endif
3605#ifdef FEATURE_WLAN_LFR
3606 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003607#endif
3608 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303609 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003610 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003611 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303612 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003613 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003614 psessionEntry, psessionEntry->peSessionId););
3615 limFTCleanup(pMac);
3616 }
3617 else
3618 {
3619 PELOGE(limLog(pMac, LOGE,
3620 FL("No FT Preauth Session Cleanup in role %d"
3621#ifdef FEATURE_WLAN_CCX
3622 " isCCX %d"
3623#endif
3624#ifdef FEATURE_WLAN_LFR
3625 " isLFR %d"
3626#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003627 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003628 psessionEntry->limSystemRole,
3629#ifdef FEATURE_WLAN_CCX
3630 psessionEntry->isCCXconnection,
3631#endif
3632#ifdef FEATURE_WLAN_LFR
3633 psessionEntry->isFastRoamIniFeatureEnabled,
3634#endif
3635 psessionEntry->is11Rconnection,
3636 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003637 }
3638#endif
3639
3640 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303641 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003642 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3643 return eHAL_STATUS_SUCCESS;
3644 }
3645 else
3646 {
3647 return eHAL_STATUS_SUCCESS;
3648 }
3649end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303650 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003651 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3652 sizeof(tSirMacAddr));
3653 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3654 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3655
3656 /* Update PE session ID*/
3657 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3658
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003659 if(pMlmDisassocReq != NULL)
3660 {
3661 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303662 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003663 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3664 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003665
3666 limPostSmeMessage(pMac,
3667 LIM_MLM_DISASSOC_CNF,
3668 (tANI_U32 *) &mlmDisassocCnf);
3669 return eHAL_STATUS_SUCCESS;
3670}
3671
3672eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3673{
3674 return limSendDisassocCnf(pMac);
3675}
3676
3677eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3678{
3679 return limSendDeauthCnf(pMac);
3680}
3681
Jeff Johnson295189b2012-06-20 16:38:30 -07003682/**
3683 * \brief This function is called to send Disassociate frame.
3684 *
3685 *
3686 * \param pMac Pointer to Global MAC structure
3687 *
3688 * \param nReason Indicates the reason that need to be sent in
3689 * Disassociation frame
3690 *
3691 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3692 * sent
3693 *
3694 *
3695 */
3696
3697void
3698limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3699 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003700 tSirMacAddr peer,
3701 tpPESession psessionEntry,
3702 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003703{
3704 tDot11fDisassociation frm;
3705 tANI_U8 *pFrame;
3706 tSirRetStatus nSirStatus;
3707 tpSirMacMgmtHdr pMacHdr;
3708 tANI_U32 nBytes, nPayload, nStatus;
3709 void *pPacket;
3710 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303711 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003712 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 if(NULL == psessionEntry)
3714 {
3715 return;
3716 }
3717
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303718 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003719
3720 frm.Reason.code = nReason;
3721
3722 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3723 if ( DOT11F_FAILED( nStatus ) )
3724 {
3725 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003726 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 nStatus );
3728 // We'll fall back on the worst case scenario:
3729 nPayload = sizeof( tDot11fDisassociation );
3730 }
3731 else if ( DOT11F_WARNED( nStatus ) )
3732 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003733 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003735 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 }
3737
3738 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3739
3740 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3741 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3742 ( void** ) &pPacket );
3743 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3744 {
3745 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003746 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 return;
3748 }
3749
3750 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303751 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003752
3753 // Next, we fill out the buffer descriptor:
3754 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3755 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3756 if ( eSIR_SUCCESS != nSirStatus )
3757 {
3758 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003759 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 nSirStatus );
3761 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3762 ( void* ) pFrame, ( void* ) pPacket );
3763 return; // just allocated...
3764 }
3765
3766 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3767
3768 // Prepare the BSSID
3769 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3770
Chet Lanctot186b5732013-03-18 10:26:30 -07003771#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003772 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003773#endif
3774
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3776 sizeof(tSirMacMgmtHdr),
3777 nPayload, &nPayload );
3778 if ( DOT11F_FAILED( nStatus ) )
3779 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003780 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 nStatus );
3782 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3783 ( void* ) pFrame, ( void* ) pPacket );
3784 return; // allocated!
3785 }
3786 else if ( DOT11F_WARNED( nStatus ) )
3787 {
3788 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003789 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 }
3791
Abhishek Singhcd09b562013-12-24 16:02:20 +05303792 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
3793 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
3794 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
3795 MAC_ADDR_ARRAY(pMacHdr->da),
3796 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003797
3798 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3800 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 )
3802 {
3803 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3804 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003805
Ganesh K08bce952012-12-13 15:04:41 -08003806 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303807 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3808 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003809 {
3810 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3811 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003812
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303813 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3814 {
3815 /* This frame will be sent on air by firmware,
3816 which will ensure that this frame goes out
3817 even though DEL_STA is sent immediately */
3818 /* Without this for DEL_STA command there is
3819 risk of flushing frame in BTQM queue without
3820 sending on air */
3821 txFlag |= HAL_USE_FW_IN_TX_PATH;
3822 }
3823
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003824 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303826 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3827 psessionEntry->peSessionId,
3828 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003829 // Queue Disassociation frame in high priority WQ
3830 /* get the duration from the request */
3831 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3832 HAL_TXRX_FRM_802_11_MGMT,
3833 ANI_TXDIR_TODS,
3834 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3835 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3836 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303837 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3838 psessionEntry->peSessionId,
3839 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003840 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003841
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003842 if (tx_timer_change(
3843 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3844 != TX_SUCCESS)
3845 {
3846 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003847 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003848 return;
3849 }
3850 else if(TX_SUCCESS != tx_timer_activate(
3851 &pMac->lim.limTimers.gLimDisassocAckTimer))
3852 {
3853 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003854 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003855 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3856 return;
3857 }
3858 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003859 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003860 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303861 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3862 psessionEntry->peSessionId,
3863 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003864 // Queue Disassociation frame in high priority WQ
3865 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3866 HAL_TXRX_FRM_802_11_MGMT,
3867 ANI_TXDIR_TODS,
3868 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3869 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303870 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3871 psessionEntry->peSessionId,
3872 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003873 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3874 {
3875 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003876 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003877 nSirStatus );
3878 //Pkt will be freed up by the callback
3879 return;
3880 }
3881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003882} // End limSendDisassocMgmtFrame.
3883
3884/**
3885 * \brief This function is called to send a Deauthenticate frame
3886 *
3887 *
3888 * \param pMac Pointer to global MAC structure
3889 *
3890 * \param nReason Indicates the reason that need to be sent in the
3891 * Deauthenticate frame
3892 *
3893 * \param peeer address of the STA to which the frame is to be sent
3894 *
3895 *
3896 */
3897
3898void
3899limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3900 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003901 tSirMacAddr peer,
3902 tpPESession psessionEntry,
3903 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003904{
3905 tDot11fDeAuth frm;
3906 tANI_U8 *pFrame;
3907 tSirRetStatus nSirStatus;
3908 tpSirMacMgmtHdr pMacHdr;
3909 tANI_U32 nBytes, nPayload, nStatus;
3910 void *pPacket;
3911 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303912 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003913 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003914#ifdef FEATURE_WLAN_TDLS
3915 tANI_U16 aid;
3916 tpDphHashNode pStaDs;
3917#endif
3918
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 if(NULL == psessionEntry)
3920 {
3921 return;
3922 }
3923
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303924 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003925
3926 frm.Reason.code = nReason;
3927
3928 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3929 if ( DOT11F_FAILED( nStatus ) )
3930 {
3931 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003932 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 nStatus );
3934 // We'll fall back on the worst case scenario:
3935 nPayload = sizeof( tDot11fDeAuth );
3936 }
3937 else if ( DOT11F_WARNED( nStatus ) )
3938 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003939 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003940 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003941 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 }
3943
3944 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3945
3946 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3947 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3948 ( void** ) &pPacket );
3949 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3950 {
3951 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003952 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003953 return;
3954 }
3955
3956 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303957 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003958
3959 // Next, we fill out the buffer descriptor:
3960 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3961 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3962 if ( eSIR_SUCCESS != nSirStatus )
3963 {
3964 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003965 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 nSirStatus );
3967 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3968 ( void* ) pFrame, ( void* ) pPacket );
3969 return; // just allocated...
3970 }
3971
3972 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3973
3974 // Prepare the BSSID
3975 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3976
Chet Lanctot186b5732013-03-18 10:26:30 -07003977#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003978 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003979#endif
3980
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3982 sizeof(tSirMacMgmtHdr),
3983 nPayload, &nPayload );
3984 if ( DOT11F_FAILED( nStatus ) )
3985 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003986 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 nStatus );
3988 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3989 ( void* ) pFrame, ( void* ) pPacket );
3990 return;
3991 }
3992 else if ( DOT11F_WARNED( nStatus ) )
3993 {
3994 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003995 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05303997 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
3998 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
3999 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4000 MAC_ADDR_ARRAY(pMacHdr->da),
4001 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004002
4003 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4005 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 )
4007 {
4008 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4009 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004010
Ganesh K08bce952012-12-13 15:04:41 -08004011 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304012 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4013 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004014 {
4015 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4016 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004017
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304018 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4019 {
4020 /* This frame will be sent on air by firmware,
4021 which will ensure that this frame goes out
4022 even though DEL_STA is sent immediately */
4023 /* Without this for DEL_STA command there is
4024 risk of flushing frame in BTQM queue without
4025 sending on air */
4026 txFlag |= HAL_USE_FW_IN_TX_PATH;
4027 }
4028
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004029#ifdef FEATURE_WLAN_TDLS
4030 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4031#endif
4032
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004033 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304035 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4036 psessionEntry->peSessionId,
4037 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004038 // Queue Disassociation frame in high priority WQ
4039 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4040 HAL_TXRX_FRM_802_11_MGMT,
4041 ANI_TXDIR_TODS,
4042 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4043 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304044 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4045 psessionEntry->peSessionId,
4046 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304047 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004048 {
4049 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304050 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004051 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004052 //Pkt will be freed up by the callback limTxComplete
4053
4054 /*Call limProcessDeauthAckTimeout which will send
4055 * DeauthCnf for this frame
4056 */
4057 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004058 return;
4059 }
4060
4061 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4062
4063 if (tx_timer_change(
4064 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4065 != TX_SUCCESS)
4066 {
4067 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004068 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004069 return;
4070 }
4071 else if(TX_SUCCESS != tx_timer_activate(
4072 &pMac->lim.limTimers.gLimDeauthAckTimer))
4073 {
4074 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004075 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004076 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4077 return;
4078 }
4079 }
4080 else
4081 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304082 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4083 psessionEntry->peSessionId,
4084 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004085#ifdef FEATURE_WLAN_TDLS
4086 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4087 {
4088 // Queue Disassociation frame in high priority WQ
4089 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004090 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004091 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004092 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4093 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004094 }
4095 else
4096 {
4097#endif
4098 // Queue Disassociation frame in high priority WQ
4099 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4100 HAL_TXRX_FRM_802_11_MGMT,
4101 ANI_TXDIR_TODS,
4102 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4103 limTxComplete, pFrame, txFlag );
4104#ifdef FEATURE_WLAN_TDLS
4105 }
4106#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304107 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4108 psessionEntry->peSessionId,
4109 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004110 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4111 {
4112 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004113 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004114 nSirStatus );
4115 //Pkt will be freed up by the callback
4116 return;
4117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 }
4119
4120} // End limSendDeauthMgmtFrame.
4121
4122
4123#ifdef ANI_SUPPORT_11H
4124/**
4125 * \brief Send a Measurement Report Action frame
4126 *
4127 *
4128 * \param pMac Pointer to the global MAC structure
4129 *
4130 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4131 *
4132 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4133 *
4134 *
4135 */
4136
4137tSirRetStatus
4138limSendMeasReportFrame(tpAniSirGlobal pMac,
4139 tpSirMacMeasReqActionFrame pMeasReqFrame,
4140 tSirMacAddr peer)
4141{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304142 tDot11fMeasurementReport frm;
4143 tANI_U8 *pFrame;
4144 tSirRetStatus nSirStatus;
4145 tpSirMacMgmtHdr pMacHdr;
4146 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4147 void *pPacket;
4148 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004149
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304150 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004151
4152 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4153 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4154 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4155
4156 switch ( pMeasReqFrame->measReqIE.measType )
4157 {
4158 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4159 nSirStatus =
4160 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4161 &frm.MeasurementReport );
4162 break;
4163 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4164 nSirStatus =
4165 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4166 &frm.MeasurementReport );
4167 break;
4168 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4169 nSirStatus =
4170 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4171 &frm.MeasurementReport );
4172 break;
4173 default:
4174 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004175 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 pMeasReqFrame->measReqIE.measType );
4177 return eSIR_FAILURE;
4178 }
4179
4180 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4181
4182 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4183 if ( DOT11F_FAILED( nStatus ) )
4184 {
4185 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004186 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 nStatus );
4188 // We'll fall back on the worst case scenario:
4189 nPayload = sizeof( tDot11fMeasurementReport );
4190 }
4191 else if ( DOT11F_WARNED( nStatus ) )
4192 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004193 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004195 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 }
4197
4198 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4199
4200 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4201 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4202 {
4203 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004204 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 return eSIR_FAILURE;
4206 }
4207
4208 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304209 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004210
4211 // Next, we fill out the buffer descriptor:
4212 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4213 SIR_MAC_MGMT_ACTION, peer);
4214 if ( eSIR_SUCCESS != nSirStatus )
4215 {
4216 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004217 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 nSirStatus );
4219 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4220 return eSIR_FAILURE; // just allocated...
4221 }
4222
4223 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4224
4225 nCfg = 6;
4226 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4227 if ( eSIR_SUCCESS != nSirStatus )
4228 {
4229 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004230 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 nSirStatus );
4232 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4233 return eSIR_FAILURE; // just allocated...
4234 }
4235
Chet Lanctot186b5732013-03-18 10:26:30 -07004236#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004237 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004238#endif
4239
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4241 sizeof(tSirMacMgmtHdr),
4242 nPayload, &nPayload );
4243 if ( DOT11F_FAILED( nStatus ) )
4244 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004245 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 nStatus );
4247 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4248 return eSIR_FAILURE; // allocated!
4249 }
4250 else if ( DOT11F_WARNED( nStatus ) )
4251 {
4252 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004253 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 }
4255
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304256 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4257 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4258 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4260 HAL_TXRX_FRM_802_11_MGMT,
4261 ANI_TXDIR_TODS,
4262 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4263 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304264 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4265 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4266 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4268 {
4269 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004270 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 nSirStatus );
4272 //Pkt will be freed up by the callback
4273 return eSIR_FAILURE; // just allocated...
4274 }
4275
4276 return eSIR_SUCCESS;
4277
4278} // End limSendMeasReportFrame.
4279
4280
4281/**
4282 * \brief Send a TPC Request Action frame
4283 *
4284 *
4285 * \param pMac Pointer to the global MAC datastructure
4286 *
4287 * \param peer MAC address to which the frame should be sent
4288 *
4289 *
4290 */
4291
4292void
4293limSendTpcRequestFrame(tpAniSirGlobal pMac,
4294 tSirMacAddr peer)
4295{
4296 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304297 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 tSirRetStatus nSirStatus;
4299 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304300 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4301 void *pPacket;
4302 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004303
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304304 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004305
4306 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4307 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4308 frm.DialogToken.token = 1;
4309 frm.TPCRequest.present = 1;
4310
4311 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4312 if ( DOT11F_FAILED( nStatus ) )
4313 {
4314 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004315 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 nStatus );
4317 // We'll fall back on the worst case scenario:
4318 nPayload = sizeof( tDot11fTPCRequest );
4319 }
4320 else if ( DOT11F_WARNED( nStatus ) )
4321 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004322 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004324 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 }
4326
4327 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4328
4329 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4330 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4331 {
4332 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004333 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 return;
4335 }
4336
4337 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304338 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004339
4340 // Next, we fill out the buffer descriptor:
4341 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4342 SIR_MAC_MGMT_ACTION, peer);
4343 if ( eSIR_SUCCESS != nSirStatus )
4344 {
4345 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004346 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 nSirStatus );
4348 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4349 return; // just allocated...
4350 }
4351
4352 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4353
4354 nCfg = 6;
4355 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4356 if ( eSIR_SUCCESS != nSirStatus )
4357 {
4358 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004359 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 nSirStatus );
4361 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4362 return; // just allocated...
4363 }
4364
Chet Lanctot186b5732013-03-18 10:26:30 -07004365#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004366 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004367#endif
4368
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4370 sizeof(tSirMacMgmtHdr),
4371 nPayload, &nPayload );
4372 if ( DOT11F_FAILED( nStatus ) )
4373 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004374 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 nStatus );
4376 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4377 return; // allocated!
4378 }
4379 else if ( DOT11F_WARNED( nStatus ) )
4380 {
4381 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004382 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 }
4384
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304385 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4386 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4387 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4389 HAL_TXRX_FRM_802_11_MGMT,
4390 ANI_TXDIR_TODS,
4391 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4392 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304393 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4394 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4395 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4397 {
4398 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004399 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 nSirStatus );
4401 //Pkt will be freed up by the callback
4402 return;
4403 }
4404
4405} // End limSendTpcRequestFrame.
4406
4407
4408/**
4409 * \brief Send a TPC Report Action frame
4410 *
4411 *
4412 * \param pMac Pointer to the global MAC datastructure
4413 *
4414 * \param pTpcReqFrame Pointer to the received TPC Request
4415 *
4416 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4417 *
4418 *
4419 */
4420
4421tSirRetStatus
4422limSendTpcReportFrame(tpAniSirGlobal pMac,
4423 tpSirMacTpcReqActionFrame pTpcReqFrame,
4424 tSirMacAddr peer)
4425{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304426 tDot11fTPCReport frm;
4427 tANI_U8 *pFrame;
4428 tSirRetStatus nSirStatus;
4429 tpSirMacMgmtHdr pMacHdr;
4430 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4431 void *pPacket;
4432 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004433
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304434 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004435
4436 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4437 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4438 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4439
4440 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4441 // "misplaced this function, need to replace:
4442 // txPower = halGetRateToPwrValue(pMac, staid,
4443 // pMac->lim.gLimCurrentChannelId, 0);
4444 frm.TPCReport.tx_power = 0;
4445 frm.TPCReport.link_margin = 0;
4446 frm.TPCReport.present = 1;
4447
4448 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4449 if ( DOT11F_FAILED( nStatus ) )
4450 {
4451 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004452 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 nStatus );
4454 // We'll fall back on the worst case scenario:
4455 nPayload = sizeof( tDot11fTPCReport );
4456 }
4457 else if ( DOT11F_WARNED( nStatus ) )
4458 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004459 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004461 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 }
4463
4464 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4465
4466 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4467 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4468 {
4469 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004470 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 return eSIR_FAILURE;
4472 }
4473
4474 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304475 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004476
4477 // Next, we fill out the buffer descriptor:
4478 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4479 SIR_MAC_MGMT_ACTION, peer);
4480 if ( eSIR_SUCCESS != nSirStatus )
4481 {
4482 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004483 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 nSirStatus );
4485 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4486 return eSIR_FAILURE; // just allocated...
4487 }
4488
4489 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4490
4491 nCfg = 6;
4492 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4493 if ( eSIR_SUCCESS != nSirStatus )
4494 {
4495 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004496 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 nSirStatus );
4498 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4499 return eSIR_FAILURE; // just allocated...
4500 }
4501
Chet Lanctot186b5732013-03-18 10:26:30 -07004502#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004503 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004504#endif
4505
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4507 sizeof(tSirMacMgmtHdr),
4508 nPayload, &nPayload );
4509 if ( DOT11F_FAILED( nStatus ) )
4510 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004511 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 nStatus );
4513 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4514 return eSIR_FAILURE; // allocated!
4515 }
4516 else if ( DOT11F_WARNED( nStatus ) )
4517 {
4518 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004519 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 }
4521
4522
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304523 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4524 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4525 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4527 HAL_TXRX_FRM_802_11_MGMT,
4528 ANI_TXDIR_TODS,
4529 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4530 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304531 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4532 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4533 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4535 {
4536 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004537 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 nSirStatus );
4539 //Pkt will be freed up by the callback
4540 return eSIR_FAILURE; // just allocated...
4541 }
4542
4543 return eSIR_SUCCESS;
4544
4545} // End limSendTpcReportFrame.
4546#endif //ANI_SUPPORT_11H
4547
4548
Jeff Johnson295189b2012-06-20 16:38:30 -07004549/**
4550 * \brief Send a Channel Switch Announcement
4551 *
4552 *
4553 * \param pMac Pointer to the global MAC datastructure
4554 *
4555 * \param peer MAC address to which this frame will be sent
4556 *
4557 * \param nMode
4558 *
4559 * \param nNewChannel
4560 *
4561 * \param nCount
4562 *
4563 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4564 *
4565 *
4566 */
4567
4568tSirRetStatus
4569limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4570 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004571 tANI_U8 nMode,
4572 tANI_U8 nNewChannel,
4573 tANI_U8 nCount,
4574 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004575{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304576 tDot11fChannelSwitch frm;
4577 tANI_U8 *pFrame;
4578 tSirRetStatus nSirStatus;
4579 tpSirMacMgmtHdr pMacHdr;
4580 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4581 void *pPacket;
4582 eHalStatus halstatus;
4583 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004584
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304585 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004586
4587 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4588 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4589 frm.ChanSwitchAnn.switchMode = nMode;
4590 frm.ChanSwitchAnn.newChannel = nNewChannel;
4591 frm.ChanSwitchAnn.switchCount = nCount;
4592 frm.ChanSwitchAnn.present = 1;
4593
4594 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4595 if ( DOT11F_FAILED( nStatus ) )
4596 {
4597 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004598 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 nStatus );
4600 // We'll fall back on the worst case scenario:
4601 nPayload = sizeof( tDot11fChannelSwitch );
4602 }
4603 else if ( DOT11F_WARNED( nStatus ) )
4604 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004605 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004607 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 }
4609
4610 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4611
4612 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4613 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4614 {
4615 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004616 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 return eSIR_FAILURE;
4618 }
4619
4620 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304621 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004622
4623 // Next, we fill out the buffer descriptor:
4624 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004625 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4626 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304627 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4628 (tANI_U8 *) psessionEntry->bssId,
4629 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 if ( eSIR_SUCCESS != nSirStatus )
4631 {
4632 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004633 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 nSirStatus );
4635 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4636 return eSIR_FAILURE; // just allocated...
4637 }
4638
Jeff Johnsone7245742012-09-05 17:12:55 -07004639#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4641
4642 nCfg = 6;
4643 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4644 if ( eSIR_SUCCESS != nSirStatus )
4645 {
4646 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004647 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 nSirStatus );
4649 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4650 return eSIR_FAILURE; // just allocated...
4651 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004652#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004653
4654#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004655 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004656#endif
4657
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4659 sizeof(tSirMacMgmtHdr),
4660 nPayload, &nPayload );
4661 if ( DOT11F_FAILED( nStatus ) )
4662 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004663 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 nStatus );
4665 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4666 return eSIR_FAILURE; // allocated!
4667 }
4668 else if ( DOT11F_WARNED( nStatus ) )
4669 {
4670 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004671 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 }
4673
Jeff Johnsone7245742012-09-05 17:12:55 -07004674 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004675 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4676 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004677 )
4678 {
4679 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4680 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304681
4682 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4683 psessionEntry->peSessionId,
4684 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4686 HAL_TXRX_FRM_802_11_MGMT,
4687 ANI_TXDIR_TODS,
4688 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004689 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304690 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4691 psessionEntry->peSessionId,
4692 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4694 {
4695 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004696 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 nSirStatus );
4698 //Pkt will be freed up by the callback
4699 return eSIR_FAILURE;
4700 }
4701
4702 return eSIR_SUCCESS;
4703
4704} // End limSendChannelSwitchMgmtFrame.
4705
Jeff Johnson295189b2012-06-20 16:38:30 -07004706
4707
Mohit Khanna4a70d262012-09-11 16:30:12 -07004708#ifdef WLAN_FEATURE_11AC
4709tSirRetStatus
4710limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4711 tSirMacAddr peer,
4712 tANI_U8 nMode,
4713 tpPESession psessionEntry )
4714{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304715 tDot11fOperatingMode frm;
4716 tANI_U8 *pFrame;
4717 tSirRetStatus nSirStatus;
4718 tpSirMacMgmtHdr pMacHdr;
4719 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4720 void *pPacket;
4721 eHalStatus halstatus;
4722 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07004723
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304724 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004725
4726 frm.Category.category = SIR_MAC_ACTION_VHT;
4727 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4728 frm.OperatingMode.chanWidth = nMode;
4729 frm.OperatingMode.rxNSS = 0;
4730 frm.OperatingMode.rxNSSType = 0;
4731
4732 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4733 if ( DOT11F_FAILED( nStatus ) )
4734 {
4735 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004736 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004737 nStatus );
4738 // We'll fall back on the worst case scenario:
4739 nPayload = sizeof( tDot11fOperatingMode);
4740 }
4741 else if ( DOT11F_WARNED( nStatus ) )
4742 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004743 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004744 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004745 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004746 }
4747
4748 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4749
4750 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4751 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4752 {
4753 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004754 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004755 return eSIR_FAILURE;
4756 }
4757
4758 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304759 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004760
4761
4762 // Next, we fill out the buffer descriptor:
4763 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4764 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4765 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4766 } else
4767 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4768 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4769 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304770 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4771 (tANI_U8 *) psessionEntry->bssId,
4772 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004773 if ( eSIR_SUCCESS != nSirStatus )
4774 {
4775 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004776 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004777 nSirStatus );
4778 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4779 return eSIR_FAILURE; // just allocated...
4780 }
4781 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4782 sizeof(tSirMacMgmtHdr),
4783 nPayload, &nPayload );
4784 if ( DOT11F_FAILED( nStatus ) )
4785 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004786 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004787 nStatus );
4788 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4789 return eSIR_FAILURE; // allocated!
4790 }
4791 else if ( DOT11F_WARNED( nStatus ) )
4792 {
4793 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004794 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004795 }
4796 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004797 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4798 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004799 )
4800 {
4801 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4802 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304803
4804 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4805 psessionEntry->peSessionId,
4806 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004807 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4808 HAL_TXRX_FRM_802_11_MGMT,
4809 ANI_TXDIR_TODS,
4810 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4811 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304812 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4813 psessionEntry->peSessionId,
4814 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004815 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4816 {
4817 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004818 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004819 nSirStatus );
4820 //Pkt will be freed up by the callback
4821 return eSIR_FAILURE;
4822 }
4823
4824 return eSIR_SUCCESS;
4825}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004826
4827/**
4828 * \brief Send a VHT Channel Switch Announcement
4829 *
4830 *
4831 * \param pMac Pointer to the global MAC datastructure
4832 *
4833 * \param peer MAC address to which this frame will be sent
4834 *
4835 * \param nChanWidth
4836 *
4837 * \param nNewChannel
4838 *
4839 *
4840 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4841 *
4842 *
4843 */
4844
4845tSirRetStatus
4846limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4847 tSirMacAddr peer,
4848 tANI_U8 nChanWidth,
4849 tANI_U8 nNewChannel,
4850 tANI_U8 ncbMode,
4851 tpPESession psessionEntry )
4852{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304853 tDot11fChannelSwitch frm;
4854 tANI_U8 *pFrame;
4855 tSirRetStatus nSirStatus;
4856 tpSirMacMgmtHdr pMacHdr;
4857 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4858 void *pPacket;
4859 eHalStatus halstatus;
4860 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004861
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304862 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004863
4864
4865 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4866 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4867 frm.ChanSwitchAnn.switchMode = 1;
4868 frm.ChanSwitchAnn.newChannel = nNewChannel;
4869 frm.ChanSwitchAnn.switchCount = 1;
4870 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4871 frm.ExtChanSwitchAnn.present = 1;
4872 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4873 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4874 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4875 frm.ChanSwitchAnn.present = 1;
4876 frm.WiderBWChanSwitchAnn.present = 1;
4877
4878 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4879 if ( DOT11F_FAILED( nStatus ) )
4880 {
4881 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004882 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004883 nStatus );
4884 // We'll fall back on the worst case scenario:
4885 nPayload = sizeof( tDot11fChannelSwitch );
4886 }
4887 else if ( DOT11F_WARNED( nStatus ) )
4888 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004889 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004890 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004891 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004892 }
4893
4894 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4895
4896 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4897 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4898 {
4899 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004900 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004901 return eSIR_FAILURE;
4902 }
4903 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304904 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004905
4906 // Next, we fill out the buffer descriptor:
4907 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4908 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4909 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304910 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4911 (tANI_U8 *) psessionEntry->bssId,
4912 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004913 if ( eSIR_SUCCESS != nSirStatus )
4914 {
4915 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004916 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004917 nSirStatus );
4918 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4919 return eSIR_FAILURE; // just allocated...
4920 }
4921 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4922 sizeof(tSirMacMgmtHdr),
4923 nPayload, &nPayload );
4924 if ( DOT11F_FAILED( nStatus ) )
4925 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004926 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004927 nStatus );
4928 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4929 return eSIR_FAILURE; // allocated!
4930 }
4931 else if ( DOT11F_WARNED( nStatus ) )
4932 {
4933 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004934 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004935 }
4936
4937 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004938 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4939 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004940 )
4941 {
4942 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4943 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304944
4945 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4946 psessionEntry->peSessionId,
4947 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004948 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4949 HAL_TXRX_FRM_802_11_MGMT,
4950 ANI_TXDIR_TODS,
4951 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4952 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304953 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4954 psessionEntry->peSessionId,
4955 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004956 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4957 {
4958 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004959 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004960 nSirStatus );
4961 //Pkt will be freed up by the callback
4962 return eSIR_FAILURE;
4963 }
4964
4965 return eSIR_SUCCESS;
4966
4967} // End limSendVHTChannelSwitchMgmtFrame.
4968
4969
4970
Mohit Khanna4a70d262012-09-11 16:30:12 -07004971#endif
4972
Jeff Johnson295189b2012-06-20 16:38:30 -07004973/**
4974 * \brief Send an ADDBA Req Action Frame to peer
4975 *
4976 * \sa limSendAddBAReq
4977 *
4978 * \param pMac The global tpAniSirGlobal object
4979 *
4980 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4981 * the necessary parameters reqd by PE send the ADDBA Req Action
4982 * Frame to the peer
4983 *
4984 * \return eSIR_SUCCESS if setup completes successfully
4985 * eSIR_FAILURE is some problem is encountered
4986 */
4987tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304988 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004989{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304990 tDot11fAddBAReq frmAddBAReq;
4991 tANI_U8 *pAddBAReqBuffer = NULL;
4992 tpSirMacMgmtHdr pMacHdr;
4993 tANI_U32 frameLen = 0, nStatus, nPayload;
4994 tSirRetStatus statusCode;
4995 eHalStatus halStatus;
4996 void *pPacket;
4997 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004998
4999 if(NULL == psessionEntry)
5000 {
5001 return eSIR_FAILURE;
5002 }
5003
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305004 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005005
5006 // Category - 3 (BA)
5007 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5008
5009 // Action - 0 (ADDBA Req)
5010 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5011
5012 // FIXME - Dialog Token, generalize this...
5013 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5014
5015 // Fill the ADDBA Parameter Set
5016 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5017 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5018 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5019
5020 // BA timeout
5021 // 0 - indicates no BA timeout
5022 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5023
5024 // BA Starting Sequence Number
5025 // Fragment number will always be zero
5026 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5027 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5028 }
5029
5030 frmAddBAReq.BAStartingSequenceControl.ssn =
5031 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5032
5033 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5034
5035 if( DOT11F_FAILED( nStatus ))
5036 {
5037 limLog( pMac, LOGW,
5038 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005039 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 nStatus );
5041
5042 // We'll fall back on the worst case scenario:
5043 nPayload = sizeof( tDot11fAddBAReq );
5044 }
5045 else if( DOT11F_WARNED( nStatus ))
5046 {
5047 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005048 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005049 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 nStatus );
5051 }
5052
5053 // Add the MGMT header to frame length
5054 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5055
5056 // Need to allocate a buffer for ADDBA AF
5057 if( eHAL_STATUS_SUCCESS !=
5058 (halStatus = palPktAlloc( pMac->hHdd,
5059 HAL_TXRX_FRM_802_11_MGMT,
5060 (tANI_U16) frameLen,
5061 (void **) &pAddBAReqBuffer,
5062 (void **) &pPacket )))
5063 {
5064 // Log error
5065 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005066 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 frameLen,
5068 halStatus );
5069
5070 statusCode = eSIR_MEM_ALLOC_FAILED;
5071 goto returnAfterError;
5072 }
5073
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305074 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005075
5076 // Copy necessary info to BD
5077 if( eSIR_SUCCESS !=
5078 (statusCode = limPopulateMacHeader( pMac,
5079 pAddBAReqBuffer,
5080 SIR_MAC_MGMT_FRAME,
5081 SIR_MAC_MGMT_ACTION,
5082 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5083 goto returnAfterError;
5084
5085 // Update A3 with the BSSID
5086 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5087
5088 #if 0
5089 cfgLen = SIR_MAC_ADDR_LENGTH;
5090 if( eSIR_SUCCESS != cfgGetStr( pMac,
5091 WNI_CFG_BSSID,
5092 (tANI_U8 *) pMacHdr->bssId,
5093 &cfgLen ))
5094 {
5095 limLog( pMac, LOGP,
5096 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005097 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005098
5099 // FIXME - Need to convert to tSirRetStatus
5100 statusCode = eSIR_FAILURE;
5101 goto returnAfterError;
5102 }
5103 #endif//TO SUPPORT BT-AMP
5104 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5105
Chet Lanctot186b5732013-03-18 10:26:30 -07005106#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005107 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005108#endif
5109
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 // Now, we're ready to "pack" the frames
5111 nStatus = dot11fPackAddBAReq( pMac,
5112 &frmAddBAReq,
5113 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5114 nPayload,
5115 &nPayload );
5116
5117 if( DOT11F_FAILED( nStatus ))
5118 {
5119 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005120 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 nStatus );
5122
5123 // FIXME - Need to convert to tSirRetStatus
5124 statusCode = eSIR_FAILURE;
5125 goto returnAfterError;
5126 }
5127 else if( DOT11F_WARNED( nStatus ))
5128 {
5129 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005130 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5131 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 }
5133
5134 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005135 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005136 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5137
5138 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005139 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5140 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005141 )
5142 {
5143 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5144 }
5145
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305146 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5147 psessionEntry->peSessionId,
5148 pMacHdr->fc.subType));
5149 halStatus = halTxFrame( pMac,
5150 pPacket,
5151 (tANI_U16) frameLen,
5152 HAL_TXRX_FRM_802_11_MGMT,
5153 ANI_TXDIR_TODS,
5154 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5155 limTxComplete,
5156 pAddBAReqBuffer, txFlag );
5157 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5158 psessionEntry->peSessionId,
5159 halStatus));
5160 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 {
5162 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005163 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 halStatus );
5165
5166 // FIXME - Need to convert eHalStatus to tSirRetStatus
5167 statusCode = eSIR_FAILURE;
5168 //Pkt will be freed up by the callback
5169 return statusCode;
5170 }
5171 else
5172 return eSIR_SUCCESS;
5173
5174returnAfterError:
5175
5176 // Release buffer, if allocated
5177 if( NULL != pAddBAReqBuffer )
5178 palPktFree( pMac->hHdd,
5179 HAL_TXRX_FRM_802_11_MGMT,
5180 (void *) pAddBAReqBuffer,
5181 (void *) pPacket );
5182
5183 return statusCode;
5184}
5185
5186/**
5187 * \brief Send an ADDBA Rsp Action Frame to peer
5188 *
5189 * \sa limSendAddBARsp
5190 *
5191 * \param pMac The global tpAniSirGlobal object
5192 *
5193 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5194 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5195 * Frame to the peer
5196 *
5197 * \return eSIR_SUCCESS if setup completes successfully
5198 * eSIR_FAILURE is some problem is encountered
5199 */
5200tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5201 tpLimMlmAddBARsp pMlmAddBARsp,
5202 tpPESession psessionEntry)
5203{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305204 tDot11fAddBARsp frmAddBARsp;
5205 tANI_U8 *pAddBARspBuffer = NULL;
5206 tpSirMacMgmtHdr pMacHdr;
5207 tANI_U32 frameLen = 0, nStatus, nPayload;
5208 tSirRetStatus statusCode;
5209 eHalStatus halStatus;
5210 void *pPacket;
5211 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005212
5213 if(NULL == psessionEntry)
5214 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005215 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 return eSIR_FAILURE;
5217 }
5218
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305219 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005220
5221 // Category - 3 (BA)
5222 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5223 // Action - 1 (ADDBA Rsp)
5224 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5225
5226 // Should be same as the one we received in the ADDBA Req
5227 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5228
5229 // ADDBA Req status
5230 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5231
5232 // Fill the ADDBA Parameter Set as provided by caller
5233 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5234 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5235 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005236
5237 if(psessionEntry->isAmsduSupportInAMPDU)
5238 {
5239 frmAddBARsp.AddBAParameterSet.amsduSupported =
5240 psessionEntry->amsduSupportedInBA;
5241 }
5242 else
5243 {
5244 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005246
5247 // BA timeout
5248 // 0 - indicates no BA timeout
5249 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5250
5251 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5252
5253 if( DOT11F_FAILED( nStatus ))
5254 {
5255 limLog( pMac, LOGW,
5256 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005257 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005258 nStatus );
5259
5260 // We'll fall back on the worst case scenario:
5261 nPayload = sizeof( tDot11fAddBARsp );
5262 }
5263 else if( DOT11F_WARNED( nStatus ))
5264 {
5265 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005266 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005267 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 nStatus );
5269 }
5270
5271 // Need to allocate a buffer for ADDBA AF
5272 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5273
5274 // Allocate shared memory
5275 if( eHAL_STATUS_SUCCESS !=
5276 (halStatus = palPktAlloc( pMac->hHdd,
5277 HAL_TXRX_FRM_802_11_MGMT,
5278 (tANI_U16) frameLen,
5279 (void **) &pAddBARspBuffer,
5280 (void **) &pPacket )))
5281 {
5282 // Log error
5283 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005284 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 frameLen,
5286 halStatus );
5287
5288 statusCode = eSIR_MEM_ALLOC_FAILED;
5289 goto returnAfterError;
5290 }
5291
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305292 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005293
5294 // Copy necessary info to BD
5295 if( eSIR_SUCCESS !=
5296 (statusCode = limPopulateMacHeader( pMac,
5297 pAddBARspBuffer,
5298 SIR_MAC_MGMT_FRAME,
5299 SIR_MAC_MGMT_ACTION,
5300 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5301 goto returnAfterError;
5302
5303 // Update A3 with the BSSID
5304
5305 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5306
5307 #if 0
5308 cfgLen = SIR_MAC_ADDR_LENGTH;
5309 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5310 WNI_CFG_BSSID,
5311 (tANI_U8 *) pMacHdr->bssId,
5312 &cfgLen ))
5313 {
5314 limLog( pMac, LOGP,
5315 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005316 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005317
5318 // FIXME - Need to convert to tSirRetStatus
5319 statusCode = eSIR_FAILURE;
5320 goto returnAfterError;
5321 }
5322 #endif // TO SUPPORT BT-AMP
5323 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5324
Chet Lanctot186b5732013-03-18 10:26:30 -07005325#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005326 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005327#endif
5328
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 // Now, we're ready to "pack" the frames
5330 nStatus = dot11fPackAddBARsp( pMac,
5331 &frmAddBARsp,
5332 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5333 nPayload,
5334 &nPayload );
5335
5336 if( DOT11F_FAILED( nStatus ))
5337 {
5338 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005339 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 nStatus );
5341
5342 // FIXME - Need to convert to tSirRetStatus
5343 statusCode = eSIR_FAILURE;
5344 goto returnAfterError;
5345 }
5346 else if( DOT11F_WARNED( nStatus ))
5347 {
5348 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005349 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5350 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 }
5352
5353 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005354 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005355 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5356
5357 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5359 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 )
5361 {
5362 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5363 }
5364
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305365 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5366 psessionEntry->peSessionId,
5367 pMacHdr->fc.subType));
5368 halStatus = halTxFrame( pMac,
5369 pPacket,
5370 (tANI_U16) frameLen,
5371 HAL_TXRX_FRM_802_11_MGMT,
5372 ANI_TXDIR_TODS,
5373 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5374 limTxComplete,
5375 pAddBARspBuffer, txFlag );
5376 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5377 psessionEntry->peSessionId,
5378 halStatus));
5379 if( eHAL_STATUS_SUCCESS != halStatus )
5380 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005382 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 halStatus );
5384
5385 // FIXME - HAL error codes are different from PE error
5386 // codes!! And, this routine is returning tSirRetStatus
5387 statusCode = eSIR_FAILURE;
5388 //Pkt will be freed up by the callback
5389 return statusCode;
5390 }
5391 else
5392 return eSIR_SUCCESS;
5393
5394 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 // Release buffer, if allocated
5396 if( NULL != pAddBARspBuffer )
5397 palPktFree( pMac->hHdd,
5398 HAL_TXRX_FRM_802_11_MGMT,
5399 (void *) pAddBARspBuffer,
5400 (void *) pPacket );
5401
5402 return statusCode;
5403}
5404
5405/**
5406 * \brief Send a DELBA Indication Action Frame to peer
5407 *
5408 * \sa limSendDelBAInd
5409 *
5410 * \param pMac The global tpAniSirGlobal object
5411 *
5412 * \param peerMacAddr MAC Address of peer
5413 *
5414 * \param reasonCode Reason for the DELBA notification
5415 *
5416 * \param pBAParameterSet The DELBA Parameter Set.
5417 * This identifies the TID for which the BA session is
5418 * being deleted.
5419 *
5420 * \return eSIR_SUCCESS if setup completes successfully
5421 * eSIR_FAILURE is some problem is encountered
5422 */
5423tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5424 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5425{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305426 tDot11fDelBAInd frmDelBAInd;
5427 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305429 tpSirMacMgmtHdr pMacHdr;
5430 tANI_U32 frameLen = 0, nStatus, nPayload;
5431 tSirRetStatus statusCode;
5432 eHalStatus halStatus;
5433 void *pPacket;
5434 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005435
5436 if(NULL == psessionEntry)
5437 {
5438 return eSIR_FAILURE;
5439 }
5440
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305441 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005442
5443 // Category - 3 (BA)
5444 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5445 // Action - 2 (DELBA)
5446 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5447
5448 // Fill the DELBA Parameter Set as provided by caller
5449 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5450 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5451
5452 // BA Starting Sequence Number
5453 // Fragment number will always be zero
5454 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5455
5456 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5457
5458 if( DOT11F_FAILED( nStatus ))
5459 {
5460 limLog( pMac, LOGW,
5461 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005462 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 nStatus );
5464
5465 // We'll fall back on the worst case scenario:
5466 nPayload = sizeof( tDot11fDelBAInd );
5467 }
5468 else if( DOT11F_WARNED( nStatus ))
5469 {
5470 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005471 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005472 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 nStatus );
5474 }
5475
5476 // Add the MGMT header to frame length
5477 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5478
5479 // Allocate shared memory
5480 if( eHAL_STATUS_SUCCESS !=
5481 (halStatus = palPktAlloc( pMac->hHdd,
5482 HAL_TXRX_FRM_802_11_MGMT,
5483 (tANI_U16) frameLen,
5484 (void **) &pDelBAIndBuffer,
5485 (void **) &pPacket )))
5486 {
5487 // Log error
5488 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005489 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 frameLen,
5491 halStatus );
5492
5493 statusCode = eSIR_MEM_ALLOC_FAILED;
5494 goto returnAfterError;
5495 }
5496
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305497 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005498
5499 // Copy necessary info to BD
5500 if( eSIR_SUCCESS !=
5501 (statusCode = limPopulateMacHeader( pMac,
5502 pDelBAIndBuffer,
5503 SIR_MAC_MGMT_FRAME,
5504 SIR_MAC_MGMT_ACTION,
5505 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5506 goto returnAfterError;
5507
5508 // Update A3 with the BSSID
5509 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5510
5511 #if 0
5512 cfgLen = SIR_MAC_ADDR_LENGTH;
5513 if( eSIR_SUCCESS != cfgGetStr( pMac,
5514 WNI_CFG_BSSID,
5515 (tANI_U8 *) pMacHdr->bssId,
5516 &cfgLen ))
5517 {
5518 limLog( pMac, LOGP,
5519 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005520 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005521
5522 // FIXME - Need to convert to tSirRetStatus
5523 statusCode = eSIR_FAILURE;
5524 goto returnAfterError;
5525 }
5526 #endif //TO SUPPORT BT-AMP
5527 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5528
Chet Lanctot186b5732013-03-18 10:26:30 -07005529#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005530 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005531#endif
5532
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 // Now, we're ready to "pack" the frames
5534 nStatus = dot11fPackDelBAInd( pMac,
5535 &frmDelBAInd,
5536 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5537 nPayload,
5538 &nPayload );
5539
5540 if( DOT11F_FAILED( nStatus ))
5541 {
5542 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005543 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 nStatus );
5545
5546 // FIXME - Need to convert to tSirRetStatus
5547 statusCode = eSIR_FAILURE;
5548 goto returnAfterError;
5549 }
5550 else if( DOT11F_WARNED( nStatus ))
5551 {
5552 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005553 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5554 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 }
5556
5557 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005558 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5560
5561 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5563 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 )
5565 {
5566 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5567 }
5568
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305569 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5570 psessionEntry->peSessionId,
5571 pMacHdr->fc.subType));
5572 halStatus = halTxFrame( pMac,
5573 pPacket,
5574 (tANI_U16) frameLen,
5575 HAL_TXRX_FRM_802_11_MGMT,
5576 ANI_TXDIR_TODS,
5577 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5578 limTxComplete,
5579 pDelBAIndBuffer, txFlag );
5580 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5581 psessionEntry->peSessionId,
5582 halStatus));
5583 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005585 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005586 statusCode = eSIR_FAILURE;
5587 //Pkt will be freed up by the callback
5588 return statusCode;
5589 }
5590 else
5591 return eSIR_SUCCESS;
5592
5593 returnAfterError:
5594
5595 // Release buffer, if allocated
5596 if( NULL != pDelBAIndBuffer )
5597 palPktFree( pMac->hHdd,
5598 HAL_TXRX_FRM_802_11_MGMT,
5599 (void *) pDelBAIndBuffer,
5600 (void *) pPacket );
5601
5602 return statusCode;
5603}
5604
5605#if defined WLAN_FEATURE_VOWIFI
5606
5607/**
5608 * \brief Send a Neighbor Report Request Action frame
5609 *
5610 *
5611 * \param pMac Pointer to the global MAC structure
5612 *
5613 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5614 *
5615 * \param peer mac address of peer station.
5616 *
5617 * \param psessionEntry address of session entry.
5618 *
5619 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5620 *
5621 *
5622 */
5623
5624tSirRetStatus
5625limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5626 tpSirMacNeighborReportReq pNeighborReq,
5627 tSirMacAddr peer,
5628 tpPESession psessionEntry
5629 )
5630{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305631 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 tDot11fNeighborReportRequest frm;
5633 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305634 tpSirMacMgmtHdr pMacHdr;
5635 tANI_U32 nBytes, nPayload, nStatus;
5636 void *pPacket;
5637 eHalStatus halstatus;
5638 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005639
5640 if ( psessionEntry == NULL )
5641 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005642 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 return eSIR_FAILURE;
5644 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305645 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005646
5647 frm.Category.category = SIR_MAC_ACTION_RRM;
5648 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5649 frm.DialogToken.token = pNeighborReq->dialogToken;
5650
5651
5652 if( pNeighborReq->ssid_present )
5653 {
5654 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5655 }
5656
5657 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5658 if ( DOT11F_FAILED( nStatus ) )
5659 {
5660 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005661 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 nStatus );
5663 // We'll fall back on the worst case scenario:
5664 nPayload = sizeof( tDot11fNeighborReportRequest );
5665 }
5666 else if ( DOT11F_WARNED( nStatus ) )
5667 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005668 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005670 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 }
5672
5673 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5674
5675 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5676 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5677 {
5678 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005679 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 return eSIR_FAILURE;
5681 }
5682
5683 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305684 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005685
5686 // Copy necessary info to BD
5687 if( eSIR_SUCCESS !=
5688 (statusCode = limPopulateMacHeader( pMac,
5689 pFrame,
5690 SIR_MAC_MGMT_FRAME,
5691 SIR_MAC_MGMT_ACTION,
5692 peer, psessionEntry->selfMacAddr)))
5693 goto returnAfterError;
5694
5695 // Update A3 with the BSSID
5696 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5697
5698 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5699
Chet Lanctot186b5732013-03-18 10:26:30 -07005700#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005701 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005702#endif
5703
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 // Now, we're ready to "pack" the frames
5705 nStatus = dot11fPackNeighborReportRequest( pMac,
5706 &frm,
5707 pFrame + sizeof( tSirMacMgmtHdr ),
5708 nPayload,
5709 &nPayload );
5710
5711 if( DOT11F_FAILED( nStatus ))
5712 {
5713 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005714 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 nStatus );
5716
5717 // FIXME - Need to convert to tSirRetStatus
5718 statusCode = eSIR_FAILURE;
5719 goto returnAfterError;
5720 }
5721 else if( DOT11F_WARNED( nStatus ))
5722 {
5723 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005724 FL( "There were warnings while packing Neighbor Report "
5725 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 }
5727
5728 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005729 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 limPrintMacAddr( pMac, peer, LOGW );
5731
5732 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5734 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 )
5736 {
5737 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5738 }
5739
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305740 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5741 psessionEntry->peSessionId,
5742 pMacHdr->fc.subType));
5743 halstatus = halTxFrame( pMac,
5744 pPacket,
5745 (tANI_U16) nBytes,
5746 HAL_TXRX_FRM_802_11_MGMT,
5747 ANI_TXDIR_TODS,
5748 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5749 limTxComplete,
5750 pFrame, txFlag );
5751 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5752 psessionEntry->peSessionId,
5753 halstatus));
5754 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005755 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005756 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 statusCode = eSIR_FAILURE;
5758 //Pkt will be freed up by the callback
5759 return statusCode;
5760 }
5761 else
5762 return eSIR_SUCCESS;
5763
5764returnAfterError:
5765 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5766
5767 return statusCode;
5768} // End limSendNeighborReportRequestFrame.
5769
5770/**
5771 * \brief Send a Link Report Action frame
5772 *
5773 *
5774 * \param pMac Pointer to the global MAC structure
5775 *
5776 * \param pLinkReport Address of a tSirMacLinkReport
5777 *
5778 * \param peer mac address of peer station.
5779 *
5780 * \param psessionEntry address of session entry.
5781 *
5782 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5783 *
5784 *
5785 */
5786
5787tSirRetStatus
5788limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5789 tpSirMacLinkReport pLinkReport,
5790 tSirMacAddr peer,
5791 tpPESession psessionEntry
5792 )
5793{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305794 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 tDot11fLinkMeasurementReport frm;
5796 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305797 tpSirMacMgmtHdr pMacHdr;
5798 tANI_U32 nBytes, nPayload, nStatus;
5799 void *pPacket;
5800 eHalStatus halstatus;
5801 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005802
5803
5804 if ( psessionEntry == NULL )
5805 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005806 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 return eSIR_FAILURE;
5808 }
5809
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305810 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005811
5812 frm.Category.category = SIR_MAC_ACTION_RRM;
5813 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5814 frm.DialogToken.token = pLinkReport->dialogToken;
5815
5816
5817 //IEEE Std. 802.11 7.3.2.18. for the report element.
5818 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5819 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5820 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5821 //such case this way than changing the frame parser.
5822 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5823 frm.TPCEleLen.TPCLen = 2;
5824 frm.TxPower.txPower = pLinkReport->txPower;
5825 frm.LinkMargin.linkMargin = 0;
5826
5827 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5828 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5829 frm.RCPI.rcpi = pLinkReport->rcpi;
5830 frm.RSNI.rsni = pLinkReport->rsni;
5831
5832 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5833 if ( DOT11F_FAILED( nStatus ) )
5834 {
5835 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005836 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 nStatus );
5838 // We'll fall back on the worst case scenario:
5839 nPayload = sizeof( tDot11fLinkMeasurementReport );
5840 }
5841 else if ( DOT11F_WARNED( nStatus ) )
5842 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005843 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005845 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 }
5847
5848 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5849
5850 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5851 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5852 {
5853 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005854 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 return eSIR_FAILURE;
5856 }
5857
5858 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305859 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005860
5861 // Copy necessary info to BD
5862 if( eSIR_SUCCESS !=
5863 (statusCode = limPopulateMacHeader( pMac,
5864 pFrame,
5865 SIR_MAC_MGMT_FRAME,
5866 SIR_MAC_MGMT_ACTION,
5867 peer, psessionEntry->selfMacAddr)))
5868 goto returnAfterError;
5869
5870 // Update A3 with the BSSID
5871 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5872
5873 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5874
Chet Lanctot186b5732013-03-18 10:26:30 -07005875#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005876 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005877#endif
5878
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 // Now, we're ready to "pack" the frames
5880 nStatus = dot11fPackLinkMeasurementReport( pMac,
5881 &frm,
5882 pFrame + sizeof( tSirMacMgmtHdr ),
5883 nPayload,
5884 &nPayload );
5885
5886 if( DOT11F_FAILED( nStatus ))
5887 {
5888 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005889 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 nStatus );
5891
5892 // FIXME - Need to convert to tSirRetStatus
5893 statusCode = eSIR_FAILURE;
5894 goto returnAfterError;
5895 }
5896 else if( DOT11F_WARNED( nStatus ))
5897 {
5898 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005899 FL( "There were warnings while packing Link Report (0x%08x)." ),
5900 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 }
5902
5903 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005904 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 limPrintMacAddr( pMac, peer, LOGW );
5906
5907 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5909 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 )
5911 {
5912 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5913 }
5914
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305915 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5916 psessionEntry->peSessionId,
5917 pMacHdr->fc.subType));
5918 halstatus = halTxFrame( pMac,
5919 pPacket,
5920 (tANI_U16) nBytes,
5921 HAL_TXRX_FRM_802_11_MGMT,
5922 ANI_TXDIR_TODS,
5923 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5924 limTxComplete,
5925 pFrame, txFlag );
5926 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5927 psessionEntry->peSessionId,
5928 halstatus));
5929 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005931 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 statusCode = eSIR_FAILURE;
5933 //Pkt will be freed up by the callback
5934 return statusCode;
5935 }
5936 else
5937 return eSIR_SUCCESS;
5938
5939returnAfterError:
5940 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5941
5942 return statusCode;
5943} // End limSendLinkReportActionFrame.
5944
5945/**
5946 * \brief Send a Beacon Report Action frame
5947 *
5948 *
5949 * \param pMac Pointer to the global MAC structure
5950 *
5951 * \param dialog_token dialog token to be used in the action frame.
5952 *
5953 * \param num_report number of reports in pRRMReport.
5954 *
5955 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5956 *
5957 * \param peer mac address of peer station.
5958 *
5959 * \param psessionEntry address of session entry.
5960 *
5961 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5962 *
5963 *
5964 */
5965
5966tSirRetStatus
5967limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5968 tANI_U8 dialog_token,
5969 tANI_U8 num_report,
5970 tpSirMacRadioMeasureReport pRRMReport,
5971 tSirMacAddr peer,
5972 tpPESession psessionEntry
5973 )
5974{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305975 tSirRetStatus statusCode = eSIR_SUCCESS;
5976 tANI_U8 *pFrame;
5977 tpSirMacMgmtHdr pMacHdr;
5978 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305980 eHalStatus halstatus;
5981 tANI_U8 i;
5982 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005983
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005984 tDot11fRadioMeasurementReport *frm =
5985 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5986 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005987 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005988 return eSIR_FAILURE;
5989 }
5990
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 if ( psessionEntry == NULL )
5992 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005993 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005994 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 return eSIR_FAILURE;
5996 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305997 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005998
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005999 frm->Category.category = SIR_MAC_ACTION_RRM;
6000 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6001 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006002
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006003 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 -07006004
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006005 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006007 frm->MeasurementReport[i].type = pRRMReport[i].type;
6008 frm->MeasurementReport[i].token = pRRMReport[i].token;
6009 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 switch( pRRMReport[i].type )
6011 {
6012 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006013 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6014 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6015 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6016 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 break;
6018 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306019 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6020 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006021 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 break;
6023 }
6024 }
6025
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006026 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 if ( DOT11F_FAILED( nStatus ) )
6028 {
6029 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006030 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 nStatus );
6032 // We'll fall back on the worst case scenario:
6033 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006034 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 return eSIR_FAILURE;
6036 }
6037 else if ( DOT11F_WARNED( nStatus ) )
6038 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006039 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006041 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 }
6043
6044 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6045
6046 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6047 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6048 {
6049 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006050 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006051 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 return eSIR_FAILURE;
6053 }
6054
6055 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306056 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006057
6058 // Copy necessary info to BD
6059 if( eSIR_SUCCESS !=
6060 (statusCode = limPopulateMacHeader( pMac,
6061 pFrame,
6062 SIR_MAC_MGMT_FRAME,
6063 SIR_MAC_MGMT_ACTION,
6064 peer, psessionEntry->selfMacAddr)))
6065 goto returnAfterError;
6066
6067 // Update A3 with the BSSID
6068 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6069
6070 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6071
Chet Lanctot186b5732013-03-18 10:26:30 -07006072#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006073 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006074#endif
6075
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 // Now, we're ready to "pack" the frames
6077 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006078 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006079 pFrame + sizeof( tSirMacMgmtHdr ),
6080 nPayload,
6081 &nPayload );
6082
6083 if( DOT11F_FAILED( nStatus ))
6084 {
6085 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006086 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 nStatus );
6088
6089 // FIXME - Need to convert to tSirRetStatus
6090 statusCode = eSIR_FAILURE;
6091 goto returnAfterError;
6092 }
6093 else if( DOT11F_WARNED( nStatus ))
6094 {
6095 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006096 FL( "There were warnings while packing Radio "
6097 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 }
6099
6100 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006101 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 limPrintMacAddr( pMac, peer, LOGW );
6103
6104 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6106 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 )
6108 {
6109 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6110 }
6111
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306112 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6113 psessionEntry->peSessionId,
6114 pMacHdr->fc.subType));
6115 halstatus = halTxFrame( pMac,
6116 pPacket,
6117 (tANI_U16) nBytes,
6118 HAL_TXRX_FRM_802_11_MGMT,
6119 ANI_TXDIR_TODS,
6120 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6121 limTxComplete,
6122 pFrame, txFlag );
6123 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6124 psessionEntry->peSessionId,
6125 halstatus));
6126 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006128 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 statusCode = eSIR_FAILURE;
6130 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006131 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 return statusCode;
6133 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006134 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006135 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006138
6139returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006140 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 return statusCode;
6143} // End limSendBeaconReportActionFrame.
6144
6145#endif
6146
6147#ifdef WLAN_FEATURE_11W
6148/**
6149 * \brief Send SA query response action frame to peer
6150 *
6151 * \sa limSendSaQueryResponseFrame
6152 *
6153 *
6154 * \param pMac The global tpAniSirGlobal object
6155 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006156 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006158 * \param peer The Mac address of the AP to which this action frame is addressed
6159 *
6160 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 *
6162 * \return eSIR_SUCCESS if setup completes successfully
6163 * eSIR_FAILURE is some problem is encountered
6164 */
6165
Chet Lanctot186b5732013-03-18 10:26:30 -07006166tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006167tSirMacAddr peer,tpPESession psessionEntry)
6168{
6169
Chet Lanctot186b5732013-03-18 10:26:30 -07006170 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006171 tANI_U8 *pFrame;
6172 tSirRetStatus nSirStatus;
6173 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006174 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 void *pPacket;
6176 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306177 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006178
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306179 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006180 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6181 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 action: 0 --> SA query request action frame
6183 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006184 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6185 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006187 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006188
Chet Lanctot186b5732013-03-18 10:26:30 -07006189 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6190 if ( DOT11F_FAILED( nStatus ) )
6191 {
6192 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6193 "or a SA Query Response (0x%08x)."),
6194 nStatus );
6195 // We'll fall back on the worst case scenario:
6196 nPayload = sizeof( tDot11fSaQueryRsp );
6197 }
6198 else if ( DOT11F_WARNED( nStatus ) )
6199 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006200 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006201 "the packed size for an SA Query Response"
6202 " (0x%08x)."), nStatus );
6203 }
6204
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6206 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6207 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6208 {
6209 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006210 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 return eSIR_FAILURE;
6212 }
6213
6214 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306215 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006216
Chet Lanctot186b5732013-03-18 10:26:30 -07006217 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006218 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006219 pFrame,
6220 SIR_MAC_MGMT_FRAME,
6221 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006222 peer, psessionEntry->selfMacAddr );
6223 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006224 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006225
Chet Lanctot186b5732013-03-18 10:26:30 -07006226 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6228
Chet Lanctot186b5732013-03-18 10:26:30 -07006229 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006230
Chet Lanctot186b5732013-03-18 10:26:30 -07006231 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6232 // in the FC
6233 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006235 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 }
6237
Chet Lanctot186b5732013-03-18 10:26:30 -07006238 // Pack 11w SA query response frame
6239 nStatus = dot11fPackSaQueryRsp( pMac,
6240 &frm,
6241 pFrame + sizeof( tSirMacMgmtHdr ),
6242 nPayload,
6243 &nPayload );
6244
6245 if ( DOT11F_FAILED( nStatus ))
6246 {
6247 limLog( pMac, LOGE,
6248 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6249 nStatus );
6250 // FIXME - Need to convert to tSirRetStatus
6251 nSirStatus = eSIR_FAILURE;
6252 goto returnAfterError;
6253 }
6254 else if ( DOT11F_WARNED( nStatus ))
6255 {
6256 limLog( pMac, LOGW,
6257 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6258 nStatus);
6259 }
6260
6261 limLog( pMac, LOG1,
6262 FL( "Sending a SA Query Response to " ));
6263 limPrintMacAddr( pMac, peer, LOGW );
6264
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006265 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006266#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006267 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6268 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006269#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006270 )
6271 {
6272 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6273 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006274
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306275 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6276 psessionEntry->peSessionId,
6277 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006278 halstatus = halTxFrame( pMac,
6279 pPacket,
6280 (tANI_U16) nBytes,
6281 HAL_TXRX_FRM_802_11_MGMT,
6282 ANI_TXDIR_TODS,
6283 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6284 limTxComplete,
6285 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306286 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6287 psessionEntry->peSessionId,
6288 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006289 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006290 {
6291 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6292 nSirStatus = eSIR_FAILURE;
6293 //Pkt will be freed up by the callback
6294 return nSirStatus;
6295 }
6296 else {
6297 return eSIR_SUCCESS;
6298 }
6299
6300returnAfterError:
6301 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6302 return nSirStatus;
6303} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006304#endif