blob: ae401bd51c8918232a7cdbf40b79d6d0abb1e339 [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 /* For CCX Associations fill the CCX IEs */
2181 if (psessionEntry->isCCXconnection &&
2182 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002184#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002185 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002186#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302187 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 }
2189#endif
2190
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002191 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 if ( DOT11F_FAILED( nStatus ) )
2193 {
2194 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002195 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 nStatus );
2197 // We'll fall back on the worst case scenario:
2198 nPayload = sizeof( tDot11fAssocRequest );
2199 }
2200 else if ( DOT11F_WARNED( nStatus ) )
2201 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002202 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002204 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 }
2206
2207 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2208
2209 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2210 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2211 ( void** ) &pPacket );
2212 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2213 {
2214 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002215 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002216
2217 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002218 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002219
2220
2221 /* Update PE session id*/
2222 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2223
2224 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2225
2226 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2227 ( void* ) pFrame, ( void* ) pPacket );
2228
2229 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2230 ( tANI_U32* ) &mlmAssocCnf);
2231
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302232 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 return;
2234 }
2235
2236 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302237 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002238
2239 // Next, we fill out the buffer descriptor:
2240 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2241 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2242 if ( eSIR_SUCCESS != nSirStatus )
2243 {
2244 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002245 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 nSirStatus );
2247 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302248 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 return;
2250 }
2251
2252
2253 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002254 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 sizeof(tSirMacMgmtHdr),
2256 nPayload, &nPayload );
2257 if ( DOT11F_FAILED( nStatus ) )
2258 {
2259 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002260 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002261 nStatus );
2262 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2263 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302264 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 return;
2266 }
2267 else if ( DOT11F_WARNED( nStatus ) )
2268 {
2269 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002270 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 }
2272
2273 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002274 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 nBytes );)
2276 // limPrintMacAddr( pMac, bssid, LOG1 );
2277
2278 if( psessionEntry->assocReq != NULL )
2279 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302280 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 psessionEntry->assocReq = NULL;
2282 }
2283
2284 if( nAddIELen )
2285 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302286 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2287 pAddIE,
2288 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 nPayload += nAddIELen;
2290 }
2291
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302292 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2293 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 {
2295 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2296 }
2297 else
2298 {
2299 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302300 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002301 psessionEntry->assocReqLen = nPayload;
2302 }
2303
2304 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2306 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 )
2308 {
2309 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2310 }
2311
Ganesh K08bce952012-12-13 15:04:41 -08002312 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2313 {
2314 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2315 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002316
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2318 HAL_TXRX_FRM_802_11_MGMT,
2319 ANI_TXDIR_TODS,
2320 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2321 limTxComplete, pFrame, txFlag );
2322 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2323 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002324 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 halstatus );
2326 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302327 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 return;
2329 }
2330
2331 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302332 vos_mem_free(pMlmAssocReq);
2333 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002334 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002335} // End limSendAssocReqMgmtFrame
2336
2337
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002338#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002339/*------------------------------------------------------------------------------------
2340 *
2341 * Send Reassoc Req with FTIEs.
2342 *
2343 *-----------------------------------------------------------------------------------
2344 */
2345void
2346limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2347 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2348{
2349 static tDot11fReAssocRequest frm;
2350 tANI_U16 caps;
2351 tANI_U8 *pFrame;
2352 tSirRetStatus nSirStatus;
2353 tANI_U32 nBytes, nPayload, nStatus;
2354 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2355 void *pPacket;
2356 eHalStatus halstatus;
2357#if defined WLAN_FEATURE_VOWIFI
2358 tANI_U8 PowerCapsPopulated = FALSE;
2359#endif
2360 tANI_U16 ft_ies_length = 0;
2361 tANI_U8 *pBody;
2362 tANI_U16 nAddIELen;
2363 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002364#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 tANI_U8 *wpsIe = NULL;
2366#endif
2367 tANI_U8 txFlag = 0;
2368
2369 if (NULL == psessionEntry)
2370 {
2371 return;
2372 }
2373
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 /* check this early to avoid unncessary operation */
2375 if(NULL == psessionEntry->pLimReAssocReq)
2376 {
2377 return;
2378 }
2379 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2380 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002381 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2382 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002383
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302384 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
2386 caps = pMlmReassocReq->capabilityInfo;
2387 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2388 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2389#if defined(FEATURE_WLAN_WAPI)
2390 /* CR: 262463 :
2391 According to WAPI standard:
2392 7.3.1.4 Capability Information field
2393 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2394 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2395 Reassociation management frames. */
2396 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2397 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2398#endif
2399 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2400
2401 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2402
2403 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302404 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2406
2407 PopulateDot11fSSID2( pMac, &frm.SSID );
2408 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2409 &frm.SuppRates,psessionEntry);
2410
2411 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2412 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2413
2414 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2415 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2416
2417 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2418 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2419
2420 if ( psessionEntry->lim11hEnable &&
2421 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2422 {
2423#if defined WLAN_FEATURE_VOWIFI
2424 PowerCapsPopulated = TRUE;
2425
2426 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2427 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2428#endif
2429 }
2430
2431#if defined WLAN_FEATURE_VOWIFI
2432 if( pMac->rrm.rrmPEContext.rrmEnable &&
2433 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2434 {
2435 if (PowerCapsPopulated == FALSE)
2436 {
2437 PowerCapsPopulated = TRUE;
2438 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2439 }
2440 }
2441#endif
2442
2443 if ( fQosEnabled &&
2444 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2445 {
2446 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2447 }
2448
2449 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2450 &frm.ExtSuppRates, psessionEntry );
2451
2452#if defined WLAN_FEATURE_VOWIFI
2453 if( pMac->rrm.rrmPEContext.rrmEnable &&
2454 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2455 {
2456 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2457 }
2458#endif
2459
2460 // Ideally this should be enabled for 11r also. But 11r does
2461 // not follow the usual norm of using the Opaque object
2462 // for rsnie and fties. Instead we just add
2463 // the rsnie and fties at the end of the pack routine for 11r.
2464 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002465#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 //
2467 // The join request *should* contain zero or one of the WPA and RSN
2468 // IEs. The payload send along with the request is a
2469 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2470
2471 // typedef struct sSirRSNie
2472 // {
2473 // tANI_U16 length;
2474 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2475 // } tSirRSNie, *tpSirRSNie;
2476
2477 // So, we should be able to make the following two calls harmlessly,
2478 // since they do nothing if they don't find the given IE in the
2479 // bytestream with which they're provided.
2480
2481 // The net effect of this will be to faithfully transmit whatever
2482 // security IE is in the join request.
2483
2484 // *However*, if we're associating for the purpose of WPS
2485 // enrollment, and we've been configured to indicate that by
2486 // eliding the WPA or RSN IE, we just skip this:
2487 if (!psessionEntry->is11Rconnection)
2488 {
2489 if( nAddIELen && pAddIE )
2490 {
2491 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2492 }
2493 if ( NULL == wpsIe )
2494 {
2495 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2496 &frm.RSNOpaque );
2497 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2498 &frm.WPAOpaque );
2499 }
2500
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002501#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302502 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 {
2504 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2505 &frm.CCXCckmOpaque );
2506 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002507#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 }
2509
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002510#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302512 if (psessionEntry->isCCXconnection &&
2513 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002515#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002517#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302518 PopulateDot11fCCXVersion(&frm.CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302520#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002521#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002522
2523 // include WME EDCA IE as well
2524 if ( fWmeEnabled )
2525 {
2526 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2527 {
2528 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2529 }
2530
2531 if ( fWsmEnabled &&
2532 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2533 {
2534 PopulateDot11fWMMCaps( &frm.WMMCaps );
2535 }
2536#ifdef FEATURE_WLAN_CCX
2537 if (psessionEntry->isCCXconnection)
2538 {
2539 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2540
2541 // Populate the TSRS IE if TSPEC is included in the reassoc request
2542 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2543 {
2544 tANI_U32 phyMode;
2545 tSirMacCCXTSRSIE tsrsIE;
2546 limGetPhyMode(pMac, &phyMode, psessionEntry);
2547
2548 tsrsIE.tsid = 0;
2549 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2550 {
2551 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2552 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302553 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 {
2555 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2556 }
2557 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2558 }
2559 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302560#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 }
2562
Jeff Johnsone7245742012-09-05 17:12:55 -07002563 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 pMac->lim.htCapabilityPresentInBeacon)
2565 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002566 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 }
2568
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002569#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302570 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2571#if defined FEATURE_WLAN_CCX
2572 && !psessionEntry->isCCXconnection
2573#endif
2574 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002575 {
2576 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2577 }
2578#endif
2579
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2581 if ( DOT11F_FAILED( nStatus ) )
2582 {
2583 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002584 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 nStatus );
2586 // We'll fall back on the worst case scenario:
2587 nPayload = sizeof( tDot11fReAssocRequest );
2588 }
2589 else if ( DOT11F_WARNED( nStatus ) )
2590 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002591 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002593 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 }
2595
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002596 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002597
2598#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002599 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2601#endif
2602
2603#if defined WLAN_FEATURE_VOWIFI_11R
2604 if (psessionEntry->is11Rconnection)
2605 {
2606 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2607 }
2608#endif
2609
2610 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2611 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2612 ( void** ) &pPacket );
2613 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2614 {
2615 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002616 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002618 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 goto end;
2620 }
2621
2622 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302623 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002624
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002625#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002626 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002627#endif
2628 // Next, we fill out the buffer descriptor:
2629 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2630 SIR_MAC_MGMT_REASSOC_REQ,
2631 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2632 if ( eSIR_SUCCESS != nSirStatus )
2633 {
2634 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002635 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 nSirStatus );
2637 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2638 goto end;
2639 }
2640
2641
2642 // That done, pack the ReAssoc Request:
2643 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2644 sizeof(tSirMacMgmtHdr),
2645 nPayload, &nPayload );
2646 if ( DOT11F_FAILED( nStatus ) )
2647 {
2648 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002649 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 nStatus );
2651 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2652 goto end;
2653 }
2654 else if ( DOT11F_WARNED( nStatus ) )
2655 {
2656 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002657 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 }
2659
2660 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002661 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 nBytes, nPayload );)
2663 if( psessionEntry->assocReq != NULL )
2664 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302665 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 psessionEntry->assocReq = NULL;
2667 }
2668
2669 if( nAddIELen )
2670 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302671 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2672 pAddIE,
2673 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 nPayload += nAddIELen;
2675 }
2676
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302677 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2678 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 {
2680 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002681 }
2682 else
2683 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302685 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002688
2689 if (psessionEntry->is11Rconnection)
2690 {
2691 {
2692 int i = 0;
2693
2694 pBody = pFrame + nBytes;
2695 for (i=0; i<ft_ies_length; i++)
2696 {
2697 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2698 pBody++;
2699 }
2700 }
2701 }
2702
2703#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002704 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2705 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 (tANI_U8 *)pFrame,
2707 (nBytes + ft_ies_length));)
2708#endif
2709
2710
2711 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002712 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2713 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 )
2715 {
2716 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2717 }
2718
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002719 if( NULL != psessionEntry->assocReq )
2720 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302721 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002722 psessionEntry->assocReq = NULL;
2723 }
2724
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302725 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2726 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002727 {
2728 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002729 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002730 }
2731 else
2732 {
2733 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302734 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2735 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002736 psessionEntry->assocReqLen = (ft_ies_length);
2737 }
2738
2739
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2741 HAL_TXRX_FRM_802_11_MGMT,
2742 ANI_TXDIR_TODS,
2743 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2744 limTxComplete, pFrame, txFlag );
2745 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2746 {
2747 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002748 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 nSirStatus );
2750 //Pkt will be freed up by the callback
2751 goto end;
2752 }
2753
2754end:
2755 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302756 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 psessionEntry->pLimMlmReassocReq = NULL;
2758
2759}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002760
2761void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2762 tLimMlmReassocReq *pMlmReassocReq,
2763 tpPESession psessionEntry)
2764{
2765 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2766 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2767 if(NULL == pTmpMlmReassocReq)
2768 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302769 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2770 if ( NULL == pTmpMlmReassocReq ) goto end;
2771 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2772 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002773 }
2774
2775 // Prepare and send Reassociation request frame
2776 // start reassoc timer.
2777 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2778 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002779 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002780 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2781 != TX_SUCCESS)
2782 {
2783 // Could not start reassoc failure timer.
2784 // Log error
2785 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002786 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002787 // Return Reassoc confirm with
2788 // Resources Unavailable
2789 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2790 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2791 goto end;
2792 }
2793
2794 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2795 return;
2796
2797end:
2798 // Free up buffer allocated for reassocReq
2799 if (pMlmReassocReq != NULL)
2800 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302801 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002802 pMlmReassocReq = NULL;
2803 }
2804 if (pTmpMlmReassocReq != NULL)
2805 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302806 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002807 pTmpMlmReassocReq = NULL;
2808 }
2809 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2810 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2811 /* Update PE sessio Id*/
2812 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2813
2814 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2815}
2816
Jeff Johnson295189b2012-06-20 16:38:30 -07002817#endif /* WLAN_FEATURE_VOWIFI_11R */
2818
2819
2820void
2821limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2822 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2823{
2824 static tDot11fReAssocRequest frm;
2825 tANI_U16 caps;
2826 tANI_U8 *pFrame;
2827 tSirRetStatus nSirStatus;
2828 tANI_U32 nBytes, nPayload, nStatus;
2829 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2830 void *pPacket;
2831 eHalStatus halstatus;
2832 tANI_U16 nAddIELen;
2833 tANI_U8 *pAddIE;
2834 tANI_U8 *wpsIe = NULL;
2835 tANI_U8 txFlag = 0;
2836#if defined WLAN_FEATURE_VOWIFI
2837 tANI_U8 PowerCapsPopulated = FALSE;
2838#endif
2839
2840 if(NULL == psessionEntry)
2841 {
2842 return;
2843 }
2844
2845 /* check this early to avoid unncessary operation */
2846 if(NULL == psessionEntry->pLimReAssocReq)
2847 {
2848 return;
2849 }
2850 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2851 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2852
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302853 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002854
2855 caps = pMlmReassocReq->capabilityInfo;
2856 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2857 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2858#if defined(FEATURE_WLAN_WAPI)
2859 /* CR: 262463 :
2860 According to WAPI standard:
2861 7.3.1.4 Capability Information field
2862 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2863 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2864 Reassociation management frames. */
2865 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2866 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2867#endif
2868 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2869
2870 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2871
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302872 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2873 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002874
2875 PopulateDot11fSSID2( pMac, &frm.SSID );
2876 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2877 &frm.SuppRates,psessionEntry);
2878
2879 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2880 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2881
2882 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2883 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2884
2885 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2886 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2887
2888
2889 if ( psessionEntry->lim11hEnable &&
2890 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2891 {
2892#if defined WLAN_FEATURE_VOWIFI
2893 PowerCapsPopulated = TRUE;
2894 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2895 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2896#endif
2897 }
2898
2899#if defined WLAN_FEATURE_VOWIFI
2900 if( pMac->rrm.rrmPEContext.rrmEnable &&
2901 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2902 {
2903 if (PowerCapsPopulated == FALSE)
2904 {
2905 PowerCapsPopulated = TRUE;
2906 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2907 }
2908 }
2909#endif
2910
2911 if ( fQosEnabled &&
2912 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2913 {
2914 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2915 }
2916
2917 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2918 &frm.ExtSuppRates, psessionEntry );
2919
2920#if defined WLAN_FEATURE_VOWIFI
2921 if( pMac->rrm.rrmPEContext.rrmEnable &&
2922 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2923 {
2924 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2925 }
2926#endif
2927 // The join request *should* contain zero or one of the WPA and RSN
2928 // IEs. The payload send along with the request is a
2929 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2930
2931 // typedef struct sSirRSNie
2932 // {
2933 // tANI_U16 length;
2934 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2935 // } tSirRSNie, *tpSirRSNie;
2936
2937 // So, we should be able to make the following two calls harmlessly,
2938 // since they do nothing if they don't find the given IE in the
2939 // bytestream with which they're provided.
2940
2941 // The net effect of this will be to faithfully transmit whatever
2942 // security IE is in the join request.
2943
2944 // *However*, if we're associating for the purpose of WPS
2945 // enrollment, and we've been configured to indicate that by
2946 // eliding the WPA or RSN IE, we just skip this:
2947 if( nAddIELen && pAddIE )
2948 {
2949 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2950 }
2951 if ( NULL == wpsIe )
2952 {
2953 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2954 &frm.RSNOpaque );
2955 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2956 &frm.WPAOpaque );
2957#if defined(FEATURE_WLAN_WAPI)
2958 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2959 &frm.WAPIOpaque );
2960#endif // defined(FEATURE_WLAN_WAPI)
2961 }
2962
2963 // include WME EDCA IE as well
2964 if ( fWmeEnabled )
2965 {
2966 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2967 {
2968 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2969 }
2970
2971 if ( fWsmEnabled &&
2972 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2973 {
2974 PopulateDot11fWMMCaps( &frm.WMMCaps );
2975 }
2976 }
2977
Jeff Johnsone7245742012-09-05 17:12:55 -07002978 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 pMac->lim.htCapabilityPresentInBeacon)
2980 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002981 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002983#ifdef WLAN_FEATURE_11AC
2984 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002985 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002986 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002987 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002988 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07002989 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002990 }
2991#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002992
2993 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2994 if ( DOT11F_FAILED( nStatus ) )
2995 {
2996 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002997 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 nStatus );
2999 // We'll fall back on the worst case scenario:
3000 nPayload = sizeof( tDot11fReAssocRequest );
3001 }
3002 else if ( DOT11F_WARNED( nStatus ) )
3003 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003004 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003005 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003006 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 }
3008
3009 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3010
3011 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3012 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3013 ( void** ) &pPacket );
3014 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3015 {
3016 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003017 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003019 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 goto end;
3021 }
3022
3023 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303024 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003025
3026 // Next, we fill out the buffer descriptor:
3027 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3028 SIR_MAC_MGMT_REASSOC_REQ,
3029 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3030 if ( eSIR_SUCCESS != nSirStatus )
3031 {
3032 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003033 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 nSirStatus );
3035 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3036 goto end;
3037 }
3038
3039
3040 // That done, pack the Probe Request:
3041 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3042 sizeof(tSirMacMgmtHdr),
3043 nPayload, &nPayload );
3044 if ( DOT11F_FAILED( nStatus ) )
3045 {
3046 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003047 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 nStatus );
3049 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3050 goto end;
3051 }
3052 else if ( DOT11F_WARNED( nStatus ) )
3053 {
3054 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003055 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 }
3057
3058 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003059 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 nBytes );)
3061
3062 if( psessionEntry->assocReq != NULL )
3063 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303064 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 psessionEntry->assocReq = NULL;
3066 }
3067
3068 if( nAddIELen )
3069 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303070 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3071 pAddIE,
3072 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 nPayload += nAddIELen;
3074 }
3075
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303076 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3077 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 {
3079 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003080 }
3081 else
3082 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303084 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003087
3088 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3090 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 )
3092 {
3093 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3094 }
3095
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003096 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003097 {
3098 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3099 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003100
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3102 HAL_TXRX_FRM_802_11_MGMT,
3103 ANI_TXDIR_TODS,
3104 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3105 limTxComplete, pFrame, txFlag );
3106 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3107 {
3108 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003109 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 nSirStatus );
3111 //Pkt will be freed up by the callback
3112 goto end;
3113 }
3114
3115end:
3116 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303117 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 psessionEntry->pLimMlmReassocReq = NULL;
3119
3120} // limSendReassocReqMgmtFrame
3121
3122/**
3123 * \brief Send an Authentication frame
3124 *
3125 *
3126 * \param pMac Pointer to Global MAC structure
3127 *
3128 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3129 * to be sent
3130 *
3131 * \param peerMacAddr MAC address of the peer entity to which Authentication
3132 * frame is destined
3133 *
3134 * \param wepBit Indicates whether wep bit to be set in FC while sending
3135 * Authentication frame3
3136 *
3137 *
3138 * This function is called by limProcessMlmMessages(). Authentication frame
3139 * is formatted and sent when this function is called.
3140 *
3141 *
3142 */
3143
3144void
3145limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3146 tpSirMacAuthFrameBody pAuthFrameBody,
3147 tSirMacAddr peerMacAddr,
3148 tANI_U8 wepBit,
3149 tpPESession psessionEntry
3150 )
3151{
3152 tANI_U8 *pFrame, *pBody;
3153 tANI_U32 frameLen = 0, bodyLen = 0;
3154 tpSirMacMgmtHdr pMacHdr;
3155 tANI_U16 i;
3156 void *pPacket;
3157 eHalStatus halstatus;
3158 tANI_U8 txFlag = 0;
3159
3160 if(NULL == psessionEntry)
3161 {
3162 return;
3163 }
3164
3165 if (wepBit == LIM_WEP_IN_FC)
3166 {
3167 /// Auth frame3 to be sent with encrypted framebody
3168 /**
3169 * Allocate buffer for Authenticaton frame of size equal
3170 * to management frame header length plus 2 bytes each for
3171 * auth algorithm number, transaction number, status code,
3172 * 128 bytes for challenge text and 4 bytes each for
3173 * IV & ICV.
3174 */
3175
3176 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3177
3178 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3179 } // if (wepBit == LIM_WEP_IN_FC)
3180 else
3181 {
3182 switch (pAuthFrameBody->authTransactionSeqNumber)
3183 {
3184 case SIR_MAC_AUTH_FRAME_1:
3185 /**
3186 * Allocate buffer for Authenticaton frame of size
3187 * equal to management frame header length plus 2 bytes
3188 * each for auth algorithm number, transaction number
3189 * and status code.
3190 */
3191
3192 frameLen = sizeof(tSirMacMgmtHdr) +
3193 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3194 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3195
3196#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003197 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3198 {
3199 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003201 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003202 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003203 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003205 else
3206 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003207 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003208 frameLen += (2+SIR_MDIE_SIZE);
3209 }
3210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003211#endif
3212 break;
3213
3214 case SIR_MAC_AUTH_FRAME_2:
3215 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3216 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3217 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3218 {
3219 /**
3220 * Allocate buffer for Authenticaton frame of size
3221 * equal to management frame header length plus
3222 * 2 bytes each for auth algorithm number,
3223 * transaction number and status code.
3224 */
3225
3226 frameLen = sizeof(tSirMacMgmtHdr) +
3227 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3228 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3229 }
3230 else
3231 {
3232 // Shared Key algorithm with challenge text
3233 // to be sent
3234 /**
3235 * Allocate buffer for Authenticaton frame of size
3236 * equal to management frame header length plus
3237 * 2 bytes each for auth algorithm number,
3238 * transaction number, status code and 128 bytes
3239 * for challenge text.
3240 */
3241
3242 frameLen = sizeof(tSirMacMgmtHdr) +
3243 sizeof(tSirMacAuthFrame);
3244 bodyLen = sizeof(tSirMacAuthFrameBody);
3245 }
3246
3247 break;
3248
3249 case SIR_MAC_AUTH_FRAME_3:
3250 /// Auth frame3 to be sent without encrypted framebody
3251 /**
3252 * Allocate buffer for Authenticaton frame of size equal
3253 * to management frame header length plus 2 bytes each
3254 * for auth algorithm number, transaction number and
3255 * status code.
3256 */
3257
3258 frameLen = sizeof(tSirMacMgmtHdr) +
3259 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3260 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3261
3262 break;
3263
3264 case SIR_MAC_AUTH_FRAME_4:
3265 /**
3266 * Allocate buffer for Authenticaton frame of size equal
3267 * to management frame header length plus 2 bytes each
3268 * for auth algorithm number, transaction number and
3269 * status code.
3270 */
3271
3272 frameLen = sizeof(tSirMacMgmtHdr) +
3273 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3274 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3275
3276 break;
3277 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3278 } // end if (wepBit == LIM_WEP_IN_FC)
3279
3280
3281 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3282
3283 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3284 {
3285 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003286 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003287
3288 return;
3289 }
3290
3291 for (i = 0; i < frameLen; i++)
3292 pFrame[i] = 0;
3293
3294 // Prepare BD
3295 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3296 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3297 {
3298 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3299 return;
3300 }
3301
3302 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3303 pMacHdr->fc.wep = wepBit;
3304
3305 // Prepare BSSId
3306 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3307 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303308 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3309 (tANI_U8 *) psessionEntry->bssId,
3310 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 }
3312
3313 /// Prepare Authentication frame body
3314 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3315
3316 if (wepBit == LIM_WEP_IN_FC)
3317 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303318 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003319
3320 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003321 FL("*** Sending Auth seq# 3 status %d (%d) to"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 pAuthFrameBody->authStatusCode,
3323 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3324
3325 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3326 }
3327 else
3328 {
3329 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3330 pBody += sizeof(tANI_U16);
3331 bodyLen -= sizeof(tANI_U16);
3332
3333 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3334 pBody += sizeof(tANI_U16);
3335 bodyLen -= sizeof(tANI_U16);
3336
3337 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3338 pBody += sizeof(tANI_U16);
3339 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003340 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3341 sizeof (pAuthFrameBody->length) +
3342 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303343 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003344
3345#if defined WLAN_FEATURE_VOWIFI_11R
3346 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3347 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3348 {
3349
3350 {
3351 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3353 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003354#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3356 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3357 (tANI_U8 *)pBody,
3358 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003359#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003360 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3361 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003362 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3363 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003364 }
3365 }
3366 else
3367 {
3368 /* MDID attr is 54*/
3369 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003371 *pBody = SIR_MDIE_SIZE;
3372 pBody++;
3373 for(i=0;i<SIR_MDIE_SIZE;i++)
3374 {
3375 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3376 pBody++;
3377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 }
3379 }
3380 }
3381#endif
3382
3383 PELOG1(limLog(pMac, LOG1,
3384 FL("*** Sending Auth seq# %d status %d (%d) to "),
3385 pAuthFrameBody->authTransactionSeqNumber,
3386 pAuthFrameBody->authStatusCode,
3387 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3388
3389 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3390 }
3391 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3392
3393 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3395 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003396#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303397 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003398 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3399#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 )
3401 {
3402 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3403 }
3404
Ganesh K08bce952012-12-13 15:04:41 -08003405 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3406 {
3407 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3408 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003409
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 /// Queue Authentication frame in high priority WQ
3411 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3412 HAL_TXRX_FRM_802_11_MGMT,
3413 ANI_TXDIR_TODS,
3414 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3415 limTxComplete, pFrame, txFlag );
3416 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3417 {
3418 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003419 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 halstatus);
3421
3422 //Pkt will be freed up by the callback
3423 }
3424
3425 return;
3426} /*** end limSendAuthMgmtFrame() ***/
3427
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003428eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3429{
3430 tANI_U16 aid;
3431 tpDphHashNode pStaDs;
3432 tLimMlmDeauthReq *pMlmDeauthReq;
3433 tLimMlmDeauthCnf mlmDeauthCnf;
3434 tpPESession psessionEntry;
3435
3436 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3437 if (pMlmDeauthReq)
3438 {
3439 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3440 {
3441 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3442 }
3443
3444 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3445 {
3446
3447 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003448 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003449 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3450 goto end;
3451 }
3452
3453 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3454 if (pStaDs == NULL)
3455 {
3456 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3457 goto end;
3458 }
3459
3460
3461 /// Receive path cleanup with dummy packet
3462 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3463 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303464 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003465 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3466 }
3467 return eHAL_STATUS_SUCCESS;
3468end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303469 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003470 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3471 sizeof(tSirMacAddr));
3472 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3473 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3474 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3475
3476 // Free up buffer allocated
3477 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303478 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003479
3480 limPostSmeMessage(pMac,
3481 LIM_MLM_DEAUTH_CNF,
3482 (tANI_U32 *) &mlmDeauthCnf);
3483 return eHAL_STATUS_SUCCESS;
3484}
3485
3486eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3487{
3488 tANI_U16 aid;
3489 tpDphHashNode pStaDs;
3490 tLimMlmDisassocCnf mlmDisassocCnf;
3491 tpPESession psessionEntry;
3492 tLimMlmDisassocReq *pMlmDisassocReq;
3493
3494 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3495 if (pMlmDisassocReq)
3496 {
3497 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3498 {
3499 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3500 }
3501
3502 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3503 {
3504
3505 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003506 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003507 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3508 goto end;
3509 }
3510
3511 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3512 if (pStaDs == NULL)
3513 {
3514 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3515 goto end;
3516 }
3517
3518 /// Receive path cleanup with dummy packet
3519 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3520 {
3521 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3522 goto end;
3523 }
3524
3525#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003526 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303527 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003528#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303529 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003530#endif
3531#ifdef FEATURE_WLAN_LFR
3532 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003533#endif
3534 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303535 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003536 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003537 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303538 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003539 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003540 psessionEntry, psessionEntry->peSessionId););
3541 limFTCleanup(pMac);
3542 }
3543 else
3544 {
3545 PELOGE(limLog(pMac, LOGE,
3546 FL("No FT Preauth Session Cleanup in role %d"
3547#ifdef FEATURE_WLAN_CCX
3548 " isCCX %d"
3549#endif
3550#ifdef FEATURE_WLAN_LFR
3551 " isLFR %d"
3552#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003553 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003554 psessionEntry->limSystemRole,
3555#ifdef FEATURE_WLAN_CCX
3556 psessionEntry->isCCXconnection,
3557#endif
3558#ifdef FEATURE_WLAN_LFR
3559 psessionEntry->isFastRoamIniFeatureEnabled,
3560#endif
3561 psessionEntry->is11Rconnection,
3562 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003563 }
3564#endif
3565
3566 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303567 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003568 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3569 return eHAL_STATUS_SUCCESS;
3570 }
3571 else
3572 {
3573 return eHAL_STATUS_SUCCESS;
3574 }
3575end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303576 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003577 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3578 sizeof(tSirMacAddr));
3579 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3580 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3581
3582 /* Update PE session ID*/
3583 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3584
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003585 if(pMlmDisassocReq != NULL)
3586 {
3587 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303588 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003589 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3590 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003591
3592 limPostSmeMessage(pMac,
3593 LIM_MLM_DISASSOC_CNF,
3594 (tANI_U32 *) &mlmDisassocCnf);
3595 return eHAL_STATUS_SUCCESS;
3596}
3597
3598eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3599{
3600 return limSendDisassocCnf(pMac);
3601}
3602
3603eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3604{
3605 return limSendDeauthCnf(pMac);
3606}
3607
Jeff Johnson295189b2012-06-20 16:38:30 -07003608/**
3609 * \brief This function is called to send Disassociate frame.
3610 *
3611 *
3612 * \param pMac Pointer to Global MAC structure
3613 *
3614 * \param nReason Indicates the reason that need to be sent in
3615 * Disassociation frame
3616 *
3617 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3618 * sent
3619 *
3620 *
3621 */
3622
3623void
3624limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3625 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003626 tSirMacAddr peer,
3627 tpPESession psessionEntry,
3628 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003629{
3630 tDot11fDisassociation frm;
3631 tANI_U8 *pFrame;
3632 tSirRetStatus nSirStatus;
3633 tpSirMacMgmtHdr pMacHdr;
3634 tANI_U32 nBytes, nPayload, nStatus;
3635 void *pPacket;
3636 eHalStatus halstatus;
3637 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003638 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 if(NULL == psessionEntry)
3640 {
3641 return;
3642 }
3643
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303644 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003645
3646 frm.Reason.code = nReason;
3647
3648 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3649 if ( DOT11F_FAILED( nStatus ) )
3650 {
3651 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003652 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 nStatus );
3654 // We'll fall back on the worst case scenario:
3655 nPayload = sizeof( tDot11fDisassociation );
3656 }
3657 else if ( DOT11F_WARNED( nStatus ) )
3658 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003659 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003661 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 }
3663
3664 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3665
3666 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3667 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3668 ( void** ) &pPacket );
3669 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3670 {
3671 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003672 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003673 return;
3674 }
3675
3676 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303677 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003678
3679 // Next, we fill out the buffer descriptor:
3680 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3681 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3682 if ( eSIR_SUCCESS != nSirStatus )
3683 {
3684 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003685 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 nSirStatus );
3687 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3688 ( void* ) pFrame, ( void* ) pPacket );
3689 return; // just allocated...
3690 }
3691
3692 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3693
3694 // Prepare the BSSID
3695 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3696
Chet Lanctot186b5732013-03-18 10:26:30 -07003697#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003698 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003699#endif
3700
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3702 sizeof(tSirMacMgmtHdr),
3703 nPayload, &nPayload );
3704 if ( DOT11F_FAILED( nStatus ) )
3705 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003706 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 nStatus );
3708 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3709 ( void* ) pFrame, ( void* ) pPacket );
3710 return; // allocated!
3711 }
3712 else if ( DOT11F_WARNED( nStatus ) )
3713 {
3714 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003715 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 }
3717
3718 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003719 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3721
3722 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3724 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 )
3726 {
3727 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3728 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003729
Ganesh K08bce952012-12-13 15:04:41 -08003730 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3731 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3732 {
3733 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3734 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003735
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003736 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003738 // Queue Disassociation frame in high priority WQ
3739 /* get the duration from the request */
3740 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3741 HAL_TXRX_FRM_802_11_MGMT,
3742 ANI_TXDIR_TODS,
3743 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3744 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3745 txFlag );
3746 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003747
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003748 if (tx_timer_change(
3749 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3750 != TX_SUCCESS)
3751 {
3752 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003753 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003754 return;
3755 }
3756 else if(TX_SUCCESS != tx_timer_activate(
3757 &pMac->lim.limTimers.gLimDisassocAckTimer))
3758 {
3759 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003760 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003761 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3762 return;
3763 }
3764 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003765 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003766 {
3767 // Queue Disassociation frame in high priority WQ
3768 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3769 HAL_TXRX_FRM_802_11_MGMT,
3770 ANI_TXDIR_TODS,
3771 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3772 limTxComplete, pFrame, txFlag );
3773 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3774 {
3775 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003776 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003777 nSirStatus );
3778 //Pkt will be freed up by the callback
3779 return;
3780 }
3781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003782} // End limSendDisassocMgmtFrame.
3783
3784/**
3785 * \brief This function is called to send a Deauthenticate frame
3786 *
3787 *
3788 * \param pMac Pointer to global MAC structure
3789 *
3790 * \param nReason Indicates the reason that need to be sent in the
3791 * Deauthenticate frame
3792 *
3793 * \param peeer address of the STA to which the frame is to be sent
3794 *
3795 *
3796 */
3797
3798void
3799limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3800 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003801 tSirMacAddr peer,
3802 tpPESession psessionEntry,
3803 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003804{
3805 tDot11fDeAuth frm;
3806 tANI_U8 *pFrame;
3807 tSirRetStatus nSirStatus;
3808 tpSirMacMgmtHdr pMacHdr;
3809 tANI_U32 nBytes, nPayload, nStatus;
3810 void *pPacket;
3811 eHalStatus halstatus;
3812 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003813 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003814#ifdef FEATURE_WLAN_TDLS
3815 tANI_U16 aid;
3816 tpDphHashNode pStaDs;
3817#endif
3818
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 if(NULL == psessionEntry)
3820 {
3821 return;
3822 }
3823
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303824 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003825
3826 frm.Reason.code = nReason;
3827
3828 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3829 if ( DOT11F_FAILED( nStatus ) )
3830 {
3831 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003832 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 nStatus );
3834 // We'll fall back on the worst case scenario:
3835 nPayload = sizeof( tDot11fDeAuth );
3836 }
3837 else if ( DOT11F_WARNED( nStatus ) )
3838 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003839 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003841 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 }
3843
3844 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3845
3846 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3847 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3848 ( void** ) &pPacket );
3849 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3850 {
3851 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003852 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 return;
3854 }
3855
3856 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303857 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003858
3859 // Next, we fill out the buffer descriptor:
3860 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3861 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3862 if ( eSIR_SUCCESS != nSirStatus )
3863 {
3864 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003865 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 nSirStatus );
3867 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3868 ( void* ) pFrame, ( void* ) pPacket );
3869 return; // just allocated...
3870 }
3871
3872 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3873
3874 // Prepare the BSSID
3875 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3876
Chet Lanctot186b5732013-03-18 10:26:30 -07003877#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003878 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003879#endif
3880
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3882 sizeof(tSirMacMgmtHdr),
3883 nPayload, &nPayload );
3884 if ( DOT11F_FAILED( nStatus ) )
3885 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003886 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 nStatus );
3888 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3889 ( void* ) pFrame, ( void* ) pPacket );
3890 return;
3891 }
3892 else if ( DOT11F_WARNED( nStatus ) )
3893 {
3894 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003895 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 }
3897
3898 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003899 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3901
3902 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3904 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 )
3906 {
3907 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3908 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003909
Ganesh K08bce952012-12-13 15:04:41 -08003910 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3911 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3912 {
3913 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3914 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003915
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003916#ifdef FEATURE_WLAN_TDLS
3917 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3918#endif
3919
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003920 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003922 // Queue Disassociation frame in high priority WQ
3923 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3924 HAL_TXRX_FRM_802_11_MGMT,
3925 ANI_TXDIR_TODS,
3926 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3927 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
3928 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3929 {
3930 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003931 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003932 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003933 //Pkt will be freed up by the callback limTxComplete
3934
3935 /*Call limProcessDeauthAckTimeout which will send
3936 * DeauthCnf for this frame
3937 */
3938 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003939 return;
3940 }
3941
3942 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3943
3944 if (tx_timer_change(
3945 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3946 != TX_SUCCESS)
3947 {
3948 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003949 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003950 return;
3951 }
3952 else if(TX_SUCCESS != tx_timer_activate(
3953 &pMac->lim.limTimers.gLimDeauthAckTimer))
3954 {
3955 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003956 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003957 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3958 return;
3959 }
3960 }
3961 else
3962 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003963#ifdef FEATURE_WLAN_TDLS
3964 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
3965 {
3966 // Queue Disassociation frame in high priority WQ
3967 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003968 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003969 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003970 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3971 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003972 }
3973 else
3974 {
3975#endif
3976 // Queue Disassociation frame in high priority WQ
3977 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3978 HAL_TXRX_FRM_802_11_MGMT,
3979 ANI_TXDIR_TODS,
3980 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3981 limTxComplete, pFrame, txFlag );
3982#ifdef FEATURE_WLAN_TDLS
3983 }
3984#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003985 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3986 {
3987 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003988 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003989 nSirStatus );
3990 //Pkt will be freed up by the callback
3991 return;
3992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 }
3994
3995} // End limSendDeauthMgmtFrame.
3996
3997
3998#ifdef ANI_SUPPORT_11H
3999/**
4000 * \brief Send a Measurement Report Action frame
4001 *
4002 *
4003 * \param pMac Pointer to the global MAC structure
4004 *
4005 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4006 *
4007 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4008 *
4009 *
4010 */
4011
4012tSirRetStatus
4013limSendMeasReportFrame(tpAniSirGlobal pMac,
4014 tpSirMacMeasReqActionFrame pMeasReqFrame,
4015 tSirMacAddr peer)
4016{
4017 tDot11fMeasurementReport frm;
4018 tANI_U8 *pFrame;
4019 tSirRetStatus nSirStatus;
4020 tpSirMacMgmtHdr pMacHdr;
4021 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4022 void *pPacket;
4023 eHalStatus halstatus;
4024
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304025 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004026
4027 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4028 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4029 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4030
4031 switch ( pMeasReqFrame->measReqIE.measType )
4032 {
4033 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4034 nSirStatus =
4035 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4036 &frm.MeasurementReport );
4037 break;
4038 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4039 nSirStatus =
4040 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4041 &frm.MeasurementReport );
4042 break;
4043 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4044 nSirStatus =
4045 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4046 &frm.MeasurementReport );
4047 break;
4048 default:
4049 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004050 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 pMeasReqFrame->measReqIE.measType );
4052 return eSIR_FAILURE;
4053 }
4054
4055 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4056
4057 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4058 if ( DOT11F_FAILED( nStatus ) )
4059 {
4060 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004061 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 nStatus );
4063 // We'll fall back on the worst case scenario:
4064 nPayload = sizeof( tDot11fMeasurementReport );
4065 }
4066 else if ( DOT11F_WARNED( nStatus ) )
4067 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004068 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004070 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 }
4072
4073 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4074
4075 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4076 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4077 {
4078 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004079 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 return eSIR_FAILURE;
4081 }
4082
4083 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304084 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004085
4086 // Next, we fill out the buffer descriptor:
4087 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4088 SIR_MAC_MGMT_ACTION, peer);
4089 if ( eSIR_SUCCESS != nSirStatus )
4090 {
4091 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004092 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 nSirStatus );
4094 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4095 return eSIR_FAILURE; // just allocated...
4096 }
4097
4098 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4099
4100 nCfg = 6;
4101 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4102 if ( eSIR_SUCCESS != nSirStatus )
4103 {
4104 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004105 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 nSirStatus );
4107 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4108 return eSIR_FAILURE; // just allocated...
4109 }
4110
Chet Lanctot186b5732013-03-18 10:26:30 -07004111#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004112 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004113#endif
4114
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4116 sizeof(tSirMacMgmtHdr),
4117 nPayload, &nPayload );
4118 if ( DOT11F_FAILED( nStatus ) )
4119 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004120 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 nStatus );
4122 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4123 return eSIR_FAILURE; // allocated!
4124 }
4125 else if ( DOT11F_WARNED( nStatus ) )
4126 {
4127 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004128 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 }
4130
4131 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4132 HAL_TXRX_FRM_802_11_MGMT,
4133 ANI_TXDIR_TODS,
4134 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4135 limTxComplete, pFrame, 0 );
4136 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4137 {
4138 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004139 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 nSirStatus );
4141 //Pkt will be freed up by the callback
4142 return eSIR_FAILURE; // just allocated...
4143 }
4144
4145 return eSIR_SUCCESS;
4146
4147} // End limSendMeasReportFrame.
4148
4149
4150/**
4151 * \brief Send a TPC Request Action frame
4152 *
4153 *
4154 * \param pMac Pointer to the global MAC datastructure
4155 *
4156 * \param peer MAC address to which the frame should be sent
4157 *
4158 *
4159 */
4160
4161void
4162limSendTpcRequestFrame(tpAniSirGlobal pMac,
4163 tSirMacAddr peer)
4164{
4165 tDot11fTPCRequest frm;
4166 tANI_U8 *pFrame;
4167 tSirRetStatus nSirStatus;
4168 tpSirMacMgmtHdr pMacHdr;
4169 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4170 void *pPacket;
4171 eHalStatus halstatus;
4172
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304173 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004174
4175 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4176 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4177 frm.DialogToken.token = 1;
4178 frm.TPCRequest.present = 1;
4179
4180 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4181 if ( DOT11F_FAILED( nStatus ) )
4182 {
4183 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004184 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 nStatus );
4186 // We'll fall back on the worst case scenario:
4187 nPayload = sizeof( tDot11fTPCRequest );
4188 }
4189 else if ( DOT11F_WARNED( nStatus ) )
4190 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004191 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004193 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 }
4195
4196 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4197
4198 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4199 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4200 {
4201 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004202 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 return;
4204 }
4205
4206 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304207 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004208
4209 // Next, we fill out the buffer descriptor:
4210 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4211 SIR_MAC_MGMT_ACTION, peer);
4212 if ( eSIR_SUCCESS != nSirStatus )
4213 {
4214 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004215 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 nSirStatus );
4217 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4218 return; // just allocated...
4219 }
4220
4221 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4222
4223 nCfg = 6;
4224 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4225 if ( eSIR_SUCCESS != nSirStatus )
4226 {
4227 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004228 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 nSirStatus );
4230 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4231 return; // just allocated...
4232 }
4233
Chet Lanctot186b5732013-03-18 10:26:30 -07004234#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004235 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004236#endif
4237
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4239 sizeof(tSirMacMgmtHdr),
4240 nPayload, &nPayload );
4241 if ( DOT11F_FAILED( nStatus ) )
4242 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004243 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 nStatus );
4245 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4246 return; // allocated!
4247 }
4248 else if ( DOT11F_WARNED( nStatus ) )
4249 {
4250 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004251 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 }
4253
4254 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4255 HAL_TXRX_FRM_802_11_MGMT,
4256 ANI_TXDIR_TODS,
4257 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4258 limTxComplete, pFrame, 0 );
4259 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4260 {
4261 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004262 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 nSirStatus );
4264 //Pkt will be freed up by the callback
4265 return;
4266 }
4267
4268} // End limSendTpcRequestFrame.
4269
4270
4271/**
4272 * \brief Send a TPC Report Action frame
4273 *
4274 *
4275 * \param pMac Pointer to the global MAC datastructure
4276 *
4277 * \param pTpcReqFrame Pointer to the received TPC Request
4278 *
4279 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4280 *
4281 *
4282 */
4283
4284tSirRetStatus
4285limSendTpcReportFrame(tpAniSirGlobal pMac,
4286 tpSirMacTpcReqActionFrame pTpcReqFrame,
4287 tSirMacAddr peer)
4288{
4289 tDot11fTPCReport frm;
4290 tANI_U8 *pFrame;
4291 tSirRetStatus nSirStatus;
4292 tpSirMacMgmtHdr pMacHdr;
4293 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4294 void *pPacket;
4295 eHalStatus halstatus;
4296
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304297 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004298
4299 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4300 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4301 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4302
4303 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4304 // "misplaced this function, need to replace:
4305 // txPower = halGetRateToPwrValue(pMac, staid,
4306 // pMac->lim.gLimCurrentChannelId, 0);
4307 frm.TPCReport.tx_power = 0;
4308 frm.TPCReport.link_margin = 0;
4309 frm.TPCReport.present = 1;
4310
4311 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4312 if ( DOT11F_FAILED( nStatus ) )
4313 {
4314 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004315 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 nStatus );
4317 // We'll fall back on the worst case scenario:
4318 nPayload = sizeof( tDot11fTPCReport );
4319 }
4320 else if ( DOT11F_WARNED( nStatus ) )
4321 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004322 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004324 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 }
4326
4327 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4328
4329 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4330 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4331 {
4332 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004333 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 return eSIR_FAILURE;
4335 }
4336
4337 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304338 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004339
4340 // Next, we fill out the buffer descriptor:
4341 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4342 SIR_MAC_MGMT_ACTION, peer);
4343 if ( eSIR_SUCCESS != nSirStatus )
4344 {
4345 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004346 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 nSirStatus );
4348 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4349 return eSIR_FAILURE; // just allocated...
4350 }
4351
4352 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4353
4354 nCfg = 6;
4355 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4356 if ( eSIR_SUCCESS != nSirStatus )
4357 {
4358 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004359 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 nSirStatus );
4361 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4362 return eSIR_FAILURE; // just allocated...
4363 }
4364
Chet Lanctot186b5732013-03-18 10:26:30 -07004365#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004366 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004367#endif
4368
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4370 sizeof(tSirMacMgmtHdr),
4371 nPayload, &nPayload );
4372 if ( DOT11F_FAILED( nStatus ) )
4373 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004374 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 nStatus );
4376 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4377 return eSIR_FAILURE; // allocated!
4378 }
4379 else if ( DOT11F_WARNED( nStatus ) )
4380 {
4381 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004382 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 }
4384
4385
4386 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4387 HAL_TXRX_FRM_802_11_MGMT,
4388 ANI_TXDIR_TODS,
4389 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4390 limTxComplete, pFrame, 0 );
4391 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4392 {
4393 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004394 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 nSirStatus );
4396 //Pkt will be freed up by the callback
4397 return eSIR_FAILURE; // just allocated...
4398 }
4399
4400 return eSIR_SUCCESS;
4401
4402} // End limSendTpcReportFrame.
4403#endif //ANI_SUPPORT_11H
4404
4405
Jeff Johnson295189b2012-06-20 16:38:30 -07004406/**
4407 * \brief Send a Channel Switch Announcement
4408 *
4409 *
4410 * \param pMac Pointer to the global MAC datastructure
4411 *
4412 * \param peer MAC address to which this frame will be sent
4413 *
4414 * \param nMode
4415 *
4416 * \param nNewChannel
4417 *
4418 * \param nCount
4419 *
4420 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4421 *
4422 *
4423 */
4424
4425tSirRetStatus
4426limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4427 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004428 tANI_U8 nMode,
4429 tANI_U8 nNewChannel,
4430 tANI_U8 nCount,
4431 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004432{
4433 tDot11fChannelSwitch frm;
4434 tANI_U8 *pFrame;
4435 tSirRetStatus nSirStatus;
4436 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004437 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 void *pPacket;
4439 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004440 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004441
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304442 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004443
4444 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4445 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4446 frm.ChanSwitchAnn.switchMode = nMode;
4447 frm.ChanSwitchAnn.newChannel = nNewChannel;
4448 frm.ChanSwitchAnn.switchCount = nCount;
4449 frm.ChanSwitchAnn.present = 1;
4450
4451 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4452 if ( DOT11F_FAILED( nStatus ) )
4453 {
4454 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004455 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 nStatus );
4457 // We'll fall back on the worst case scenario:
4458 nPayload = sizeof( tDot11fChannelSwitch );
4459 }
4460 else if ( DOT11F_WARNED( nStatus ) )
4461 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004462 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004464 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 }
4466
4467 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4468
4469 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4470 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4471 {
4472 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004473 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 return eSIR_FAILURE;
4475 }
4476
4477 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304478 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004479
4480 // Next, we fill out the buffer descriptor:
4481 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004482 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4483 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304484 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4485 (tANI_U8 *) psessionEntry->bssId,
4486 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 if ( eSIR_SUCCESS != nSirStatus )
4488 {
4489 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004490 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 nSirStatus );
4492 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4493 return eSIR_FAILURE; // just allocated...
4494 }
4495
Jeff Johnsone7245742012-09-05 17:12:55 -07004496#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4498
4499 nCfg = 6;
4500 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4501 if ( eSIR_SUCCESS != nSirStatus )
4502 {
4503 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004504 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 nSirStatus );
4506 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4507 return eSIR_FAILURE; // just allocated...
4508 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004509#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004510
4511#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004512 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004513#endif
4514
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4516 sizeof(tSirMacMgmtHdr),
4517 nPayload, &nPayload );
4518 if ( DOT11F_FAILED( nStatus ) )
4519 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004520 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 nStatus );
4522 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4523 return eSIR_FAILURE; // allocated!
4524 }
4525 else if ( DOT11F_WARNED( nStatus ) )
4526 {
4527 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004528 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 }
4530
Jeff Johnsone7245742012-09-05 17:12:55 -07004531 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004532 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4533 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004534 )
4535 {
4536 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4539 HAL_TXRX_FRM_802_11_MGMT,
4540 ANI_TXDIR_TODS,
4541 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004542 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4544 {
4545 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004546 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 nSirStatus );
4548 //Pkt will be freed up by the callback
4549 return eSIR_FAILURE;
4550 }
4551
4552 return eSIR_SUCCESS;
4553
4554} // End limSendChannelSwitchMgmtFrame.
4555
Jeff Johnson295189b2012-06-20 16:38:30 -07004556
4557
Mohit Khanna4a70d262012-09-11 16:30:12 -07004558#ifdef WLAN_FEATURE_11AC
4559tSirRetStatus
4560limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4561 tSirMacAddr peer,
4562 tANI_U8 nMode,
4563 tpPESession psessionEntry )
4564{
4565 tDot11fOperatingMode frm;
4566 tANI_U8 *pFrame;
4567 tSirRetStatus nSirStatus;
4568 tpSirMacMgmtHdr pMacHdr;
4569 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4570 void *pPacket;
4571 eHalStatus halstatus;
4572 tANI_U8 txFlag = 0;
4573
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304574 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004575
4576 frm.Category.category = SIR_MAC_ACTION_VHT;
4577 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4578 frm.OperatingMode.chanWidth = nMode;
4579 frm.OperatingMode.rxNSS = 0;
4580 frm.OperatingMode.rxNSSType = 0;
4581
4582 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4583 if ( DOT11F_FAILED( nStatus ) )
4584 {
4585 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004586 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004587 nStatus );
4588 // We'll fall back on the worst case scenario:
4589 nPayload = sizeof( tDot11fOperatingMode);
4590 }
4591 else if ( DOT11F_WARNED( nStatus ) )
4592 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004593 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004594 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004595 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004596 }
4597
4598 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4599
4600 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4601 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4602 {
4603 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004604 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004605 return eSIR_FAILURE;
4606 }
4607
4608 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304609 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004610
4611
4612 // Next, we fill out the buffer descriptor:
4613 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4614 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4615 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4616 } else
4617 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4618 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4619 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304620 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4621 (tANI_U8 *) psessionEntry->bssId,
4622 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004623 if ( eSIR_SUCCESS != nSirStatus )
4624 {
4625 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004626 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004627 nSirStatus );
4628 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4629 return eSIR_FAILURE; // just allocated...
4630 }
4631 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4632 sizeof(tSirMacMgmtHdr),
4633 nPayload, &nPayload );
4634 if ( DOT11F_FAILED( nStatus ) )
4635 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004636 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004637 nStatus );
4638 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4639 return eSIR_FAILURE; // allocated!
4640 }
4641 else if ( DOT11F_WARNED( nStatus ) )
4642 {
4643 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004644 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004645 }
4646 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004647 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4648 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004649 )
4650 {
4651 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4652 }
4653 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4654 HAL_TXRX_FRM_802_11_MGMT,
4655 ANI_TXDIR_TODS,
4656 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4657 limTxComplete, pFrame, txFlag );
4658 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4659 {
4660 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004661 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004662 nSirStatus );
4663 //Pkt will be freed up by the callback
4664 return eSIR_FAILURE;
4665 }
4666
4667 return eSIR_SUCCESS;
4668}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004669
4670/**
4671 * \brief Send a VHT Channel Switch Announcement
4672 *
4673 *
4674 * \param pMac Pointer to the global MAC datastructure
4675 *
4676 * \param peer MAC address to which this frame will be sent
4677 *
4678 * \param nChanWidth
4679 *
4680 * \param nNewChannel
4681 *
4682 *
4683 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4684 *
4685 *
4686 */
4687
4688tSirRetStatus
4689limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4690 tSirMacAddr peer,
4691 tANI_U8 nChanWidth,
4692 tANI_U8 nNewChannel,
4693 tANI_U8 ncbMode,
4694 tpPESession psessionEntry )
4695{
4696 tDot11fChannelSwitch frm;
4697 tANI_U8 *pFrame;
4698 tSirRetStatus nSirStatus;
4699 tpSirMacMgmtHdr pMacHdr;
4700 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4701 void *pPacket;
4702 eHalStatus halstatus;
4703 tANI_U8 txFlag = 0;
4704
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304705 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004706
4707
4708 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4709 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4710 frm.ChanSwitchAnn.switchMode = 1;
4711 frm.ChanSwitchAnn.newChannel = nNewChannel;
4712 frm.ChanSwitchAnn.switchCount = 1;
4713 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4714 frm.ExtChanSwitchAnn.present = 1;
4715 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4716 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4717 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4718 frm.ChanSwitchAnn.present = 1;
4719 frm.WiderBWChanSwitchAnn.present = 1;
4720
4721 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4722 if ( DOT11F_FAILED( nStatus ) )
4723 {
4724 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004725 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004726 nStatus );
4727 // We'll fall back on the worst case scenario:
4728 nPayload = sizeof( tDot11fChannelSwitch );
4729 }
4730 else if ( DOT11F_WARNED( nStatus ) )
4731 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004732 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004733 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004734 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004735 }
4736
4737 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4738
4739 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4740 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4741 {
4742 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004743 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004744 return eSIR_FAILURE;
4745 }
4746 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304747 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004748
4749 // Next, we fill out the buffer descriptor:
4750 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4751 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4752 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304753 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4754 (tANI_U8 *) psessionEntry->bssId,
4755 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004756 if ( eSIR_SUCCESS != nSirStatus )
4757 {
4758 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004759 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004760 nSirStatus );
4761 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4762 return eSIR_FAILURE; // just allocated...
4763 }
4764 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4765 sizeof(tSirMacMgmtHdr),
4766 nPayload, &nPayload );
4767 if ( DOT11F_FAILED( nStatus ) )
4768 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004769 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004770 nStatus );
4771 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4772 return eSIR_FAILURE; // allocated!
4773 }
4774 else if ( DOT11F_WARNED( nStatus ) )
4775 {
4776 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004777 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004778 }
4779
4780 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004781 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4782 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004783 )
4784 {
4785 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4786 }
4787 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4788 HAL_TXRX_FRM_802_11_MGMT,
4789 ANI_TXDIR_TODS,
4790 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4791 limTxComplete, pFrame, txFlag );
4792 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4793 {
4794 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004795 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004796 nSirStatus );
4797 //Pkt will be freed up by the callback
4798 return eSIR_FAILURE;
4799 }
4800
4801 return eSIR_SUCCESS;
4802
4803} // End limSendVHTChannelSwitchMgmtFrame.
4804
4805
4806
Mohit Khanna4a70d262012-09-11 16:30:12 -07004807#endif
4808
Jeff Johnson295189b2012-06-20 16:38:30 -07004809/**
4810 * \brief Send an ADDBA Req Action Frame to peer
4811 *
4812 * \sa limSendAddBAReq
4813 *
4814 * \param pMac The global tpAniSirGlobal object
4815 *
4816 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4817 * the necessary parameters reqd by PE send the ADDBA Req Action
4818 * Frame to the peer
4819 *
4820 * \return eSIR_SUCCESS if setup completes successfully
4821 * eSIR_FAILURE is some problem is encountered
4822 */
4823tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304824 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004825{
4826 tDot11fAddBAReq frmAddBAReq;
4827 tANI_U8 *pAddBAReqBuffer = NULL;
4828 tpSirMacMgmtHdr pMacHdr;
4829 tANI_U32 frameLen = 0, nStatus, nPayload;
4830 tSirRetStatus statusCode;
4831 eHalStatus halStatus;
4832 void *pPacket;
4833 tANI_U8 txFlag = 0;
4834
4835 if(NULL == psessionEntry)
4836 {
4837 return eSIR_FAILURE;
4838 }
4839
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304840 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004841
4842 // Category - 3 (BA)
4843 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4844
4845 // Action - 0 (ADDBA Req)
4846 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4847
4848 // FIXME - Dialog Token, generalize this...
4849 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4850
4851 // Fill the ADDBA Parameter Set
4852 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4853 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4854 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4855
4856 // BA timeout
4857 // 0 - indicates no BA timeout
4858 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4859
4860 // BA Starting Sequence Number
4861 // Fragment number will always be zero
4862 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4863 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4864 }
4865
4866 frmAddBAReq.BAStartingSequenceControl.ssn =
4867 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4868
4869 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4870
4871 if( DOT11F_FAILED( nStatus ))
4872 {
4873 limLog( pMac, LOGW,
4874 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004875 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 nStatus );
4877
4878 // We'll fall back on the worst case scenario:
4879 nPayload = sizeof( tDot11fAddBAReq );
4880 }
4881 else if( DOT11F_WARNED( nStatus ))
4882 {
4883 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004884 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004885 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 nStatus );
4887 }
4888
4889 // Add the MGMT header to frame length
4890 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4891
4892 // Need to allocate a buffer for ADDBA AF
4893 if( eHAL_STATUS_SUCCESS !=
4894 (halStatus = palPktAlloc( pMac->hHdd,
4895 HAL_TXRX_FRM_802_11_MGMT,
4896 (tANI_U16) frameLen,
4897 (void **) &pAddBAReqBuffer,
4898 (void **) &pPacket )))
4899 {
4900 // Log error
4901 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004902 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 frameLen,
4904 halStatus );
4905
4906 statusCode = eSIR_MEM_ALLOC_FAILED;
4907 goto returnAfterError;
4908 }
4909
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304910 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004911
4912 // Copy necessary info to BD
4913 if( eSIR_SUCCESS !=
4914 (statusCode = limPopulateMacHeader( pMac,
4915 pAddBAReqBuffer,
4916 SIR_MAC_MGMT_FRAME,
4917 SIR_MAC_MGMT_ACTION,
4918 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4919 goto returnAfterError;
4920
4921 // Update A3 with the BSSID
4922 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4923
4924 #if 0
4925 cfgLen = SIR_MAC_ADDR_LENGTH;
4926 if( eSIR_SUCCESS != cfgGetStr( pMac,
4927 WNI_CFG_BSSID,
4928 (tANI_U8 *) pMacHdr->bssId,
4929 &cfgLen ))
4930 {
4931 limLog( pMac, LOGP,
4932 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004933 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004934
4935 // FIXME - Need to convert to tSirRetStatus
4936 statusCode = eSIR_FAILURE;
4937 goto returnAfterError;
4938 }
4939 #endif//TO SUPPORT BT-AMP
4940 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4941
Chet Lanctot186b5732013-03-18 10:26:30 -07004942#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004943 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004944#endif
4945
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 // Now, we're ready to "pack" the frames
4947 nStatus = dot11fPackAddBAReq( pMac,
4948 &frmAddBAReq,
4949 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4950 nPayload,
4951 &nPayload );
4952
4953 if( DOT11F_FAILED( nStatus ))
4954 {
4955 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004956 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 nStatus );
4958
4959 // FIXME - Need to convert to tSirRetStatus
4960 statusCode = eSIR_FAILURE;
4961 goto returnAfterError;
4962 }
4963 else if( DOT11F_WARNED( nStatus ))
4964 {
4965 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004966 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
4967 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 }
4969
4970 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004971 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4973
4974 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4976 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 )
4978 {
4979 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4980 }
4981
4982 if( eHAL_STATUS_SUCCESS !=
4983 (halStatus = halTxFrame( pMac,
4984 pPacket,
4985 (tANI_U16) frameLen,
4986 HAL_TXRX_FRM_802_11_MGMT,
4987 ANI_TXDIR_TODS,
4988 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4989 limTxComplete,
4990 pAddBAReqBuffer, txFlag )))
4991 {
4992 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004993 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 halStatus );
4995
4996 // FIXME - Need to convert eHalStatus to tSirRetStatus
4997 statusCode = eSIR_FAILURE;
4998 //Pkt will be freed up by the callback
4999 return statusCode;
5000 }
5001 else
5002 return eSIR_SUCCESS;
5003
5004returnAfterError:
5005
5006 // Release buffer, if allocated
5007 if( NULL != pAddBAReqBuffer )
5008 palPktFree( pMac->hHdd,
5009 HAL_TXRX_FRM_802_11_MGMT,
5010 (void *) pAddBAReqBuffer,
5011 (void *) pPacket );
5012
5013 return statusCode;
5014}
5015
5016/**
5017 * \brief Send an ADDBA Rsp Action Frame to peer
5018 *
5019 * \sa limSendAddBARsp
5020 *
5021 * \param pMac The global tpAniSirGlobal object
5022 *
5023 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5024 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5025 * Frame to the peer
5026 *
5027 * \return eSIR_SUCCESS if setup completes successfully
5028 * eSIR_FAILURE is some problem is encountered
5029 */
5030tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5031 tpLimMlmAddBARsp pMlmAddBARsp,
5032 tpPESession psessionEntry)
5033{
5034 tDot11fAddBARsp frmAddBARsp;
5035 tANI_U8 *pAddBARspBuffer = NULL;
5036 tpSirMacMgmtHdr pMacHdr;
5037 tANI_U32 frameLen = 0, nStatus, nPayload;
5038 tSirRetStatus statusCode;
5039 eHalStatus halStatus;
5040 void *pPacket;
5041 tANI_U8 txFlag = 0;
5042
5043 if(NULL == psessionEntry)
5044 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005045 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005046 return eSIR_FAILURE;
5047 }
5048
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305049 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005050
5051 // Category - 3 (BA)
5052 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5053 // Action - 1 (ADDBA Rsp)
5054 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5055
5056 // Should be same as the one we received in the ADDBA Req
5057 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5058
5059 // ADDBA Req status
5060 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5061
5062 // Fill the ADDBA Parameter Set as provided by caller
5063 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5064 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5065 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005066
5067 if(psessionEntry->isAmsduSupportInAMPDU)
5068 {
5069 frmAddBARsp.AddBAParameterSet.amsduSupported =
5070 psessionEntry->amsduSupportedInBA;
5071 }
5072 else
5073 {
5074 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005076
5077 // BA timeout
5078 // 0 - indicates no BA timeout
5079 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5080
5081 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5082
5083 if( DOT11F_FAILED( nStatus ))
5084 {
5085 limLog( pMac, LOGW,
5086 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005087 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 nStatus );
5089
5090 // We'll fall back on the worst case scenario:
5091 nPayload = sizeof( tDot11fAddBARsp );
5092 }
5093 else if( DOT11F_WARNED( nStatus ))
5094 {
5095 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005096 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005097 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 nStatus );
5099 }
5100
5101 // Need to allocate a buffer for ADDBA AF
5102 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5103
5104 // Allocate shared memory
5105 if( eHAL_STATUS_SUCCESS !=
5106 (halStatus = palPktAlloc( pMac->hHdd,
5107 HAL_TXRX_FRM_802_11_MGMT,
5108 (tANI_U16) frameLen,
5109 (void **) &pAddBARspBuffer,
5110 (void **) &pPacket )))
5111 {
5112 // Log error
5113 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005114 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 frameLen,
5116 halStatus );
5117
5118 statusCode = eSIR_MEM_ALLOC_FAILED;
5119 goto returnAfterError;
5120 }
5121
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305122 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005123
5124 // Copy necessary info to BD
5125 if( eSIR_SUCCESS !=
5126 (statusCode = limPopulateMacHeader( pMac,
5127 pAddBARspBuffer,
5128 SIR_MAC_MGMT_FRAME,
5129 SIR_MAC_MGMT_ACTION,
5130 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5131 goto returnAfterError;
5132
5133 // Update A3 with the BSSID
5134
5135 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5136
5137 #if 0
5138 cfgLen = SIR_MAC_ADDR_LENGTH;
5139 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5140 WNI_CFG_BSSID,
5141 (tANI_U8 *) pMacHdr->bssId,
5142 &cfgLen ))
5143 {
5144 limLog( pMac, LOGP,
5145 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005146 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005147
5148 // FIXME - Need to convert to tSirRetStatus
5149 statusCode = eSIR_FAILURE;
5150 goto returnAfterError;
5151 }
5152 #endif // TO SUPPORT BT-AMP
5153 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5154
Chet Lanctot186b5732013-03-18 10:26:30 -07005155#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005156 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005157#endif
5158
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 // Now, we're ready to "pack" the frames
5160 nStatus = dot11fPackAddBARsp( pMac,
5161 &frmAddBARsp,
5162 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5163 nPayload,
5164 &nPayload );
5165
5166 if( DOT11F_FAILED( nStatus ))
5167 {
5168 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005169 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 nStatus );
5171
5172 // FIXME - Need to convert to tSirRetStatus
5173 statusCode = eSIR_FAILURE;
5174 goto returnAfterError;
5175 }
5176 else if( DOT11F_WARNED( nStatus ))
5177 {
5178 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005179 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5180 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005181 }
5182
5183 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005184 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5186
5187 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005188 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5189 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 )
5191 {
5192 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5193 }
5194
5195 if( eHAL_STATUS_SUCCESS !=
5196 (halStatus = halTxFrame( pMac,
5197 pPacket,
5198 (tANI_U16) frameLen,
5199 HAL_TXRX_FRM_802_11_MGMT,
5200 ANI_TXDIR_TODS,
5201 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5202 limTxComplete,
5203 pAddBARspBuffer, txFlag )))
5204 {
5205 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005206 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 halStatus );
5208
5209 // FIXME - HAL error codes are different from PE error
5210 // codes!! And, this routine is returning tSirRetStatus
5211 statusCode = eSIR_FAILURE;
5212 //Pkt will be freed up by the callback
5213 return statusCode;
5214 }
5215 else
5216 return eSIR_SUCCESS;
5217
5218 returnAfterError:
5219
5220 // Release buffer, if allocated
5221 if( NULL != pAddBARspBuffer )
5222 palPktFree( pMac->hHdd,
5223 HAL_TXRX_FRM_802_11_MGMT,
5224 (void *) pAddBARspBuffer,
5225 (void *) pPacket );
5226
5227 return statusCode;
5228}
5229
5230/**
5231 * \brief Send a DELBA Indication Action Frame to peer
5232 *
5233 * \sa limSendDelBAInd
5234 *
5235 * \param pMac The global tpAniSirGlobal object
5236 *
5237 * \param peerMacAddr MAC Address of peer
5238 *
5239 * \param reasonCode Reason for the DELBA notification
5240 *
5241 * \param pBAParameterSet The DELBA Parameter Set.
5242 * This identifies the TID for which the BA session is
5243 * being deleted.
5244 *
5245 * \return eSIR_SUCCESS if setup completes successfully
5246 * eSIR_FAILURE is some problem is encountered
5247 */
5248tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5249 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5250{
5251 tDot11fDelBAInd frmDelBAInd;
5252 tANI_U8 *pDelBAIndBuffer = NULL;
5253 //tANI_U32 val;
5254 tpSirMacMgmtHdr pMacHdr;
5255 tANI_U32 frameLen = 0, nStatus, nPayload;
5256 tSirRetStatus statusCode;
5257 eHalStatus halStatus;
5258 void *pPacket;
5259 tANI_U8 txFlag = 0;
5260
5261 if(NULL == psessionEntry)
5262 {
5263 return eSIR_FAILURE;
5264 }
5265
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305266 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005267
5268 // Category - 3 (BA)
5269 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5270 // Action - 2 (DELBA)
5271 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5272
5273 // Fill the DELBA Parameter Set as provided by caller
5274 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5275 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5276
5277 // BA Starting Sequence Number
5278 // Fragment number will always be zero
5279 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5280
5281 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5282
5283 if( DOT11F_FAILED( nStatus ))
5284 {
5285 limLog( pMac, LOGW,
5286 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005287 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 nStatus );
5289
5290 // We'll fall back on the worst case scenario:
5291 nPayload = sizeof( tDot11fDelBAInd );
5292 }
5293 else if( DOT11F_WARNED( nStatus ))
5294 {
5295 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005296 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005297 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 nStatus );
5299 }
5300
5301 // Add the MGMT header to frame length
5302 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5303
5304 // Allocate shared memory
5305 if( eHAL_STATUS_SUCCESS !=
5306 (halStatus = palPktAlloc( pMac->hHdd,
5307 HAL_TXRX_FRM_802_11_MGMT,
5308 (tANI_U16) frameLen,
5309 (void **) &pDelBAIndBuffer,
5310 (void **) &pPacket )))
5311 {
5312 // Log error
5313 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005314 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 frameLen,
5316 halStatus );
5317
5318 statusCode = eSIR_MEM_ALLOC_FAILED;
5319 goto returnAfterError;
5320 }
5321
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305322 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005323
5324 // Copy necessary info to BD
5325 if( eSIR_SUCCESS !=
5326 (statusCode = limPopulateMacHeader( pMac,
5327 pDelBAIndBuffer,
5328 SIR_MAC_MGMT_FRAME,
5329 SIR_MAC_MGMT_ACTION,
5330 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5331 goto returnAfterError;
5332
5333 // Update A3 with the BSSID
5334 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5335
5336 #if 0
5337 cfgLen = SIR_MAC_ADDR_LENGTH;
5338 if( eSIR_SUCCESS != cfgGetStr( pMac,
5339 WNI_CFG_BSSID,
5340 (tANI_U8 *) pMacHdr->bssId,
5341 &cfgLen ))
5342 {
5343 limLog( pMac, LOGP,
5344 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005345 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005346
5347 // FIXME - Need to convert to tSirRetStatus
5348 statusCode = eSIR_FAILURE;
5349 goto returnAfterError;
5350 }
5351 #endif //TO SUPPORT BT-AMP
5352 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5353
Chet Lanctot186b5732013-03-18 10:26:30 -07005354#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005355 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005356#endif
5357
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 // Now, we're ready to "pack" the frames
5359 nStatus = dot11fPackDelBAInd( pMac,
5360 &frmDelBAInd,
5361 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5362 nPayload,
5363 &nPayload );
5364
5365 if( DOT11F_FAILED( nStatus ))
5366 {
5367 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005368 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 nStatus );
5370
5371 // FIXME - Need to convert to tSirRetStatus
5372 statusCode = eSIR_FAILURE;
5373 goto returnAfterError;
5374 }
5375 else if( DOT11F_WARNED( nStatus ))
5376 {
5377 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005378 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5379 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 }
5381
5382 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005383 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5385
5386 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5388 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 )
5390 {
5391 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5392 }
5393
5394 if( eHAL_STATUS_SUCCESS !=
5395 (halStatus = halTxFrame( pMac,
5396 pPacket,
5397 (tANI_U16) frameLen,
5398 HAL_TXRX_FRM_802_11_MGMT,
5399 ANI_TXDIR_TODS,
5400 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5401 limTxComplete,
5402 pDelBAIndBuffer, txFlag )))
5403 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005404 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 statusCode = eSIR_FAILURE;
5406 //Pkt will be freed up by the callback
5407 return statusCode;
5408 }
5409 else
5410 return eSIR_SUCCESS;
5411
5412 returnAfterError:
5413
5414 // Release buffer, if allocated
5415 if( NULL != pDelBAIndBuffer )
5416 palPktFree( pMac->hHdd,
5417 HAL_TXRX_FRM_802_11_MGMT,
5418 (void *) pDelBAIndBuffer,
5419 (void *) pPacket );
5420
5421 return statusCode;
5422}
5423
5424#if defined WLAN_FEATURE_VOWIFI
5425
5426/**
5427 * \brief Send a Neighbor Report Request Action frame
5428 *
5429 *
5430 * \param pMac Pointer to the global MAC structure
5431 *
5432 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5433 *
5434 * \param peer mac address of peer station.
5435 *
5436 * \param psessionEntry address of session entry.
5437 *
5438 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5439 *
5440 *
5441 */
5442
5443tSirRetStatus
5444limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5445 tpSirMacNeighborReportReq pNeighborReq,
5446 tSirMacAddr peer,
5447 tpPESession psessionEntry
5448 )
5449{
5450 tSirRetStatus statusCode = eSIR_SUCCESS;
5451 tDot11fNeighborReportRequest frm;
5452 tANI_U8 *pFrame;
5453 tpSirMacMgmtHdr pMacHdr;
5454 tANI_U32 nBytes, nPayload, nStatus;
5455 void *pPacket;
5456 eHalStatus halstatus;
5457 tANI_U8 txFlag = 0;
5458
5459 if ( psessionEntry == NULL )
5460 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005461 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 return eSIR_FAILURE;
5463 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305464 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005465
5466 frm.Category.category = SIR_MAC_ACTION_RRM;
5467 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5468 frm.DialogToken.token = pNeighborReq->dialogToken;
5469
5470
5471 if( pNeighborReq->ssid_present )
5472 {
5473 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5474 }
5475
5476 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5477 if ( DOT11F_FAILED( nStatus ) )
5478 {
5479 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005480 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 nStatus );
5482 // We'll fall back on the worst case scenario:
5483 nPayload = sizeof( tDot11fNeighborReportRequest );
5484 }
5485 else if ( DOT11F_WARNED( nStatus ) )
5486 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005487 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005489 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 }
5491
5492 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5493
5494 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5495 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5496 {
5497 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005498 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 return eSIR_FAILURE;
5500 }
5501
5502 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305503 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005504
5505 // Copy necessary info to BD
5506 if( eSIR_SUCCESS !=
5507 (statusCode = limPopulateMacHeader( pMac,
5508 pFrame,
5509 SIR_MAC_MGMT_FRAME,
5510 SIR_MAC_MGMT_ACTION,
5511 peer, psessionEntry->selfMacAddr)))
5512 goto returnAfterError;
5513
5514 // Update A3 with the BSSID
5515 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5516
5517 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5518
Chet Lanctot186b5732013-03-18 10:26:30 -07005519#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005520 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005521#endif
5522
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 // Now, we're ready to "pack" the frames
5524 nStatus = dot11fPackNeighborReportRequest( pMac,
5525 &frm,
5526 pFrame + sizeof( tSirMacMgmtHdr ),
5527 nPayload,
5528 &nPayload );
5529
5530 if( DOT11F_FAILED( nStatus ))
5531 {
5532 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005533 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 nStatus );
5535
5536 // FIXME - Need to convert to tSirRetStatus
5537 statusCode = eSIR_FAILURE;
5538 goto returnAfterError;
5539 }
5540 else if( DOT11F_WARNED( nStatus ))
5541 {
5542 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005543 FL( "There were warnings while packing Neighbor Report "
5544 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 }
5546
5547 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005548 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 limPrintMacAddr( pMac, peer, LOGW );
5550
5551 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5553 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 )
5555 {
5556 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5557 }
5558
5559 if( eHAL_STATUS_SUCCESS !=
5560 (halstatus = halTxFrame( pMac,
5561 pPacket,
5562 (tANI_U16) nBytes,
5563 HAL_TXRX_FRM_802_11_MGMT,
5564 ANI_TXDIR_TODS,
5565 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5566 limTxComplete,
5567 pFrame, txFlag )))
5568 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005569 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 statusCode = eSIR_FAILURE;
5571 //Pkt will be freed up by the callback
5572 return statusCode;
5573 }
5574 else
5575 return eSIR_SUCCESS;
5576
5577returnAfterError:
5578 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5579
5580 return statusCode;
5581} // End limSendNeighborReportRequestFrame.
5582
5583/**
5584 * \brief Send a Link Report Action frame
5585 *
5586 *
5587 * \param pMac Pointer to the global MAC structure
5588 *
5589 * \param pLinkReport Address of a tSirMacLinkReport
5590 *
5591 * \param peer mac address of peer station.
5592 *
5593 * \param psessionEntry address of session entry.
5594 *
5595 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5596 *
5597 *
5598 */
5599
5600tSirRetStatus
5601limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5602 tpSirMacLinkReport pLinkReport,
5603 tSirMacAddr peer,
5604 tpPESession psessionEntry
5605 )
5606{
5607 tSirRetStatus statusCode = eSIR_SUCCESS;
5608 tDot11fLinkMeasurementReport frm;
5609 tANI_U8 *pFrame;
5610 tpSirMacMgmtHdr pMacHdr;
5611 tANI_U32 nBytes, nPayload, nStatus;
5612 void *pPacket;
5613 eHalStatus halstatus;
5614 tANI_U8 txFlag = 0;
5615
5616
5617 if ( psessionEntry == NULL )
5618 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005619 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 return eSIR_FAILURE;
5621 }
5622
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305623 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005624
5625 frm.Category.category = SIR_MAC_ACTION_RRM;
5626 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5627 frm.DialogToken.token = pLinkReport->dialogToken;
5628
5629
5630 //IEEE Std. 802.11 7.3.2.18. for the report element.
5631 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5632 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5633 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5634 //such case this way than changing the frame parser.
5635 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5636 frm.TPCEleLen.TPCLen = 2;
5637 frm.TxPower.txPower = pLinkReport->txPower;
5638 frm.LinkMargin.linkMargin = 0;
5639
5640 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5641 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5642 frm.RCPI.rcpi = pLinkReport->rcpi;
5643 frm.RSNI.rsni = pLinkReport->rsni;
5644
5645 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5646 if ( DOT11F_FAILED( nStatus ) )
5647 {
5648 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005649 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 nStatus );
5651 // We'll fall back on the worst case scenario:
5652 nPayload = sizeof( tDot11fLinkMeasurementReport );
5653 }
5654 else if ( DOT11F_WARNED( nStatus ) )
5655 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005656 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005658 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 }
5660
5661 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5662
5663 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5664 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5665 {
5666 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005667 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 return eSIR_FAILURE;
5669 }
5670
5671 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305672 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005673
5674 // Copy necessary info to BD
5675 if( eSIR_SUCCESS !=
5676 (statusCode = limPopulateMacHeader( pMac,
5677 pFrame,
5678 SIR_MAC_MGMT_FRAME,
5679 SIR_MAC_MGMT_ACTION,
5680 peer, psessionEntry->selfMacAddr)))
5681 goto returnAfterError;
5682
5683 // Update A3 with the BSSID
5684 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5685
5686 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5687
Chet Lanctot186b5732013-03-18 10:26:30 -07005688#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005689 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005690#endif
5691
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 // Now, we're ready to "pack" the frames
5693 nStatus = dot11fPackLinkMeasurementReport( pMac,
5694 &frm,
5695 pFrame + sizeof( tSirMacMgmtHdr ),
5696 nPayload,
5697 &nPayload );
5698
5699 if( DOT11F_FAILED( nStatus ))
5700 {
5701 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005702 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 nStatus );
5704
5705 // FIXME - Need to convert to tSirRetStatus
5706 statusCode = eSIR_FAILURE;
5707 goto returnAfterError;
5708 }
5709 else if( DOT11F_WARNED( nStatus ))
5710 {
5711 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005712 FL( "There were warnings while packing Link Report (0x%08x)." ),
5713 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 }
5715
5716 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005717 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 limPrintMacAddr( pMac, peer, LOGW );
5719
5720 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5722 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 )
5724 {
5725 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5726 }
5727
5728 if( eHAL_STATUS_SUCCESS !=
5729 (halstatus = halTxFrame( pMac,
5730 pPacket,
5731 (tANI_U16) nBytes,
5732 HAL_TXRX_FRM_802_11_MGMT,
5733 ANI_TXDIR_TODS,
5734 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5735 limTxComplete,
5736 pFrame, txFlag )))
5737 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005738 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 statusCode = eSIR_FAILURE;
5740 //Pkt will be freed up by the callback
5741 return statusCode;
5742 }
5743 else
5744 return eSIR_SUCCESS;
5745
5746returnAfterError:
5747 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5748
5749 return statusCode;
5750} // End limSendLinkReportActionFrame.
5751
5752/**
5753 * \brief Send a Beacon Report Action frame
5754 *
5755 *
5756 * \param pMac Pointer to the global MAC structure
5757 *
5758 * \param dialog_token dialog token to be used in the action frame.
5759 *
5760 * \param num_report number of reports in pRRMReport.
5761 *
5762 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5763 *
5764 * \param peer mac address of peer station.
5765 *
5766 * \param psessionEntry address of session entry.
5767 *
5768 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5769 *
5770 *
5771 */
5772
5773tSirRetStatus
5774limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5775 tANI_U8 dialog_token,
5776 tANI_U8 num_report,
5777 tpSirMacRadioMeasureReport pRRMReport,
5778 tSirMacAddr peer,
5779 tpPESession psessionEntry
5780 )
5781{
5782 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 tANI_U8 *pFrame;
5784 tpSirMacMgmtHdr pMacHdr;
5785 tANI_U32 nBytes, nPayload, nStatus;
5786 void *pPacket;
5787 eHalStatus halstatus;
5788 tANI_U8 i;
5789 tANI_U8 txFlag = 0;
5790
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005791 tDot11fRadioMeasurementReport *frm =
5792 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5793 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005794 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005795 return eSIR_FAILURE;
5796 }
5797
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 if ( psessionEntry == NULL )
5799 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005800 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005801 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 return eSIR_FAILURE;
5803 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305804 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005805
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005806 frm->Category.category = SIR_MAC_ACTION_RRM;
5807 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5808 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005809
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005810 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 -07005811
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005812 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005814 frm->MeasurementReport[i].type = pRRMReport[i].type;
5815 frm->MeasurementReport[i].token = pRRMReport[i].token;
5816 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 switch( pRRMReport[i].type )
5818 {
5819 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005820 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5821 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5822 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5823 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 break;
5825 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305826 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5827 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005828 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 break;
5830 }
5831 }
5832
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005833 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 if ( DOT11F_FAILED( nStatus ) )
5835 {
5836 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005837 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 nStatus );
5839 // We'll fall back on the worst case scenario:
5840 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005841 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 return eSIR_FAILURE;
5843 }
5844 else if ( DOT11F_WARNED( nStatus ) )
5845 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005846 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005848 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 }
5850
5851 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5852
5853 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5854 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5855 {
5856 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005857 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005858 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 return eSIR_FAILURE;
5860 }
5861
5862 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305863 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005864
5865 // Copy necessary info to BD
5866 if( eSIR_SUCCESS !=
5867 (statusCode = limPopulateMacHeader( pMac,
5868 pFrame,
5869 SIR_MAC_MGMT_FRAME,
5870 SIR_MAC_MGMT_ACTION,
5871 peer, psessionEntry->selfMacAddr)))
5872 goto returnAfterError;
5873
5874 // Update A3 with the BSSID
5875 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5876
5877 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5878
Chet Lanctot186b5732013-03-18 10:26:30 -07005879#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005880 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005881#endif
5882
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 // Now, we're ready to "pack" the frames
5884 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005885 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 pFrame + sizeof( tSirMacMgmtHdr ),
5887 nPayload,
5888 &nPayload );
5889
5890 if( DOT11F_FAILED( nStatus ))
5891 {
5892 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005893 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 nStatus );
5895
5896 // FIXME - Need to convert to tSirRetStatus
5897 statusCode = eSIR_FAILURE;
5898 goto returnAfterError;
5899 }
5900 else if( DOT11F_WARNED( nStatus ))
5901 {
5902 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005903 FL( "There were warnings while packing Radio "
5904 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 }
5906
5907 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005908 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 limPrintMacAddr( pMac, peer, LOGW );
5910
5911 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5913 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005914 )
5915 {
5916 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5917 }
5918
5919 if( eHAL_STATUS_SUCCESS !=
5920 (halstatus = halTxFrame( pMac,
5921 pPacket,
5922 (tANI_U16) nBytes,
5923 HAL_TXRX_FRM_802_11_MGMT,
5924 ANI_TXDIR_TODS,
5925 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5926 limTxComplete,
5927 pFrame, txFlag )))
5928 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005929 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 statusCode = eSIR_FAILURE;
5931 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005932 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 return statusCode;
5934 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005935 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005936 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005939
5940returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005941 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 return statusCode;
5944} // End limSendBeaconReportActionFrame.
5945
5946#endif
5947
5948#ifdef WLAN_FEATURE_11W
5949/**
5950 * \brief Send SA query response action frame to peer
5951 *
5952 * \sa limSendSaQueryResponseFrame
5953 *
5954 *
5955 * \param pMac The global tpAniSirGlobal object
5956 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005957 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005959 * \param peer The Mac address of the AP to which this action frame is addressed
5960 *
5961 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 *
5963 * \return eSIR_SUCCESS if setup completes successfully
5964 * eSIR_FAILURE is some problem is encountered
5965 */
5966
Chet Lanctot186b5732013-03-18 10:26:30 -07005967tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005968tSirMacAddr peer,tpPESession psessionEntry)
5969{
5970
Chet Lanctot186b5732013-03-18 10:26:30 -07005971 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 tANI_U8 *pFrame;
5973 tSirRetStatus nSirStatus;
5974 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07005975 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 void *pPacket;
5977 eHalStatus halstatus;
Chet Lanctot186b5732013-03-18 10:26:30 -07005978 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005979
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305980 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07005981 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
5982 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 action: 0 --> SA query request action frame
5984 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07005985 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
5986 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07005988 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005989
Chet Lanctot186b5732013-03-18 10:26:30 -07005990 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
5991 if ( DOT11F_FAILED( nStatus ) )
5992 {
5993 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5994 "or a SA Query Response (0x%08x)."),
5995 nStatus );
5996 // We'll fall back on the worst case scenario:
5997 nPayload = sizeof( tDot11fSaQueryRsp );
5998 }
5999 else if ( DOT11F_WARNED( nStatus ) )
6000 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006001 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006002 "the packed size for an SA Query Response"
6003 " (0x%08x)."), nStatus );
6004 }
6005
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6007 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6008 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6009 {
6010 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006011 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 return eSIR_FAILURE;
6013 }
6014
6015 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306016 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006017
Chet Lanctot186b5732013-03-18 10:26:30 -07006018 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006019 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006020 pFrame,
6021 SIR_MAC_MGMT_FRAME,
6022 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006023 peer, psessionEntry->selfMacAddr );
6024 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006025 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006026
Chet Lanctot186b5732013-03-18 10:26:30 -07006027 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6029
Chet Lanctot186b5732013-03-18 10:26:30 -07006030 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006031
Chet Lanctot186b5732013-03-18 10:26:30 -07006032 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6033 // in the FC
6034 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006036 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 }
6038
Chet Lanctot186b5732013-03-18 10:26:30 -07006039 // Pack 11w SA query response frame
6040 nStatus = dot11fPackSaQueryRsp( pMac,
6041 &frm,
6042 pFrame + sizeof( tSirMacMgmtHdr ),
6043 nPayload,
6044 &nPayload );
6045
6046 if ( DOT11F_FAILED( nStatus ))
6047 {
6048 limLog( pMac, LOGE,
6049 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6050 nStatus );
6051 // FIXME - Need to convert to tSirRetStatus
6052 nSirStatus = eSIR_FAILURE;
6053 goto returnAfterError;
6054 }
6055 else if ( DOT11F_WARNED( nStatus ))
6056 {
6057 limLog( pMac, LOGW,
6058 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6059 nStatus);
6060 }
6061
6062 limLog( pMac, LOG1,
6063 FL( "Sending a SA Query Response to " ));
6064 limPrintMacAddr( pMac, peer, LOGW );
6065
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006066 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006067#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006068 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6069 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006070#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006071 )
6072 {
6073 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6074 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006075
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006076 halstatus = halTxFrame( pMac,
6077 pPacket,
6078 (tANI_U16) nBytes,
6079 HAL_TXRX_FRM_802_11_MGMT,
6080 ANI_TXDIR_TODS,
6081 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6082 limTxComplete,
6083 pFrame, txFlag );
6084 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006085 {
6086 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6087 nSirStatus = eSIR_FAILURE;
6088 //Pkt will be freed up by the callback
6089 return nSirStatus;
6090 }
6091 else {
6092 return eSIR_SUCCESS;
6093 }
6094
6095returnAfterError:
6096 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6097 return nSirStatus;
6098} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006099#endif