blob: 849158d97692a7c90f491c7e76e6a3d22fe46061 [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,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +0530895 FL("Not able to insert NoA because of length constraint."
896 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530897 vos_mem_free(addIE);
898 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -0700899 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
900 ( void* ) pFrame, ( void* ) pPacket );
901 return;
902 }
903 else
904 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530905 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -0700906 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 }
908 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700909
910 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
912 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 )
914 {
915 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
916 }
917
918 // Queue Probe Response frame in high priority WQ
919 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
920 ( tANI_U16 ) nBytes,
921 HAL_TXRX_FRM_802_11_MGMT,
922 ANI_TXDIR_TODS,
923 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
924 limTxComplete, pFrame, txFlag );
925 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
926 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700927 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 //Pkt will be freed up by the callback
929 }
930
931 if ( addIE != NULL )
932 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530933 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 }
935
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530936 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700937 return;
938
939
Jeff Johnson295189b2012-06-20 16:38:30 -0700940} // End limSendProbeRspMgmtFrame.
941
942void
943limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
944 tSirMacAddr peerMacAddr,
945 tSirAddtsReqInfo *pAddTS,
946 tpPESession psessionEntry)
947{
948 tANI_U16 i;
949 tANI_U8 *pFrame;
950 tSirRetStatus nSirStatus;
951 tDot11fAddTSRequest AddTSReq;
952 tDot11fWMMAddTSRequest WMMAddTSReq;
953 tANI_U32 nPayload, nBytes, nStatus;
954 tpSirMacMgmtHdr pMacHdr;
955 void *pPacket;
956#ifdef FEATURE_WLAN_CCX
957 tANI_U32 phyMode;
958#endif
959 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530960 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700961
962 if(NULL == psessionEntry)
963 {
964 return;
965 }
966
967 if ( ! pAddTS->wmeTspecPresent )
968 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530969 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700970
971 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
972 AddTSReq.DialogToken.token = pAddTS->dialogToken;
973 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
974 if ( pAddTS->lleTspecPresent )
975 {
976 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
977 }
978 else
979 {
980 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
981 }
982
983 if ( pAddTS->lleTspecPresent )
984 {
985 AddTSReq.num_WMMTCLAS = 0;
986 AddTSReq.num_TCLAS = pAddTS->numTclas;
987 for ( i = 0; i < pAddTS->numTclas; ++i)
988 {
989 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
990 &AddTSReq.TCLAS[i] );
991 }
992 }
993 else
994 {
995 AddTSReq.num_TCLAS = 0;
996 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
997 for ( i = 0; i < pAddTS->numTclas; ++i)
998 {
999 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1000 &AddTSReq.WMMTCLAS[i] );
1001 }
1002 }
1003
1004 if ( pAddTS->tclasProcPresent )
1005 {
1006 if ( pAddTS->lleTspecPresent )
1007 {
1008 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1009 AddTSReq.TCLASSPROC.present = 1;
1010 }
1011 else
1012 {
1013 AddTSReq.WMMTCLASPROC.version = 1;
1014 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1015 AddTSReq.WMMTCLASPROC.present = 1;
1016 }
1017 }
1018
1019 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1020 if ( DOT11F_FAILED( nStatus ) )
1021 {
1022 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001023 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 nStatus );
1025 // We'll fall back on the worst case scenario:
1026 nPayload = sizeof( tDot11fAddTSRequest );
1027 }
1028 else if ( DOT11F_WARNED( nStatus ) )
1029 {
1030 limLog( pMac, LOGW, FL("There were warnings while calculating"
1031 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001032 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 }
1034 }
1035 else
1036 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301037 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001038
1039 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1040 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1041 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1042
1043 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1044 WMMAddTSReq.StatusCode.statusCode = 0;
1045
1046 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1047#ifdef FEATURE_WLAN_CCX
1048 limGetPhyMode(pMac, &phyMode, psessionEntry);
1049
1050 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1051 {
1052 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1053 }
1054 else
1055 {
1056 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1057 }
1058 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1059#endif
1060 // fillWmeTspecIE
1061
1062 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1063 if ( DOT11F_FAILED( nStatus ) )
1064 {
1065 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001066 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 nStatus );
1068 // We'll fall back on the worst case scenario:
1069 nPayload = sizeof( tDot11fAddTSRequest );
1070 }
1071 else if ( DOT11F_WARNED( nStatus ) )
1072 {
1073 limLog( pMac, LOGW, FL("There were warnings while calculating"
1074 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001075 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 }
1077 }
1078
1079 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1080
1081 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1082 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1083 ( void** ) &pPacket );
1084 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1085 {
1086 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001087 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 return;
1089 }
1090
1091 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301092 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001093
1094 // Next, we fill out the buffer descriptor:
1095 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1096 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1097 if ( eSIR_SUCCESS != nSirStatus )
1098 {
1099 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001100 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 nSirStatus );
1102 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1103 ( void* ) pFrame, ( void* ) pPacket );
1104 return;
1105 }
1106
1107 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1108
1109 #if 0
1110 cfgLen = SIR_MAC_ADDR_LENGTH;
1111 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1112 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1113 {
1114 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001115 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1117 ( void* ) pFrame, ( void* ) pPacket );
1118 return;
1119 }
1120 #endif //TO SUPPORT BT-AMP
1121
1122 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1123
Chet Lanctot186b5732013-03-18 10:26:30 -07001124#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001125 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001126#endif
1127
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 // That done, pack the struct:
1129 if ( ! pAddTS->wmeTspecPresent )
1130 {
1131 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1132 pFrame + sizeof(tSirMacMgmtHdr),
1133 nPayload, &nPayload );
1134 if ( DOT11F_FAILED( nStatus ) )
1135 {
1136 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001137 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 nStatus );
1139 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1140 return; // allocated!
1141 }
1142 else if ( DOT11F_WARNED( nStatus ) )
1143 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001144 limLog( pMac, LOGW, FL("There were warnings while packing "
1145 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 }
1147 }
1148 else
1149 {
1150 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1151 pFrame + sizeof(tSirMacMgmtHdr),
1152 nPayload, &nPayload );
1153 if ( DOT11F_FAILED( nStatus ) )
1154 {
1155 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001156 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 nStatus );
1158 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1159 return; // allocated!
1160 }
1161 else if ( DOT11F_WARNED( nStatus ) )
1162 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001163 limLog( pMac, LOGW, FL("There were warnings while packing "
1164 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 }
1166 }
1167
1168 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1169 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1170
1171 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1173 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 )
1175 {
1176 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1177 }
1178
1179 // Queue Addts Response frame in high priority WQ
1180 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1181 HAL_TXRX_FRM_802_11_MGMT,
1182 ANI_TXDIR_TODS,
1183 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1184 limTxComplete, pFrame, txFlag );
1185 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1186 {
1187 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001188 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 //Pkt will be freed up by the callback
1190 }
1191
1192} // End limSendAddtsReqActionFrame.
1193
Jeff Johnson295189b2012-06-20 16:38:30 -07001194
1195
1196void
1197limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1198 tANI_U16 statusCode,
1199 tANI_U16 aid,
1200 tSirMacAddr peerMacAddr,
1201 tANI_U8 subType,
1202 tpDphHashNode pSta,tpPESession psessionEntry)
1203{
1204 static tDot11fAssocResponse frm;
1205 tANI_U8 *pFrame, *macAddr;
1206 tpSirMacMgmtHdr pMacHdr;
1207 tSirRetStatus nSirStatus;
1208 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1209 tHalBitVal qosMode, wmeMode;
1210 tANI_U32 nPayload, nBytes, nStatus;
1211 void *pPacket;
1212 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301213 tUpdateBeaconParams beaconParams;
1214 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 tANI_U32 addnIEPresent = false;
1216 tANI_U32 addnIELen=0;
1217 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1218 tpSirAssocReq pAssocReq = NULL;
1219
1220 if(NULL == psessionEntry)
1221 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301222 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 return;
1224 }
1225
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301226 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001227
1228 limGetQosMode(psessionEntry, &qosMode);
1229 limGetWmeMode(psessionEntry, &wmeMode);
1230
1231 // An Add TS IE is added only if the AP supports it and the requesting
1232 // STA sent a traffic spec.
1233 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1234
1235 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1236
1237 frm.Status.status = statusCode;
1238
1239 frm.AID.associd = aid | LIM_AID_MASK;
1240
1241 if ( NULL == pSta )
1242 {
1243 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1244 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1245 }
1246 else
1247 {
1248 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1249 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1250 }
1251
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1253 {
1254 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1255 {
1256 pAssocReq =
1257 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1259 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1260 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 }
1263 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001264
1265 if ( NULL != pSta )
1266 {
1267 if ( eHAL_SET == qosMode )
1268 {
1269 if ( pSta->lleEnabled )
1270 {
1271 lleMode = 1;
1272 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1273 {
1274 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1275
1276// FramesToDo:...
1277// if ( fAddTS )
1278// {
1279// tANI_U8 *pAf = pBody;
1280// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1281// tANI_U32 tlen;
1282// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1283// &tlen, bufLen - frameLen);
1284// } // End if on Add TS.
1285 }
1286 } // End if on .11e enabled in 'pSta'.
1287 } // End if on QOS Mode on.
1288
1289 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1290 {
1291 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1292 {
1293
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001295
1296 if ( pSta->wsmEnabled )
1297 {
1298 PopulateDot11fWMMCaps(&frm.WMMCaps );
1299 }
1300 }
1301 }
1302
1303 if ( pSta->aniPeer )
1304 {
1305 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1306 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1307 {
1308 edcaInclude = 1;
1309 }
1310
1311 } // End if on Airgo peer.
1312
1313 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001314 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001316 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001319
1320#ifdef WLAN_FEATURE_11AC
1321 if( pSta->mlmStaContext.vhtCapability &&
1322 psessionEntry->vhtCapability )
1323 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001324 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001325 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1326 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001327 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001328 }
1329#endif
1330
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 } // End if on non-NULL 'pSta'.
1332
1333
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301334 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001335
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1337 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1338 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001340
1341 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1342 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1343
1344 beaconParams.bssIdx = psessionEntry->bssIdx;
1345
1346 //Send message to HAL about beacon parameter change.
1347 if(beaconParams.paramChangeBitmap)
1348 {
1349 schSetFixedBeaconFields(pMac,psessionEntry);
1350 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1351 }
1352
1353 // Allocate a buffer for this frame:
1354 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1355 if ( DOT11F_FAILED( nStatus ) )
1356 {
1357 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001358 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 nStatus );
1360 return;
1361 }
1362 else if ( DOT11F_WARNED( nStatus ) )
1363 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001364 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07001365 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001366 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 }
1368
1369 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1370
1371 if ( pAssocReq != NULL )
1372 {
1373 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1374 &addnIEPresent) != eSIR_SUCCESS)
1375 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301376 limLog(pMac, LOGP, FL("Unable to get "
1377 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 return;
1379 }
1380
1381 if (addnIEPresent)
1382 {
1383 //Assoc rsp IE available
1384 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1385 &addnIELen) != eSIR_SUCCESS)
1386 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301387 limLog(pMac, LOGP, FL("Unable to get "
1388 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 return;
1390 }
1391
1392 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1393 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1394 {
1395 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1396 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1397 {
1398 nBytes = nBytes + addnIELen;
1399 }
1400 }
1401 }
1402 }
1403
1404 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1405 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1406 ( void** ) &pPacket );
1407 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1408 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001409 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 return;
1411 }
1412
1413 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301414 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001415
1416 // Next, we fill out the buffer descriptor:
1417 nSirStatus = limPopulateMacHeader( pMac,
1418 pFrame,
1419 SIR_MAC_MGMT_FRAME,
1420 ( LIM_ASSOC == subType ) ?
1421 SIR_MAC_MGMT_ASSOC_RSP :
1422 SIR_MAC_MGMT_REASSOC_RSP,
1423 peerMacAddr,psessionEntry->selfMacAddr);
1424 if ( eSIR_SUCCESS != nSirStatus )
1425 {
1426 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001427 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 nSirStatus );
1429 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1430 ( void* ) pFrame, ( void* ) pPacket );
1431 return;
1432 }
1433
1434 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1435
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1437
1438 nStatus = dot11fPackAssocResponse( pMac, &frm,
1439 pFrame + sizeof( tSirMacMgmtHdr ),
1440 nPayload, &nPayload );
1441 if ( DOT11F_FAILED( nStatus ) )
1442 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301443 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1444 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001445 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1446 ( void* ) pFrame, ( void* ) pPacket );
1447 return; // allocated!
1448 }
1449 else if ( DOT11F_WARNED( nStatus ) )
1450 {
1451 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001452 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 }
1454
1455 macAddr = pMacHdr->da;
1456
1457 if (subType == LIM_ASSOC)
1458 {
1459 PELOG1(limLog(pMac, LOG1,
1460 FL("*** Sending Assoc Resp status %d aid %d to "),
1461 statusCode, aid);)
1462 }
1463 else{
1464 PELOG1(limLog(pMac, LOG1,
1465 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1466 statusCode, aid);)
1467 }
1468 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1469
1470 if ( addnIEPresent )
1471 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301472 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 }
1474
1475 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1477 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 )
1479 {
1480 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1481 }
1482
1483 /// Queue Association Response frame in high priority WQ
1484 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1485 HAL_TXRX_FRM_802_11_MGMT,
1486 ANI_TXDIR_TODS,
1487 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1488 limTxComplete, pFrame, txFlag );
1489 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1490 {
1491 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001492 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 nSirStatus);
1494
1495 //Pkt will be freed up by the callback
1496 }
1497
1498 // update the ANI peer station count
1499 //FIXME_PROTECTION : take care of different type of station
1500 // counter inside this function.
1501 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1502
1503} // End limSendAssocRspMgmtFrame.
1504
1505
1506
1507void
1508limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1509 tSirMacAddr peer,
1510 tANI_U16 nStatusCode,
1511 tSirAddtsReqInfo *pAddTS,
1512 tSirMacScheduleIE *pSchedule,
1513 tpPESession psessionEntry)
1514{
1515 tANI_U8 *pFrame;
1516 tpSirMacMgmtHdr pMacHdr;
1517 tDot11fAddTSResponse AddTSRsp;
1518 tDot11fWMMAddTSResponse WMMAddTSRsp;
1519 tSirRetStatus nSirStatus;
1520 tANI_U32 i, nBytes, nPayload, nStatus;
1521 void *pPacket;
1522 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301523 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001524
1525 if(NULL == psessionEntry)
1526 {
1527 return;
1528 }
1529
1530 if ( ! pAddTS->wmeTspecPresent )
1531 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301532 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001533
1534 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1535 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1536 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1537 AddTSRsp.Status.status = nStatusCode;
1538
1539 // The TsDelay information element is only filled in for a specific
1540 // status code:
1541 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1542 {
1543 if ( pAddTS->wsmTspecPresent )
1544 {
1545 AddTSRsp.WMMTSDelay.version = 1;
1546 AddTSRsp.WMMTSDelay.delay = 10;
1547 AddTSRsp.WMMTSDelay.present = 1;
1548 }
1549 else
1550 {
1551 AddTSRsp.TSDelay.delay = 10;
1552 AddTSRsp.TSDelay.present = 1;
1553 }
1554 }
1555
1556 if ( pAddTS->wsmTspecPresent )
1557 {
1558 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1559 }
1560 else
1561 {
1562 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1563 }
1564
1565 if ( pAddTS->wsmTspecPresent )
1566 {
1567 AddTSRsp.num_WMMTCLAS = 0;
1568 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1569 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1570 {
1571 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1572 &AddTSRsp.TCLAS[i] );
1573 }
1574 }
1575 else
1576 {
1577 AddTSRsp.num_TCLAS = 0;
1578 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1579 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1580 {
1581 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1582 &AddTSRsp.WMMTCLAS[i] );
1583 }
1584 }
1585
1586 if ( pAddTS->tclasProcPresent )
1587 {
1588 if ( pAddTS->wsmTspecPresent )
1589 {
1590 AddTSRsp.WMMTCLASPROC.version = 1;
1591 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1592 AddTSRsp.WMMTCLASPROC.present = 1;
1593 }
1594 else
1595 {
1596 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1597 AddTSRsp.TCLASSPROC.present = 1;
1598 }
1599 }
1600
1601 // schedule element is included only if requested in the tspec and we are
1602 // using hcca (or both edca and hcca)
1603 // 11e-D8.0 is inconsistent on whether the schedule element is included
1604 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1605 // pg 46, line 17-18 says something else. So just include it and let the
1606 // sta figure it out
1607 if ((pSchedule != NULL) &&
1608 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1609 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1610 {
1611 if ( pAddTS->wsmTspecPresent )
1612 {
1613 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1614 }
1615 else
1616 {
1617 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1618 }
1619 }
1620
1621 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1622 if ( DOT11F_FAILED( nStatus ) )
1623 {
1624 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001625 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 nStatus );
1627 // We'll fall back on the worst case scenario:
1628 nPayload = sizeof( tDot11fAddTSResponse );
1629 }
1630 else if ( DOT11F_WARNED( nStatus ) )
1631 {
1632 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001633 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001634 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 }
1636 }
1637 else
1638 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301639 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001640
1641 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1642 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1643 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1644 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1645
1646 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1647
1648 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1649 if ( DOT11F_FAILED( nStatus ) )
1650 {
1651 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001652 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 nStatus );
1654 // We'll fall back on the worst case scenario:
1655 nPayload = sizeof( tDot11fWMMAddTSResponse );
1656 }
1657 else if ( DOT11F_WARNED( nStatus ) )
1658 {
1659 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001660 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001661 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 }
1663 }
1664
1665 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1666
1667 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1668 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1669 {
1670 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001671 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 return;
1673 }
1674
1675 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301676 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001677
1678 // Next, we fill out the buffer descriptor:
1679 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1680 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1681 if ( eSIR_SUCCESS != nSirStatus )
1682 {
1683 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001684 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 nSirStatus );
1686 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1687 return; // allocated!
1688 }
1689
1690 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1691
1692
1693 #if 0
1694 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1695 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1696 {
1697 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001698 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1700 return; // allocated!
1701 }
1702 #endif //TO SUPPORT BT-AMP
1703 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1704
Chet Lanctot186b5732013-03-18 10:26:30 -07001705#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001706 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001707#endif
1708
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 // That done, pack the struct:
1710 if ( ! pAddTS->wmeTspecPresent )
1711 {
1712 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1713 pFrame + sizeof( tSirMacMgmtHdr ),
1714 nPayload, &nPayload );
1715 if ( DOT11F_FAILED( nStatus ) )
1716 {
1717 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001718 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 nStatus );
1720 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1721 return;
1722 }
1723 else if ( DOT11F_WARNED( nStatus ) )
1724 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001725 limLog( pMac, LOGW, FL("There were warnings while packing "
1726 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 }
1728 }
1729 else
1730 {
1731 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1732 pFrame + sizeof( tSirMacMgmtHdr ),
1733 nPayload, &nPayload );
1734 if ( DOT11F_FAILED( nStatus ) )
1735 {
1736 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001737 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 nStatus );
1739 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1740 return;
1741 }
1742 else if ( DOT11F_WARNED( nStatus ) )
1743 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001744 limLog( pMac, LOGW, FL("There were warnings while packing "
1745 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 }
1747 }
1748
1749 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1750 nStatusCode );
1751 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1752
1753 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1755 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 )
1757 {
1758 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1759 }
1760
1761 // Queue the frame in high priority WQ:
1762 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1763 HAL_TXRX_FRM_802_11_MGMT,
1764 ANI_TXDIR_TODS,
1765 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1766 limTxComplete, pFrame, txFlag );
1767 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1768 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001769 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 nSirStatus );
1771 //Pkt will be freed up by the callback
1772 }
1773
1774} // End limSendAddtsRspActionFrame.
1775
1776void
1777limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1778 tSirMacAddr peer,
1779 tANI_U8 wmmTspecPresent,
1780 tSirMacTSInfo *pTsinfo,
1781 tSirMacTspecIE *pTspecIe,
1782 tpPESession psessionEntry)
1783{
1784 tANI_U8 *pFrame;
1785 tpSirMacMgmtHdr pMacHdr;
1786 tDot11fDelTS DelTS;
1787 tDot11fWMMDelTS WMMDelTS;
1788 tSirRetStatus nSirStatus;
1789 tANI_U32 nBytes, nPayload, nStatus;
1790 void *pPacket;
1791 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301792 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001793
1794 if(NULL == psessionEntry)
1795 {
1796 return;
1797 }
1798
1799 if ( ! wmmTspecPresent )
1800 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301801 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001802
1803 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1804 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1805 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1806
1807 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1808 if ( DOT11F_FAILED( nStatus ) )
1809 {
1810 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001811 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 nStatus );
1813 // We'll fall back on the worst case scenario:
1814 nPayload = sizeof( tDot11fDelTS );
1815 }
1816 else if ( DOT11F_WARNED( nStatus ) )
1817 {
1818 limLog( pMac, LOGW, FL("There were warnings while calcula"
1819 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001820 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 }
1822 }
1823 else
1824 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301825 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001826
1827 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1828 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1829 WMMDelTS.DialogToken.token = 0;
1830 WMMDelTS.StatusCode.statusCode = 0;
1831 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1832 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1833 if ( DOT11F_FAILED( nStatus ) )
1834 {
1835 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001836 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 nStatus );
1838 // We'll fall back on the worst case scenario:
1839 nPayload = sizeof( tDot11fDelTS );
1840 }
1841 else if ( DOT11F_WARNED( nStatus ) )
1842 {
1843 limLog( pMac, LOGW, FL("There were warnings while calcula"
1844 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001845 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001846 }
1847 }
1848
1849 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1850
1851 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1852 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1853 {
1854 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001855 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 return;
1857 }
1858
1859 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301860 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001861
1862 // Next, we fill out the buffer descriptor:
1863 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1864 SIR_MAC_MGMT_ACTION, peer,
1865 psessionEntry->selfMacAddr);
1866 if ( eSIR_SUCCESS != nSirStatus )
1867 {
1868 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001869 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 nSirStatus );
1871 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1872 return; // allocated!
1873 }
1874
1875 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1876
1877 #if 0
1878
1879 cfgLen = SIR_MAC_ADDR_LENGTH;
1880 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1881 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1882 {
1883 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001884 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1886 return; // allocated!
1887 }
1888 #endif //TO SUPPORT BT-AMP
1889 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1890
Chet Lanctot186b5732013-03-18 10:26:30 -07001891#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001892 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001893#endif
1894
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 // That done, pack the struct:
1896 if ( !wmmTspecPresent )
1897 {
1898 nStatus = dot11fPackDelTS( pMac, &DelTS,
1899 pFrame + sizeof( tSirMacMgmtHdr ),
1900 nPayload, &nPayload );
1901 if ( DOT11F_FAILED( nStatus ) )
1902 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001903 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 nStatus );
1905 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1906 return; // allocated!
1907 }
1908 else if ( DOT11F_WARNED( nStatus ) )
1909 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001910 limLog( pMac, LOGW, FL("There were warnings while packing "
1911 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 }
1913 }
1914 else
1915 {
1916 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1917 pFrame + sizeof( tSirMacMgmtHdr ),
1918 nPayload, &nPayload );
1919 if ( DOT11F_FAILED( nStatus ) )
1920 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001921 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 nStatus );
1923 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1924 return; // allocated!
1925 }
1926 else if ( DOT11F_WARNED( nStatus ) )
1927 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001928 limLog( pMac, LOGW, FL("There were warnings while packing "
1929 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 }
1931 }
1932
1933 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1934 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1935
1936 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1938 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 )
1940 {
1941 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1942 }
1943
1944 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1945 HAL_TXRX_FRM_802_11_MGMT,
1946 ANI_TXDIR_TODS,
1947 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1948 limTxComplete, pFrame, txFlag );
1949 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1950 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001951 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 nSirStatus );
1953 //Pkt will be freed up by the callback
1954 }
1955
1956} // End limSendDeltsReqActionFrame.
1957
1958void
1959limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1960 tLimMlmAssocReq *pMlmAssocReq,
1961 tpPESession psessionEntry)
1962{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001963 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 tANI_U16 caps;
1965 tANI_U8 *pFrame;
1966 tSirRetStatus nSirStatus;
1967 tLimMlmAssocCnf mlmAssocCnf;
1968 tANI_U32 nBytes, nPayload, nStatus;
1969 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1970 void *pPacket;
1971 eHalStatus halstatus;
1972 tANI_U16 nAddIELen;
1973 tANI_U8 *pAddIE;
1974 tANI_U8 *wpsIe = NULL;
1975#if defined WLAN_FEATURE_VOWIFI
1976 tANI_U8 PowerCapsPopulated = FALSE;
1977#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301978 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001979
1980 if(NULL == psessionEntry)
1981 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301982 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 return;
1984 }
1985
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 /* check this early to avoid unncessary operation */
1987 if(NULL == psessionEntry->pLimJoinReq)
1988 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301989 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001990 return;
1991 }
1992 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
1993 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
1994
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301995 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
1996 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001997 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301998 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001999 return;
2000 }
2001
2002
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302003 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002004
2005 caps = pMlmAssocReq->capabilityInfo;
2006 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2007 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2008#if defined(FEATURE_WLAN_WAPI)
2009 /* CR: 262463 :
2010 According to WAPI standard:
2011 7.3.1.4 Capability Information field
2012 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2013 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2014 Reassociation management frames. */
2015 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2016 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2017#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002018 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002019
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002020 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2021 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002023 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002024
2025 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2026 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2027
2028 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2029 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2030
2031 // We prefer .11e asociations:
2032 if ( fQosEnabled ) fWmeEnabled = false;
2033
2034 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2035 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2036
2037 if ( psessionEntry->lim11hEnable &&
2038 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2039 {
2040#if defined WLAN_FEATURE_VOWIFI
2041 PowerCapsPopulated = TRUE;
2042
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002043 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002044#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002045 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002046
2047 }
2048
2049#if defined WLAN_FEATURE_VOWIFI
2050 if( pMac->rrm.rrmPEContext.rrmEnable &&
2051 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2052 {
2053 if (PowerCapsPopulated == FALSE)
2054 {
2055 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002056 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 }
2058 }
2059#endif
2060
2061 if ( fQosEnabled &&
2062 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002063 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002064
2065 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002066 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002067
2068#if defined WLAN_FEATURE_VOWIFI
2069 if( pMac->rrm.rrmPEContext.rrmEnable &&
2070 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2071 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002072 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 }
2074#endif
2075 // The join request *should* contain zero or one of the WPA and RSN
2076 // IEs. The payload send along with the request is a
2077 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2078
2079 // typedef struct sSirRSNie
2080 // {
2081 // tANI_U16 length;
2082 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2083 // } tSirRSNie, *tpSirRSNie;
2084
2085 // So, we should be able to make the following two calls harmlessly,
2086 // since they do nothing if they don't find the given IE in the
2087 // bytestream with which they're provided.
2088
2089 // The net effect of this will be to faithfully transmit whatever
2090 // security IE is in the join request.
2091
2092 // *However*, if we're associating for the purpose of WPS
2093 // enrollment, and we've been configured to indicate that by
2094 // eliding the WPA or RSN IE, we just skip this:
2095 if( nAddIELen && pAddIE )
2096 {
2097 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2098 }
2099 if ( NULL == wpsIe )
2100 {
2101 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002102 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002104 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002105#if defined(FEATURE_WLAN_WAPI)
2106 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002107 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002108#endif // defined(FEATURE_WLAN_WAPI)
2109 }
2110
2111 // include WME EDCA IE as well
2112 if ( fWmeEnabled )
2113 {
2114 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2115 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002116 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 }
2118
2119 if ( fWsmEnabled &&
2120 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2121 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002122 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 }
2124 }
2125
2126 //Populate HT IEs, when operating in 11n or Taurus modes AND
2127 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002128 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 pMac->lim.htCapabilityPresentInBeacon)
2130 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002131 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002132#ifdef DISABLE_GF_FOR_INTEROP
2133
2134 /*
2135 * To resolve the interop problem with Broadcom AP,
2136 * where TQ STA could not pass traffic with GF enabled,
2137 * TQ STA will do Greenfield only with TQ AP, for
2138 * everybody else it will be turned off.
2139 */
2140
2141 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2142 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302143 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2144 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002145 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 }
2147#endif
2148
2149 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002150#ifdef WLAN_FEATURE_11AC
2151 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002152 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002153 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002154 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002155 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2156 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002157 }
2158#endif
2159
Jeff Johnson295189b2012-06-20 16:38:30 -07002160
2161#if defined WLAN_FEATURE_VOWIFI_11R
2162 if (psessionEntry->pLimJoinReq->is11Rconnection)
2163 {
2164#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002165 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2167 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2168 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2169#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302170 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2171 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302173 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 {
2175 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302176 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 }
2178#endif
2179
2180#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302181 /* For CCX Associations fill the CCX IEs */
2182 if (psessionEntry->isCCXconnection &&
2183 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002185#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002186 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002187#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302188 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 }
2190#endif
2191
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002192 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 if ( DOT11F_FAILED( nStatus ) )
2194 {
2195 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002196 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 nStatus );
2198 // We'll fall back on the worst case scenario:
2199 nPayload = sizeof( tDot11fAssocRequest );
2200 }
2201 else if ( DOT11F_WARNED( nStatus ) )
2202 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002203 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002205 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 }
2207
2208 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2209
2210 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2211 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2212 ( void** ) &pPacket );
2213 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2214 {
2215 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002216 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002217
2218 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002219 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002220
2221
2222 /* Update PE session id*/
2223 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2224
2225 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2226
2227 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2228 ( void* ) pFrame, ( void* ) pPacket );
2229
2230 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2231 ( tANI_U32* ) &mlmAssocCnf);
2232
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302233 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 return;
2235 }
2236
2237 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302238 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002239
2240 // Next, we fill out the buffer descriptor:
2241 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2242 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2243 if ( eSIR_SUCCESS != nSirStatus )
2244 {
2245 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002246 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 nSirStatus );
2248 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302249 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 return;
2251 }
2252
2253
Abhishek Singh57aebef2014-02-03 18:47:44 +05302254 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002255 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 sizeof(tSirMacMgmtHdr),
2257 nPayload, &nPayload );
2258 if ( DOT11F_FAILED( nStatus ) )
2259 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302260 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002261 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 nStatus );
2263 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2264 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302265 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 return;
2267 }
2268 else if ( DOT11F_WARNED( nStatus ) )
2269 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302270 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2271 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 }
2273
2274 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002275 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 nBytes );)
2277 // limPrintMacAddr( pMac, bssid, LOG1 );
2278
2279 if( psessionEntry->assocReq != NULL )
2280 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302281 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 psessionEntry->assocReq = NULL;
2283 }
2284
2285 if( nAddIELen )
2286 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302287 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2288 pAddIE,
2289 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 nPayload += nAddIELen;
2291 }
2292
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302293 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2294 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302296 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2297 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 }
2299 else
2300 {
2301 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302302 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 psessionEntry->assocReqLen = nPayload;
2304 }
2305
2306 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2308 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 )
2310 {
2311 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2312 }
2313
Ganesh K08bce952012-12-13 15:04:41 -08002314 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2315 {
2316 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2317 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002318 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2319 HAL_TXRX_FRM_802_11_MGMT,
2320 ANI_TXDIR_TODS,
2321 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2322 limTxComplete, pFrame, txFlag );
2323 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2324 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002325 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 halstatus );
2327 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302328 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 return;
2330 }
2331
2332 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302333 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002334 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302335 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002336 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002337} // End limSendAssocReqMgmtFrame
2338
2339
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002340#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002341/*------------------------------------------------------------------------------------
2342 *
2343 * Send Reassoc Req with FTIEs.
2344 *
2345 *-----------------------------------------------------------------------------------
2346 */
2347void
2348limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2349 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2350{
2351 static tDot11fReAssocRequest frm;
2352 tANI_U16 caps;
2353 tANI_U8 *pFrame;
2354 tSirRetStatus nSirStatus;
2355 tANI_U32 nBytes, nPayload, nStatus;
2356 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2357 void *pPacket;
2358 eHalStatus halstatus;
2359#if defined WLAN_FEATURE_VOWIFI
2360 tANI_U8 PowerCapsPopulated = FALSE;
2361#endif
2362 tANI_U16 ft_ies_length = 0;
2363 tANI_U8 *pBody;
2364 tANI_U16 nAddIELen;
2365 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002366#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 tANI_U8 *wpsIe = NULL;
2368#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302369 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002370
2371 if (NULL == psessionEntry)
2372 {
2373 return;
2374 }
2375
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 /* check this early to avoid unncessary operation */
2377 if(NULL == psessionEntry->pLimReAssocReq)
2378 {
2379 return;
2380 }
2381 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2382 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002383 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2384 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302386 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002387
2388 caps = pMlmReassocReq->capabilityInfo;
2389 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2390 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2391#if defined(FEATURE_WLAN_WAPI)
2392 /* CR: 262463 :
2393 According to WAPI standard:
2394 7.3.1.4 Capability Information field
2395 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2396 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2397 Reassociation management frames. */
2398 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2399 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2400#endif
2401 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2402
2403 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2404
2405 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302406 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2408
2409 PopulateDot11fSSID2( pMac, &frm.SSID );
2410 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2411 &frm.SuppRates,psessionEntry);
2412
2413 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2414 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2415
2416 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2417 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2418
2419 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2420 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2421
2422 if ( psessionEntry->lim11hEnable &&
2423 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2424 {
2425#if defined WLAN_FEATURE_VOWIFI
2426 PowerCapsPopulated = TRUE;
2427
2428 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2429 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2430#endif
2431 }
2432
2433#if defined WLAN_FEATURE_VOWIFI
2434 if( pMac->rrm.rrmPEContext.rrmEnable &&
2435 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2436 {
2437 if (PowerCapsPopulated == FALSE)
2438 {
2439 PowerCapsPopulated = TRUE;
2440 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2441 }
2442 }
2443#endif
2444
2445 if ( fQosEnabled &&
2446 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2447 {
2448 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2449 }
2450
2451 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2452 &frm.ExtSuppRates, psessionEntry );
2453
2454#if defined WLAN_FEATURE_VOWIFI
2455 if( pMac->rrm.rrmPEContext.rrmEnable &&
2456 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2457 {
2458 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2459 }
2460#endif
2461
2462 // Ideally this should be enabled for 11r also. But 11r does
2463 // not follow the usual norm of using the Opaque object
2464 // for rsnie and fties. Instead we just add
2465 // the rsnie and fties at the end of the pack routine for 11r.
2466 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002467#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 //
2469 // The join request *should* contain zero or one of the WPA and RSN
2470 // IEs. The payload send along with the request is a
2471 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2472
2473 // typedef struct sSirRSNie
2474 // {
2475 // tANI_U16 length;
2476 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2477 // } tSirRSNie, *tpSirRSNie;
2478
2479 // So, we should be able to make the following two calls harmlessly,
2480 // since they do nothing if they don't find the given IE in the
2481 // bytestream with which they're provided.
2482
2483 // The net effect of this will be to faithfully transmit whatever
2484 // security IE is in the join request.
2485
2486 // *However*, if we're associating for the purpose of WPS
2487 // enrollment, and we've been configured to indicate that by
2488 // eliding the WPA or RSN IE, we just skip this:
2489 if (!psessionEntry->is11Rconnection)
2490 {
2491 if( nAddIELen && pAddIE )
2492 {
2493 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2494 }
2495 if ( NULL == wpsIe )
2496 {
2497 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2498 &frm.RSNOpaque );
2499 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2500 &frm.WPAOpaque );
2501 }
2502
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002503#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302504 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 {
2506 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2507 &frm.CCXCckmOpaque );
2508 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002509#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002510 }
2511
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002512#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302514 if (psessionEntry->isCCXconnection &&
2515 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002517#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002519#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302520 PopulateDot11fCCXVersion(&frm.CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302522#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002523#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002524
2525 // include WME EDCA IE as well
2526 if ( fWmeEnabled )
2527 {
2528 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2529 {
2530 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2531 }
2532
2533 if ( fWsmEnabled &&
2534 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2535 {
2536 PopulateDot11fWMMCaps( &frm.WMMCaps );
2537 }
2538#ifdef FEATURE_WLAN_CCX
2539 if (psessionEntry->isCCXconnection)
2540 {
2541 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2542
2543 // Populate the TSRS IE if TSPEC is included in the reassoc request
2544 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2545 {
2546 tANI_U32 phyMode;
2547 tSirMacCCXTSRSIE tsrsIE;
2548 limGetPhyMode(pMac, &phyMode, psessionEntry);
2549
2550 tsrsIE.tsid = 0;
2551 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2552 {
2553 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2554 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302555 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 {
2557 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2558 }
2559 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2560 }
2561 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302562#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 }
2564
Jeff Johnsone7245742012-09-05 17:12:55 -07002565 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 pMac->lim.htCapabilityPresentInBeacon)
2567 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002568 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 }
2570
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002571#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302572 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2573#if defined FEATURE_WLAN_CCX
2574 && !psessionEntry->isCCXconnection
2575#endif
2576 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002577 {
2578 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2579 }
2580#endif
2581
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002582#ifdef WLAN_FEATURE_11AC
2583 if ( psessionEntry->vhtCapability &&
2584 psessionEntry->vhtCapabilityPresentInBeacon)
2585 {
2586 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2587 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
2588 PopulateDot11fExtCap( pMac, &frm.ExtCap);
2589 }
2590#endif
2591
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2593 if ( DOT11F_FAILED( nStatus ) )
2594 {
2595 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002596 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 nStatus );
2598 // We'll fall back on the worst case scenario:
2599 nPayload = sizeof( tDot11fReAssocRequest );
2600 }
2601 else if ( DOT11F_WARNED( nStatus ) )
2602 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002603 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002605 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 }
2607
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002608 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002609
2610#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002611 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2613#endif
2614
2615#if defined WLAN_FEATURE_VOWIFI_11R
2616 if (psessionEntry->is11Rconnection)
2617 {
2618 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2619 }
2620#endif
2621
2622 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2623 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2624 ( void** ) &pPacket );
2625 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2626 {
2627 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002628 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002630 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 goto end;
2632 }
2633
2634 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302635 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002636
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002637#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002638 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002639#endif
2640 // Next, we fill out the buffer descriptor:
2641 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2642 SIR_MAC_MGMT_REASSOC_REQ,
2643 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2644 if ( eSIR_SUCCESS != nSirStatus )
2645 {
2646 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002647 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 nSirStatus );
2649 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2650 goto end;
2651 }
2652
2653
2654 // That done, pack the ReAssoc Request:
2655 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2656 sizeof(tSirMacMgmtHdr),
2657 nPayload, &nPayload );
2658 if ( DOT11F_FAILED( nStatus ) )
2659 {
2660 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002661 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 nStatus );
2663 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2664 goto end;
2665 }
2666 else if ( DOT11F_WARNED( nStatus ) )
2667 {
2668 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002669 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 }
2671
2672 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002673 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 nBytes, nPayload );)
2675 if( psessionEntry->assocReq != NULL )
2676 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302677 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 psessionEntry->assocReq = NULL;
2679 }
2680
2681 if( nAddIELen )
2682 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302683 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2684 pAddIE,
2685 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 nPayload += nAddIELen;
2687 }
2688
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302689 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2690 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 {
2692 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002693 }
2694 else
2695 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302697 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002700
2701 if (psessionEntry->is11Rconnection)
2702 {
2703 {
2704 int i = 0;
2705
2706 pBody = pFrame + nBytes;
2707 for (i=0; i<ft_ies_length; i++)
2708 {
2709 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2710 pBody++;
2711 }
2712 }
2713 }
2714
2715#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002716 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2717 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 (tANI_U8 *)pFrame,
2719 (nBytes + ft_ies_length));)
2720#endif
2721
2722
2723 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002724 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2725 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 )
2727 {
2728 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2729 }
2730
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002731 if( NULL != psessionEntry->assocReq )
2732 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302733 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002734 psessionEntry->assocReq = NULL;
2735 }
2736
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302737 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2738 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002739 {
2740 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002741 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002742 }
2743 else
2744 {
2745 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302746 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2747 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002748 psessionEntry->assocReqLen = (ft_ies_length);
2749 }
2750
2751
Jeff Johnson295189b2012-06-20 16:38:30 -07002752 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2753 HAL_TXRX_FRM_802_11_MGMT,
2754 ANI_TXDIR_TODS,
2755 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2756 limTxComplete, pFrame, txFlag );
2757 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2758 {
2759 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002760 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 nSirStatus );
2762 //Pkt will be freed up by the callback
2763 goto end;
2764 }
2765
2766end:
2767 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302768 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 psessionEntry->pLimMlmReassocReq = NULL;
2770
2771}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002772
2773void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2774 tLimMlmReassocReq *pMlmReassocReq,
2775 tpPESession psessionEntry)
2776{
2777 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2778 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2779 if(NULL == pTmpMlmReassocReq)
2780 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302781 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2782 if ( NULL == pTmpMlmReassocReq ) goto end;
2783 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2784 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002785 }
2786
2787 // Prepare and send Reassociation request frame
2788 // start reassoc timer.
2789 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2790 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002791 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002792 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2793 != TX_SUCCESS)
2794 {
2795 // Could not start reassoc failure timer.
2796 // Log error
2797 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002798 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002799 // Return Reassoc confirm with
2800 // Resources Unavailable
2801 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2802 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2803 goto end;
2804 }
2805
2806 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2807 return;
2808
2809end:
2810 // Free up buffer allocated for reassocReq
2811 if (pMlmReassocReq != NULL)
2812 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302813 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002814 pMlmReassocReq = NULL;
2815 }
2816 if (pTmpMlmReassocReq != NULL)
2817 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302818 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002819 pTmpMlmReassocReq = NULL;
2820 }
2821 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2822 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2823 /* Update PE sessio Id*/
2824 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2825
2826 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2827}
2828
Jeff Johnson295189b2012-06-20 16:38:30 -07002829#endif /* WLAN_FEATURE_VOWIFI_11R */
2830
2831
2832void
2833limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2834 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2835{
2836 static tDot11fReAssocRequest frm;
2837 tANI_U16 caps;
2838 tANI_U8 *pFrame;
2839 tSirRetStatus nSirStatus;
2840 tANI_U32 nBytes, nPayload, nStatus;
2841 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2842 void *pPacket;
2843 eHalStatus halstatus;
2844 tANI_U16 nAddIELen;
2845 tANI_U8 *pAddIE;
2846 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302847 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002848#if defined WLAN_FEATURE_VOWIFI
2849 tANI_U8 PowerCapsPopulated = FALSE;
2850#endif
2851
2852 if(NULL == psessionEntry)
2853 {
2854 return;
2855 }
2856
2857 /* check this early to avoid unncessary operation */
2858 if(NULL == psessionEntry->pLimReAssocReq)
2859 {
2860 return;
2861 }
2862 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2863 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2864
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302865 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002866
2867 caps = pMlmReassocReq->capabilityInfo;
2868 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2869 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2870#if defined(FEATURE_WLAN_WAPI)
2871 /* CR: 262463 :
2872 According to WAPI standard:
2873 7.3.1.4 Capability Information field
2874 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2875 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2876 Reassociation management frames. */
2877 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2878 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2879#endif
2880 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2881
2882 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2883
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302884 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2885 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002886
2887 PopulateDot11fSSID2( pMac, &frm.SSID );
2888 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2889 &frm.SuppRates,psessionEntry);
2890
2891 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2892 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2893
2894 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2895 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2896
2897 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2898 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2899
2900
2901 if ( psessionEntry->lim11hEnable &&
2902 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2903 {
2904#if defined WLAN_FEATURE_VOWIFI
2905 PowerCapsPopulated = TRUE;
2906 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2907 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2908#endif
2909 }
2910
2911#if defined WLAN_FEATURE_VOWIFI
2912 if( pMac->rrm.rrmPEContext.rrmEnable &&
2913 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2914 {
2915 if (PowerCapsPopulated == FALSE)
2916 {
2917 PowerCapsPopulated = TRUE;
2918 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2919 }
2920 }
2921#endif
2922
2923 if ( fQosEnabled &&
2924 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2925 {
2926 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2927 }
2928
2929 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2930 &frm.ExtSuppRates, psessionEntry );
2931
2932#if defined WLAN_FEATURE_VOWIFI
2933 if( pMac->rrm.rrmPEContext.rrmEnable &&
2934 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2935 {
2936 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2937 }
2938#endif
2939 // The join request *should* contain zero or one of the WPA and RSN
2940 // IEs. The payload send along with the request is a
2941 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2942
2943 // typedef struct sSirRSNie
2944 // {
2945 // tANI_U16 length;
2946 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2947 // } tSirRSNie, *tpSirRSNie;
2948
2949 // So, we should be able to make the following two calls harmlessly,
2950 // since they do nothing if they don't find the given IE in the
2951 // bytestream with which they're provided.
2952
2953 // The net effect of this will be to faithfully transmit whatever
2954 // security IE is in the join request.
2955
2956 // *However*, if we're associating for the purpose of WPS
2957 // enrollment, and we've been configured to indicate that by
2958 // eliding the WPA or RSN IE, we just skip this:
2959 if( nAddIELen && pAddIE )
2960 {
2961 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2962 }
2963 if ( NULL == wpsIe )
2964 {
2965 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2966 &frm.RSNOpaque );
2967 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2968 &frm.WPAOpaque );
2969#if defined(FEATURE_WLAN_WAPI)
2970 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2971 &frm.WAPIOpaque );
2972#endif // defined(FEATURE_WLAN_WAPI)
2973 }
2974
2975 // include WME EDCA IE as well
2976 if ( fWmeEnabled )
2977 {
2978 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2979 {
2980 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2981 }
2982
2983 if ( fWsmEnabled &&
2984 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2985 {
2986 PopulateDot11fWMMCaps( &frm.WMMCaps );
2987 }
2988 }
2989
Jeff Johnsone7245742012-09-05 17:12:55 -07002990 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 pMac->lim.htCapabilityPresentInBeacon)
2992 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002993 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002995#ifdef WLAN_FEATURE_11AC
2996 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002997 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002998 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002999 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003000 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07003001 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003002 }
3003#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003004
3005 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3006 if ( DOT11F_FAILED( nStatus ) )
3007 {
3008 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003009 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 nStatus );
3011 // We'll fall back on the worst case scenario:
3012 nPayload = sizeof( tDot11fReAssocRequest );
3013 }
3014 else if ( DOT11F_WARNED( nStatus ) )
3015 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003016 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003017 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003018 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 }
3020
3021 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3022
3023 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3024 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3025 ( void** ) &pPacket );
3026 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3027 {
3028 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003029 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003031 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 goto end;
3033 }
3034
3035 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303036 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003037
3038 // Next, we fill out the buffer descriptor:
3039 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3040 SIR_MAC_MGMT_REASSOC_REQ,
3041 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3042 if ( eSIR_SUCCESS != nSirStatus )
3043 {
3044 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003045 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 nSirStatus );
3047 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3048 goto end;
3049 }
3050
3051
3052 // That done, pack the Probe Request:
3053 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3054 sizeof(tSirMacMgmtHdr),
3055 nPayload, &nPayload );
3056 if ( DOT11F_FAILED( nStatus ) )
3057 {
3058 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003059 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 nStatus );
3061 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3062 goto end;
3063 }
3064 else if ( DOT11F_WARNED( nStatus ) )
3065 {
3066 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003067 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 }
3069
3070 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003071 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 nBytes );)
3073
3074 if( psessionEntry->assocReq != NULL )
3075 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303076 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 psessionEntry->assocReq = NULL;
3078 }
3079
3080 if( nAddIELen )
3081 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303082 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3083 pAddIE,
3084 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 nPayload += nAddIELen;
3086 }
3087
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303088 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3089 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 {
3091 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003092 }
3093 else
3094 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303096 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003099
3100 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3102 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 )
3104 {
3105 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3106 }
3107
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003108 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003109 {
3110 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3111 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003112
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3114 HAL_TXRX_FRM_802_11_MGMT,
3115 ANI_TXDIR_TODS,
3116 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3117 limTxComplete, pFrame, txFlag );
3118 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3119 {
3120 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003121 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 nSirStatus );
3123 //Pkt will be freed up by the callback
3124 goto end;
3125 }
3126
3127end:
3128 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303129 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 psessionEntry->pLimMlmReassocReq = NULL;
3131
3132} // limSendReassocReqMgmtFrame
3133
3134/**
3135 * \brief Send an Authentication frame
3136 *
3137 *
3138 * \param pMac Pointer to Global MAC structure
3139 *
3140 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3141 * to be sent
3142 *
3143 * \param peerMacAddr MAC address of the peer entity to which Authentication
3144 * frame is destined
3145 *
3146 * \param wepBit Indicates whether wep bit to be set in FC while sending
3147 * Authentication frame3
3148 *
3149 *
3150 * This function is called by limProcessMlmMessages(). Authentication frame
3151 * is formatted and sent when this function is called.
3152 *
3153 *
3154 */
3155
3156void
3157limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3158 tpSirMacAuthFrameBody pAuthFrameBody,
3159 tSirMacAddr peerMacAddr,
3160 tANI_U8 wepBit,
3161 tpPESession psessionEntry
3162 )
3163{
3164 tANI_U8 *pFrame, *pBody;
3165 tANI_U32 frameLen = 0, bodyLen = 0;
3166 tpSirMacMgmtHdr pMacHdr;
3167 tANI_U16 i;
3168 void *pPacket;
3169 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303170 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003171
3172 if(NULL == psessionEntry)
3173 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303174 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 return;
3176 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303177
3178 limLog(pMac, LOG1,
3179 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3180 pAuthFrameBody->authTransactionSeqNumber,
3181 pAuthFrameBody->authStatusCode,
3182 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3183 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 if (wepBit == LIM_WEP_IN_FC)
3185 {
3186 /// Auth frame3 to be sent with encrypted framebody
3187 /**
3188 * Allocate buffer for Authenticaton frame of size equal
3189 * to management frame header length plus 2 bytes each for
3190 * auth algorithm number, transaction number, status code,
3191 * 128 bytes for challenge text and 4 bytes each for
3192 * IV & ICV.
3193 */
3194
3195 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3196
3197 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3198 } // if (wepBit == LIM_WEP_IN_FC)
3199 else
3200 {
3201 switch (pAuthFrameBody->authTransactionSeqNumber)
3202 {
3203 case SIR_MAC_AUTH_FRAME_1:
3204 /**
3205 * Allocate buffer for Authenticaton frame of size
3206 * equal to management frame header length plus 2 bytes
3207 * each for auth algorithm number, transaction number
3208 * and status code.
3209 */
3210
3211 frameLen = sizeof(tSirMacMgmtHdr) +
3212 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3213 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3214
3215#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003216 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3217 {
3218 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003220 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003221 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003222 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003224 else
3225 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303226 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3227 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003228 frameLen += (2+SIR_MDIE_SIZE);
3229 }
3230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003231#endif
3232 break;
3233
3234 case SIR_MAC_AUTH_FRAME_2:
3235 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3236 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3237 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3238 {
3239 /**
3240 * Allocate buffer for Authenticaton frame of size
3241 * equal to management frame header length plus
3242 * 2 bytes each for auth algorithm number,
3243 * transaction number and status code.
3244 */
3245
3246 frameLen = sizeof(tSirMacMgmtHdr) +
3247 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3248 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3249 }
3250 else
3251 {
3252 // Shared Key algorithm with challenge text
3253 // to be sent
3254 /**
3255 * Allocate buffer for Authenticaton frame of size
3256 * equal to management frame header length plus
3257 * 2 bytes each for auth algorithm number,
3258 * transaction number, status code and 128 bytes
3259 * for challenge text.
3260 */
3261
3262 frameLen = sizeof(tSirMacMgmtHdr) +
3263 sizeof(tSirMacAuthFrame);
3264 bodyLen = sizeof(tSirMacAuthFrameBody);
3265 }
3266
3267 break;
3268
3269 case SIR_MAC_AUTH_FRAME_3:
3270 /// Auth frame3 to be sent without encrypted framebody
3271 /**
3272 * Allocate buffer for Authenticaton frame of size equal
3273 * to management frame header length plus 2 bytes each
3274 * for auth algorithm number, transaction number and
3275 * status code.
3276 */
3277
3278 frameLen = sizeof(tSirMacMgmtHdr) +
3279 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3280 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3281
3282 break;
3283
3284 case SIR_MAC_AUTH_FRAME_4:
3285 /**
3286 * Allocate buffer for Authenticaton frame of size equal
3287 * to management frame header length plus 2 bytes each
3288 * for auth algorithm number, transaction number and
3289 * status code.
3290 */
3291
3292 frameLen = sizeof(tSirMacMgmtHdr) +
3293 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3294 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3295
3296 break;
3297 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3298 } // end if (wepBit == LIM_WEP_IN_FC)
3299
3300
3301 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3302
3303 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3304 {
3305 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003306 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003307
3308 return;
3309 }
3310
3311 for (i = 0; i < frameLen; i++)
3312 pFrame[i] = 0;
3313
3314 // Prepare BD
3315 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3316 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3317 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303318 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3319 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3321 return;
3322 }
3323
3324 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3325 pMacHdr->fc.wep = wepBit;
3326
3327 // Prepare BSSId
3328 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3329 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303330 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3331 (tANI_U8 *) psessionEntry->bssId,
3332 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 }
3334
3335 /// Prepare Authentication frame body
3336 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3337
3338 if (wepBit == LIM_WEP_IN_FC)
3339 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303340 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003341
3342 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303343 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303345 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3346 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003347
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 }
3349 else
3350 {
3351 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3352 pBody += sizeof(tANI_U16);
3353 bodyLen -= sizeof(tANI_U16);
3354
3355 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3356 pBody += sizeof(tANI_U16);
3357 bodyLen -= sizeof(tANI_U16);
3358
3359 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3360 pBody += sizeof(tANI_U16);
3361 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003362 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3363 sizeof (pAuthFrameBody->length) +
3364 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303365 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003366
3367#if defined WLAN_FEATURE_VOWIFI_11R
3368 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3369 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3370 {
3371
3372 {
3373 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3375 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003376#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3378 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3379 (tANI_U8 *)pBody,
3380 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003381#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003382 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3383 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003384 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3385 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003386 }
3387 }
3388 else
3389 {
3390 /* MDID attr is 54*/
3391 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003393 *pBody = SIR_MDIE_SIZE;
3394 pBody++;
3395 for(i=0;i<SIR_MDIE_SIZE;i++)
3396 {
3397 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3398 pBody++;
3399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 }
3401 }
3402 }
3403#endif
3404
3405 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303406 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 pAuthFrameBody->authTransactionSeqNumber,
3408 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303409 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3410 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 }
3412 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3413
3414 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3416 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003417#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303418 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003419 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3420#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 )
3422 {
3423 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3424 }
3425
Ganesh K08bce952012-12-13 15:04:41 -08003426 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3427 {
3428 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3429 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003430
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 /// Queue Authentication frame in high priority WQ
3432 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3433 HAL_TXRX_FRM_802_11_MGMT,
3434 ANI_TXDIR_TODS,
3435 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3436 limTxComplete, pFrame, txFlag );
3437 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3438 {
3439 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003440 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 halstatus);
3442
3443 //Pkt will be freed up by the callback
3444 }
3445
3446 return;
3447} /*** end limSendAuthMgmtFrame() ***/
3448
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003449eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3450{
3451 tANI_U16 aid;
3452 tpDphHashNode pStaDs;
3453 tLimMlmDeauthReq *pMlmDeauthReq;
3454 tLimMlmDeauthCnf mlmDeauthCnf;
3455 tpPESession psessionEntry;
3456
3457 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3458 if (pMlmDeauthReq)
3459 {
3460 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3461 {
3462 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3463 }
3464
3465 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3466 {
3467
3468 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003469 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003470 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3471 goto end;
3472 }
3473
3474 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3475 if (pStaDs == NULL)
3476 {
3477 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3478 goto end;
3479 }
3480
3481
3482 /// Receive path cleanup with dummy packet
3483 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3484 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303485 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003486 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3487 }
3488 return eHAL_STATUS_SUCCESS;
3489end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303490 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003491 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3492 sizeof(tSirMacAddr));
3493 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3494 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3495 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3496
3497 // Free up buffer allocated
3498 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303499 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003500
3501 limPostSmeMessage(pMac,
3502 LIM_MLM_DEAUTH_CNF,
3503 (tANI_U32 *) &mlmDeauthCnf);
3504 return eHAL_STATUS_SUCCESS;
3505}
3506
3507eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3508{
3509 tANI_U16 aid;
3510 tpDphHashNode pStaDs;
3511 tLimMlmDisassocCnf mlmDisassocCnf;
3512 tpPESession psessionEntry;
3513 tLimMlmDisassocReq *pMlmDisassocReq;
3514
3515 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3516 if (pMlmDisassocReq)
3517 {
3518 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3519 {
3520 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3521 }
3522
3523 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3524 {
3525
3526 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003527 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003528 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3529 goto end;
3530 }
3531
3532 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3533 if (pStaDs == NULL)
3534 {
3535 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3536 goto end;
3537 }
3538
3539 /// Receive path cleanup with dummy packet
3540 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3541 {
3542 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3543 goto end;
3544 }
3545
3546#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003547 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303548 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003549#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303550 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003551#endif
3552#ifdef FEATURE_WLAN_LFR
3553 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003554#endif
3555 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303556 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003557 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003558 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303559 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003560 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003561 psessionEntry, psessionEntry->peSessionId););
3562 limFTCleanup(pMac);
3563 }
3564 else
3565 {
3566 PELOGE(limLog(pMac, LOGE,
3567 FL("No FT Preauth Session Cleanup in role %d"
3568#ifdef FEATURE_WLAN_CCX
3569 " isCCX %d"
3570#endif
3571#ifdef FEATURE_WLAN_LFR
3572 " isLFR %d"
3573#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003574 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003575 psessionEntry->limSystemRole,
3576#ifdef FEATURE_WLAN_CCX
3577 psessionEntry->isCCXconnection,
3578#endif
3579#ifdef FEATURE_WLAN_LFR
3580 psessionEntry->isFastRoamIniFeatureEnabled,
3581#endif
3582 psessionEntry->is11Rconnection,
3583 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003584 }
3585#endif
3586
3587 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303588 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003589 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3590 return eHAL_STATUS_SUCCESS;
3591 }
3592 else
3593 {
3594 return eHAL_STATUS_SUCCESS;
3595 }
3596end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303597 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003598 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3599 sizeof(tSirMacAddr));
3600 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3601 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3602
3603 /* Update PE session ID*/
3604 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3605
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003606 if(pMlmDisassocReq != NULL)
3607 {
3608 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303609 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003610 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3611 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003612
3613 limPostSmeMessage(pMac,
3614 LIM_MLM_DISASSOC_CNF,
3615 (tANI_U32 *) &mlmDisassocCnf);
3616 return eHAL_STATUS_SUCCESS;
3617}
3618
3619eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3620{
3621 return limSendDisassocCnf(pMac);
3622}
3623
3624eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3625{
3626 return limSendDeauthCnf(pMac);
3627}
3628
Jeff Johnson295189b2012-06-20 16:38:30 -07003629/**
3630 * \brief This function is called to send Disassociate frame.
3631 *
3632 *
3633 * \param pMac Pointer to Global MAC structure
3634 *
3635 * \param nReason Indicates the reason that need to be sent in
3636 * Disassociation frame
3637 *
3638 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3639 * sent
3640 *
3641 *
3642 */
3643
3644void
3645limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3646 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003647 tSirMacAddr peer,
3648 tpPESession psessionEntry,
3649 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003650{
3651 tDot11fDisassociation frm;
3652 tANI_U8 *pFrame;
3653 tSirRetStatus nSirStatus;
3654 tpSirMacMgmtHdr pMacHdr;
3655 tANI_U32 nBytes, nPayload, nStatus;
3656 void *pPacket;
3657 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303658 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003659 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 if(NULL == psessionEntry)
3661 {
3662 return;
3663 }
3664
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303665 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003666
3667 frm.Reason.code = nReason;
3668
3669 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3670 if ( DOT11F_FAILED( nStatus ) )
3671 {
3672 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003673 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 nStatus );
3675 // We'll fall back on the worst case scenario:
3676 nPayload = sizeof( tDot11fDisassociation );
3677 }
3678 else if ( DOT11F_WARNED( nStatus ) )
3679 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003680 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003682 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 }
3684
3685 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3686
3687 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3688 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3689 ( void** ) &pPacket );
3690 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3691 {
3692 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003693 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 return;
3695 }
3696
3697 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303698 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003699
3700 // Next, we fill out the buffer descriptor:
3701 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3702 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3703 if ( eSIR_SUCCESS != nSirStatus )
3704 {
3705 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003706 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 nSirStatus );
3708 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3709 ( void* ) pFrame, ( void* ) pPacket );
3710 return; // just allocated...
3711 }
3712
3713 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3714
3715 // Prepare the BSSID
3716 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3717
Chet Lanctot186b5732013-03-18 10:26:30 -07003718#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003719 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003720#endif
3721
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3723 sizeof(tSirMacMgmtHdr),
3724 nPayload, &nPayload );
3725 if ( DOT11F_FAILED( nStatus ) )
3726 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003727 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 nStatus );
3729 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3730 ( void* ) pFrame, ( void* ) pPacket );
3731 return; // allocated!
3732 }
3733 else if ( DOT11F_WARNED( nStatus ) )
3734 {
3735 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003736 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 }
3738
Abhishek Singhcd09b562013-12-24 16:02:20 +05303739 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
3740 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
3741 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
3742 MAC_ADDR_ARRAY(pMacHdr->da),
3743 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003744
3745 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3747 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 )
3749 {
3750 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3751 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003752
Ganesh K08bce952012-12-13 15:04:41 -08003753 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303754 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3755 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003756 {
3757 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3758 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003759
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303760 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3761 {
3762 /* This frame will be sent on air by firmware,
3763 which will ensure that this frame goes out
3764 even though DEL_STA is sent immediately */
3765 /* Without this for DEL_STA command there is
3766 risk of flushing frame in BTQM queue without
3767 sending on air */
3768 txFlag |= HAL_USE_FW_IN_TX_PATH;
3769 }
3770
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003771 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003773 // Queue Disassociation frame in high priority WQ
3774 /* get the duration from the request */
3775 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3776 HAL_TXRX_FRM_802_11_MGMT,
3777 ANI_TXDIR_TODS,
3778 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3779 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3780 txFlag );
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303781
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003782 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003783
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003784 if (tx_timer_change(
3785 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3786 != TX_SUCCESS)
3787 {
3788 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003789 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003790 return;
3791 }
3792 else if(TX_SUCCESS != tx_timer_activate(
3793 &pMac->lim.limTimers.gLimDisassocAckTimer))
3794 {
3795 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003796 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003797 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3798 return;
3799 }
3800 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003801 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003802 {
3803 // Queue Disassociation frame in high priority WQ
3804 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3805 HAL_TXRX_FRM_802_11_MGMT,
3806 ANI_TXDIR_TODS,
3807 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3808 limTxComplete, pFrame, txFlag );
3809 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3810 {
3811 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003812 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003813 nSirStatus );
3814 //Pkt will be freed up by the callback
3815 return;
3816 }
3817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003818} // End limSendDisassocMgmtFrame.
3819
3820/**
3821 * \brief This function is called to send a Deauthenticate frame
3822 *
3823 *
3824 * \param pMac Pointer to global MAC structure
3825 *
3826 * \param nReason Indicates the reason that need to be sent in the
3827 * Deauthenticate frame
3828 *
3829 * \param peeer address of the STA to which the frame is to be sent
3830 *
3831 *
3832 */
3833
3834void
3835limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3836 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003837 tSirMacAddr peer,
3838 tpPESession psessionEntry,
3839 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003840{
3841 tDot11fDeAuth frm;
3842 tANI_U8 *pFrame;
3843 tSirRetStatus nSirStatus;
3844 tpSirMacMgmtHdr pMacHdr;
3845 tANI_U32 nBytes, nPayload, nStatus;
3846 void *pPacket;
3847 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303848 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003849 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003850#ifdef FEATURE_WLAN_TDLS
3851 tANI_U16 aid;
3852 tpDphHashNode pStaDs;
3853#endif
3854
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 if(NULL == psessionEntry)
3856 {
3857 return;
3858 }
3859
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303860 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003861
3862 frm.Reason.code = nReason;
3863
3864 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3865 if ( DOT11F_FAILED( nStatus ) )
3866 {
3867 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003868 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 nStatus );
3870 // We'll fall back on the worst case scenario:
3871 nPayload = sizeof( tDot11fDeAuth );
3872 }
3873 else if ( DOT11F_WARNED( nStatus ) )
3874 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003875 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003877 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 }
3879
3880 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3881
3882 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3883 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3884 ( void** ) &pPacket );
3885 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3886 {
3887 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003888 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 return;
3890 }
3891
3892 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303893 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003894
3895 // Next, we fill out the buffer descriptor:
3896 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3897 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3898 if ( eSIR_SUCCESS != nSirStatus )
3899 {
3900 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003901 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 nSirStatus );
3903 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3904 ( void* ) pFrame, ( void* ) pPacket );
3905 return; // just allocated...
3906 }
3907
3908 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3909
3910 // Prepare the BSSID
3911 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3912
Chet Lanctot186b5732013-03-18 10:26:30 -07003913#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003914 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003915#endif
3916
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3918 sizeof(tSirMacMgmtHdr),
3919 nPayload, &nPayload );
3920 if ( DOT11F_FAILED( nStatus ) )
3921 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003922 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 nStatus );
3924 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3925 ( void* ) pFrame, ( void* ) pPacket );
3926 return;
3927 }
3928 else if ( DOT11F_WARNED( nStatus ) )
3929 {
3930 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003931 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05303933 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
3934 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
3935 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
3936 MAC_ADDR_ARRAY(pMacHdr->da),
3937 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003938
3939 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003940 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3941 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 )
3943 {
3944 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3945 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003946
Ganesh K08bce952012-12-13 15:04:41 -08003947 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303948 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3949 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003950 {
3951 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3952 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003953
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303954 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3955 {
3956 /* This frame will be sent on air by firmware,
3957 which will ensure that this frame goes out
3958 even though DEL_STA is sent immediately */
3959 /* Without this for DEL_STA command there is
3960 risk of flushing frame in BTQM queue without
3961 sending on air */
3962 txFlag |= HAL_USE_FW_IN_TX_PATH;
3963 }
3964
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003965#ifdef FEATURE_WLAN_TDLS
3966 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3967#endif
3968
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003969 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003971 // Queue Disassociation frame in high priority WQ
3972 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3973 HAL_TXRX_FRM_802_11_MGMT,
3974 ANI_TXDIR_TODS,
3975 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3976 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303977
3978 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003979 {
3980 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303981 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003982 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003983 //Pkt will be freed up by the callback limTxComplete
3984
3985 /*Call limProcessDeauthAckTimeout which will send
3986 * DeauthCnf for this frame
3987 */
3988 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003989 return;
3990 }
3991
3992 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3993
3994 if (tx_timer_change(
3995 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3996 != TX_SUCCESS)
3997 {
3998 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003999 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004000 return;
4001 }
4002 else if(TX_SUCCESS != tx_timer_activate(
4003 &pMac->lim.limTimers.gLimDeauthAckTimer))
4004 {
4005 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004006 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004007 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4008 return;
4009 }
4010 }
4011 else
4012 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004013#ifdef FEATURE_WLAN_TDLS
4014 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4015 {
4016 // Queue Disassociation frame in high priority WQ
4017 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004018 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004019 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004020 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4021 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004022 }
4023 else
4024 {
4025#endif
4026 // Queue Disassociation frame in high priority WQ
4027 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4028 HAL_TXRX_FRM_802_11_MGMT,
4029 ANI_TXDIR_TODS,
4030 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4031 limTxComplete, pFrame, txFlag );
4032#ifdef FEATURE_WLAN_TDLS
4033 }
4034#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004035 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4036 {
4037 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004038 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004039 nSirStatus );
4040 //Pkt will be freed up by the callback
4041 return;
4042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 }
4044
4045} // End limSendDeauthMgmtFrame.
4046
4047
4048#ifdef ANI_SUPPORT_11H
4049/**
4050 * \brief Send a Measurement Report Action frame
4051 *
4052 *
4053 * \param pMac Pointer to the global MAC structure
4054 *
4055 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4056 *
4057 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4058 *
4059 *
4060 */
4061
4062tSirRetStatus
4063limSendMeasReportFrame(tpAniSirGlobal pMac,
4064 tpSirMacMeasReqActionFrame pMeasReqFrame,
4065 tSirMacAddr peer)
4066{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304067 tDot11fMeasurementReport frm;
4068 tANI_U8 *pFrame;
4069 tSirRetStatus nSirStatus;
4070 tpSirMacMgmtHdr pMacHdr;
4071 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4072 void *pPacket;
4073 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004074
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304075 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004076
4077 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4078 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4079 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4080
4081 switch ( pMeasReqFrame->measReqIE.measType )
4082 {
4083 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4084 nSirStatus =
4085 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4086 &frm.MeasurementReport );
4087 break;
4088 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4089 nSirStatus =
4090 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4091 &frm.MeasurementReport );
4092 break;
4093 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4094 nSirStatus =
4095 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4096 &frm.MeasurementReport );
4097 break;
4098 default:
4099 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004100 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 pMeasReqFrame->measReqIE.measType );
4102 return eSIR_FAILURE;
4103 }
4104
4105 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4106
4107 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4108 if ( DOT11F_FAILED( nStatus ) )
4109 {
4110 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004111 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 nStatus );
4113 // We'll fall back on the worst case scenario:
4114 nPayload = sizeof( tDot11fMeasurementReport );
4115 }
4116 else if ( DOT11F_WARNED( nStatus ) )
4117 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004118 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004120 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 }
4122
4123 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4124
4125 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4126 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4127 {
4128 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004129 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 return eSIR_FAILURE;
4131 }
4132
4133 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304134 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004135
4136 // Next, we fill out the buffer descriptor:
4137 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4138 SIR_MAC_MGMT_ACTION, peer);
4139 if ( eSIR_SUCCESS != nSirStatus )
4140 {
4141 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004142 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 nSirStatus );
4144 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4145 return eSIR_FAILURE; // just allocated...
4146 }
4147
4148 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4149
4150 nCfg = 6;
4151 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4152 if ( eSIR_SUCCESS != nSirStatus )
4153 {
4154 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004155 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 nSirStatus );
4157 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4158 return eSIR_FAILURE; // just allocated...
4159 }
4160
Chet Lanctot186b5732013-03-18 10:26:30 -07004161#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004162 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004163#endif
4164
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4166 sizeof(tSirMacMgmtHdr),
4167 nPayload, &nPayload );
4168 if ( DOT11F_FAILED( nStatus ) )
4169 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004170 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 nStatus );
4172 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4173 return eSIR_FAILURE; // allocated!
4174 }
4175 else if ( DOT11F_WARNED( nStatus ) )
4176 {
4177 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004178 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 }
4180
4181 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4182 HAL_TXRX_FRM_802_11_MGMT,
4183 ANI_TXDIR_TODS,
4184 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4185 limTxComplete, pFrame, 0 );
4186 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4187 {
4188 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004189 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 nSirStatus );
4191 //Pkt will be freed up by the callback
4192 return eSIR_FAILURE; // just allocated...
4193 }
4194
4195 return eSIR_SUCCESS;
4196
4197} // End limSendMeasReportFrame.
4198
4199
4200/**
4201 * \brief Send a TPC Request Action frame
4202 *
4203 *
4204 * \param pMac Pointer to the global MAC datastructure
4205 *
4206 * \param peer MAC address to which the frame should be sent
4207 *
4208 *
4209 */
4210
4211void
4212limSendTpcRequestFrame(tpAniSirGlobal pMac,
4213 tSirMacAddr peer)
4214{
4215 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304216 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 tSirRetStatus nSirStatus;
4218 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304219 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4220 void *pPacket;
4221 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004222
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304223 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004224
4225 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4226 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4227 frm.DialogToken.token = 1;
4228 frm.TPCRequest.present = 1;
4229
4230 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4231 if ( DOT11F_FAILED( nStatus ) )
4232 {
4233 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004234 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 nStatus );
4236 // We'll fall back on the worst case scenario:
4237 nPayload = sizeof( tDot11fTPCRequest );
4238 }
4239 else if ( DOT11F_WARNED( nStatus ) )
4240 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004241 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004243 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 }
4245
4246 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4247
4248 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4249 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4250 {
4251 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004252 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 return;
4254 }
4255
4256 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304257 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004258
4259 // Next, we fill out the buffer descriptor:
4260 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4261 SIR_MAC_MGMT_ACTION, peer);
4262 if ( eSIR_SUCCESS != nSirStatus )
4263 {
4264 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004265 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 nSirStatus );
4267 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4268 return; // just allocated...
4269 }
4270
4271 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4272
4273 nCfg = 6;
4274 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4275 if ( eSIR_SUCCESS != nSirStatus )
4276 {
4277 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004278 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004279 nSirStatus );
4280 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4281 return; // just allocated...
4282 }
4283
Chet Lanctot186b5732013-03-18 10:26:30 -07004284#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004285 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004286#endif
4287
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4289 sizeof(tSirMacMgmtHdr),
4290 nPayload, &nPayload );
4291 if ( DOT11F_FAILED( nStatus ) )
4292 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004293 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 nStatus );
4295 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4296 return; // allocated!
4297 }
4298 else if ( DOT11F_WARNED( nStatus ) )
4299 {
4300 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004301 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 }
4303
4304 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4305 HAL_TXRX_FRM_802_11_MGMT,
4306 ANI_TXDIR_TODS,
4307 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4308 limTxComplete, pFrame, 0 );
4309 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4310 {
4311 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004312 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 nSirStatus );
4314 //Pkt will be freed up by the callback
4315 return;
4316 }
4317
4318} // End limSendTpcRequestFrame.
4319
4320
4321/**
4322 * \brief Send a TPC Report Action frame
4323 *
4324 *
4325 * \param pMac Pointer to the global MAC datastructure
4326 *
4327 * \param pTpcReqFrame Pointer to the received TPC Request
4328 *
4329 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4330 *
4331 *
4332 */
4333
4334tSirRetStatus
4335limSendTpcReportFrame(tpAniSirGlobal pMac,
4336 tpSirMacTpcReqActionFrame pTpcReqFrame,
4337 tSirMacAddr peer)
4338{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304339 tDot11fTPCReport frm;
4340 tANI_U8 *pFrame;
4341 tSirRetStatus nSirStatus;
4342 tpSirMacMgmtHdr pMacHdr;
4343 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4344 void *pPacket;
4345 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004346
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304347 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004348
4349 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4350 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4351 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4352
4353 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4354 // "misplaced this function, need to replace:
4355 // txPower = halGetRateToPwrValue(pMac, staid,
4356 // pMac->lim.gLimCurrentChannelId, 0);
4357 frm.TPCReport.tx_power = 0;
4358 frm.TPCReport.link_margin = 0;
4359 frm.TPCReport.present = 1;
4360
4361 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4362 if ( DOT11F_FAILED( nStatus ) )
4363 {
4364 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004365 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 nStatus );
4367 // We'll fall back on the worst case scenario:
4368 nPayload = sizeof( tDot11fTPCReport );
4369 }
4370 else if ( DOT11F_WARNED( nStatus ) )
4371 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004372 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004374 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 }
4376
4377 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4378
4379 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4380 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4381 {
4382 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004383 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 return eSIR_FAILURE;
4385 }
4386
4387 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304388 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004389
4390 // Next, we fill out the buffer descriptor:
4391 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4392 SIR_MAC_MGMT_ACTION, peer);
4393 if ( eSIR_SUCCESS != nSirStatus )
4394 {
4395 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004396 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 nSirStatus );
4398 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4399 return eSIR_FAILURE; // just allocated...
4400 }
4401
4402 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4403
4404 nCfg = 6;
4405 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4406 if ( eSIR_SUCCESS != nSirStatus )
4407 {
4408 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004409 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 nSirStatus );
4411 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4412 return eSIR_FAILURE; // just allocated...
4413 }
4414
Chet Lanctot186b5732013-03-18 10:26:30 -07004415#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004416 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004417#endif
4418
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4420 sizeof(tSirMacMgmtHdr),
4421 nPayload, &nPayload );
4422 if ( DOT11F_FAILED( nStatus ) )
4423 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004424 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 nStatus );
4426 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4427 return eSIR_FAILURE; // allocated!
4428 }
4429 else if ( DOT11F_WARNED( nStatus ) )
4430 {
4431 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004432 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 }
4434
4435
4436 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4437 HAL_TXRX_FRM_802_11_MGMT,
4438 ANI_TXDIR_TODS,
4439 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4440 limTxComplete, pFrame, 0 );
4441 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4442 {
4443 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004444 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 nSirStatus );
4446 //Pkt will be freed up by the callback
4447 return eSIR_FAILURE; // just allocated...
4448 }
4449
4450 return eSIR_SUCCESS;
4451
4452} // End limSendTpcReportFrame.
4453#endif //ANI_SUPPORT_11H
4454
4455
Jeff Johnson295189b2012-06-20 16:38:30 -07004456/**
4457 * \brief Send a Channel Switch Announcement
4458 *
4459 *
4460 * \param pMac Pointer to the global MAC datastructure
4461 *
4462 * \param peer MAC address to which this frame will be sent
4463 *
4464 * \param nMode
4465 *
4466 * \param nNewChannel
4467 *
4468 * \param nCount
4469 *
4470 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4471 *
4472 *
4473 */
4474
4475tSirRetStatus
4476limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4477 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004478 tANI_U8 nMode,
4479 tANI_U8 nNewChannel,
4480 tANI_U8 nCount,
4481 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004482{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304483 tDot11fChannelSwitch frm;
4484 tANI_U8 *pFrame;
4485 tSirRetStatus nSirStatus;
4486 tpSirMacMgmtHdr pMacHdr;
4487 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4488 void *pPacket;
4489 eHalStatus halstatus;
4490 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004491
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304492 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004493
4494 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4495 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4496 frm.ChanSwitchAnn.switchMode = nMode;
4497 frm.ChanSwitchAnn.newChannel = nNewChannel;
4498 frm.ChanSwitchAnn.switchCount = nCount;
4499 frm.ChanSwitchAnn.present = 1;
4500
4501 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4502 if ( DOT11F_FAILED( nStatus ) )
4503 {
4504 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004505 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 nStatus );
4507 // We'll fall back on the worst case scenario:
4508 nPayload = sizeof( tDot11fChannelSwitch );
4509 }
4510 else if ( DOT11F_WARNED( nStatus ) )
4511 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004512 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004514 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 }
4516
4517 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4518
4519 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4520 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4521 {
4522 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004523 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 return eSIR_FAILURE;
4525 }
4526
4527 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304528 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004529
4530 // Next, we fill out the buffer descriptor:
4531 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004532 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4533 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304534 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4535 (tANI_U8 *) psessionEntry->bssId,
4536 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 if ( eSIR_SUCCESS != nSirStatus )
4538 {
4539 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004540 "tor for a Channel Switch (%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 }
4545
Jeff Johnsone7245742012-09-05 17:12:55 -07004546#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4548
4549 nCfg = 6;
4550 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4551 if ( eSIR_SUCCESS != nSirStatus )
4552 {
4553 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004554 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 nSirStatus );
4556 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4557 return eSIR_FAILURE; // just allocated...
4558 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004559#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004560
4561#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004562 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004563#endif
4564
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4566 sizeof(tSirMacMgmtHdr),
4567 nPayload, &nPayload );
4568 if ( DOT11F_FAILED( nStatus ) )
4569 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004570 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 nStatus );
4572 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4573 return eSIR_FAILURE; // allocated!
4574 }
4575 else if ( DOT11F_WARNED( nStatus ) )
4576 {
4577 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004578 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 }
4580
Jeff Johnsone7245742012-09-05 17:12:55 -07004581 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004582 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4583 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004584 )
4585 {
4586 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4589 HAL_TXRX_FRM_802_11_MGMT,
4590 ANI_TXDIR_TODS,
4591 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004592 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4594 {
4595 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004596 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 nSirStatus );
4598 //Pkt will be freed up by the callback
4599 return eSIR_FAILURE;
4600 }
4601
4602 return eSIR_SUCCESS;
4603
4604} // End limSendChannelSwitchMgmtFrame.
4605
Jeff Johnson295189b2012-06-20 16:38:30 -07004606
4607
Mohit Khanna4a70d262012-09-11 16:30:12 -07004608#ifdef WLAN_FEATURE_11AC
4609tSirRetStatus
4610limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4611 tSirMacAddr peer,
4612 tANI_U8 nMode,
4613 tpPESession psessionEntry )
4614{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304615 tDot11fOperatingMode frm;
4616 tANI_U8 *pFrame;
4617 tSirRetStatus nSirStatus;
4618 tpSirMacMgmtHdr pMacHdr;
4619 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4620 void *pPacket;
4621 eHalStatus halstatus;
4622 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07004623
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304624 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004625
4626 frm.Category.category = SIR_MAC_ACTION_VHT;
4627 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4628 frm.OperatingMode.chanWidth = nMode;
4629 frm.OperatingMode.rxNSS = 0;
4630 frm.OperatingMode.rxNSSType = 0;
4631
4632 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4633 if ( DOT11F_FAILED( nStatus ) )
4634 {
4635 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004636 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004637 nStatus );
4638 // We'll fall back on the worst case scenario:
4639 nPayload = sizeof( tDot11fOperatingMode);
4640 }
4641 else if ( DOT11F_WARNED( nStatus ) )
4642 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004643 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004644 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004645 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004646 }
4647
4648 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4649
4650 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4651 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4652 {
4653 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004654 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004655 return eSIR_FAILURE;
4656 }
4657
4658 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304659 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004660
4661
4662 // Next, we fill out the buffer descriptor:
4663 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4664 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4665 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4666 } else
4667 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4668 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4669 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304670 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4671 (tANI_U8 *) psessionEntry->bssId,
4672 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004673 if ( eSIR_SUCCESS != nSirStatus )
4674 {
4675 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004676 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004677 nSirStatus );
4678 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4679 return eSIR_FAILURE; // just allocated...
4680 }
4681 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4682 sizeof(tSirMacMgmtHdr),
4683 nPayload, &nPayload );
4684 if ( DOT11F_FAILED( nStatus ) )
4685 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004686 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004687 nStatus );
4688 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4689 return eSIR_FAILURE; // allocated!
4690 }
4691 else if ( DOT11F_WARNED( nStatus ) )
4692 {
4693 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004694 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004695 }
4696 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004697 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4698 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004699 )
4700 {
4701 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4702 }
4703 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4704 HAL_TXRX_FRM_802_11_MGMT,
4705 ANI_TXDIR_TODS,
4706 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4707 limTxComplete, pFrame, txFlag );
4708 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4709 {
4710 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004711 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004712 nSirStatus );
4713 //Pkt will be freed up by the callback
4714 return eSIR_FAILURE;
4715 }
4716
4717 return eSIR_SUCCESS;
4718}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004719
4720/**
4721 * \brief Send a VHT Channel Switch Announcement
4722 *
4723 *
4724 * \param pMac Pointer to the global MAC datastructure
4725 *
4726 * \param peer MAC address to which this frame will be sent
4727 *
4728 * \param nChanWidth
4729 *
4730 * \param nNewChannel
4731 *
4732 *
4733 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4734 *
4735 *
4736 */
4737
4738tSirRetStatus
4739limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4740 tSirMacAddr peer,
4741 tANI_U8 nChanWidth,
4742 tANI_U8 nNewChannel,
4743 tANI_U8 ncbMode,
4744 tpPESession psessionEntry )
4745{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304746 tDot11fChannelSwitch frm;
4747 tANI_U8 *pFrame;
4748 tSirRetStatus nSirStatus;
4749 tpSirMacMgmtHdr pMacHdr;
4750 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4751 void *pPacket;
4752 eHalStatus halstatus;
4753 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004754
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304755 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004756
4757
4758 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4759 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4760 frm.ChanSwitchAnn.switchMode = 1;
4761 frm.ChanSwitchAnn.newChannel = nNewChannel;
4762 frm.ChanSwitchAnn.switchCount = 1;
4763 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4764 frm.ExtChanSwitchAnn.present = 1;
4765 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4766 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4767 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4768 frm.ChanSwitchAnn.present = 1;
4769 frm.WiderBWChanSwitchAnn.present = 1;
4770
4771 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4772 if ( DOT11F_FAILED( nStatus ) )
4773 {
4774 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004775 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004776 nStatus );
4777 // We'll fall back on the worst case scenario:
4778 nPayload = sizeof( tDot11fChannelSwitch );
4779 }
4780 else if ( DOT11F_WARNED( nStatus ) )
4781 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004782 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004783 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004784 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004785 }
4786
4787 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4788
4789 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4790 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4791 {
4792 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004793 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004794 return eSIR_FAILURE;
4795 }
4796 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304797 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004798
4799 // Next, we fill out the buffer descriptor:
4800 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4801 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4802 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304803 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4804 (tANI_U8 *) psessionEntry->bssId,
4805 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004806 if ( eSIR_SUCCESS != nSirStatus )
4807 {
4808 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004809 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004810 nSirStatus );
4811 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4812 return eSIR_FAILURE; // just allocated...
4813 }
4814 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4815 sizeof(tSirMacMgmtHdr),
4816 nPayload, &nPayload );
4817 if ( DOT11F_FAILED( nStatus ) )
4818 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004819 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004820 nStatus );
4821 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4822 return eSIR_FAILURE; // allocated!
4823 }
4824 else if ( DOT11F_WARNED( nStatus ) )
4825 {
4826 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004827 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004828 }
4829
4830 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004831 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4832 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004833 )
4834 {
4835 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4836 }
4837 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4838 HAL_TXRX_FRM_802_11_MGMT,
4839 ANI_TXDIR_TODS,
4840 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4841 limTxComplete, pFrame, txFlag );
4842 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4843 {
4844 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004845 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004846 nSirStatus );
4847 //Pkt will be freed up by the callback
4848 return eSIR_FAILURE;
4849 }
4850
4851 return eSIR_SUCCESS;
4852
4853} // End limSendVHTChannelSwitchMgmtFrame.
4854
4855
4856
Mohit Khanna4a70d262012-09-11 16:30:12 -07004857#endif
4858
Jeff Johnson295189b2012-06-20 16:38:30 -07004859/**
4860 * \brief Send an ADDBA Req Action Frame to peer
4861 *
4862 * \sa limSendAddBAReq
4863 *
4864 * \param pMac The global tpAniSirGlobal object
4865 *
4866 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4867 * the necessary parameters reqd by PE send the ADDBA Req Action
4868 * Frame to the peer
4869 *
4870 * \return eSIR_SUCCESS if setup completes successfully
4871 * eSIR_FAILURE is some problem is encountered
4872 */
4873tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304874 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004875{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304876 tDot11fAddBAReq frmAddBAReq;
4877 tANI_U8 *pAddBAReqBuffer = NULL;
4878 tpSirMacMgmtHdr pMacHdr;
4879 tANI_U32 frameLen = 0, nStatus, nPayload;
4880 tSirRetStatus statusCode;
4881 eHalStatus halStatus;
4882 void *pPacket;
4883 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004884
4885 if(NULL == psessionEntry)
4886 {
4887 return eSIR_FAILURE;
4888 }
4889
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304890 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004891
4892 // Category - 3 (BA)
4893 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4894
4895 // Action - 0 (ADDBA Req)
4896 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4897
4898 // FIXME - Dialog Token, generalize this...
4899 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4900
4901 // Fill the ADDBA Parameter Set
4902 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4903 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4904 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4905
4906 // BA timeout
4907 // 0 - indicates no BA timeout
4908 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4909
4910 // BA Starting Sequence Number
4911 // Fragment number will always be zero
4912 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4913 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4914 }
4915
4916 frmAddBAReq.BAStartingSequenceControl.ssn =
4917 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4918
4919 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4920
4921 if( DOT11F_FAILED( nStatus ))
4922 {
4923 limLog( pMac, LOGW,
4924 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004925 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 nStatus );
4927
4928 // We'll fall back on the worst case scenario:
4929 nPayload = sizeof( tDot11fAddBAReq );
4930 }
4931 else if( DOT11F_WARNED( nStatus ))
4932 {
4933 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004934 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004935 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 nStatus );
4937 }
4938
4939 // Add the MGMT header to frame length
4940 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4941
4942 // Need to allocate a buffer for ADDBA AF
4943 if( eHAL_STATUS_SUCCESS !=
4944 (halStatus = palPktAlloc( pMac->hHdd,
4945 HAL_TXRX_FRM_802_11_MGMT,
4946 (tANI_U16) frameLen,
4947 (void **) &pAddBAReqBuffer,
4948 (void **) &pPacket )))
4949 {
4950 // Log error
4951 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004952 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 frameLen,
4954 halStatus );
4955
4956 statusCode = eSIR_MEM_ALLOC_FAILED;
4957 goto returnAfterError;
4958 }
4959
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304960 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004961
4962 // Copy necessary info to BD
4963 if( eSIR_SUCCESS !=
4964 (statusCode = limPopulateMacHeader( pMac,
4965 pAddBAReqBuffer,
4966 SIR_MAC_MGMT_FRAME,
4967 SIR_MAC_MGMT_ACTION,
4968 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4969 goto returnAfterError;
4970
4971 // Update A3 with the BSSID
4972 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4973
4974 #if 0
4975 cfgLen = SIR_MAC_ADDR_LENGTH;
4976 if( eSIR_SUCCESS != cfgGetStr( pMac,
4977 WNI_CFG_BSSID,
4978 (tANI_U8 *) pMacHdr->bssId,
4979 &cfgLen ))
4980 {
4981 limLog( pMac, LOGP,
4982 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004983 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004984
4985 // FIXME - Need to convert to tSirRetStatus
4986 statusCode = eSIR_FAILURE;
4987 goto returnAfterError;
4988 }
4989 #endif//TO SUPPORT BT-AMP
4990 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4991
Chet Lanctot186b5732013-03-18 10:26:30 -07004992#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004993 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004994#endif
4995
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 // Now, we're ready to "pack" the frames
4997 nStatus = dot11fPackAddBAReq( pMac,
4998 &frmAddBAReq,
4999 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5000 nPayload,
5001 &nPayload );
5002
5003 if( DOT11F_FAILED( nStatus ))
5004 {
5005 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005006 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005007 nStatus );
5008
5009 // FIXME - Need to convert to tSirRetStatus
5010 statusCode = eSIR_FAILURE;
5011 goto returnAfterError;
5012 }
5013 else if( DOT11F_WARNED( nStatus ))
5014 {
5015 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005016 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5017 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 }
5019
5020 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005021 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5023
5024 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5026 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 )
5028 {
5029 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5030 }
5031
5032 if( eHAL_STATUS_SUCCESS !=
5033 (halStatus = halTxFrame( pMac,
5034 pPacket,
5035 (tANI_U16) frameLen,
5036 HAL_TXRX_FRM_802_11_MGMT,
5037 ANI_TXDIR_TODS,
5038 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5039 limTxComplete,
5040 pAddBAReqBuffer, txFlag )))
5041 {
5042 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005043 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 halStatus );
5045
5046 // FIXME - Need to convert eHalStatus to tSirRetStatus
5047 statusCode = eSIR_FAILURE;
5048 //Pkt will be freed up by the callback
5049 return statusCode;
5050 }
5051 else
5052 return eSIR_SUCCESS;
5053
5054returnAfterError:
5055
5056 // Release buffer, if allocated
5057 if( NULL != pAddBAReqBuffer )
5058 palPktFree( pMac->hHdd,
5059 HAL_TXRX_FRM_802_11_MGMT,
5060 (void *) pAddBAReqBuffer,
5061 (void *) pPacket );
5062
5063 return statusCode;
5064}
5065
5066/**
5067 * \brief Send an ADDBA Rsp Action Frame to peer
5068 *
5069 * \sa limSendAddBARsp
5070 *
5071 * \param pMac The global tpAniSirGlobal object
5072 *
5073 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5074 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5075 * Frame to the peer
5076 *
5077 * \return eSIR_SUCCESS if setup completes successfully
5078 * eSIR_FAILURE is some problem is encountered
5079 */
5080tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5081 tpLimMlmAddBARsp pMlmAddBARsp,
5082 tpPESession psessionEntry)
5083{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305084 tDot11fAddBARsp frmAddBARsp;
5085 tANI_U8 *pAddBARspBuffer = NULL;
5086 tpSirMacMgmtHdr pMacHdr;
5087 tANI_U32 frameLen = 0, nStatus, nPayload;
5088 tSirRetStatus statusCode;
5089 eHalStatus halStatus;
5090 void *pPacket;
5091 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005092
5093 if(NULL == psessionEntry)
5094 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005095 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 return eSIR_FAILURE;
5097 }
5098
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305099 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005100
5101 // Category - 3 (BA)
5102 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5103 // Action - 1 (ADDBA Rsp)
5104 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5105
5106 // Should be same as the one we received in the ADDBA Req
5107 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5108
5109 // ADDBA Req status
5110 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5111
5112 // Fill the ADDBA Parameter Set as provided by caller
5113 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5114 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5115 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005116
5117 if(psessionEntry->isAmsduSupportInAMPDU)
5118 {
5119 frmAddBARsp.AddBAParameterSet.amsduSupported =
5120 psessionEntry->amsduSupportedInBA;
5121 }
5122 else
5123 {
5124 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005126
5127 // BA timeout
5128 // 0 - indicates no BA timeout
5129 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5130
5131 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5132
5133 if( DOT11F_FAILED( nStatus ))
5134 {
5135 limLog( pMac, LOGW,
5136 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005137 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 nStatus );
5139
5140 // We'll fall back on the worst case scenario:
5141 nPayload = sizeof( tDot11fAddBARsp );
5142 }
5143 else if( DOT11F_WARNED( nStatus ))
5144 {
5145 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005146 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005147 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005148 nStatus );
5149 }
5150
5151 // Need to allocate a buffer for ADDBA AF
5152 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5153
5154 // Allocate shared memory
5155 if( eHAL_STATUS_SUCCESS !=
5156 (halStatus = palPktAlloc( pMac->hHdd,
5157 HAL_TXRX_FRM_802_11_MGMT,
5158 (tANI_U16) frameLen,
5159 (void **) &pAddBARspBuffer,
5160 (void **) &pPacket )))
5161 {
5162 // Log error
5163 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005164 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 frameLen,
5166 halStatus );
5167
5168 statusCode = eSIR_MEM_ALLOC_FAILED;
5169 goto returnAfterError;
5170 }
5171
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305172 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005173
5174 // Copy necessary info to BD
5175 if( eSIR_SUCCESS !=
5176 (statusCode = limPopulateMacHeader( pMac,
5177 pAddBARspBuffer,
5178 SIR_MAC_MGMT_FRAME,
5179 SIR_MAC_MGMT_ACTION,
5180 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5181 goto returnAfterError;
5182
5183 // Update A3 with the BSSID
5184
5185 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5186
5187 #if 0
5188 cfgLen = SIR_MAC_ADDR_LENGTH;
5189 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5190 WNI_CFG_BSSID,
5191 (tANI_U8 *) pMacHdr->bssId,
5192 &cfgLen ))
5193 {
5194 limLog( pMac, LOGP,
5195 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005196 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005197
5198 // FIXME - Need to convert to tSirRetStatus
5199 statusCode = eSIR_FAILURE;
5200 goto returnAfterError;
5201 }
5202 #endif // TO SUPPORT BT-AMP
5203 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5204
Chet Lanctot186b5732013-03-18 10:26:30 -07005205#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005206 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005207#endif
5208
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 // Now, we're ready to "pack" the frames
5210 nStatus = dot11fPackAddBARsp( pMac,
5211 &frmAddBARsp,
5212 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5213 nPayload,
5214 &nPayload );
5215
5216 if( DOT11F_FAILED( nStatus ))
5217 {
5218 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005219 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005220 nStatus );
5221
5222 // FIXME - Need to convert to tSirRetStatus
5223 statusCode = eSIR_FAILURE;
5224 goto returnAfterError;
5225 }
5226 else if( DOT11F_WARNED( nStatus ))
5227 {
5228 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005229 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5230 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 }
5232
5233 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005234 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5236
5237 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5239 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 )
5241 {
5242 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5243 }
5244
5245 if( eHAL_STATUS_SUCCESS !=
5246 (halStatus = halTxFrame( pMac,
5247 pPacket,
5248 (tANI_U16) frameLen,
5249 HAL_TXRX_FRM_802_11_MGMT,
5250 ANI_TXDIR_TODS,
5251 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5252 limTxComplete,
5253 pAddBARspBuffer, txFlag )))
5254 {
5255 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005256 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 halStatus );
5258
5259 // FIXME - HAL error codes are different from PE error
5260 // codes!! And, this routine is returning tSirRetStatus
5261 statusCode = eSIR_FAILURE;
5262 //Pkt will be freed up by the callback
5263 return statusCode;
5264 }
5265 else
5266 return eSIR_SUCCESS;
5267
5268 returnAfterError:
5269
5270 // Release buffer, if allocated
5271 if( NULL != pAddBARspBuffer )
5272 palPktFree( pMac->hHdd,
5273 HAL_TXRX_FRM_802_11_MGMT,
5274 (void *) pAddBARspBuffer,
5275 (void *) pPacket );
5276
5277 return statusCode;
5278}
5279
5280/**
5281 * \brief Send a DELBA Indication Action Frame to peer
5282 *
5283 * \sa limSendDelBAInd
5284 *
5285 * \param pMac The global tpAniSirGlobal object
5286 *
5287 * \param peerMacAddr MAC Address of peer
5288 *
5289 * \param reasonCode Reason for the DELBA notification
5290 *
5291 * \param pBAParameterSet The DELBA Parameter Set.
5292 * This identifies the TID for which the BA session is
5293 * being deleted.
5294 *
5295 * \return eSIR_SUCCESS if setup completes successfully
5296 * eSIR_FAILURE is some problem is encountered
5297 */
5298tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5299 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5300{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305301 tDot11fDelBAInd frmDelBAInd;
5302 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005303 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305304 tpSirMacMgmtHdr pMacHdr;
5305 tANI_U32 frameLen = 0, nStatus, nPayload;
5306 tSirRetStatus statusCode;
5307 eHalStatus halStatus;
5308 void *pPacket;
5309 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005310
5311 if(NULL == psessionEntry)
5312 {
5313 return eSIR_FAILURE;
5314 }
5315
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305316 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005317
5318 // Category - 3 (BA)
5319 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5320 // Action - 2 (DELBA)
5321 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5322
5323 // Fill the DELBA Parameter Set as provided by caller
5324 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5325 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5326
5327 // BA Starting Sequence Number
5328 // Fragment number will always be zero
5329 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5330
5331 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5332
5333 if( DOT11F_FAILED( nStatus ))
5334 {
5335 limLog( pMac, LOGW,
5336 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005337 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 nStatus );
5339
5340 // We'll fall back on the worst case scenario:
5341 nPayload = sizeof( tDot11fDelBAInd );
5342 }
5343 else if( DOT11F_WARNED( nStatus ))
5344 {
5345 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005346 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005347 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 nStatus );
5349 }
5350
5351 // Add the MGMT header to frame length
5352 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5353
5354 // Allocate shared memory
5355 if( eHAL_STATUS_SUCCESS !=
5356 (halStatus = palPktAlloc( pMac->hHdd,
5357 HAL_TXRX_FRM_802_11_MGMT,
5358 (tANI_U16) frameLen,
5359 (void **) &pDelBAIndBuffer,
5360 (void **) &pPacket )))
5361 {
5362 // Log error
5363 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005364 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 frameLen,
5366 halStatus );
5367
5368 statusCode = eSIR_MEM_ALLOC_FAILED;
5369 goto returnAfterError;
5370 }
5371
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305372 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005373
5374 // Copy necessary info to BD
5375 if( eSIR_SUCCESS !=
5376 (statusCode = limPopulateMacHeader( pMac,
5377 pDelBAIndBuffer,
5378 SIR_MAC_MGMT_FRAME,
5379 SIR_MAC_MGMT_ACTION,
5380 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5381 goto returnAfterError;
5382
5383 // Update A3 with the BSSID
5384 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5385
5386 #if 0
5387 cfgLen = SIR_MAC_ADDR_LENGTH;
5388 if( eSIR_SUCCESS != cfgGetStr( pMac,
5389 WNI_CFG_BSSID,
5390 (tANI_U8 *) pMacHdr->bssId,
5391 &cfgLen ))
5392 {
5393 limLog( pMac, LOGP,
5394 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005395 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005396
5397 // FIXME - Need to convert to tSirRetStatus
5398 statusCode = eSIR_FAILURE;
5399 goto returnAfterError;
5400 }
5401 #endif //TO SUPPORT BT-AMP
5402 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5403
Chet Lanctot186b5732013-03-18 10:26:30 -07005404#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005405 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005406#endif
5407
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 // Now, we're ready to "pack" the frames
5409 nStatus = dot11fPackDelBAInd( pMac,
5410 &frmDelBAInd,
5411 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5412 nPayload,
5413 &nPayload );
5414
5415 if( DOT11F_FAILED( nStatus ))
5416 {
5417 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005418 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 nStatus );
5420
5421 // FIXME - Need to convert to tSirRetStatus
5422 statusCode = eSIR_FAILURE;
5423 goto returnAfterError;
5424 }
5425 else if( DOT11F_WARNED( nStatus ))
5426 {
5427 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005428 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5429 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 }
5431
5432 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005433 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5435
5436 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5438 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 )
5440 {
5441 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5442 }
5443
5444 if( eHAL_STATUS_SUCCESS !=
5445 (halStatus = halTxFrame( pMac,
5446 pPacket,
5447 (tANI_U16) frameLen,
5448 HAL_TXRX_FRM_802_11_MGMT,
5449 ANI_TXDIR_TODS,
5450 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5451 limTxComplete,
5452 pDelBAIndBuffer, txFlag )))
5453 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005454 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 statusCode = eSIR_FAILURE;
5456 //Pkt will be freed up by the callback
5457 return statusCode;
5458 }
5459 else
5460 return eSIR_SUCCESS;
5461
5462 returnAfterError:
5463
5464 // Release buffer, if allocated
5465 if( NULL != pDelBAIndBuffer )
5466 palPktFree( pMac->hHdd,
5467 HAL_TXRX_FRM_802_11_MGMT,
5468 (void *) pDelBAIndBuffer,
5469 (void *) pPacket );
5470
5471 return statusCode;
5472}
5473
5474#if defined WLAN_FEATURE_VOWIFI
5475
5476/**
5477 * \brief Send a Neighbor Report Request Action frame
5478 *
5479 *
5480 * \param pMac Pointer to the global MAC structure
5481 *
5482 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5483 *
5484 * \param peer mac address of peer station.
5485 *
5486 * \param psessionEntry address of session entry.
5487 *
5488 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5489 *
5490 *
5491 */
5492
5493tSirRetStatus
5494limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5495 tpSirMacNeighborReportReq pNeighborReq,
5496 tSirMacAddr peer,
5497 tpPESession psessionEntry
5498 )
5499{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305500 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 tDot11fNeighborReportRequest frm;
5502 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305503 tpSirMacMgmtHdr pMacHdr;
5504 tANI_U32 nBytes, nPayload, nStatus;
5505 void *pPacket;
5506 eHalStatus halstatus;
5507 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005508
5509 if ( psessionEntry == NULL )
5510 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005511 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 return eSIR_FAILURE;
5513 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305514 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005515
5516 frm.Category.category = SIR_MAC_ACTION_RRM;
5517 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5518 frm.DialogToken.token = pNeighborReq->dialogToken;
5519
5520
5521 if( pNeighborReq->ssid_present )
5522 {
5523 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5524 }
5525
5526 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5527 if ( DOT11F_FAILED( nStatus ) )
5528 {
5529 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005530 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 nStatus );
5532 // We'll fall back on the worst case scenario:
5533 nPayload = sizeof( tDot11fNeighborReportRequest );
5534 }
5535 else if ( DOT11F_WARNED( nStatus ) )
5536 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005537 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005539 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 }
5541
5542 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5543
5544 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5545 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5546 {
5547 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005548 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 return eSIR_FAILURE;
5550 }
5551
5552 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305553 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005554
5555 // Copy necessary info to BD
5556 if( eSIR_SUCCESS !=
5557 (statusCode = limPopulateMacHeader( pMac,
5558 pFrame,
5559 SIR_MAC_MGMT_FRAME,
5560 SIR_MAC_MGMT_ACTION,
5561 peer, psessionEntry->selfMacAddr)))
5562 goto returnAfterError;
5563
5564 // Update A3 with the BSSID
5565 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5566
5567 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5568
Chet Lanctot186b5732013-03-18 10:26:30 -07005569#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005570 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005571#endif
5572
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 // Now, we're ready to "pack" the frames
5574 nStatus = dot11fPackNeighborReportRequest( pMac,
5575 &frm,
5576 pFrame + sizeof( tSirMacMgmtHdr ),
5577 nPayload,
5578 &nPayload );
5579
5580 if( DOT11F_FAILED( nStatus ))
5581 {
5582 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005583 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 nStatus );
5585
5586 // FIXME - Need to convert to tSirRetStatus
5587 statusCode = eSIR_FAILURE;
5588 goto returnAfterError;
5589 }
5590 else if( DOT11F_WARNED( nStatus ))
5591 {
5592 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005593 FL( "There were warnings while packing Neighbor Report "
5594 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 }
5596
5597 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005598 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 limPrintMacAddr( pMac, peer, LOGW );
5600
5601 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5603 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 )
5605 {
5606 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5607 }
5608
5609 if( eHAL_STATUS_SUCCESS !=
5610 (halstatus = halTxFrame( pMac,
5611 pPacket,
5612 (tANI_U16) nBytes,
5613 HAL_TXRX_FRM_802_11_MGMT,
5614 ANI_TXDIR_TODS,
5615 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5616 limTxComplete,
5617 pFrame, txFlag )))
5618 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005619 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 statusCode = eSIR_FAILURE;
5621 //Pkt will be freed up by the callback
5622 return statusCode;
5623 }
5624 else
5625 return eSIR_SUCCESS;
5626
5627returnAfterError:
5628 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5629
5630 return statusCode;
5631} // End limSendNeighborReportRequestFrame.
5632
5633/**
5634 * \brief Send a Link Report Action frame
5635 *
5636 *
5637 * \param pMac Pointer to the global MAC structure
5638 *
5639 * \param pLinkReport Address of a tSirMacLinkReport
5640 *
5641 * \param peer mac address of peer station.
5642 *
5643 * \param psessionEntry address of session entry.
5644 *
5645 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5646 *
5647 *
5648 */
5649
5650tSirRetStatus
5651limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5652 tpSirMacLinkReport pLinkReport,
5653 tSirMacAddr peer,
5654 tpPESession psessionEntry
5655 )
5656{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305657 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 tDot11fLinkMeasurementReport frm;
5659 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305660 tpSirMacMgmtHdr pMacHdr;
5661 tANI_U32 nBytes, nPayload, nStatus;
5662 void *pPacket;
5663 eHalStatus halstatus;
5664 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005665
5666
5667 if ( psessionEntry == NULL )
5668 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005669 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 return eSIR_FAILURE;
5671 }
5672
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305673 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005674
5675 frm.Category.category = SIR_MAC_ACTION_RRM;
5676 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5677 frm.DialogToken.token = pLinkReport->dialogToken;
5678
5679
5680 //IEEE Std. 802.11 7.3.2.18. for the report element.
5681 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5682 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5683 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5684 //such case this way than changing the frame parser.
5685 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5686 frm.TPCEleLen.TPCLen = 2;
5687 frm.TxPower.txPower = pLinkReport->txPower;
5688 frm.LinkMargin.linkMargin = 0;
5689
5690 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5691 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5692 frm.RCPI.rcpi = pLinkReport->rcpi;
5693 frm.RSNI.rsni = pLinkReport->rsni;
5694
5695 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5696 if ( DOT11F_FAILED( nStatus ) )
5697 {
5698 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005699 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 nStatus );
5701 // We'll fall back on the worst case scenario:
5702 nPayload = sizeof( tDot11fLinkMeasurementReport );
5703 }
5704 else if ( DOT11F_WARNED( nStatus ) )
5705 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005706 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005708 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 }
5710
5711 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5712
5713 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5714 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5715 {
5716 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005717 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 return eSIR_FAILURE;
5719 }
5720
5721 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305722 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005723
5724 // Copy necessary info to BD
5725 if( eSIR_SUCCESS !=
5726 (statusCode = limPopulateMacHeader( pMac,
5727 pFrame,
5728 SIR_MAC_MGMT_FRAME,
5729 SIR_MAC_MGMT_ACTION,
5730 peer, psessionEntry->selfMacAddr)))
5731 goto returnAfterError;
5732
5733 // Update A3 with the BSSID
5734 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5735
5736 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5737
Chet Lanctot186b5732013-03-18 10:26:30 -07005738#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005739 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005740#endif
5741
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 // Now, we're ready to "pack" the frames
5743 nStatus = dot11fPackLinkMeasurementReport( pMac,
5744 &frm,
5745 pFrame + sizeof( tSirMacMgmtHdr ),
5746 nPayload,
5747 &nPayload );
5748
5749 if( DOT11F_FAILED( nStatus ))
5750 {
5751 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005752 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005753 nStatus );
5754
5755 // FIXME - Need to convert to tSirRetStatus
5756 statusCode = eSIR_FAILURE;
5757 goto returnAfterError;
5758 }
5759 else if( DOT11F_WARNED( nStatus ))
5760 {
5761 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005762 FL( "There were warnings while packing Link Report (0x%08x)." ),
5763 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 }
5765
5766 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005767 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005768 limPrintMacAddr( pMac, peer, LOGW );
5769
5770 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5772 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005773 )
5774 {
5775 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5776 }
5777
5778 if( eHAL_STATUS_SUCCESS !=
5779 (halstatus = halTxFrame( pMac,
5780 pPacket,
5781 (tANI_U16) nBytes,
5782 HAL_TXRX_FRM_802_11_MGMT,
5783 ANI_TXDIR_TODS,
5784 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5785 limTxComplete,
5786 pFrame, txFlag )))
5787 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005788 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 statusCode = eSIR_FAILURE;
5790 //Pkt will be freed up by the callback
5791 return statusCode;
5792 }
5793 else
5794 return eSIR_SUCCESS;
5795
5796returnAfterError:
5797 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5798
5799 return statusCode;
5800} // End limSendLinkReportActionFrame.
5801
5802/**
5803 * \brief Send a Beacon Report Action frame
5804 *
5805 *
5806 * \param pMac Pointer to the global MAC structure
5807 *
5808 * \param dialog_token dialog token to be used in the action frame.
5809 *
5810 * \param num_report number of reports in pRRMReport.
5811 *
5812 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5813 *
5814 * \param peer mac address of peer station.
5815 *
5816 * \param psessionEntry address of session entry.
5817 *
5818 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5819 *
5820 *
5821 */
5822
5823tSirRetStatus
5824limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5825 tANI_U8 dialog_token,
5826 tANI_U8 num_report,
5827 tpSirMacRadioMeasureReport pRRMReport,
5828 tSirMacAddr peer,
5829 tpPESession psessionEntry
5830 )
5831{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305832 tSirRetStatus statusCode = eSIR_SUCCESS;
5833 tANI_U8 *pFrame;
5834 tpSirMacMgmtHdr pMacHdr;
5835 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305837 eHalStatus halstatus;
5838 tANI_U8 i;
5839 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005840
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005841 tDot11fRadioMeasurementReport *frm =
5842 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5843 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005844 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005845 return eSIR_FAILURE;
5846 }
5847
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 if ( psessionEntry == NULL )
5849 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005850 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005851 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 return eSIR_FAILURE;
5853 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305854 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005855
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005856 frm->Category.category = SIR_MAC_ACTION_RRM;
5857 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5858 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005859
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005860 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 -07005861
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005862 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005864 frm->MeasurementReport[i].type = pRRMReport[i].type;
5865 frm->MeasurementReport[i].token = pRRMReport[i].token;
5866 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 switch( pRRMReport[i].type )
5868 {
5869 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005870 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5871 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5872 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5873 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 break;
5875 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305876 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5877 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005878 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 break;
5880 }
5881 }
5882
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005883 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 if ( DOT11F_FAILED( nStatus ) )
5885 {
5886 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005887 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005888 nStatus );
5889 // We'll fall back on the worst case scenario:
5890 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005891 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 return eSIR_FAILURE;
5893 }
5894 else if ( DOT11F_WARNED( nStatus ) )
5895 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005896 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005898 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 }
5900
5901 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5902
5903 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5904 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5905 {
5906 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005907 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005908 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 return eSIR_FAILURE;
5910 }
5911
5912 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305913 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005914
5915 // Copy necessary info to BD
5916 if( eSIR_SUCCESS !=
5917 (statusCode = limPopulateMacHeader( pMac,
5918 pFrame,
5919 SIR_MAC_MGMT_FRAME,
5920 SIR_MAC_MGMT_ACTION,
5921 peer, psessionEntry->selfMacAddr)))
5922 goto returnAfterError;
5923
5924 // Update A3 with the BSSID
5925 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5926
5927 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5928
Chet Lanctot186b5732013-03-18 10:26:30 -07005929#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005930 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005931#endif
5932
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 // Now, we're ready to "pack" the frames
5934 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005935 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 pFrame + sizeof( tSirMacMgmtHdr ),
5937 nPayload,
5938 &nPayload );
5939
5940 if( DOT11F_FAILED( nStatus ))
5941 {
5942 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005943 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 nStatus );
5945
5946 // FIXME - Need to convert to tSirRetStatus
5947 statusCode = eSIR_FAILURE;
5948 goto returnAfterError;
5949 }
5950 else if( DOT11F_WARNED( nStatus ))
5951 {
5952 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005953 FL( "There were warnings while packing Radio "
5954 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 }
5956
5957 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005958 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 limPrintMacAddr( pMac, peer, LOGW );
5960
5961 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5963 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 )
5965 {
5966 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5967 }
5968
5969 if( eHAL_STATUS_SUCCESS !=
5970 (halstatus = halTxFrame( pMac,
5971 pPacket,
5972 (tANI_U16) nBytes,
5973 HAL_TXRX_FRM_802_11_MGMT,
5974 ANI_TXDIR_TODS,
5975 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5976 limTxComplete,
5977 pFrame, txFlag )))
5978 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005979 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 statusCode = eSIR_FAILURE;
5981 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005982 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 return statusCode;
5984 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005985 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005986 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005989
5990returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005991 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 return statusCode;
5994} // End limSendBeaconReportActionFrame.
5995
5996#endif
5997
5998#ifdef WLAN_FEATURE_11W
5999/**
6000 * \brief Send SA query response action frame to peer
6001 *
6002 * \sa limSendSaQueryResponseFrame
6003 *
6004 *
6005 * \param pMac The global tpAniSirGlobal object
6006 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006007 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006009 * \param peer The Mac address of the AP to which this action frame is addressed
6010 *
6011 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 *
6013 * \return eSIR_SUCCESS if setup completes successfully
6014 * eSIR_FAILURE is some problem is encountered
6015 */
6016
Chet Lanctot186b5732013-03-18 10:26:30 -07006017tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006018tSirMacAddr peer,tpPESession psessionEntry)
6019{
6020
Chet Lanctot186b5732013-03-18 10:26:30 -07006021 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 tANI_U8 *pFrame;
6023 tSirRetStatus nSirStatus;
6024 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006025 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 void *pPacket;
6027 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306028 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006029
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306030 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006031 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6032 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 action: 0 --> SA query request action frame
6034 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006035 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6036 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006038 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006039
Chet Lanctot186b5732013-03-18 10:26:30 -07006040 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6041 if ( DOT11F_FAILED( nStatus ) )
6042 {
6043 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6044 "or a SA Query Response (0x%08x)."),
6045 nStatus );
6046 // We'll fall back on the worst case scenario:
6047 nPayload = sizeof( tDot11fSaQueryRsp );
6048 }
6049 else if ( DOT11F_WARNED( nStatus ) )
6050 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006051 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006052 "the packed size for an SA Query Response"
6053 " (0x%08x)."), nStatus );
6054 }
6055
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6057 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6058 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6059 {
6060 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006061 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 return eSIR_FAILURE;
6063 }
6064
6065 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306066 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006067
Chet Lanctot186b5732013-03-18 10:26:30 -07006068 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006069 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006070 pFrame,
6071 SIR_MAC_MGMT_FRAME,
6072 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006073 peer, psessionEntry->selfMacAddr );
6074 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006075 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006076
Chet Lanctot186b5732013-03-18 10:26:30 -07006077 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6079
Chet Lanctot186b5732013-03-18 10:26:30 -07006080 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006081
Chet Lanctot186b5732013-03-18 10:26:30 -07006082 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6083 // in the FC
6084 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006086 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 }
6088
Chet Lanctot186b5732013-03-18 10:26:30 -07006089 // Pack 11w SA query response frame
6090 nStatus = dot11fPackSaQueryRsp( pMac,
6091 &frm,
6092 pFrame + sizeof( tSirMacMgmtHdr ),
6093 nPayload,
6094 &nPayload );
6095
6096 if ( DOT11F_FAILED( nStatus ))
6097 {
6098 limLog( pMac, LOGE,
6099 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6100 nStatus );
6101 // FIXME - Need to convert to tSirRetStatus
6102 nSirStatus = eSIR_FAILURE;
6103 goto returnAfterError;
6104 }
6105 else if ( DOT11F_WARNED( nStatus ))
6106 {
6107 limLog( pMac, LOGW,
6108 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6109 nStatus);
6110 }
6111
6112 limLog( pMac, LOG1,
6113 FL( "Sending a SA Query Response to " ));
6114 limPrintMacAddr( pMac, peer, LOGW );
6115
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006116 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006117#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006118 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6119 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006120#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006121 )
6122 {
6123 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6124 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006125
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006126 halstatus = halTxFrame( pMac,
6127 pPacket,
6128 (tANI_U16) nBytes,
6129 HAL_TXRX_FRM_802_11_MGMT,
6130 ANI_TXDIR_TODS,
6131 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6132 limTxComplete,
6133 pFrame, txFlag );
6134 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006135 {
6136 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6137 nSirStatus = eSIR_FAILURE;
6138 //Pkt will be freed up by the callback
6139 return nSirStatus;
6140 }
6141 else {
6142 return eSIR_SUCCESS;
6143 }
6144
6145returnAfterError:
6146 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6147 return nSirStatus;
6148} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006149#endif