blob: 1e7a0e940e688ec30c9be127e0bb912ffd2e0b29 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
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 *
46 * Copyright (C) 2005-2007 Airgo Networks, Incorporated
47 *
48 */
49
50#include "sirApi.h"
51#include "aniGlobal.h"
52#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include "cfgApi.h"
54#include "utilsApi.h"
55#include "limTypes.h"
56#include "limUtils.h"
57#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070058#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070059#include "dot11f.h"
60#include "limStaHashApi.h"
61#include "schApi.h"
62#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080063#include "limAssocUtils.h"
64#include "limFT.h"
65
Jeff Johnson295189b2012-06-20 16:38:30 -070066#if defined WLAN_FEATURE_VOWIFI
67#include "rrmApi.h"
68#endif
69
Jeff Johnson295189b2012-06-20 16:38:30 -070070#include "wlan_qct_wda.h"
71#ifdef WLAN_FEATURE_11W
72#include "dot11fdefs.h"
73#endif
74
75
76////////////////////////////////////////////////////////////////////////
77
Jeff Johnson295189b2012-06-20 16:38:30 -070078
79/**
80 *
81 * \brief This function is called by various LIM modules to prepare the
82 * 802.11 frame MAC header
83 *
84 *
85 * \param pMac Pointer to Global MAC structure
86 *
87 * \param pBD Pointer to the frame buffer that needs to be populate
88 *
89 * \param type Type of the frame
90 *
91 * \param subType Subtype of the frame
92 *
93 * \return eHalStatus
94 *
95 *
96 * The pFrameBuf argument points to the beginning of the frame buffer to
97 * which - a) The 802.11 MAC header is set b) Following this MAC header
98 * will be the MGMT frame payload The payload itself is populated by the
99 * caller API
100 *
101 *
102 */
103
104tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
105 tANI_U8* pBD,
106 tANI_U8 type,
107 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530108 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700109{
110 tSirRetStatus statusCode = eSIR_SUCCESS;
111 tpSirMacMgmtHdr pMacHdr;
112
113 /// Prepare MAC management header
114 pMacHdr = (tpSirMacMgmtHdr) (pBD);
115
116 // Prepare FC
117 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
118 pMacHdr->fc.type = type;
119 pMacHdr->fc.subType = subType;
120
121 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530122 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700123 (tANI_U8 *) peerAddr,
124 sizeof( tSirMacAddr ));
125
126 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700127 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
128
129 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530130 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 (tANI_U8 *) peerAddr,
132 sizeof( tSirMacAddr ));
133 return statusCode;
134} /*** end limPopulateMacHeader() ***/
135
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700136#ifdef WLAN_FEATURE_11W
137/**
138 *
139 * \brief This function is called by various LIM modules to correctly set
140 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
141 *
142 *
143 * \param pMac Pointer to Global MAC structure
144 *
145 * \param psessionEntry Pointer to session corresponding to the connection
146 *
147 * \param peer Peer address of the STA to which the frame is to be sent
148 *
149 * \param pMacHdr Pointer to the frame MAC header
150 *
151 * \return nothing
152 *
153 *
154 */
155void
156limSetProtectedBit(tpAniSirGlobal pMac,
157 tpPESession psessionEntry,
158 tSirMacAddr peer,
159 tpSirMacMgmtHdr pMacHdr)
160{
161 tANI_U16 aid;
162 tpDphHashNode pStaDs;
163
164 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
165 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
166 {
167
168 pStaDs = dphLookupHashEntry( pMac, peer, &aid, &psessionEntry->dph.dphHashTable );
169 if( pStaDs != NULL )
170 if( pStaDs->rmfEnabled )
171 pMacHdr->fc.wep = 1;
172 }
173 else if ( psessionEntry->limRmfEnabled )
174 pMacHdr->fc.wep = 1;
175} /*** end limSetProtectedBit() ***/
176#endif
177
Jeff Johnson295189b2012-06-20 16:38:30 -0700178/**
179 * \brief limSendProbeReqMgmtFrame
180 *
181 *
182 * \param pMac Pointer to Global MAC structure
183 *
184 * \param pSsid SSID to be sent in Probe Request frame
185 *
186 * \param bssid BSSID to be sent in Probe Request frame
187 *
188 * \param nProbeDelay probe delay to be used before sending Probe Request
189 * frame
190 *
191 * \param nChannelNum Channel # on which the Probe Request is going out
192 *
193 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
194 *
195 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
196 *
197 * This function is called by various LIM modules to send Probe Request frame
198 * during active scan/learn phase.
199 * Probe request is sent out in the following scenarios:
200 * --heartbeat failure: session needed
201 * --join req: session needed
202 * --foreground scan: no session
203 * --background scan: no session
204 * --schBeaconProcessing: to get EDCA parameters: session needed
205 *
206 *
207 */
208tSirRetStatus
209limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
210 tSirMacSSid *pSsid,
211 tSirMacAddr bssid,
212 tANI_U8 nChannelNum,
213 tSirMacAddr SelfMacAddr,
214 tANI_U32 dot11mode,
215 tANI_U32 nAdditionalIELen,
216 tANI_U8 *pAdditionalIE)
217{
218 tDot11fProbeRequest pr;
219 tANI_U32 nStatus, nBytes, nPayload;
220 tSirRetStatus nSirStatus;
221 tANI_U8 *pFrame;
222 void *pPacket;
223 eHalStatus halstatus;
224 tpPESession psessionEntry;
225 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700226 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700227 tANI_U8 txFlag = 0;
228
229#ifndef GEN4_SCAN
230 return eSIR_FAILURE;
231#endif
232
233#if defined ( ANI_DVT_DEBUG )
234 return eSIR_FAILURE;
235#endif
236
237 /*
238 * session context may or may not be present, when probe request needs to be sent out.
239 * following cases exist:
240 * --heartbeat failure: session needed
241 * --join req: session needed
242 * --foreground scan: no session
243 * --background scan: no session
244 * --schBeaconProcessing: to get EDCA parameters: session needed
245 * If session context does not exist, some IEs will be populated from CFGs,
246 * e.g. Supported and Extended rate set IEs
247 */
248 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
249
250 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
251 // and then hand it off to 'dot11fPackProbeRequest' (for
252 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530253 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700254
255 // & delegating to assorted helpers:
256 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
257
Jeff Johnson295189b2012-06-20 16:38:30 -0700258 if( nAdditionalIELen && pAdditionalIE )
259 {
260 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
261 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700262 /* Don't include 11b rate only when device is doing P2P Search */
263 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
264 ( p2pIe != NULL ) &&
265 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
266 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
267 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
268 ( ( psessionEntry != NULL ) &&
269 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
270 )
271 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 {
273 /* In the below API pass channel number > 14, do that it fills only
274 * 11a rates in supported rates */
275 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
276 }
277 else
278 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 PopulateDot11fSuppRates( pMac, nChannelNum,
280 &pr.SuppRates,psessionEntry);
281
282 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
283 {
284 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
285 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700286 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288#if defined WLAN_FEATURE_VOWIFI
289 //Table 7-14 in IEEE Std. 802.11k-2008 says
290 //DS params "can" be present in RRM is disabled and "is" present if
291 //RRM is enabled. It should be ok even if we add it into probe req when
292 //RRM is not enabled.
293 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
294 //Call RRM module to get the tx power for management used.
295 {
296 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
297 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
298 }
299#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700300
301 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700302 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700303 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700304 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700306 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700308 } else { //psessionEntry == NULL
309 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700311 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700312 }
313 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800314
315 /* Set channelbonding information as "disabled" when tunned to a 2.4 GHz channel */
316 if( nChannelNum <= SIR_11B_CHANNEL_END)
317 {
318 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
319 pr.HTCaps.shortGI40MHz = 0;
320 }
321
Jeff Johnsone7245742012-09-05 17:12:55 -0700322#ifdef WLAN_FEATURE_11AC
323 if (psessionEntry != NULL ) {
324 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
325 //Include HT Capability IE
326 if (psessionEntry->vhtCapability)
327 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700328 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
329 }
330 } else {
331 if (IS_DOT11_MODE_VHT(dot11mode))
332 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700333 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
334 }
335 }
336#endif
337
Jeff Johnson295189b2012-06-20 16:38:30 -0700338
339 // That's it-- now we pack it. First, how much space are we going to
340 // need?
341 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
342 if ( DOT11F_FAILED( nStatus ) )
343 {
344 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700345 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700346 // We'll fall back on the worst case scenario:
347 nPayload = sizeof( tDot11fProbeRequest );
348 }
349 else if ( DOT11F_WARNED( nStatus ) )
350 {
351 limLog( pMac, LOGW, FL("There were warnings while calculating"
352 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700353 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 }
355
356 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
357
358 // Ok-- try to allocate some memory:
359 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
360 ( tANI_U16 )nBytes, ( void** ) &pFrame,
361 ( void** ) &pPacket );
362 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
363 {
364 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700365 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 return eSIR_MEM_ALLOC_FAILED;
367 }
368
369 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530370 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700371
372 // Next, we fill out the buffer descriptor:
373 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530374 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 if ( eSIR_SUCCESS != nSirStatus )
376 {
377 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700378 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 nSirStatus );
380 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
381 ( void* ) pFrame, ( void* ) pPacket );
382 return nSirStatus; // allocated!
383 }
384
385 // That done, pack the Probe Request:
386 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
387 sizeof( tSirMacMgmtHdr ),
388 nPayload, &nPayload );
389 if ( DOT11F_FAILED( nStatus ) )
390 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700391 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 nStatus );
393 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
394 return eSIR_FAILURE; // allocated!
395 }
396 else if ( DOT11F_WARNED( nStatus ) )
397 {
398 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800399 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 }
401
402 // Append any AddIE if present.
403 if( nAdditionalIELen )
404 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530405 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 pAdditionalIE, nAdditionalIELen );
407 nPayload += nAdditionalIELen;
408 }
409
410 /* If this probe request is sent during P2P Search State, then we need
411 * to send it at OFDM rate.
412 */
413 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700414 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
415 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530416 /* For unicast probe req mgmt from Join function
417 we don't set above variables. So we need to add
418 one more check whether it is pePersona is P2P_CLIENT or not */
419 || ( ( psessionEntry != NULL ) &&
420 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 )
422 {
423 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
424 }
425
426
427 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
428 HAL_TXRX_FRM_802_11_MGMT,
429 ANI_TXDIR_TODS,
430 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
431 limTxComplete, pFrame, txFlag );
432 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
433 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700434 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 //Pkt will be freed up by the callback
436 return eSIR_FAILURE;
437 }
438
439 return eSIR_SUCCESS;
440} // End limSendProbeReqMgmtFrame.
441
Jeff Johnson295189b2012-06-20 16:38:30 -0700442tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
443 tANI_U8* addIE, tANI_U16 *addnIELen,
444 tANI_U8 probeReqP2pIe)
445{
446 /* If Probe request doesn't have P2P IE, then take out P2P IE
447 from additional IE */
448 if(!probeReqP2pIe)
449 {
450 tANI_U8* tempbuf = NULL;
451 tANI_U16 tempLen = 0;
452 int left = *addnIELen;
453 v_U8_t *ptr = addIE;
454 v_U8_t elem_id, elem_len;
455
456 if(NULL == addIE)
457 {
458 PELOGE(limLog(pMac, LOGE,
459 FL(" NULL addIE pointer"));)
460 return eSIR_FAILURE;
461 }
462
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530463 tempbuf = vos_mem_malloc(left);
464 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 {
466 PELOGE(limLog(pMac, LOGE,
467 FL("Unable to allocate memory to store addn IE"));)
468 return eSIR_MEM_ALLOC_FAILED;
469 }
470
471 while(left >= 2)
472 {
473 elem_id = ptr[0];
474 elem_len = ptr[1];
475 left -= 2;
476 if(elem_len > left)
477 {
478 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700479 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530481 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 return eSIR_FAILURE;
483 }
484 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
485 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
486 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530487 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 tempLen += (elem_len + 2);
489 }
490 left -= elem_len;
491 ptr += (elem_len + 2);
492 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530493 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530495 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 }
497 return eSIR_SUCCESS;
498}
Jeff Johnson295189b2012-06-20 16:38:30 -0700499
500void
501limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
502 tSirMacAddr peerMacAddr,
503 tpAniSSID pSsid,
504 short nStaId,
505 tANI_U8 nKeepAlive,
506 tpPESession psessionEntry,
507 tANI_U8 probeReqP2pIe)
508{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700509 tDot11fProbeResponse *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 tSirRetStatus nSirStatus;
511 tANI_U32 cfg, nPayload, nBytes, nStatus;
512 tpSirMacMgmtHdr pMacHdr;
513 tANI_U8 *pFrame;
514 void *pPacket;
515 eHalStatus halstatus;
516 tANI_U32 addnIEPresent;
517 tANI_U32 addnIE1Len=0;
518 tANI_U32 addnIE2Len=0;
519 tANI_U32 addnIE3Len=0;
520 tANI_U16 totalAddnIeLen = 0;
521 tANI_U32 wpsApEnable=0, tmp;
522 tANI_U8 txFlag = 0;
523 tANI_U8 *addIE = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 tANI_U8 *pP2pIe = NULL;
525 tANI_U8 noaLen = 0;
526 tANI_U8 total_noaLen = 0;
527 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
528 + SIR_P2P_IE_HEADER_LEN];
529 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700530
531 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
532 {
533 return; // in this case.
534 }
535
536 if(NULL == psessionEntry)
537 {
538 return;
539 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530540
541 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
542 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700543 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530544 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700545 return;
546 }
547
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 // Fill out 'frm', after which we'll just hand the struct off to
549 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530550 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700551
552 // Timestamp to be updated by TFP, below.
553
554 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
556 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700557 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 }
559 else
560 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800561 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
562 if (eSIR_SUCCESS != nSirStatus)
563 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700564 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800565 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530566 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800567 return;
568 }
569 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800570 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700571
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700572 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
573 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700575 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700576
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700577 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
578 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
Jeff Johnson295189b2012-06-20 16:38:30 -0700580
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
582 {
583 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
584 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700585 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 }
587 }
588 else
589 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800590 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700591 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700592
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800593 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700594
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800595 if (wpsApEnable)
596 {
597 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
598 }
599
600 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
601 {
602 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
603 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
604 }
605
606 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
607 {
608 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
609 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
610 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700612
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700613 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
614 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700615
Jeff Johnson295189b2012-06-20 16:38:30 -0700616
617 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700618 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700619
620
621 // N.B. In earlier implementations, the RSN IE would be placed in
622 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
623 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700624 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700625
626 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700627 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700629 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700630 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700632#ifdef WLAN_FEATURE_11AC
633 if(psessionEntry->vhtCapability)
634 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700635 limLog( pMac, LOGW, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700636 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
637 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700638 // we do not support multi users yet
639 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700640 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700641 }
642#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700643
644 if ( psessionEntry->pLimStartBssReq )
645 {
646 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700647 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700648 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
649 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 }
651
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700652 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700653
654#if defined(FEATURE_WLAN_WAPI)
655 if( psessionEntry->pLimStartBssReq )
656 {
657 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700658 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 }
660
661#endif // defined(FEATURE_WLAN_WAPI)
662
663
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700664 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 if ( DOT11F_FAILED( nStatus ) )
666 {
667 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700668 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 nStatus );
670 // We'll fall back on the worst case scenario:
671 nPayload = sizeof( tDot11fProbeResponse );
672 }
673 else if ( DOT11F_WARNED( nStatus ) )
674 {
675 limLog( pMac, LOGW, FL("There were warnings while calculating"
676 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700677 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 }
679
680 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
681
682 addnIEPresent = false;
683
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 if( pMac->lim.gpLimRemainOnChanReq )
685 {
686 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
687 }
688 //Only use CFG for non-listen mode. This CFG is not working for concurrency
689 //In listening mode, probe rsp IEs is passed in the message from SME to PE
690 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 {
692
693 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
694 &addnIEPresent) != eSIR_SUCCESS)
695 {
696 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530697 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 return;
699 }
700 }
701
702 if (addnIEPresent)
703 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530704
705 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
706 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 {
708 PELOGE(limLog(pMac, LOGE,
709 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530710 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 return;
712 }
713
714 //Probe rsp IE available
715 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
716 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
717 {
718 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530719 vos_mem_free(addIE);
720 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 return;
722 }
723 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
724 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
725 {
726 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
727 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
728 &addnIE1Len) )
729 {
730 limLog(pMac, LOGP,
731 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530732 vos_mem_free(addIE);
733 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 return;
735 }
736 }
737
738 //Probe rsp IE available
739 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
740 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
741 {
742 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530743 vos_mem_free(addIE);
744 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 return;
746 }
747 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
748 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
749 {
750 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
751 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
752 &addnIE2Len) )
753 {
754 limLog(pMac, LOGP,
755 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530756 vos_mem_free(addIE);
757 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 return;
759 }
760 }
761
762 //Probe rsp IE available
763 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
764 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
765 {
766 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530767 vos_mem_free(addIE);
768 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 return;
770 }
771 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
772 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
773 {
774 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
775 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
776 &addIE[addnIE1Len + addnIE2Len],
777 &addnIE3Len) )
778 {
779 limLog(pMac, LOGP,
780 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530781 vos_mem_free(addIE);
782 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 return;
784 }
785 }
786 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
787
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
789 {
790 limLog(pMac, LOGP,
791 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530792 vos_mem_free(addIE);
793 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 return;
795 }
796 nBytes = nBytes + totalAddnIeLen;
797
798 if (probeReqP2pIe)
799 {
800 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
801 if (pP2pIe != NULL)
802 {
803 //get NoA attribute stream P2P IE
804 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
805 if (noaLen != 0)
806 {
807 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
808 &noaStream[0], noaLen);
809 nBytes = nBytes + total_noaLen;
810 }
811 }
812 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 }
814
815 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
816 ( tANI_U16 )nBytes, ( void** ) &pFrame,
817 ( void** ) &pPacket );
818 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
819 {
820 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700821 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 if ( addIE != NULL )
823 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530824 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530826 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 return;
828 }
829
830 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530831 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700832
833 // Next, we fill out the buffer descriptor:
834 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
835 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
836 if ( eSIR_SUCCESS != nSirStatus )
837 {
838 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700839 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 nSirStatus );
841 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
842 ( void* ) pFrame, ( void* ) pPacket );
843 if ( addIE != NULL )
844 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530845 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530847 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 return;
849 }
850
851 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
852
853 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
854
855 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700856 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 nPayload, &nPayload );
858 if ( DOT11F_FAILED( nStatus ) )
859 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700860 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 nStatus );
862 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
863 if ( addIE != NULL )
864 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530865 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530867 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 return; // allocated!
869 }
870 else if ( DOT11F_WARNED( nStatus ) )
871 {
872 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800873 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 }
875
876 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
877 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
878
879 pMac->sys.probeRespond++;
880
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 if( pMac->lim.gpLimRemainOnChanReq )
882 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530883 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
885 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700886
887 if ( addnIEPresent )
888 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530889 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 if (noaLen != 0)
892 {
Krunal Soni81b24262013-05-15 17:46:41 -0700893 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 {
895 limLog(pMac, LOGE,
896 FL("Not able to insert NoA because of length constraint"));
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;
960 tANI_U8 txFlag = 0;
961
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;
1213 tUpdateBeaconParams beaconParams;
1214 tANI_U8 txFlag = 0;
1215 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 {
1222 return;
1223 }
1224
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301225 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001226
1227 limGetQosMode(psessionEntry, &qosMode);
1228 limGetWmeMode(psessionEntry, &wmeMode);
1229
1230 // An Add TS IE is added only if the AP supports it and the requesting
1231 // STA sent a traffic spec.
1232 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1233
1234 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1235
1236 frm.Status.status = statusCode;
1237
1238 frm.AID.associd = aid | LIM_AID_MASK;
1239
1240 if ( NULL == pSta )
1241 {
1242 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1243 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1244 }
1245 else
1246 {
1247 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1248 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1249 }
1250
Jeff Johnson295189b2012-06-20 16:38:30 -07001251 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1252 {
1253 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1254 {
1255 pAssocReq =
1256 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1258 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1259 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 }
1262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001263
1264 if ( NULL != pSta )
1265 {
1266 if ( eHAL_SET == qosMode )
1267 {
1268 if ( pSta->lleEnabled )
1269 {
1270 lleMode = 1;
1271 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1272 {
1273 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1274
1275// FramesToDo:...
1276// if ( fAddTS )
1277// {
1278// tANI_U8 *pAf = pBody;
1279// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1280// tANI_U32 tlen;
1281// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1282// &tlen, bufLen - frameLen);
1283// } // End if on Add TS.
1284 }
1285 } // End if on .11e enabled in 'pSta'.
1286 } // End if on QOS Mode on.
1287
1288 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1289 {
1290 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1291 {
1292
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001294
1295 if ( pSta->wsmEnabled )
1296 {
1297 PopulateDot11fWMMCaps(&frm.WMMCaps );
1298 }
1299 }
1300 }
1301
1302 if ( pSta->aniPeer )
1303 {
1304 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1305 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1306 {
1307 edcaInclude = 1;
1308 }
1309
1310 } // End if on Airgo peer.
1311
1312 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001313 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001315 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001318
1319#ifdef WLAN_FEATURE_11AC
1320 if( pSta->mlmStaContext.vhtCapability &&
1321 psessionEntry->vhtCapability )
1322 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001323 limLog( pMac, LOGW, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001324 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1325 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001326 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001327 }
1328#endif
1329
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 } // End if on non-NULL 'pSta'.
1331
1332
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301333 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001334
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1336 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1337 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001339
1340 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1341 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1342
1343 beaconParams.bssIdx = psessionEntry->bssIdx;
1344
1345 //Send message to HAL about beacon parameter change.
1346 if(beaconParams.paramChangeBitmap)
1347 {
1348 schSetFixedBeaconFields(pMac,psessionEntry);
1349 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1350 }
1351
1352 // Allocate a buffer for this frame:
1353 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1354 if ( DOT11F_FAILED( nStatus ) )
1355 {
1356 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001357 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 nStatus );
1359 return;
1360 }
1361 else if ( DOT11F_WARNED( nStatus ) )
1362 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001363 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001365 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 }
1367
1368 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1369
1370 if ( pAssocReq != NULL )
1371 {
1372 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1373 &addnIEPresent) != eSIR_SUCCESS)
1374 {
1375 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
1376 return;
1377 }
1378
1379 if (addnIEPresent)
1380 {
1381 //Assoc rsp IE available
1382 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1383 &addnIELen) != eSIR_SUCCESS)
1384 {
1385 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
1386 return;
1387 }
1388
1389 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1390 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1391 {
1392 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1393 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1394 {
1395 nBytes = nBytes + addnIELen;
1396 }
1397 }
1398 }
1399 }
1400
1401 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1402 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1403 ( void** ) &pPacket );
1404 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1405 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001406 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 return;
1408 }
1409
1410 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301411 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001412
1413 // Next, we fill out the buffer descriptor:
1414 nSirStatus = limPopulateMacHeader( pMac,
1415 pFrame,
1416 SIR_MAC_MGMT_FRAME,
1417 ( LIM_ASSOC == subType ) ?
1418 SIR_MAC_MGMT_ASSOC_RSP :
1419 SIR_MAC_MGMT_REASSOC_RSP,
1420 peerMacAddr,psessionEntry->selfMacAddr);
1421 if ( eSIR_SUCCESS != nSirStatus )
1422 {
1423 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001424 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 nSirStatus );
1426 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1427 ( void* ) pFrame, ( void* ) pPacket );
1428 return;
1429 }
1430
1431 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1432
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1434
1435 nStatus = dot11fPackAssocResponse( pMac, &frm,
1436 pFrame + sizeof( tSirMacMgmtHdr ),
1437 nPayload, &nPayload );
1438 if ( DOT11F_FAILED( nStatus ) )
1439 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001440 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 nStatus );
1442 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1443 ( void* ) pFrame, ( void* ) pPacket );
1444 return; // allocated!
1445 }
1446 else if ( DOT11F_WARNED( nStatus ) )
1447 {
1448 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001449 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 }
1451
1452 macAddr = pMacHdr->da;
1453
1454 if (subType == LIM_ASSOC)
1455 {
1456 PELOG1(limLog(pMac, LOG1,
1457 FL("*** Sending Assoc Resp status %d aid %d to "),
1458 statusCode, aid);)
1459 }
1460 else{
1461 PELOG1(limLog(pMac, LOG1,
1462 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1463 statusCode, aid);)
1464 }
1465 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1466
1467 if ( addnIEPresent )
1468 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301469 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 }
1471
1472 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1474 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 )
1476 {
1477 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1478 }
1479
1480 /// Queue Association Response frame in high priority WQ
1481 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1482 HAL_TXRX_FRM_802_11_MGMT,
1483 ANI_TXDIR_TODS,
1484 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1485 limTxComplete, pFrame, txFlag );
1486 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1487 {
1488 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001489 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 nSirStatus);
1491
1492 //Pkt will be freed up by the callback
1493 }
1494
1495 // update the ANI peer station count
1496 //FIXME_PROTECTION : take care of different type of station
1497 // counter inside this function.
1498 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1499
1500} // End limSendAssocRspMgmtFrame.
1501
1502
1503
1504void
1505limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1506 tSirMacAddr peer,
1507 tANI_U16 nStatusCode,
1508 tSirAddtsReqInfo *pAddTS,
1509 tSirMacScheduleIE *pSchedule,
1510 tpPESession psessionEntry)
1511{
1512 tANI_U8 *pFrame;
1513 tpSirMacMgmtHdr pMacHdr;
1514 tDot11fAddTSResponse AddTSRsp;
1515 tDot11fWMMAddTSResponse WMMAddTSRsp;
1516 tSirRetStatus nSirStatus;
1517 tANI_U32 i, nBytes, nPayload, nStatus;
1518 void *pPacket;
1519 eHalStatus halstatus;
1520 tANI_U8 txFlag = 0;
1521
1522 if(NULL == psessionEntry)
1523 {
1524 return;
1525 }
1526
1527 if ( ! pAddTS->wmeTspecPresent )
1528 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301529 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001530
1531 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1532 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1533 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1534 AddTSRsp.Status.status = nStatusCode;
1535
1536 // The TsDelay information element is only filled in for a specific
1537 // status code:
1538 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1539 {
1540 if ( pAddTS->wsmTspecPresent )
1541 {
1542 AddTSRsp.WMMTSDelay.version = 1;
1543 AddTSRsp.WMMTSDelay.delay = 10;
1544 AddTSRsp.WMMTSDelay.present = 1;
1545 }
1546 else
1547 {
1548 AddTSRsp.TSDelay.delay = 10;
1549 AddTSRsp.TSDelay.present = 1;
1550 }
1551 }
1552
1553 if ( pAddTS->wsmTspecPresent )
1554 {
1555 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1556 }
1557 else
1558 {
1559 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1560 }
1561
1562 if ( pAddTS->wsmTspecPresent )
1563 {
1564 AddTSRsp.num_WMMTCLAS = 0;
1565 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1566 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1567 {
1568 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1569 &AddTSRsp.TCLAS[i] );
1570 }
1571 }
1572 else
1573 {
1574 AddTSRsp.num_TCLAS = 0;
1575 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1576 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1577 {
1578 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1579 &AddTSRsp.WMMTCLAS[i] );
1580 }
1581 }
1582
1583 if ( pAddTS->tclasProcPresent )
1584 {
1585 if ( pAddTS->wsmTspecPresent )
1586 {
1587 AddTSRsp.WMMTCLASPROC.version = 1;
1588 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1589 AddTSRsp.WMMTCLASPROC.present = 1;
1590 }
1591 else
1592 {
1593 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1594 AddTSRsp.TCLASSPROC.present = 1;
1595 }
1596 }
1597
1598 // schedule element is included only if requested in the tspec and we are
1599 // using hcca (or both edca and hcca)
1600 // 11e-D8.0 is inconsistent on whether the schedule element is included
1601 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1602 // pg 46, line 17-18 says something else. So just include it and let the
1603 // sta figure it out
1604 if ((pSchedule != NULL) &&
1605 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1606 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1607 {
1608 if ( pAddTS->wsmTspecPresent )
1609 {
1610 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1611 }
1612 else
1613 {
1614 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1615 }
1616 }
1617
1618 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1619 if ( DOT11F_FAILED( nStatus ) )
1620 {
1621 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001622 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 nStatus );
1624 // We'll fall back on the worst case scenario:
1625 nPayload = sizeof( tDot11fAddTSResponse );
1626 }
1627 else if ( DOT11F_WARNED( nStatus ) )
1628 {
1629 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001630 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001631 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 }
1633 }
1634 else
1635 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301636 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001637
1638 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1639 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1640 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1641 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1642
1643 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1644
1645 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1646 if ( DOT11F_FAILED( nStatus ) )
1647 {
1648 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001649 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 nStatus );
1651 // We'll fall back on the worst case scenario:
1652 nPayload = sizeof( tDot11fWMMAddTSResponse );
1653 }
1654 else if ( DOT11F_WARNED( nStatus ) )
1655 {
1656 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001657 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001658 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 }
1660 }
1661
1662 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1663
1664 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1665 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1666 {
1667 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001668 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 return;
1670 }
1671
1672 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301673 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001674
1675 // Next, we fill out the buffer descriptor:
1676 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1677 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1678 if ( eSIR_SUCCESS != nSirStatus )
1679 {
1680 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001681 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 nSirStatus );
1683 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1684 return; // allocated!
1685 }
1686
1687 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1688
1689
1690 #if 0
1691 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1692 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1693 {
1694 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001695 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1697 return; // allocated!
1698 }
1699 #endif //TO SUPPORT BT-AMP
1700 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1701
Chet Lanctot186b5732013-03-18 10:26:30 -07001702#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001703 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001704#endif
1705
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 // That done, pack the struct:
1707 if ( ! pAddTS->wmeTspecPresent )
1708 {
1709 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1710 pFrame + sizeof( tSirMacMgmtHdr ),
1711 nPayload, &nPayload );
1712 if ( DOT11F_FAILED( nStatus ) )
1713 {
1714 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001715 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 nStatus );
1717 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1718 return;
1719 }
1720 else if ( DOT11F_WARNED( nStatus ) )
1721 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001722 limLog( pMac, LOGW, FL("There were warnings while packing "
1723 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 }
1725 }
1726 else
1727 {
1728 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1729 pFrame + sizeof( tSirMacMgmtHdr ),
1730 nPayload, &nPayload );
1731 if ( DOT11F_FAILED( nStatus ) )
1732 {
1733 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001734 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 nStatus );
1736 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1737 return;
1738 }
1739 else if ( DOT11F_WARNED( nStatus ) )
1740 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001741 limLog( pMac, LOGW, FL("There were warnings while packing "
1742 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 }
1744 }
1745
1746 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1747 nStatusCode );
1748 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1749
1750 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1752 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 )
1754 {
1755 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1756 }
1757
1758 // Queue the frame in high priority WQ:
1759 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1760 HAL_TXRX_FRM_802_11_MGMT,
1761 ANI_TXDIR_TODS,
1762 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1763 limTxComplete, pFrame, txFlag );
1764 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1765 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001766 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 nSirStatus );
1768 //Pkt will be freed up by the callback
1769 }
1770
1771} // End limSendAddtsRspActionFrame.
1772
1773void
1774limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1775 tSirMacAddr peer,
1776 tANI_U8 wmmTspecPresent,
1777 tSirMacTSInfo *pTsinfo,
1778 tSirMacTspecIE *pTspecIe,
1779 tpPESession psessionEntry)
1780{
1781 tANI_U8 *pFrame;
1782 tpSirMacMgmtHdr pMacHdr;
1783 tDot11fDelTS DelTS;
1784 tDot11fWMMDelTS WMMDelTS;
1785 tSirRetStatus nSirStatus;
1786 tANI_U32 nBytes, nPayload, nStatus;
1787 void *pPacket;
1788 eHalStatus halstatus;
1789 tANI_U8 txFlag = 0;
1790
1791 if(NULL == psessionEntry)
1792 {
1793 return;
1794 }
1795
1796 if ( ! wmmTspecPresent )
1797 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301798 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001799
1800 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1801 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1802 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1803
1804 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1805 if ( DOT11F_FAILED( nStatus ) )
1806 {
1807 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001808 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 nStatus );
1810 // We'll fall back on the worst case scenario:
1811 nPayload = sizeof( tDot11fDelTS );
1812 }
1813 else if ( DOT11F_WARNED( nStatus ) )
1814 {
1815 limLog( pMac, LOGW, FL("There were warnings while calcula"
1816 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001817 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 }
1819 }
1820 else
1821 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301822 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001823
1824 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1825 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1826 WMMDelTS.DialogToken.token = 0;
1827 WMMDelTS.StatusCode.statusCode = 0;
1828 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1829 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1830 if ( DOT11F_FAILED( nStatus ) )
1831 {
1832 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001833 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 nStatus );
1835 // We'll fall back on the worst case scenario:
1836 nPayload = sizeof( tDot11fDelTS );
1837 }
1838 else if ( DOT11F_WARNED( nStatus ) )
1839 {
1840 limLog( pMac, LOGW, FL("There were warnings while calcula"
1841 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001842 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 }
1844 }
1845
1846 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1847
1848 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1849 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1850 {
1851 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001852 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 return;
1854 }
1855
1856 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301857 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001858
1859 // Next, we fill out the buffer descriptor:
1860 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1861 SIR_MAC_MGMT_ACTION, peer,
1862 psessionEntry->selfMacAddr);
1863 if ( eSIR_SUCCESS != nSirStatus )
1864 {
1865 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001866 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 nSirStatus );
1868 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1869 return; // allocated!
1870 }
1871
1872 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1873
1874 #if 0
1875
1876 cfgLen = SIR_MAC_ADDR_LENGTH;
1877 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1878 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1879 {
1880 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001881 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1883 return; // allocated!
1884 }
1885 #endif //TO SUPPORT BT-AMP
1886 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1887
Chet Lanctot186b5732013-03-18 10:26:30 -07001888#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001889 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001890#endif
1891
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 // That done, pack the struct:
1893 if ( !wmmTspecPresent )
1894 {
1895 nStatus = dot11fPackDelTS( pMac, &DelTS,
1896 pFrame + sizeof( tSirMacMgmtHdr ),
1897 nPayload, &nPayload );
1898 if ( DOT11F_FAILED( nStatus ) )
1899 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001900 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 nStatus );
1902 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1903 return; // allocated!
1904 }
1905 else if ( DOT11F_WARNED( nStatus ) )
1906 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001907 limLog( pMac, LOGW, FL("There were warnings while packing "
1908 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 }
1910 }
1911 else
1912 {
1913 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1914 pFrame + sizeof( tSirMacMgmtHdr ),
1915 nPayload, &nPayload );
1916 if ( DOT11F_FAILED( nStatus ) )
1917 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001918 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 nStatus );
1920 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1921 return; // allocated!
1922 }
1923 else if ( DOT11F_WARNED( nStatus ) )
1924 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001925 limLog( pMac, LOGW, FL("There were warnings while packing "
1926 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 }
1928 }
1929
1930 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1931 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1932
1933 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1935 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001936 )
1937 {
1938 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1939 }
1940
1941 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1942 HAL_TXRX_FRM_802_11_MGMT,
1943 ANI_TXDIR_TODS,
1944 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1945 limTxComplete, pFrame, txFlag );
1946 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1947 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001948 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 nSirStatus );
1950 //Pkt will be freed up by the callback
1951 }
1952
1953} // End limSendDeltsReqActionFrame.
1954
1955void
1956limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1957 tLimMlmAssocReq *pMlmAssocReq,
1958 tpPESession psessionEntry)
1959{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001960 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 tANI_U16 caps;
1962 tANI_U8 *pFrame;
1963 tSirRetStatus nSirStatus;
1964 tLimMlmAssocCnf mlmAssocCnf;
1965 tANI_U32 nBytes, nPayload, nStatus;
1966 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1967 void *pPacket;
1968 eHalStatus halstatus;
1969 tANI_U16 nAddIELen;
1970 tANI_U8 *pAddIE;
1971 tANI_U8 *wpsIe = NULL;
1972#if defined WLAN_FEATURE_VOWIFI
1973 tANI_U8 PowerCapsPopulated = FALSE;
1974#endif
1975 tANI_U8 txFlag = 0;
1976
1977 if(NULL == psessionEntry)
1978 {
1979 return;
1980 }
1981
1982 if(NULL == psessionEntry->pLimJoinReq)
1983 {
1984 return;
1985 }
1986
1987 /* check this early to avoid unncessary operation */
1988 if(NULL == psessionEntry->pLimJoinReq)
1989 {
1990 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 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301998 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendAssocReqMgmtFrame") );
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 {
2143 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002144 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 }
2146#endif
2147
2148 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002149#ifdef WLAN_FEATURE_11AC
2150 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002151 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002152 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002153 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002154 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2155 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002156 }
2157#endif
2158
Jeff Johnson295189b2012-06-20 16:38:30 -07002159
2160#if defined WLAN_FEATURE_VOWIFI_11R
2161 if (psessionEntry->pLimJoinReq->is11Rconnection)
2162 {
2163#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002164 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2166 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2167 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2168#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302169 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2170 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302172 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 {
2174 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302175 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 }
2177#endif
2178
2179#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302180 /* CCX Version IE will be included in association request
2181 when CCX is enabled on DUT through ini */
2182 if (psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
2183 {
2184 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
2185 }
2186 /* For CCX Associations fill the CCX IEs */
2187 if (psessionEntry->isCCXconnection &&
2188 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002190#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002191 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002192#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 }
2194#endif
2195
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002196 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 if ( DOT11F_FAILED( nStatus ) )
2198 {
2199 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002200 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 nStatus );
2202 // We'll fall back on the worst case scenario:
2203 nPayload = sizeof( tDot11fAssocRequest );
2204 }
2205 else if ( DOT11F_WARNED( nStatus ) )
2206 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002207 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002209 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 }
2211
2212 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2213
2214 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2215 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2216 ( void** ) &pPacket );
2217 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2218 {
2219 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002220 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002221
2222 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002223 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002224
2225
2226 /* Update PE session id*/
2227 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2228
2229 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2230
2231 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2232 ( void* ) pFrame, ( void* ) pPacket );
2233
2234 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2235 ( tANI_U32* ) &mlmAssocCnf);
2236
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302237 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 return;
2239 }
2240
2241 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302242 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002243
2244 // Next, we fill out the buffer descriptor:
2245 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2246 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2247 if ( eSIR_SUCCESS != nSirStatus )
2248 {
2249 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002250 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 nSirStatus );
2252 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302253 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 return;
2255 }
2256
2257
2258 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002259 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 sizeof(tSirMacMgmtHdr),
2261 nPayload, &nPayload );
2262 if ( DOT11F_FAILED( nStatus ) )
2263 {
2264 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002265 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 nStatus );
2267 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2268 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302269 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 return;
2271 }
2272 else if ( DOT11F_WARNED( nStatus ) )
2273 {
2274 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002275 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 }
2277
2278 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002279 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 nBytes );)
2281 // limPrintMacAddr( pMac, bssid, LOG1 );
2282
2283 if( psessionEntry->assocReq != NULL )
2284 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302285 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 psessionEntry->assocReq = NULL;
2287 }
2288
2289 if( nAddIELen )
2290 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302291 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2292 pAddIE,
2293 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 nPayload += nAddIELen;
2295 }
2296
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302297 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2298 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 {
2300 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2301 }
2302 else
2303 {
2304 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302305 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 psessionEntry->assocReqLen = nPayload;
2307 }
2308
2309 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2311 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 )
2313 {
2314 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2315 }
2316
Ganesh K08bce952012-12-13 15:04:41 -08002317 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2318 {
2319 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2320 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002321
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2323 HAL_TXRX_FRM_802_11_MGMT,
2324 ANI_TXDIR_TODS,
2325 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2326 limTxComplete, pFrame, txFlag );
2327 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2328 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002329 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 halstatus );
2331 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302332 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002333 return;
2334 }
2335
2336 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302337 vos_mem_free(pMlmAssocReq);
2338 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002339 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002340} // End limSendAssocReqMgmtFrame
2341
2342
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002343#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002344/*------------------------------------------------------------------------------------
2345 *
2346 * Send Reassoc Req with FTIEs.
2347 *
2348 *-----------------------------------------------------------------------------------
2349 */
2350void
2351limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2352 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2353{
2354 static tDot11fReAssocRequest frm;
2355 tANI_U16 caps;
2356 tANI_U8 *pFrame;
2357 tSirRetStatus nSirStatus;
2358 tANI_U32 nBytes, nPayload, nStatus;
2359 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2360 void *pPacket;
2361 eHalStatus halstatus;
2362#if defined WLAN_FEATURE_VOWIFI
2363 tANI_U8 PowerCapsPopulated = FALSE;
2364#endif
2365 tANI_U16 ft_ies_length = 0;
2366 tANI_U8 *pBody;
2367 tANI_U16 nAddIELen;
2368 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002369#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002370 tANI_U8 *wpsIe = NULL;
2371#endif
2372 tANI_U8 txFlag = 0;
2373
2374 if (NULL == psessionEntry)
2375 {
2376 return;
2377 }
2378
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 /* check this early to avoid unncessary operation */
2380 if(NULL == psessionEntry->pLimReAssocReq)
2381 {
2382 return;
2383 }
2384 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2385 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002386 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2387 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002388
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302389 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002390
2391 caps = pMlmReassocReq->capabilityInfo;
2392 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2393 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2394#if defined(FEATURE_WLAN_WAPI)
2395 /* CR: 262463 :
2396 According to WAPI standard:
2397 7.3.1.4 Capability Information field
2398 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2399 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2400 Reassociation management frames. */
2401 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2402 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2403#endif
2404 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2405
2406 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2407
2408 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302409 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2411
2412 PopulateDot11fSSID2( pMac, &frm.SSID );
2413 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2414 &frm.SuppRates,psessionEntry);
2415
2416 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2417 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2418
2419 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2420 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2421
2422 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2423 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2424
2425 if ( psessionEntry->lim11hEnable &&
2426 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2427 {
2428#if defined WLAN_FEATURE_VOWIFI
2429 PowerCapsPopulated = TRUE;
2430
2431 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2432 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2433#endif
2434 }
2435
2436#if defined WLAN_FEATURE_VOWIFI
2437 if( pMac->rrm.rrmPEContext.rrmEnable &&
2438 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2439 {
2440 if (PowerCapsPopulated == FALSE)
2441 {
2442 PowerCapsPopulated = TRUE;
2443 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2444 }
2445 }
2446#endif
2447
2448 if ( fQosEnabled &&
2449 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2450 {
2451 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2452 }
2453
2454 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2455 &frm.ExtSuppRates, psessionEntry );
2456
2457#if defined WLAN_FEATURE_VOWIFI
2458 if( pMac->rrm.rrmPEContext.rrmEnable &&
2459 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2460 {
2461 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2462 }
2463#endif
2464
2465 // Ideally this should be enabled for 11r also. But 11r does
2466 // not follow the usual norm of using the Opaque object
2467 // for rsnie and fties. Instead we just add
2468 // the rsnie and fties at the end of the pack routine for 11r.
2469 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002470#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002471 //
2472 // The join request *should* contain zero or one of the WPA and RSN
2473 // IEs. The payload send along with the request is a
2474 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2475
2476 // typedef struct sSirRSNie
2477 // {
2478 // tANI_U16 length;
2479 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2480 // } tSirRSNie, *tpSirRSNie;
2481
2482 // So, we should be able to make the following two calls harmlessly,
2483 // since they do nothing if they don't find the given IE in the
2484 // bytestream with which they're provided.
2485
2486 // The net effect of this will be to faithfully transmit whatever
2487 // security IE is in the join request.
2488
2489 // *However*, if we're associating for the purpose of WPS
2490 // enrollment, and we've been configured to indicate that by
2491 // eliding the WPA or RSN IE, we just skip this:
2492 if (!psessionEntry->is11Rconnection)
2493 {
2494 if( nAddIELen && pAddIE )
2495 {
2496 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2497 }
2498 if ( NULL == wpsIe )
2499 {
2500 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2501 &frm.RSNOpaque );
2502 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2503 &frm.WPAOpaque );
2504 }
2505
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002506#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302507 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 {
2509 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2510 &frm.CCXCckmOpaque );
2511 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002512#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 }
2514
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002515#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302516 /* CCX Version IE will be included in reassociation request
2517 when CCX is enabled on DUT through ini */
2518 if (psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
2519 {
2520 PopulateDot11fCCXVersion(&frm.CCXVersion);
2521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302523 if (psessionEntry->isCCXconnection &&
2524 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002526#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002527 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002528#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302530#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002531#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002532
2533 // include WME EDCA IE as well
2534 if ( fWmeEnabled )
2535 {
2536 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2537 {
2538 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2539 }
2540
2541 if ( fWsmEnabled &&
2542 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2543 {
2544 PopulateDot11fWMMCaps( &frm.WMMCaps );
2545 }
2546#ifdef FEATURE_WLAN_CCX
2547 if (psessionEntry->isCCXconnection)
2548 {
2549 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2550
2551 // Populate the TSRS IE if TSPEC is included in the reassoc request
2552 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2553 {
2554 tANI_U32 phyMode;
2555 tSirMacCCXTSRSIE tsrsIE;
2556 limGetPhyMode(pMac, &phyMode, psessionEntry);
2557
2558 tsrsIE.tsid = 0;
2559 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2560 {
2561 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2562 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302563 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 {
2565 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2566 }
2567 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2568 }
2569 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302570#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 }
2572
Jeff Johnsone7245742012-09-05 17:12:55 -07002573 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 pMac->lim.htCapabilityPresentInBeacon)
2575 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002576 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 }
2578
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002579#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302580 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2581#if defined FEATURE_WLAN_CCX
2582 && !psessionEntry->isCCXconnection
2583#endif
2584 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002585 {
2586 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2587 }
2588#endif
2589
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2591 if ( DOT11F_FAILED( nStatus ) )
2592 {
2593 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002594 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 nStatus );
2596 // We'll fall back on the worst case scenario:
2597 nPayload = sizeof( tDot11fReAssocRequest );
2598 }
2599 else if ( DOT11F_WARNED( nStatus ) )
2600 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002601 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002603 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 }
2605
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002606 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002607
2608#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002609 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2611#endif
2612
2613#if defined WLAN_FEATURE_VOWIFI_11R
2614 if (psessionEntry->is11Rconnection)
2615 {
2616 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2617 }
2618#endif
2619
2620 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2621 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2622 ( void** ) &pPacket );
2623 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2624 {
2625 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002626 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002628 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 goto end;
2630 }
2631
2632 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302633 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002634
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002635#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002636 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002637#endif
2638 // Next, we fill out the buffer descriptor:
2639 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2640 SIR_MAC_MGMT_REASSOC_REQ,
2641 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2642 if ( eSIR_SUCCESS != nSirStatus )
2643 {
2644 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002645 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002646 nSirStatus );
2647 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2648 goto end;
2649 }
2650
2651
2652 // That done, pack the ReAssoc Request:
2653 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2654 sizeof(tSirMacMgmtHdr),
2655 nPayload, &nPayload );
2656 if ( DOT11F_FAILED( nStatus ) )
2657 {
2658 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002659 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 nStatus );
2661 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2662 goto end;
2663 }
2664 else if ( DOT11F_WARNED( nStatus ) )
2665 {
2666 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002667 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 }
2669
2670 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002671 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 nBytes, nPayload );)
2673 if( psessionEntry->assocReq != NULL )
2674 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302675 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 psessionEntry->assocReq = NULL;
2677 }
2678
2679 if( nAddIELen )
2680 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302681 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2682 pAddIE,
2683 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 nPayload += nAddIELen;
2685 }
2686
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302687 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2688 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 {
2690 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002691 }
2692 else
2693 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002694 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302695 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002698
2699 if (psessionEntry->is11Rconnection)
2700 {
2701 {
2702 int i = 0;
2703
2704 pBody = pFrame + nBytes;
2705 for (i=0; i<ft_ies_length; i++)
2706 {
2707 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2708 pBody++;
2709 }
2710 }
2711 }
2712
2713#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002714 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2715 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 (tANI_U8 *)pFrame,
2717 (nBytes + ft_ies_length));)
2718#endif
2719
2720
2721 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2723 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002724 )
2725 {
2726 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2727 }
2728
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002729 if( NULL != psessionEntry->assocReq )
2730 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302731 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002732 psessionEntry->assocReq = NULL;
2733 }
2734
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302735 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2736 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002737 {
2738 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002739 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002740 }
2741 else
2742 {
2743 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302744 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2745 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002746 psessionEntry->assocReqLen = (ft_ies_length);
2747 }
2748
2749
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2751 HAL_TXRX_FRM_802_11_MGMT,
2752 ANI_TXDIR_TODS,
2753 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2754 limTxComplete, pFrame, txFlag );
2755 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2756 {
2757 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002758 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 nSirStatus );
2760 //Pkt will be freed up by the callback
2761 goto end;
2762 }
2763
2764end:
2765 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302766 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 psessionEntry->pLimMlmReassocReq = NULL;
2768
2769}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002770
2771void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2772 tLimMlmReassocReq *pMlmReassocReq,
2773 tpPESession psessionEntry)
2774{
2775 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2776 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2777 if(NULL == pTmpMlmReassocReq)
2778 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302779 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2780 if ( NULL == pTmpMlmReassocReq ) goto end;
2781 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2782 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002783 }
2784
2785 // Prepare and send Reassociation request frame
2786 // start reassoc timer.
2787 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2788 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002789 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002790 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2791 != TX_SUCCESS)
2792 {
2793 // Could not start reassoc failure timer.
2794 // Log error
2795 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002796 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002797 // Return Reassoc confirm with
2798 // Resources Unavailable
2799 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2800 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2801 goto end;
2802 }
2803
2804 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2805 return;
2806
2807end:
2808 // Free up buffer allocated for reassocReq
2809 if (pMlmReassocReq != NULL)
2810 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302811 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002812 pMlmReassocReq = NULL;
2813 }
2814 if (pTmpMlmReassocReq != NULL)
2815 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302816 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002817 pTmpMlmReassocReq = NULL;
2818 }
2819 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2820 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2821 /* Update PE sessio Id*/
2822 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2823
2824 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2825}
2826
Jeff Johnson295189b2012-06-20 16:38:30 -07002827#endif /* WLAN_FEATURE_VOWIFI_11R */
2828
2829
2830void
2831limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2832 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2833{
2834 static tDot11fReAssocRequest frm;
2835 tANI_U16 caps;
2836 tANI_U8 *pFrame;
2837 tSirRetStatus nSirStatus;
2838 tANI_U32 nBytes, nPayload, nStatus;
2839 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2840 void *pPacket;
2841 eHalStatus halstatus;
2842 tANI_U16 nAddIELen;
2843 tANI_U8 *pAddIE;
2844 tANI_U8 *wpsIe = NULL;
2845 tANI_U8 txFlag = 0;
2846#if defined WLAN_FEATURE_VOWIFI
2847 tANI_U8 PowerCapsPopulated = FALSE;
2848#endif
2849
2850 if(NULL == psessionEntry)
2851 {
2852 return;
2853 }
2854
2855 /* check this early to avoid unncessary operation */
2856 if(NULL == psessionEntry->pLimReAssocReq)
2857 {
2858 return;
2859 }
2860 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2861 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2862
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302863 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002864
2865 caps = pMlmReassocReq->capabilityInfo;
2866 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2867 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2868#if defined(FEATURE_WLAN_WAPI)
2869 /* CR: 262463 :
2870 According to WAPI standard:
2871 7.3.1.4 Capability Information field
2872 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2873 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2874 Reassociation management frames. */
2875 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2876 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2877#endif
2878 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2879
2880 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2881
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302882 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2883 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002884
2885 PopulateDot11fSSID2( pMac, &frm.SSID );
2886 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2887 &frm.SuppRates,psessionEntry);
2888
2889 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2890 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2891
2892 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2893 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2894
2895 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2896 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2897
2898
2899 if ( psessionEntry->lim11hEnable &&
2900 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2901 {
2902#if defined WLAN_FEATURE_VOWIFI
2903 PowerCapsPopulated = TRUE;
2904 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2905 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2906#endif
2907 }
2908
2909#if defined WLAN_FEATURE_VOWIFI
2910 if( pMac->rrm.rrmPEContext.rrmEnable &&
2911 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2912 {
2913 if (PowerCapsPopulated == FALSE)
2914 {
2915 PowerCapsPopulated = TRUE;
2916 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2917 }
2918 }
2919#endif
2920
2921 if ( fQosEnabled &&
2922 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2923 {
2924 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2925 }
2926
2927 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2928 &frm.ExtSuppRates, psessionEntry );
2929
2930#if defined WLAN_FEATURE_VOWIFI
2931 if( pMac->rrm.rrmPEContext.rrmEnable &&
2932 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2933 {
2934 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2935 }
2936#endif
2937 // The join request *should* contain zero or one of the WPA and RSN
2938 // IEs. The payload send along with the request is a
2939 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2940
2941 // typedef struct sSirRSNie
2942 // {
2943 // tANI_U16 length;
2944 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2945 // } tSirRSNie, *tpSirRSNie;
2946
2947 // So, we should be able to make the following two calls harmlessly,
2948 // since they do nothing if they don't find the given IE in the
2949 // bytestream with which they're provided.
2950
2951 // The net effect of this will be to faithfully transmit whatever
2952 // security IE is in the join request.
2953
2954 // *However*, if we're associating for the purpose of WPS
2955 // enrollment, and we've been configured to indicate that by
2956 // eliding the WPA or RSN IE, we just skip this:
2957 if( nAddIELen && pAddIE )
2958 {
2959 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2960 }
2961 if ( NULL == wpsIe )
2962 {
2963 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2964 &frm.RSNOpaque );
2965 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2966 &frm.WPAOpaque );
2967#if defined(FEATURE_WLAN_WAPI)
2968 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2969 &frm.WAPIOpaque );
2970#endif // defined(FEATURE_WLAN_WAPI)
2971 }
2972
2973 // include WME EDCA IE as well
2974 if ( fWmeEnabled )
2975 {
2976 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2977 {
2978 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2979 }
2980
2981 if ( fWsmEnabled &&
2982 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2983 {
2984 PopulateDot11fWMMCaps( &frm.WMMCaps );
2985 }
2986 }
2987
Jeff Johnsone7245742012-09-05 17:12:55 -07002988 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 pMac->lim.htCapabilityPresentInBeacon)
2990 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002991 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002993#ifdef WLAN_FEATURE_11AC
2994 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002995 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002996 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002997 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002998 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07002999 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003000 }
3001#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003002
3003 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3004 if ( DOT11F_FAILED( nStatus ) )
3005 {
3006 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003007 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 nStatus );
3009 // We'll fall back on the worst case scenario:
3010 nPayload = sizeof( tDot11fReAssocRequest );
3011 }
3012 else if ( DOT11F_WARNED( nStatus ) )
3013 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003014 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003016 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003017 }
3018
3019 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3020
3021 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3022 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3023 ( void** ) &pPacket );
3024 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3025 {
3026 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003027 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003029 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 goto end;
3031 }
3032
3033 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303034 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003035
3036 // Next, we fill out the buffer descriptor:
3037 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3038 SIR_MAC_MGMT_REASSOC_REQ,
3039 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3040 if ( eSIR_SUCCESS != nSirStatus )
3041 {
3042 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003043 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 nSirStatus );
3045 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3046 goto end;
3047 }
3048
3049
3050 // That done, pack the Probe Request:
3051 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3052 sizeof(tSirMacMgmtHdr),
3053 nPayload, &nPayload );
3054 if ( DOT11F_FAILED( nStatus ) )
3055 {
3056 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003057 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 nStatus );
3059 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3060 goto end;
3061 }
3062 else if ( DOT11F_WARNED( nStatus ) )
3063 {
3064 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003065 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 }
3067
3068 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003069 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 nBytes );)
3071
3072 if( psessionEntry->assocReq != NULL )
3073 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303074 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 psessionEntry->assocReq = NULL;
3076 }
3077
3078 if( nAddIELen )
3079 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303080 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3081 pAddIE,
3082 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 nPayload += nAddIELen;
3084 }
3085
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303086 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3087 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 {
3089 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003090 }
3091 else
3092 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303094 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003097
3098 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3100 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 )
3102 {
3103 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3104 }
3105
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003106 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003107 {
3108 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3109 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003110
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3112 HAL_TXRX_FRM_802_11_MGMT,
3113 ANI_TXDIR_TODS,
3114 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3115 limTxComplete, pFrame, txFlag );
3116 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3117 {
3118 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003119 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 nSirStatus );
3121 //Pkt will be freed up by the callback
3122 goto end;
3123 }
3124
3125end:
3126 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303127 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 psessionEntry->pLimMlmReassocReq = NULL;
3129
3130} // limSendReassocReqMgmtFrame
3131
3132/**
3133 * \brief Send an Authentication frame
3134 *
3135 *
3136 * \param pMac Pointer to Global MAC structure
3137 *
3138 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3139 * to be sent
3140 *
3141 * \param peerMacAddr MAC address of the peer entity to which Authentication
3142 * frame is destined
3143 *
3144 * \param wepBit Indicates whether wep bit to be set in FC while sending
3145 * Authentication frame3
3146 *
3147 *
3148 * This function is called by limProcessMlmMessages(). Authentication frame
3149 * is formatted and sent when this function is called.
3150 *
3151 *
3152 */
3153
3154void
3155limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3156 tpSirMacAuthFrameBody pAuthFrameBody,
3157 tSirMacAddr peerMacAddr,
3158 tANI_U8 wepBit,
3159 tpPESession psessionEntry
3160 )
3161{
3162 tANI_U8 *pFrame, *pBody;
3163 tANI_U32 frameLen = 0, bodyLen = 0;
3164 tpSirMacMgmtHdr pMacHdr;
3165 tANI_U16 i;
3166 void *pPacket;
3167 eHalStatus halstatus;
3168 tANI_U8 txFlag = 0;
3169
3170 if(NULL == psessionEntry)
3171 {
3172 return;
3173 }
3174
3175 if (wepBit == LIM_WEP_IN_FC)
3176 {
3177 /// Auth frame3 to be sent with encrypted framebody
3178 /**
3179 * Allocate buffer for Authenticaton frame of size equal
3180 * to management frame header length plus 2 bytes each for
3181 * auth algorithm number, transaction number, status code,
3182 * 128 bytes for challenge text and 4 bytes each for
3183 * IV & ICV.
3184 */
3185
3186 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3187
3188 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3189 } // if (wepBit == LIM_WEP_IN_FC)
3190 else
3191 {
3192 switch (pAuthFrameBody->authTransactionSeqNumber)
3193 {
3194 case SIR_MAC_AUTH_FRAME_1:
3195 /**
3196 * Allocate buffer for Authenticaton frame of size
3197 * equal to management frame header length plus 2 bytes
3198 * each for auth algorithm number, transaction number
3199 * and status code.
3200 */
3201
3202 frameLen = sizeof(tSirMacMgmtHdr) +
3203 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3204 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3205
3206#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003207 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3208 {
3209 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003211 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003212 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003213 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003215 else
3216 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003217 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003218 frameLen += (2+SIR_MDIE_SIZE);
3219 }
3220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003221#endif
3222 break;
3223
3224 case SIR_MAC_AUTH_FRAME_2:
3225 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3226 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3227 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3228 {
3229 /**
3230 * Allocate buffer for Authenticaton frame of size
3231 * equal to management frame header length plus
3232 * 2 bytes each for auth algorithm number,
3233 * transaction number and status code.
3234 */
3235
3236 frameLen = sizeof(tSirMacMgmtHdr) +
3237 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3238 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3239 }
3240 else
3241 {
3242 // Shared Key algorithm with challenge text
3243 // to be sent
3244 /**
3245 * Allocate buffer for Authenticaton frame of size
3246 * equal to management frame header length plus
3247 * 2 bytes each for auth algorithm number,
3248 * transaction number, status code and 128 bytes
3249 * for challenge text.
3250 */
3251
3252 frameLen = sizeof(tSirMacMgmtHdr) +
3253 sizeof(tSirMacAuthFrame);
3254 bodyLen = sizeof(tSirMacAuthFrameBody);
3255 }
3256
3257 break;
3258
3259 case SIR_MAC_AUTH_FRAME_3:
3260 /// Auth frame3 to be sent without encrypted framebody
3261 /**
3262 * Allocate buffer for Authenticaton frame of size equal
3263 * to management frame header length plus 2 bytes each
3264 * for auth algorithm number, transaction number and
3265 * status code.
3266 */
3267
3268 frameLen = sizeof(tSirMacMgmtHdr) +
3269 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3270 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3271
3272 break;
3273
3274 case SIR_MAC_AUTH_FRAME_4:
3275 /**
3276 * Allocate buffer for Authenticaton frame of size equal
3277 * to management frame header length plus 2 bytes each
3278 * for auth algorithm number, transaction number and
3279 * status code.
3280 */
3281
3282 frameLen = sizeof(tSirMacMgmtHdr) +
3283 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3284 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3285
3286 break;
3287 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3288 } // end if (wepBit == LIM_WEP_IN_FC)
3289
3290
3291 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3292
3293 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3294 {
3295 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003296 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003297
3298 return;
3299 }
3300
3301 for (i = 0; i < frameLen; i++)
3302 pFrame[i] = 0;
3303
3304 // Prepare BD
3305 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3306 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3307 {
3308 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3309 return;
3310 }
3311
3312 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3313 pMacHdr->fc.wep = wepBit;
3314
3315 // Prepare BSSId
3316 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3317 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303318 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3319 (tANI_U8 *) psessionEntry->bssId,
3320 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 }
3322
3323 /// Prepare Authentication frame body
3324 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3325
3326 if (wepBit == LIM_WEP_IN_FC)
3327 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303328 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003329
3330 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003331 FL("*** Sending Auth seq# 3 status %d (%d) to"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 pAuthFrameBody->authStatusCode,
3333 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3334
3335 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3336 }
3337 else
3338 {
3339 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3340 pBody += sizeof(tANI_U16);
3341 bodyLen -= sizeof(tANI_U16);
3342
3343 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3344 pBody += sizeof(tANI_U16);
3345 bodyLen -= sizeof(tANI_U16);
3346
3347 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3348 pBody += sizeof(tANI_U16);
3349 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003350 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3351 sizeof (pAuthFrameBody->length) +
3352 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303353 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003354
3355#if defined WLAN_FEATURE_VOWIFI_11R
3356 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3357 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3358 {
3359
3360 {
3361 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3363 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003364#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3366 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3367 (tANI_U8 *)pBody,
3368 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003369#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003370 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3371 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003372 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3373 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003374 }
3375 }
3376 else
3377 {
3378 /* MDID attr is 54*/
3379 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003381 *pBody = SIR_MDIE_SIZE;
3382 pBody++;
3383 for(i=0;i<SIR_MDIE_SIZE;i++)
3384 {
3385 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3386 pBody++;
3387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 }
3389 }
3390 }
3391#endif
3392
3393 PELOG1(limLog(pMac, LOG1,
3394 FL("*** Sending Auth seq# %d status %d (%d) to "),
3395 pAuthFrameBody->authTransactionSeqNumber,
3396 pAuthFrameBody->authStatusCode,
3397 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3398
3399 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3400 }
3401 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3402
3403 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3405 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003406#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303407 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003408 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 )
3411 {
3412 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3413 }
3414
Ganesh K08bce952012-12-13 15:04:41 -08003415 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3416 {
3417 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3418 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003419
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 /// Queue Authentication frame in high priority WQ
3421 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3422 HAL_TXRX_FRM_802_11_MGMT,
3423 ANI_TXDIR_TODS,
3424 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3425 limTxComplete, pFrame, txFlag );
3426 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3427 {
3428 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003429 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 halstatus);
3431
3432 //Pkt will be freed up by the callback
3433 }
3434
3435 return;
3436} /*** end limSendAuthMgmtFrame() ***/
3437
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003438eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3439{
3440 tANI_U16 aid;
3441 tpDphHashNode pStaDs;
3442 tLimMlmDeauthReq *pMlmDeauthReq;
3443 tLimMlmDeauthCnf mlmDeauthCnf;
3444 tpPESession psessionEntry;
3445
3446 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3447 if (pMlmDeauthReq)
3448 {
3449 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3450 {
3451 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3452 }
3453
3454 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3455 {
3456
3457 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003458 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003459 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3460 goto end;
3461 }
3462
3463 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3464 if (pStaDs == NULL)
3465 {
3466 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3467 goto end;
3468 }
3469
3470
3471 /// Receive path cleanup with dummy packet
3472 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3473 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303474 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003475 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3476 }
3477 return eHAL_STATUS_SUCCESS;
3478end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303479 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003480 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3481 sizeof(tSirMacAddr));
3482 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3483 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3484 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3485
3486 // Free up buffer allocated
3487 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303488 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003489
3490 limPostSmeMessage(pMac,
3491 LIM_MLM_DEAUTH_CNF,
3492 (tANI_U32 *) &mlmDeauthCnf);
3493 return eHAL_STATUS_SUCCESS;
3494}
3495
3496eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3497{
3498 tANI_U16 aid;
3499 tpDphHashNode pStaDs;
3500 tLimMlmDisassocCnf mlmDisassocCnf;
3501 tpPESession psessionEntry;
3502 tLimMlmDisassocReq *pMlmDisassocReq;
3503
3504 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3505 if (pMlmDisassocReq)
3506 {
3507 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3508 {
3509 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3510 }
3511
3512 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3513 {
3514
3515 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003516 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003517 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3518 goto end;
3519 }
3520
3521 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3522 if (pStaDs == NULL)
3523 {
3524 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3525 goto end;
3526 }
3527
3528 /// Receive path cleanup with dummy packet
3529 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3530 {
3531 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3532 goto end;
3533 }
3534
3535#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003536 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303537 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003538#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303539 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003540#endif
3541#ifdef FEATURE_WLAN_LFR
3542 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003543#endif
3544 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303545 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003546 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003547 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303548 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003549 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003550 psessionEntry, psessionEntry->peSessionId););
3551 limFTCleanup(pMac);
3552 }
3553 else
3554 {
3555 PELOGE(limLog(pMac, LOGE,
3556 FL("No FT Preauth Session Cleanup in role %d"
3557#ifdef FEATURE_WLAN_CCX
3558 " isCCX %d"
3559#endif
3560#ifdef FEATURE_WLAN_LFR
3561 " isLFR %d"
3562#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003563 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003564 psessionEntry->limSystemRole,
3565#ifdef FEATURE_WLAN_CCX
3566 psessionEntry->isCCXconnection,
3567#endif
3568#ifdef FEATURE_WLAN_LFR
3569 psessionEntry->isFastRoamIniFeatureEnabled,
3570#endif
3571 psessionEntry->is11Rconnection,
3572 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003573 }
3574#endif
3575
3576 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303577 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003578 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3579 return eHAL_STATUS_SUCCESS;
3580 }
3581 else
3582 {
3583 return eHAL_STATUS_SUCCESS;
3584 }
3585end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303586 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003587 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3588 sizeof(tSirMacAddr));
3589 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3590 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3591
3592 /* Update PE session ID*/
3593 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3594
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003595 if(pMlmDisassocReq != NULL)
3596 {
3597 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303598 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003599 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3600 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003601
3602 limPostSmeMessage(pMac,
3603 LIM_MLM_DISASSOC_CNF,
3604 (tANI_U32 *) &mlmDisassocCnf);
3605 return eHAL_STATUS_SUCCESS;
3606}
3607
3608eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3609{
3610 return limSendDisassocCnf(pMac);
3611}
3612
3613eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3614{
3615 return limSendDeauthCnf(pMac);
3616}
3617
Jeff Johnson295189b2012-06-20 16:38:30 -07003618/**
3619 * \brief This function is called to send Disassociate frame.
3620 *
3621 *
3622 * \param pMac Pointer to Global MAC structure
3623 *
3624 * \param nReason Indicates the reason that need to be sent in
3625 * Disassociation frame
3626 *
3627 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3628 * sent
3629 *
3630 *
3631 */
3632
3633void
3634limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3635 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003636 tSirMacAddr peer,
3637 tpPESession psessionEntry,
3638 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003639{
3640 tDot11fDisassociation frm;
3641 tANI_U8 *pFrame;
3642 tSirRetStatus nSirStatus;
3643 tpSirMacMgmtHdr pMacHdr;
3644 tANI_U32 nBytes, nPayload, nStatus;
3645 void *pPacket;
3646 eHalStatus halstatus;
3647 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003648 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 if(NULL == psessionEntry)
3650 {
3651 return;
3652 }
3653
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303654 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003655
3656 frm.Reason.code = nReason;
3657
3658 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3659 if ( DOT11F_FAILED( nStatus ) )
3660 {
3661 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003662 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 nStatus );
3664 // We'll fall back on the worst case scenario:
3665 nPayload = sizeof( tDot11fDisassociation );
3666 }
3667 else if ( DOT11F_WARNED( nStatus ) )
3668 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003669 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003671 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003672 }
3673
3674 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3675
3676 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3677 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3678 ( void** ) &pPacket );
3679 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3680 {
3681 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003682 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 return;
3684 }
3685
3686 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303687 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003688
3689 // Next, we fill out the buffer descriptor:
3690 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3691 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3692 if ( eSIR_SUCCESS != nSirStatus )
3693 {
3694 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003695 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 nSirStatus );
3697 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3698 ( void* ) pFrame, ( void* ) pPacket );
3699 return; // just allocated...
3700 }
3701
3702 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3703
3704 // Prepare the BSSID
3705 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3706
Chet Lanctot186b5732013-03-18 10:26:30 -07003707#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003708 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003709#endif
3710
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3712 sizeof(tSirMacMgmtHdr),
3713 nPayload, &nPayload );
3714 if ( DOT11F_FAILED( nStatus ) )
3715 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003716 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 nStatus );
3718 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3719 ( void* ) pFrame, ( void* ) pPacket );
3720 return; // allocated!
3721 }
3722 else if ( DOT11F_WARNED( nStatus ) )
3723 {
3724 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003725 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 }
3727
3728 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003729 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3731
3732 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3734 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 )
3736 {
3737 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3738 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003739
Ganesh K08bce952012-12-13 15:04:41 -08003740 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3741 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3742 {
3743 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3744 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003745
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003746 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003748 // Queue Disassociation frame in high priority WQ
3749 /* get the duration from the request */
3750 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3751 HAL_TXRX_FRM_802_11_MGMT,
3752 ANI_TXDIR_TODS,
3753 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3754 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3755 txFlag );
3756 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003757
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003758 if (tx_timer_change(
3759 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3760 != TX_SUCCESS)
3761 {
3762 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003763 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003764 return;
3765 }
3766 else if(TX_SUCCESS != tx_timer_activate(
3767 &pMac->lim.limTimers.gLimDisassocAckTimer))
3768 {
3769 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003770 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003771 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3772 return;
3773 }
3774 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003775 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003776 {
3777 // Queue Disassociation frame in high priority WQ
3778 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3779 HAL_TXRX_FRM_802_11_MGMT,
3780 ANI_TXDIR_TODS,
3781 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3782 limTxComplete, pFrame, txFlag );
3783 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3784 {
3785 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003786 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003787 nSirStatus );
3788 //Pkt will be freed up by the callback
3789 return;
3790 }
3791 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003792} // End limSendDisassocMgmtFrame.
3793
3794/**
3795 * \brief This function is called to send a Deauthenticate frame
3796 *
3797 *
3798 * \param pMac Pointer to global MAC structure
3799 *
3800 * \param nReason Indicates the reason that need to be sent in the
3801 * Deauthenticate frame
3802 *
3803 * \param peeer address of the STA to which the frame is to be sent
3804 *
3805 *
3806 */
3807
3808void
3809limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3810 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003811 tSirMacAddr peer,
3812 tpPESession psessionEntry,
3813 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003814{
3815 tDot11fDeAuth frm;
3816 tANI_U8 *pFrame;
3817 tSirRetStatus nSirStatus;
3818 tpSirMacMgmtHdr pMacHdr;
3819 tANI_U32 nBytes, nPayload, nStatus;
3820 void *pPacket;
3821 eHalStatus halstatus;
3822 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003823 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003824#ifdef FEATURE_WLAN_TDLS
3825 tANI_U16 aid;
3826 tpDphHashNode pStaDs;
3827#endif
3828
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 if(NULL == psessionEntry)
3830 {
3831 return;
3832 }
3833
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303834 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003835
3836 frm.Reason.code = nReason;
3837
3838 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3839 if ( DOT11F_FAILED( nStatus ) )
3840 {
3841 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003842 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 nStatus );
3844 // We'll fall back on the worst case scenario:
3845 nPayload = sizeof( tDot11fDeAuth );
3846 }
3847 else if ( DOT11F_WARNED( nStatus ) )
3848 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003849 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003851 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 }
3853
3854 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3855
3856 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3857 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3858 ( void** ) &pPacket );
3859 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3860 {
3861 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003862 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 return;
3864 }
3865
3866 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303867 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003868
3869 // Next, we fill out the buffer descriptor:
3870 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3871 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3872 if ( eSIR_SUCCESS != nSirStatus )
3873 {
3874 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003875 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 nSirStatus );
3877 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3878 ( void* ) pFrame, ( void* ) pPacket );
3879 return; // just allocated...
3880 }
3881
3882 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3883
3884 // Prepare the BSSID
3885 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3886
Chet Lanctot186b5732013-03-18 10:26:30 -07003887#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003888 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003889#endif
3890
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3892 sizeof(tSirMacMgmtHdr),
3893 nPayload, &nPayload );
3894 if ( DOT11F_FAILED( nStatus ) )
3895 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003896 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 nStatus );
3898 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3899 ( void* ) pFrame, ( void* ) pPacket );
3900 return;
3901 }
3902 else if ( DOT11F_WARNED( nStatus ) )
3903 {
3904 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003905 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 }
3907
3908 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003909 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3911
3912 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3914 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 )
3916 {
3917 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3918 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003919
Ganesh K08bce952012-12-13 15:04:41 -08003920 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3921 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3922 {
3923 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3924 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003925
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003926#ifdef FEATURE_WLAN_TDLS
3927 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3928#endif
3929
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003930 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003931 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003932 // Queue Disassociation frame in high priority WQ
3933 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3934 HAL_TXRX_FRM_802_11_MGMT,
3935 ANI_TXDIR_TODS,
3936 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3937 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
3938 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3939 {
3940 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003941 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003942 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003943 //Pkt will be freed up by the callback limTxComplete
3944
3945 /*Call limProcessDeauthAckTimeout which will send
3946 * DeauthCnf for this frame
3947 */
3948 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003949 return;
3950 }
3951
3952 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3953
3954 if (tx_timer_change(
3955 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3956 != TX_SUCCESS)
3957 {
3958 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003959 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003960 return;
3961 }
3962 else if(TX_SUCCESS != tx_timer_activate(
3963 &pMac->lim.limTimers.gLimDeauthAckTimer))
3964 {
3965 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003966 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003967 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3968 return;
3969 }
3970 }
3971 else
3972 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003973#ifdef FEATURE_WLAN_TDLS
3974 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
3975 {
3976 // Queue Disassociation frame in high priority WQ
3977 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003978 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003979 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003980 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3981 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003982 }
3983 else
3984 {
3985#endif
3986 // Queue Disassociation frame in high priority WQ
3987 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3988 HAL_TXRX_FRM_802_11_MGMT,
3989 ANI_TXDIR_TODS,
3990 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3991 limTxComplete, pFrame, txFlag );
3992#ifdef FEATURE_WLAN_TDLS
3993 }
3994#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003995 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3996 {
3997 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003998 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003999 nSirStatus );
4000 //Pkt will be freed up by the callback
4001 return;
4002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 }
4004
4005} // End limSendDeauthMgmtFrame.
4006
4007
4008#ifdef ANI_SUPPORT_11H
4009/**
4010 * \brief Send a Measurement Report Action frame
4011 *
4012 *
4013 * \param pMac Pointer to the global MAC structure
4014 *
4015 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4016 *
4017 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4018 *
4019 *
4020 */
4021
4022tSirRetStatus
4023limSendMeasReportFrame(tpAniSirGlobal pMac,
4024 tpSirMacMeasReqActionFrame pMeasReqFrame,
4025 tSirMacAddr peer)
4026{
4027 tDot11fMeasurementReport frm;
4028 tANI_U8 *pFrame;
4029 tSirRetStatus nSirStatus;
4030 tpSirMacMgmtHdr pMacHdr;
4031 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4032 void *pPacket;
4033 eHalStatus halstatus;
4034
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304035 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004036
4037 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4038 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4039 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4040
4041 switch ( pMeasReqFrame->measReqIE.measType )
4042 {
4043 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4044 nSirStatus =
4045 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4046 &frm.MeasurementReport );
4047 break;
4048 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4049 nSirStatus =
4050 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4051 &frm.MeasurementReport );
4052 break;
4053 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4054 nSirStatus =
4055 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4056 &frm.MeasurementReport );
4057 break;
4058 default:
4059 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004060 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 pMeasReqFrame->measReqIE.measType );
4062 return eSIR_FAILURE;
4063 }
4064
4065 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4066
4067 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4068 if ( DOT11F_FAILED( nStatus ) )
4069 {
4070 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004071 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 nStatus );
4073 // We'll fall back on the worst case scenario:
4074 nPayload = sizeof( tDot11fMeasurementReport );
4075 }
4076 else if ( DOT11F_WARNED( nStatus ) )
4077 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004078 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004080 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 }
4082
4083 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4084
4085 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4086 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4087 {
4088 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004089 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 return eSIR_FAILURE;
4091 }
4092
4093 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304094 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004095
4096 // Next, we fill out the buffer descriptor:
4097 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4098 SIR_MAC_MGMT_ACTION, peer);
4099 if ( eSIR_SUCCESS != nSirStatus )
4100 {
4101 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004102 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 nSirStatus );
4104 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4105 return eSIR_FAILURE; // just allocated...
4106 }
4107
4108 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4109
4110 nCfg = 6;
4111 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4112 if ( eSIR_SUCCESS != nSirStatus )
4113 {
4114 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004115 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 nSirStatus );
4117 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4118 return eSIR_FAILURE; // just allocated...
4119 }
4120
Chet Lanctot186b5732013-03-18 10:26:30 -07004121#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004122 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004123#endif
4124
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4126 sizeof(tSirMacMgmtHdr),
4127 nPayload, &nPayload );
4128 if ( DOT11F_FAILED( nStatus ) )
4129 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004130 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 nStatus );
4132 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4133 return eSIR_FAILURE; // allocated!
4134 }
4135 else if ( DOT11F_WARNED( nStatus ) )
4136 {
4137 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004138 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 }
4140
4141 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4142 HAL_TXRX_FRM_802_11_MGMT,
4143 ANI_TXDIR_TODS,
4144 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4145 limTxComplete, pFrame, 0 );
4146 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4147 {
4148 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004149 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 nSirStatus );
4151 //Pkt will be freed up by the callback
4152 return eSIR_FAILURE; // just allocated...
4153 }
4154
4155 return eSIR_SUCCESS;
4156
4157} // End limSendMeasReportFrame.
4158
4159
4160/**
4161 * \brief Send a TPC Request Action frame
4162 *
4163 *
4164 * \param pMac Pointer to the global MAC datastructure
4165 *
4166 * \param peer MAC address to which the frame should be sent
4167 *
4168 *
4169 */
4170
4171void
4172limSendTpcRequestFrame(tpAniSirGlobal pMac,
4173 tSirMacAddr peer)
4174{
4175 tDot11fTPCRequest frm;
4176 tANI_U8 *pFrame;
4177 tSirRetStatus nSirStatus;
4178 tpSirMacMgmtHdr pMacHdr;
4179 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4180 void *pPacket;
4181 eHalStatus halstatus;
4182
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304183 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004184
4185 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4186 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4187 frm.DialogToken.token = 1;
4188 frm.TPCRequest.present = 1;
4189
4190 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4191 if ( DOT11F_FAILED( nStatus ) )
4192 {
4193 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004194 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 nStatus );
4196 // We'll fall back on the worst case scenario:
4197 nPayload = sizeof( tDot11fTPCRequest );
4198 }
4199 else if ( DOT11F_WARNED( nStatus ) )
4200 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004201 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004203 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 }
4205
4206 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4207
4208 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4209 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4210 {
4211 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004212 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 return;
4214 }
4215
4216 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304217 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004218
4219 // Next, we fill out the buffer descriptor:
4220 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4221 SIR_MAC_MGMT_ACTION, peer);
4222 if ( eSIR_SUCCESS != nSirStatus )
4223 {
4224 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004225 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 nSirStatus );
4227 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4228 return; // just allocated...
4229 }
4230
4231 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4232
4233 nCfg = 6;
4234 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4235 if ( eSIR_SUCCESS != nSirStatus )
4236 {
4237 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004238 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 nSirStatus );
4240 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4241 return; // just allocated...
4242 }
4243
Chet Lanctot186b5732013-03-18 10:26:30 -07004244#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004245 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004246#endif
4247
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4249 sizeof(tSirMacMgmtHdr),
4250 nPayload, &nPayload );
4251 if ( DOT11F_FAILED( nStatus ) )
4252 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004253 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 nStatus );
4255 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4256 return; // allocated!
4257 }
4258 else if ( DOT11F_WARNED( nStatus ) )
4259 {
4260 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004261 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 }
4263
4264 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4265 HAL_TXRX_FRM_802_11_MGMT,
4266 ANI_TXDIR_TODS,
4267 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4268 limTxComplete, pFrame, 0 );
4269 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4270 {
4271 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004272 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 nSirStatus );
4274 //Pkt will be freed up by the callback
4275 return;
4276 }
4277
4278} // End limSendTpcRequestFrame.
4279
4280
4281/**
4282 * \brief Send a TPC Report Action frame
4283 *
4284 *
4285 * \param pMac Pointer to the global MAC datastructure
4286 *
4287 * \param pTpcReqFrame Pointer to the received TPC Request
4288 *
4289 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4290 *
4291 *
4292 */
4293
4294tSirRetStatus
4295limSendTpcReportFrame(tpAniSirGlobal pMac,
4296 tpSirMacTpcReqActionFrame pTpcReqFrame,
4297 tSirMacAddr peer)
4298{
4299 tDot11fTPCReport frm;
4300 tANI_U8 *pFrame;
4301 tSirRetStatus nSirStatus;
4302 tpSirMacMgmtHdr pMacHdr;
4303 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4304 void *pPacket;
4305 eHalStatus halstatus;
4306
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304307 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004308
4309 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4310 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4311 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4312
4313 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4314 // "misplaced this function, need to replace:
4315 // txPower = halGetRateToPwrValue(pMac, staid,
4316 // pMac->lim.gLimCurrentChannelId, 0);
4317 frm.TPCReport.tx_power = 0;
4318 frm.TPCReport.link_margin = 0;
4319 frm.TPCReport.present = 1;
4320
4321 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4322 if ( DOT11F_FAILED( nStatus ) )
4323 {
4324 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004325 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 nStatus );
4327 // We'll fall back on the worst case scenario:
4328 nPayload = sizeof( tDot11fTPCReport );
4329 }
4330 else if ( DOT11F_WARNED( nStatus ) )
4331 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004332 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004334 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 }
4336
4337 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4338
4339 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4340 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4341 {
4342 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004343 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 return eSIR_FAILURE;
4345 }
4346
4347 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304348 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004349
4350 // Next, we fill out the buffer descriptor:
4351 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4352 SIR_MAC_MGMT_ACTION, peer);
4353 if ( eSIR_SUCCESS != nSirStatus )
4354 {
4355 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004356 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 nSirStatus );
4358 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4359 return eSIR_FAILURE; // just allocated...
4360 }
4361
4362 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4363
4364 nCfg = 6;
4365 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4366 if ( eSIR_SUCCESS != nSirStatus )
4367 {
4368 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004369 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 nSirStatus );
4371 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4372 return eSIR_FAILURE; // just allocated...
4373 }
4374
Chet Lanctot186b5732013-03-18 10:26:30 -07004375#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004376 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004377#endif
4378
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4380 sizeof(tSirMacMgmtHdr),
4381 nPayload, &nPayload );
4382 if ( DOT11F_FAILED( nStatus ) )
4383 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004384 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 nStatus );
4386 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4387 return eSIR_FAILURE; // allocated!
4388 }
4389 else if ( DOT11F_WARNED( nStatus ) )
4390 {
4391 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004392 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 }
4394
4395
4396 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4397 HAL_TXRX_FRM_802_11_MGMT,
4398 ANI_TXDIR_TODS,
4399 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4400 limTxComplete, pFrame, 0 );
4401 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4402 {
4403 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004404 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 nSirStatus );
4406 //Pkt will be freed up by the callback
4407 return eSIR_FAILURE; // just allocated...
4408 }
4409
4410 return eSIR_SUCCESS;
4411
4412} // End limSendTpcReportFrame.
4413#endif //ANI_SUPPORT_11H
4414
4415
Jeff Johnson295189b2012-06-20 16:38:30 -07004416/**
4417 * \brief Send a Channel Switch Announcement
4418 *
4419 *
4420 * \param pMac Pointer to the global MAC datastructure
4421 *
4422 * \param peer MAC address to which this frame will be sent
4423 *
4424 * \param nMode
4425 *
4426 * \param nNewChannel
4427 *
4428 * \param nCount
4429 *
4430 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4431 *
4432 *
4433 */
4434
4435tSirRetStatus
4436limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4437 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004438 tANI_U8 nMode,
4439 tANI_U8 nNewChannel,
4440 tANI_U8 nCount,
4441 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004442{
4443 tDot11fChannelSwitch frm;
4444 tANI_U8 *pFrame;
4445 tSirRetStatus nSirStatus;
4446 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004447 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 void *pPacket;
4449 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004450 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004451
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304452 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004453
4454 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4455 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4456 frm.ChanSwitchAnn.switchMode = nMode;
4457 frm.ChanSwitchAnn.newChannel = nNewChannel;
4458 frm.ChanSwitchAnn.switchCount = nCount;
4459 frm.ChanSwitchAnn.present = 1;
4460
4461 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4462 if ( DOT11F_FAILED( nStatus ) )
4463 {
4464 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004465 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 nStatus );
4467 // We'll fall back on the worst case scenario:
4468 nPayload = sizeof( tDot11fChannelSwitch );
4469 }
4470 else if ( DOT11F_WARNED( nStatus ) )
4471 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004472 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004474 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 }
4476
4477 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4478
4479 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4480 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4481 {
4482 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004483 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 return eSIR_FAILURE;
4485 }
4486
4487 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304488 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004489
4490 // Next, we fill out the buffer descriptor:
4491 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004492 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4493 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304494 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4495 (tANI_U8 *) psessionEntry->bssId,
4496 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 if ( eSIR_SUCCESS != nSirStatus )
4498 {
4499 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004500 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 nSirStatus );
4502 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4503 return eSIR_FAILURE; // just allocated...
4504 }
4505
Jeff Johnsone7245742012-09-05 17:12:55 -07004506#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004507 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4508
4509 nCfg = 6;
4510 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4511 if ( eSIR_SUCCESS != nSirStatus )
4512 {
4513 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004514 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 nSirStatus );
4516 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4517 return eSIR_FAILURE; // just allocated...
4518 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004519#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004520
4521#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004522 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004523#endif
4524
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4526 sizeof(tSirMacMgmtHdr),
4527 nPayload, &nPayload );
4528 if ( DOT11F_FAILED( nStatus ) )
4529 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004530 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 nStatus );
4532 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4533 return eSIR_FAILURE; // allocated!
4534 }
4535 else if ( DOT11F_WARNED( nStatus ) )
4536 {
4537 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004538 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 }
4540
Jeff Johnsone7245742012-09-05 17:12:55 -07004541 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004542 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4543 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004544 )
4545 {
4546 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4549 HAL_TXRX_FRM_802_11_MGMT,
4550 ANI_TXDIR_TODS,
4551 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004552 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4554 {
4555 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004556 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 nSirStatus );
4558 //Pkt will be freed up by the callback
4559 return eSIR_FAILURE;
4560 }
4561
4562 return eSIR_SUCCESS;
4563
4564} // End limSendChannelSwitchMgmtFrame.
4565
Jeff Johnson295189b2012-06-20 16:38:30 -07004566
4567
Mohit Khanna4a70d262012-09-11 16:30:12 -07004568#ifdef WLAN_FEATURE_11AC
4569tSirRetStatus
4570limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4571 tSirMacAddr peer,
4572 tANI_U8 nMode,
4573 tpPESession psessionEntry )
4574{
4575 tDot11fOperatingMode frm;
4576 tANI_U8 *pFrame;
4577 tSirRetStatus nSirStatus;
4578 tpSirMacMgmtHdr pMacHdr;
4579 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4580 void *pPacket;
4581 eHalStatus halstatus;
4582 tANI_U8 txFlag = 0;
4583
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304584 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004585
4586 frm.Category.category = SIR_MAC_ACTION_VHT;
4587 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4588 frm.OperatingMode.chanWidth = nMode;
4589 frm.OperatingMode.rxNSS = 0;
4590 frm.OperatingMode.rxNSSType = 0;
4591
4592 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4593 if ( DOT11F_FAILED( nStatus ) )
4594 {
4595 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004596 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004597 nStatus );
4598 // We'll fall back on the worst case scenario:
4599 nPayload = sizeof( tDot11fOperatingMode);
4600 }
4601 else if ( DOT11F_WARNED( nStatus ) )
4602 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004603 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004604 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004605 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004606 }
4607
4608 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4609
4610 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4611 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4612 {
4613 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004614 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004615 return eSIR_FAILURE;
4616 }
4617
4618 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304619 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004620
4621
4622 // Next, we fill out the buffer descriptor:
4623 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4624 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4625 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4626 } else
4627 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4628 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4629 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304630 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4631 (tANI_U8 *) psessionEntry->bssId,
4632 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004633 if ( eSIR_SUCCESS != nSirStatus )
4634 {
4635 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004636 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004637 nSirStatus );
4638 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4639 return eSIR_FAILURE; // just allocated...
4640 }
4641 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4642 sizeof(tSirMacMgmtHdr),
4643 nPayload, &nPayload );
4644 if ( DOT11F_FAILED( nStatus ) )
4645 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004646 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004647 nStatus );
4648 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4649 return eSIR_FAILURE; // allocated!
4650 }
4651 else if ( DOT11F_WARNED( nStatus ) )
4652 {
4653 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004654 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004655 }
4656 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004657 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4658 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004659 )
4660 {
4661 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4662 }
4663 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4664 HAL_TXRX_FRM_802_11_MGMT,
4665 ANI_TXDIR_TODS,
4666 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4667 limTxComplete, pFrame, txFlag );
4668 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4669 {
4670 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004671 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004672 nSirStatus );
4673 //Pkt will be freed up by the callback
4674 return eSIR_FAILURE;
4675 }
4676
4677 return eSIR_SUCCESS;
4678}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004679
4680/**
4681 * \brief Send a VHT Channel Switch Announcement
4682 *
4683 *
4684 * \param pMac Pointer to the global MAC datastructure
4685 *
4686 * \param peer MAC address to which this frame will be sent
4687 *
4688 * \param nChanWidth
4689 *
4690 * \param nNewChannel
4691 *
4692 *
4693 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4694 *
4695 *
4696 */
4697
4698tSirRetStatus
4699limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4700 tSirMacAddr peer,
4701 tANI_U8 nChanWidth,
4702 tANI_U8 nNewChannel,
4703 tANI_U8 ncbMode,
4704 tpPESession psessionEntry )
4705{
4706 tDot11fChannelSwitch frm;
4707 tANI_U8 *pFrame;
4708 tSirRetStatus nSirStatus;
4709 tpSirMacMgmtHdr pMacHdr;
4710 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4711 void *pPacket;
4712 eHalStatus halstatus;
4713 tANI_U8 txFlag = 0;
4714
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304715 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004716
4717
4718 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4719 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4720 frm.ChanSwitchAnn.switchMode = 1;
4721 frm.ChanSwitchAnn.newChannel = nNewChannel;
4722 frm.ChanSwitchAnn.switchCount = 1;
4723 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4724 frm.ExtChanSwitchAnn.present = 1;
4725 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4726 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4727 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4728 frm.ChanSwitchAnn.present = 1;
4729 frm.WiderBWChanSwitchAnn.present = 1;
4730
4731 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4732 if ( DOT11F_FAILED( nStatus ) )
4733 {
4734 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004735 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004736 nStatus );
4737 // We'll fall back on the worst case scenario:
4738 nPayload = sizeof( tDot11fChannelSwitch );
4739 }
4740 else if ( DOT11F_WARNED( nStatus ) )
4741 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004742 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004743 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004744 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004745 }
4746
4747 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4748
4749 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4750 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4751 {
4752 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004753 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004754 return eSIR_FAILURE;
4755 }
4756 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304757 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004758
4759 // Next, we fill out the buffer descriptor:
4760 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4761 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4762 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304763 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4764 (tANI_U8 *) psessionEntry->bssId,
4765 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004766 if ( eSIR_SUCCESS != nSirStatus )
4767 {
4768 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004769 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004770 nSirStatus );
4771 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4772 return eSIR_FAILURE; // just allocated...
4773 }
4774 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4775 sizeof(tSirMacMgmtHdr),
4776 nPayload, &nPayload );
4777 if ( DOT11F_FAILED( nStatus ) )
4778 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004779 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004780 nStatus );
4781 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4782 return eSIR_FAILURE; // allocated!
4783 }
4784 else if ( DOT11F_WARNED( nStatus ) )
4785 {
4786 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004787 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004788 }
4789
4790 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004791 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4792 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004793 )
4794 {
4795 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4796 }
4797 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4798 HAL_TXRX_FRM_802_11_MGMT,
4799 ANI_TXDIR_TODS,
4800 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4801 limTxComplete, pFrame, txFlag );
4802 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4803 {
4804 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004805 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004806 nSirStatus );
4807 //Pkt will be freed up by the callback
4808 return eSIR_FAILURE;
4809 }
4810
4811 return eSIR_SUCCESS;
4812
4813} // End limSendVHTChannelSwitchMgmtFrame.
4814
4815
4816
Mohit Khanna4a70d262012-09-11 16:30:12 -07004817#endif
4818
Jeff Johnson295189b2012-06-20 16:38:30 -07004819/**
4820 * \brief Send an ADDBA Req Action Frame to peer
4821 *
4822 * \sa limSendAddBAReq
4823 *
4824 * \param pMac The global tpAniSirGlobal object
4825 *
4826 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4827 * the necessary parameters reqd by PE send the ADDBA Req Action
4828 * Frame to the peer
4829 *
4830 * \return eSIR_SUCCESS if setup completes successfully
4831 * eSIR_FAILURE is some problem is encountered
4832 */
4833tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304834 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004835{
4836 tDot11fAddBAReq frmAddBAReq;
4837 tANI_U8 *pAddBAReqBuffer = NULL;
4838 tpSirMacMgmtHdr pMacHdr;
4839 tANI_U32 frameLen = 0, nStatus, nPayload;
4840 tSirRetStatus statusCode;
4841 eHalStatus halStatus;
4842 void *pPacket;
4843 tANI_U8 txFlag = 0;
4844
4845 if(NULL == psessionEntry)
4846 {
4847 return eSIR_FAILURE;
4848 }
4849
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304850 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004851
4852 // Category - 3 (BA)
4853 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4854
4855 // Action - 0 (ADDBA Req)
4856 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4857
4858 // FIXME - Dialog Token, generalize this...
4859 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4860
4861 // Fill the ADDBA Parameter Set
4862 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4863 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4864 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4865
4866 // BA timeout
4867 // 0 - indicates no BA timeout
4868 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4869
4870 // BA Starting Sequence Number
4871 // Fragment number will always be zero
4872 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4873 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4874 }
4875
4876 frmAddBAReq.BAStartingSequenceControl.ssn =
4877 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4878
4879 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4880
4881 if( DOT11F_FAILED( nStatus ))
4882 {
4883 limLog( pMac, LOGW,
4884 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004885 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 nStatus );
4887
4888 // We'll fall back on the worst case scenario:
4889 nPayload = sizeof( tDot11fAddBAReq );
4890 }
4891 else if( DOT11F_WARNED( nStatus ))
4892 {
4893 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004894 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004895 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 nStatus );
4897 }
4898
4899 // Add the MGMT header to frame length
4900 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4901
4902 // Need to allocate a buffer for ADDBA AF
4903 if( eHAL_STATUS_SUCCESS !=
4904 (halStatus = palPktAlloc( pMac->hHdd,
4905 HAL_TXRX_FRM_802_11_MGMT,
4906 (tANI_U16) frameLen,
4907 (void **) &pAddBAReqBuffer,
4908 (void **) &pPacket )))
4909 {
4910 // Log error
4911 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004912 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 frameLen,
4914 halStatus );
4915
4916 statusCode = eSIR_MEM_ALLOC_FAILED;
4917 goto returnAfterError;
4918 }
4919
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304920 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004921
4922 // Copy necessary info to BD
4923 if( eSIR_SUCCESS !=
4924 (statusCode = limPopulateMacHeader( pMac,
4925 pAddBAReqBuffer,
4926 SIR_MAC_MGMT_FRAME,
4927 SIR_MAC_MGMT_ACTION,
4928 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4929 goto returnAfterError;
4930
4931 // Update A3 with the BSSID
4932 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4933
4934 #if 0
4935 cfgLen = SIR_MAC_ADDR_LENGTH;
4936 if( eSIR_SUCCESS != cfgGetStr( pMac,
4937 WNI_CFG_BSSID,
4938 (tANI_U8 *) pMacHdr->bssId,
4939 &cfgLen ))
4940 {
4941 limLog( pMac, LOGP,
4942 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004943 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004944
4945 // FIXME - Need to convert to tSirRetStatus
4946 statusCode = eSIR_FAILURE;
4947 goto returnAfterError;
4948 }
4949 #endif//TO SUPPORT BT-AMP
4950 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4951
Chet Lanctot186b5732013-03-18 10:26:30 -07004952#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004953 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004954#endif
4955
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 // Now, we're ready to "pack" the frames
4957 nStatus = dot11fPackAddBAReq( pMac,
4958 &frmAddBAReq,
4959 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4960 nPayload,
4961 &nPayload );
4962
4963 if( DOT11F_FAILED( nStatus ))
4964 {
4965 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004966 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 nStatus );
4968
4969 // FIXME - Need to convert to tSirRetStatus
4970 statusCode = eSIR_FAILURE;
4971 goto returnAfterError;
4972 }
4973 else if( DOT11F_WARNED( nStatus ))
4974 {
4975 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004976 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
4977 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 }
4979
4980 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004981 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4983
4984 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4986 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 )
4988 {
4989 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4990 }
4991
4992 if( eHAL_STATUS_SUCCESS !=
4993 (halStatus = halTxFrame( pMac,
4994 pPacket,
4995 (tANI_U16) frameLen,
4996 HAL_TXRX_FRM_802_11_MGMT,
4997 ANI_TXDIR_TODS,
4998 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4999 limTxComplete,
5000 pAddBAReqBuffer, txFlag )))
5001 {
5002 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005003 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 halStatus );
5005
5006 // FIXME - Need to convert eHalStatus to tSirRetStatus
5007 statusCode = eSIR_FAILURE;
5008 //Pkt will be freed up by the callback
5009 return statusCode;
5010 }
5011 else
5012 return eSIR_SUCCESS;
5013
5014returnAfterError:
5015
5016 // Release buffer, if allocated
5017 if( NULL != pAddBAReqBuffer )
5018 palPktFree( pMac->hHdd,
5019 HAL_TXRX_FRM_802_11_MGMT,
5020 (void *) pAddBAReqBuffer,
5021 (void *) pPacket );
5022
5023 return statusCode;
5024}
5025
5026/**
5027 * \brief Send an ADDBA Rsp Action Frame to peer
5028 *
5029 * \sa limSendAddBARsp
5030 *
5031 * \param pMac The global tpAniSirGlobal object
5032 *
5033 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5034 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5035 * Frame to the peer
5036 *
5037 * \return eSIR_SUCCESS if setup completes successfully
5038 * eSIR_FAILURE is some problem is encountered
5039 */
5040tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5041 tpLimMlmAddBARsp pMlmAddBARsp,
5042 tpPESession psessionEntry)
5043{
5044 tDot11fAddBARsp frmAddBARsp;
5045 tANI_U8 *pAddBARspBuffer = NULL;
5046 tpSirMacMgmtHdr pMacHdr;
5047 tANI_U32 frameLen = 0, nStatus, nPayload;
5048 tSirRetStatus statusCode;
5049 eHalStatus halStatus;
5050 void *pPacket;
5051 tANI_U8 txFlag = 0;
5052
5053 if(NULL == psessionEntry)
5054 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005055 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 return eSIR_FAILURE;
5057 }
5058
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305059 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005060
5061 // Category - 3 (BA)
5062 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5063 // Action - 1 (ADDBA Rsp)
5064 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5065
5066 // Should be same as the one we received in the ADDBA Req
5067 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5068
5069 // ADDBA Req status
5070 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5071
5072 // Fill the ADDBA Parameter Set as provided by caller
5073 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5074 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5075 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005076
5077 if(psessionEntry->isAmsduSupportInAMPDU)
5078 {
5079 frmAddBARsp.AddBAParameterSet.amsduSupported =
5080 psessionEntry->amsduSupportedInBA;
5081 }
5082 else
5083 {
5084 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005086
5087 // BA timeout
5088 // 0 - indicates no BA timeout
5089 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5090
5091 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5092
5093 if( DOT11F_FAILED( nStatus ))
5094 {
5095 limLog( pMac, LOGW,
5096 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005097 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 nStatus );
5099
5100 // We'll fall back on the worst case scenario:
5101 nPayload = sizeof( tDot11fAddBARsp );
5102 }
5103 else if( DOT11F_WARNED( nStatus ))
5104 {
5105 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005106 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005107 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 nStatus );
5109 }
5110
5111 // Need to allocate a buffer for ADDBA AF
5112 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5113
5114 // Allocate shared memory
5115 if( eHAL_STATUS_SUCCESS !=
5116 (halStatus = palPktAlloc( pMac->hHdd,
5117 HAL_TXRX_FRM_802_11_MGMT,
5118 (tANI_U16) frameLen,
5119 (void **) &pAddBARspBuffer,
5120 (void **) &pPacket )))
5121 {
5122 // Log error
5123 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005124 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 frameLen,
5126 halStatus );
5127
5128 statusCode = eSIR_MEM_ALLOC_FAILED;
5129 goto returnAfterError;
5130 }
5131
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305132 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005133
5134 // Copy necessary info to BD
5135 if( eSIR_SUCCESS !=
5136 (statusCode = limPopulateMacHeader( pMac,
5137 pAddBARspBuffer,
5138 SIR_MAC_MGMT_FRAME,
5139 SIR_MAC_MGMT_ACTION,
5140 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5141 goto returnAfterError;
5142
5143 // Update A3 with the BSSID
5144
5145 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5146
5147 #if 0
5148 cfgLen = SIR_MAC_ADDR_LENGTH;
5149 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5150 WNI_CFG_BSSID,
5151 (tANI_U8 *) pMacHdr->bssId,
5152 &cfgLen ))
5153 {
5154 limLog( pMac, LOGP,
5155 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005156 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005157
5158 // FIXME - Need to convert to tSirRetStatus
5159 statusCode = eSIR_FAILURE;
5160 goto returnAfterError;
5161 }
5162 #endif // TO SUPPORT BT-AMP
5163 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5164
Chet Lanctot186b5732013-03-18 10:26:30 -07005165#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005166 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005167#endif
5168
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 // Now, we're ready to "pack" the frames
5170 nStatus = dot11fPackAddBARsp( pMac,
5171 &frmAddBARsp,
5172 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5173 nPayload,
5174 &nPayload );
5175
5176 if( DOT11F_FAILED( nStatus ))
5177 {
5178 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005179 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 nStatus );
5181
5182 // FIXME - Need to convert to tSirRetStatus
5183 statusCode = eSIR_FAILURE;
5184 goto returnAfterError;
5185 }
5186 else if( DOT11F_WARNED( nStatus ))
5187 {
5188 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005189 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5190 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 }
5192
5193 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005194 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5196
5197 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5199 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 )
5201 {
5202 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5203 }
5204
5205 if( eHAL_STATUS_SUCCESS !=
5206 (halStatus = halTxFrame( pMac,
5207 pPacket,
5208 (tANI_U16) frameLen,
5209 HAL_TXRX_FRM_802_11_MGMT,
5210 ANI_TXDIR_TODS,
5211 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5212 limTxComplete,
5213 pAddBARspBuffer, txFlag )))
5214 {
5215 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005216 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 halStatus );
5218
5219 // FIXME - HAL error codes are different from PE error
5220 // codes!! And, this routine is returning tSirRetStatus
5221 statusCode = eSIR_FAILURE;
5222 //Pkt will be freed up by the callback
5223 return statusCode;
5224 }
5225 else
5226 return eSIR_SUCCESS;
5227
5228 returnAfterError:
5229
5230 // Release buffer, if allocated
5231 if( NULL != pAddBARspBuffer )
5232 palPktFree( pMac->hHdd,
5233 HAL_TXRX_FRM_802_11_MGMT,
5234 (void *) pAddBARspBuffer,
5235 (void *) pPacket );
5236
5237 return statusCode;
5238}
5239
5240/**
5241 * \brief Send a DELBA Indication Action Frame to peer
5242 *
5243 * \sa limSendDelBAInd
5244 *
5245 * \param pMac The global tpAniSirGlobal object
5246 *
5247 * \param peerMacAddr MAC Address of peer
5248 *
5249 * \param reasonCode Reason for the DELBA notification
5250 *
5251 * \param pBAParameterSet The DELBA Parameter Set.
5252 * This identifies the TID for which the BA session is
5253 * being deleted.
5254 *
5255 * \return eSIR_SUCCESS if setup completes successfully
5256 * eSIR_FAILURE is some problem is encountered
5257 */
5258tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5259 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5260{
5261 tDot11fDelBAInd frmDelBAInd;
5262 tANI_U8 *pDelBAIndBuffer = NULL;
5263 //tANI_U32 val;
5264 tpSirMacMgmtHdr pMacHdr;
5265 tANI_U32 frameLen = 0, nStatus, nPayload;
5266 tSirRetStatus statusCode;
5267 eHalStatus halStatus;
5268 void *pPacket;
5269 tANI_U8 txFlag = 0;
5270
5271 if(NULL == psessionEntry)
5272 {
5273 return eSIR_FAILURE;
5274 }
5275
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305276 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005277
5278 // Category - 3 (BA)
5279 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5280 // Action - 2 (DELBA)
5281 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5282
5283 // Fill the DELBA Parameter Set as provided by caller
5284 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5285 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5286
5287 // BA Starting Sequence Number
5288 // Fragment number will always be zero
5289 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5290
5291 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5292
5293 if( DOT11F_FAILED( nStatus ))
5294 {
5295 limLog( pMac, LOGW,
5296 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005297 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 nStatus );
5299
5300 // We'll fall back on the worst case scenario:
5301 nPayload = sizeof( tDot11fDelBAInd );
5302 }
5303 else if( DOT11F_WARNED( nStatus ))
5304 {
5305 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005306 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005307 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 nStatus );
5309 }
5310
5311 // Add the MGMT header to frame length
5312 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5313
5314 // Allocate shared memory
5315 if( eHAL_STATUS_SUCCESS !=
5316 (halStatus = palPktAlloc( pMac->hHdd,
5317 HAL_TXRX_FRM_802_11_MGMT,
5318 (tANI_U16) frameLen,
5319 (void **) &pDelBAIndBuffer,
5320 (void **) &pPacket )))
5321 {
5322 // Log error
5323 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005324 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 frameLen,
5326 halStatus );
5327
5328 statusCode = eSIR_MEM_ALLOC_FAILED;
5329 goto returnAfterError;
5330 }
5331
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305332 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005333
5334 // Copy necessary info to BD
5335 if( eSIR_SUCCESS !=
5336 (statusCode = limPopulateMacHeader( pMac,
5337 pDelBAIndBuffer,
5338 SIR_MAC_MGMT_FRAME,
5339 SIR_MAC_MGMT_ACTION,
5340 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5341 goto returnAfterError;
5342
5343 // Update A3 with the BSSID
5344 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5345
5346 #if 0
5347 cfgLen = SIR_MAC_ADDR_LENGTH;
5348 if( eSIR_SUCCESS != cfgGetStr( pMac,
5349 WNI_CFG_BSSID,
5350 (tANI_U8 *) pMacHdr->bssId,
5351 &cfgLen ))
5352 {
5353 limLog( pMac, LOGP,
5354 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005355 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005356
5357 // FIXME - Need to convert to tSirRetStatus
5358 statusCode = eSIR_FAILURE;
5359 goto returnAfterError;
5360 }
5361 #endif //TO SUPPORT BT-AMP
5362 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5363
Chet Lanctot186b5732013-03-18 10:26:30 -07005364#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005365 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005366#endif
5367
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 // Now, we're ready to "pack" the frames
5369 nStatus = dot11fPackDelBAInd( pMac,
5370 &frmDelBAInd,
5371 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5372 nPayload,
5373 &nPayload );
5374
5375 if( DOT11F_FAILED( nStatus ))
5376 {
5377 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005378 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 nStatus );
5380
5381 // FIXME - Need to convert to tSirRetStatus
5382 statusCode = eSIR_FAILURE;
5383 goto returnAfterError;
5384 }
5385 else if( DOT11F_WARNED( nStatus ))
5386 {
5387 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005388 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5389 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 }
5391
5392 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005393 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5395
5396 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5398 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 )
5400 {
5401 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5402 }
5403
5404 if( eHAL_STATUS_SUCCESS !=
5405 (halStatus = halTxFrame( pMac,
5406 pPacket,
5407 (tANI_U16) frameLen,
5408 HAL_TXRX_FRM_802_11_MGMT,
5409 ANI_TXDIR_TODS,
5410 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5411 limTxComplete,
5412 pDelBAIndBuffer, txFlag )))
5413 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005414 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 statusCode = eSIR_FAILURE;
5416 //Pkt will be freed up by the callback
5417 return statusCode;
5418 }
5419 else
5420 return eSIR_SUCCESS;
5421
5422 returnAfterError:
5423
5424 // Release buffer, if allocated
5425 if( NULL != pDelBAIndBuffer )
5426 palPktFree( pMac->hHdd,
5427 HAL_TXRX_FRM_802_11_MGMT,
5428 (void *) pDelBAIndBuffer,
5429 (void *) pPacket );
5430
5431 return statusCode;
5432}
5433
5434#if defined WLAN_FEATURE_VOWIFI
5435
5436/**
5437 * \brief Send a Neighbor Report Request Action frame
5438 *
5439 *
5440 * \param pMac Pointer to the global MAC structure
5441 *
5442 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5443 *
5444 * \param peer mac address of peer station.
5445 *
5446 * \param psessionEntry address of session entry.
5447 *
5448 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5449 *
5450 *
5451 */
5452
5453tSirRetStatus
5454limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5455 tpSirMacNeighborReportReq pNeighborReq,
5456 tSirMacAddr peer,
5457 tpPESession psessionEntry
5458 )
5459{
5460 tSirRetStatus statusCode = eSIR_SUCCESS;
5461 tDot11fNeighborReportRequest frm;
5462 tANI_U8 *pFrame;
5463 tpSirMacMgmtHdr pMacHdr;
5464 tANI_U32 nBytes, nPayload, nStatus;
5465 void *pPacket;
5466 eHalStatus halstatus;
5467 tANI_U8 txFlag = 0;
5468
5469 if ( psessionEntry == NULL )
5470 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005471 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 return eSIR_FAILURE;
5473 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305474 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005475
5476 frm.Category.category = SIR_MAC_ACTION_RRM;
5477 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5478 frm.DialogToken.token = pNeighborReq->dialogToken;
5479
5480
5481 if( pNeighborReq->ssid_present )
5482 {
5483 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5484 }
5485
5486 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5487 if ( DOT11F_FAILED( nStatus ) )
5488 {
5489 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005490 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 nStatus );
5492 // We'll fall back on the worst case scenario:
5493 nPayload = sizeof( tDot11fNeighborReportRequest );
5494 }
5495 else if ( DOT11F_WARNED( nStatus ) )
5496 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005497 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005499 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 }
5501
5502 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5503
5504 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5505 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5506 {
5507 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005508 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 return eSIR_FAILURE;
5510 }
5511
5512 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305513 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005514
5515 // Copy necessary info to BD
5516 if( eSIR_SUCCESS !=
5517 (statusCode = limPopulateMacHeader( pMac,
5518 pFrame,
5519 SIR_MAC_MGMT_FRAME,
5520 SIR_MAC_MGMT_ACTION,
5521 peer, psessionEntry->selfMacAddr)))
5522 goto returnAfterError;
5523
5524 // Update A3 with the BSSID
5525 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5526
5527 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5528
Chet Lanctot186b5732013-03-18 10:26:30 -07005529#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005530 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005531#endif
5532
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 // Now, we're ready to "pack" the frames
5534 nStatus = dot11fPackNeighborReportRequest( pMac,
5535 &frm,
5536 pFrame + sizeof( tSirMacMgmtHdr ),
5537 nPayload,
5538 &nPayload );
5539
5540 if( DOT11F_FAILED( nStatus ))
5541 {
5542 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005543 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 nStatus );
5545
5546 // FIXME - Need to convert to tSirRetStatus
5547 statusCode = eSIR_FAILURE;
5548 goto returnAfterError;
5549 }
5550 else if( DOT11F_WARNED( nStatus ))
5551 {
5552 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005553 FL( "There were warnings while packing Neighbor Report "
5554 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 }
5556
5557 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005558 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 limPrintMacAddr( pMac, peer, LOGW );
5560
5561 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5563 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 )
5565 {
5566 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5567 }
5568
5569 if( eHAL_STATUS_SUCCESS !=
5570 (halstatus = halTxFrame( pMac,
5571 pPacket,
5572 (tANI_U16) nBytes,
5573 HAL_TXRX_FRM_802_11_MGMT,
5574 ANI_TXDIR_TODS,
5575 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5576 limTxComplete,
5577 pFrame, txFlag )))
5578 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005579 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 statusCode = eSIR_FAILURE;
5581 //Pkt will be freed up by the callback
5582 return statusCode;
5583 }
5584 else
5585 return eSIR_SUCCESS;
5586
5587returnAfterError:
5588 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5589
5590 return statusCode;
5591} // End limSendNeighborReportRequestFrame.
5592
5593/**
5594 * \brief Send a Link Report Action frame
5595 *
5596 *
5597 * \param pMac Pointer to the global MAC structure
5598 *
5599 * \param pLinkReport Address of a tSirMacLinkReport
5600 *
5601 * \param peer mac address of peer station.
5602 *
5603 * \param psessionEntry address of session entry.
5604 *
5605 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5606 *
5607 *
5608 */
5609
5610tSirRetStatus
5611limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5612 tpSirMacLinkReport pLinkReport,
5613 tSirMacAddr peer,
5614 tpPESession psessionEntry
5615 )
5616{
5617 tSirRetStatus statusCode = eSIR_SUCCESS;
5618 tDot11fLinkMeasurementReport frm;
5619 tANI_U8 *pFrame;
5620 tpSirMacMgmtHdr pMacHdr;
5621 tANI_U32 nBytes, nPayload, nStatus;
5622 void *pPacket;
5623 eHalStatus halstatus;
5624 tANI_U8 txFlag = 0;
5625
5626
5627 if ( psessionEntry == NULL )
5628 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005629 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 return eSIR_FAILURE;
5631 }
5632
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305633 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005634
5635 frm.Category.category = SIR_MAC_ACTION_RRM;
5636 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5637 frm.DialogToken.token = pLinkReport->dialogToken;
5638
5639
5640 //IEEE Std. 802.11 7.3.2.18. for the report element.
5641 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5642 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5643 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5644 //such case this way than changing the frame parser.
5645 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5646 frm.TPCEleLen.TPCLen = 2;
5647 frm.TxPower.txPower = pLinkReport->txPower;
5648 frm.LinkMargin.linkMargin = 0;
5649
5650 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5651 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5652 frm.RCPI.rcpi = pLinkReport->rcpi;
5653 frm.RSNI.rsni = pLinkReport->rsni;
5654
5655 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5656 if ( DOT11F_FAILED( nStatus ) )
5657 {
5658 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005659 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 nStatus );
5661 // We'll fall back on the worst case scenario:
5662 nPayload = sizeof( tDot11fLinkMeasurementReport );
5663 }
5664 else if ( DOT11F_WARNED( nStatus ) )
5665 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005666 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005668 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 }
5670
5671 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5672
5673 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5674 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5675 {
5676 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005677 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 return eSIR_FAILURE;
5679 }
5680
5681 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305682 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005683
5684 // Copy necessary info to BD
5685 if( eSIR_SUCCESS !=
5686 (statusCode = limPopulateMacHeader( pMac,
5687 pFrame,
5688 SIR_MAC_MGMT_FRAME,
5689 SIR_MAC_MGMT_ACTION,
5690 peer, psessionEntry->selfMacAddr)))
5691 goto returnAfterError;
5692
5693 // Update A3 with the BSSID
5694 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5695
5696 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5697
Chet Lanctot186b5732013-03-18 10:26:30 -07005698#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005699 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005700#endif
5701
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 // Now, we're ready to "pack" the frames
5703 nStatus = dot11fPackLinkMeasurementReport( pMac,
5704 &frm,
5705 pFrame + sizeof( tSirMacMgmtHdr ),
5706 nPayload,
5707 &nPayload );
5708
5709 if( DOT11F_FAILED( nStatus ))
5710 {
5711 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005712 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 nStatus );
5714
5715 // FIXME - Need to convert to tSirRetStatus
5716 statusCode = eSIR_FAILURE;
5717 goto returnAfterError;
5718 }
5719 else if( DOT11F_WARNED( nStatus ))
5720 {
5721 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005722 FL( "There were warnings while packing Link Report (0x%08x)." ),
5723 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 }
5725
5726 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005727 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 limPrintMacAddr( pMac, peer, LOGW );
5729
5730 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5732 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 )
5734 {
5735 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5736 }
5737
5738 if( eHAL_STATUS_SUCCESS !=
5739 (halstatus = halTxFrame( pMac,
5740 pPacket,
5741 (tANI_U16) nBytes,
5742 HAL_TXRX_FRM_802_11_MGMT,
5743 ANI_TXDIR_TODS,
5744 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5745 limTxComplete,
5746 pFrame, txFlag )))
5747 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005748 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 statusCode = eSIR_FAILURE;
5750 //Pkt will be freed up by the callback
5751 return statusCode;
5752 }
5753 else
5754 return eSIR_SUCCESS;
5755
5756returnAfterError:
5757 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5758
5759 return statusCode;
5760} // End limSendLinkReportActionFrame.
5761
5762/**
5763 * \brief Send a Beacon Report Action frame
5764 *
5765 *
5766 * \param pMac Pointer to the global MAC structure
5767 *
5768 * \param dialog_token dialog token to be used in the action frame.
5769 *
5770 * \param num_report number of reports in pRRMReport.
5771 *
5772 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5773 *
5774 * \param peer mac address of peer station.
5775 *
5776 * \param psessionEntry address of session entry.
5777 *
5778 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5779 *
5780 *
5781 */
5782
5783tSirRetStatus
5784limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5785 tANI_U8 dialog_token,
5786 tANI_U8 num_report,
5787 tpSirMacRadioMeasureReport pRRMReport,
5788 tSirMacAddr peer,
5789 tpPESession psessionEntry
5790 )
5791{
5792 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 tANI_U8 *pFrame;
5794 tpSirMacMgmtHdr pMacHdr;
5795 tANI_U32 nBytes, nPayload, nStatus;
5796 void *pPacket;
5797 eHalStatus halstatus;
5798 tANI_U8 i;
5799 tANI_U8 txFlag = 0;
5800
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005801 tDot11fRadioMeasurementReport *frm =
5802 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5803 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005804 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005805 return eSIR_FAILURE;
5806 }
5807
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 if ( psessionEntry == NULL )
5809 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005810 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005811 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 return eSIR_FAILURE;
5813 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305814 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005815
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005816 frm->Category.category = SIR_MAC_ACTION_RRM;
5817 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5818 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005819
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005820 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 -07005821
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005822 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005824 frm->MeasurementReport[i].type = pRRMReport[i].type;
5825 frm->MeasurementReport[i].token = pRRMReport[i].token;
5826 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 switch( pRRMReport[i].type )
5828 {
5829 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005830 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5831 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5832 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5833 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 break;
5835 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305836 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5837 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005838 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 break;
5840 }
5841 }
5842
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005843 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 if ( DOT11F_FAILED( nStatus ) )
5845 {
5846 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005847 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 nStatus );
5849 // We'll fall back on the worst case scenario:
5850 nPayload = sizeof( tDot11fLinkMeasurementReport );
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 }
5854 else if ( DOT11F_WARNED( nStatus ) )
5855 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005856 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005858 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 }
5860
5861 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5862
5863 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5864 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5865 {
5866 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005867 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005868 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 return eSIR_FAILURE;
5870 }
5871
5872 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305873 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005874
5875 // Copy necessary info to BD
5876 if( eSIR_SUCCESS !=
5877 (statusCode = limPopulateMacHeader( pMac,
5878 pFrame,
5879 SIR_MAC_MGMT_FRAME,
5880 SIR_MAC_MGMT_ACTION,
5881 peer, psessionEntry->selfMacAddr)))
5882 goto returnAfterError;
5883
5884 // Update A3 with the BSSID
5885 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5886
5887 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5888
Chet Lanctot186b5732013-03-18 10:26:30 -07005889#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005890 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005891#endif
5892
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 // Now, we're ready to "pack" the frames
5894 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005895 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 pFrame + sizeof( tSirMacMgmtHdr ),
5897 nPayload,
5898 &nPayload );
5899
5900 if( DOT11F_FAILED( nStatus ))
5901 {
5902 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005903 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005904 nStatus );
5905
5906 // FIXME - Need to convert to tSirRetStatus
5907 statusCode = eSIR_FAILURE;
5908 goto returnAfterError;
5909 }
5910 else if( DOT11F_WARNED( nStatus ))
5911 {
5912 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005913 FL( "There were warnings while packing Radio "
5914 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 }
5916
5917 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005918 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 limPrintMacAddr( pMac, peer, LOGW );
5920
5921 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5923 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 )
5925 {
5926 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5927 }
5928
5929 if( eHAL_STATUS_SUCCESS !=
5930 (halstatus = halTxFrame( pMac,
5931 pPacket,
5932 (tANI_U16) nBytes,
5933 HAL_TXRX_FRM_802_11_MGMT,
5934 ANI_TXDIR_TODS,
5935 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5936 limTxComplete,
5937 pFrame, txFlag )))
5938 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005939 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 statusCode = eSIR_FAILURE;
5941 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005942 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 return statusCode;
5944 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005945 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005946 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005949
5950returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005951 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 return statusCode;
5954} // End limSendBeaconReportActionFrame.
5955
5956#endif
5957
5958#ifdef WLAN_FEATURE_11W
5959/**
5960 * \brief Send SA query response action frame to peer
5961 *
5962 * \sa limSendSaQueryResponseFrame
5963 *
5964 *
5965 * \param pMac The global tpAniSirGlobal object
5966 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005967 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005969 * \param peer The Mac address of the AP to which this action frame is addressed
5970 *
5971 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 *
5973 * \return eSIR_SUCCESS if setup completes successfully
5974 * eSIR_FAILURE is some problem is encountered
5975 */
5976
Chet Lanctot186b5732013-03-18 10:26:30 -07005977tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005978tSirMacAddr peer,tpPESession psessionEntry)
5979{
5980
Chet Lanctot186b5732013-03-18 10:26:30 -07005981 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 tANI_U8 *pFrame;
5983 tSirRetStatus nSirStatus;
5984 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07005985 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 void *pPacket;
5987 eHalStatus halstatus;
Chet Lanctot186b5732013-03-18 10:26:30 -07005988 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005989
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305990 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07005991 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
5992 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 action: 0 --> SA query request action frame
5994 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07005995 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
5996 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07005998 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005999
Chet Lanctot186b5732013-03-18 10:26:30 -07006000 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6001 if ( DOT11F_FAILED( nStatus ) )
6002 {
6003 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6004 "or a SA Query Response (0x%08x)."),
6005 nStatus );
6006 // We'll fall back on the worst case scenario:
6007 nPayload = sizeof( tDot11fSaQueryRsp );
6008 }
6009 else if ( DOT11F_WARNED( nStatus ) )
6010 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006011 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006012 "the packed size for an SA Query Response"
6013 " (0x%08x)."), nStatus );
6014 }
6015
Jeff Johnson295189b2012-06-20 16:38:30 -07006016 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6017 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6018 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6019 {
6020 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006021 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 return eSIR_FAILURE;
6023 }
6024
6025 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306026 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006027
Chet Lanctot186b5732013-03-18 10:26:30 -07006028 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006029 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006030 pFrame,
6031 SIR_MAC_MGMT_FRAME,
6032 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006033 peer, psessionEntry->selfMacAddr );
6034 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006035 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006036
Chet Lanctot186b5732013-03-18 10:26:30 -07006037 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6039
Chet Lanctot186b5732013-03-18 10:26:30 -07006040 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006041
Chet Lanctot186b5732013-03-18 10:26:30 -07006042 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6043 // in the FC
6044 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006046 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 }
6048
Chet Lanctot186b5732013-03-18 10:26:30 -07006049 // Pack 11w SA query response frame
6050 nStatus = dot11fPackSaQueryRsp( pMac,
6051 &frm,
6052 pFrame + sizeof( tSirMacMgmtHdr ),
6053 nPayload,
6054 &nPayload );
6055
6056 if ( DOT11F_FAILED( nStatus ))
6057 {
6058 limLog( pMac, LOGE,
6059 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6060 nStatus );
6061 // FIXME - Need to convert to tSirRetStatus
6062 nSirStatus = eSIR_FAILURE;
6063 goto returnAfterError;
6064 }
6065 else if ( DOT11F_WARNED( nStatus ))
6066 {
6067 limLog( pMac, LOGW,
6068 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6069 nStatus);
6070 }
6071
6072 limLog( pMac, LOG1,
6073 FL( "Sending a SA Query Response to " ));
6074 limPrintMacAddr( pMac, peer, LOGW );
6075
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006076 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006077#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006078 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6079 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006080#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006081 )
6082 {
6083 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6084 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006085
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006086 halstatus = halTxFrame( pMac,
6087 pPacket,
6088 (tANI_U16) nBytes,
6089 HAL_TXRX_FRM_802_11_MGMT,
6090 ANI_TXDIR_TODS,
6091 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6092 limTxComplete,
6093 pFrame, txFlag );
6094 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006095 {
6096 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6097 nSirStatus = eSIR_FAILURE;
6098 //Pkt will be freed up by the callback
6099 return nSirStatus;
6100 }
6101 else {
6102 return eSIR_SUCCESS;
6103 }
6104
6105returnAfterError:
6106 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6107 return nSirStatus;
6108} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006109#endif