blob: b7ab35e01bf2dbd17d9e65e21f9da2c0ff82d329 [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;
Jeff Johnson295189b2012-06-20 16:38:30 -0700227
228#ifndef GEN4_SCAN
229 return eSIR_FAILURE;
230#endif
231
232#if defined ( ANI_DVT_DEBUG )
233 return eSIR_FAILURE;
234#endif
235
236 /*
237 * session context may or may not be present, when probe request needs to be sent out.
238 * following cases exist:
239 * --heartbeat failure: session needed
240 * --join req: session needed
241 * --foreground scan: no session
242 * --background scan: no session
243 * --schBeaconProcessing: to get EDCA parameters: session needed
244 * If session context does not exist, some IEs will be populated from CFGs,
245 * e.g. Supported and Extended rate set IEs
246 */
247 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
248
249 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
250 // and then hand it off to 'dot11fPackProbeRequest' (for
251 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530252 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700253
254 // & delegating to assorted helpers:
255 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
256
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 if( nAdditionalIELen && pAdditionalIE )
258 {
259 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
260 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700261 /* Don't include 11b rate only when device is doing P2P Search */
262 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
263 ( p2pIe != NULL ) &&
264 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
265 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
266 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
267 ( ( psessionEntry != NULL ) &&
268 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
269 )
270 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 {
272 /* In the below API pass channel number > 14, do that it fills only
273 * 11a rates in supported rates */
274 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
275 }
276 else
277 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 PopulateDot11fSuppRates( pMac, nChannelNum,
279 &pr.SuppRates,psessionEntry);
280
281 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
282 {
283 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
284 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700286
287#if defined WLAN_FEATURE_VOWIFI
288 //Table 7-14 in IEEE Std. 802.11k-2008 says
289 //DS params "can" be present in RRM is disabled and "is" present if
290 //RRM is enabled. It should be ok even if we add it into probe req when
291 //RRM is not enabled.
292 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
293 //Call RRM module to get the tx power for management used.
294 {
295 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
296 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
297 }
298#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700299
300 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700301 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700303 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700305 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700306 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700307 } else { //psessionEntry == NULL
308 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700310 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 }
312 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800313
314 /* Set channelbonding information as "disabled" when tunned to a 2.4 GHz channel */
315 if( nChannelNum <= SIR_11B_CHANNEL_END)
316 {
317 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
318 pr.HTCaps.shortGI40MHz = 0;
319 }
320
Jeff Johnsone7245742012-09-05 17:12:55 -0700321#ifdef WLAN_FEATURE_11AC
322 if (psessionEntry != NULL ) {
323 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
324 //Include HT Capability IE
325 if (psessionEntry->vhtCapability)
326 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700327 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
328 }
329 } else {
330 if (IS_DOT11_MODE_VHT(dot11mode))
331 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700332 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
333 }
334 }
335#endif
336
Jeff Johnson295189b2012-06-20 16:38:30 -0700337
338 // That's it-- now we pack it. First, how much space are we going to
339 // need?
340 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
341 if ( DOT11F_FAILED( nStatus ) )
342 {
343 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700344 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 // We'll fall back on the worst case scenario:
346 nPayload = sizeof( tDot11fProbeRequest );
347 }
348 else if ( DOT11F_WARNED( nStatus ) )
349 {
350 limLog( pMac, LOGW, FL("There were warnings while calculating"
351 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700352 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 }
354
355 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
356
357 // Ok-- try to allocate some memory:
358 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
359 ( tANI_U16 )nBytes, ( void** ) &pFrame,
360 ( void** ) &pPacket );
361 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
362 {
363 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700364 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 return eSIR_MEM_ALLOC_FAILED;
366 }
367
368 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530369 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700370
371 // Next, we fill out the buffer descriptor:
372 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530373 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 if ( eSIR_SUCCESS != nSirStatus )
375 {
376 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700377 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 nSirStatus );
379 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
380 ( void* ) pFrame, ( void* ) pPacket );
381 return nSirStatus; // allocated!
382 }
383
384 // That done, pack the Probe Request:
385 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
386 sizeof( tSirMacMgmtHdr ),
387 nPayload, &nPayload );
388 if ( DOT11F_FAILED( nStatus ) )
389 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700390 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 nStatus );
392 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
393 return eSIR_FAILURE; // allocated!
394 }
395 else if ( DOT11F_WARNED( nStatus ) )
396 {
397 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800398 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 }
400
401 // Append any AddIE if present.
402 if( nAdditionalIELen )
403 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530404 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 pAdditionalIE, nAdditionalIELen );
406 nPayload += nAdditionalIELen;
407 }
408
409 /* If this probe request is sent during P2P Search State, then we need
410 * to send it at OFDM rate.
411 */
412 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
414 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530415 /* For unicast probe req mgmt from Join function
416 we don't set above variables. So we need to add
417 one more check whether it is pePersona is P2P_CLIENT or not */
418 || ( ( psessionEntry != NULL ) &&
419 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700420 )
421 {
422 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
423 }
424
425
426 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 );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700639 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700640 }
641#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700642
643 if ( psessionEntry->pLimStartBssReq )
644 {
645 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700646 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700647 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
648 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 }
650
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700651 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700652
653#if defined(FEATURE_WLAN_WAPI)
654 if( psessionEntry->pLimStartBssReq )
655 {
656 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700657 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 }
659
660#endif // defined(FEATURE_WLAN_WAPI)
661
662
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700663 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 if ( DOT11F_FAILED( nStatus ) )
665 {
666 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700667 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 nStatus );
669 // We'll fall back on the worst case scenario:
670 nPayload = sizeof( tDot11fProbeResponse );
671 }
672 else if ( DOT11F_WARNED( nStatus ) )
673 {
674 limLog( pMac, LOGW, FL("There were warnings while calculating"
675 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700676 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 }
678
679 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
680
681 addnIEPresent = false;
682
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 if( pMac->lim.gpLimRemainOnChanReq )
684 {
685 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
686 }
687 //Only use CFG for non-listen mode. This CFG is not working for concurrency
688 //In listening mode, probe rsp IEs is passed in the message from SME to PE
689 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 {
691
692 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
693 &addnIEPresent) != eSIR_SUCCESS)
694 {
695 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530696 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 return;
698 }
699 }
700
701 if (addnIEPresent)
702 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530703
704 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
705 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 {
707 PELOGE(limLog(pMac, LOGE,
708 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530709 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 return;
711 }
712
713 //Probe rsp IE available
714 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
715 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
716 {
717 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530718 vos_mem_free(addIE);
719 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 return;
721 }
722 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
723 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
724 {
725 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
726 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
727 &addnIE1Len) )
728 {
729 limLog(pMac, LOGP,
730 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530731 vos_mem_free(addIE);
732 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 return;
734 }
735 }
736
737 //Probe rsp IE available
738 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
739 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
740 {
741 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530742 vos_mem_free(addIE);
743 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 return;
745 }
746 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
747 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
748 {
749 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
750 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
751 &addnIE2Len) )
752 {
753 limLog(pMac, LOGP,
754 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530755 vos_mem_free(addIE);
756 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 return;
758 }
759 }
760
761 //Probe rsp IE available
762 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
763 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
764 {
765 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530766 vos_mem_free(addIE);
767 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 return;
769 }
770 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
771 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
772 {
773 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
774 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
775 &addIE[addnIE1Len + addnIE2Len],
776 &addnIE3Len) )
777 {
778 limLog(pMac, LOGP,
779 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530780 vos_mem_free(addIE);
781 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 return;
783 }
784 }
785 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
786
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
788 {
789 limLog(pMac, LOGP,
790 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530791 vos_mem_free(addIE);
792 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 return;
794 }
795 nBytes = nBytes + totalAddnIeLen;
796
797 if (probeReqP2pIe)
798 {
799 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
800 if (pP2pIe != NULL)
801 {
802 //get NoA attribute stream P2P IE
803 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
804 if (noaLen != 0)
805 {
806 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
807 &noaStream[0], noaLen);
808 nBytes = nBytes + total_noaLen;
809 }
810 }
811 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 }
813
814 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
815 ( tANI_U16 )nBytes, ( void** ) &pFrame,
816 ( void** ) &pPacket );
817 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
818 {
819 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700820 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 if ( addIE != NULL )
822 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530823 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530825 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700826 return;
827 }
828
829 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530830 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700831
832 // Next, we fill out the buffer descriptor:
833 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
834 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
835 if ( eSIR_SUCCESS != nSirStatus )
836 {
837 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700838 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 nSirStatus );
840 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
841 ( void* ) pFrame, ( void* ) pPacket );
842 if ( addIE != NULL )
843 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530844 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530846 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 return;
848 }
849
850 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
851
852 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
853
854 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700855 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 nPayload, &nPayload );
857 if ( DOT11F_FAILED( nStatus ) )
858 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700859 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 nStatus );
861 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
862 if ( addIE != NULL )
863 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530864 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530866 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700867 return; // allocated!
868 }
869 else if ( DOT11F_WARNED( nStatus ) )
870 {
871 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800872 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 }
874
875 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
876 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
877
878 pMac->sys.probeRespond++;
879
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 if( pMac->lim.gpLimRemainOnChanReq )
881 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530882 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
884 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700885
886 if ( addnIEPresent )
887 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530888 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 if (noaLen != 0)
891 {
Krunal Soni81b24262013-05-15 17:46:41 -0700892 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 {
894 limLog(pMac, LOGE,
895 FL("Not able to insert NoA because of length constraint"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530896 vos_mem_free(addIE);
897 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -0700898 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
899 ( void* ) pFrame, ( void* ) pPacket );
900 return;
901 }
902 else
903 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530904 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -0700905 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 }
907 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700908
909 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
911 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 )
913 {
914 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
915 }
916
917 // Queue Probe Response frame in high priority WQ
918 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
919 ( tANI_U16 ) nBytes,
920 HAL_TXRX_FRM_802_11_MGMT,
921 ANI_TXDIR_TODS,
922 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
923 limTxComplete, pFrame, txFlag );
924 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
925 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700926 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 //Pkt will be freed up by the callback
928 }
929
930 if ( addIE != NULL )
931 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530932 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 }
934
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530935 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700936 return;
937
938
Jeff Johnson295189b2012-06-20 16:38:30 -0700939} // End limSendProbeRspMgmtFrame.
940
941void
942limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
943 tSirMacAddr peerMacAddr,
944 tSirAddtsReqInfo *pAddTS,
945 tpPESession psessionEntry)
946{
947 tANI_U16 i;
948 tANI_U8 *pFrame;
949 tSirRetStatus nSirStatus;
950 tDot11fAddTSRequest AddTSReq;
951 tDot11fWMMAddTSRequest WMMAddTSReq;
952 tANI_U32 nPayload, nBytes, nStatus;
953 tpSirMacMgmtHdr pMacHdr;
954 void *pPacket;
955#ifdef FEATURE_WLAN_CCX
956 tANI_U32 phyMode;
957#endif
958 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530959 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700960
961 if(NULL == psessionEntry)
962 {
963 return;
964 }
965
966 if ( ! pAddTS->wmeTspecPresent )
967 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530968 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700969
970 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
971 AddTSReq.DialogToken.token = pAddTS->dialogToken;
972 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
973 if ( pAddTS->lleTspecPresent )
974 {
975 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
976 }
977 else
978 {
979 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
980 }
981
982 if ( pAddTS->lleTspecPresent )
983 {
984 AddTSReq.num_WMMTCLAS = 0;
985 AddTSReq.num_TCLAS = pAddTS->numTclas;
986 for ( i = 0; i < pAddTS->numTclas; ++i)
987 {
988 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
989 &AddTSReq.TCLAS[i] );
990 }
991 }
992 else
993 {
994 AddTSReq.num_TCLAS = 0;
995 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
996 for ( i = 0; i < pAddTS->numTclas; ++i)
997 {
998 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
999 &AddTSReq.WMMTCLAS[i] );
1000 }
1001 }
1002
1003 if ( pAddTS->tclasProcPresent )
1004 {
1005 if ( pAddTS->lleTspecPresent )
1006 {
1007 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1008 AddTSReq.TCLASSPROC.present = 1;
1009 }
1010 else
1011 {
1012 AddTSReq.WMMTCLASPROC.version = 1;
1013 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1014 AddTSReq.WMMTCLASPROC.present = 1;
1015 }
1016 }
1017
1018 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1019 if ( DOT11F_FAILED( nStatus ) )
1020 {
1021 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001022 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 nStatus );
1024 // We'll fall back on the worst case scenario:
1025 nPayload = sizeof( tDot11fAddTSRequest );
1026 }
1027 else if ( DOT11F_WARNED( nStatus ) )
1028 {
1029 limLog( pMac, LOGW, FL("There were warnings while calculating"
1030 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001031 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 }
1033 }
1034 else
1035 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301036 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001037
1038 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1039 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1040 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1041
1042 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1043 WMMAddTSReq.StatusCode.statusCode = 0;
1044
1045 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1046#ifdef FEATURE_WLAN_CCX
1047 limGetPhyMode(pMac, &phyMode, psessionEntry);
1048
1049 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1050 {
1051 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1052 }
1053 else
1054 {
1055 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1056 }
1057 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1058#endif
1059 // fillWmeTspecIE
1060
1061 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1062 if ( DOT11F_FAILED( nStatus ) )
1063 {
1064 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001065 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 nStatus );
1067 // We'll fall back on the worst case scenario:
1068 nPayload = sizeof( tDot11fAddTSRequest );
1069 }
1070 else if ( DOT11F_WARNED( nStatus ) )
1071 {
1072 limLog( pMac, LOGW, FL("There were warnings while calculating"
1073 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001074 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 }
1076 }
1077
1078 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1079
1080 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1081 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1082 ( void** ) &pPacket );
1083 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1084 {
1085 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001086 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 return;
1088 }
1089
1090 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301091 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001092
1093 // Next, we fill out the buffer descriptor:
1094 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1095 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1096 if ( eSIR_SUCCESS != nSirStatus )
1097 {
1098 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001099 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 nSirStatus );
1101 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1102 ( void* ) pFrame, ( void* ) pPacket );
1103 return;
1104 }
1105
1106 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1107
1108 #if 0
1109 cfgLen = SIR_MAC_ADDR_LENGTH;
1110 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1111 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1112 {
1113 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001114 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1116 ( void* ) pFrame, ( void* ) pPacket );
1117 return;
1118 }
1119 #endif //TO SUPPORT BT-AMP
1120
1121 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1122
Chet Lanctot186b5732013-03-18 10:26:30 -07001123#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001124 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001125#endif
1126
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 // That done, pack the struct:
1128 if ( ! pAddTS->wmeTspecPresent )
1129 {
1130 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1131 pFrame + sizeof(tSirMacMgmtHdr),
1132 nPayload, &nPayload );
1133 if ( DOT11F_FAILED( nStatus ) )
1134 {
1135 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001136 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 nStatus );
1138 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1139 return; // allocated!
1140 }
1141 else if ( DOT11F_WARNED( nStatus ) )
1142 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001143 limLog( pMac, LOGW, FL("There were warnings while packing "
1144 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 }
1146 }
1147 else
1148 {
1149 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1150 pFrame + sizeof(tSirMacMgmtHdr),
1151 nPayload, &nPayload );
1152 if ( DOT11F_FAILED( nStatus ) )
1153 {
1154 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001155 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001156 nStatus );
1157 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1158 return; // allocated!
1159 }
1160 else if ( DOT11F_WARNED( nStatus ) )
1161 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001162 limLog( pMac, LOGW, FL("There were warnings while packing "
1163 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 }
1165 }
1166
1167 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1168 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1169
1170 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001171 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1172 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 )
1174 {
1175 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1176 }
1177
1178 // Queue Addts Response frame in high priority WQ
1179 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1180 HAL_TXRX_FRM_802_11_MGMT,
1181 ANI_TXDIR_TODS,
1182 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1183 limTxComplete, pFrame, txFlag );
1184 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1185 {
1186 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001187 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 //Pkt will be freed up by the callback
1189 }
1190
1191} // End limSendAddtsReqActionFrame.
1192
Jeff Johnson295189b2012-06-20 16:38:30 -07001193
1194
1195void
1196limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1197 tANI_U16 statusCode,
1198 tANI_U16 aid,
1199 tSirMacAddr peerMacAddr,
1200 tANI_U8 subType,
1201 tpDphHashNode pSta,tpPESession psessionEntry)
1202{
1203 static tDot11fAssocResponse frm;
1204 tANI_U8 *pFrame, *macAddr;
1205 tpSirMacMgmtHdr pMacHdr;
1206 tSirRetStatus nSirStatus;
1207 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1208 tHalBitVal qosMode, wmeMode;
1209 tANI_U32 nPayload, nBytes, nStatus;
1210 void *pPacket;
1211 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301212 tUpdateBeaconParams beaconParams;
1213 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 tANI_U32 addnIEPresent = false;
1215 tANI_U32 addnIELen=0;
1216 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1217 tpSirAssocReq pAssocReq = NULL;
1218
1219 if(NULL == psessionEntry)
1220 {
1221 return;
1222 }
1223
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301224 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001225
1226 limGetQosMode(psessionEntry, &qosMode);
1227 limGetWmeMode(psessionEntry, &wmeMode);
1228
1229 // An Add TS IE is added only if the AP supports it and the requesting
1230 // STA sent a traffic spec.
1231 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1232
1233 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1234
1235 frm.Status.status = statusCode;
1236
1237 frm.AID.associd = aid | LIM_AID_MASK;
1238
1239 if ( NULL == pSta )
1240 {
1241 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1242 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1243 }
1244 else
1245 {
1246 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1247 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1248 }
1249
Jeff Johnson295189b2012-06-20 16:38:30 -07001250 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1251 {
1252 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1253 {
1254 pAssocReq =
1255 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1257 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1258 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 }
1261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001262
1263 if ( NULL != pSta )
1264 {
1265 if ( eHAL_SET == qosMode )
1266 {
1267 if ( pSta->lleEnabled )
1268 {
1269 lleMode = 1;
1270 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1271 {
1272 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1273
1274// FramesToDo:...
1275// if ( fAddTS )
1276// {
1277// tANI_U8 *pAf = pBody;
1278// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1279// tANI_U32 tlen;
1280// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1281// &tlen, bufLen - frameLen);
1282// } // End if on Add TS.
1283 }
1284 } // End if on .11e enabled in 'pSta'.
1285 } // End if on QOS Mode on.
1286
1287 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1288 {
1289 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1290 {
1291
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001293
1294 if ( pSta->wsmEnabled )
1295 {
1296 PopulateDot11fWMMCaps(&frm.WMMCaps );
1297 }
1298 }
1299 }
1300
1301 if ( pSta->aniPeer )
1302 {
1303 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1304 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1305 {
1306 edcaInclude = 1;
1307 }
1308
1309 } // End if on Airgo peer.
1310
1311 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001312 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001314 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001317
1318#ifdef WLAN_FEATURE_11AC
1319 if( pSta->mlmStaContext.vhtCapability &&
1320 psessionEntry->vhtCapability )
1321 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001322 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001323 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1324 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001325 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001326 }
1327#endif
1328
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 } // End if on non-NULL 'pSta'.
1330
1331
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301332 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001333
Jeff Johnson295189b2012-06-20 16:38:30 -07001334 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1335 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1336 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001338
1339 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1340 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1341
1342 beaconParams.bssIdx = psessionEntry->bssIdx;
1343
1344 //Send message to HAL about beacon parameter change.
1345 if(beaconParams.paramChangeBitmap)
1346 {
1347 schSetFixedBeaconFields(pMac,psessionEntry);
1348 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1349 }
1350
1351 // Allocate a buffer for this frame:
1352 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1353 if ( DOT11F_FAILED( nStatus ) )
1354 {
1355 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001356 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 nStatus );
1358 return;
1359 }
1360 else if ( DOT11F_WARNED( nStatus ) )
1361 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001362 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001364 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001365 }
1366
1367 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1368
1369 if ( pAssocReq != NULL )
1370 {
1371 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1372 &addnIEPresent) != eSIR_SUCCESS)
1373 {
1374 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
1375 return;
1376 }
1377
1378 if (addnIEPresent)
1379 {
1380 //Assoc rsp IE available
1381 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1382 &addnIELen) != eSIR_SUCCESS)
1383 {
1384 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
1385 return;
1386 }
1387
1388 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1389 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1390 {
1391 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1392 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1393 {
1394 nBytes = nBytes + addnIELen;
1395 }
1396 }
1397 }
1398 }
1399
1400 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1401 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1402 ( void** ) &pPacket );
1403 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1404 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001405 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 return;
1407 }
1408
1409 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301410 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001411
1412 // Next, we fill out the buffer descriptor:
1413 nSirStatus = limPopulateMacHeader( pMac,
1414 pFrame,
1415 SIR_MAC_MGMT_FRAME,
1416 ( LIM_ASSOC == subType ) ?
1417 SIR_MAC_MGMT_ASSOC_RSP :
1418 SIR_MAC_MGMT_REASSOC_RSP,
1419 peerMacAddr,psessionEntry->selfMacAddr);
1420 if ( eSIR_SUCCESS != nSirStatus )
1421 {
1422 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001423 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 nSirStatus );
1425 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1426 ( void* ) pFrame, ( void* ) pPacket );
1427 return;
1428 }
1429
1430 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1431
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1433
1434 nStatus = dot11fPackAssocResponse( pMac, &frm,
1435 pFrame + sizeof( tSirMacMgmtHdr ),
1436 nPayload, &nPayload );
1437 if ( DOT11F_FAILED( nStatus ) )
1438 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001439 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 nStatus );
1441 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1442 ( void* ) pFrame, ( void* ) pPacket );
1443 return; // allocated!
1444 }
1445 else if ( DOT11F_WARNED( nStatus ) )
1446 {
1447 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001448 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001449 }
1450
1451 macAddr = pMacHdr->da;
1452
1453 if (subType == LIM_ASSOC)
1454 {
1455 PELOG1(limLog(pMac, LOG1,
1456 FL("*** Sending Assoc Resp status %d aid %d to "),
1457 statusCode, aid);)
1458 }
1459 else{
1460 PELOG1(limLog(pMac, LOG1,
1461 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1462 statusCode, aid);)
1463 }
1464 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1465
1466 if ( addnIEPresent )
1467 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301468 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 }
1470
1471 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1473 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 )
1475 {
1476 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1477 }
1478
1479 /// Queue Association Response frame in high priority WQ
1480 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1481 HAL_TXRX_FRM_802_11_MGMT,
1482 ANI_TXDIR_TODS,
1483 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1484 limTxComplete, pFrame, txFlag );
1485 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1486 {
1487 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001488 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 nSirStatus);
1490
1491 //Pkt will be freed up by the callback
1492 }
1493
1494 // update the ANI peer station count
1495 //FIXME_PROTECTION : take care of different type of station
1496 // counter inside this function.
1497 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1498
1499} // End limSendAssocRspMgmtFrame.
1500
1501
1502
1503void
1504limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1505 tSirMacAddr peer,
1506 tANI_U16 nStatusCode,
1507 tSirAddtsReqInfo *pAddTS,
1508 tSirMacScheduleIE *pSchedule,
1509 tpPESession psessionEntry)
1510{
1511 tANI_U8 *pFrame;
1512 tpSirMacMgmtHdr pMacHdr;
1513 tDot11fAddTSResponse AddTSRsp;
1514 tDot11fWMMAddTSResponse WMMAddTSRsp;
1515 tSirRetStatus nSirStatus;
1516 tANI_U32 i, nBytes, nPayload, nStatus;
1517 void *pPacket;
1518 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301519 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001520
1521 if(NULL == psessionEntry)
1522 {
1523 return;
1524 }
1525
1526 if ( ! pAddTS->wmeTspecPresent )
1527 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301528 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001529
1530 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1531 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1532 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1533 AddTSRsp.Status.status = nStatusCode;
1534
1535 // The TsDelay information element is only filled in for a specific
1536 // status code:
1537 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1538 {
1539 if ( pAddTS->wsmTspecPresent )
1540 {
1541 AddTSRsp.WMMTSDelay.version = 1;
1542 AddTSRsp.WMMTSDelay.delay = 10;
1543 AddTSRsp.WMMTSDelay.present = 1;
1544 }
1545 else
1546 {
1547 AddTSRsp.TSDelay.delay = 10;
1548 AddTSRsp.TSDelay.present = 1;
1549 }
1550 }
1551
1552 if ( pAddTS->wsmTspecPresent )
1553 {
1554 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1555 }
1556 else
1557 {
1558 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1559 }
1560
1561 if ( pAddTS->wsmTspecPresent )
1562 {
1563 AddTSRsp.num_WMMTCLAS = 0;
1564 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1565 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1566 {
1567 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1568 &AddTSRsp.TCLAS[i] );
1569 }
1570 }
1571 else
1572 {
1573 AddTSRsp.num_TCLAS = 0;
1574 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1575 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1576 {
1577 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1578 &AddTSRsp.WMMTCLAS[i] );
1579 }
1580 }
1581
1582 if ( pAddTS->tclasProcPresent )
1583 {
1584 if ( pAddTS->wsmTspecPresent )
1585 {
1586 AddTSRsp.WMMTCLASPROC.version = 1;
1587 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1588 AddTSRsp.WMMTCLASPROC.present = 1;
1589 }
1590 else
1591 {
1592 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1593 AddTSRsp.TCLASSPROC.present = 1;
1594 }
1595 }
1596
1597 // schedule element is included only if requested in the tspec and we are
1598 // using hcca (or both edca and hcca)
1599 // 11e-D8.0 is inconsistent on whether the schedule element is included
1600 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1601 // pg 46, line 17-18 says something else. So just include it and let the
1602 // sta figure it out
1603 if ((pSchedule != NULL) &&
1604 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1605 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1606 {
1607 if ( pAddTS->wsmTspecPresent )
1608 {
1609 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1610 }
1611 else
1612 {
1613 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1614 }
1615 }
1616
1617 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1618 if ( DOT11F_FAILED( nStatus ) )
1619 {
1620 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001621 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 nStatus );
1623 // We'll fall back on the worst case scenario:
1624 nPayload = sizeof( tDot11fAddTSResponse );
1625 }
1626 else if ( DOT11F_WARNED( nStatus ) )
1627 {
1628 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001629 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001630 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 }
1632 }
1633 else
1634 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301635 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001636
1637 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1638 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1639 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1640 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1641
1642 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1643
1644 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1645 if ( DOT11F_FAILED( nStatus ) )
1646 {
1647 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001648 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 nStatus );
1650 // We'll fall back on the worst case scenario:
1651 nPayload = sizeof( tDot11fWMMAddTSResponse );
1652 }
1653 else if ( DOT11F_WARNED( nStatus ) )
1654 {
1655 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001656 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001657 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 }
1659 }
1660
1661 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1662
1663 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1664 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1665 {
1666 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001667 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 return;
1669 }
1670
1671 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301672 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001673
1674 // Next, we fill out the buffer descriptor:
1675 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1676 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1677 if ( eSIR_SUCCESS != nSirStatus )
1678 {
1679 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001680 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 nSirStatus );
1682 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1683 return; // allocated!
1684 }
1685
1686 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1687
1688
1689 #if 0
1690 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1691 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1692 {
1693 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001694 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1696 return; // allocated!
1697 }
1698 #endif //TO SUPPORT BT-AMP
1699 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1700
Chet Lanctot186b5732013-03-18 10:26:30 -07001701#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001702 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001703#endif
1704
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 // That done, pack the struct:
1706 if ( ! pAddTS->wmeTspecPresent )
1707 {
1708 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1709 pFrame + sizeof( tSirMacMgmtHdr ),
1710 nPayload, &nPayload );
1711 if ( DOT11F_FAILED( nStatus ) )
1712 {
1713 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001714 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 nStatus );
1716 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1717 return;
1718 }
1719 else if ( DOT11F_WARNED( nStatus ) )
1720 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001721 limLog( pMac, LOGW, FL("There were warnings while packing "
1722 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 }
1724 }
1725 else
1726 {
1727 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1728 pFrame + sizeof( tSirMacMgmtHdr ),
1729 nPayload, &nPayload );
1730 if ( DOT11F_FAILED( nStatus ) )
1731 {
1732 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001733 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 nStatus );
1735 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1736 return;
1737 }
1738 else if ( DOT11F_WARNED( nStatus ) )
1739 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001740 limLog( pMac, LOGW, FL("There were warnings while packing "
1741 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 }
1743 }
1744
1745 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1746 nStatusCode );
1747 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1748
1749 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1751 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 )
1753 {
1754 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1755 }
1756
1757 // Queue the frame in high priority WQ:
1758 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1759 HAL_TXRX_FRM_802_11_MGMT,
1760 ANI_TXDIR_TODS,
1761 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1762 limTxComplete, pFrame, txFlag );
1763 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1764 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001765 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 nSirStatus );
1767 //Pkt will be freed up by the callback
1768 }
1769
1770} // End limSendAddtsRspActionFrame.
1771
1772void
1773limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1774 tSirMacAddr peer,
1775 tANI_U8 wmmTspecPresent,
1776 tSirMacTSInfo *pTsinfo,
1777 tSirMacTspecIE *pTspecIe,
1778 tpPESession psessionEntry)
1779{
1780 tANI_U8 *pFrame;
1781 tpSirMacMgmtHdr pMacHdr;
1782 tDot11fDelTS DelTS;
1783 tDot11fWMMDelTS WMMDelTS;
1784 tSirRetStatus nSirStatus;
1785 tANI_U32 nBytes, nPayload, nStatus;
1786 void *pPacket;
1787 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301788 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001789
1790 if(NULL == psessionEntry)
1791 {
1792 return;
1793 }
1794
1795 if ( ! wmmTspecPresent )
1796 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301797 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001798
1799 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1800 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1801 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1802
1803 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1804 if ( DOT11F_FAILED( nStatus ) )
1805 {
1806 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001807 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 nStatus );
1809 // We'll fall back on the worst case scenario:
1810 nPayload = sizeof( tDot11fDelTS );
1811 }
1812 else if ( DOT11F_WARNED( nStatus ) )
1813 {
1814 limLog( pMac, LOGW, FL("There were warnings while calcula"
1815 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001816 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001817 }
1818 }
1819 else
1820 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301821 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001822
1823 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1824 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1825 WMMDelTS.DialogToken.token = 0;
1826 WMMDelTS.StatusCode.statusCode = 0;
1827 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1828 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1829 if ( DOT11F_FAILED( nStatus ) )
1830 {
1831 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001832 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 nStatus );
1834 // We'll fall back on the worst case scenario:
1835 nPayload = sizeof( tDot11fDelTS );
1836 }
1837 else if ( DOT11F_WARNED( nStatus ) )
1838 {
1839 limLog( pMac, LOGW, FL("There were warnings while calcula"
1840 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001841 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 }
1843 }
1844
1845 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1846
1847 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1848 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1849 {
1850 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001851 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 return;
1853 }
1854
1855 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301856 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001857
1858 // Next, we fill out the buffer descriptor:
1859 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1860 SIR_MAC_MGMT_ACTION, peer,
1861 psessionEntry->selfMacAddr);
1862 if ( eSIR_SUCCESS != nSirStatus )
1863 {
1864 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001865 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 nSirStatus );
1867 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1868 return; // allocated!
1869 }
1870
1871 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1872
1873 #if 0
1874
1875 cfgLen = SIR_MAC_ADDR_LENGTH;
1876 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1877 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1878 {
1879 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001880 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1882 return; // allocated!
1883 }
1884 #endif //TO SUPPORT BT-AMP
1885 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1886
Chet Lanctot186b5732013-03-18 10:26:30 -07001887#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001888 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001889#endif
1890
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 // That done, pack the struct:
1892 if ( !wmmTspecPresent )
1893 {
1894 nStatus = dot11fPackDelTS( pMac, &DelTS,
1895 pFrame + sizeof( tSirMacMgmtHdr ),
1896 nPayload, &nPayload );
1897 if ( DOT11F_FAILED( nStatus ) )
1898 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001899 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 nStatus );
1901 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1902 return; // allocated!
1903 }
1904 else if ( DOT11F_WARNED( nStatus ) )
1905 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001906 limLog( pMac, LOGW, FL("There were warnings while packing "
1907 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 }
1909 }
1910 else
1911 {
1912 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1913 pFrame + sizeof( tSirMacMgmtHdr ),
1914 nPayload, &nPayload );
1915 if ( DOT11F_FAILED( nStatus ) )
1916 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001917 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 nStatus );
1919 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1920 return; // allocated!
1921 }
1922 else if ( DOT11F_WARNED( nStatus ) )
1923 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001924 limLog( pMac, LOGW, FL("There were warnings while packing "
1925 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 }
1927 }
1928
1929 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1930 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1931
1932 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1934 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 )
1936 {
1937 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1938 }
1939
1940 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1941 HAL_TXRX_FRM_802_11_MGMT,
1942 ANI_TXDIR_TODS,
1943 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1944 limTxComplete, pFrame, txFlag );
1945 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1946 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001947 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 nSirStatus );
1949 //Pkt will be freed up by the callback
1950 }
1951
1952} // End limSendDeltsReqActionFrame.
1953
1954void
1955limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1956 tLimMlmAssocReq *pMlmAssocReq,
1957 tpPESession psessionEntry)
1958{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001959 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 tANI_U16 caps;
1961 tANI_U8 *pFrame;
1962 tSirRetStatus nSirStatus;
1963 tLimMlmAssocCnf mlmAssocCnf;
1964 tANI_U32 nBytes, nPayload, nStatus;
1965 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1966 void *pPacket;
1967 eHalStatus halstatus;
1968 tANI_U16 nAddIELen;
1969 tANI_U8 *pAddIE;
1970 tANI_U8 *wpsIe = NULL;
1971#if defined WLAN_FEATURE_VOWIFI
1972 tANI_U8 PowerCapsPopulated = FALSE;
1973#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301974 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001975
1976 if(NULL == psessionEntry)
1977 {
1978 return;
1979 }
1980
1981 if(NULL == psessionEntry->pLimJoinReq)
1982 {
1983 return;
1984 }
1985
1986 /* check this early to avoid unncessary operation */
1987 if(NULL == psessionEntry->pLimJoinReq)
1988 {
1989 return;
1990 }
1991 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
1992 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
1993
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301994 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
1995 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001996 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301997 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendAssocReqMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001998 return;
1999 }
2000
2001
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302002 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002003
2004 caps = pMlmAssocReq->capabilityInfo;
2005 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2006 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2007#if defined(FEATURE_WLAN_WAPI)
2008 /* CR: 262463 :
2009 According to WAPI standard:
2010 7.3.1.4 Capability Information field
2011 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2012 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2013 Reassociation management frames. */
2014 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2015 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2016#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002017 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002018
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002019 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2020 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002022 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002023
2024 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2025 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2026
2027 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2028 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2029
2030 // We prefer .11e asociations:
2031 if ( fQosEnabled ) fWmeEnabled = false;
2032
2033 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2034 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2035
2036 if ( psessionEntry->lim11hEnable &&
2037 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2038 {
2039#if defined WLAN_FEATURE_VOWIFI
2040 PowerCapsPopulated = TRUE;
2041
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002042 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002043#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002044 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002045
2046 }
2047
2048#if defined WLAN_FEATURE_VOWIFI
2049 if( pMac->rrm.rrmPEContext.rrmEnable &&
2050 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2051 {
2052 if (PowerCapsPopulated == FALSE)
2053 {
2054 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002055 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 }
2057 }
2058#endif
2059
2060 if ( fQosEnabled &&
2061 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002062 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
2064 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002065 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002066
2067#if defined WLAN_FEATURE_VOWIFI
2068 if( pMac->rrm.rrmPEContext.rrmEnable &&
2069 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2070 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002071 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 }
2073#endif
2074 // The join request *should* contain zero or one of the WPA and RSN
2075 // IEs. The payload send along with the request is a
2076 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2077
2078 // typedef struct sSirRSNie
2079 // {
2080 // tANI_U16 length;
2081 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2082 // } tSirRSNie, *tpSirRSNie;
2083
2084 // So, we should be able to make the following two calls harmlessly,
2085 // since they do nothing if they don't find the given IE in the
2086 // bytestream with which they're provided.
2087
2088 // The net effect of this will be to faithfully transmit whatever
2089 // security IE is in the join request.
2090
2091 // *However*, if we're associating for the purpose of WPS
2092 // enrollment, and we've been configured to indicate that by
2093 // eliding the WPA or RSN IE, we just skip this:
2094 if( nAddIELen && pAddIE )
2095 {
2096 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2097 }
2098 if ( NULL == wpsIe )
2099 {
2100 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002101 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002103 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002104#if defined(FEATURE_WLAN_WAPI)
2105 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002106 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002107#endif // defined(FEATURE_WLAN_WAPI)
2108 }
2109
2110 // include WME EDCA IE as well
2111 if ( fWmeEnabled )
2112 {
2113 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2114 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002115 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 }
2117
2118 if ( fWsmEnabled &&
2119 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2120 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002121 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 }
2123 }
2124
2125 //Populate HT IEs, when operating in 11n or Taurus modes AND
2126 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002127 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 pMac->lim.htCapabilityPresentInBeacon)
2129 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002130 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002131#ifdef DISABLE_GF_FOR_INTEROP
2132
2133 /*
2134 * To resolve the interop problem with Broadcom AP,
2135 * where TQ STA could not pass traffic with GF enabled,
2136 * TQ STA will do Greenfield only with TQ AP, for
2137 * everybody else it will be turned off.
2138 */
2139
2140 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2141 {
2142 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002143 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 }
2145#endif
2146
2147 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002148#ifdef WLAN_FEATURE_11AC
2149 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002150 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002151 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002152 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002153 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2154 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002155 }
2156#endif
2157
Jeff Johnson295189b2012-06-20 16:38:30 -07002158
2159#if defined WLAN_FEATURE_VOWIFI_11R
2160 if (psessionEntry->pLimJoinReq->is11Rconnection)
2161 {
2162#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002163 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2165 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2166 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2167#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302168 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2169 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302171 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 {
2173 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302174 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 }
2176#endif
2177
2178#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302179 /* For CCX Associations fill the CCX IEs */
2180 if (psessionEntry->isCCXconnection &&
2181 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002183#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002184 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002185#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302186 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002187 }
2188#endif
2189
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002190 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 if ( DOT11F_FAILED( nStatus ) )
2192 {
2193 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002194 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 nStatus );
2196 // We'll fall back on the worst case scenario:
2197 nPayload = sizeof( tDot11fAssocRequest );
2198 }
2199 else if ( DOT11F_WARNED( nStatus ) )
2200 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002201 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002203 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 }
2205
2206 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2207
2208 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2209 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2210 ( void** ) &pPacket );
2211 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2212 {
2213 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002214 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002215
2216 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002217 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002218
2219
2220 /* Update PE session id*/
2221 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2222
2223 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2224
2225 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2226 ( void* ) pFrame, ( void* ) pPacket );
2227
2228 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2229 ( tANI_U32* ) &mlmAssocCnf);
2230
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302231 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 return;
2233 }
2234
2235 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302236 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002237
2238 // Next, we fill out the buffer descriptor:
2239 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2240 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2241 if ( eSIR_SUCCESS != nSirStatus )
2242 {
2243 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002244 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002245 nSirStatus );
2246 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302247 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 return;
2249 }
2250
2251
2252 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002253 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 sizeof(tSirMacMgmtHdr),
2255 nPayload, &nPayload );
2256 if ( DOT11F_FAILED( nStatus ) )
2257 {
2258 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002259 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 nStatus );
2261 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2262 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302263 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 return;
2265 }
2266 else if ( DOT11F_WARNED( nStatus ) )
2267 {
2268 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002269 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 }
2271
2272 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002273 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 nBytes );)
2275 // limPrintMacAddr( pMac, bssid, LOG1 );
2276
2277 if( psessionEntry->assocReq != NULL )
2278 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302279 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 psessionEntry->assocReq = NULL;
2281 }
2282
2283 if( nAddIELen )
2284 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302285 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2286 pAddIE,
2287 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 nPayload += nAddIELen;
2289 }
2290
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302291 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2292 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 {
2294 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2295 }
2296 else
2297 {
2298 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302299 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 psessionEntry->assocReqLen = nPayload;
2301 }
2302
2303 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2305 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 )
2307 {
2308 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2309 }
2310
Ganesh K08bce952012-12-13 15:04:41 -08002311 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2312 {
2313 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2314 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002315
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2317 HAL_TXRX_FRM_802_11_MGMT,
2318 ANI_TXDIR_TODS,
2319 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2320 limTxComplete, pFrame, txFlag );
2321 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2322 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002323 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002324 halstatus );
2325 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302326 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 return;
2328 }
2329
2330 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302331 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002332 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302333 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002334 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002335} // End limSendAssocReqMgmtFrame
2336
2337
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002338#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002339/*------------------------------------------------------------------------------------
2340 *
2341 * Send Reassoc Req with FTIEs.
2342 *
2343 *-----------------------------------------------------------------------------------
2344 */
2345void
2346limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2347 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2348{
2349 static tDot11fReAssocRequest frm;
2350 tANI_U16 caps;
2351 tANI_U8 *pFrame;
2352 tSirRetStatus nSirStatus;
2353 tANI_U32 nBytes, nPayload, nStatus;
2354 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2355 void *pPacket;
2356 eHalStatus halstatus;
2357#if defined WLAN_FEATURE_VOWIFI
2358 tANI_U8 PowerCapsPopulated = FALSE;
2359#endif
2360 tANI_U16 ft_ies_length = 0;
2361 tANI_U8 *pBody;
2362 tANI_U16 nAddIELen;
2363 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002364#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 tANI_U8 *wpsIe = NULL;
2366#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302367 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002368
2369 if (NULL == psessionEntry)
2370 {
2371 return;
2372 }
2373
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 /* check this early to avoid unncessary operation */
2375 if(NULL == psessionEntry->pLimReAssocReq)
2376 {
2377 return;
2378 }
2379 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2380 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002381 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2382 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002383
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302384 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
2386 caps = pMlmReassocReq->capabilityInfo;
2387 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2388 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2389#if defined(FEATURE_WLAN_WAPI)
2390 /* CR: 262463 :
2391 According to WAPI standard:
2392 7.3.1.4 Capability Information field
2393 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2394 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2395 Reassociation management frames. */
2396 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2397 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2398#endif
2399 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2400
2401 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2402
2403 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302404 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2406
2407 PopulateDot11fSSID2( pMac, &frm.SSID );
2408 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2409 &frm.SuppRates,psessionEntry);
2410
2411 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2412 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2413
2414 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2415 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2416
2417 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2418 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2419
2420 if ( psessionEntry->lim11hEnable &&
2421 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2422 {
2423#if defined WLAN_FEATURE_VOWIFI
2424 PowerCapsPopulated = TRUE;
2425
2426 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2427 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2428#endif
2429 }
2430
2431#if defined WLAN_FEATURE_VOWIFI
2432 if( pMac->rrm.rrmPEContext.rrmEnable &&
2433 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2434 {
2435 if (PowerCapsPopulated == FALSE)
2436 {
2437 PowerCapsPopulated = TRUE;
2438 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2439 }
2440 }
2441#endif
2442
2443 if ( fQosEnabled &&
2444 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2445 {
2446 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2447 }
2448
2449 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2450 &frm.ExtSuppRates, psessionEntry );
2451
2452#if defined WLAN_FEATURE_VOWIFI
2453 if( pMac->rrm.rrmPEContext.rrmEnable &&
2454 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2455 {
2456 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2457 }
2458#endif
2459
2460 // Ideally this should be enabled for 11r also. But 11r does
2461 // not follow the usual norm of using the Opaque object
2462 // for rsnie and fties. Instead we just add
2463 // the rsnie and fties at the end of the pack routine for 11r.
2464 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002465#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 //
2467 // The join request *should* contain zero or one of the WPA and RSN
2468 // IEs. The payload send along with the request is a
2469 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2470
2471 // typedef struct sSirRSNie
2472 // {
2473 // tANI_U16 length;
2474 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2475 // } tSirRSNie, *tpSirRSNie;
2476
2477 // So, we should be able to make the following two calls harmlessly,
2478 // since they do nothing if they don't find the given IE in the
2479 // bytestream with which they're provided.
2480
2481 // The net effect of this will be to faithfully transmit whatever
2482 // security IE is in the join request.
2483
2484 // *However*, if we're associating for the purpose of WPS
2485 // enrollment, and we've been configured to indicate that by
2486 // eliding the WPA or RSN IE, we just skip this:
2487 if (!psessionEntry->is11Rconnection)
2488 {
2489 if( nAddIELen && pAddIE )
2490 {
2491 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2492 }
2493 if ( NULL == wpsIe )
2494 {
2495 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2496 &frm.RSNOpaque );
2497 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2498 &frm.WPAOpaque );
2499 }
2500
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002501#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302502 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 {
2504 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2505 &frm.CCXCckmOpaque );
2506 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002507#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 }
2509
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002510#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302512 if (psessionEntry->isCCXconnection &&
2513 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002515#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002517#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302518 PopulateDot11fCCXVersion(&frm.CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302520#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002521#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002522
2523 // include WME EDCA IE as well
2524 if ( fWmeEnabled )
2525 {
2526 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2527 {
2528 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2529 }
2530
2531 if ( fWsmEnabled &&
2532 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2533 {
2534 PopulateDot11fWMMCaps( &frm.WMMCaps );
2535 }
2536#ifdef FEATURE_WLAN_CCX
2537 if (psessionEntry->isCCXconnection)
2538 {
2539 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2540
2541 // Populate the TSRS IE if TSPEC is included in the reassoc request
2542 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2543 {
2544 tANI_U32 phyMode;
2545 tSirMacCCXTSRSIE tsrsIE;
2546 limGetPhyMode(pMac, &phyMode, psessionEntry);
2547
2548 tsrsIE.tsid = 0;
2549 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2550 {
2551 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2552 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302553 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 {
2555 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2556 }
2557 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2558 }
2559 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302560#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 }
2562
Jeff Johnsone7245742012-09-05 17:12:55 -07002563 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 pMac->lim.htCapabilityPresentInBeacon)
2565 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002566 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 }
2568
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002569#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302570 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2571#if defined FEATURE_WLAN_CCX
2572 && !psessionEntry->isCCXconnection
2573#endif
2574 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002575 {
2576 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2577 }
2578#endif
2579
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002580#ifdef WLAN_FEATURE_11AC
2581 if ( psessionEntry->vhtCapability &&
2582 psessionEntry->vhtCapabilityPresentInBeacon)
2583 {
2584 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2585 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
2586 PopulateDot11fExtCap( pMac, &frm.ExtCap);
2587 }
2588#endif
2589
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2591 if ( DOT11F_FAILED( nStatus ) )
2592 {
2593 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002594 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 nStatus );
2596 // We'll fall back on the worst case scenario:
2597 nPayload = sizeof( tDot11fReAssocRequest );
2598 }
2599 else if ( DOT11F_WARNED( nStatus ) )
2600 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002601 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002603 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 }
2605
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002606 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002607
2608#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002609 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2611#endif
2612
2613#if defined WLAN_FEATURE_VOWIFI_11R
2614 if (psessionEntry->is11Rconnection)
2615 {
2616 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2617 }
2618#endif
2619
2620 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2621 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2622 ( void** ) &pPacket );
2623 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2624 {
2625 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002626 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002628 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 goto end;
2630 }
2631
2632 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302633 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002634
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002635#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002636 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002637#endif
2638 // Next, we fill out the buffer descriptor:
2639 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2640 SIR_MAC_MGMT_REASSOC_REQ,
2641 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2642 if ( eSIR_SUCCESS != nSirStatus )
2643 {
2644 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002645 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002646 nSirStatus );
2647 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2648 goto end;
2649 }
2650
2651
2652 // That done, pack the ReAssoc Request:
2653 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2654 sizeof(tSirMacMgmtHdr),
2655 nPayload, &nPayload );
2656 if ( DOT11F_FAILED( nStatus ) )
2657 {
2658 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002659 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 nStatus );
2661 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2662 goto end;
2663 }
2664 else if ( DOT11F_WARNED( nStatus ) )
2665 {
2666 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002667 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 }
2669
2670 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002671 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 nBytes, nPayload );)
2673 if( psessionEntry->assocReq != NULL )
2674 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302675 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 psessionEntry->assocReq = NULL;
2677 }
2678
2679 if( nAddIELen )
2680 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302681 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2682 pAddIE,
2683 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 nPayload += nAddIELen;
2685 }
2686
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302687 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2688 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 {
2690 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002691 }
2692 else
2693 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002694 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302695 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002698
2699 if (psessionEntry->is11Rconnection)
2700 {
2701 {
2702 int i = 0;
2703
2704 pBody = pFrame + nBytes;
2705 for (i=0; i<ft_ies_length; i++)
2706 {
2707 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2708 pBody++;
2709 }
2710 }
2711 }
2712
2713#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002714 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2715 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 (tANI_U8 *)pFrame,
2717 (nBytes + ft_ies_length));)
2718#endif
2719
2720
2721 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2723 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002724 )
2725 {
2726 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2727 }
2728
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002729 if( NULL != psessionEntry->assocReq )
2730 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302731 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002732 psessionEntry->assocReq = NULL;
2733 }
2734
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302735 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2736 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002737 {
2738 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002739 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002740 }
2741 else
2742 {
2743 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302744 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2745 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002746 psessionEntry->assocReqLen = (ft_ies_length);
2747 }
2748
2749
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2751 HAL_TXRX_FRM_802_11_MGMT,
2752 ANI_TXDIR_TODS,
2753 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2754 limTxComplete, pFrame, txFlag );
2755 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2756 {
2757 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002758 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 nSirStatus );
2760 //Pkt will be freed up by the callback
2761 goto end;
2762 }
2763
2764end:
2765 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302766 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 psessionEntry->pLimMlmReassocReq = NULL;
2768
2769}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002770
2771void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2772 tLimMlmReassocReq *pMlmReassocReq,
2773 tpPESession psessionEntry)
2774{
2775 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2776 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2777 if(NULL == pTmpMlmReassocReq)
2778 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302779 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2780 if ( NULL == pTmpMlmReassocReq ) goto end;
2781 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2782 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002783 }
2784
2785 // Prepare and send Reassociation request frame
2786 // start reassoc timer.
2787 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2788 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002789 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002790 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2791 != TX_SUCCESS)
2792 {
2793 // Could not start reassoc failure timer.
2794 // Log error
2795 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002796 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002797 // Return Reassoc confirm with
2798 // Resources Unavailable
2799 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2800 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2801 goto end;
2802 }
2803
2804 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2805 return;
2806
2807end:
2808 // Free up buffer allocated for reassocReq
2809 if (pMlmReassocReq != NULL)
2810 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302811 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002812 pMlmReassocReq = NULL;
2813 }
2814 if (pTmpMlmReassocReq != NULL)
2815 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302816 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002817 pTmpMlmReassocReq = NULL;
2818 }
2819 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2820 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2821 /* Update PE sessio Id*/
2822 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2823
2824 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2825}
2826
Jeff Johnson295189b2012-06-20 16:38:30 -07002827#endif /* WLAN_FEATURE_VOWIFI_11R */
2828
2829
2830void
2831limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2832 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2833{
2834 static tDot11fReAssocRequest frm;
2835 tANI_U16 caps;
2836 tANI_U8 *pFrame;
2837 tSirRetStatus nSirStatus;
2838 tANI_U32 nBytes, nPayload, nStatus;
2839 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2840 void *pPacket;
2841 eHalStatus halstatus;
2842 tANI_U16 nAddIELen;
2843 tANI_U8 *pAddIE;
2844 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302845 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002846#if defined WLAN_FEATURE_VOWIFI
2847 tANI_U8 PowerCapsPopulated = FALSE;
2848#endif
2849
2850 if(NULL == psessionEntry)
2851 {
2852 return;
2853 }
2854
2855 /* check this early to avoid unncessary operation */
2856 if(NULL == psessionEntry->pLimReAssocReq)
2857 {
2858 return;
2859 }
2860 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2861 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2862
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302863 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002864
2865 caps = pMlmReassocReq->capabilityInfo;
2866 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2867 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2868#if defined(FEATURE_WLAN_WAPI)
2869 /* CR: 262463 :
2870 According to WAPI standard:
2871 7.3.1.4 Capability Information field
2872 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2873 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2874 Reassociation management frames. */
2875 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2876 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2877#endif
2878 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2879
2880 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2881
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302882 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2883 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002884
2885 PopulateDot11fSSID2( pMac, &frm.SSID );
2886 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2887 &frm.SuppRates,psessionEntry);
2888
2889 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2890 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2891
2892 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2893 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2894
2895 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2896 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2897
2898
2899 if ( psessionEntry->lim11hEnable &&
2900 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2901 {
2902#if defined WLAN_FEATURE_VOWIFI
2903 PowerCapsPopulated = TRUE;
2904 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2905 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2906#endif
2907 }
2908
2909#if defined WLAN_FEATURE_VOWIFI
2910 if( pMac->rrm.rrmPEContext.rrmEnable &&
2911 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2912 {
2913 if (PowerCapsPopulated == FALSE)
2914 {
2915 PowerCapsPopulated = TRUE;
2916 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2917 }
2918 }
2919#endif
2920
2921 if ( fQosEnabled &&
2922 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2923 {
2924 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2925 }
2926
2927 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2928 &frm.ExtSuppRates, psessionEntry );
2929
2930#if defined WLAN_FEATURE_VOWIFI
2931 if( pMac->rrm.rrmPEContext.rrmEnable &&
2932 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2933 {
2934 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2935 }
2936#endif
2937 // The join request *should* contain zero or one of the WPA and RSN
2938 // IEs. The payload send along with the request is a
2939 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2940
2941 // typedef struct sSirRSNie
2942 // {
2943 // tANI_U16 length;
2944 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2945 // } tSirRSNie, *tpSirRSNie;
2946
2947 // So, we should be able to make the following two calls harmlessly,
2948 // since they do nothing if they don't find the given IE in the
2949 // bytestream with which they're provided.
2950
2951 // The net effect of this will be to faithfully transmit whatever
2952 // security IE is in the join request.
2953
2954 // *However*, if we're associating for the purpose of WPS
2955 // enrollment, and we've been configured to indicate that by
2956 // eliding the WPA or RSN IE, we just skip this:
2957 if( nAddIELen && pAddIE )
2958 {
2959 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2960 }
2961 if ( NULL == wpsIe )
2962 {
2963 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2964 &frm.RSNOpaque );
2965 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2966 &frm.WPAOpaque );
2967#if defined(FEATURE_WLAN_WAPI)
2968 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2969 &frm.WAPIOpaque );
2970#endif // defined(FEATURE_WLAN_WAPI)
2971 }
2972
2973 // include WME EDCA IE as well
2974 if ( fWmeEnabled )
2975 {
2976 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2977 {
2978 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2979 }
2980
2981 if ( fWsmEnabled &&
2982 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2983 {
2984 PopulateDot11fWMMCaps( &frm.WMMCaps );
2985 }
2986 }
2987
Jeff Johnsone7245742012-09-05 17:12:55 -07002988 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 pMac->lim.htCapabilityPresentInBeacon)
2990 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002991 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002993#ifdef WLAN_FEATURE_11AC
2994 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002995 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002996 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002997 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002998 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07002999 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003000 }
3001#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003002
3003 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3004 if ( DOT11F_FAILED( nStatus ) )
3005 {
3006 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003007 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 nStatus );
3009 // We'll fall back on the worst case scenario:
3010 nPayload = sizeof( tDot11fReAssocRequest );
3011 }
3012 else if ( DOT11F_WARNED( nStatus ) )
3013 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003014 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003016 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003017 }
3018
3019 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3020
3021 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3022 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3023 ( void** ) &pPacket );
3024 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3025 {
3026 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003027 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003029 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 goto end;
3031 }
3032
3033 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303034 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003035
3036 // Next, we fill out the buffer descriptor:
3037 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3038 SIR_MAC_MGMT_REASSOC_REQ,
3039 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3040 if ( eSIR_SUCCESS != nSirStatus )
3041 {
3042 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003043 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 nSirStatus );
3045 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3046 goto end;
3047 }
3048
3049
3050 // That done, pack the Probe Request:
3051 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3052 sizeof(tSirMacMgmtHdr),
3053 nPayload, &nPayload );
3054 if ( DOT11F_FAILED( nStatus ) )
3055 {
3056 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003057 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 nStatus );
3059 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3060 goto end;
3061 }
3062 else if ( DOT11F_WARNED( nStatus ) )
3063 {
3064 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003065 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 }
3067
3068 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003069 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 nBytes );)
3071
3072 if( psessionEntry->assocReq != NULL )
3073 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303074 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 psessionEntry->assocReq = NULL;
3076 }
3077
3078 if( nAddIELen )
3079 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303080 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3081 pAddIE,
3082 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 nPayload += nAddIELen;
3084 }
3085
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303086 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3087 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 {
3089 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003090 }
3091 else
3092 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303094 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003097
3098 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3100 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 )
3102 {
3103 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3104 }
3105
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003106 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003107 {
3108 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3109 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003110
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3112 HAL_TXRX_FRM_802_11_MGMT,
3113 ANI_TXDIR_TODS,
3114 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3115 limTxComplete, pFrame, txFlag );
3116 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3117 {
3118 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003119 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 nSirStatus );
3121 //Pkt will be freed up by the callback
3122 goto end;
3123 }
3124
3125end:
3126 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303127 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 psessionEntry->pLimMlmReassocReq = NULL;
3129
3130} // limSendReassocReqMgmtFrame
3131
3132/**
3133 * \brief Send an Authentication frame
3134 *
3135 *
3136 * \param pMac Pointer to Global MAC structure
3137 *
3138 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3139 * to be sent
3140 *
3141 * \param peerMacAddr MAC address of the peer entity to which Authentication
3142 * frame is destined
3143 *
3144 * \param wepBit Indicates whether wep bit to be set in FC while sending
3145 * Authentication frame3
3146 *
3147 *
3148 * This function is called by limProcessMlmMessages(). Authentication frame
3149 * is formatted and sent when this function is called.
3150 *
3151 *
3152 */
3153
3154void
3155limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3156 tpSirMacAuthFrameBody pAuthFrameBody,
3157 tSirMacAddr peerMacAddr,
3158 tANI_U8 wepBit,
3159 tpPESession psessionEntry
3160 )
3161{
3162 tANI_U8 *pFrame, *pBody;
3163 tANI_U32 frameLen = 0, bodyLen = 0;
3164 tpSirMacMgmtHdr pMacHdr;
3165 tANI_U16 i;
3166 void *pPacket;
3167 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303168 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003169
3170 if(NULL == psessionEntry)
3171 {
3172 return;
3173 }
3174
3175 if (wepBit == LIM_WEP_IN_FC)
3176 {
3177 /// Auth frame3 to be sent with encrypted framebody
3178 /**
3179 * Allocate buffer for Authenticaton frame of size equal
3180 * to management frame header length plus 2 bytes each for
3181 * auth algorithm number, transaction number, status code,
3182 * 128 bytes for challenge text and 4 bytes each for
3183 * IV & ICV.
3184 */
3185
3186 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3187
3188 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3189 } // if (wepBit == LIM_WEP_IN_FC)
3190 else
3191 {
3192 switch (pAuthFrameBody->authTransactionSeqNumber)
3193 {
3194 case SIR_MAC_AUTH_FRAME_1:
3195 /**
3196 * Allocate buffer for Authenticaton frame of size
3197 * equal to management frame header length plus 2 bytes
3198 * each for auth algorithm number, transaction number
3199 * and status code.
3200 */
3201
3202 frameLen = sizeof(tSirMacMgmtHdr) +
3203 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3204 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3205
3206#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003207 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3208 {
3209 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003211 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003212 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003213 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003215 else
3216 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003217 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003218 frameLen += (2+SIR_MDIE_SIZE);
3219 }
3220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003221#endif
3222 break;
3223
3224 case SIR_MAC_AUTH_FRAME_2:
3225 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3226 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3227 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3228 {
3229 /**
3230 * Allocate buffer for Authenticaton frame of size
3231 * equal to management frame header length plus
3232 * 2 bytes each for auth algorithm number,
3233 * transaction number and status code.
3234 */
3235
3236 frameLen = sizeof(tSirMacMgmtHdr) +
3237 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3238 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3239 }
3240 else
3241 {
3242 // Shared Key algorithm with challenge text
3243 // to be sent
3244 /**
3245 * Allocate buffer for Authenticaton frame of size
3246 * equal to management frame header length plus
3247 * 2 bytes each for auth algorithm number,
3248 * transaction number, status code and 128 bytes
3249 * for challenge text.
3250 */
3251
3252 frameLen = sizeof(tSirMacMgmtHdr) +
3253 sizeof(tSirMacAuthFrame);
3254 bodyLen = sizeof(tSirMacAuthFrameBody);
3255 }
3256
3257 break;
3258
3259 case SIR_MAC_AUTH_FRAME_3:
3260 /// Auth frame3 to be sent without encrypted framebody
3261 /**
3262 * Allocate buffer for Authenticaton frame of size equal
3263 * to management frame header length plus 2 bytes each
3264 * for auth algorithm number, transaction number and
3265 * status code.
3266 */
3267
3268 frameLen = sizeof(tSirMacMgmtHdr) +
3269 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3270 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3271
3272 break;
3273
3274 case SIR_MAC_AUTH_FRAME_4:
3275 /**
3276 * Allocate buffer for Authenticaton frame of size equal
3277 * to management frame header length plus 2 bytes each
3278 * for auth algorithm number, transaction number and
3279 * status code.
3280 */
3281
3282 frameLen = sizeof(tSirMacMgmtHdr) +
3283 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3284 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3285
3286 break;
3287 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3288 } // end if (wepBit == LIM_WEP_IN_FC)
3289
3290
3291 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3292
3293 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3294 {
3295 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003296 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003297
3298 return;
3299 }
3300
3301 for (i = 0; i < frameLen; i++)
3302 pFrame[i] = 0;
3303
3304 // Prepare BD
3305 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3306 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3307 {
3308 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3309 return;
3310 }
3311
3312 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3313 pMacHdr->fc.wep = wepBit;
3314
3315 // Prepare BSSId
3316 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3317 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303318 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3319 (tANI_U8 *) psessionEntry->bssId,
3320 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 }
3322
3323 /// Prepare Authentication frame body
3324 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3325
3326 if (wepBit == LIM_WEP_IN_FC)
3327 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303328 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003329
3330 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003331 FL("*** Sending Auth seq# 3 status %d (%d) to"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 pAuthFrameBody->authStatusCode,
3333 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3334
3335 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3336 }
3337 else
3338 {
3339 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3340 pBody += sizeof(tANI_U16);
3341 bodyLen -= sizeof(tANI_U16);
3342
3343 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3344 pBody += sizeof(tANI_U16);
3345 bodyLen -= sizeof(tANI_U16);
3346
3347 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3348 pBody += sizeof(tANI_U16);
3349 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003350 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3351 sizeof (pAuthFrameBody->length) +
3352 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303353 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003354
3355#if defined WLAN_FEATURE_VOWIFI_11R
3356 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3357 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3358 {
3359
3360 {
3361 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3363 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003364#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3366 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3367 (tANI_U8 *)pBody,
3368 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003369#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003370 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3371 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003372 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3373 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003374 }
3375 }
3376 else
3377 {
3378 /* MDID attr is 54*/
3379 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003381 *pBody = SIR_MDIE_SIZE;
3382 pBody++;
3383 for(i=0;i<SIR_MDIE_SIZE;i++)
3384 {
3385 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3386 pBody++;
3387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 }
3389 }
3390 }
3391#endif
3392
3393 PELOG1(limLog(pMac, LOG1,
3394 FL("*** Sending Auth seq# %d status %d (%d) to "),
3395 pAuthFrameBody->authTransactionSeqNumber,
3396 pAuthFrameBody->authStatusCode,
3397 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3398
3399 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3400 }
3401 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3402
3403 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3405 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003406#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303407 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003408 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 )
3411 {
3412 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3413 }
3414
Ganesh K08bce952012-12-13 15:04:41 -08003415 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3416 {
3417 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3418 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003419
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 /// Queue Authentication frame in high priority WQ
3421 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3422 HAL_TXRX_FRM_802_11_MGMT,
3423 ANI_TXDIR_TODS,
3424 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3425 limTxComplete, pFrame, txFlag );
3426 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3427 {
3428 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003429 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 halstatus);
3431
3432 //Pkt will be freed up by the callback
3433 }
3434
3435 return;
3436} /*** end limSendAuthMgmtFrame() ***/
3437
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003438eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3439{
3440 tANI_U16 aid;
3441 tpDphHashNode pStaDs;
3442 tLimMlmDeauthReq *pMlmDeauthReq;
3443 tLimMlmDeauthCnf mlmDeauthCnf;
3444 tpPESession psessionEntry;
3445
3446 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3447 if (pMlmDeauthReq)
3448 {
3449 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3450 {
3451 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3452 }
3453
3454 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3455 {
3456
3457 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003458 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003459 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3460 goto end;
3461 }
3462
3463 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3464 if (pStaDs == NULL)
3465 {
3466 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3467 goto end;
3468 }
3469
3470
3471 /// Receive path cleanup with dummy packet
3472 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3473 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303474 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003475 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3476 }
3477 return eHAL_STATUS_SUCCESS;
3478end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303479 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003480 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3481 sizeof(tSirMacAddr));
3482 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3483 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3484 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3485
3486 // Free up buffer allocated
3487 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303488 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003489
3490 limPostSmeMessage(pMac,
3491 LIM_MLM_DEAUTH_CNF,
3492 (tANI_U32 *) &mlmDeauthCnf);
3493 return eHAL_STATUS_SUCCESS;
3494}
3495
3496eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3497{
3498 tANI_U16 aid;
3499 tpDphHashNode pStaDs;
3500 tLimMlmDisassocCnf mlmDisassocCnf;
3501 tpPESession psessionEntry;
3502 tLimMlmDisassocReq *pMlmDisassocReq;
3503
3504 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3505 if (pMlmDisassocReq)
3506 {
3507 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3508 {
3509 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3510 }
3511
3512 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3513 {
3514
3515 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003516 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003517 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3518 goto end;
3519 }
3520
3521 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3522 if (pStaDs == NULL)
3523 {
3524 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3525 goto end;
3526 }
3527
3528 /// Receive path cleanup with dummy packet
3529 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3530 {
3531 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3532 goto end;
3533 }
3534
3535#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003536 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303537 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003538#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303539 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003540#endif
3541#ifdef FEATURE_WLAN_LFR
3542 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003543#endif
3544 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303545 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003546 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003547 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303548 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003549 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003550 psessionEntry, psessionEntry->peSessionId););
3551 limFTCleanup(pMac);
3552 }
3553 else
3554 {
3555 PELOGE(limLog(pMac, LOGE,
3556 FL("No FT Preauth Session Cleanup in role %d"
3557#ifdef FEATURE_WLAN_CCX
3558 " isCCX %d"
3559#endif
3560#ifdef FEATURE_WLAN_LFR
3561 " isLFR %d"
3562#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003563 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003564 psessionEntry->limSystemRole,
3565#ifdef FEATURE_WLAN_CCX
3566 psessionEntry->isCCXconnection,
3567#endif
3568#ifdef FEATURE_WLAN_LFR
3569 psessionEntry->isFastRoamIniFeatureEnabled,
3570#endif
3571 psessionEntry->is11Rconnection,
3572 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003573 }
3574#endif
3575
3576 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303577 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003578 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3579 return eHAL_STATUS_SUCCESS;
3580 }
3581 else
3582 {
3583 return eHAL_STATUS_SUCCESS;
3584 }
3585end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303586 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003587 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3588 sizeof(tSirMacAddr));
3589 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3590 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3591
3592 /* Update PE session ID*/
3593 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3594
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003595 if(pMlmDisassocReq != NULL)
3596 {
3597 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303598 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003599 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3600 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003601
3602 limPostSmeMessage(pMac,
3603 LIM_MLM_DISASSOC_CNF,
3604 (tANI_U32 *) &mlmDisassocCnf);
3605 return eHAL_STATUS_SUCCESS;
3606}
3607
3608eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3609{
3610 return limSendDisassocCnf(pMac);
3611}
3612
3613eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3614{
3615 return limSendDeauthCnf(pMac);
3616}
3617
Jeff Johnson295189b2012-06-20 16:38:30 -07003618/**
3619 * \brief This function is called to send Disassociate frame.
3620 *
3621 *
3622 * \param pMac Pointer to Global MAC structure
3623 *
3624 * \param nReason Indicates the reason that need to be sent in
3625 * Disassociation frame
3626 *
3627 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3628 * sent
3629 *
3630 *
3631 */
3632
3633void
3634limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3635 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003636 tSirMacAddr peer,
3637 tpPESession psessionEntry,
3638 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003639{
3640 tDot11fDisassociation frm;
3641 tANI_U8 *pFrame;
3642 tSirRetStatus nSirStatus;
3643 tpSirMacMgmtHdr pMacHdr;
3644 tANI_U32 nBytes, nPayload, nStatus;
3645 void *pPacket;
3646 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303647 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003648 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 if(NULL == psessionEntry)
3650 {
3651 return;
3652 }
3653
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303654 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003655
3656 frm.Reason.code = nReason;
3657
3658 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3659 if ( DOT11F_FAILED( nStatus ) )
3660 {
3661 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003662 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 nStatus );
3664 // We'll fall back on the worst case scenario:
3665 nPayload = sizeof( tDot11fDisassociation );
3666 }
3667 else if ( DOT11F_WARNED( nStatus ) )
3668 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003669 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003671 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003672 }
3673
3674 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3675
3676 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3677 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3678 ( void** ) &pPacket );
3679 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3680 {
3681 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003682 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 return;
3684 }
3685
3686 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303687 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003688
3689 // Next, we fill out the buffer descriptor:
3690 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3691 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3692 if ( eSIR_SUCCESS != nSirStatus )
3693 {
3694 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003695 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 nSirStatus );
3697 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3698 ( void* ) pFrame, ( void* ) pPacket );
3699 return; // just allocated...
3700 }
3701
3702 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3703
3704 // Prepare the BSSID
3705 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3706
Chet Lanctot186b5732013-03-18 10:26:30 -07003707#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003708 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003709#endif
3710
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3712 sizeof(tSirMacMgmtHdr),
3713 nPayload, &nPayload );
3714 if ( DOT11F_FAILED( nStatus ) )
3715 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003716 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 nStatus );
3718 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3719 ( void* ) pFrame, ( void* ) pPacket );
3720 return; // allocated!
3721 }
3722 else if ( DOT11F_WARNED( nStatus ) )
3723 {
3724 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003725 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 }
3727
3728 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003729 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3731
3732 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3734 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 )
3736 {
3737 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3738 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003739
Ganesh K08bce952012-12-13 15:04:41 -08003740 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303741 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3742 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003743 {
3744 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3745 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003746
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303747 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3748 {
3749 /* This frame will be sent on air by firmware,
3750 which will ensure that this frame goes out
3751 even though DEL_STA is sent immediately */
3752 /* Without this for DEL_STA command there is
3753 risk of flushing frame in BTQM queue without
3754 sending on air */
3755 txFlag |= HAL_USE_FW_IN_TX_PATH;
3756 }
3757
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003758 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003760 // Queue Disassociation frame in high priority WQ
3761 /* get the duration from the request */
3762 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3763 HAL_TXRX_FRM_802_11_MGMT,
3764 ANI_TXDIR_TODS,
3765 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3766 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3767 txFlag );
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303768
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003769 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003770
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003771 if (tx_timer_change(
3772 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3773 != TX_SUCCESS)
3774 {
3775 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003776 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003777 return;
3778 }
3779 else if(TX_SUCCESS != tx_timer_activate(
3780 &pMac->lim.limTimers.gLimDisassocAckTimer))
3781 {
3782 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003783 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003784 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3785 return;
3786 }
3787 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003788 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003789 {
3790 // Queue Disassociation frame in high priority WQ
3791 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3792 HAL_TXRX_FRM_802_11_MGMT,
3793 ANI_TXDIR_TODS,
3794 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3795 limTxComplete, pFrame, txFlag );
3796 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3797 {
3798 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003799 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003800 nSirStatus );
3801 //Pkt will be freed up by the callback
3802 return;
3803 }
3804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003805} // End limSendDisassocMgmtFrame.
3806
3807/**
3808 * \brief This function is called to send a Deauthenticate frame
3809 *
3810 *
3811 * \param pMac Pointer to global MAC structure
3812 *
3813 * \param nReason Indicates the reason that need to be sent in the
3814 * Deauthenticate frame
3815 *
3816 * \param peeer address of the STA to which the frame is to be sent
3817 *
3818 *
3819 */
3820
3821void
3822limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3823 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003824 tSirMacAddr peer,
3825 tpPESession psessionEntry,
3826 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003827{
3828 tDot11fDeAuth frm;
3829 tANI_U8 *pFrame;
3830 tSirRetStatus nSirStatus;
3831 tpSirMacMgmtHdr pMacHdr;
3832 tANI_U32 nBytes, nPayload, nStatus;
3833 void *pPacket;
3834 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303835 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003836 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003837#ifdef FEATURE_WLAN_TDLS
3838 tANI_U16 aid;
3839 tpDphHashNode pStaDs;
3840#endif
3841
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 if(NULL == psessionEntry)
3843 {
3844 return;
3845 }
3846
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303847 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003848
3849 frm.Reason.code = nReason;
3850
3851 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3852 if ( DOT11F_FAILED( nStatus ) )
3853 {
3854 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003855 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 nStatus );
3857 // We'll fall back on the worst case scenario:
3858 nPayload = sizeof( tDot11fDeAuth );
3859 }
3860 else if ( DOT11F_WARNED( nStatus ) )
3861 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003862 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003864 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 }
3866
3867 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3868
3869 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3870 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3871 ( void** ) &pPacket );
3872 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3873 {
3874 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003875 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 return;
3877 }
3878
3879 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303880 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003881
3882 // Next, we fill out the buffer descriptor:
3883 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3884 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3885 if ( eSIR_SUCCESS != nSirStatus )
3886 {
3887 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003888 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 nSirStatus );
3890 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3891 ( void* ) pFrame, ( void* ) pPacket );
3892 return; // just allocated...
3893 }
3894
3895 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3896
3897 // Prepare the BSSID
3898 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3899
Chet Lanctot186b5732013-03-18 10:26:30 -07003900#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003901 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003902#endif
3903
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3905 sizeof(tSirMacMgmtHdr),
3906 nPayload, &nPayload );
3907 if ( DOT11F_FAILED( nStatus ) )
3908 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003909 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 nStatus );
3911 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3912 ( void* ) pFrame, ( void* ) pPacket );
3913 return;
3914 }
3915 else if ( DOT11F_WARNED( nStatus ) )
3916 {
3917 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003918 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 }
3920
3921 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003922 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3924
3925 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3927 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 )
3929 {
3930 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3931 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003932
Ganesh K08bce952012-12-13 15:04:41 -08003933 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303934 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3935 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003936 {
3937 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3938 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003939
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303940 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3941 {
3942 /* This frame will be sent on air by firmware,
3943 which will ensure that this frame goes out
3944 even though DEL_STA is sent immediately */
3945 /* Without this for DEL_STA command there is
3946 risk of flushing frame in BTQM queue without
3947 sending on air */
3948 txFlag |= HAL_USE_FW_IN_TX_PATH;
3949 }
3950
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003951#ifdef FEATURE_WLAN_TDLS
3952 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3953#endif
3954
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003955 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003957 // Queue Disassociation frame in high priority WQ
3958 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3959 HAL_TXRX_FRM_802_11_MGMT,
3960 ANI_TXDIR_TODS,
3961 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3962 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303963
3964 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003965 {
3966 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303967 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003968 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003969 //Pkt will be freed up by the callback limTxComplete
3970
3971 /*Call limProcessDeauthAckTimeout which will send
3972 * DeauthCnf for this frame
3973 */
3974 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003975 return;
3976 }
3977
3978 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3979
3980 if (tx_timer_change(
3981 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3982 != TX_SUCCESS)
3983 {
3984 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003985 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003986 return;
3987 }
3988 else if(TX_SUCCESS != tx_timer_activate(
3989 &pMac->lim.limTimers.gLimDeauthAckTimer))
3990 {
3991 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003992 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003993 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3994 return;
3995 }
3996 }
3997 else
3998 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003999#ifdef FEATURE_WLAN_TDLS
4000 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4001 {
4002 // Queue Disassociation frame in high priority WQ
4003 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004004 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004005 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004006 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4007 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004008 }
4009 else
4010 {
4011#endif
4012 // Queue Disassociation frame in high priority WQ
4013 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4014 HAL_TXRX_FRM_802_11_MGMT,
4015 ANI_TXDIR_TODS,
4016 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4017 limTxComplete, pFrame, txFlag );
4018#ifdef FEATURE_WLAN_TDLS
4019 }
4020#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004021 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4022 {
4023 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004024 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004025 nSirStatus );
4026 //Pkt will be freed up by the callback
4027 return;
4028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 }
4030
4031} // End limSendDeauthMgmtFrame.
4032
4033
4034#ifdef ANI_SUPPORT_11H
4035/**
4036 * \brief Send a Measurement Report Action frame
4037 *
4038 *
4039 * \param pMac Pointer to the global MAC structure
4040 *
4041 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4042 *
4043 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4044 *
4045 *
4046 */
4047
4048tSirRetStatus
4049limSendMeasReportFrame(tpAniSirGlobal pMac,
4050 tpSirMacMeasReqActionFrame pMeasReqFrame,
4051 tSirMacAddr peer)
4052{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304053 tDot11fMeasurementReport frm;
4054 tANI_U8 *pFrame;
4055 tSirRetStatus nSirStatus;
4056 tpSirMacMgmtHdr pMacHdr;
4057 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4058 void *pPacket;
4059 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004060
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304061 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004062
4063 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4064 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4065 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4066
4067 switch ( pMeasReqFrame->measReqIE.measType )
4068 {
4069 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4070 nSirStatus =
4071 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4072 &frm.MeasurementReport );
4073 break;
4074 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4075 nSirStatus =
4076 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4077 &frm.MeasurementReport );
4078 break;
4079 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4080 nSirStatus =
4081 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4082 &frm.MeasurementReport );
4083 break;
4084 default:
4085 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004086 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 pMeasReqFrame->measReqIE.measType );
4088 return eSIR_FAILURE;
4089 }
4090
4091 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4092
4093 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4094 if ( DOT11F_FAILED( nStatus ) )
4095 {
4096 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004097 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 nStatus );
4099 // We'll fall back on the worst case scenario:
4100 nPayload = sizeof( tDot11fMeasurementReport );
4101 }
4102 else if ( DOT11F_WARNED( nStatus ) )
4103 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004104 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004106 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 }
4108
4109 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4110
4111 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4112 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4113 {
4114 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004115 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 return eSIR_FAILURE;
4117 }
4118
4119 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304120 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004121
4122 // Next, we fill out the buffer descriptor:
4123 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4124 SIR_MAC_MGMT_ACTION, peer);
4125 if ( eSIR_SUCCESS != nSirStatus )
4126 {
4127 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004128 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 nSirStatus );
4130 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4131 return eSIR_FAILURE; // just allocated...
4132 }
4133
4134 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4135
4136 nCfg = 6;
4137 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4138 if ( eSIR_SUCCESS != nSirStatus )
4139 {
4140 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004141 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 nSirStatus );
4143 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4144 return eSIR_FAILURE; // just allocated...
4145 }
4146
Chet Lanctot186b5732013-03-18 10:26:30 -07004147#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004148 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004149#endif
4150
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4152 sizeof(tSirMacMgmtHdr),
4153 nPayload, &nPayload );
4154 if ( DOT11F_FAILED( nStatus ) )
4155 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004156 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 nStatus );
4158 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4159 return eSIR_FAILURE; // allocated!
4160 }
4161 else if ( DOT11F_WARNED( nStatus ) )
4162 {
4163 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004164 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 }
4166
4167 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4168 HAL_TXRX_FRM_802_11_MGMT,
4169 ANI_TXDIR_TODS,
4170 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4171 limTxComplete, pFrame, 0 );
4172 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4173 {
4174 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004175 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 nSirStatus );
4177 //Pkt will be freed up by the callback
4178 return eSIR_FAILURE; // just allocated...
4179 }
4180
4181 return eSIR_SUCCESS;
4182
4183} // End limSendMeasReportFrame.
4184
4185
4186/**
4187 * \brief Send a TPC Request Action frame
4188 *
4189 *
4190 * \param pMac Pointer to the global MAC datastructure
4191 *
4192 * \param peer MAC address to which the frame should be sent
4193 *
4194 *
4195 */
4196
4197void
4198limSendTpcRequestFrame(tpAniSirGlobal pMac,
4199 tSirMacAddr peer)
4200{
4201 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304202 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 tSirRetStatus nSirStatus;
4204 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304205 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4206 void *pPacket;
4207 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004208
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304209 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004210
4211 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4212 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4213 frm.DialogToken.token = 1;
4214 frm.TPCRequest.present = 1;
4215
4216 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4217 if ( DOT11F_FAILED( nStatus ) )
4218 {
4219 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004220 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 nStatus );
4222 // We'll fall back on the worst case scenario:
4223 nPayload = sizeof( tDot11fTPCRequest );
4224 }
4225 else if ( DOT11F_WARNED( nStatus ) )
4226 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004227 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004229 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004230 }
4231
4232 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4233
4234 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4235 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4236 {
4237 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004238 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 return;
4240 }
4241
4242 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304243 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004244
4245 // Next, we fill out the buffer descriptor:
4246 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4247 SIR_MAC_MGMT_ACTION, peer);
4248 if ( eSIR_SUCCESS != nSirStatus )
4249 {
4250 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004251 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 nSirStatus );
4253 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4254 return; // just allocated...
4255 }
4256
4257 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4258
4259 nCfg = 6;
4260 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4261 if ( eSIR_SUCCESS != nSirStatus )
4262 {
4263 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004264 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 nSirStatus );
4266 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4267 return; // just allocated...
4268 }
4269
Chet Lanctot186b5732013-03-18 10:26:30 -07004270#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004271 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004272#endif
4273
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4275 sizeof(tSirMacMgmtHdr),
4276 nPayload, &nPayload );
4277 if ( DOT11F_FAILED( nStatus ) )
4278 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004279 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 nStatus );
4281 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4282 return; // allocated!
4283 }
4284 else if ( DOT11F_WARNED( nStatus ) )
4285 {
4286 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004287 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 }
4289
4290 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4291 HAL_TXRX_FRM_802_11_MGMT,
4292 ANI_TXDIR_TODS,
4293 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4294 limTxComplete, pFrame, 0 );
4295 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4296 {
4297 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004298 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 nSirStatus );
4300 //Pkt will be freed up by the callback
4301 return;
4302 }
4303
4304} // End limSendTpcRequestFrame.
4305
4306
4307/**
4308 * \brief Send a TPC Report Action frame
4309 *
4310 *
4311 * \param pMac Pointer to the global MAC datastructure
4312 *
4313 * \param pTpcReqFrame Pointer to the received TPC Request
4314 *
4315 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4316 *
4317 *
4318 */
4319
4320tSirRetStatus
4321limSendTpcReportFrame(tpAniSirGlobal pMac,
4322 tpSirMacTpcReqActionFrame pTpcReqFrame,
4323 tSirMacAddr peer)
4324{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304325 tDot11fTPCReport frm;
4326 tANI_U8 *pFrame;
4327 tSirRetStatus nSirStatus;
4328 tpSirMacMgmtHdr pMacHdr;
4329 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4330 void *pPacket;
4331 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004332
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304333 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004334
4335 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4336 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4337 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4338
4339 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4340 // "misplaced this function, need to replace:
4341 // txPower = halGetRateToPwrValue(pMac, staid,
4342 // pMac->lim.gLimCurrentChannelId, 0);
4343 frm.TPCReport.tx_power = 0;
4344 frm.TPCReport.link_margin = 0;
4345 frm.TPCReport.present = 1;
4346
4347 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4348 if ( DOT11F_FAILED( nStatus ) )
4349 {
4350 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004351 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 nStatus );
4353 // We'll fall back on the worst case scenario:
4354 nPayload = sizeof( tDot11fTPCReport );
4355 }
4356 else if ( DOT11F_WARNED( nStatus ) )
4357 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004358 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004360 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 }
4362
4363 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4364
4365 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4366 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4367 {
4368 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004369 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 return eSIR_FAILURE;
4371 }
4372
4373 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304374 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004375
4376 // Next, we fill out the buffer descriptor:
4377 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4378 SIR_MAC_MGMT_ACTION, peer);
4379 if ( eSIR_SUCCESS != nSirStatus )
4380 {
4381 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004382 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 nSirStatus );
4384 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4385 return eSIR_FAILURE; // just allocated...
4386 }
4387
4388 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4389
4390 nCfg = 6;
4391 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4392 if ( eSIR_SUCCESS != nSirStatus )
4393 {
4394 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004395 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 nSirStatus );
4397 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4398 return eSIR_FAILURE; // just allocated...
4399 }
4400
Chet Lanctot186b5732013-03-18 10:26:30 -07004401#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004402 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004403#endif
4404
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4406 sizeof(tSirMacMgmtHdr),
4407 nPayload, &nPayload );
4408 if ( DOT11F_FAILED( nStatus ) )
4409 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004410 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 nStatus );
4412 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4413 return eSIR_FAILURE; // allocated!
4414 }
4415 else if ( DOT11F_WARNED( nStatus ) )
4416 {
4417 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004418 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 }
4420
4421
4422 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4423 HAL_TXRX_FRM_802_11_MGMT,
4424 ANI_TXDIR_TODS,
4425 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4426 limTxComplete, pFrame, 0 );
4427 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4428 {
4429 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004430 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 nSirStatus );
4432 //Pkt will be freed up by the callback
4433 return eSIR_FAILURE; // just allocated...
4434 }
4435
4436 return eSIR_SUCCESS;
4437
4438} // End limSendTpcReportFrame.
4439#endif //ANI_SUPPORT_11H
4440
4441
Jeff Johnson295189b2012-06-20 16:38:30 -07004442/**
4443 * \brief Send a Channel Switch Announcement
4444 *
4445 *
4446 * \param pMac Pointer to the global MAC datastructure
4447 *
4448 * \param peer MAC address to which this frame will be sent
4449 *
4450 * \param nMode
4451 *
4452 * \param nNewChannel
4453 *
4454 * \param nCount
4455 *
4456 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4457 *
4458 *
4459 */
4460
4461tSirRetStatus
4462limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4463 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004464 tANI_U8 nMode,
4465 tANI_U8 nNewChannel,
4466 tANI_U8 nCount,
4467 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004468{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304469 tDot11fChannelSwitch frm;
4470 tANI_U8 *pFrame;
4471 tSirRetStatus nSirStatus;
4472 tpSirMacMgmtHdr pMacHdr;
4473 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4474 void *pPacket;
4475 eHalStatus halstatus;
4476 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004477
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304478 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004479
4480 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4481 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4482 frm.ChanSwitchAnn.switchMode = nMode;
4483 frm.ChanSwitchAnn.newChannel = nNewChannel;
4484 frm.ChanSwitchAnn.switchCount = nCount;
4485 frm.ChanSwitchAnn.present = 1;
4486
4487 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4488 if ( DOT11F_FAILED( nStatus ) )
4489 {
4490 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004491 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 nStatus );
4493 // We'll fall back on the worst case scenario:
4494 nPayload = sizeof( tDot11fChannelSwitch );
4495 }
4496 else if ( DOT11F_WARNED( nStatus ) )
4497 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004498 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004500 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 }
4502
4503 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4504
4505 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4506 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4507 {
4508 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004509 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 return eSIR_FAILURE;
4511 }
4512
4513 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304514 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004515
4516 // Next, we fill out the buffer descriptor:
4517 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004518 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4519 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304520 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4521 (tANI_U8 *) psessionEntry->bssId,
4522 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 if ( eSIR_SUCCESS != nSirStatus )
4524 {
4525 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004526 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 nSirStatus );
4528 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4529 return eSIR_FAILURE; // just allocated...
4530 }
4531
Jeff Johnsone7245742012-09-05 17:12:55 -07004532#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4534
4535 nCfg = 6;
4536 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4537 if ( eSIR_SUCCESS != nSirStatus )
4538 {
4539 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004540 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 nSirStatus );
4542 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4543 return eSIR_FAILURE; // just allocated...
4544 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004545#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004546
4547#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004548 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004549#endif
4550
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4552 sizeof(tSirMacMgmtHdr),
4553 nPayload, &nPayload );
4554 if ( DOT11F_FAILED( nStatus ) )
4555 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004556 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 nStatus );
4558 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4559 return eSIR_FAILURE; // allocated!
4560 }
4561 else if ( DOT11F_WARNED( nStatus ) )
4562 {
4563 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004564 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 }
4566
Jeff Johnsone7245742012-09-05 17:12:55 -07004567 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004568 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4569 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004570 )
4571 {
4572 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4575 HAL_TXRX_FRM_802_11_MGMT,
4576 ANI_TXDIR_TODS,
4577 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004578 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4580 {
4581 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004582 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 nSirStatus );
4584 //Pkt will be freed up by the callback
4585 return eSIR_FAILURE;
4586 }
4587
4588 return eSIR_SUCCESS;
4589
4590} // End limSendChannelSwitchMgmtFrame.
4591
Jeff Johnson295189b2012-06-20 16:38:30 -07004592
4593
Mohit Khanna4a70d262012-09-11 16:30:12 -07004594#ifdef WLAN_FEATURE_11AC
4595tSirRetStatus
4596limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4597 tSirMacAddr peer,
4598 tANI_U8 nMode,
4599 tpPESession psessionEntry )
4600{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304601 tDot11fOperatingMode frm;
4602 tANI_U8 *pFrame;
4603 tSirRetStatus nSirStatus;
4604 tpSirMacMgmtHdr pMacHdr;
4605 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4606 void *pPacket;
4607 eHalStatus halstatus;
4608 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07004609
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304610 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004611
4612 frm.Category.category = SIR_MAC_ACTION_VHT;
4613 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4614 frm.OperatingMode.chanWidth = nMode;
4615 frm.OperatingMode.rxNSS = 0;
4616 frm.OperatingMode.rxNSSType = 0;
4617
4618 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4619 if ( DOT11F_FAILED( nStatus ) )
4620 {
4621 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004622 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004623 nStatus );
4624 // We'll fall back on the worst case scenario:
4625 nPayload = sizeof( tDot11fOperatingMode);
4626 }
4627 else if ( DOT11F_WARNED( nStatus ) )
4628 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004629 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004630 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004631 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004632 }
4633
4634 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4635
4636 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4637 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4638 {
4639 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004640 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004641 return eSIR_FAILURE;
4642 }
4643
4644 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304645 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004646
4647
4648 // Next, we fill out the buffer descriptor:
4649 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4650 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4651 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4652 } else
4653 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4654 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4655 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304656 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4657 (tANI_U8 *) psessionEntry->bssId,
4658 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004659 if ( eSIR_SUCCESS != nSirStatus )
4660 {
4661 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004662 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004663 nSirStatus );
4664 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4665 return eSIR_FAILURE; // just allocated...
4666 }
4667 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4668 sizeof(tSirMacMgmtHdr),
4669 nPayload, &nPayload );
4670 if ( DOT11F_FAILED( nStatus ) )
4671 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004672 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004673 nStatus );
4674 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4675 return eSIR_FAILURE; // allocated!
4676 }
4677 else if ( DOT11F_WARNED( nStatus ) )
4678 {
4679 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004680 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004681 }
4682 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004683 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4684 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004685 )
4686 {
4687 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4688 }
4689 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4690 HAL_TXRX_FRM_802_11_MGMT,
4691 ANI_TXDIR_TODS,
4692 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4693 limTxComplete, pFrame, txFlag );
4694 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4695 {
4696 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004697 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004698 nSirStatus );
4699 //Pkt will be freed up by the callback
4700 return eSIR_FAILURE;
4701 }
4702
4703 return eSIR_SUCCESS;
4704}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004705
4706/**
4707 * \brief Send a VHT Channel Switch Announcement
4708 *
4709 *
4710 * \param pMac Pointer to the global MAC datastructure
4711 *
4712 * \param peer MAC address to which this frame will be sent
4713 *
4714 * \param nChanWidth
4715 *
4716 * \param nNewChannel
4717 *
4718 *
4719 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4720 *
4721 *
4722 */
4723
4724tSirRetStatus
4725limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4726 tSirMacAddr peer,
4727 tANI_U8 nChanWidth,
4728 tANI_U8 nNewChannel,
4729 tANI_U8 ncbMode,
4730 tpPESession psessionEntry )
4731{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304732 tDot11fChannelSwitch frm;
4733 tANI_U8 *pFrame;
4734 tSirRetStatus nSirStatus;
4735 tpSirMacMgmtHdr pMacHdr;
4736 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4737 void *pPacket;
4738 eHalStatus halstatus;
4739 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004740
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304741 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004742
4743
4744 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4745 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4746 frm.ChanSwitchAnn.switchMode = 1;
4747 frm.ChanSwitchAnn.newChannel = nNewChannel;
4748 frm.ChanSwitchAnn.switchCount = 1;
4749 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4750 frm.ExtChanSwitchAnn.present = 1;
4751 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4752 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4753 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4754 frm.ChanSwitchAnn.present = 1;
4755 frm.WiderBWChanSwitchAnn.present = 1;
4756
4757 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4758 if ( DOT11F_FAILED( nStatus ) )
4759 {
4760 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004761 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004762 nStatus );
4763 // We'll fall back on the worst case scenario:
4764 nPayload = sizeof( tDot11fChannelSwitch );
4765 }
4766 else if ( DOT11F_WARNED( nStatus ) )
4767 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004768 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004769 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004770 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004771 }
4772
4773 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4774
4775 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4776 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4777 {
4778 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004779 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004780 return eSIR_FAILURE;
4781 }
4782 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304783 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004784
4785 // Next, we fill out the buffer descriptor:
4786 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4787 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4788 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304789 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4790 (tANI_U8 *) psessionEntry->bssId,
4791 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004792 if ( eSIR_SUCCESS != nSirStatus )
4793 {
4794 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004795 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004796 nSirStatus );
4797 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4798 return eSIR_FAILURE; // just allocated...
4799 }
4800 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4801 sizeof(tSirMacMgmtHdr),
4802 nPayload, &nPayload );
4803 if ( DOT11F_FAILED( nStatus ) )
4804 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004805 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004806 nStatus );
4807 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4808 return eSIR_FAILURE; // allocated!
4809 }
4810 else if ( DOT11F_WARNED( nStatus ) )
4811 {
4812 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004813 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004814 }
4815
4816 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004817 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4818 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004819 )
4820 {
4821 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4822 }
4823 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4824 HAL_TXRX_FRM_802_11_MGMT,
4825 ANI_TXDIR_TODS,
4826 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4827 limTxComplete, pFrame, txFlag );
4828 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4829 {
4830 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004831 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004832 nSirStatus );
4833 //Pkt will be freed up by the callback
4834 return eSIR_FAILURE;
4835 }
4836
4837 return eSIR_SUCCESS;
4838
4839} // End limSendVHTChannelSwitchMgmtFrame.
4840
4841
4842
Mohit Khanna4a70d262012-09-11 16:30:12 -07004843#endif
4844
Jeff Johnson295189b2012-06-20 16:38:30 -07004845/**
4846 * \brief Send an ADDBA Req Action Frame to peer
4847 *
4848 * \sa limSendAddBAReq
4849 *
4850 * \param pMac The global tpAniSirGlobal object
4851 *
4852 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4853 * the necessary parameters reqd by PE send the ADDBA Req Action
4854 * Frame to the peer
4855 *
4856 * \return eSIR_SUCCESS if setup completes successfully
4857 * eSIR_FAILURE is some problem is encountered
4858 */
4859tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304860 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004861{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304862 tDot11fAddBAReq frmAddBAReq;
4863 tANI_U8 *pAddBAReqBuffer = NULL;
4864 tpSirMacMgmtHdr pMacHdr;
4865 tANI_U32 frameLen = 0, nStatus, nPayload;
4866 tSirRetStatus statusCode;
4867 eHalStatus halStatus;
4868 void *pPacket;
4869 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004870
4871 if(NULL == psessionEntry)
4872 {
4873 return eSIR_FAILURE;
4874 }
4875
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304876 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004877
4878 // Category - 3 (BA)
4879 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4880
4881 // Action - 0 (ADDBA Req)
4882 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4883
4884 // FIXME - Dialog Token, generalize this...
4885 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4886
4887 // Fill the ADDBA Parameter Set
4888 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4889 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4890 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4891
4892 // BA timeout
4893 // 0 - indicates no BA timeout
4894 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4895
4896 // BA Starting Sequence Number
4897 // Fragment number will always be zero
4898 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4899 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4900 }
4901
4902 frmAddBAReq.BAStartingSequenceControl.ssn =
4903 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4904
4905 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4906
4907 if( DOT11F_FAILED( nStatus ))
4908 {
4909 limLog( pMac, LOGW,
4910 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004911 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004912 nStatus );
4913
4914 // We'll fall back on the worst case scenario:
4915 nPayload = sizeof( tDot11fAddBAReq );
4916 }
4917 else if( DOT11F_WARNED( nStatus ))
4918 {
4919 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004920 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004921 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 nStatus );
4923 }
4924
4925 // Add the MGMT header to frame length
4926 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4927
4928 // Need to allocate a buffer for ADDBA AF
4929 if( eHAL_STATUS_SUCCESS !=
4930 (halStatus = palPktAlloc( pMac->hHdd,
4931 HAL_TXRX_FRM_802_11_MGMT,
4932 (tANI_U16) frameLen,
4933 (void **) &pAddBAReqBuffer,
4934 (void **) &pPacket )))
4935 {
4936 // Log error
4937 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004938 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 frameLen,
4940 halStatus );
4941
4942 statusCode = eSIR_MEM_ALLOC_FAILED;
4943 goto returnAfterError;
4944 }
4945
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304946 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004947
4948 // Copy necessary info to BD
4949 if( eSIR_SUCCESS !=
4950 (statusCode = limPopulateMacHeader( pMac,
4951 pAddBAReqBuffer,
4952 SIR_MAC_MGMT_FRAME,
4953 SIR_MAC_MGMT_ACTION,
4954 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4955 goto returnAfterError;
4956
4957 // Update A3 with the BSSID
4958 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4959
4960 #if 0
4961 cfgLen = SIR_MAC_ADDR_LENGTH;
4962 if( eSIR_SUCCESS != cfgGetStr( pMac,
4963 WNI_CFG_BSSID,
4964 (tANI_U8 *) pMacHdr->bssId,
4965 &cfgLen ))
4966 {
4967 limLog( pMac, LOGP,
4968 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004969 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004970
4971 // FIXME - Need to convert to tSirRetStatus
4972 statusCode = eSIR_FAILURE;
4973 goto returnAfterError;
4974 }
4975 #endif//TO SUPPORT BT-AMP
4976 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4977
Chet Lanctot186b5732013-03-18 10:26:30 -07004978#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004979 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004980#endif
4981
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 // Now, we're ready to "pack" the frames
4983 nStatus = dot11fPackAddBAReq( pMac,
4984 &frmAddBAReq,
4985 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4986 nPayload,
4987 &nPayload );
4988
4989 if( DOT11F_FAILED( nStatus ))
4990 {
4991 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004992 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 nStatus );
4994
4995 // FIXME - Need to convert to tSirRetStatus
4996 statusCode = eSIR_FAILURE;
4997 goto returnAfterError;
4998 }
4999 else if( DOT11F_WARNED( nStatus ))
5000 {
5001 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005002 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5003 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 }
5005
5006 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005007 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5009
5010 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5012 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 )
5014 {
5015 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5016 }
5017
5018 if( eHAL_STATUS_SUCCESS !=
5019 (halStatus = halTxFrame( pMac,
5020 pPacket,
5021 (tANI_U16) frameLen,
5022 HAL_TXRX_FRM_802_11_MGMT,
5023 ANI_TXDIR_TODS,
5024 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5025 limTxComplete,
5026 pAddBAReqBuffer, txFlag )))
5027 {
5028 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005029 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 halStatus );
5031
5032 // FIXME - Need to convert eHalStatus to tSirRetStatus
5033 statusCode = eSIR_FAILURE;
5034 //Pkt will be freed up by the callback
5035 return statusCode;
5036 }
5037 else
5038 return eSIR_SUCCESS;
5039
5040returnAfterError:
5041
5042 // Release buffer, if allocated
5043 if( NULL != pAddBAReqBuffer )
5044 palPktFree( pMac->hHdd,
5045 HAL_TXRX_FRM_802_11_MGMT,
5046 (void *) pAddBAReqBuffer,
5047 (void *) pPacket );
5048
5049 return statusCode;
5050}
5051
5052/**
5053 * \brief Send an ADDBA Rsp Action Frame to peer
5054 *
5055 * \sa limSendAddBARsp
5056 *
5057 * \param pMac The global tpAniSirGlobal object
5058 *
5059 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5060 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5061 * Frame to the peer
5062 *
5063 * \return eSIR_SUCCESS if setup completes successfully
5064 * eSIR_FAILURE is some problem is encountered
5065 */
5066tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5067 tpLimMlmAddBARsp pMlmAddBARsp,
5068 tpPESession psessionEntry)
5069{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305070 tDot11fAddBARsp frmAddBARsp;
5071 tANI_U8 *pAddBARspBuffer = NULL;
5072 tpSirMacMgmtHdr pMacHdr;
5073 tANI_U32 frameLen = 0, nStatus, nPayload;
5074 tSirRetStatus statusCode;
5075 eHalStatus halStatus;
5076 void *pPacket;
5077 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005078
5079 if(NULL == psessionEntry)
5080 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005081 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 return eSIR_FAILURE;
5083 }
5084
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305085 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005086
5087 // Category - 3 (BA)
5088 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5089 // Action - 1 (ADDBA Rsp)
5090 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5091
5092 // Should be same as the one we received in the ADDBA Req
5093 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5094
5095 // ADDBA Req status
5096 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5097
5098 // Fill the ADDBA Parameter Set as provided by caller
5099 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5100 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5101 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005102
5103 if(psessionEntry->isAmsduSupportInAMPDU)
5104 {
5105 frmAddBARsp.AddBAParameterSet.amsduSupported =
5106 psessionEntry->amsduSupportedInBA;
5107 }
5108 else
5109 {
5110 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005112
5113 // BA timeout
5114 // 0 - indicates no BA timeout
5115 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5116
5117 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5118
5119 if( DOT11F_FAILED( nStatus ))
5120 {
5121 limLog( pMac, LOGW,
5122 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005123 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 nStatus );
5125
5126 // We'll fall back on the worst case scenario:
5127 nPayload = sizeof( tDot11fAddBARsp );
5128 }
5129 else if( DOT11F_WARNED( nStatus ))
5130 {
5131 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005132 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005133 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 nStatus );
5135 }
5136
5137 // Need to allocate a buffer for ADDBA AF
5138 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5139
5140 // Allocate shared memory
5141 if( eHAL_STATUS_SUCCESS !=
5142 (halStatus = palPktAlloc( pMac->hHdd,
5143 HAL_TXRX_FRM_802_11_MGMT,
5144 (tANI_U16) frameLen,
5145 (void **) &pAddBARspBuffer,
5146 (void **) &pPacket )))
5147 {
5148 // Log error
5149 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005150 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005151 frameLen,
5152 halStatus );
5153
5154 statusCode = eSIR_MEM_ALLOC_FAILED;
5155 goto returnAfterError;
5156 }
5157
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305158 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005159
5160 // Copy necessary info to BD
5161 if( eSIR_SUCCESS !=
5162 (statusCode = limPopulateMacHeader( pMac,
5163 pAddBARspBuffer,
5164 SIR_MAC_MGMT_FRAME,
5165 SIR_MAC_MGMT_ACTION,
5166 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5167 goto returnAfterError;
5168
5169 // Update A3 with the BSSID
5170
5171 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5172
5173 #if 0
5174 cfgLen = SIR_MAC_ADDR_LENGTH;
5175 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5176 WNI_CFG_BSSID,
5177 (tANI_U8 *) pMacHdr->bssId,
5178 &cfgLen ))
5179 {
5180 limLog( pMac, LOGP,
5181 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005182 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005183
5184 // FIXME - Need to convert to tSirRetStatus
5185 statusCode = eSIR_FAILURE;
5186 goto returnAfterError;
5187 }
5188 #endif // TO SUPPORT BT-AMP
5189 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5190
Chet Lanctot186b5732013-03-18 10:26:30 -07005191#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005192 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005193#endif
5194
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 // Now, we're ready to "pack" the frames
5196 nStatus = dot11fPackAddBARsp( pMac,
5197 &frmAddBARsp,
5198 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5199 nPayload,
5200 &nPayload );
5201
5202 if( DOT11F_FAILED( nStatus ))
5203 {
5204 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005205 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 nStatus );
5207
5208 // FIXME - Need to convert to tSirRetStatus
5209 statusCode = eSIR_FAILURE;
5210 goto returnAfterError;
5211 }
5212 else if( DOT11F_WARNED( nStatus ))
5213 {
5214 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005215 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5216 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 }
5218
5219 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005220 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5222
5223 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5225 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 )
5227 {
5228 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5229 }
5230
5231 if( eHAL_STATUS_SUCCESS !=
5232 (halStatus = halTxFrame( pMac,
5233 pPacket,
5234 (tANI_U16) frameLen,
5235 HAL_TXRX_FRM_802_11_MGMT,
5236 ANI_TXDIR_TODS,
5237 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5238 limTxComplete,
5239 pAddBARspBuffer, txFlag )))
5240 {
5241 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005242 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 halStatus );
5244
5245 // FIXME - HAL error codes are different from PE error
5246 // codes!! And, this routine is returning tSirRetStatus
5247 statusCode = eSIR_FAILURE;
5248 //Pkt will be freed up by the callback
5249 return statusCode;
5250 }
5251 else
5252 return eSIR_SUCCESS;
5253
5254 returnAfterError:
5255
5256 // Release buffer, if allocated
5257 if( NULL != pAddBARspBuffer )
5258 palPktFree( pMac->hHdd,
5259 HAL_TXRX_FRM_802_11_MGMT,
5260 (void *) pAddBARspBuffer,
5261 (void *) pPacket );
5262
5263 return statusCode;
5264}
5265
5266/**
5267 * \brief Send a DELBA Indication Action Frame to peer
5268 *
5269 * \sa limSendDelBAInd
5270 *
5271 * \param pMac The global tpAniSirGlobal object
5272 *
5273 * \param peerMacAddr MAC Address of peer
5274 *
5275 * \param reasonCode Reason for the DELBA notification
5276 *
5277 * \param pBAParameterSet The DELBA Parameter Set.
5278 * This identifies the TID for which the BA session is
5279 * being deleted.
5280 *
5281 * \return eSIR_SUCCESS if setup completes successfully
5282 * eSIR_FAILURE is some problem is encountered
5283 */
5284tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5285 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5286{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305287 tDot11fDelBAInd frmDelBAInd;
5288 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305290 tpSirMacMgmtHdr pMacHdr;
5291 tANI_U32 frameLen = 0, nStatus, nPayload;
5292 tSirRetStatus statusCode;
5293 eHalStatus halStatus;
5294 void *pPacket;
5295 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005296
5297 if(NULL == psessionEntry)
5298 {
5299 return eSIR_FAILURE;
5300 }
5301
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305302 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005303
5304 // Category - 3 (BA)
5305 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5306 // Action - 2 (DELBA)
5307 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5308
5309 // Fill the DELBA Parameter Set as provided by caller
5310 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5311 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5312
5313 // BA Starting Sequence Number
5314 // Fragment number will always be zero
5315 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5316
5317 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5318
5319 if( DOT11F_FAILED( nStatus ))
5320 {
5321 limLog( pMac, LOGW,
5322 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005323 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 nStatus );
5325
5326 // We'll fall back on the worst case scenario:
5327 nPayload = sizeof( tDot11fDelBAInd );
5328 }
5329 else if( DOT11F_WARNED( nStatus ))
5330 {
5331 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005332 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005333 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 nStatus );
5335 }
5336
5337 // Add the MGMT header to frame length
5338 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5339
5340 // Allocate shared memory
5341 if( eHAL_STATUS_SUCCESS !=
5342 (halStatus = palPktAlloc( pMac->hHdd,
5343 HAL_TXRX_FRM_802_11_MGMT,
5344 (tANI_U16) frameLen,
5345 (void **) &pDelBAIndBuffer,
5346 (void **) &pPacket )))
5347 {
5348 // Log error
5349 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005350 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 frameLen,
5352 halStatus );
5353
5354 statusCode = eSIR_MEM_ALLOC_FAILED;
5355 goto returnAfterError;
5356 }
5357
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305358 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005359
5360 // Copy necessary info to BD
5361 if( eSIR_SUCCESS !=
5362 (statusCode = limPopulateMacHeader( pMac,
5363 pDelBAIndBuffer,
5364 SIR_MAC_MGMT_FRAME,
5365 SIR_MAC_MGMT_ACTION,
5366 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5367 goto returnAfterError;
5368
5369 // Update A3 with the BSSID
5370 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5371
5372 #if 0
5373 cfgLen = SIR_MAC_ADDR_LENGTH;
5374 if( eSIR_SUCCESS != cfgGetStr( pMac,
5375 WNI_CFG_BSSID,
5376 (tANI_U8 *) pMacHdr->bssId,
5377 &cfgLen ))
5378 {
5379 limLog( pMac, LOGP,
5380 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005381 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005382
5383 // FIXME - Need to convert to tSirRetStatus
5384 statusCode = eSIR_FAILURE;
5385 goto returnAfterError;
5386 }
5387 #endif //TO SUPPORT BT-AMP
5388 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5389
Chet Lanctot186b5732013-03-18 10:26:30 -07005390#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005391 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005392#endif
5393
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 // Now, we're ready to "pack" the frames
5395 nStatus = dot11fPackDelBAInd( pMac,
5396 &frmDelBAInd,
5397 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5398 nPayload,
5399 &nPayload );
5400
5401 if( DOT11F_FAILED( nStatus ))
5402 {
5403 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005404 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 nStatus );
5406
5407 // FIXME - Need to convert to tSirRetStatus
5408 statusCode = eSIR_FAILURE;
5409 goto returnAfterError;
5410 }
5411 else if( DOT11F_WARNED( nStatus ))
5412 {
5413 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005414 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5415 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 }
5417
5418 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005419 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5421
5422 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5424 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 )
5426 {
5427 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5428 }
5429
5430 if( eHAL_STATUS_SUCCESS !=
5431 (halStatus = halTxFrame( pMac,
5432 pPacket,
5433 (tANI_U16) frameLen,
5434 HAL_TXRX_FRM_802_11_MGMT,
5435 ANI_TXDIR_TODS,
5436 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5437 limTxComplete,
5438 pDelBAIndBuffer, txFlag )))
5439 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005440 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 statusCode = eSIR_FAILURE;
5442 //Pkt will be freed up by the callback
5443 return statusCode;
5444 }
5445 else
5446 return eSIR_SUCCESS;
5447
5448 returnAfterError:
5449
5450 // Release buffer, if allocated
5451 if( NULL != pDelBAIndBuffer )
5452 palPktFree( pMac->hHdd,
5453 HAL_TXRX_FRM_802_11_MGMT,
5454 (void *) pDelBAIndBuffer,
5455 (void *) pPacket );
5456
5457 return statusCode;
5458}
5459
5460#if defined WLAN_FEATURE_VOWIFI
5461
5462/**
5463 * \brief Send a Neighbor Report Request Action frame
5464 *
5465 *
5466 * \param pMac Pointer to the global MAC structure
5467 *
5468 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5469 *
5470 * \param peer mac address of peer station.
5471 *
5472 * \param psessionEntry address of session entry.
5473 *
5474 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5475 *
5476 *
5477 */
5478
5479tSirRetStatus
5480limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5481 tpSirMacNeighborReportReq pNeighborReq,
5482 tSirMacAddr peer,
5483 tpPESession psessionEntry
5484 )
5485{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305486 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 tDot11fNeighborReportRequest frm;
5488 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305489 tpSirMacMgmtHdr pMacHdr;
5490 tANI_U32 nBytes, nPayload, nStatus;
5491 void *pPacket;
5492 eHalStatus halstatus;
5493 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005494
5495 if ( psessionEntry == NULL )
5496 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005497 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 return eSIR_FAILURE;
5499 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305500 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005501
5502 frm.Category.category = SIR_MAC_ACTION_RRM;
5503 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5504 frm.DialogToken.token = pNeighborReq->dialogToken;
5505
5506
5507 if( pNeighborReq->ssid_present )
5508 {
5509 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5510 }
5511
5512 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5513 if ( DOT11F_FAILED( nStatus ) )
5514 {
5515 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005516 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005517 nStatus );
5518 // We'll fall back on the worst case scenario:
5519 nPayload = sizeof( tDot11fNeighborReportRequest );
5520 }
5521 else if ( DOT11F_WARNED( nStatus ) )
5522 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005523 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005525 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 }
5527
5528 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5529
5530 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5531 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5532 {
5533 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005534 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 return eSIR_FAILURE;
5536 }
5537
5538 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305539 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005540
5541 // Copy necessary info to BD
5542 if( eSIR_SUCCESS !=
5543 (statusCode = limPopulateMacHeader( pMac,
5544 pFrame,
5545 SIR_MAC_MGMT_FRAME,
5546 SIR_MAC_MGMT_ACTION,
5547 peer, psessionEntry->selfMacAddr)))
5548 goto returnAfterError;
5549
5550 // Update A3 with the BSSID
5551 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5552
5553 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5554
Chet Lanctot186b5732013-03-18 10:26:30 -07005555#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005556 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005557#endif
5558
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 // Now, we're ready to "pack" the frames
5560 nStatus = dot11fPackNeighborReportRequest( pMac,
5561 &frm,
5562 pFrame + sizeof( tSirMacMgmtHdr ),
5563 nPayload,
5564 &nPayload );
5565
5566 if( DOT11F_FAILED( nStatus ))
5567 {
5568 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005569 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 nStatus );
5571
5572 // FIXME - Need to convert to tSirRetStatus
5573 statusCode = eSIR_FAILURE;
5574 goto returnAfterError;
5575 }
5576 else if( DOT11F_WARNED( nStatus ))
5577 {
5578 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005579 FL( "There were warnings while packing Neighbor Report "
5580 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 }
5582
5583 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005584 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 limPrintMacAddr( pMac, peer, LOGW );
5586
5587 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5589 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 )
5591 {
5592 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5593 }
5594
5595 if( eHAL_STATUS_SUCCESS !=
5596 (halstatus = halTxFrame( pMac,
5597 pPacket,
5598 (tANI_U16) nBytes,
5599 HAL_TXRX_FRM_802_11_MGMT,
5600 ANI_TXDIR_TODS,
5601 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5602 limTxComplete,
5603 pFrame, txFlag )))
5604 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005605 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 statusCode = eSIR_FAILURE;
5607 //Pkt will be freed up by the callback
5608 return statusCode;
5609 }
5610 else
5611 return eSIR_SUCCESS;
5612
5613returnAfterError:
5614 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5615
5616 return statusCode;
5617} // End limSendNeighborReportRequestFrame.
5618
5619/**
5620 * \brief Send a Link Report Action frame
5621 *
5622 *
5623 * \param pMac Pointer to the global MAC structure
5624 *
5625 * \param pLinkReport Address of a tSirMacLinkReport
5626 *
5627 * \param peer mac address of peer station.
5628 *
5629 * \param psessionEntry address of session entry.
5630 *
5631 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5632 *
5633 *
5634 */
5635
5636tSirRetStatus
5637limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5638 tpSirMacLinkReport pLinkReport,
5639 tSirMacAddr peer,
5640 tpPESession psessionEntry
5641 )
5642{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305643 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 tDot11fLinkMeasurementReport frm;
5645 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305646 tpSirMacMgmtHdr pMacHdr;
5647 tANI_U32 nBytes, nPayload, nStatus;
5648 void *pPacket;
5649 eHalStatus halstatus;
5650 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005651
5652
5653 if ( psessionEntry == NULL )
5654 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005655 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 return eSIR_FAILURE;
5657 }
5658
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305659 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005660
5661 frm.Category.category = SIR_MAC_ACTION_RRM;
5662 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5663 frm.DialogToken.token = pLinkReport->dialogToken;
5664
5665
5666 //IEEE Std. 802.11 7.3.2.18. for the report element.
5667 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5668 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5669 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5670 //such case this way than changing the frame parser.
5671 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5672 frm.TPCEleLen.TPCLen = 2;
5673 frm.TxPower.txPower = pLinkReport->txPower;
5674 frm.LinkMargin.linkMargin = 0;
5675
5676 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5677 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5678 frm.RCPI.rcpi = pLinkReport->rcpi;
5679 frm.RSNI.rsni = pLinkReport->rsni;
5680
5681 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5682 if ( DOT11F_FAILED( nStatus ) )
5683 {
5684 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005685 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 nStatus );
5687 // We'll fall back on the worst case scenario:
5688 nPayload = sizeof( tDot11fLinkMeasurementReport );
5689 }
5690 else if ( DOT11F_WARNED( nStatus ) )
5691 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005692 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005694 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005695 }
5696
5697 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5698
5699 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5700 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5701 {
5702 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005703 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 return eSIR_FAILURE;
5705 }
5706
5707 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305708 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005709
5710 // Copy necessary info to BD
5711 if( eSIR_SUCCESS !=
5712 (statusCode = limPopulateMacHeader( pMac,
5713 pFrame,
5714 SIR_MAC_MGMT_FRAME,
5715 SIR_MAC_MGMT_ACTION,
5716 peer, psessionEntry->selfMacAddr)))
5717 goto returnAfterError;
5718
5719 // Update A3 with the BSSID
5720 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5721
5722 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5723
Chet Lanctot186b5732013-03-18 10:26:30 -07005724#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005725 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005726#endif
5727
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 // Now, we're ready to "pack" the frames
5729 nStatus = dot11fPackLinkMeasurementReport( pMac,
5730 &frm,
5731 pFrame + sizeof( tSirMacMgmtHdr ),
5732 nPayload,
5733 &nPayload );
5734
5735 if( DOT11F_FAILED( nStatus ))
5736 {
5737 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005738 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 nStatus );
5740
5741 // FIXME - Need to convert to tSirRetStatus
5742 statusCode = eSIR_FAILURE;
5743 goto returnAfterError;
5744 }
5745 else if( DOT11F_WARNED( nStatus ))
5746 {
5747 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005748 FL( "There were warnings while packing Link Report (0x%08x)." ),
5749 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 }
5751
5752 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005753 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 limPrintMacAddr( pMac, peer, LOGW );
5755
5756 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5758 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 )
5760 {
5761 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5762 }
5763
5764 if( eHAL_STATUS_SUCCESS !=
5765 (halstatus = halTxFrame( pMac,
5766 pPacket,
5767 (tANI_U16) nBytes,
5768 HAL_TXRX_FRM_802_11_MGMT,
5769 ANI_TXDIR_TODS,
5770 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5771 limTxComplete,
5772 pFrame, txFlag )))
5773 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005774 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 statusCode = eSIR_FAILURE;
5776 //Pkt will be freed up by the callback
5777 return statusCode;
5778 }
5779 else
5780 return eSIR_SUCCESS;
5781
5782returnAfterError:
5783 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5784
5785 return statusCode;
5786} // End limSendLinkReportActionFrame.
5787
5788/**
5789 * \brief Send a Beacon Report Action frame
5790 *
5791 *
5792 * \param pMac Pointer to the global MAC structure
5793 *
5794 * \param dialog_token dialog token to be used in the action frame.
5795 *
5796 * \param num_report number of reports in pRRMReport.
5797 *
5798 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5799 *
5800 * \param peer mac address of peer station.
5801 *
5802 * \param psessionEntry address of session entry.
5803 *
5804 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5805 *
5806 *
5807 */
5808
5809tSirRetStatus
5810limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5811 tANI_U8 dialog_token,
5812 tANI_U8 num_report,
5813 tpSirMacRadioMeasureReport pRRMReport,
5814 tSirMacAddr peer,
5815 tpPESession psessionEntry
5816 )
5817{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305818 tSirRetStatus statusCode = eSIR_SUCCESS;
5819 tANI_U8 *pFrame;
5820 tpSirMacMgmtHdr pMacHdr;
5821 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305823 eHalStatus halstatus;
5824 tANI_U8 i;
5825 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005826
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005827 tDot11fRadioMeasurementReport *frm =
5828 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5829 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005830 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005831 return eSIR_FAILURE;
5832 }
5833
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 if ( psessionEntry == NULL )
5835 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005836 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005837 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 return eSIR_FAILURE;
5839 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305840 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005841
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005842 frm->Category.category = SIR_MAC_ACTION_RRM;
5843 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5844 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005845
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005846 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 -07005847
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005848 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005850 frm->MeasurementReport[i].type = pRRMReport[i].type;
5851 frm->MeasurementReport[i].token = pRRMReport[i].token;
5852 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 switch( pRRMReport[i].type )
5854 {
5855 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005856 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5857 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5858 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5859 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 break;
5861 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305862 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5863 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005864 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 break;
5866 }
5867 }
5868
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005869 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 if ( DOT11F_FAILED( nStatus ) )
5871 {
5872 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005873 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 nStatus );
5875 // We'll fall back on the worst case scenario:
5876 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005877 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 return eSIR_FAILURE;
5879 }
5880 else if ( DOT11F_WARNED( nStatus ) )
5881 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005882 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005884 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 }
5886
5887 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5888
5889 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5890 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5891 {
5892 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005893 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005894 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005895 return eSIR_FAILURE;
5896 }
5897
5898 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305899 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005900
5901 // Copy necessary info to BD
5902 if( eSIR_SUCCESS !=
5903 (statusCode = limPopulateMacHeader( pMac,
5904 pFrame,
5905 SIR_MAC_MGMT_FRAME,
5906 SIR_MAC_MGMT_ACTION,
5907 peer, psessionEntry->selfMacAddr)))
5908 goto returnAfterError;
5909
5910 // Update A3 with the BSSID
5911 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5912
5913 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5914
Chet Lanctot186b5732013-03-18 10:26:30 -07005915#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005916 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005917#endif
5918
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 // Now, we're ready to "pack" the frames
5920 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005921 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 pFrame + sizeof( tSirMacMgmtHdr ),
5923 nPayload,
5924 &nPayload );
5925
5926 if( DOT11F_FAILED( nStatus ))
5927 {
5928 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005929 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 nStatus );
5931
5932 // FIXME - Need to convert to tSirRetStatus
5933 statusCode = eSIR_FAILURE;
5934 goto returnAfterError;
5935 }
5936 else if( DOT11F_WARNED( nStatus ))
5937 {
5938 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005939 FL( "There were warnings while packing Radio "
5940 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 }
5942
5943 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005944 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 limPrintMacAddr( pMac, peer, LOGW );
5946
5947 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5949 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 )
5951 {
5952 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5953 }
5954
5955 if( eHAL_STATUS_SUCCESS !=
5956 (halstatus = halTxFrame( pMac,
5957 pPacket,
5958 (tANI_U16) nBytes,
5959 HAL_TXRX_FRM_802_11_MGMT,
5960 ANI_TXDIR_TODS,
5961 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5962 limTxComplete,
5963 pFrame, txFlag )))
5964 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005965 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 statusCode = eSIR_FAILURE;
5967 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005968 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 return statusCode;
5970 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005971 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005972 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005974 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005975
5976returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005977 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 return statusCode;
5980} // End limSendBeaconReportActionFrame.
5981
5982#endif
5983
5984#ifdef WLAN_FEATURE_11W
5985/**
5986 * \brief Send SA query response action frame to peer
5987 *
5988 * \sa limSendSaQueryResponseFrame
5989 *
5990 *
5991 * \param pMac The global tpAniSirGlobal object
5992 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005993 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005995 * \param peer The Mac address of the AP to which this action frame is addressed
5996 *
5997 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 *
5999 * \return eSIR_SUCCESS if setup completes successfully
6000 * eSIR_FAILURE is some problem is encountered
6001 */
6002
Chet Lanctot186b5732013-03-18 10:26:30 -07006003tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006004tSirMacAddr peer,tpPESession psessionEntry)
6005{
6006
Chet Lanctot186b5732013-03-18 10:26:30 -07006007 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 tANI_U8 *pFrame;
6009 tSirRetStatus nSirStatus;
6010 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006011 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 void *pPacket;
6013 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306014 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006015
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306016 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006017 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6018 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 action: 0 --> SA query request action frame
6020 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006021 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6022 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006024 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006025
Chet Lanctot186b5732013-03-18 10:26:30 -07006026 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6027 if ( DOT11F_FAILED( nStatus ) )
6028 {
6029 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6030 "or a SA Query Response (0x%08x)."),
6031 nStatus );
6032 // We'll fall back on the worst case scenario:
6033 nPayload = sizeof( tDot11fSaQueryRsp );
6034 }
6035 else if ( DOT11F_WARNED( nStatus ) )
6036 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006037 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006038 "the packed size for an SA Query Response"
6039 " (0x%08x)."), nStatus );
6040 }
6041
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6043 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6044 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6045 {
6046 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006047 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 return eSIR_FAILURE;
6049 }
6050
6051 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306052 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006053
Chet Lanctot186b5732013-03-18 10:26:30 -07006054 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006055 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006056 pFrame,
6057 SIR_MAC_MGMT_FRAME,
6058 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006059 peer, psessionEntry->selfMacAddr );
6060 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006061 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006062
Chet Lanctot186b5732013-03-18 10:26:30 -07006063 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6065
Chet Lanctot186b5732013-03-18 10:26:30 -07006066 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006067
Chet Lanctot186b5732013-03-18 10:26:30 -07006068 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6069 // in the FC
6070 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006072 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 }
6074
Chet Lanctot186b5732013-03-18 10:26:30 -07006075 // Pack 11w SA query response frame
6076 nStatus = dot11fPackSaQueryRsp( pMac,
6077 &frm,
6078 pFrame + sizeof( tSirMacMgmtHdr ),
6079 nPayload,
6080 &nPayload );
6081
6082 if ( DOT11F_FAILED( nStatus ))
6083 {
6084 limLog( pMac, LOGE,
6085 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6086 nStatus );
6087 // FIXME - Need to convert to tSirRetStatus
6088 nSirStatus = eSIR_FAILURE;
6089 goto returnAfterError;
6090 }
6091 else if ( DOT11F_WARNED( nStatus ))
6092 {
6093 limLog( pMac, LOGW,
6094 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6095 nStatus);
6096 }
6097
6098 limLog( pMac, LOG1,
6099 FL( "Sending a SA Query Response to " ));
6100 limPrintMacAddr( pMac, peer, LOGW );
6101
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006102 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006103#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006104 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6105 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006106#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006107 )
6108 {
6109 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6110 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006111
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006112 halstatus = halTxFrame( pMac,
6113 pPacket,
6114 (tANI_U16) nBytes,
6115 HAL_TXRX_FRM_802_11_MGMT,
6116 ANI_TXDIR_TODS,
6117 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6118 limTxComplete,
6119 pFrame, txFlag );
6120 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006121 {
6122 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6123 nSirStatus = eSIR_FAILURE;
6124 //Pkt will be freed up by the callback
6125 return nSirStatus;
6126 }
6127 else {
6128 return eSIR_SUCCESS;
6129 }
6130
6131returnAfterError:
6132 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6133 return nSirStatus;
6134} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006135#endif