blob: 305422123454a639b4ee70b4ad878603d6a9970f [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);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002333 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302334 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002335 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002336} // End limSendAssocReqMgmtFrame
2337
2338
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002339#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002340/*------------------------------------------------------------------------------------
2341 *
2342 * Send Reassoc Req with FTIEs.
2343 *
2344 *-----------------------------------------------------------------------------------
2345 */
2346void
2347limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2348 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2349{
2350 static tDot11fReAssocRequest frm;
2351 tANI_U16 caps;
2352 tANI_U8 *pFrame;
2353 tSirRetStatus nSirStatus;
2354 tANI_U32 nBytes, nPayload, nStatus;
2355 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2356 void *pPacket;
2357 eHalStatus halstatus;
2358#if defined WLAN_FEATURE_VOWIFI
2359 tANI_U8 PowerCapsPopulated = FALSE;
2360#endif
2361 tANI_U16 ft_ies_length = 0;
2362 tANI_U8 *pBody;
2363 tANI_U16 nAddIELen;
2364 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002365#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 tANI_U8 *wpsIe = NULL;
2367#endif
2368 tANI_U8 txFlag = 0;
2369
2370 if (NULL == psessionEntry)
2371 {
2372 return;
2373 }
2374
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 /* check this early to avoid unncessary operation */
2376 if(NULL == psessionEntry->pLimReAssocReq)
2377 {
2378 return;
2379 }
2380 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2381 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002382 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2383 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002384
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302385 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002386
2387 caps = pMlmReassocReq->capabilityInfo;
2388 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2389 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2390#if defined(FEATURE_WLAN_WAPI)
2391 /* CR: 262463 :
2392 According to WAPI standard:
2393 7.3.1.4 Capability Information field
2394 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2395 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2396 Reassociation management frames. */
2397 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2398 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2399#endif
2400 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2401
2402 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2403
2404 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302405 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2407
2408 PopulateDot11fSSID2( pMac, &frm.SSID );
2409 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2410 &frm.SuppRates,psessionEntry);
2411
2412 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2413 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2414
2415 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2416 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2417
2418 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2419 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2420
2421 if ( psessionEntry->lim11hEnable &&
2422 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2423 {
2424#if defined WLAN_FEATURE_VOWIFI
2425 PowerCapsPopulated = TRUE;
2426
2427 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2428 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2429#endif
2430 }
2431
2432#if defined WLAN_FEATURE_VOWIFI
2433 if( pMac->rrm.rrmPEContext.rrmEnable &&
2434 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2435 {
2436 if (PowerCapsPopulated == FALSE)
2437 {
2438 PowerCapsPopulated = TRUE;
2439 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2440 }
2441 }
2442#endif
2443
2444 if ( fQosEnabled &&
2445 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2446 {
2447 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2448 }
2449
2450 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2451 &frm.ExtSuppRates, psessionEntry );
2452
2453#if defined WLAN_FEATURE_VOWIFI
2454 if( pMac->rrm.rrmPEContext.rrmEnable &&
2455 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2456 {
2457 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2458 }
2459#endif
2460
2461 // Ideally this should be enabled for 11r also. But 11r does
2462 // not follow the usual norm of using the Opaque object
2463 // for rsnie and fties. Instead we just add
2464 // the rsnie and fties at the end of the pack routine for 11r.
2465 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002466#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 //
2468 // The join request *should* contain zero or one of the WPA and RSN
2469 // IEs. The payload send along with the request is a
2470 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2471
2472 // typedef struct sSirRSNie
2473 // {
2474 // tANI_U16 length;
2475 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2476 // } tSirRSNie, *tpSirRSNie;
2477
2478 // So, we should be able to make the following two calls harmlessly,
2479 // since they do nothing if they don't find the given IE in the
2480 // bytestream with which they're provided.
2481
2482 // The net effect of this will be to faithfully transmit whatever
2483 // security IE is in the join request.
2484
2485 // *However*, if we're associating for the purpose of WPS
2486 // enrollment, and we've been configured to indicate that by
2487 // eliding the WPA or RSN IE, we just skip this:
2488 if (!psessionEntry->is11Rconnection)
2489 {
2490 if( nAddIELen && pAddIE )
2491 {
2492 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2493 }
2494 if ( NULL == wpsIe )
2495 {
2496 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2497 &frm.RSNOpaque );
2498 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2499 &frm.WPAOpaque );
2500 }
2501
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002502#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302503 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002504 {
2505 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2506 &frm.CCXCckmOpaque );
2507 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002508#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 }
2510
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002511#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302513 if (psessionEntry->isCCXconnection &&
2514 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002516#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002518#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302519 PopulateDot11fCCXVersion(&frm.CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302521#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002522#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002523
2524 // include WME EDCA IE as well
2525 if ( fWmeEnabled )
2526 {
2527 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2528 {
2529 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2530 }
2531
2532 if ( fWsmEnabled &&
2533 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2534 {
2535 PopulateDot11fWMMCaps( &frm.WMMCaps );
2536 }
2537#ifdef FEATURE_WLAN_CCX
2538 if (psessionEntry->isCCXconnection)
2539 {
2540 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2541
2542 // Populate the TSRS IE if TSPEC is included in the reassoc request
2543 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2544 {
2545 tANI_U32 phyMode;
2546 tSirMacCCXTSRSIE tsrsIE;
2547 limGetPhyMode(pMac, &phyMode, psessionEntry);
2548
2549 tsrsIE.tsid = 0;
2550 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2551 {
2552 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2553 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302554 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 {
2556 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2557 }
2558 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2559 }
2560 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302561#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 }
2563
Jeff Johnsone7245742012-09-05 17:12:55 -07002564 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 pMac->lim.htCapabilityPresentInBeacon)
2566 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002567 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 }
2569
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002570#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302571 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2572#if defined FEATURE_WLAN_CCX
2573 && !psessionEntry->isCCXconnection
2574#endif
2575 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002576 {
2577 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2578 }
2579#endif
2580
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2582 if ( DOT11F_FAILED( nStatus ) )
2583 {
2584 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002585 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 nStatus );
2587 // We'll fall back on the worst case scenario:
2588 nPayload = sizeof( tDot11fReAssocRequest );
2589 }
2590 else if ( DOT11F_WARNED( nStatus ) )
2591 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002592 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002594 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 }
2596
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002597 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002598
2599#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002600 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2602#endif
2603
2604#if defined WLAN_FEATURE_VOWIFI_11R
2605 if (psessionEntry->is11Rconnection)
2606 {
2607 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2608 }
2609#endif
2610
2611 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2612 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2613 ( void** ) &pPacket );
2614 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2615 {
2616 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002617 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002619 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 goto end;
2621 }
2622
2623 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302624 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002625
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002626#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002627 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002628#endif
2629 // Next, we fill out the buffer descriptor:
2630 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2631 SIR_MAC_MGMT_REASSOC_REQ,
2632 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2633 if ( eSIR_SUCCESS != nSirStatus )
2634 {
2635 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002636 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 nSirStatus );
2638 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2639 goto end;
2640 }
2641
2642
2643 // That done, pack the ReAssoc Request:
2644 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2645 sizeof(tSirMacMgmtHdr),
2646 nPayload, &nPayload );
2647 if ( DOT11F_FAILED( nStatus ) )
2648 {
2649 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002650 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 nStatus );
2652 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2653 goto end;
2654 }
2655 else if ( DOT11F_WARNED( nStatus ) )
2656 {
2657 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002658 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 }
2660
2661 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002662 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 nBytes, nPayload );)
2664 if( psessionEntry->assocReq != NULL )
2665 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302666 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 psessionEntry->assocReq = NULL;
2668 }
2669
2670 if( nAddIELen )
2671 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302672 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2673 pAddIE,
2674 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 nPayload += nAddIELen;
2676 }
2677
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302678 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2679 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 {
2681 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002682 }
2683 else
2684 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302686 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002689
2690 if (psessionEntry->is11Rconnection)
2691 {
2692 {
2693 int i = 0;
2694
2695 pBody = pFrame + nBytes;
2696 for (i=0; i<ft_ies_length; i++)
2697 {
2698 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2699 pBody++;
2700 }
2701 }
2702 }
2703
2704#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002705 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2706 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 (tANI_U8 *)pFrame,
2708 (nBytes + ft_ies_length));)
2709#endif
2710
2711
2712 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2714 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 )
2716 {
2717 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2718 }
2719
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002720 if( NULL != psessionEntry->assocReq )
2721 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302722 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002723 psessionEntry->assocReq = NULL;
2724 }
2725
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302726 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2727 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002728 {
2729 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002730 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002731 }
2732 else
2733 {
2734 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302735 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2736 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002737 psessionEntry->assocReqLen = (ft_ies_length);
2738 }
2739
2740
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2742 HAL_TXRX_FRM_802_11_MGMT,
2743 ANI_TXDIR_TODS,
2744 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2745 limTxComplete, pFrame, txFlag );
2746 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2747 {
2748 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002749 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 nSirStatus );
2751 //Pkt will be freed up by the callback
2752 goto end;
2753 }
2754
2755end:
2756 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302757 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 psessionEntry->pLimMlmReassocReq = NULL;
2759
2760}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002761
2762void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2763 tLimMlmReassocReq *pMlmReassocReq,
2764 tpPESession psessionEntry)
2765{
2766 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2767 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2768 if(NULL == pTmpMlmReassocReq)
2769 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302770 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2771 if ( NULL == pTmpMlmReassocReq ) goto end;
2772 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2773 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002774 }
2775
2776 // Prepare and send Reassociation request frame
2777 // start reassoc timer.
2778 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2779 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002780 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002781 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2782 != TX_SUCCESS)
2783 {
2784 // Could not start reassoc failure timer.
2785 // Log error
2786 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002787 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002788 // Return Reassoc confirm with
2789 // Resources Unavailable
2790 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2791 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2792 goto end;
2793 }
2794
2795 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2796 return;
2797
2798end:
2799 // Free up buffer allocated for reassocReq
2800 if (pMlmReassocReq != NULL)
2801 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302802 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002803 pMlmReassocReq = NULL;
2804 }
2805 if (pTmpMlmReassocReq != NULL)
2806 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302807 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002808 pTmpMlmReassocReq = NULL;
2809 }
2810 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2811 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2812 /* Update PE sessio Id*/
2813 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2814
2815 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2816}
2817
Jeff Johnson295189b2012-06-20 16:38:30 -07002818#endif /* WLAN_FEATURE_VOWIFI_11R */
2819
2820
2821void
2822limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2823 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2824{
2825 static tDot11fReAssocRequest frm;
2826 tANI_U16 caps;
2827 tANI_U8 *pFrame;
2828 tSirRetStatus nSirStatus;
2829 tANI_U32 nBytes, nPayload, nStatus;
2830 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2831 void *pPacket;
2832 eHalStatus halstatus;
2833 tANI_U16 nAddIELen;
2834 tANI_U8 *pAddIE;
2835 tANI_U8 *wpsIe = NULL;
2836 tANI_U8 txFlag = 0;
2837#if defined WLAN_FEATURE_VOWIFI
2838 tANI_U8 PowerCapsPopulated = FALSE;
2839#endif
2840
2841 if(NULL == psessionEntry)
2842 {
2843 return;
2844 }
2845
2846 /* check this early to avoid unncessary operation */
2847 if(NULL == psessionEntry->pLimReAssocReq)
2848 {
2849 return;
2850 }
2851 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2852 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2853
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302854 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002855
2856 caps = pMlmReassocReq->capabilityInfo;
2857 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2858 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2859#if defined(FEATURE_WLAN_WAPI)
2860 /* CR: 262463 :
2861 According to WAPI standard:
2862 7.3.1.4 Capability Information field
2863 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2864 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2865 Reassociation management frames. */
2866 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2867 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2868#endif
2869 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2870
2871 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2872
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302873 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2874 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002875
2876 PopulateDot11fSSID2( pMac, &frm.SSID );
2877 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2878 &frm.SuppRates,psessionEntry);
2879
2880 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2881 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2882
2883 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2884 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2885
2886 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2887 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2888
2889
2890 if ( psessionEntry->lim11hEnable &&
2891 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2892 {
2893#if defined WLAN_FEATURE_VOWIFI
2894 PowerCapsPopulated = TRUE;
2895 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2896 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2897#endif
2898 }
2899
2900#if defined WLAN_FEATURE_VOWIFI
2901 if( pMac->rrm.rrmPEContext.rrmEnable &&
2902 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2903 {
2904 if (PowerCapsPopulated == FALSE)
2905 {
2906 PowerCapsPopulated = TRUE;
2907 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2908 }
2909 }
2910#endif
2911
2912 if ( fQosEnabled &&
2913 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2914 {
2915 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2916 }
2917
2918 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2919 &frm.ExtSuppRates, psessionEntry );
2920
2921#if defined WLAN_FEATURE_VOWIFI
2922 if( pMac->rrm.rrmPEContext.rrmEnable &&
2923 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2924 {
2925 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2926 }
2927#endif
2928 // The join request *should* contain zero or one of the WPA and RSN
2929 // IEs. The payload send along with the request is a
2930 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2931
2932 // typedef struct sSirRSNie
2933 // {
2934 // tANI_U16 length;
2935 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2936 // } tSirRSNie, *tpSirRSNie;
2937
2938 // So, we should be able to make the following two calls harmlessly,
2939 // since they do nothing if they don't find the given IE in the
2940 // bytestream with which they're provided.
2941
2942 // The net effect of this will be to faithfully transmit whatever
2943 // security IE is in the join request.
2944
2945 // *However*, if we're associating for the purpose of WPS
2946 // enrollment, and we've been configured to indicate that by
2947 // eliding the WPA or RSN IE, we just skip this:
2948 if( nAddIELen && pAddIE )
2949 {
2950 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2951 }
2952 if ( NULL == wpsIe )
2953 {
2954 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2955 &frm.RSNOpaque );
2956 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2957 &frm.WPAOpaque );
2958#if defined(FEATURE_WLAN_WAPI)
2959 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2960 &frm.WAPIOpaque );
2961#endif // defined(FEATURE_WLAN_WAPI)
2962 }
2963
2964 // include WME EDCA IE as well
2965 if ( fWmeEnabled )
2966 {
2967 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2968 {
2969 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2970 }
2971
2972 if ( fWsmEnabled &&
2973 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2974 {
2975 PopulateDot11fWMMCaps( &frm.WMMCaps );
2976 }
2977 }
2978
Jeff Johnsone7245742012-09-05 17:12:55 -07002979 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 pMac->lim.htCapabilityPresentInBeacon)
2981 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002982 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002984#ifdef WLAN_FEATURE_11AC
2985 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002986 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002987 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002988 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002989 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07002990 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002991 }
2992#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002993
2994 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2995 if ( DOT11F_FAILED( nStatus ) )
2996 {
2997 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002998 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002999 nStatus );
3000 // We'll fall back on the worst case scenario:
3001 nPayload = sizeof( tDot11fReAssocRequest );
3002 }
3003 else if ( DOT11F_WARNED( nStatus ) )
3004 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003005 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003007 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 }
3009
3010 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3011
3012 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3013 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3014 ( void** ) &pPacket );
3015 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3016 {
3017 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003018 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003020 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 goto end;
3022 }
3023
3024 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303025 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003026
3027 // Next, we fill out the buffer descriptor:
3028 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3029 SIR_MAC_MGMT_REASSOC_REQ,
3030 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3031 if ( eSIR_SUCCESS != nSirStatus )
3032 {
3033 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003034 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 nSirStatus );
3036 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3037 goto end;
3038 }
3039
3040
3041 // That done, pack the Probe Request:
3042 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3043 sizeof(tSirMacMgmtHdr),
3044 nPayload, &nPayload );
3045 if ( DOT11F_FAILED( nStatus ) )
3046 {
3047 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003048 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 nStatus );
3050 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3051 goto end;
3052 }
3053 else if ( DOT11F_WARNED( nStatus ) )
3054 {
3055 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003056 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 }
3058
3059 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003060 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 nBytes );)
3062
3063 if( psessionEntry->assocReq != NULL )
3064 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303065 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 psessionEntry->assocReq = NULL;
3067 }
3068
3069 if( nAddIELen )
3070 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303071 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3072 pAddIE,
3073 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 nPayload += nAddIELen;
3075 }
3076
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303077 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3078 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 {
3080 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003081 }
3082 else
3083 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303085 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003088
3089 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3091 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 )
3093 {
3094 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3095 }
3096
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003097 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003098 {
3099 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3100 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003101
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3103 HAL_TXRX_FRM_802_11_MGMT,
3104 ANI_TXDIR_TODS,
3105 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3106 limTxComplete, pFrame, txFlag );
3107 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3108 {
3109 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003110 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 nSirStatus );
3112 //Pkt will be freed up by the callback
3113 goto end;
3114 }
3115
3116end:
3117 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303118 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 psessionEntry->pLimMlmReassocReq = NULL;
3120
3121} // limSendReassocReqMgmtFrame
3122
3123/**
3124 * \brief Send an Authentication frame
3125 *
3126 *
3127 * \param pMac Pointer to Global MAC structure
3128 *
3129 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3130 * to be sent
3131 *
3132 * \param peerMacAddr MAC address of the peer entity to which Authentication
3133 * frame is destined
3134 *
3135 * \param wepBit Indicates whether wep bit to be set in FC while sending
3136 * Authentication frame3
3137 *
3138 *
3139 * This function is called by limProcessMlmMessages(). Authentication frame
3140 * is formatted and sent when this function is called.
3141 *
3142 *
3143 */
3144
3145void
3146limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3147 tpSirMacAuthFrameBody pAuthFrameBody,
3148 tSirMacAddr peerMacAddr,
3149 tANI_U8 wepBit,
3150 tpPESession psessionEntry
3151 )
3152{
3153 tANI_U8 *pFrame, *pBody;
3154 tANI_U32 frameLen = 0, bodyLen = 0;
3155 tpSirMacMgmtHdr pMacHdr;
3156 tANI_U16 i;
3157 void *pPacket;
3158 eHalStatus halstatus;
3159 tANI_U8 txFlag = 0;
3160
3161 if(NULL == psessionEntry)
3162 {
3163 return;
3164 }
3165
3166 if (wepBit == LIM_WEP_IN_FC)
3167 {
3168 /// Auth frame3 to be sent with encrypted framebody
3169 /**
3170 * Allocate buffer for Authenticaton frame of size equal
3171 * to management frame header length plus 2 bytes each for
3172 * auth algorithm number, transaction number, status code,
3173 * 128 bytes for challenge text and 4 bytes each for
3174 * IV & ICV.
3175 */
3176
3177 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3178
3179 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3180 } // if (wepBit == LIM_WEP_IN_FC)
3181 else
3182 {
3183 switch (pAuthFrameBody->authTransactionSeqNumber)
3184 {
3185 case SIR_MAC_AUTH_FRAME_1:
3186 /**
3187 * Allocate buffer for Authenticaton frame of size
3188 * equal to management frame header length plus 2 bytes
3189 * each for auth algorithm number, transaction number
3190 * and status code.
3191 */
3192
3193 frameLen = sizeof(tSirMacMgmtHdr) +
3194 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3195 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3196
3197#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003198 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3199 {
3200 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003202 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003203 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003204 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003206 else
3207 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003208 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003209 frameLen += (2+SIR_MDIE_SIZE);
3210 }
3211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003212#endif
3213 break;
3214
3215 case SIR_MAC_AUTH_FRAME_2:
3216 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3217 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3218 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3219 {
3220 /**
3221 * Allocate buffer for Authenticaton frame of size
3222 * equal to management frame header length plus
3223 * 2 bytes each for auth algorithm number,
3224 * transaction number and status code.
3225 */
3226
3227 frameLen = sizeof(tSirMacMgmtHdr) +
3228 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3229 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3230 }
3231 else
3232 {
3233 // Shared Key algorithm with challenge text
3234 // to be sent
3235 /**
3236 * Allocate buffer for Authenticaton frame of size
3237 * equal to management frame header length plus
3238 * 2 bytes each for auth algorithm number,
3239 * transaction number, status code and 128 bytes
3240 * for challenge text.
3241 */
3242
3243 frameLen = sizeof(tSirMacMgmtHdr) +
3244 sizeof(tSirMacAuthFrame);
3245 bodyLen = sizeof(tSirMacAuthFrameBody);
3246 }
3247
3248 break;
3249
3250 case SIR_MAC_AUTH_FRAME_3:
3251 /// Auth frame3 to be sent without encrypted framebody
3252 /**
3253 * Allocate buffer for Authenticaton frame of size equal
3254 * to management frame header length plus 2 bytes each
3255 * for auth algorithm number, transaction number and
3256 * status code.
3257 */
3258
3259 frameLen = sizeof(tSirMacMgmtHdr) +
3260 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3261 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3262
3263 break;
3264
3265 case SIR_MAC_AUTH_FRAME_4:
3266 /**
3267 * Allocate buffer for Authenticaton frame of size equal
3268 * to management frame header length plus 2 bytes each
3269 * for auth algorithm number, transaction number and
3270 * status code.
3271 */
3272
3273 frameLen = sizeof(tSirMacMgmtHdr) +
3274 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3275 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3276
3277 break;
3278 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3279 } // end if (wepBit == LIM_WEP_IN_FC)
3280
3281
3282 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3283
3284 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3285 {
3286 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003287 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003288
3289 return;
3290 }
3291
3292 for (i = 0; i < frameLen; i++)
3293 pFrame[i] = 0;
3294
3295 // Prepare BD
3296 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3297 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3298 {
3299 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3300 return;
3301 }
3302
3303 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3304 pMacHdr->fc.wep = wepBit;
3305
3306 // Prepare BSSId
3307 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3308 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303309 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3310 (tANI_U8 *) psessionEntry->bssId,
3311 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 }
3313
3314 /// Prepare Authentication frame body
3315 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3316
3317 if (wepBit == LIM_WEP_IN_FC)
3318 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303319 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003320
3321 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003322 FL("*** Sending Auth seq# 3 status %d (%d) to"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 pAuthFrameBody->authStatusCode,
3324 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3325
3326 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3327 }
3328 else
3329 {
3330 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3331 pBody += sizeof(tANI_U16);
3332 bodyLen -= sizeof(tANI_U16);
3333
3334 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3335 pBody += sizeof(tANI_U16);
3336 bodyLen -= sizeof(tANI_U16);
3337
3338 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3339 pBody += sizeof(tANI_U16);
3340 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003341 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3342 sizeof (pAuthFrameBody->length) +
3343 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303344 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003345
3346#if defined WLAN_FEATURE_VOWIFI_11R
3347 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3348 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3349 {
3350
3351 {
3352 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3354 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003355#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3357 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3358 (tANI_U8 *)pBody,
3359 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003360#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003361 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3362 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003363 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3364 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003365 }
3366 }
3367 else
3368 {
3369 /* MDID attr is 54*/
3370 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003372 *pBody = SIR_MDIE_SIZE;
3373 pBody++;
3374 for(i=0;i<SIR_MDIE_SIZE;i++)
3375 {
3376 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3377 pBody++;
3378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 }
3380 }
3381 }
3382#endif
3383
3384 PELOG1(limLog(pMac, LOG1,
3385 FL("*** Sending Auth seq# %d status %d (%d) to "),
3386 pAuthFrameBody->authTransactionSeqNumber,
3387 pAuthFrameBody->authStatusCode,
3388 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3389
3390 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3391 }
3392 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3393
3394 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3396 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003397#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303398 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003399 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3400#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 )
3402 {
3403 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3404 }
3405
Ganesh K08bce952012-12-13 15:04:41 -08003406 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3407 {
3408 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3409 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003410
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 /// Queue Authentication frame in high priority WQ
3412 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3413 HAL_TXRX_FRM_802_11_MGMT,
3414 ANI_TXDIR_TODS,
3415 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3416 limTxComplete, pFrame, txFlag );
3417 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3418 {
3419 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003420 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 halstatus);
3422
3423 //Pkt will be freed up by the callback
3424 }
3425
3426 return;
3427} /*** end limSendAuthMgmtFrame() ***/
3428
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003429eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3430{
3431 tANI_U16 aid;
3432 tpDphHashNode pStaDs;
3433 tLimMlmDeauthReq *pMlmDeauthReq;
3434 tLimMlmDeauthCnf mlmDeauthCnf;
3435 tpPESession psessionEntry;
3436
3437 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3438 if (pMlmDeauthReq)
3439 {
3440 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3441 {
3442 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3443 }
3444
3445 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3446 {
3447
3448 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003449 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003450 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3451 goto end;
3452 }
3453
3454 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3455 if (pStaDs == NULL)
3456 {
3457 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3458 goto end;
3459 }
3460
3461
3462 /// Receive path cleanup with dummy packet
3463 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3464 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303465 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003466 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3467 }
3468 return eHAL_STATUS_SUCCESS;
3469end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303470 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003471 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3472 sizeof(tSirMacAddr));
3473 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3474 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3475 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3476
3477 // Free up buffer allocated
3478 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303479 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003480
3481 limPostSmeMessage(pMac,
3482 LIM_MLM_DEAUTH_CNF,
3483 (tANI_U32 *) &mlmDeauthCnf);
3484 return eHAL_STATUS_SUCCESS;
3485}
3486
3487eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3488{
3489 tANI_U16 aid;
3490 tpDphHashNode pStaDs;
3491 tLimMlmDisassocCnf mlmDisassocCnf;
3492 tpPESession psessionEntry;
3493 tLimMlmDisassocReq *pMlmDisassocReq;
3494
3495 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3496 if (pMlmDisassocReq)
3497 {
3498 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3499 {
3500 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3501 }
3502
3503 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3504 {
3505
3506 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003507 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003508 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3509 goto end;
3510 }
3511
3512 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3513 if (pStaDs == NULL)
3514 {
3515 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3516 goto end;
3517 }
3518
3519 /// Receive path cleanup with dummy packet
3520 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3521 {
3522 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3523 goto end;
3524 }
3525
3526#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003527 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303528 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003529#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303530 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003531#endif
3532#ifdef FEATURE_WLAN_LFR
3533 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003534#endif
3535 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303536 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003537 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003538 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303539 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003540 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003541 psessionEntry, psessionEntry->peSessionId););
3542 limFTCleanup(pMac);
3543 }
3544 else
3545 {
3546 PELOGE(limLog(pMac, LOGE,
3547 FL("No FT Preauth Session Cleanup in role %d"
3548#ifdef FEATURE_WLAN_CCX
3549 " isCCX %d"
3550#endif
3551#ifdef FEATURE_WLAN_LFR
3552 " isLFR %d"
3553#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003554 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003555 psessionEntry->limSystemRole,
3556#ifdef FEATURE_WLAN_CCX
3557 psessionEntry->isCCXconnection,
3558#endif
3559#ifdef FEATURE_WLAN_LFR
3560 psessionEntry->isFastRoamIniFeatureEnabled,
3561#endif
3562 psessionEntry->is11Rconnection,
3563 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003564 }
3565#endif
3566
3567 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303568 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003569 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3570 return eHAL_STATUS_SUCCESS;
3571 }
3572 else
3573 {
3574 return eHAL_STATUS_SUCCESS;
3575 }
3576end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303577 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003578 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3579 sizeof(tSirMacAddr));
3580 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3581 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3582
3583 /* Update PE session ID*/
3584 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3585
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003586 if(pMlmDisassocReq != NULL)
3587 {
3588 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303589 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003590 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3591 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003592
3593 limPostSmeMessage(pMac,
3594 LIM_MLM_DISASSOC_CNF,
3595 (tANI_U32 *) &mlmDisassocCnf);
3596 return eHAL_STATUS_SUCCESS;
3597}
3598
3599eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3600{
3601 return limSendDisassocCnf(pMac);
3602}
3603
3604eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3605{
3606 return limSendDeauthCnf(pMac);
3607}
3608
Jeff Johnson295189b2012-06-20 16:38:30 -07003609/**
3610 * \brief This function is called to send Disassociate frame.
3611 *
3612 *
3613 * \param pMac Pointer to Global MAC structure
3614 *
3615 * \param nReason Indicates the reason that need to be sent in
3616 * Disassociation frame
3617 *
3618 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3619 * sent
3620 *
3621 *
3622 */
3623
3624void
3625limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3626 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003627 tSirMacAddr peer,
3628 tpPESession psessionEntry,
3629 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003630{
3631 tDot11fDisassociation frm;
3632 tANI_U8 *pFrame;
3633 tSirRetStatus nSirStatus;
3634 tpSirMacMgmtHdr pMacHdr;
3635 tANI_U32 nBytes, nPayload, nStatus;
3636 void *pPacket;
3637 eHalStatus halstatus;
3638 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003639 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 if(NULL == psessionEntry)
3641 {
3642 return;
3643 }
3644
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303645 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003646
3647 frm.Reason.code = nReason;
3648
3649 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3650 if ( DOT11F_FAILED( nStatus ) )
3651 {
3652 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003653 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 nStatus );
3655 // We'll fall back on the worst case scenario:
3656 nPayload = sizeof( tDot11fDisassociation );
3657 }
3658 else if ( DOT11F_WARNED( nStatus ) )
3659 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003660 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003662 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 }
3664
3665 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3666
3667 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3668 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3669 ( void** ) &pPacket );
3670 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3671 {
3672 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003673 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 return;
3675 }
3676
3677 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303678 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003679
3680 // Next, we fill out the buffer descriptor:
3681 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3682 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3683 if ( eSIR_SUCCESS != nSirStatus )
3684 {
3685 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003686 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 nSirStatus );
3688 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3689 ( void* ) pFrame, ( void* ) pPacket );
3690 return; // just allocated...
3691 }
3692
3693 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3694
3695 // Prepare the BSSID
3696 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3697
Chet Lanctot186b5732013-03-18 10:26:30 -07003698#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003699 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003700#endif
3701
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3703 sizeof(tSirMacMgmtHdr),
3704 nPayload, &nPayload );
3705 if ( DOT11F_FAILED( nStatus ) )
3706 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003707 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 nStatus );
3709 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3710 ( void* ) pFrame, ( void* ) pPacket );
3711 return; // allocated!
3712 }
3713 else if ( DOT11F_WARNED( nStatus ) )
3714 {
3715 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003716 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 }
3718
3719 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003720 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3722
3723 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3725 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 )
3727 {
3728 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3729 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003730
Ganesh K08bce952012-12-13 15:04:41 -08003731 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3732 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3733 {
3734 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3735 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003736
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003737 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003739 // Queue Disassociation frame in high priority WQ
3740 /* get the duration from the request */
3741 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3742 HAL_TXRX_FRM_802_11_MGMT,
3743 ANI_TXDIR_TODS,
3744 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3745 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3746 txFlag );
3747 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003748
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003749 if (tx_timer_change(
3750 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3751 != TX_SUCCESS)
3752 {
3753 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003754 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003755 return;
3756 }
3757 else if(TX_SUCCESS != tx_timer_activate(
3758 &pMac->lim.limTimers.gLimDisassocAckTimer))
3759 {
3760 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003761 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003762 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3763 return;
3764 }
3765 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003766 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003767 {
3768 // Queue Disassociation frame in high priority WQ
3769 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3770 HAL_TXRX_FRM_802_11_MGMT,
3771 ANI_TXDIR_TODS,
3772 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3773 limTxComplete, pFrame, txFlag );
3774 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3775 {
3776 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003777 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003778 nSirStatus );
3779 //Pkt will be freed up by the callback
3780 return;
3781 }
3782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003783} // End limSendDisassocMgmtFrame.
3784
3785/**
3786 * \brief This function is called to send a Deauthenticate frame
3787 *
3788 *
3789 * \param pMac Pointer to global MAC structure
3790 *
3791 * \param nReason Indicates the reason that need to be sent in the
3792 * Deauthenticate frame
3793 *
3794 * \param peeer address of the STA to which the frame is to be sent
3795 *
3796 *
3797 */
3798
3799void
3800limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3801 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003802 tSirMacAddr peer,
3803 tpPESession psessionEntry,
3804 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003805{
3806 tDot11fDeAuth frm;
3807 tANI_U8 *pFrame;
3808 tSirRetStatus nSirStatus;
3809 tpSirMacMgmtHdr pMacHdr;
3810 tANI_U32 nBytes, nPayload, nStatus;
3811 void *pPacket;
3812 eHalStatus halstatus;
3813 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003814 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003815#ifdef FEATURE_WLAN_TDLS
3816 tANI_U16 aid;
3817 tpDphHashNode pStaDs;
3818#endif
3819
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 if(NULL == psessionEntry)
3821 {
3822 return;
3823 }
3824
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303825 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003826
3827 frm.Reason.code = nReason;
3828
3829 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3830 if ( DOT11F_FAILED( nStatus ) )
3831 {
3832 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003833 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 nStatus );
3835 // We'll fall back on the worst case scenario:
3836 nPayload = sizeof( tDot11fDeAuth );
3837 }
3838 else if ( DOT11F_WARNED( nStatus ) )
3839 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003840 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003842 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 }
3844
3845 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3846
3847 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3848 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3849 ( void** ) &pPacket );
3850 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3851 {
3852 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003853 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 return;
3855 }
3856
3857 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303858 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003859
3860 // Next, we fill out the buffer descriptor:
3861 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3862 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3863 if ( eSIR_SUCCESS != nSirStatus )
3864 {
3865 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003866 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 nSirStatus );
3868 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3869 ( void* ) pFrame, ( void* ) pPacket );
3870 return; // just allocated...
3871 }
3872
3873 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3874
3875 // Prepare the BSSID
3876 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3877
Chet Lanctot186b5732013-03-18 10:26:30 -07003878#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003879 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003880#endif
3881
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3883 sizeof(tSirMacMgmtHdr),
3884 nPayload, &nPayload );
3885 if ( DOT11F_FAILED( nStatus ) )
3886 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003887 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 nStatus );
3889 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3890 ( void* ) pFrame, ( void* ) pPacket );
3891 return;
3892 }
3893 else if ( DOT11F_WARNED( nStatus ) )
3894 {
3895 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003896 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 }
3898
3899 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003900 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3902
3903 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3905 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 )
3907 {
3908 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3909 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003910
Ganesh K08bce952012-12-13 15:04:41 -08003911 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3912 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3913 {
3914 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3915 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003916
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003917#ifdef FEATURE_WLAN_TDLS
3918 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3919#endif
3920
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003921 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003923 // Queue Disassociation frame in high priority WQ
3924 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3925 HAL_TXRX_FRM_802_11_MGMT,
3926 ANI_TXDIR_TODS,
3927 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3928 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
3929 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3930 {
3931 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003932 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003933 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003934 //Pkt will be freed up by the callback limTxComplete
3935
3936 /*Call limProcessDeauthAckTimeout which will send
3937 * DeauthCnf for this frame
3938 */
3939 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003940 return;
3941 }
3942
3943 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3944
3945 if (tx_timer_change(
3946 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3947 != TX_SUCCESS)
3948 {
3949 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003950 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003951 return;
3952 }
3953 else if(TX_SUCCESS != tx_timer_activate(
3954 &pMac->lim.limTimers.gLimDeauthAckTimer))
3955 {
3956 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003957 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003958 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3959 return;
3960 }
3961 }
3962 else
3963 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003964#ifdef FEATURE_WLAN_TDLS
3965 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
3966 {
3967 // Queue Disassociation frame in high priority WQ
3968 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003969 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003970 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003971 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3972 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003973 }
3974 else
3975 {
3976#endif
3977 // Queue Disassociation frame in high priority WQ
3978 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3979 HAL_TXRX_FRM_802_11_MGMT,
3980 ANI_TXDIR_TODS,
3981 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3982 limTxComplete, pFrame, txFlag );
3983#ifdef FEATURE_WLAN_TDLS
3984 }
3985#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003986 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3987 {
3988 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003989 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003990 nSirStatus );
3991 //Pkt will be freed up by the callback
3992 return;
3993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 }
3995
3996} // End limSendDeauthMgmtFrame.
3997
3998
3999#ifdef ANI_SUPPORT_11H
4000/**
4001 * \brief Send a Measurement Report Action frame
4002 *
4003 *
4004 * \param pMac Pointer to the global MAC structure
4005 *
4006 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4007 *
4008 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4009 *
4010 *
4011 */
4012
4013tSirRetStatus
4014limSendMeasReportFrame(tpAniSirGlobal pMac,
4015 tpSirMacMeasReqActionFrame pMeasReqFrame,
4016 tSirMacAddr peer)
4017{
4018 tDot11fMeasurementReport frm;
4019 tANI_U8 *pFrame;
4020 tSirRetStatus nSirStatus;
4021 tpSirMacMgmtHdr pMacHdr;
4022 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4023 void *pPacket;
4024 eHalStatus halstatus;
4025
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304026 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004027
4028 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4029 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4030 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4031
4032 switch ( pMeasReqFrame->measReqIE.measType )
4033 {
4034 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4035 nSirStatus =
4036 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4037 &frm.MeasurementReport );
4038 break;
4039 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4040 nSirStatus =
4041 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4042 &frm.MeasurementReport );
4043 break;
4044 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4045 nSirStatus =
4046 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4047 &frm.MeasurementReport );
4048 break;
4049 default:
4050 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004051 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 pMeasReqFrame->measReqIE.measType );
4053 return eSIR_FAILURE;
4054 }
4055
4056 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4057
4058 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4059 if ( DOT11F_FAILED( nStatus ) )
4060 {
4061 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004062 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 nStatus );
4064 // We'll fall back on the worst case scenario:
4065 nPayload = sizeof( tDot11fMeasurementReport );
4066 }
4067 else if ( DOT11F_WARNED( nStatus ) )
4068 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004069 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004071 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 }
4073
4074 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4075
4076 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4077 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4078 {
4079 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004080 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 return eSIR_FAILURE;
4082 }
4083
4084 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304085 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004086
4087 // Next, we fill out the buffer descriptor:
4088 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4089 SIR_MAC_MGMT_ACTION, peer);
4090 if ( eSIR_SUCCESS != nSirStatus )
4091 {
4092 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004093 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 nSirStatus );
4095 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4096 return eSIR_FAILURE; // just allocated...
4097 }
4098
4099 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4100
4101 nCfg = 6;
4102 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4103 if ( eSIR_SUCCESS != nSirStatus )
4104 {
4105 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004106 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 nSirStatus );
4108 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4109 return eSIR_FAILURE; // just allocated...
4110 }
4111
Chet Lanctot186b5732013-03-18 10:26:30 -07004112#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004113 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004114#endif
4115
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4117 sizeof(tSirMacMgmtHdr),
4118 nPayload, &nPayload );
4119 if ( DOT11F_FAILED( nStatus ) )
4120 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004121 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 nStatus );
4123 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4124 return eSIR_FAILURE; // allocated!
4125 }
4126 else if ( DOT11F_WARNED( nStatus ) )
4127 {
4128 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004129 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 }
4131
4132 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4133 HAL_TXRX_FRM_802_11_MGMT,
4134 ANI_TXDIR_TODS,
4135 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4136 limTxComplete, pFrame, 0 );
4137 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4138 {
4139 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004140 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 nSirStatus );
4142 //Pkt will be freed up by the callback
4143 return eSIR_FAILURE; // just allocated...
4144 }
4145
4146 return eSIR_SUCCESS;
4147
4148} // End limSendMeasReportFrame.
4149
4150
4151/**
4152 * \brief Send a TPC Request Action frame
4153 *
4154 *
4155 * \param pMac Pointer to the global MAC datastructure
4156 *
4157 * \param peer MAC address to which the frame should be sent
4158 *
4159 *
4160 */
4161
4162void
4163limSendTpcRequestFrame(tpAniSirGlobal pMac,
4164 tSirMacAddr peer)
4165{
4166 tDot11fTPCRequest frm;
4167 tANI_U8 *pFrame;
4168 tSirRetStatus nSirStatus;
4169 tpSirMacMgmtHdr pMacHdr;
4170 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4171 void *pPacket;
4172 eHalStatus halstatus;
4173
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304174 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004175
4176 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4177 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4178 frm.DialogToken.token = 1;
4179 frm.TPCRequest.present = 1;
4180
4181 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4182 if ( DOT11F_FAILED( nStatus ) )
4183 {
4184 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004185 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 nStatus );
4187 // We'll fall back on the worst case scenario:
4188 nPayload = sizeof( tDot11fTPCRequest );
4189 }
4190 else if ( DOT11F_WARNED( nStatus ) )
4191 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004192 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004194 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 }
4196
4197 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4198
4199 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4200 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4201 {
4202 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004203 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 return;
4205 }
4206
4207 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304208 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004209
4210 // Next, we fill out the buffer descriptor:
4211 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4212 SIR_MAC_MGMT_ACTION, peer);
4213 if ( eSIR_SUCCESS != nSirStatus )
4214 {
4215 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004216 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 nSirStatus );
4218 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4219 return; // just allocated...
4220 }
4221
4222 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4223
4224 nCfg = 6;
4225 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4226 if ( eSIR_SUCCESS != nSirStatus )
4227 {
4228 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004229 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004230 nSirStatus );
4231 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4232 return; // just allocated...
4233 }
4234
Chet Lanctot186b5732013-03-18 10:26:30 -07004235#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004236 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004237#endif
4238
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4240 sizeof(tSirMacMgmtHdr),
4241 nPayload, &nPayload );
4242 if ( DOT11F_FAILED( nStatus ) )
4243 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004244 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 nStatus );
4246 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4247 return; // allocated!
4248 }
4249 else if ( DOT11F_WARNED( nStatus ) )
4250 {
4251 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004252 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 }
4254
4255 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4256 HAL_TXRX_FRM_802_11_MGMT,
4257 ANI_TXDIR_TODS,
4258 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4259 limTxComplete, pFrame, 0 );
4260 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4261 {
4262 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004263 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 nSirStatus );
4265 //Pkt will be freed up by the callback
4266 return;
4267 }
4268
4269} // End limSendTpcRequestFrame.
4270
4271
4272/**
4273 * \brief Send a TPC Report Action frame
4274 *
4275 *
4276 * \param pMac Pointer to the global MAC datastructure
4277 *
4278 * \param pTpcReqFrame Pointer to the received TPC Request
4279 *
4280 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4281 *
4282 *
4283 */
4284
4285tSirRetStatus
4286limSendTpcReportFrame(tpAniSirGlobal pMac,
4287 tpSirMacTpcReqActionFrame pTpcReqFrame,
4288 tSirMacAddr peer)
4289{
4290 tDot11fTPCReport frm;
4291 tANI_U8 *pFrame;
4292 tSirRetStatus nSirStatus;
4293 tpSirMacMgmtHdr pMacHdr;
4294 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4295 void *pPacket;
4296 eHalStatus halstatus;
4297
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304298 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004299
4300 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4301 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4302 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4303
4304 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4305 // "misplaced this function, need to replace:
4306 // txPower = halGetRateToPwrValue(pMac, staid,
4307 // pMac->lim.gLimCurrentChannelId, 0);
4308 frm.TPCReport.tx_power = 0;
4309 frm.TPCReport.link_margin = 0;
4310 frm.TPCReport.present = 1;
4311
4312 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4313 if ( DOT11F_FAILED( nStatus ) )
4314 {
4315 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004316 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 nStatus );
4318 // We'll fall back on the worst case scenario:
4319 nPayload = sizeof( tDot11fTPCReport );
4320 }
4321 else if ( DOT11F_WARNED( nStatus ) )
4322 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004323 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004324 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004325 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 }
4327
4328 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4329
4330 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4331 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4332 {
4333 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004334 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 return eSIR_FAILURE;
4336 }
4337
4338 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304339 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004340
4341 // Next, we fill out the buffer descriptor:
4342 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4343 SIR_MAC_MGMT_ACTION, peer);
4344 if ( eSIR_SUCCESS != nSirStatus )
4345 {
4346 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004347 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 nSirStatus );
4349 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4350 return eSIR_FAILURE; // just allocated...
4351 }
4352
4353 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4354
4355 nCfg = 6;
4356 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4357 if ( eSIR_SUCCESS != nSirStatus )
4358 {
4359 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004360 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 nSirStatus );
4362 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4363 return eSIR_FAILURE; // just allocated...
4364 }
4365
Chet Lanctot186b5732013-03-18 10:26:30 -07004366#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004367 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004368#endif
4369
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4371 sizeof(tSirMacMgmtHdr),
4372 nPayload, &nPayload );
4373 if ( DOT11F_FAILED( nStatus ) )
4374 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004375 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 nStatus );
4377 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4378 return eSIR_FAILURE; // allocated!
4379 }
4380 else if ( DOT11F_WARNED( nStatus ) )
4381 {
4382 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004383 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 }
4385
4386
4387 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4388 HAL_TXRX_FRM_802_11_MGMT,
4389 ANI_TXDIR_TODS,
4390 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4391 limTxComplete, pFrame, 0 );
4392 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4393 {
4394 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004395 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 nSirStatus );
4397 //Pkt will be freed up by the callback
4398 return eSIR_FAILURE; // just allocated...
4399 }
4400
4401 return eSIR_SUCCESS;
4402
4403} // End limSendTpcReportFrame.
4404#endif //ANI_SUPPORT_11H
4405
4406
Jeff Johnson295189b2012-06-20 16:38:30 -07004407/**
4408 * \brief Send a Channel Switch Announcement
4409 *
4410 *
4411 * \param pMac Pointer to the global MAC datastructure
4412 *
4413 * \param peer MAC address to which this frame will be sent
4414 *
4415 * \param nMode
4416 *
4417 * \param nNewChannel
4418 *
4419 * \param nCount
4420 *
4421 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4422 *
4423 *
4424 */
4425
4426tSirRetStatus
4427limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4428 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004429 tANI_U8 nMode,
4430 tANI_U8 nNewChannel,
4431 tANI_U8 nCount,
4432 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004433{
4434 tDot11fChannelSwitch frm;
4435 tANI_U8 *pFrame;
4436 tSirRetStatus nSirStatus;
4437 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004438 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 void *pPacket;
4440 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004441 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004442
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304443 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004444
4445 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4446 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4447 frm.ChanSwitchAnn.switchMode = nMode;
4448 frm.ChanSwitchAnn.newChannel = nNewChannel;
4449 frm.ChanSwitchAnn.switchCount = nCount;
4450 frm.ChanSwitchAnn.present = 1;
4451
4452 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4453 if ( DOT11F_FAILED( nStatus ) )
4454 {
4455 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004456 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 nStatus );
4458 // We'll fall back on the worst case scenario:
4459 nPayload = sizeof( tDot11fChannelSwitch );
4460 }
4461 else if ( DOT11F_WARNED( nStatus ) )
4462 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004463 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004465 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 }
4467
4468 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4469
4470 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4471 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4472 {
4473 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004474 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 return eSIR_FAILURE;
4476 }
4477
4478 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304479 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004480
4481 // Next, we fill out the buffer descriptor:
4482 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004483 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4484 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304485 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4486 (tANI_U8 *) psessionEntry->bssId,
4487 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 if ( eSIR_SUCCESS != nSirStatus )
4489 {
4490 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004491 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 nSirStatus );
4493 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4494 return eSIR_FAILURE; // just allocated...
4495 }
4496
Jeff Johnsone7245742012-09-05 17:12:55 -07004497#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4499
4500 nCfg = 6;
4501 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4502 if ( eSIR_SUCCESS != nSirStatus )
4503 {
4504 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004505 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 nSirStatus );
4507 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4508 return eSIR_FAILURE; // just allocated...
4509 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004510#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004511
4512#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004513 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004514#endif
4515
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4517 sizeof(tSirMacMgmtHdr),
4518 nPayload, &nPayload );
4519 if ( DOT11F_FAILED( nStatus ) )
4520 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004521 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 nStatus );
4523 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4524 return eSIR_FAILURE; // allocated!
4525 }
4526 else if ( DOT11F_WARNED( nStatus ) )
4527 {
4528 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004529 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 }
4531
Jeff Johnsone7245742012-09-05 17:12:55 -07004532 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004533 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4534 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004535 )
4536 {
4537 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4540 HAL_TXRX_FRM_802_11_MGMT,
4541 ANI_TXDIR_TODS,
4542 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004543 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4545 {
4546 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004547 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 nSirStatus );
4549 //Pkt will be freed up by the callback
4550 return eSIR_FAILURE;
4551 }
4552
4553 return eSIR_SUCCESS;
4554
4555} // End limSendChannelSwitchMgmtFrame.
4556
Jeff Johnson295189b2012-06-20 16:38:30 -07004557
4558
Mohit Khanna4a70d262012-09-11 16:30:12 -07004559#ifdef WLAN_FEATURE_11AC
4560tSirRetStatus
4561limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4562 tSirMacAddr peer,
4563 tANI_U8 nMode,
4564 tpPESession psessionEntry )
4565{
4566 tDot11fOperatingMode frm;
4567 tANI_U8 *pFrame;
4568 tSirRetStatus nSirStatus;
4569 tpSirMacMgmtHdr pMacHdr;
4570 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4571 void *pPacket;
4572 eHalStatus halstatus;
4573 tANI_U8 txFlag = 0;
4574
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304575 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004576
4577 frm.Category.category = SIR_MAC_ACTION_VHT;
4578 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4579 frm.OperatingMode.chanWidth = nMode;
4580 frm.OperatingMode.rxNSS = 0;
4581 frm.OperatingMode.rxNSSType = 0;
4582
4583 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4584 if ( DOT11F_FAILED( nStatus ) )
4585 {
4586 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004587 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004588 nStatus );
4589 // We'll fall back on the worst case scenario:
4590 nPayload = sizeof( tDot11fOperatingMode);
4591 }
4592 else if ( DOT11F_WARNED( nStatus ) )
4593 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004594 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004595 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004596 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004597 }
4598
4599 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4600
4601 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4602 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4603 {
4604 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004605 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004606 return eSIR_FAILURE;
4607 }
4608
4609 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304610 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004611
4612
4613 // Next, we fill out the buffer descriptor:
4614 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4615 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4616 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4617 } else
4618 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4619 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4620 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304621 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4622 (tANI_U8 *) psessionEntry->bssId,
4623 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004624 if ( eSIR_SUCCESS != nSirStatus )
4625 {
4626 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004627 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004628 nSirStatus );
4629 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4630 return eSIR_FAILURE; // just allocated...
4631 }
4632 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4633 sizeof(tSirMacMgmtHdr),
4634 nPayload, &nPayload );
4635 if ( DOT11F_FAILED( nStatus ) )
4636 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004637 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004638 nStatus );
4639 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4640 return eSIR_FAILURE; // allocated!
4641 }
4642 else if ( DOT11F_WARNED( nStatus ) )
4643 {
4644 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004645 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004646 }
4647 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004648 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4649 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004650 )
4651 {
4652 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4653 }
4654 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4655 HAL_TXRX_FRM_802_11_MGMT,
4656 ANI_TXDIR_TODS,
4657 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4658 limTxComplete, pFrame, txFlag );
4659 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4660 {
4661 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004662 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004663 nSirStatus );
4664 //Pkt will be freed up by the callback
4665 return eSIR_FAILURE;
4666 }
4667
4668 return eSIR_SUCCESS;
4669}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004670
4671/**
4672 * \brief Send a VHT Channel Switch Announcement
4673 *
4674 *
4675 * \param pMac Pointer to the global MAC datastructure
4676 *
4677 * \param peer MAC address to which this frame will be sent
4678 *
4679 * \param nChanWidth
4680 *
4681 * \param nNewChannel
4682 *
4683 *
4684 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4685 *
4686 *
4687 */
4688
4689tSirRetStatus
4690limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4691 tSirMacAddr peer,
4692 tANI_U8 nChanWidth,
4693 tANI_U8 nNewChannel,
4694 tANI_U8 ncbMode,
4695 tpPESession psessionEntry )
4696{
4697 tDot11fChannelSwitch frm;
4698 tANI_U8 *pFrame;
4699 tSirRetStatus nSirStatus;
4700 tpSirMacMgmtHdr pMacHdr;
4701 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4702 void *pPacket;
4703 eHalStatus halstatus;
4704 tANI_U8 txFlag = 0;
4705
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304706 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004707
4708
4709 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4710 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4711 frm.ChanSwitchAnn.switchMode = 1;
4712 frm.ChanSwitchAnn.newChannel = nNewChannel;
4713 frm.ChanSwitchAnn.switchCount = 1;
4714 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4715 frm.ExtChanSwitchAnn.present = 1;
4716 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4717 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4718 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4719 frm.ChanSwitchAnn.present = 1;
4720 frm.WiderBWChanSwitchAnn.present = 1;
4721
4722 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4723 if ( DOT11F_FAILED( nStatus ) )
4724 {
4725 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004726 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004727 nStatus );
4728 // We'll fall back on the worst case scenario:
4729 nPayload = sizeof( tDot11fChannelSwitch );
4730 }
4731 else if ( DOT11F_WARNED( nStatus ) )
4732 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004733 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004734 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004735 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004736 }
4737
4738 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4739
4740 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4741 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4742 {
4743 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004744 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004745 return eSIR_FAILURE;
4746 }
4747 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304748 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004749
4750 // Next, we fill out the buffer descriptor:
4751 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4752 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4753 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304754 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4755 (tANI_U8 *) psessionEntry->bssId,
4756 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004757 if ( eSIR_SUCCESS != nSirStatus )
4758 {
4759 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004760 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004761 nSirStatus );
4762 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4763 return eSIR_FAILURE; // just allocated...
4764 }
4765 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4766 sizeof(tSirMacMgmtHdr),
4767 nPayload, &nPayload );
4768 if ( DOT11F_FAILED( nStatus ) )
4769 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004770 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004771 nStatus );
4772 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4773 return eSIR_FAILURE; // allocated!
4774 }
4775 else if ( DOT11F_WARNED( nStatus ) )
4776 {
4777 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004778 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004779 }
4780
4781 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004782 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4783 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004784 )
4785 {
4786 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4787 }
4788 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4789 HAL_TXRX_FRM_802_11_MGMT,
4790 ANI_TXDIR_TODS,
4791 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4792 limTxComplete, pFrame, txFlag );
4793 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4794 {
4795 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004796 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004797 nSirStatus );
4798 //Pkt will be freed up by the callback
4799 return eSIR_FAILURE;
4800 }
4801
4802 return eSIR_SUCCESS;
4803
4804} // End limSendVHTChannelSwitchMgmtFrame.
4805
4806
4807
Mohit Khanna4a70d262012-09-11 16:30:12 -07004808#endif
4809
Jeff Johnson295189b2012-06-20 16:38:30 -07004810/**
4811 * \brief Send an ADDBA Req Action Frame to peer
4812 *
4813 * \sa limSendAddBAReq
4814 *
4815 * \param pMac The global tpAniSirGlobal object
4816 *
4817 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4818 * the necessary parameters reqd by PE send the ADDBA Req Action
4819 * Frame to the peer
4820 *
4821 * \return eSIR_SUCCESS if setup completes successfully
4822 * eSIR_FAILURE is some problem is encountered
4823 */
4824tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304825 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004826{
4827 tDot11fAddBAReq frmAddBAReq;
4828 tANI_U8 *pAddBAReqBuffer = NULL;
4829 tpSirMacMgmtHdr pMacHdr;
4830 tANI_U32 frameLen = 0, nStatus, nPayload;
4831 tSirRetStatus statusCode;
4832 eHalStatus halStatus;
4833 void *pPacket;
4834 tANI_U8 txFlag = 0;
4835
4836 if(NULL == psessionEntry)
4837 {
4838 return eSIR_FAILURE;
4839 }
4840
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304841 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004842
4843 // Category - 3 (BA)
4844 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4845
4846 // Action - 0 (ADDBA Req)
4847 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4848
4849 // FIXME - Dialog Token, generalize this...
4850 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4851
4852 // Fill the ADDBA Parameter Set
4853 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4854 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4855 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4856
4857 // BA timeout
4858 // 0 - indicates no BA timeout
4859 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4860
4861 // BA Starting Sequence Number
4862 // Fragment number will always be zero
4863 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4864 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4865 }
4866
4867 frmAddBAReq.BAStartingSequenceControl.ssn =
4868 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4869
4870 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4871
4872 if( DOT11F_FAILED( nStatus ))
4873 {
4874 limLog( pMac, LOGW,
4875 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004876 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 nStatus );
4878
4879 // We'll fall back on the worst case scenario:
4880 nPayload = sizeof( tDot11fAddBAReq );
4881 }
4882 else if( DOT11F_WARNED( nStatus ))
4883 {
4884 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004885 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004886 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 nStatus );
4888 }
4889
4890 // Add the MGMT header to frame length
4891 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4892
4893 // Need to allocate a buffer for ADDBA AF
4894 if( eHAL_STATUS_SUCCESS !=
4895 (halStatus = palPktAlloc( pMac->hHdd,
4896 HAL_TXRX_FRM_802_11_MGMT,
4897 (tANI_U16) frameLen,
4898 (void **) &pAddBAReqBuffer,
4899 (void **) &pPacket )))
4900 {
4901 // Log error
4902 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004903 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 frameLen,
4905 halStatus );
4906
4907 statusCode = eSIR_MEM_ALLOC_FAILED;
4908 goto returnAfterError;
4909 }
4910
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304911 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004912
4913 // Copy necessary info to BD
4914 if( eSIR_SUCCESS !=
4915 (statusCode = limPopulateMacHeader( pMac,
4916 pAddBAReqBuffer,
4917 SIR_MAC_MGMT_FRAME,
4918 SIR_MAC_MGMT_ACTION,
4919 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4920 goto returnAfterError;
4921
4922 // Update A3 with the BSSID
4923 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4924
4925 #if 0
4926 cfgLen = SIR_MAC_ADDR_LENGTH;
4927 if( eSIR_SUCCESS != cfgGetStr( pMac,
4928 WNI_CFG_BSSID,
4929 (tANI_U8 *) pMacHdr->bssId,
4930 &cfgLen ))
4931 {
4932 limLog( pMac, LOGP,
4933 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004934 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004935
4936 // FIXME - Need to convert to tSirRetStatus
4937 statusCode = eSIR_FAILURE;
4938 goto returnAfterError;
4939 }
4940 #endif//TO SUPPORT BT-AMP
4941 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4942
Chet Lanctot186b5732013-03-18 10:26:30 -07004943#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004944 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004945#endif
4946
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 // Now, we're ready to "pack" the frames
4948 nStatus = dot11fPackAddBAReq( pMac,
4949 &frmAddBAReq,
4950 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4951 nPayload,
4952 &nPayload );
4953
4954 if( DOT11F_FAILED( nStatus ))
4955 {
4956 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004957 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004958 nStatus );
4959
4960 // FIXME - Need to convert to tSirRetStatus
4961 statusCode = eSIR_FAILURE;
4962 goto returnAfterError;
4963 }
4964 else if( DOT11F_WARNED( nStatus ))
4965 {
4966 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004967 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
4968 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 }
4970
4971 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004972 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4974
4975 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4977 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 )
4979 {
4980 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4981 }
4982
4983 if( eHAL_STATUS_SUCCESS !=
4984 (halStatus = halTxFrame( pMac,
4985 pPacket,
4986 (tANI_U16) frameLen,
4987 HAL_TXRX_FRM_802_11_MGMT,
4988 ANI_TXDIR_TODS,
4989 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4990 limTxComplete,
4991 pAddBAReqBuffer, txFlag )))
4992 {
4993 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004994 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 halStatus );
4996
4997 // FIXME - Need to convert eHalStatus to tSirRetStatus
4998 statusCode = eSIR_FAILURE;
4999 //Pkt will be freed up by the callback
5000 return statusCode;
5001 }
5002 else
5003 return eSIR_SUCCESS;
5004
5005returnAfterError:
5006
5007 // Release buffer, if allocated
5008 if( NULL != pAddBAReqBuffer )
5009 palPktFree( pMac->hHdd,
5010 HAL_TXRX_FRM_802_11_MGMT,
5011 (void *) pAddBAReqBuffer,
5012 (void *) pPacket );
5013
5014 return statusCode;
5015}
5016
5017/**
5018 * \brief Send an ADDBA Rsp Action Frame to peer
5019 *
5020 * \sa limSendAddBARsp
5021 *
5022 * \param pMac The global tpAniSirGlobal object
5023 *
5024 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5025 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5026 * Frame to the peer
5027 *
5028 * \return eSIR_SUCCESS if setup completes successfully
5029 * eSIR_FAILURE is some problem is encountered
5030 */
5031tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5032 tpLimMlmAddBARsp pMlmAddBARsp,
5033 tpPESession psessionEntry)
5034{
5035 tDot11fAddBARsp frmAddBARsp;
5036 tANI_U8 *pAddBARspBuffer = NULL;
5037 tpSirMacMgmtHdr pMacHdr;
5038 tANI_U32 frameLen = 0, nStatus, nPayload;
5039 tSirRetStatus statusCode;
5040 eHalStatus halStatus;
5041 void *pPacket;
5042 tANI_U8 txFlag = 0;
5043
5044 if(NULL == psessionEntry)
5045 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005046 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 return eSIR_FAILURE;
5048 }
5049
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305050 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005051
5052 // Category - 3 (BA)
5053 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5054 // Action - 1 (ADDBA Rsp)
5055 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5056
5057 // Should be same as the one we received in the ADDBA Req
5058 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5059
5060 // ADDBA Req status
5061 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5062
5063 // Fill the ADDBA Parameter Set as provided by caller
5064 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5065 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5066 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005067
5068 if(psessionEntry->isAmsduSupportInAMPDU)
5069 {
5070 frmAddBARsp.AddBAParameterSet.amsduSupported =
5071 psessionEntry->amsduSupportedInBA;
5072 }
5073 else
5074 {
5075 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005077
5078 // BA timeout
5079 // 0 - indicates no BA timeout
5080 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5081
5082 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5083
5084 if( DOT11F_FAILED( nStatus ))
5085 {
5086 limLog( pMac, LOGW,
5087 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005088 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 nStatus );
5090
5091 // We'll fall back on the worst case scenario:
5092 nPayload = sizeof( tDot11fAddBARsp );
5093 }
5094 else if( DOT11F_WARNED( nStatus ))
5095 {
5096 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005097 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005098 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 nStatus );
5100 }
5101
5102 // Need to allocate a buffer for ADDBA AF
5103 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5104
5105 // Allocate shared memory
5106 if( eHAL_STATUS_SUCCESS !=
5107 (halStatus = palPktAlloc( pMac->hHdd,
5108 HAL_TXRX_FRM_802_11_MGMT,
5109 (tANI_U16) frameLen,
5110 (void **) &pAddBARspBuffer,
5111 (void **) &pPacket )))
5112 {
5113 // Log error
5114 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005115 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 frameLen,
5117 halStatus );
5118
5119 statusCode = eSIR_MEM_ALLOC_FAILED;
5120 goto returnAfterError;
5121 }
5122
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305123 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005124
5125 // Copy necessary info to BD
5126 if( eSIR_SUCCESS !=
5127 (statusCode = limPopulateMacHeader( pMac,
5128 pAddBARspBuffer,
5129 SIR_MAC_MGMT_FRAME,
5130 SIR_MAC_MGMT_ACTION,
5131 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5132 goto returnAfterError;
5133
5134 // Update A3 with the BSSID
5135
5136 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5137
5138 #if 0
5139 cfgLen = SIR_MAC_ADDR_LENGTH;
5140 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5141 WNI_CFG_BSSID,
5142 (tANI_U8 *) pMacHdr->bssId,
5143 &cfgLen ))
5144 {
5145 limLog( pMac, LOGP,
5146 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005147 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005148
5149 // FIXME - Need to convert to tSirRetStatus
5150 statusCode = eSIR_FAILURE;
5151 goto returnAfterError;
5152 }
5153 #endif // TO SUPPORT BT-AMP
5154 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5155
Chet Lanctot186b5732013-03-18 10:26:30 -07005156#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005157 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005158#endif
5159
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 // Now, we're ready to "pack" the frames
5161 nStatus = dot11fPackAddBARsp( pMac,
5162 &frmAddBARsp,
5163 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5164 nPayload,
5165 &nPayload );
5166
5167 if( DOT11F_FAILED( nStatus ))
5168 {
5169 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005170 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 nStatus );
5172
5173 // FIXME - Need to convert to tSirRetStatus
5174 statusCode = eSIR_FAILURE;
5175 goto returnAfterError;
5176 }
5177 else if( DOT11F_WARNED( nStatus ))
5178 {
5179 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005180 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5181 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 }
5183
5184 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005185 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5187
5188 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5190 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 )
5192 {
5193 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5194 }
5195
5196 if( eHAL_STATUS_SUCCESS !=
5197 (halStatus = halTxFrame( pMac,
5198 pPacket,
5199 (tANI_U16) frameLen,
5200 HAL_TXRX_FRM_802_11_MGMT,
5201 ANI_TXDIR_TODS,
5202 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5203 limTxComplete,
5204 pAddBARspBuffer, txFlag )))
5205 {
5206 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005207 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 halStatus );
5209
5210 // FIXME - HAL error codes are different from PE error
5211 // codes!! And, this routine is returning tSirRetStatus
5212 statusCode = eSIR_FAILURE;
5213 //Pkt will be freed up by the callback
5214 return statusCode;
5215 }
5216 else
5217 return eSIR_SUCCESS;
5218
5219 returnAfterError:
5220
5221 // Release buffer, if allocated
5222 if( NULL != pAddBARspBuffer )
5223 palPktFree( pMac->hHdd,
5224 HAL_TXRX_FRM_802_11_MGMT,
5225 (void *) pAddBARspBuffer,
5226 (void *) pPacket );
5227
5228 return statusCode;
5229}
5230
5231/**
5232 * \brief Send a DELBA Indication Action Frame to peer
5233 *
5234 * \sa limSendDelBAInd
5235 *
5236 * \param pMac The global tpAniSirGlobal object
5237 *
5238 * \param peerMacAddr MAC Address of peer
5239 *
5240 * \param reasonCode Reason for the DELBA notification
5241 *
5242 * \param pBAParameterSet The DELBA Parameter Set.
5243 * This identifies the TID for which the BA session is
5244 * being deleted.
5245 *
5246 * \return eSIR_SUCCESS if setup completes successfully
5247 * eSIR_FAILURE is some problem is encountered
5248 */
5249tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5250 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5251{
5252 tDot11fDelBAInd frmDelBAInd;
5253 tANI_U8 *pDelBAIndBuffer = NULL;
5254 //tANI_U32 val;
5255 tpSirMacMgmtHdr pMacHdr;
5256 tANI_U32 frameLen = 0, nStatus, nPayload;
5257 tSirRetStatus statusCode;
5258 eHalStatus halStatus;
5259 void *pPacket;
5260 tANI_U8 txFlag = 0;
5261
5262 if(NULL == psessionEntry)
5263 {
5264 return eSIR_FAILURE;
5265 }
5266
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305267 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005268
5269 // Category - 3 (BA)
5270 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5271 // Action - 2 (DELBA)
5272 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5273
5274 // Fill the DELBA Parameter Set as provided by caller
5275 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5276 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5277
5278 // BA Starting Sequence Number
5279 // Fragment number will always be zero
5280 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5281
5282 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5283
5284 if( DOT11F_FAILED( nStatus ))
5285 {
5286 limLog( pMac, LOGW,
5287 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005288 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 nStatus );
5290
5291 // We'll fall back on the worst case scenario:
5292 nPayload = sizeof( tDot11fDelBAInd );
5293 }
5294 else if( DOT11F_WARNED( nStatus ))
5295 {
5296 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005297 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005298 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 nStatus );
5300 }
5301
5302 // Add the MGMT header to frame length
5303 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5304
5305 // Allocate shared memory
5306 if( eHAL_STATUS_SUCCESS !=
5307 (halStatus = palPktAlloc( pMac->hHdd,
5308 HAL_TXRX_FRM_802_11_MGMT,
5309 (tANI_U16) frameLen,
5310 (void **) &pDelBAIndBuffer,
5311 (void **) &pPacket )))
5312 {
5313 // Log error
5314 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005315 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 frameLen,
5317 halStatus );
5318
5319 statusCode = eSIR_MEM_ALLOC_FAILED;
5320 goto returnAfterError;
5321 }
5322
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305323 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005324
5325 // Copy necessary info to BD
5326 if( eSIR_SUCCESS !=
5327 (statusCode = limPopulateMacHeader( pMac,
5328 pDelBAIndBuffer,
5329 SIR_MAC_MGMT_FRAME,
5330 SIR_MAC_MGMT_ACTION,
5331 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5332 goto returnAfterError;
5333
5334 // Update A3 with the BSSID
5335 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5336
5337 #if 0
5338 cfgLen = SIR_MAC_ADDR_LENGTH;
5339 if( eSIR_SUCCESS != cfgGetStr( pMac,
5340 WNI_CFG_BSSID,
5341 (tANI_U8 *) pMacHdr->bssId,
5342 &cfgLen ))
5343 {
5344 limLog( pMac, LOGP,
5345 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005346 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005347
5348 // FIXME - Need to convert to tSirRetStatus
5349 statusCode = eSIR_FAILURE;
5350 goto returnAfterError;
5351 }
5352 #endif //TO SUPPORT BT-AMP
5353 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5354
Chet Lanctot186b5732013-03-18 10:26:30 -07005355#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005356 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005357#endif
5358
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 // Now, we're ready to "pack" the frames
5360 nStatus = dot11fPackDelBAInd( pMac,
5361 &frmDelBAInd,
5362 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5363 nPayload,
5364 &nPayload );
5365
5366 if( DOT11F_FAILED( nStatus ))
5367 {
5368 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005369 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 nStatus );
5371
5372 // FIXME - Need to convert to tSirRetStatus
5373 statusCode = eSIR_FAILURE;
5374 goto returnAfterError;
5375 }
5376 else if( DOT11F_WARNED( nStatus ))
5377 {
5378 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005379 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5380 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 }
5382
5383 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005384 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5386
5387 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5389 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 )
5391 {
5392 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5393 }
5394
5395 if( eHAL_STATUS_SUCCESS !=
5396 (halStatus = halTxFrame( pMac,
5397 pPacket,
5398 (tANI_U16) frameLen,
5399 HAL_TXRX_FRM_802_11_MGMT,
5400 ANI_TXDIR_TODS,
5401 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5402 limTxComplete,
5403 pDelBAIndBuffer, txFlag )))
5404 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005405 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 statusCode = eSIR_FAILURE;
5407 //Pkt will be freed up by the callback
5408 return statusCode;
5409 }
5410 else
5411 return eSIR_SUCCESS;
5412
5413 returnAfterError:
5414
5415 // Release buffer, if allocated
5416 if( NULL != pDelBAIndBuffer )
5417 palPktFree( pMac->hHdd,
5418 HAL_TXRX_FRM_802_11_MGMT,
5419 (void *) pDelBAIndBuffer,
5420 (void *) pPacket );
5421
5422 return statusCode;
5423}
5424
5425#if defined WLAN_FEATURE_VOWIFI
5426
5427/**
5428 * \brief Send a Neighbor Report Request Action frame
5429 *
5430 *
5431 * \param pMac Pointer to the global MAC structure
5432 *
5433 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5434 *
5435 * \param peer mac address of peer station.
5436 *
5437 * \param psessionEntry address of session entry.
5438 *
5439 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5440 *
5441 *
5442 */
5443
5444tSirRetStatus
5445limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5446 tpSirMacNeighborReportReq pNeighborReq,
5447 tSirMacAddr peer,
5448 tpPESession psessionEntry
5449 )
5450{
5451 tSirRetStatus statusCode = eSIR_SUCCESS;
5452 tDot11fNeighborReportRequest frm;
5453 tANI_U8 *pFrame;
5454 tpSirMacMgmtHdr pMacHdr;
5455 tANI_U32 nBytes, nPayload, nStatus;
5456 void *pPacket;
5457 eHalStatus halstatus;
5458 tANI_U8 txFlag = 0;
5459
5460 if ( psessionEntry == NULL )
5461 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005462 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 return eSIR_FAILURE;
5464 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305465 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005466
5467 frm.Category.category = SIR_MAC_ACTION_RRM;
5468 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5469 frm.DialogToken.token = pNeighborReq->dialogToken;
5470
5471
5472 if( pNeighborReq->ssid_present )
5473 {
5474 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5475 }
5476
5477 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5478 if ( DOT11F_FAILED( nStatus ) )
5479 {
5480 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005481 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 nStatus );
5483 // We'll fall back on the worst case scenario:
5484 nPayload = sizeof( tDot11fNeighborReportRequest );
5485 }
5486 else if ( DOT11F_WARNED( nStatus ) )
5487 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005488 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005490 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 }
5492
5493 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5494
5495 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5496 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5497 {
5498 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005499 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 return eSIR_FAILURE;
5501 }
5502
5503 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305504 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005505
5506 // Copy necessary info to BD
5507 if( eSIR_SUCCESS !=
5508 (statusCode = limPopulateMacHeader( pMac,
5509 pFrame,
5510 SIR_MAC_MGMT_FRAME,
5511 SIR_MAC_MGMT_ACTION,
5512 peer, psessionEntry->selfMacAddr)))
5513 goto returnAfterError;
5514
5515 // Update A3 with the BSSID
5516 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5517
5518 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5519
Chet Lanctot186b5732013-03-18 10:26:30 -07005520#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005521 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005522#endif
5523
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 // Now, we're ready to "pack" the frames
5525 nStatus = dot11fPackNeighborReportRequest( pMac,
5526 &frm,
5527 pFrame + sizeof( tSirMacMgmtHdr ),
5528 nPayload,
5529 &nPayload );
5530
5531 if( DOT11F_FAILED( nStatus ))
5532 {
5533 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005534 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 nStatus );
5536
5537 // FIXME - Need to convert to tSirRetStatus
5538 statusCode = eSIR_FAILURE;
5539 goto returnAfterError;
5540 }
5541 else if( DOT11F_WARNED( nStatus ))
5542 {
5543 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005544 FL( "There were warnings while packing Neighbor Report "
5545 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 }
5547
5548 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005549 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 limPrintMacAddr( pMac, peer, LOGW );
5551
5552 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5554 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 )
5556 {
5557 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5558 }
5559
5560 if( eHAL_STATUS_SUCCESS !=
5561 (halstatus = halTxFrame( pMac,
5562 pPacket,
5563 (tANI_U16) nBytes,
5564 HAL_TXRX_FRM_802_11_MGMT,
5565 ANI_TXDIR_TODS,
5566 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5567 limTxComplete,
5568 pFrame, txFlag )))
5569 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005570 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005571 statusCode = eSIR_FAILURE;
5572 //Pkt will be freed up by the callback
5573 return statusCode;
5574 }
5575 else
5576 return eSIR_SUCCESS;
5577
5578returnAfterError:
5579 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5580
5581 return statusCode;
5582} // End limSendNeighborReportRequestFrame.
5583
5584/**
5585 * \brief Send a Link Report Action frame
5586 *
5587 *
5588 * \param pMac Pointer to the global MAC structure
5589 *
5590 * \param pLinkReport Address of a tSirMacLinkReport
5591 *
5592 * \param peer mac address of peer station.
5593 *
5594 * \param psessionEntry address of session entry.
5595 *
5596 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5597 *
5598 *
5599 */
5600
5601tSirRetStatus
5602limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5603 tpSirMacLinkReport pLinkReport,
5604 tSirMacAddr peer,
5605 tpPESession psessionEntry
5606 )
5607{
5608 tSirRetStatus statusCode = eSIR_SUCCESS;
5609 tDot11fLinkMeasurementReport frm;
5610 tANI_U8 *pFrame;
5611 tpSirMacMgmtHdr pMacHdr;
5612 tANI_U32 nBytes, nPayload, nStatus;
5613 void *pPacket;
5614 eHalStatus halstatus;
5615 tANI_U8 txFlag = 0;
5616
5617
5618 if ( psessionEntry == NULL )
5619 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005620 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 return eSIR_FAILURE;
5622 }
5623
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305624 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005625
5626 frm.Category.category = SIR_MAC_ACTION_RRM;
5627 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5628 frm.DialogToken.token = pLinkReport->dialogToken;
5629
5630
5631 //IEEE Std. 802.11 7.3.2.18. for the report element.
5632 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5633 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5634 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5635 //such case this way than changing the frame parser.
5636 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5637 frm.TPCEleLen.TPCLen = 2;
5638 frm.TxPower.txPower = pLinkReport->txPower;
5639 frm.LinkMargin.linkMargin = 0;
5640
5641 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5642 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5643 frm.RCPI.rcpi = pLinkReport->rcpi;
5644 frm.RSNI.rsni = pLinkReport->rsni;
5645
5646 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5647 if ( DOT11F_FAILED( nStatus ) )
5648 {
5649 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005650 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 nStatus );
5652 // We'll fall back on the worst case scenario:
5653 nPayload = sizeof( tDot11fLinkMeasurementReport );
5654 }
5655 else if ( DOT11F_WARNED( nStatus ) )
5656 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005657 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005659 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 }
5661
5662 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5663
5664 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5665 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5666 {
5667 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005668 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 return eSIR_FAILURE;
5670 }
5671
5672 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305673 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005674
5675 // Copy necessary info to BD
5676 if( eSIR_SUCCESS !=
5677 (statusCode = limPopulateMacHeader( pMac,
5678 pFrame,
5679 SIR_MAC_MGMT_FRAME,
5680 SIR_MAC_MGMT_ACTION,
5681 peer, psessionEntry->selfMacAddr)))
5682 goto returnAfterError;
5683
5684 // Update A3 with the BSSID
5685 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5686
5687 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5688
Chet Lanctot186b5732013-03-18 10:26:30 -07005689#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005690 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005691#endif
5692
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 // Now, we're ready to "pack" the frames
5694 nStatus = dot11fPackLinkMeasurementReport( pMac,
5695 &frm,
5696 pFrame + sizeof( tSirMacMgmtHdr ),
5697 nPayload,
5698 &nPayload );
5699
5700 if( DOT11F_FAILED( nStatus ))
5701 {
5702 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005703 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 nStatus );
5705
5706 // FIXME - Need to convert to tSirRetStatus
5707 statusCode = eSIR_FAILURE;
5708 goto returnAfterError;
5709 }
5710 else if( DOT11F_WARNED( nStatus ))
5711 {
5712 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005713 FL( "There were warnings while packing Link Report (0x%08x)." ),
5714 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 }
5716
5717 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005718 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 limPrintMacAddr( pMac, peer, LOGW );
5720
5721 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5723 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 )
5725 {
5726 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5727 }
5728
5729 if( eHAL_STATUS_SUCCESS !=
5730 (halstatus = halTxFrame( pMac,
5731 pPacket,
5732 (tANI_U16) nBytes,
5733 HAL_TXRX_FRM_802_11_MGMT,
5734 ANI_TXDIR_TODS,
5735 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5736 limTxComplete,
5737 pFrame, txFlag )))
5738 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005739 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 statusCode = eSIR_FAILURE;
5741 //Pkt will be freed up by the callback
5742 return statusCode;
5743 }
5744 else
5745 return eSIR_SUCCESS;
5746
5747returnAfterError:
5748 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5749
5750 return statusCode;
5751} // End limSendLinkReportActionFrame.
5752
5753/**
5754 * \brief Send a Beacon Report Action frame
5755 *
5756 *
5757 * \param pMac Pointer to the global MAC structure
5758 *
5759 * \param dialog_token dialog token to be used in the action frame.
5760 *
5761 * \param num_report number of reports in pRRMReport.
5762 *
5763 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5764 *
5765 * \param peer mac address of peer station.
5766 *
5767 * \param psessionEntry address of session entry.
5768 *
5769 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5770 *
5771 *
5772 */
5773
5774tSirRetStatus
5775limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5776 tANI_U8 dialog_token,
5777 tANI_U8 num_report,
5778 tpSirMacRadioMeasureReport pRRMReport,
5779 tSirMacAddr peer,
5780 tpPESession psessionEntry
5781 )
5782{
5783 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 tANI_U8 *pFrame;
5785 tpSirMacMgmtHdr pMacHdr;
5786 tANI_U32 nBytes, nPayload, nStatus;
5787 void *pPacket;
5788 eHalStatus halstatus;
5789 tANI_U8 i;
5790 tANI_U8 txFlag = 0;
5791
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005792 tDot11fRadioMeasurementReport *frm =
5793 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5794 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005795 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005796 return eSIR_FAILURE;
5797 }
5798
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 if ( psessionEntry == NULL )
5800 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005801 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005802 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005803 return eSIR_FAILURE;
5804 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305805 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005806
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005807 frm->Category.category = SIR_MAC_ACTION_RRM;
5808 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5809 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005810
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005811 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 -07005812
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005813 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005815 frm->MeasurementReport[i].type = pRRMReport[i].type;
5816 frm->MeasurementReport[i].token = pRRMReport[i].token;
5817 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 switch( pRRMReport[i].type )
5819 {
5820 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005821 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5822 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5823 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5824 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 break;
5826 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305827 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5828 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005829 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 break;
5831 }
5832 }
5833
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005834 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 if ( DOT11F_FAILED( nStatus ) )
5836 {
5837 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005838 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 nStatus );
5840 // We'll fall back on the worst case scenario:
5841 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005842 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 return eSIR_FAILURE;
5844 }
5845 else if ( DOT11F_WARNED( nStatus ) )
5846 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005847 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005849 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 }
5851
5852 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5853
5854 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5855 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5856 {
5857 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005858 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005859 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 return eSIR_FAILURE;
5861 }
5862
5863 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305864 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005865
5866 // Copy necessary info to BD
5867 if( eSIR_SUCCESS !=
5868 (statusCode = limPopulateMacHeader( pMac,
5869 pFrame,
5870 SIR_MAC_MGMT_FRAME,
5871 SIR_MAC_MGMT_ACTION,
5872 peer, psessionEntry->selfMacAddr)))
5873 goto returnAfterError;
5874
5875 // Update A3 with the BSSID
5876 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5877
5878 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5879
Chet Lanctot186b5732013-03-18 10:26:30 -07005880#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005881 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005882#endif
5883
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 // Now, we're ready to "pack" the frames
5885 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005886 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 pFrame + sizeof( tSirMacMgmtHdr ),
5888 nPayload,
5889 &nPayload );
5890
5891 if( DOT11F_FAILED( nStatus ))
5892 {
5893 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005894 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005895 nStatus );
5896
5897 // FIXME - Need to convert to tSirRetStatus
5898 statusCode = eSIR_FAILURE;
5899 goto returnAfterError;
5900 }
5901 else if( DOT11F_WARNED( nStatus ))
5902 {
5903 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005904 FL( "There were warnings while packing Radio "
5905 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 }
5907
5908 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005909 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 limPrintMacAddr( pMac, peer, LOGW );
5911
5912 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5914 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 )
5916 {
5917 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5918 }
5919
5920 if( eHAL_STATUS_SUCCESS !=
5921 (halstatus = halTxFrame( pMac,
5922 pPacket,
5923 (tANI_U16) nBytes,
5924 HAL_TXRX_FRM_802_11_MGMT,
5925 ANI_TXDIR_TODS,
5926 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5927 limTxComplete,
5928 pFrame, txFlag )))
5929 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005930 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 statusCode = eSIR_FAILURE;
5932 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005933 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 return statusCode;
5935 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005936 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005937 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005940
5941returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005942 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 return statusCode;
5945} // End limSendBeaconReportActionFrame.
5946
5947#endif
5948
5949#ifdef WLAN_FEATURE_11W
5950/**
5951 * \brief Send SA query response action frame to peer
5952 *
5953 * \sa limSendSaQueryResponseFrame
5954 *
5955 *
5956 * \param pMac The global tpAniSirGlobal object
5957 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005958 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005960 * \param peer The Mac address of the AP to which this action frame is addressed
5961 *
5962 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 *
5964 * \return eSIR_SUCCESS if setup completes successfully
5965 * eSIR_FAILURE is some problem is encountered
5966 */
5967
Chet Lanctot186b5732013-03-18 10:26:30 -07005968tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005969tSirMacAddr peer,tpPESession psessionEntry)
5970{
5971
Chet Lanctot186b5732013-03-18 10:26:30 -07005972 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 tANI_U8 *pFrame;
5974 tSirRetStatus nSirStatus;
5975 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07005976 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 void *pPacket;
5978 eHalStatus halstatus;
Chet Lanctot186b5732013-03-18 10:26:30 -07005979 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005980
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305981 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07005982 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
5983 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 action: 0 --> SA query request action frame
5985 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07005986 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
5987 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07005989 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005990
Chet Lanctot186b5732013-03-18 10:26:30 -07005991 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
5992 if ( DOT11F_FAILED( nStatus ) )
5993 {
5994 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5995 "or a SA Query Response (0x%08x)."),
5996 nStatus );
5997 // We'll fall back on the worst case scenario:
5998 nPayload = sizeof( tDot11fSaQueryRsp );
5999 }
6000 else if ( DOT11F_WARNED( nStatus ) )
6001 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006002 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006003 "the packed size for an SA Query Response"
6004 " (0x%08x)."), nStatus );
6005 }
6006
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6008 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6009 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6010 {
6011 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006012 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 return eSIR_FAILURE;
6014 }
6015
6016 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306017 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006018
Chet Lanctot186b5732013-03-18 10:26:30 -07006019 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006020 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006021 pFrame,
6022 SIR_MAC_MGMT_FRAME,
6023 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006024 peer, psessionEntry->selfMacAddr );
6025 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006026 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006027
Chet Lanctot186b5732013-03-18 10:26:30 -07006028 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6030
Chet Lanctot186b5732013-03-18 10:26:30 -07006031 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006032
Chet Lanctot186b5732013-03-18 10:26:30 -07006033 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6034 // in the FC
6035 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006037 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 }
6039
Chet Lanctot186b5732013-03-18 10:26:30 -07006040 // Pack 11w SA query response frame
6041 nStatus = dot11fPackSaQueryRsp( pMac,
6042 &frm,
6043 pFrame + sizeof( tSirMacMgmtHdr ),
6044 nPayload,
6045 &nPayload );
6046
6047 if ( DOT11F_FAILED( nStatus ))
6048 {
6049 limLog( pMac, LOGE,
6050 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6051 nStatus );
6052 // FIXME - Need to convert to tSirRetStatus
6053 nSirStatus = eSIR_FAILURE;
6054 goto returnAfterError;
6055 }
6056 else if ( DOT11F_WARNED( nStatus ))
6057 {
6058 limLog( pMac, LOGW,
6059 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6060 nStatus);
6061 }
6062
6063 limLog( pMac, LOG1,
6064 FL( "Sending a SA Query Response to " ));
6065 limPrintMacAddr( pMac, peer, LOGW );
6066
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006067 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006068#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006069 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6070 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006071#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006072 )
6073 {
6074 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6075 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006076
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006077 halstatus = halTxFrame( pMac,
6078 pPacket,
6079 (tANI_U16) nBytes,
6080 HAL_TXRX_FRM_802_11_MGMT,
6081 ANI_TXDIR_TODS,
6082 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6083 limTxComplete,
6084 pFrame, txFlag );
6085 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006086 {
6087 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6088 nSirStatus = eSIR_FAILURE;
6089 //Pkt will be freed up by the callback
6090 return nSirStatus;
6091 }
6092 else {
6093 return eSIR_SUCCESS;
6094 }
6095
6096returnAfterError:
6097 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6098 return nSirStatus;
6099} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006100#endif