blob: 35d83dd0ab7db4b87b73ac1578da70d4012e8e22 [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
70#ifdef FEATURE_WLAN_CCX
71#include <limCcxparserApi.h>
72#endif
73#include "wlan_qct_wda.h"
74#ifdef WLAN_FEATURE_11W
75#include "dot11fdefs.h"
76#endif
77
78
79////////////////////////////////////////////////////////////////////////
80
Jeff Johnson295189b2012-06-20 16:38:30 -070081
82/**
83 *
84 * \brief This function is called by various LIM modules to prepare the
85 * 802.11 frame MAC header
86 *
87 *
88 * \param pMac Pointer to Global MAC structure
89 *
90 * \param pBD Pointer to the frame buffer that needs to be populate
91 *
92 * \param type Type of the frame
93 *
94 * \param subType Subtype of the frame
95 *
96 * \return eHalStatus
97 *
98 *
99 * The pFrameBuf argument points to the beginning of the frame buffer to
100 * which - a) The 802.11 MAC header is set b) Following this MAC header
101 * will be the MGMT frame payload The payload itself is populated by the
102 * caller API
103 *
104 *
105 */
106
107tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
108 tANI_U8* pBD,
109 tANI_U8 type,
110 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530111 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700112{
113 tSirRetStatus statusCode = eSIR_SUCCESS;
114 tpSirMacMgmtHdr pMacHdr;
115
116 /// Prepare MAC management header
117 pMacHdr = (tpSirMacMgmtHdr) (pBD);
118
119 // Prepare FC
120 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
121 pMacHdr->fc.type = type;
122 pMacHdr->fc.subType = subType;
123
124 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530125 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700126 (tANI_U8 *) peerAddr,
127 sizeof( tSirMacAddr ));
128
129 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700130 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
131
132 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530133 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 (tANI_U8 *) peerAddr,
135 sizeof( tSirMacAddr ));
136 return statusCode;
137} /*** end limPopulateMacHeader() ***/
138
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700139#ifdef WLAN_FEATURE_11W
140/**
141 *
142 * \brief This function is called by various LIM modules to correctly set
143 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
144 *
145 *
146 * \param pMac Pointer to Global MAC structure
147 *
148 * \param psessionEntry Pointer to session corresponding to the connection
149 *
150 * \param peer Peer address of the STA to which the frame is to be sent
151 *
152 * \param pMacHdr Pointer to the frame MAC header
153 *
154 * \return nothing
155 *
156 *
157 */
158void
159limSetProtectedBit(tpAniSirGlobal pMac,
160 tpPESession psessionEntry,
161 tSirMacAddr peer,
162 tpSirMacMgmtHdr pMacHdr)
163{
164 tANI_U16 aid;
165 tpDphHashNode pStaDs;
166
167 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
168 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
169 {
170
171 pStaDs = dphLookupHashEntry( pMac, peer, &aid, &psessionEntry->dph.dphHashTable );
172 if( pStaDs != NULL )
173 if( pStaDs->rmfEnabled )
174 pMacHdr->fc.wep = 1;
175 }
176 else if ( psessionEntry->limRmfEnabled )
177 pMacHdr->fc.wep = 1;
178} /*** end limSetProtectedBit() ***/
179#endif
180
Jeff Johnson295189b2012-06-20 16:38:30 -0700181/**
182 * \brief limSendProbeReqMgmtFrame
183 *
184 *
185 * \param pMac Pointer to Global MAC structure
186 *
187 * \param pSsid SSID to be sent in Probe Request frame
188 *
189 * \param bssid BSSID to be sent in Probe Request frame
190 *
191 * \param nProbeDelay probe delay to be used before sending Probe Request
192 * frame
193 *
194 * \param nChannelNum Channel # on which the Probe Request is going out
195 *
196 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
197 *
198 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
199 *
200 * This function is called by various LIM modules to send Probe Request frame
201 * during active scan/learn phase.
202 * Probe request is sent out in the following scenarios:
203 * --heartbeat failure: session needed
204 * --join req: session needed
205 * --foreground scan: no session
206 * --background scan: no session
207 * --schBeaconProcessing: to get EDCA parameters: session needed
208 *
209 *
210 */
211tSirRetStatus
212limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
213 tSirMacSSid *pSsid,
214 tSirMacAddr bssid,
215 tANI_U8 nChannelNum,
216 tSirMacAddr SelfMacAddr,
217 tANI_U32 dot11mode,
218 tANI_U32 nAdditionalIELen,
219 tANI_U8 *pAdditionalIE)
220{
221 tDot11fProbeRequest pr;
222 tANI_U32 nStatus, nBytes, nPayload;
223 tSirRetStatus nSirStatus;
224 tANI_U8 *pFrame;
225 void *pPacket;
226 eHalStatus halstatus;
227 tpPESession psessionEntry;
228 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700230 tANI_U8 txFlag = 0;
231
232#ifndef GEN4_SCAN
233 return eSIR_FAILURE;
234#endif
235
236#if defined ( ANI_DVT_DEBUG )
237 return eSIR_FAILURE;
238#endif
239
240 /*
241 * session context may or may not be present, when probe request needs to be sent out.
242 * following cases exist:
243 * --heartbeat failure: session needed
244 * --join req: session needed
245 * --foreground scan: no session
246 * --background scan: no session
247 * --schBeaconProcessing: to get EDCA parameters: session needed
248 * If session context does not exist, some IEs will be populated from CFGs,
249 * e.g. Supported and Extended rate set IEs
250 */
251 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
252
253 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
254 // and then hand it off to 'dot11fPackProbeRequest' (for
255 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530256 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700257
258 // & delegating to assorted helpers:
259 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
260
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 if( nAdditionalIELen && pAdditionalIE )
262 {
263 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
264 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700265 /* Don't include 11b rate only when device is doing P2P Search */
266 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
267 ( p2pIe != NULL ) &&
268 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
269 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
270 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
271 ( ( psessionEntry != NULL ) &&
272 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
273 )
274 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 {
276 /* In the below API pass channel number > 14, do that it fills only
277 * 11a rates in supported rates */
278 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
279 }
280 else
281 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 PopulateDot11fSuppRates( pMac, nChannelNum,
283 &pr.SuppRates,psessionEntry);
284
285 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
286 {
287 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
288 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700290
291#if defined WLAN_FEATURE_VOWIFI
292 //Table 7-14 in IEEE Std. 802.11k-2008 says
293 //DS params "can" be present in RRM is disabled and "is" present if
294 //RRM is enabled. It should be ok even if we add it into probe req when
295 //RRM is not enabled.
296 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
297 //Call RRM module to get the tx power for management used.
298 {
299 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
300 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
301 }
302#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700303
304 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700305 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700306 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700307 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700308 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700309 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700311 } else { //psessionEntry == NULL
312 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700314 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 }
316 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800317
318 /* Set channelbonding information as "disabled" when tunned to a 2.4 GHz channel */
319 if( nChannelNum <= SIR_11B_CHANNEL_END)
320 {
321 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
322 pr.HTCaps.shortGI40MHz = 0;
323 }
324
Jeff Johnsone7245742012-09-05 17:12:55 -0700325#ifdef WLAN_FEATURE_11AC
326 if (psessionEntry != NULL ) {
327 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
328 //Include HT Capability IE
329 if (psessionEntry->vhtCapability)
330 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700331 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
332 }
333 } else {
334 if (IS_DOT11_MODE_VHT(dot11mode))
335 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700336 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
337 }
338 }
339#endif
340
Jeff Johnson295189b2012-06-20 16:38:30 -0700341
342 // That's it-- now we pack it. First, how much space are we going to
343 // need?
344 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
345 if ( DOT11F_FAILED( nStatus ) )
346 {
347 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700348 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 // We'll fall back on the worst case scenario:
350 nPayload = sizeof( tDot11fProbeRequest );
351 }
352 else if ( DOT11F_WARNED( nStatus ) )
353 {
354 limLog( pMac, LOGW, FL("There were warnings while calculating"
355 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700356 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 }
358
359 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
360
361 // Ok-- try to allocate some memory:
362 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
363 ( tANI_U16 )nBytes, ( void** ) &pFrame,
364 ( void** ) &pPacket );
365 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
366 {
367 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700368 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 return eSIR_MEM_ALLOC_FAILED;
370 }
371
372 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530373 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700374
375 // Next, we fill out the buffer descriptor:
376 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530377 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 if ( eSIR_SUCCESS != nSirStatus )
379 {
380 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700381 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 nSirStatus );
383 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
384 ( void* ) pFrame, ( void* ) pPacket );
385 return nSirStatus; // allocated!
386 }
387
388 // That done, pack the Probe Request:
389 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
390 sizeof( tSirMacMgmtHdr ),
391 nPayload, &nPayload );
392 if ( DOT11F_FAILED( nStatus ) )
393 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700394 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 nStatus );
396 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
397 return eSIR_FAILURE; // allocated!
398 }
399 else if ( DOT11F_WARNED( nStatus ) )
400 {
401 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700402 "robe Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700403 }
404
405 // Append any AddIE if present.
406 if( nAdditionalIELen )
407 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530408 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 pAdditionalIE, nAdditionalIELen );
410 nPayload += nAdditionalIELen;
411 }
412
413 /* If this probe request is sent during P2P Search State, then we need
414 * to send it at OFDM rate.
415 */
416 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700417 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
418 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530419 /* For unicast probe req mgmt from Join function
420 we don't set above variables. So we need to add
421 one more check whether it is pePersona is P2P_CLIENT or not */
422 || ( ( psessionEntry != NULL ) &&
423 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700424 )
425 {
426 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
427 }
428
429
430 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
431 HAL_TXRX_FRM_802_11_MGMT,
432 ANI_TXDIR_TODS,
433 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
434 limTxComplete, pFrame, txFlag );
435 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
436 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700437 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700438 //Pkt will be freed up by the callback
439 return eSIR_FAILURE;
440 }
441
442 return eSIR_SUCCESS;
443} // End limSendProbeReqMgmtFrame.
444
Jeff Johnson295189b2012-06-20 16:38:30 -0700445tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
446 tANI_U8* addIE, tANI_U16 *addnIELen,
447 tANI_U8 probeReqP2pIe)
448{
449 /* If Probe request doesn't have P2P IE, then take out P2P IE
450 from additional IE */
451 if(!probeReqP2pIe)
452 {
453 tANI_U8* tempbuf = NULL;
454 tANI_U16 tempLen = 0;
455 int left = *addnIELen;
456 v_U8_t *ptr = addIE;
457 v_U8_t elem_id, elem_len;
458
459 if(NULL == addIE)
460 {
461 PELOGE(limLog(pMac, LOGE,
462 FL(" NULL addIE pointer"));)
463 return eSIR_FAILURE;
464 }
465
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530466 tempbuf = vos_mem_malloc(left);
467 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 {
469 PELOGE(limLog(pMac, LOGE,
470 FL("Unable to allocate memory to store addn IE"));)
471 return eSIR_MEM_ALLOC_FAILED;
472 }
473
474 while(left >= 2)
475 {
476 elem_id = ptr[0];
477 elem_len = ptr[1];
478 left -= 2;
479 if(elem_len > left)
480 {
481 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700482 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700483 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530484 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 return eSIR_FAILURE;
486 }
487 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
488 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
489 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530490 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 tempLen += (elem_len + 2);
492 }
493 left -= elem_len;
494 ptr += (elem_len + 2);
495 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530496 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530498 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 }
500 return eSIR_SUCCESS;
501}
Jeff Johnson295189b2012-06-20 16:38:30 -0700502
503void
504limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
505 tSirMacAddr peerMacAddr,
506 tpAniSSID pSsid,
507 short nStaId,
508 tANI_U8 nKeepAlive,
509 tpPESession psessionEntry,
510 tANI_U8 probeReqP2pIe)
511{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700512 tDot11fProbeResponse *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 tSirRetStatus nSirStatus;
514 tANI_U32 cfg, nPayload, nBytes, nStatus;
515 tpSirMacMgmtHdr pMacHdr;
516 tANI_U8 *pFrame;
517 void *pPacket;
518 eHalStatus halstatus;
519 tANI_U32 addnIEPresent;
520 tANI_U32 addnIE1Len=0;
521 tANI_U32 addnIE2Len=0;
522 tANI_U32 addnIE3Len=0;
523 tANI_U16 totalAddnIeLen = 0;
524 tANI_U32 wpsApEnable=0, tmp;
525 tANI_U8 txFlag = 0;
526 tANI_U8 *addIE = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 tANI_U8 *pP2pIe = NULL;
528 tANI_U8 noaLen = 0;
529 tANI_U8 total_noaLen = 0;
530 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
531 + SIR_P2P_IE_HEADER_LEN];
532 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
534 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
535 {
536 return; // in this case.
537 }
538
539 if(NULL == psessionEntry)
540 {
541 return;
542 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530543
544 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
545 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700546 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530547 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700548 return;
549 }
550
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 // Fill out 'frm', after which we'll just hand the struct off to
552 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530553 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700554
555 // Timestamp to be updated by TFP, below.
556
557 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
559 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700560 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 }
562 else
563 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800564 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
565 if (eSIR_SUCCESS != nSirStatus)
566 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700567 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800568 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530569 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800570 return;
571 }
572 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800573 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700574
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700575 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
576 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700578 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700580 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
581 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700582
Jeff Johnson295189b2012-06-20 16:38:30 -0700583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
585 {
586 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
587 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700588 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 }
590 }
591 else
592 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800593 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700594 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700595
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800596 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700597
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800598 if (wpsApEnable)
599 {
600 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
601 }
602
603 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
604 {
605 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
606 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
607 }
608
609 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
610 {
611 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
612 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
613 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700615
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700616 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
617 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700618
Jeff Johnson295189b2012-06-20 16:38:30 -0700619
620 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700621 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700622
623
624 // N.B. In earlier implementations, the RSN IE would be placed in
625 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
626 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700627 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700628
629 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700630 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700632 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700633 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700635#ifdef WLAN_FEATURE_11AC
636 if(psessionEntry->vhtCapability)
637 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700638 limLog( pMac, LOGW, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700639 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
640 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700641 // we do not support multi users yet
642 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700643 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700644 }
645#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700646
krunal soni4f087d22013-07-29 16:32:26 -0700647 if (psessionEntry->oxygenNwkIniFeatureEnabled &&
648 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole)) {
649 if (wlan_cfgGetInt(pMac, WNI_CFG_OXYGEN_NETWORK_DATA,
650 &tmp) != eSIR_SUCCESS){
651 limLog(pMac, LOGW, FL("Unable to get WNI_CFG_OXYGEN_NETWORK_DATA"));
652 }
653 else {
654 pFrm->OxygenNetwork.present = 1;
655 pFrm->OxygenNetwork.data = (tmp & 0xffff);
656 }
657 }
658
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 if ( psessionEntry->pLimStartBssReq )
660 {
661 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700662 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700663 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
664 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 }
666
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700667 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700668
669#if defined(FEATURE_WLAN_WAPI)
670 if( psessionEntry->pLimStartBssReq )
671 {
672 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700673 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 }
675
676#endif // defined(FEATURE_WLAN_WAPI)
677
678
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700679 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 if ( DOT11F_FAILED( nStatus ) )
681 {
682 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700683 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 nStatus );
685 // We'll fall back on the worst case scenario:
686 nPayload = sizeof( tDot11fProbeResponse );
687 }
688 else if ( DOT11F_WARNED( nStatus ) )
689 {
690 limLog( pMac, LOGW, FL("There were warnings while calculating"
691 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700692 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 }
694
695 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
696
697 addnIEPresent = false;
698
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 if( pMac->lim.gpLimRemainOnChanReq )
700 {
701 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
702 }
703 //Only use CFG for non-listen mode. This CFG is not working for concurrency
704 //In listening mode, probe rsp IEs is passed in the message from SME to PE
705 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 {
707
708 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
709 &addnIEPresent) != eSIR_SUCCESS)
710 {
711 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530712 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 return;
714 }
715 }
716
717 if (addnIEPresent)
718 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530719
720 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
721 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 {
723 PELOGE(limLog(pMac, LOGE,
724 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530725 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 return;
727 }
728
729 //Probe rsp IE available
730 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
731 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
732 {
733 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530734 vos_mem_free(addIE);
735 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 return;
737 }
738 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
739 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
740 {
741 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
742 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
743 &addnIE1Len) )
744 {
745 limLog(pMac, LOGP,
746 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530747 vos_mem_free(addIE);
748 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 return;
750 }
751 }
752
753 //Probe rsp IE available
754 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
755 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
756 {
757 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530758 vos_mem_free(addIE);
759 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 return;
761 }
762 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
763 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
764 {
765 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
766 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
767 &addnIE2Len) )
768 {
769 limLog(pMac, LOGP,
770 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530771 vos_mem_free(addIE);
772 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 return;
774 }
775 }
776
777 //Probe rsp IE available
778 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
779 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
780 {
781 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530782 vos_mem_free(addIE);
783 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 return;
785 }
786 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
787 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
788 {
789 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
790 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
791 &addIE[addnIE1Len + addnIE2Len],
792 &addnIE3Len) )
793 {
794 limLog(pMac, LOGP,
795 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530796 vos_mem_free(addIE);
797 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 return;
799 }
800 }
801 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
802
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
804 {
805 limLog(pMac, LOGP,
806 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530807 vos_mem_free(addIE);
808 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 return;
810 }
811 nBytes = nBytes + totalAddnIeLen;
812
813 if (probeReqP2pIe)
814 {
815 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
816 if (pP2pIe != NULL)
817 {
818 //get NoA attribute stream P2P IE
819 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
820 if (noaLen != 0)
821 {
822 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
823 &noaStream[0], noaLen);
824 nBytes = nBytes + total_noaLen;
825 }
826 }
827 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 }
829
830 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
831 ( tANI_U16 )nBytes, ( void** ) &pFrame,
832 ( void** ) &pPacket );
833 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
834 {
835 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700836 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 if ( addIE != NULL )
838 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530839 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530841 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 return;
843 }
844
845 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530846 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700847
848 // Next, we fill out the buffer descriptor:
849 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
850 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
851 if ( eSIR_SUCCESS != nSirStatus )
852 {
853 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700854 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 nSirStatus );
856 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
857 ( void* ) pFrame, ( void* ) pPacket );
858 if ( addIE != NULL )
859 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530860 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530862 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 return;
864 }
865
866 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
867
868 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
869
870 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700871 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 nPayload, &nPayload );
873 if ( DOT11F_FAILED( nStatus ) )
874 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700875 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 nStatus );
877 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
878 if ( addIE != NULL )
879 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530880 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530882 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 return; // allocated!
884 }
885 else if ( DOT11F_WARNED( nStatus ) )
886 {
887 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700888 "robe Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 }
890
891 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
892 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
893
894 pMac->sys.probeRespond++;
895
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 if( pMac->lim.gpLimRemainOnChanReq )
897 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530898 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
900 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700901
902 if ( addnIEPresent )
903 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530904 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 if (noaLen != 0)
907 {
Krunal Soni81b24262013-05-15 17:46:41 -0700908 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 {
910 limLog(pMac, LOGE,
911 FL("Not able to insert NoA because of length constraint"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530912 vos_mem_free(addIE);
913 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -0700914 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
915 ( void* ) pFrame, ( void* ) pPacket );
916 return;
917 }
918 else
919 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530920 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -0700921 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 }
923 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700924
925 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
927 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 )
929 {
930 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
931 }
932
933 // Queue Probe Response frame in high priority WQ
934 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
935 ( tANI_U16 ) nBytes,
936 HAL_TXRX_FRM_802_11_MGMT,
937 ANI_TXDIR_TODS,
938 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
939 limTxComplete, pFrame, txFlag );
940 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
941 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700942 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 //Pkt will be freed up by the callback
944 }
945
946 if ( addIE != NULL )
947 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530948 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 }
950
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530951 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700952 return;
953
954
Jeff Johnson295189b2012-06-20 16:38:30 -0700955} // End limSendProbeRspMgmtFrame.
956
957void
958limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
959 tSirMacAddr peerMacAddr,
960 tSirAddtsReqInfo *pAddTS,
961 tpPESession psessionEntry)
962{
963 tANI_U16 i;
964 tANI_U8 *pFrame;
965 tSirRetStatus nSirStatus;
966 tDot11fAddTSRequest AddTSReq;
967 tDot11fWMMAddTSRequest WMMAddTSReq;
968 tANI_U32 nPayload, nBytes, nStatus;
969 tpSirMacMgmtHdr pMacHdr;
970 void *pPacket;
971#ifdef FEATURE_WLAN_CCX
972 tANI_U32 phyMode;
973#endif
974 eHalStatus halstatus;
975 tANI_U8 txFlag = 0;
976
977 if(NULL == psessionEntry)
978 {
979 return;
980 }
981
982 if ( ! pAddTS->wmeTspecPresent )
983 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530984 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700985
986 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
987 AddTSReq.DialogToken.token = pAddTS->dialogToken;
988 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
989 if ( pAddTS->lleTspecPresent )
990 {
991 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
992 }
993 else
994 {
995 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
996 }
997
998 if ( pAddTS->lleTspecPresent )
999 {
1000 AddTSReq.num_WMMTCLAS = 0;
1001 AddTSReq.num_TCLAS = pAddTS->numTclas;
1002 for ( i = 0; i < pAddTS->numTclas; ++i)
1003 {
1004 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1005 &AddTSReq.TCLAS[i] );
1006 }
1007 }
1008 else
1009 {
1010 AddTSReq.num_TCLAS = 0;
1011 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1012 for ( i = 0; i < pAddTS->numTclas; ++i)
1013 {
1014 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1015 &AddTSReq.WMMTCLAS[i] );
1016 }
1017 }
1018
1019 if ( pAddTS->tclasProcPresent )
1020 {
1021 if ( pAddTS->lleTspecPresent )
1022 {
1023 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1024 AddTSReq.TCLASSPROC.present = 1;
1025 }
1026 else
1027 {
1028 AddTSReq.WMMTCLASPROC.version = 1;
1029 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1030 AddTSReq.WMMTCLASPROC.present = 1;
1031 }
1032 }
1033
1034 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1035 if ( DOT11F_FAILED( nStatus ) )
1036 {
1037 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001038 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 nStatus );
1040 // We'll fall back on the worst case scenario:
1041 nPayload = sizeof( tDot11fAddTSRequest );
1042 }
1043 else if ( DOT11F_WARNED( nStatus ) )
1044 {
1045 limLog( pMac, LOGW, FL("There were warnings while calculating"
1046 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001047 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 }
1049 }
1050 else
1051 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301052 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001053
1054 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1055 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1056 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1057
1058 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1059 WMMAddTSReq.StatusCode.statusCode = 0;
1060
1061 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1062#ifdef FEATURE_WLAN_CCX
1063 limGetPhyMode(pMac, &phyMode, psessionEntry);
1064
1065 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1066 {
1067 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1068 }
1069 else
1070 {
1071 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1072 }
1073 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1074#endif
1075 // fillWmeTspecIE
1076
1077 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1078 if ( DOT11F_FAILED( nStatus ) )
1079 {
1080 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001081 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 nStatus );
1083 // We'll fall back on the worst case scenario:
1084 nPayload = sizeof( tDot11fAddTSRequest );
1085 }
1086 else if ( DOT11F_WARNED( nStatus ) )
1087 {
1088 limLog( pMac, LOGW, FL("There were warnings while calculating"
1089 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001090 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 }
1092 }
1093
1094 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1095
1096 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1097 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1098 ( void** ) &pPacket );
1099 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1100 {
1101 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001102 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 return;
1104 }
1105
1106 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301107 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001108
1109 // Next, we fill out the buffer descriptor:
1110 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1111 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1112 if ( eSIR_SUCCESS != nSirStatus )
1113 {
1114 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001115 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 nSirStatus );
1117 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1118 ( void* ) pFrame, ( void* ) pPacket );
1119 return;
1120 }
1121
1122 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1123
1124 #if 0
1125 cfgLen = SIR_MAC_ADDR_LENGTH;
1126 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1127 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1128 {
1129 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001130 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1132 ( void* ) pFrame, ( void* ) pPacket );
1133 return;
1134 }
1135 #endif //TO SUPPORT BT-AMP
1136
1137 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1138
Chet Lanctot186b5732013-03-18 10:26:30 -07001139#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001140 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001141#endif
1142
Jeff Johnson295189b2012-06-20 16:38:30 -07001143 // That done, pack the struct:
1144 if ( ! pAddTS->wmeTspecPresent )
1145 {
1146 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1147 pFrame + sizeof(tSirMacMgmtHdr),
1148 nPayload, &nPayload );
1149 if ( DOT11F_FAILED( nStatus ) )
1150 {
1151 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001152 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001153 nStatus );
1154 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1155 return; // allocated!
1156 }
1157 else if ( DOT11F_WARNED( nStatus ) )
1158 {
1159 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001160 "an Add TS Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001161 }
1162 }
1163 else
1164 {
1165 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1166 pFrame + sizeof(tSirMacMgmtHdr),
1167 nPayload, &nPayload );
1168 if ( DOT11F_FAILED( nStatus ) )
1169 {
1170 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001171 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 nStatus );
1173 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1174 return; // allocated!
1175 }
1176 else if ( DOT11F_WARNED( nStatus ) )
1177 {
1178 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001179 "a WMM Add TS Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 }
1181 }
1182
1183 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1184 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1185
1186 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1188 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 )
1190 {
1191 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1192 }
1193
1194 // Queue Addts Response frame in high priority WQ
1195 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1196 HAL_TXRX_FRM_802_11_MGMT,
1197 ANI_TXDIR_TODS,
1198 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1199 limTxComplete, pFrame, txFlag );
1200 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1201 {
1202 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001203 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 //Pkt will be freed up by the callback
1205 }
1206
1207} // End limSendAddtsReqActionFrame.
1208
Jeff Johnson295189b2012-06-20 16:38:30 -07001209
1210
1211void
1212limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1213 tANI_U16 statusCode,
1214 tANI_U16 aid,
1215 tSirMacAddr peerMacAddr,
1216 tANI_U8 subType,
1217 tpDphHashNode pSta,tpPESession psessionEntry)
1218{
1219 static tDot11fAssocResponse frm;
1220 tANI_U8 *pFrame, *macAddr;
1221 tpSirMacMgmtHdr pMacHdr;
1222 tSirRetStatus nSirStatus;
1223 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1224 tHalBitVal qosMode, wmeMode;
1225 tANI_U32 nPayload, nBytes, nStatus;
1226 void *pPacket;
1227 eHalStatus halstatus;
1228 tUpdateBeaconParams beaconParams;
1229 tANI_U8 txFlag = 0;
1230 tANI_U32 addnIEPresent = false;
1231 tANI_U32 addnIELen=0;
1232 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1233 tpSirAssocReq pAssocReq = NULL;
1234
1235 if(NULL == psessionEntry)
1236 {
1237 return;
1238 }
1239
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301240 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001241
1242 limGetQosMode(psessionEntry, &qosMode);
1243 limGetWmeMode(psessionEntry, &wmeMode);
1244
1245 // An Add TS IE is added only if the AP supports it and the requesting
1246 // STA sent a traffic spec.
1247 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1248
1249 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1250
1251 frm.Status.status = statusCode;
1252
1253 frm.AID.associd = aid | LIM_AID_MASK;
1254
1255 if ( NULL == pSta )
1256 {
1257 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1258 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1259 }
1260 else
1261 {
1262 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1263 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1264 }
1265
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1267 {
1268 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1269 {
1270 pAssocReq =
1271 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1273 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1274 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1275 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 }
1277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001278
1279 if ( NULL != pSta )
1280 {
1281 if ( eHAL_SET == qosMode )
1282 {
1283 if ( pSta->lleEnabled )
1284 {
1285 lleMode = 1;
1286 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1287 {
1288 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1289
1290// FramesToDo:...
1291// if ( fAddTS )
1292// {
1293// tANI_U8 *pAf = pBody;
1294// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1295// tANI_U32 tlen;
1296// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1297// &tlen, bufLen - frameLen);
1298// } // End if on Add TS.
1299 }
1300 } // End if on .11e enabled in 'pSta'.
1301 } // End if on QOS Mode on.
1302
1303 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1304 {
1305 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1306 {
1307
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001309
1310 if ( pSta->wsmEnabled )
1311 {
1312 PopulateDot11fWMMCaps(&frm.WMMCaps );
1313 }
1314 }
1315 }
1316
1317 if ( pSta->aniPeer )
1318 {
1319 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1320 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1321 {
1322 edcaInclude = 1;
1323 }
1324
1325 } // End if on Airgo peer.
1326
1327 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001328 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001330 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001332 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001333
1334#ifdef WLAN_FEATURE_11AC
1335 if( pSta->mlmStaContext.vhtCapability &&
1336 psessionEntry->vhtCapability )
1337 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001338 limLog( pMac, LOGW, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001339 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1340 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001341 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001342 }
1343#endif
1344
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 } // End if on non-NULL 'pSta'.
1346
1347
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301348 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001349
Jeff Johnson295189b2012-06-20 16:38:30 -07001350 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1351 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1352 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001354
1355 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1356 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1357
1358 beaconParams.bssIdx = psessionEntry->bssIdx;
1359
1360 //Send message to HAL about beacon parameter change.
1361 if(beaconParams.paramChangeBitmap)
1362 {
1363 schSetFixedBeaconFields(pMac,psessionEntry);
1364 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1365 }
1366
1367 // Allocate a buffer for this frame:
1368 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1369 if ( DOT11F_FAILED( nStatus ) )
1370 {
1371 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001372 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 nStatus );
1374 return;
1375 }
1376 else if ( DOT11F_WARNED( nStatus ) )
1377 {
1378 limLog( pMac, LOGW, FL("There were warnings while calculating"
1379 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001380 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 }
1382
1383 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1384
1385 if ( pAssocReq != NULL )
1386 {
1387 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1388 &addnIEPresent) != eSIR_SUCCESS)
1389 {
1390 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
1391 return;
1392 }
1393
1394 if (addnIEPresent)
1395 {
1396 //Assoc rsp IE available
1397 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1398 &addnIELen) != eSIR_SUCCESS)
1399 {
1400 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
1401 return;
1402 }
1403
1404 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1405 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1406 {
1407 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1408 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1409 {
1410 nBytes = nBytes + addnIELen;
1411 }
1412 }
1413 }
1414 }
1415
1416 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1417 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1418 ( void** ) &pPacket );
1419 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1420 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001421 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 return;
1423 }
1424
1425 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301426 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001427
1428 // Next, we fill out the buffer descriptor:
1429 nSirStatus = limPopulateMacHeader( pMac,
1430 pFrame,
1431 SIR_MAC_MGMT_FRAME,
1432 ( LIM_ASSOC == subType ) ?
1433 SIR_MAC_MGMT_ASSOC_RSP :
1434 SIR_MAC_MGMT_REASSOC_RSP,
1435 peerMacAddr,psessionEntry->selfMacAddr);
1436 if ( eSIR_SUCCESS != nSirStatus )
1437 {
1438 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001439 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 nSirStatus );
1441 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1442 ( void* ) pFrame, ( void* ) pPacket );
1443 return;
1444 }
1445
1446 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1447
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1449
1450 nStatus = dot11fPackAssocResponse( pMac, &frm,
1451 pFrame + sizeof( tSirMacMgmtHdr ),
1452 nPayload, &nPayload );
1453 if ( DOT11F_FAILED( nStatus ) )
1454 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001455 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 nStatus );
1457 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1458 ( void* ) pFrame, ( void* ) pPacket );
1459 return; // allocated!
1460 }
1461 else if ( DOT11F_WARNED( nStatus ) )
1462 {
1463 limLog( pMac, LOGW, FL("There were warnings while packing an "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001464 "Association Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 }
1466
1467 macAddr = pMacHdr->da;
1468
1469 if (subType == LIM_ASSOC)
1470 {
1471 PELOG1(limLog(pMac, LOG1,
1472 FL("*** Sending Assoc Resp status %d aid %d to "),
1473 statusCode, aid);)
1474 }
1475 else{
1476 PELOG1(limLog(pMac, LOG1,
1477 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1478 statusCode, aid);)
1479 }
1480 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1481
1482 if ( addnIEPresent )
1483 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301484 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001485 }
1486
1487 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1489 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 )
1491 {
1492 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1493 }
1494
1495 /// Queue Association Response frame in high priority WQ
1496 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1497 HAL_TXRX_FRM_802_11_MGMT,
1498 ANI_TXDIR_TODS,
1499 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1500 limTxComplete, pFrame, txFlag );
1501 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1502 {
1503 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001504 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 nSirStatus);
1506
1507 //Pkt will be freed up by the callback
1508 }
1509
1510 // update the ANI peer station count
1511 //FIXME_PROTECTION : take care of different type of station
1512 // counter inside this function.
1513 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1514
1515} // End limSendAssocRspMgmtFrame.
1516
1517
1518
1519void
1520limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1521 tSirMacAddr peer,
1522 tANI_U16 nStatusCode,
1523 tSirAddtsReqInfo *pAddTS,
1524 tSirMacScheduleIE *pSchedule,
1525 tpPESession psessionEntry)
1526{
1527 tANI_U8 *pFrame;
1528 tpSirMacMgmtHdr pMacHdr;
1529 tDot11fAddTSResponse AddTSRsp;
1530 tDot11fWMMAddTSResponse WMMAddTSRsp;
1531 tSirRetStatus nSirStatus;
1532 tANI_U32 i, nBytes, nPayload, nStatus;
1533 void *pPacket;
1534 eHalStatus halstatus;
1535 tANI_U8 txFlag = 0;
1536
1537 if(NULL == psessionEntry)
1538 {
1539 return;
1540 }
1541
1542 if ( ! pAddTS->wmeTspecPresent )
1543 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301544 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
1546 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1547 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1548 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1549 AddTSRsp.Status.status = nStatusCode;
1550
1551 // The TsDelay information element is only filled in for a specific
1552 // status code:
1553 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1554 {
1555 if ( pAddTS->wsmTspecPresent )
1556 {
1557 AddTSRsp.WMMTSDelay.version = 1;
1558 AddTSRsp.WMMTSDelay.delay = 10;
1559 AddTSRsp.WMMTSDelay.present = 1;
1560 }
1561 else
1562 {
1563 AddTSRsp.TSDelay.delay = 10;
1564 AddTSRsp.TSDelay.present = 1;
1565 }
1566 }
1567
1568 if ( pAddTS->wsmTspecPresent )
1569 {
1570 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1571 }
1572 else
1573 {
1574 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1575 }
1576
1577 if ( pAddTS->wsmTspecPresent )
1578 {
1579 AddTSRsp.num_WMMTCLAS = 0;
1580 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1581 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1582 {
1583 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1584 &AddTSRsp.TCLAS[i] );
1585 }
1586 }
1587 else
1588 {
1589 AddTSRsp.num_TCLAS = 0;
1590 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1591 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1592 {
1593 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1594 &AddTSRsp.WMMTCLAS[i] );
1595 }
1596 }
1597
1598 if ( pAddTS->tclasProcPresent )
1599 {
1600 if ( pAddTS->wsmTspecPresent )
1601 {
1602 AddTSRsp.WMMTCLASPROC.version = 1;
1603 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1604 AddTSRsp.WMMTCLASPROC.present = 1;
1605 }
1606 else
1607 {
1608 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1609 AddTSRsp.TCLASSPROC.present = 1;
1610 }
1611 }
1612
1613 // schedule element is included only if requested in the tspec and we are
1614 // using hcca (or both edca and hcca)
1615 // 11e-D8.0 is inconsistent on whether the schedule element is included
1616 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1617 // pg 46, line 17-18 says something else. So just include it and let the
1618 // sta figure it out
1619 if ((pSchedule != NULL) &&
1620 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1621 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1622 {
1623 if ( pAddTS->wsmTspecPresent )
1624 {
1625 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1626 }
1627 else
1628 {
1629 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1630 }
1631 }
1632
1633 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1634 if ( DOT11F_FAILED( nStatus ) )
1635 {
1636 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001637 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 nStatus );
1639 // We'll fall back on the worst case scenario:
1640 nPayload = sizeof( tDot11fAddTSResponse );
1641 }
1642 else if ( DOT11F_WARNED( nStatus ) )
1643 {
1644 limLog( pMac, LOGW, FL("There were warnings while calcula"
1645 "tingthe packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001646 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 }
1648 }
1649 else
1650 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301651 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001652
1653 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1654 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1655 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1656 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1657
1658 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1659
1660 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1661 if ( DOT11F_FAILED( nStatus ) )
1662 {
1663 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001664 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 nStatus );
1666 // We'll fall back on the worst case scenario:
1667 nPayload = sizeof( tDot11fWMMAddTSResponse );
1668 }
1669 else if ( DOT11F_WARNED( nStatus ) )
1670 {
1671 limLog( pMac, LOGW, FL("There were warnings while calcula"
1672 "tingthe packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001673 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 }
1675 }
1676
1677 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1678
1679 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1680 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1681 {
1682 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001683 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 return;
1685 }
1686
1687 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301688 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001689
1690 // Next, we fill out the buffer descriptor:
1691 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1692 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1693 if ( eSIR_SUCCESS != nSirStatus )
1694 {
1695 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001696 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 nSirStatus );
1698 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1699 return; // allocated!
1700 }
1701
1702 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1703
1704
1705 #if 0
1706 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1707 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1708 {
1709 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001710 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1712 return; // allocated!
1713 }
1714 #endif //TO SUPPORT BT-AMP
1715 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1716
Chet Lanctot186b5732013-03-18 10:26:30 -07001717#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001718 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001719#endif
1720
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 // That done, pack the struct:
1722 if ( ! pAddTS->wmeTspecPresent )
1723 {
1724 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1725 pFrame + sizeof( tSirMacMgmtHdr ),
1726 nPayload, &nPayload );
1727 if ( DOT11F_FAILED( nStatus ) )
1728 {
1729 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001730 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 nStatus );
1732 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1733 return;
1734 }
1735 else if ( DOT11F_WARNED( nStatus ) )
1736 {
1737 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001738 "an Add TS Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 }
1740 }
1741 else
1742 {
1743 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1744 pFrame + sizeof( tSirMacMgmtHdr ),
1745 nPayload, &nPayload );
1746 if ( DOT11F_FAILED( nStatus ) )
1747 {
1748 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001749 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 nStatus );
1751 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1752 return;
1753 }
1754 else if ( DOT11F_WARNED( nStatus ) )
1755 {
1756 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001757 "a WMM Add TS Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 }
1759 }
1760
1761 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1762 nStatusCode );
1763 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1764
1765 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1767 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 )
1769 {
1770 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1771 }
1772
1773 // Queue the frame in high priority WQ:
1774 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1775 HAL_TXRX_FRM_802_11_MGMT,
1776 ANI_TXDIR_TODS,
1777 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1778 limTxComplete, pFrame, txFlag );
1779 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1780 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001781 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 nSirStatus );
1783 //Pkt will be freed up by the callback
1784 }
1785
1786} // End limSendAddtsRspActionFrame.
1787
1788void
1789limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1790 tSirMacAddr peer,
1791 tANI_U8 wmmTspecPresent,
1792 tSirMacTSInfo *pTsinfo,
1793 tSirMacTspecIE *pTspecIe,
1794 tpPESession psessionEntry)
1795{
1796 tANI_U8 *pFrame;
1797 tpSirMacMgmtHdr pMacHdr;
1798 tDot11fDelTS DelTS;
1799 tDot11fWMMDelTS WMMDelTS;
1800 tSirRetStatus nSirStatus;
1801 tANI_U32 nBytes, nPayload, nStatus;
1802 void *pPacket;
1803 eHalStatus halstatus;
1804 tANI_U8 txFlag = 0;
1805
1806 if(NULL == psessionEntry)
1807 {
1808 return;
1809 }
1810
1811 if ( ! wmmTspecPresent )
1812 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301813 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001814
1815 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1816 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1817 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1818
1819 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1820 if ( DOT11F_FAILED( nStatus ) )
1821 {
1822 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001823 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 nStatus );
1825 // We'll fall back on the worst case scenario:
1826 nPayload = sizeof( tDot11fDelTS );
1827 }
1828 else if ( DOT11F_WARNED( nStatus ) )
1829 {
1830 limLog( pMac, LOGW, FL("There were warnings while calcula"
1831 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001832 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 }
1834 }
1835 else
1836 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301837 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001838
1839 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1840 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1841 WMMDelTS.DialogToken.token = 0;
1842 WMMDelTS.StatusCode.statusCode = 0;
1843 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1844 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1845 if ( DOT11F_FAILED( nStatus ) )
1846 {
1847 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001848 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 nStatus );
1850 // We'll fall back on the worst case scenario:
1851 nPayload = sizeof( tDot11fDelTS );
1852 }
1853 else if ( DOT11F_WARNED( nStatus ) )
1854 {
1855 limLog( pMac, LOGW, FL("There were warnings while calcula"
1856 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001857 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 }
1859 }
1860
1861 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1862
1863 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1864 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1865 {
1866 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001867 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 return;
1869 }
1870
1871 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301872 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001873
1874 // Next, we fill out the buffer descriptor:
1875 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1876 SIR_MAC_MGMT_ACTION, peer,
1877 psessionEntry->selfMacAddr);
1878 if ( eSIR_SUCCESS != nSirStatus )
1879 {
1880 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001881 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 nSirStatus );
1883 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1884 return; // allocated!
1885 }
1886
1887 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1888
1889 #if 0
1890
1891 cfgLen = SIR_MAC_ADDR_LENGTH;
1892 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1893 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1894 {
1895 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001896 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001897 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1898 return; // allocated!
1899 }
1900 #endif //TO SUPPORT BT-AMP
1901 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1902
Chet Lanctot186b5732013-03-18 10:26:30 -07001903#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001904 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001905#endif
1906
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 // That done, pack the struct:
1908 if ( !wmmTspecPresent )
1909 {
1910 nStatus = dot11fPackDelTS( pMac, &DelTS,
1911 pFrame + sizeof( tSirMacMgmtHdr ),
1912 nPayload, &nPayload );
1913 if ( DOT11F_FAILED( nStatus ) )
1914 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001915 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 nStatus );
1917 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1918 return; // allocated!
1919 }
1920 else if ( DOT11F_WARNED( nStatus ) )
1921 {
1922 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001923 "a Del TS frame (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 }
1925 }
1926 else
1927 {
1928 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1929 pFrame + sizeof( tSirMacMgmtHdr ),
1930 nPayload, &nPayload );
1931 if ( DOT11F_FAILED( nStatus ) )
1932 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001933 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 nStatus );
1935 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1936 return; // allocated!
1937 }
1938 else if ( DOT11F_WARNED( nStatus ) )
1939 {
1940 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001941 "a WMM Del TS frame (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 }
1943 }
1944
1945 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1946 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1947
1948 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1950 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 )
1952 {
1953 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1954 }
1955
1956 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1957 HAL_TXRX_FRM_802_11_MGMT,
1958 ANI_TXDIR_TODS,
1959 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1960 limTxComplete, pFrame, txFlag );
1961 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1962 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001963 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 nSirStatus );
1965 //Pkt will be freed up by the callback
1966 }
1967
1968} // End limSendDeltsReqActionFrame.
1969
1970void
1971limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1972 tLimMlmAssocReq *pMlmAssocReq,
1973 tpPESession psessionEntry)
1974{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001975 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 tANI_U16 caps;
1977 tANI_U8 *pFrame;
1978 tSirRetStatus nSirStatus;
1979 tLimMlmAssocCnf mlmAssocCnf;
1980 tANI_U32 nBytes, nPayload, nStatus;
1981 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1982 void *pPacket;
1983 eHalStatus halstatus;
1984 tANI_U16 nAddIELen;
1985 tANI_U8 *pAddIE;
1986 tANI_U8 *wpsIe = NULL;
1987#if defined WLAN_FEATURE_VOWIFI
1988 tANI_U8 PowerCapsPopulated = FALSE;
1989#endif
1990 tANI_U8 txFlag = 0;
1991
1992 if(NULL == psessionEntry)
1993 {
1994 return;
1995 }
1996
1997 if(NULL == psessionEntry->pLimJoinReq)
1998 {
1999 return;
2000 }
2001
2002 /* check this early to avoid unncessary operation */
2003 if(NULL == psessionEntry->pLimJoinReq)
2004 {
2005 return;
2006 }
2007 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2008 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2009
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302010 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2011 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002012 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302013 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendAssocReqMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002014 return;
2015 }
2016
2017
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302018 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002019
2020 caps = pMlmAssocReq->capabilityInfo;
2021 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2022 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2023#if defined(FEATURE_WLAN_WAPI)
2024 /* CR: 262463 :
2025 According to WAPI standard:
2026 7.3.1.4 Capability Information field
2027 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2028 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2029 Reassociation management frames. */
2030 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2031 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2032#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002033 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002034
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002035 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2036 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002038 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002039
2040 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2041 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2042
2043 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2044 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2045
2046 // We prefer .11e asociations:
2047 if ( fQosEnabled ) fWmeEnabled = false;
2048
2049 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2050 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2051
2052 if ( psessionEntry->lim11hEnable &&
2053 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2054 {
2055#if defined WLAN_FEATURE_VOWIFI
2056 PowerCapsPopulated = TRUE;
2057
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002058 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002059#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002060 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002061
2062 }
2063
2064#if defined WLAN_FEATURE_VOWIFI
2065 if( pMac->rrm.rrmPEContext.rrmEnable &&
2066 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2067 {
2068 if (PowerCapsPopulated == FALSE)
2069 {
2070 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002071 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 }
2073 }
2074#endif
2075
2076 if ( fQosEnabled &&
2077 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002078 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002079
2080 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002081 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002082
2083#if defined WLAN_FEATURE_VOWIFI
2084 if( pMac->rrm.rrmPEContext.rrmEnable &&
2085 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2086 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002087 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 }
2089#endif
2090 // The join request *should* contain zero or one of the WPA and RSN
2091 // IEs. The payload send along with the request is a
2092 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2093
2094 // typedef struct sSirRSNie
2095 // {
2096 // tANI_U16 length;
2097 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2098 // } tSirRSNie, *tpSirRSNie;
2099
2100 // So, we should be able to make the following two calls harmlessly,
2101 // since they do nothing if they don't find the given IE in the
2102 // bytestream with which they're provided.
2103
2104 // The net effect of this will be to faithfully transmit whatever
2105 // security IE is in the join request.
2106
2107 // *However*, if we're associating for the purpose of WPS
2108 // enrollment, and we've been configured to indicate that by
2109 // eliding the WPA or RSN IE, we just skip this:
2110 if( nAddIELen && pAddIE )
2111 {
2112 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2113 }
2114 if ( NULL == wpsIe )
2115 {
2116 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002117 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002119 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002120#if defined(FEATURE_WLAN_WAPI)
2121 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002122 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002123#endif // defined(FEATURE_WLAN_WAPI)
2124 }
2125
2126 // include WME EDCA IE as well
2127 if ( fWmeEnabled )
2128 {
2129 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2130 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002131 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 }
2133
2134 if ( fWsmEnabled &&
2135 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2136 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002137 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 }
2139 }
2140
2141 //Populate HT IEs, when operating in 11n or Taurus modes AND
2142 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002143 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 pMac->lim.htCapabilityPresentInBeacon)
2145 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002146 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002147#ifdef DISABLE_GF_FOR_INTEROP
2148
2149 /*
2150 * To resolve the interop problem with Broadcom AP,
2151 * where TQ STA could not pass traffic with GF enabled,
2152 * TQ STA will do Greenfield only with TQ AP, for
2153 * everybody else it will be turned off.
2154 */
2155
2156 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2157 {
2158 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002159 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 }
2161#endif
2162
2163 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002164#ifdef WLAN_FEATURE_11AC
2165 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002166 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002167 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002168 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002169 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2170 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002171 }
2172#endif
2173
Jeff Johnson295189b2012-06-20 16:38:30 -07002174
2175#if defined WLAN_FEATURE_VOWIFI_11R
2176 if (psessionEntry->pLimJoinReq->is11Rconnection)
2177 {
2178#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002179 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2181 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2182 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2183#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302184 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2185 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302187 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 {
2189 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302190 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 }
2192#endif
2193
2194#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302195 /* CCX Version IE will be included in association request
2196 when CCX is enabled on DUT through ini */
2197 if (psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
2198 {
2199 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
2200 }
2201 /* For CCX Associations fill the CCX IEs */
2202 if (psessionEntry->isCCXconnection &&
2203 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002205#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002206 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002207#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 }
2209#endif
2210
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002211 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 if ( DOT11F_FAILED( nStatus ) )
2213 {
2214 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002215 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 nStatus );
2217 // We'll fall back on the worst case scenario:
2218 nPayload = sizeof( tDot11fAssocRequest );
2219 }
2220 else if ( DOT11F_WARNED( nStatus ) )
2221 {
2222 limLog( pMac, LOGW, FL("There were warnings while calculating"
2223 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002224 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 }
2226
2227 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2228
2229 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2230 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2231 ( void** ) &pPacket );
2232 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2233 {
2234 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002235 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002236
2237 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002238 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002239
2240
2241 /* Update PE session id*/
2242 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2243
2244 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2245
2246 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2247 ( void* ) pFrame, ( void* ) pPacket );
2248
2249 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2250 ( tANI_U32* ) &mlmAssocCnf);
2251
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302252 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 return;
2254 }
2255
2256 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302257 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002258
2259 // Next, we fill out the buffer descriptor:
2260 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2261 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2262 if ( eSIR_SUCCESS != nSirStatus )
2263 {
2264 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002265 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 nSirStatus );
2267 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302268 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 return;
2270 }
2271
2272
2273 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002274 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 sizeof(tSirMacMgmtHdr),
2276 nPayload, &nPayload );
2277 if ( DOT11F_FAILED( nStatus ) )
2278 {
2279 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002280 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 nStatus );
2282 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2283 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302284 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 return;
2286 }
2287 else if ( DOT11F_WARNED( nStatus ) )
2288 {
2289 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002290 "robe Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 }
2292
2293 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002294 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 nBytes );)
2296 // limPrintMacAddr( pMac, bssid, LOG1 );
2297
2298 if( psessionEntry->assocReq != NULL )
2299 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302300 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002301 psessionEntry->assocReq = NULL;
2302 }
2303
2304 if( nAddIELen )
2305 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302306 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2307 pAddIE,
2308 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 nPayload += nAddIELen;
2310 }
2311
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302312 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2313 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 {
2315 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2316 }
2317 else
2318 {
2319 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302320 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 psessionEntry->assocReqLen = nPayload;
2322 }
2323
2324 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2326 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 )
2328 {
2329 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2330 }
2331
Ganesh K08bce952012-12-13 15:04:41 -08002332 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2333 {
2334 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2335 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002336
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2338 HAL_TXRX_FRM_802_11_MGMT,
2339 ANI_TXDIR_TODS,
2340 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2341 limTxComplete, pFrame, txFlag );
2342 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2343 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002344 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 halstatus );
2346 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302347 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 return;
2349 }
2350
2351 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302352 vos_mem_free(pMlmAssocReq);
2353 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002354 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002355} // End limSendAssocReqMgmtFrame
2356
2357
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002358#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002359/*------------------------------------------------------------------------------------
2360 *
2361 * Send Reassoc Req with FTIEs.
2362 *
2363 *-----------------------------------------------------------------------------------
2364 */
2365void
2366limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2367 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2368{
2369 static tDot11fReAssocRequest frm;
2370 tANI_U16 caps;
2371 tANI_U8 *pFrame;
2372 tSirRetStatus nSirStatus;
2373 tANI_U32 nBytes, nPayload, nStatus;
2374 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2375 void *pPacket;
2376 eHalStatus halstatus;
2377#if defined WLAN_FEATURE_VOWIFI
2378 tANI_U8 PowerCapsPopulated = FALSE;
2379#endif
2380 tANI_U16 ft_ies_length = 0;
2381 tANI_U8 *pBody;
2382 tANI_U16 nAddIELen;
2383 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002384#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 tANI_U8 *wpsIe = NULL;
2386#endif
2387 tANI_U8 txFlag = 0;
2388
2389 if (NULL == psessionEntry)
2390 {
2391 return;
2392 }
2393
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 /* check this early to avoid unncessary operation */
2395 if(NULL == psessionEntry->pLimReAssocReq)
2396 {
2397 return;
2398 }
2399 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2400 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002401 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2402 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002403
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302404 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002405
2406 caps = pMlmReassocReq->capabilityInfo;
2407 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2408 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2409#if defined(FEATURE_WLAN_WAPI)
2410 /* CR: 262463 :
2411 According to WAPI standard:
2412 7.3.1.4 Capability Information field
2413 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2414 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2415 Reassociation management frames. */
2416 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2417 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2418#endif
2419 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2420
2421 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2422
2423 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302424 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2426
2427 PopulateDot11fSSID2( pMac, &frm.SSID );
2428 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2429 &frm.SuppRates,psessionEntry);
2430
2431 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2432 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2433
2434 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2435 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2436
2437 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2438 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2439
2440 if ( psessionEntry->lim11hEnable &&
2441 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2442 {
2443#if defined WLAN_FEATURE_VOWIFI
2444 PowerCapsPopulated = TRUE;
2445
2446 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2447 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2448#endif
2449 }
2450
2451#if defined WLAN_FEATURE_VOWIFI
2452 if( pMac->rrm.rrmPEContext.rrmEnable &&
2453 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2454 {
2455 if (PowerCapsPopulated == FALSE)
2456 {
2457 PowerCapsPopulated = TRUE;
2458 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2459 }
2460 }
2461#endif
2462
2463 if ( fQosEnabled &&
2464 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2465 {
2466 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2467 }
2468
2469 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2470 &frm.ExtSuppRates, psessionEntry );
2471
2472#if defined WLAN_FEATURE_VOWIFI
2473 if( pMac->rrm.rrmPEContext.rrmEnable &&
2474 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2475 {
2476 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2477 }
2478#endif
2479
2480 // Ideally this should be enabled for 11r also. But 11r does
2481 // not follow the usual norm of using the Opaque object
2482 // for rsnie and fties. Instead we just add
2483 // the rsnie and fties at the end of the pack routine for 11r.
2484 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002485#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 //
2487 // The join request *should* contain zero or one of the WPA and RSN
2488 // IEs. The payload send along with the request is a
2489 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2490
2491 // typedef struct sSirRSNie
2492 // {
2493 // tANI_U16 length;
2494 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2495 // } tSirRSNie, *tpSirRSNie;
2496
2497 // So, we should be able to make the following two calls harmlessly,
2498 // since they do nothing if they don't find the given IE in the
2499 // bytestream with which they're provided.
2500
2501 // The net effect of this will be to faithfully transmit whatever
2502 // security IE is in the join request.
2503
2504 // *However*, if we're associating for the purpose of WPS
2505 // enrollment, and we've been configured to indicate that by
2506 // eliding the WPA or RSN IE, we just skip this:
2507 if (!psessionEntry->is11Rconnection)
2508 {
2509 if( nAddIELen && pAddIE )
2510 {
2511 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2512 }
2513 if ( NULL == wpsIe )
2514 {
2515 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2516 &frm.RSNOpaque );
2517 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2518 &frm.WPAOpaque );
2519 }
2520
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002521#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302522 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002523 {
2524 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2525 &frm.CCXCckmOpaque );
2526 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002527#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 }
2529
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002530#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302531 /* CCX Version IE will be included in reassociation request
2532 when CCX is enabled on DUT through ini */
2533 if (psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
2534 {
2535 PopulateDot11fCCXVersion(&frm.CCXVersion);
2536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302538 if (psessionEntry->isCCXconnection &&
2539 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002541#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002543#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302545#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002546#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002547
2548 // include WME EDCA IE as well
2549 if ( fWmeEnabled )
2550 {
2551 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2552 {
2553 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2554 }
2555
2556 if ( fWsmEnabled &&
2557 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2558 {
2559 PopulateDot11fWMMCaps( &frm.WMMCaps );
2560 }
2561#ifdef FEATURE_WLAN_CCX
2562 if (psessionEntry->isCCXconnection)
2563 {
2564 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2565
2566 // Populate the TSRS IE if TSPEC is included in the reassoc request
2567 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2568 {
2569 tANI_U32 phyMode;
2570 tSirMacCCXTSRSIE tsrsIE;
2571 limGetPhyMode(pMac, &phyMode, psessionEntry);
2572
2573 tsrsIE.tsid = 0;
2574 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2575 {
2576 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2577 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302578 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 {
2580 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2581 }
2582 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2583 }
2584 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302585#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 }
2587
Jeff Johnsone7245742012-09-05 17:12:55 -07002588 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 pMac->lim.htCapabilityPresentInBeacon)
2590 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002591 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 }
2593
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002594#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302595 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2596#if defined FEATURE_WLAN_CCX
2597 && !psessionEntry->isCCXconnection
2598#endif
2599 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002600 {
2601 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2602 }
2603#endif
2604
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2606 if ( DOT11F_FAILED( nStatus ) )
2607 {
2608 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002609 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 nStatus );
2611 // We'll fall back on the worst case scenario:
2612 nPayload = sizeof( tDot11fReAssocRequest );
2613 }
2614 else if ( DOT11F_WARNED( nStatus ) )
2615 {
2616 limLog( pMac, LOGW, FL("There were warnings while calculating"
2617 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002618 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 }
2620
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002621 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002622
2623#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002624 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2626#endif
2627
2628#if defined WLAN_FEATURE_VOWIFI_11R
2629 if (psessionEntry->is11Rconnection)
2630 {
2631 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2632 }
2633#endif
2634
2635 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2636 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2637 ( void** ) &pPacket );
2638 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2639 {
2640 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002641 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002643 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 goto end;
2645 }
2646
2647 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302648 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002649
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002650#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002651 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002652#endif
2653 // Next, we fill out the buffer descriptor:
2654 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2655 SIR_MAC_MGMT_REASSOC_REQ,
2656 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2657 if ( eSIR_SUCCESS != nSirStatus )
2658 {
2659 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002660 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 nSirStatus );
2662 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2663 goto end;
2664 }
2665
2666
2667 // That done, pack the ReAssoc Request:
2668 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2669 sizeof(tSirMacMgmtHdr),
2670 nPayload, &nPayload );
2671 if ( DOT11F_FAILED( nStatus ) )
2672 {
2673 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002674 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 nStatus );
2676 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2677 goto end;
2678 }
2679 else if ( DOT11F_WARNED( nStatus ) )
2680 {
2681 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002682 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 }
2684
2685 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002686 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 nBytes, nPayload );)
2688 if( psessionEntry->assocReq != NULL )
2689 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302690 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 psessionEntry->assocReq = NULL;
2692 }
2693
2694 if( nAddIELen )
2695 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302696 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2697 pAddIE,
2698 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 nPayload += nAddIELen;
2700 }
2701
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302702 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2703 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 {
2705 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002706 }
2707 else
2708 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002709 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302710 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002713
2714 if (psessionEntry->is11Rconnection)
2715 {
2716 {
2717 int i = 0;
2718
2719 pBody = pFrame + nBytes;
2720 for (i=0; i<ft_ies_length; i++)
2721 {
2722 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2723 pBody++;
2724 }
2725 }
2726 }
2727
2728#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002729 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2730 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 (tANI_U8 *)pFrame,
2732 (nBytes + ft_ies_length));)
2733#endif
2734
2735
2736 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2738 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 )
2740 {
2741 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2742 }
2743
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002744 if( NULL != psessionEntry->assocReq )
2745 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302746 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002747 psessionEntry->assocReq = NULL;
2748 }
2749
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302750 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2751 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002752 {
2753 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002754 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002755 }
2756 else
2757 {
2758 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302759 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2760 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002761 psessionEntry->assocReqLen = (ft_ies_length);
2762 }
2763
2764
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2766 HAL_TXRX_FRM_802_11_MGMT,
2767 ANI_TXDIR_TODS,
2768 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2769 limTxComplete, pFrame, txFlag );
2770 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2771 {
2772 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002773 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 nSirStatus );
2775 //Pkt will be freed up by the callback
2776 goto end;
2777 }
2778
2779end:
2780 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302781 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 psessionEntry->pLimMlmReassocReq = NULL;
2783
2784}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002785
2786void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2787 tLimMlmReassocReq *pMlmReassocReq,
2788 tpPESession psessionEntry)
2789{
2790 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2791 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2792 if(NULL == pTmpMlmReassocReq)
2793 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302794 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2795 if ( NULL == pTmpMlmReassocReq ) goto end;
2796 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2797 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002798 }
2799
2800 // Prepare and send Reassociation request frame
2801 // start reassoc timer.
2802 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2803 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002804 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002805 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2806 != TX_SUCCESS)
2807 {
2808 // Could not start reassoc failure timer.
2809 // Log error
2810 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002811 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002812 // Return Reassoc confirm with
2813 // Resources Unavailable
2814 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2815 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2816 goto end;
2817 }
2818
2819 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2820 return;
2821
2822end:
2823 // Free up buffer allocated for reassocReq
2824 if (pMlmReassocReq != NULL)
2825 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302826 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002827 pMlmReassocReq = NULL;
2828 }
2829 if (pTmpMlmReassocReq != NULL)
2830 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302831 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002832 pTmpMlmReassocReq = NULL;
2833 }
2834 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2835 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2836 /* Update PE sessio Id*/
2837 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2838
2839 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2840}
2841
Jeff Johnson295189b2012-06-20 16:38:30 -07002842#endif /* WLAN_FEATURE_VOWIFI_11R */
2843
2844
2845void
2846limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2847 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2848{
2849 static tDot11fReAssocRequest frm;
2850 tANI_U16 caps;
2851 tANI_U8 *pFrame;
2852 tSirRetStatus nSirStatus;
2853 tANI_U32 nBytes, nPayload, nStatus;
2854 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2855 void *pPacket;
2856 eHalStatus halstatus;
2857 tANI_U16 nAddIELen;
2858 tANI_U8 *pAddIE;
2859 tANI_U8 *wpsIe = NULL;
2860 tANI_U8 txFlag = 0;
2861#if defined WLAN_FEATURE_VOWIFI
2862 tANI_U8 PowerCapsPopulated = FALSE;
2863#endif
2864
2865 if(NULL == psessionEntry)
2866 {
2867 return;
2868 }
2869
2870 /* check this early to avoid unncessary operation */
2871 if(NULL == psessionEntry->pLimReAssocReq)
2872 {
2873 return;
2874 }
2875 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2876 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2877
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302878 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002879
2880 caps = pMlmReassocReq->capabilityInfo;
2881 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2882 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2883#if defined(FEATURE_WLAN_WAPI)
2884 /* CR: 262463 :
2885 According to WAPI standard:
2886 7.3.1.4 Capability Information field
2887 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2888 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2889 Reassociation management frames. */
2890 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2891 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2892#endif
2893 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2894
2895 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2896
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302897 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2898 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002899
2900 PopulateDot11fSSID2( pMac, &frm.SSID );
2901 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2902 &frm.SuppRates,psessionEntry);
2903
2904 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2905 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2906
2907 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2908 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2909
2910 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2911 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2912
2913
2914 if ( psessionEntry->lim11hEnable &&
2915 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2916 {
2917#if defined WLAN_FEATURE_VOWIFI
2918 PowerCapsPopulated = TRUE;
2919 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2920 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2921#endif
2922 }
2923
2924#if defined WLAN_FEATURE_VOWIFI
2925 if( pMac->rrm.rrmPEContext.rrmEnable &&
2926 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2927 {
2928 if (PowerCapsPopulated == FALSE)
2929 {
2930 PowerCapsPopulated = TRUE;
2931 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2932 }
2933 }
2934#endif
2935
2936 if ( fQosEnabled &&
2937 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2938 {
2939 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2940 }
2941
2942 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2943 &frm.ExtSuppRates, psessionEntry );
2944
2945#if defined WLAN_FEATURE_VOWIFI
2946 if( pMac->rrm.rrmPEContext.rrmEnable &&
2947 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2948 {
2949 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2950 }
2951#endif
2952 // The join request *should* contain zero or one of the WPA and RSN
2953 // IEs. The payload send along with the request is a
2954 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2955
2956 // typedef struct sSirRSNie
2957 // {
2958 // tANI_U16 length;
2959 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2960 // } tSirRSNie, *tpSirRSNie;
2961
2962 // So, we should be able to make the following two calls harmlessly,
2963 // since they do nothing if they don't find the given IE in the
2964 // bytestream with which they're provided.
2965
2966 // The net effect of this will be to faithfully transmit whatever
2967 // security IE is in the join request.
2968
2969 // *However*, if we're associating for the purpose of WPS
2970 // enrollment, and we've been configured to indicate that by
2971 // eliding the WPA or RSN IE, we just skip this:
2972 if( nAddIELen && pAddIE )
2973 {
2974 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2975 }
2976 if ( NULL == wpsIe )
2977 {
2978 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2979 &frm.RSNOpaque );
2980 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2981 &frm.WPAOpaque );
2982#if defined(FEATURE_WLAN_WAPI)
2983 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2984 &frm.WAPIOpaque );
2985#endif // defined(FEATURE_WLAN_WAPI)
2986 }
2987
2988 // include WME EDCA IE as well
2989 if ( fWmeEnabled )
2990 {
2991 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2992 {
2993 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2994 }
2995
2996 if ( fWsmEnabled &&
2997 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2998 {
2999 PopulateDot11fWMMCaps( &frm.WMMCaps );
3000 }
3001 }
3002
Jeff Johnsone7245742012-09-05 17:12:55 -07003003 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 pMac->lim.htCapabilityPresentInBeacon)
3005 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003006 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003008#ifdef WLAN_FEATURE_11AC
3009 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003010 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003011 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003012 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003013 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07003014 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003015 }
3016#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003017
3018 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3019 if ( DOT11F_FAILED( nStatus ) )
3020 {
3021 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003022 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 nStatus );
3024 // We'll fall back on the worst case scenario:
3025 nPayload = sizeof( tDot11fReAssocRequest );
3026 }
3027 else if ( DOT11F_WARNED( nStatus ) )
3028 {
3029 limLog( pMac, LOGW, FL("There were warnings while calculating"
3030 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003031 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 }
3033
3034 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3035
3036 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3037 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3038 ( void** ) &pPacket );
3039 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3040 {
3041 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003042 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003044 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 goto end;
3046 }
3047
3048 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303049 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003050
3051 // Next, we fill out the buffer descriptor:
3052 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3053 SIR_MAC_MGMT_REASSOC_REQ,
3054 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3055 if ( eSIR_SUCCESS != nSirStatus )
3056 {
3057 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003058 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 nSirStatus );
3060 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3061 goto end;
3062 }
3063
3064
3065 // That done, pack the Probe Request:
3066 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3067 sizeof(tSirMacMgmtHdr),
3068 nPayload, &nPayload );
3069 if ( DOT11F_FAILED( nStatus ) )
3070 {
3071 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003072 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 nStatus );
3074 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3075 goto end;
3076 }
3077 else if ( DOT11F_WARNED( nStatus ) )
3078 {
3079 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003080 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 }
3082
3083 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003084 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 nBytes );)
3086
3087 if( psessionEntry->assocReq != NULL )
3088 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303089 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 psessionEntry->assocReq = NULL;
3091 }
3092
3093 if( nAddIELen )
3094 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303095 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3096 pAddIE,
3097 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 nPayload += nAddIELen;
3099 }
3100
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303101 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3102 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 {
3104 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003105 }
3106 else
3107 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303109 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003112
3113 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3115 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 )
3117 {
3118 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3119 }
3120
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003121 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003122 {
3123 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3124 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003125
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3127 HAL_TXRX_FRM_802_11_MGMT,
3128 ANI_TXDIR_TODS,
3129 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3130 limTxComplete, pFrame, txFlag );
3131 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3132 {
3133 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003134 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 nSirStatus );
3136 //Pkt will be freed up by the callback
3137 goto end;
3138 }
3139
3140end:
3141 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303142 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 psessionEntry->pLimMlmReassocReq = NULL;
3144
3145} // limSendReassocReqMgmtFrame
3146
3147/**
3148 * \brief Send an Authentication frame
3149 *
3150 *
3151 * \param pMac Pointer to Global MAC structure
3152 *
3153 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3154 * to be sent
3155 *
3156 * \param peerMacAddr MAC address of the peer entity to which Authentication
3157 * frame is destined
3158 *
3159 * \param wepBit Indicates whether wep bit to be set in FC while sending
3160 * Authentication frame3
3161 *
3162 *
3163 * This function is called by limProcessMlmMessages(). Authentication frame
3164 * is formatted and sent when this function is called.
3165 *
3166 *
3167 */
3168
3169void
3170limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3171 tpSirMacAuthFrameBody pAuthFrameBody,
3172 tSirMacAddr peerMacAddr,
3173 tANI_U8 wepBit,
3174 tpPESession psessionEntry
3175 )
3176{
3177 tANI_U8 *pFrame, *pBody;
3178 tANI_U32 frameLen = 0, bodyLen = 0;
3179 tpSirMacMgmtHdr pMacHdr;
3180 tANI_U16 i;
3181 void *pPacket;
3182 eHalStatus halstatus;
3183 tANI_U8 txFlag = 0;
3184
3185 if(NULL == psessionEntry)
3186 {
3187 return;
3188 }
3189
3190 if (wepBit == LIM_WEP_IN_FC)
3191 {
3192 /// Auth frame3 to be sent with encrypted framebody
3193 /**
3194 * Allocate buffer for Authenticaton frame of size equal
3195 * to management frame header length plus 2 bytes each for
3196 * auth algorithm number, transaction number, status code,
3197 * 128 bytes for challenge text and 4 bytes each for
3198 * IV & ICV.
3199 */
3200
3201 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3202
3203 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3204 } // if (wepBit == LIM_WEP_IN_FC)
3205 else
3206 {
3207 switch (pAuthFrameBody->authTransactionSeqNumber)
3208 {
3209 case SIR_MAC_AUTH_FRAME_1:
3210 /**
3211 * Allocate buffer for Authenticaton frame of size
3212 * equal to management frame header length plus 2 bytes
3213 * each for auth algorithm number, transaction number
3214 * and status code.
3215 */
3216
3217 frameLen = sizeof(tSirMacMgmtHdr) +
3218 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3219 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3220
3221#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003222 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3223 {
3224 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003226 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003227 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003228 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003230 else
3231 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003232 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003233 frameLen += (2+SIR_MDIE_SIZE);
3234 }
3235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003236#endif
3237 break;
3238
3239 case SIR_MAC_AUTH_FRAME_2:
3240 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3241 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3242 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3243 {
3244 /**
3245 * Allocate buffer for Authenticaton frame of size
3246 * equal to management frame header length plus
3247 * 2 bytes each for auth algorithm number,
3248 * transaction number and status code.
3249 */
3250
3251 frameLen = sizeof(tSirMacMgmtHdr) +
3252 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3253 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3254 }
3255 else
3256 {
3257 // Shared Key algorithm with challenge text
3258 // to be sent
3259 /**
3260 * Allocate buffer for Authenticaton frame of size
3261 * equal to management frame header length plus
3262 * 2 bytes each for auth algorithm number,
3263 * transaction number, status code and 128 bytes
3264 * for challenge text.
3265 */
3266
3267 frameLen = sizeof(tSirMacMgmtHdr) +
3268 sizeof(tSirMacAuthFrame);
3269 bodyLen = sizeof(tSirMacAuthFrameBody);
3270 }
3271
3272 break;
3273
3274 case SIR_MAC_AUTH_FRAME_3:
3275 /// Auth frame3 to be sent without encrypted framebody
3276 /**
3277 * Allocate buffer for Authenticaton frame of size equal
3278 * to management frame header length plus 2 bytes each
3279 * for auth algorithm number, transaction number and
3280 * status code.
3281 */
3282
3283 frameLen = sizeof(tSirMacMgmtHdr) +
3284 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3285 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3286
3287 break;
3288
3289 case SIR_MAC_AUTH_FRAME_4:
3290 /**
3291 * Allocate buffer for Authenticaton frame of size equal
3292 * to management frame header length plus 2 bytes each
3293 * for auth algorithm number, transaction number and
3294 * status code.
3295 */
3296
3297 frameLen = sizeof(tSirMacMgmtHdr) +
3298 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3299 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3300
3301 break;
3302 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3303 } // end if (wepBit == LIM_WEP_IN_FC)
3304
3305
3306 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3307
3308 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3309 {
3310 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003311 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003312
3313 return;
3314 }
3315
3316 for (i = 0; i < frameLen; i++)
3317 pFrame[i] = 0;
3318
3319 // Prepare BD
3320 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3321 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3322 {
3323 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3324 return;
3325 }
3326
3327 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3328 pMacHdr->fc.wep = wepBit;
3329
3330 // Prepare BSSId
3331 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3332 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303333 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3334 (tANI_U8 *) psessionEntry->bssId,
3335 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 }
3337
3338 /// Prepare Authentication frame body
3339 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3340
3341 if (wepBit == LIM_WEP_IN_FC)
3342 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303343 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003344
3345 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003346 FL("*** Sending Auth seq# 3 status %d (%d) to"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 pAuthFrameBody->authStatusCode,
3348 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3349
3350 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3351 }
3352 else
3353 {
3354 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3355 pBody += sizeof(tANI_U16);
3356 bodyLen -= sizeof(tANI_U16);
3357
3358 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3359 pBody += sizeof(tANI_U16);
3360 bodyLen -= sizeof(tANI_U16);
3361
3362 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3363 pBody += sizeof(tANI_U16);
3364 bodyLen -= sizeof(tANI_U16);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07003365 if ( bodyLen < sizeof (pAuthFrameBody->type) + sizeof (pAuthFrameBody->length) + sizeof (pAuthFrameBody->challengeText))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303366 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003367
3368#if defined WLAN_FEATURE_VOWIFI_11R
3369 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3370 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3371 {
3372
3373 {
3374 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3376 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003377#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3379 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3380 (tANI_U8 *)pBody,
3381 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003382#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003383 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3384 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003385 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3386 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003387 }
3388 }
3389 else
3390 {
3391 /* MDID attr is 54*/
3392 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003394 *pBody = SIR_MDIE_SIZE;
3395 pBody++;
3396 for(i=0;i<SIR_MDIE_SIZE;i++)
3397 {
3398 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3399 pBody++;
3400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 }
3402 }
3403 }
3404#endif
3405
3406 PELOG1(limLog(pMac, LOG1,
3407 FL("*** Sending Auth seq# %d status %d (%d) to "),
3408 pAuthFrameBody->authTransactionSeqNumber,
3409 pAuthFrameBody->authStatusCode,
3410 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3411
3412 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3413 }
3414 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3415
3416 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3418 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003419#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303420 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003421 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3422#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 )
3424 {
3425 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3426 }
3427
Ganesh K08bce952012-12-13 15:04:41 -08003428 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3429 {
3430 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3431 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003432
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 /// Queue Authentication frame in high priority WQ
3434 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3435 HAL_TXRX_FRM_802_11_MGMT,
3436 ANI_TXDIR_TODS,
3437 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3438 limTxComplete, pFrame, txFlag );
3439 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3440 {
3441 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003442 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 halstatus);
3444
3445 //Pkt will be freed up by the callback
3446 }
3447
3448 return;
3449} /*** end limSendAuthMgmtFrame() ***/
3450
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003451eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3452{
3453 tANI_U16 aid;
3454 tpDphHashNode pStaDs;
3455 tLimMlmDeauthReq *pMlmDeauthReq;
3456 tLimMlmDeauthCnf mlmDeauthCnf;
3457 tpPESession psessionEntry;
3458
3459 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3460 if (pMlmDeauthReq)
3461 {
3462 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3463 {
3464 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3465 }
3466
3467 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3468 {
3469
3470 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003471 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003472 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3473 goto end;
3474 }
3475
3476 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3477 if (pStaDs == NULL)
3478 {
3479 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3480 goto end;
3481 }
3482
3483
3484 /// Receive path cleanup with dummy packet
3485 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3486 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303487 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003488 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3489 }
3490 return eHAL_STATUS_SUCCESS;
3491end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303492 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003493 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3494 sizeof(tSirMacAddr));
3495 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3496 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3497 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3498
3499 // Free up buffer allocated
3500 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303501 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003502
3503 limPostSmeMessage(pMac,
3504 LIM_MLM_DEAUTH_CNF,
3505 (tANI_U32 *) &mlmDeauthCnf);
3506 return eHAL_STATUS_SUCCESS;
3507}
3508
3509eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3510{
3511 tANI_U16 aid;
3512 tpDphHashNode pStaDs;
3513 tLimMlmDisassocCnf mlmDisassocCnf;
3514 tpPESession psessionEntry;
3515 tLimMlmDisassocReq *pMlmDisassocReq;
3516
3517 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3518 if (pMlmDisassocReq)
3519 {
3520 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3521 {
3522 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3523 }
3524
3525 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3526 {
3527
3528 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003529 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003530 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3531 goto end;
3532 }
3533
3534 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3535 if (pStaDs == NULL)
3536 {
3537 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3538 goto end;
3539 }
3540
3541 /// Receive path cleanup with dummy packet
3542 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3543 {
3544 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3545 goto end;
3546 }
3547
3548#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003549 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303550 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003551#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303552 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003553#endif
3554#ifdef FEATURE_WLAN_LFR
3555 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003556#endif
3557 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303558 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003559 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003560 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303561 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003562 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003563 psessionEntry, psessionEntry->peSessionId););
3564 limFTCleanup(pMac);
3565 }
3566 else
3567 {
3568 PELOGE(limLog(pMac, LOGE,
3569 FL("No FT Preauth Session Cleanup in role %d"
3570#ifdef FEATURE_WLAN_CCX
3571 " isCCX %d"
3572#endif
3573#ifdef FEATURE_WLAN_LFR
3574 " isLFR %d"
3575#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003576 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003577 psessionEntry->limSystemRole,
3578#ifdef FEATURE_WLAN_CCX
3579 psessionEntry->isCCXconnection,
3580#endif
3581#ifdef FEATURE_WLAN_LFR
3582 psessionEntry->isFastRoamIniFeatureEnabled,
3583#endif
3584 psessionEntry->is11Rconnection,
3585 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003586 }
3587#endif
3588
3589 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303590 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003591 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3592 return eHAL_STATUS_SUCCESS;
3593 }
3594 else
3595 {
3596 return eHAL_STATUS_SUCCESS;
3597 }
3598end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303599 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003600 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3601 sizeof(tSirMacAddr));
3602 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3603 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3604
3605 /* Update PE session ID*/
3606 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3607
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003608 if(pMlmDisassocReq != NULL)
3609 {
3610 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303611 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003612 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3613 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003614
3615 limPostSmeMessage(pMac,
3616 LIM_MLM_DISASSOC_CNF,
3617 (tANI_U32 *) &mlmDisassocCnf);
3618 return eHAL_STATUS_SUCCESS;
3619}
3620
3621eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3622{
3623 return limSendDisassocCnf(pMac);
3624}
3625
3626eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3627{
3628 return limSendDeauthCnf(pMac);
3629}
3630
Jeff Johnson295189b2012-06-20 16:38:30 -07003631/**
3632 * \brief This function is called to send Disassociate frame.
3633 *
3634 *
3635 * \param pMac Pointer to Global MAC structure
3636 *
3637 * \param nReason Indicates the reason that need to be sent in
3638 * Disassociation frame
3639 *
3640 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3641 * sent
3642 *
3643 *
3644 */
3645
3646void
3647limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3648 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003649 tSirMacAddr peer,
3650 tpPESession psessionEntry,
3651 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003652{
3653 tDot11fDisassociation frm;
3654 tANI_U8 *pFrame;
3655 tSirRetStatus nSirStatus;
3656 tpSirMacMgmtHdr pMacHdr;
3657 tANI_U32 nBytes, nPayload, nStatus;
3658 void *pPacket;
3659 eHalStatus halstatus;
3660 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003661 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 if(NULL == psessionEntry)
3663 {
3664 return;
3665 }
3666
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303667 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003668
3669 frm.Reason.code = nReason;
3670
3671 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3672 if ( DOT11F_FAILED( nStatus ) )
3673 {
3674 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003675 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 nStatus );
3677 // We'll fall back on the worst case scenario:
3678 nPayload = sizeof( tDot11fDisassociation );
3679 }
3680 else if ( DOT11F_WARNED( nStatus ) )
3681 {
3682 limLog( pMac, LOGW, FL("There were warnings while calculating"
3683 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003684 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 }
3686
3687 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3688
3689 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3690 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3691 ( void** ) &pPacket );
3692 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3693 {
3694 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003695 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 return;
3697 }
3698
3699 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303700 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003701
3702 // Next, we fill out the buffer descriptor:
3703 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3704 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3705 if ( eSIR_SUCCESS != nSirStatus )
3706 {
3707 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003708 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 nSirStatus );
3710 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3711 ( void* ) pFrame, ( void* ) pPacket );
3712 return; // just allocated...
3713 }
3714
3715 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3716
3717 // Prepare the BSSID
3718 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3719
Chet Lanctot186b5732013-03-18 10:26:30 -07003720#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003721 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003722#endif
3723
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3725 sizeof(tSirMacMgmtHdr),
3726 nPayload, &nPayload );
3727 if ( DOT11F_FAILED( nStatus ) )
3728 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003729 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 nStatus );
3731 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3732 ( void* ) pFrame, ( void* ) pPacket );
3733 return; // allocated!
3734 }
3735 else if ( DOT11F_WARNED( nStatus ) )
3736 {
3737 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003738 "isassociation (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 }
3740
3741 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003742 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3744
3745 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3747 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 )
3749 {
3750 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3751 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003752
Ganesh K08bce952012-12-13 15:04:41 -08003753 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3754 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3755 {
3756 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3757 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003758
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003759 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003761 // Queue Disassociation frame in high priority WQ
3762 /* get the duration from the request */
3763 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3764 HAL_TXRX_FRM_802_11_MGMT,
3765 ANI_TXDIR_TODS,
3766 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3767 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3768 txFlag );
3769 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003770
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003771 if (tx_timer_change(
3772 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3773 != TX_SUCCESS)
3774 {
3775 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003776 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003777 return;
3778 }
3779 else if(TX_SUCCESS != tx_timer_activate(
3780 &pMac->lim.limTimers.gLimDisassocAckTimer))
3781 {
3782 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003783 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003784 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3785 return;
3786 }
3787 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003788 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003789 {
3790 // Queue Disassociation frame in high priority WQ
3791 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3792 HAL_TXRX_FRM_802_11_MGMT,
3793 ANI_TXDIR_TODS,
3794 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3795 limTxComplete, pFrame, txFlag );
3796 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3797 {
3798 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003799 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003800 nSirStatus );
3801 //Pkt will be freed up by the callback
3802 return;
3803 }
3804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003805} // End limSendDisassocMgmtFrame.
3806
3807/**
3808 * \brief This function is called to send a Deauthenticate frame
3809 *
3810 *
3811 * \param pMac Pointer to global MAC structure
3812 *
3813 * \param nReason Indicates the reason that need to be sent in the
3814 * Deauthenticate frame
3815 *
3816 * \param peeer address of the STA to which the frame is to be sent
3817 *
3818 *
3819 */
3820
3821void
3822limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3823 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003824 tSirMacAddr peer,
3825 tpPESession psessionEntry,
3826 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003827{
3828 tDot11fDeAuth frm;
3829 tANI_U8 *pFrame;
3830 tSirRetStatus nSirStatus;
3831 tpSirMacMgmtHdr pMacHdr;
3832 tANI_U32 nBytes, nPayload, nStatus;
3833 void *pPacket;
3834 eHalStatus halstatus;
3835 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003836 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003837#ifdef FEATURE_WLAN_TDLS
3838 tANI_U16 aid;
3839 tpDphHashNode pStaDs;
3840#endif
3841
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 if(NULL == psessionEntry)
3843 {
3844 return;
3845 }
3846
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303847 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003848
3849 frm.Reason.code = nReason;
3850
3851 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3852 if ( DOT11F_FAILED( nStatus ) )
3853 {
3854 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003855 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 nStatus );
3857 // We'll fall back on the worst case scenario:
3858 nPayload = sizeof( tDot11fDeAuth );
3859 }
3860 else if ( DOT11F_WARNED( nStatus ) )
3861 {
3862 limLog( pMac, LOGW, FL("There were warnings while calculating"
3863 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003864 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 }
3866
3867 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3868
3869 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3870 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3871 ( void** ) &pPacket );
3872 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3873 {
3874 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003875 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 return;
3877 }
3878
3879 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303880 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003881
3882 // Next, we fill out the buffer descriptor:
3883 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3884 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3885 if ( eSIR_SUCCESS != nSirStatus )
3886 {
3887 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003888 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 nSirStatus );
3890 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3891 ( void* ) pFrame, ( void* ) pPacket );
3892 return; // just allocated...
3893 }
3894
3895 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3896
3897 // Prepare the BSSID
3898 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3899
Chet Lanctot186b5732013-03-18 10:26:30 -07003900#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003901 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003902#endif
3903
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3905 sizeof(tSirMacMgmtHdr),
3906 nPayload, &nPayload );
3907 if ( DOT11F_FAILED( nStatus ) )
3908 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003909 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 nStatus );
3911 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3912 ( void* ) pFrame, ( void* ) pPacket );
3913 return;
3914 }
3915 else if ( DOT11F_WARNED( nStatus ) )
3916 {
3917 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003918 "e-Authentication (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 }
3920
3921 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003922 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3924
3925 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3927 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 )
3929 {
3930 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3931 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003932
Ganesh K08bce952012-12-13 15:04:41 -08003933 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3934 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3935 {
3936 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3937 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003938
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003939#ifdef FEATURE_WLAN_TDLS
3940 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3941#endif
3942
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003943 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003945 // Queue Disassociation frame in high priority WQ
3946 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3947 HAL_TXRX_FRM_802_11_MGMT,
3948 ANI_TXDIR_TODS,
3949 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3950 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
3951 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3952 {
3953 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003954 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003955 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003956 //Pkt will be freed up by the callback limTxComplete
3957
3958 /*Call limProcessDeauthAckTimeout which will send
3959 * DeauthCnf for this frame
3960 */
3961 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003962 return;
3963 }
3964
3965 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3966
3967 if (tx_timer_change(
3968 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3969 != TX_SUCCESS)
3970 {
3971 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003972 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003973 return;
3974 }
3975 else if(TX_SUCCESS != tx_timer_activate(
3976 &pMac->lim.limTimers.gLimDeauthAckTimer))
3977 {
3978 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003979 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003980 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3981 return;
3982 }
3983 }
3984 else
3985 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003986#ifdef FEATURE_WLAN_TDLS
3987 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
3988 {
3989 // Queue Disassociation frame in high priority WQ
3990 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003991 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003992 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003993 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3994 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003995 }
3996 else
3997 {
3998#endif
3999 // Queue Disassociation frame in high priority WQ
4000 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4001 HAL_TXRX_FRM_802_11_MGMT,
4002 ANI_TXDIR_TODS,
4003 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4004 limTxComplete, pFrame, txFlag );
4005#ifdef FEATURE_WLAN_TDLS
4006 }
4007#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004008 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4009 {
4010 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004011 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004012 nSirStatus );
4013 //Pkt will be freed up by the callback
4014 return;
4015 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 }
4017
4018} // End limSendDeauthMgmtFrame.
4019
4020
4021#ifdef ANI_SUPPORT_11H
4022/**
4023 * \brief Send a Measurement Report Action frame
4024 *
4025 *
4026 * \param pMac Pointer to the global MAC structure
4027 *
4028 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4029 *
4030 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4031 *
4032 *
4033 */
4034
4035tSirRetStatus
4036limSendMeasReportFrame(tpAniSirGlobal pMac,
4037 tpSirMacMeasReqActionFrame pMeasReqFrame,
4038 tSirMacAddr peer)
4039{
4040 tDot11fMeasurementReport frm;
4041 tANI_U8 *pFrame;
4042 tSirRetStatus nSirStatus;
4043 tpSirMacMgmtHdr pMacHdr;
4044 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4045 void *pPacket;
4046 eHalStatus halstatus;
4047
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304048 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004049
4050 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4051 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4052 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4053
4054 switch ( pMeasReqFrame->measReqIE.measType )
4055 {
4056 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4057 nSirStatus =
4058 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4059 &frm.MeasurementReport );
4060 break;
4061 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4062 nSirStatus =
4063 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4064 &frm.MeasurementReport );
4065 break;
4066 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4067 nSirStatus =
4068 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4069 &frm.MeasurementReport );
4070 break;
4071 default:
4072 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004073 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 pMeasReqFrame->measReqIE.measType );
4075 return eSIR_FAILURE;
4076 }
4077
4078 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4079
4080 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4081 if ( DOT11F_FAILED( nStatus ) )
4082 {
4083 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004084 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 nStatus );
4086 // We'll fall back on the worst case scenario:
4087 nPayload = sizeof( tDot11fMeasurementReport );
4088 }
4089 else if ( DOT11F_WARNED( nStatus ) )
4090 {
4091 limLog( pMac, LOGW, FL("There were warnings while calculating"
4092 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004093 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 }
4095
4096 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4097
4098 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4099 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4100 {
4101 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004102 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 return eSIR_FAILURE;
4104 }
4105
4106 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304107 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004108
4109 // Next, we fill out the buffer descriptor:
4110 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4111 SIR_MAC_MGMT_ACTION, peer);
4112 if ( eSIR_SUCCESS != nSirStatus )
4113 {
4114 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004115 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 nSirStatus );
4117 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4118 return eSIR_FAILURE; // just allocated...
4119 }
4120
4121 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4122
4123 nCfg = 6;
4124 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4125 if ( eSIR_SUCCESS != nSirStatus )
4126 {
4127 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004128 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 nSirStatus );
4130 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4131 return eSIR_FAILURE; // just allocated...
4132 }
4133
Chet Lanctot186b5732013-03-18 10:26:30 -07004134#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004135 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004136#endif
4137
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4139 sizeof(tSirMacMgmtHdr),
4140 nPayload, &nPayload );
4141 if ( DOT11F_FAILED( nStatus ) )
4142 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004143 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 nStatus );
4145 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4146 return eSIR_FAILURE; // allocated!
4147 }
4148 else if ( DOT11F_WARNED( nStatus ) )
4149 {
4150 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004151 "easurement Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 }
4153
4154 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4155 HAL_TXRX_FRM_802_11_MGMT,
4156 ANI_TXDIR_TODS,
4157 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4158 limTxComplete, pFrame, 0 );
4159 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4160 {
4161 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004162 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 nSirStatus );
4164 //Pkt will be freed up by the callback
4165 return eSIR_FAILURE; // just allocated...
4166 }
4167
4168 return eSIR_SUCCESS;
4169
4170} // End limSendMeasReportFrame.
4171
4172
4173/**
4174 * \brief Send a TPC Request Action frame
4175 *
4176 *
4177 * \param pMac Pointer to the global MAC datastructure
4178 *
4179 * \param peer MAC address to which the frame should be sent
4180 *
4181 *
4182 */
4183
4184void
4185limSendTpcRequestFrame(tpAniSirGlobal pMac,
4186 tSirMacAddr peer)
4187{
4188 tDot11fTPCRequest frm;
4189 tANI_U8 *pFrame;
4190 tSirRetStatus nSirStatus;
4191 tpSirMacMgmtHdr pMacHdr;
4192 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4193 void *pPacket;
4194 eHalStatus halstatus;
4195
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304196 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004197
4198 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4199 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4200 frm.DialogToken.token = 1;
4201 frm.TPCRequest.present = 1;
4202
4203 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4204 if ( DOT11F_FAILED( nStatus ) )
4205 {
4206 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004207 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 nStatus );
4209 // We'll fall back on the worst case scenario:
4210 nPayload = sizeof( tDot11fTPCRequest );
4211 }
4212 else if ( DOT11F_WARNED( nStatus ) )
4213 {
4214 limLog( pMac, LOGW, FL("There were warnings while calculating"
4215 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004216 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 }
4218
4219 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4220
4221 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4222 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4223 {
4224 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004225 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 return;
4227 }
4228
4229 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304230 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004231
4232 // Next, we fill out the buffer descriptor:
4233 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4234 SIR_MAC_MGMT_ACTION, peer);
4235 if ( eSIR_SUCCESS != nSirStatus )
4236 {
4237 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004238 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 nSirStatus );
4240 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4241 return; // just allocated...
4242 }
4243
4244 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4245
4246 nCfg = 6;
4247 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4248 if ( eSIR_SUCCESS != nSirStatus )
4249 {
4250 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004251 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 nSirStatus );
4253 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4254 return; // just allocated...
4255 }
4256
Chet Lanctot186b5732013-03-18 10:26:30 -07004257#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004258 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004259#endif
4260
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4262 sizeof(tSirMacMgmtHdr),
4263 nPayload, &nPayload );
4264 if ( DOT11F_FAILED( nStatus ) )
4265 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004266 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 nStatus );
4268 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4269 return; // allocated!
4270 }
4271 else if ( DOT11F_WARNED( nStatus ) )
4272 {
4273 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004274 "PC Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 }
4276
4277 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4278 HAL_TXRX_FRM_802_11_MGMT,
4279 ANI_TXDIR_TODS,
4280 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4281 limTxComplete, pFrame, 0 );
4282 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4283 {
4284 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004285 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 nSirStatus );
4287 //Pkt will be freed up by the callback
4288 return;
4289 }
4290
4291} // End limSendTpcRequestFrame.
4292
4293
4294/**
4295 * \brief Send a TPC Report Action frame
4296 *
4297 *
4298 * \param pMac Pointer to the global MAC datastructure
4299 *
4300 * \param pTpcReqFrame Pointer to the received TPC Request
4301 *
4302 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4303 *
4304 *
4305 */
4306
4307tSirRetStatus
4308limSendTpcReportFrame(tpAniSirGlobal pMac,
4309 tpSirMacTpcReqActionFrame pTpcReqFrame,
4310 tSirMacAddr peer)
4311{
4312 tDot11fTPCReport frm;
4313 tANI_U8 *pFrame;
4314 tSirRetStatus nSirStatus;
4315 tpSirMacMgmtHdr pMacHdr;
4316 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4317 void *pPacket;
4318 eHalStatus halstatus;
4319
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304320 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004321
4322 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4323 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4324 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4325
4326 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4327 // "misplaced this function, need to replace:
4328 // txPower = halGetRateToPwrValue(pMac, staid,
4329 // pMac->lim.gLimCurrentChannelId, 0);
4330 frm.TPCReport.tx_power = 0;
4331 frm.TPCReport.link_margin = 0;
4332 frm.TPCReport.present = 1;
4333
4334 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4335 if ( DOT11F_FAILED( nStatus ) )
4336 {
4337 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004338 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 nStatus );
4340 // We'll fall back on the worst case scenario:
4341 nPayload = sizeof( tDot11fTPCReport );
4342 }
4343 else if ( DOT11F_WARNED( nStatus ) )
4344 {
4345 limLog( pMac, LOGW, FL("There were warnings while calculating"
4346 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004347 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 }
4349
4350 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4351
4352 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4353 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4354 {
4355 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004356 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 return eSIR_FAILURE;
4358 }
4359
4360 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304361 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004362
4363 // Next, we fill out the buffer descriptor:
4364 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4365 SIR_MAC_MGMT_ACTION, peer);
4366 if ( eSIR_SUCCESS != nSirStatus )
4367 {
4368 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004369 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 nSirStatus );
4371 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4372 return eSIR_FAILURE; // just allocated...
4373 }
4374
4375 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4376
4377 nCfg = 6;
4378 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4379 if ( eSIR_SUCCESS != nSirStatus )
4380 {
4381 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004382 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 nSirStatus );
4384 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4385 return eSIR_FAILURE; // just allocated...
4386 }
4387
Chet Lanctot186b5732013-03-18 10:26:30 -07004388#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004389 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004390#endif
4391
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4393 sizeof(tSirMacMgmtHdr),
4394 nPayload, &nPayload );
4395 if ( DOT11F_FAILED( nStatus ) )
4396 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004397 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 nStatus );
4399 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4400 return eSIR_FAILURE; // allocated!
4401 }
4402 else if ( DOT11F_WARNED( nStatus ) )
4403 {
4404 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004405 "PC Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 }
4407
4408
4409 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4410 HAL_TXRX_FRM_802_11_MGMT,
4411 ANI_TXDIR_TODS,
4412 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4413 limTxComplete, pFrame, 0 );
4414 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4415 {
4416 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004417 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 nSirStatus );
4419 //Pkt will be freed up by the callback
4420 return eSIR_FAILURE; // just allocated...
4421 }
4422
4423 return eSIR_SUCCESS;
4424
4425} // End limSendTpcReportFrame.
4426#endif //ANI_SUPPORT_11H
4427
4428
Jeff Johnson295189b2012-06-20 16:38:30 -07004429/**
4430 * \brief Send a Channel Switch Announcement
4431 *
4432 *
4433 * \param pMac Pointer to the global MAC datastructure
4434 *
4435 * \param peer MAC address to which this frame will be sent
4436 *
4437 * \param nMode
4438 *
4439 * \param nNewChannel
4440 *
4441 * \param nCount
4442 *
4443 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4444 *
4445 *
4446 */
4447
4448tSirRetStatus
4449limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4450 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004451 tANI_U8 nMode,
4452 tANI_U8 nNewChannel,
4453 tANI_U8 nCount,
4454 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004455{
4456 tDot11fChannelSwitch frm;
4457 tANI_U8 *pFrame;
4458 tSirRetStatus nSirStatus;
4459 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004460 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 void *pPacket;
4462 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004463 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004464
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304465 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004466
4467 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4468 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4469 frm.ChanSwitchAnn.switchMode = nMode;
4470 frm.ChanSwitchAnn.newChannel = nNewChannel;
4471 frm.ChanSwitchAnn.switchCount = nCount;
4472 frm.ChanSwitchAnn.present = 1;
4473
4474 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4475 if ( DOT11F_FAILED( nStatus ) )
4476 {
4477 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004478 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 nStatus );
4480 // We'll fall back on the worst case scenario:
4481 nPayload = sizeof( tDot11fChannelSwitch );
4482 }
4483 else if ( DOT11F_WARNED( nStatus ) )
4484 {
4485 limLog( pMac, LOGW, FL("There were warnings while calculating"
4486 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004487 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 }
4489
4490 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4491
4492 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4493 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4494 {
4495 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004496 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 return eSIR_FAILURE;
4498 }
4499
4500 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304501 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004502
4503 // Next, we fill out the buffer descriptor:
4504 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004505 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4506 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304507 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4508 (tANI_U8 *) psessionEntry->bssId,
4509 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 if ( eSIR_SUCCESS != nSirStatus )
4511 {
4512 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004513 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 nSirStatus );
4515 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4516 return eSIR_FAILURE; // just allocated...
4517 }
4518
Jeff Johnsone7245742012-09-05 17:12:55 -07004519#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4521
4522 nCfg = 6;
4523 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4524 if ( eSIR_SUCCESS != nSirStatus )
4525 {
4526 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004527 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 nSirStatus );
4529 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4530 return eSIR_FAILURE; // just allocated...
4531 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004532#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004533
4534#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004535 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004536#endif
4537
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4539 sizeof(tSirMacMgmtHdr),
4540 nPayload, &nPayload );
4541 if ( DOT11F_FAILED( nStatus ) )
4542 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004543 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 nStatus );
4545 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4546 return eSIR_FAILURE; // allocated!
4547 }
4548 else if ( DOT11F_WARNED( nStatus ) )
4549 {
4550 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004551 "hannel Switch (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 }
4553
Jeff Johnsone7245742012-09-05 17:12:55 -07004554 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004555 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4556 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004557 )
4558 {
4559 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4562 HAL_TXRX_FRM_802_11_MGMT,
4563 ANI_TXDIR_TODS,
4564 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004565 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4567 {
4568 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004569 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 nSirStatus );
4571 //Pkt will be freed up by the callback
4572 return eSIR_FAILURE;
4573 }
4574
4575 return eSIR_SUCCESS;
4576
4577} // End limSendChannelSwitchMgmtFrame.
4578
Jeff Johnson295189b2012-06-20 16:38:30 -07004579
4580
Mohit Khanna4a70d262012-09-11 16:30:12 -07004581#ifdef WLAN_FEATURE_11AC
4582tSirRetStatus
4583limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4584 tSirMacAddr peer,
4585 tANI_U8 nMode,
4586 tpPESession psessionEntry )
4587{
4588 tDot11fOperatingMode frm;
4589 tANI_U8 *pFrame;
4590 tSirRetStatus nSirStatus;
4591 tpSirMacMgmtHdr pMacHdr;
4592 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4593 void *pPacket;
4594 eHalStatus halstatus;
4595 tANI_U8 txFlag = 0;
4596
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304597 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004598
4599 frm.Category.category = SIR_MAC_ACTION_VHT;
4600 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4601 frm.OperatingMode.chanWidth = nMode;
4602 frm.OperatingMode.rxNSS = 0;
4603 frm.OperatingMode.rxNSSType = 0;
4604
4605 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4606 if ( DOT11F_FAILED( nStatus ) )
4607 {
4608 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004609 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004610 nStatus );
4611 // We'll fall back on the worst case scenario:
4612 nPayload = sizeof( tDot11fOperatingMode);
4613 }
4614 else if ( DOT11F_WARNED( nStatus ) )
4615 {
4616 limLog( pMac, LOGW, FL("There were warnings while calculating"
4617 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004618 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004619 }
4620
4621 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4622
4623 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4624 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4625 {
4626 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004627 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004628 return eSIR_FAILURE;
4629 }
4630
4631 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304632 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004633
4634
4635 // Next, we fill out the buffer descriptor:
4636 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4637 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4638 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4639 } else
4640 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4641 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4642 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304643 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4644 (tANI_U8 *) psessionEntry->bssId,
4645 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004646 if ( eSIR_SUCCESS != nSirStatus )
4647 {
4648 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004649 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004650 nSirStatus );
4651 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4652 return eSIR_FAILURE; // just allocated...
4653 }
4654 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4655 sizeof(tSirMacMgmtHdr),
4656 nPayload, &nPayload );
4657 if ( DOT11F_FAILED( nStatus ) )
4658 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004659 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004660 nStatus );
4661 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4662 return eSIR_FAILURE; // allocated!
4663 }
4664 else if ( DOT11F_WARNED( nStatus ) )
4665 {
4666 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004667 " (0x%08x).") );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004668 }
4669 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004670 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4671 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004672 )
4673 {
4674 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4675 }
4676 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4677 HAL_TXRX_FRM_802_11_MGMT,
4678 ANI_TXDIR_TODS,
4679 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4680 limTxComplete, pFrame, txFlag );
4681 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4682 {
4683 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004684 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004685 nSirStatus );
4686 //Pkt will be freed up by the callback
4687 return eSIR_FAILURE;
4688 }
4689
4690 return eSIR_SUCCESS;
4691}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004692
4693/**
4694 * \brief Send a VHT Channel Switch Announcement
4695 *
4696 *
4697 * \param pMac Pointer to the global MAC datastructure
4698 *
4699 * \param peer MAC address to which this frame will be sent
4700 *
4701 * \param nChanWidth
4702 *
4703 * \param nNewChannel
4704 *
4705 *
4706 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4707 *
4708 *
4709 */
4710
4711tSirRetStatus
4712limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4713 tSirMacAddr peer,
4714 tANI_U8 nChanWidth,
4715 tANI_U8 nNewChannel,
4716 tANI_U8 ncbMode,
4717 tpPESession psessionEntry )
4718{
4719 tDot11fChannelSwitch frm;
4720 tANI_U8 *pFrame;
4721 tSirRetStatus nSirStatus;
4722 tpSirMacMgmtHdr pMacHdr;
4723 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4724 void *pPacket;
4725 eHalStatus halstatus;
4726 tANI_U8 txFlag = 0;
4727
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304728 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004729
4730
4731 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4732 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4733 frm.ChanSwitchAnn.switchMode = 1;
4734 frm.ChanSwitchAnn.newChannel = nNewChannel;
4735 frm.ChanSwitchAnn.switchCount = 1;
4736 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4737 frm.ExtChanSwitchAnn.present = 1;
4738 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4739 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4740 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4741 frm.ChanSwitchAnn.present = 1;
4742 frm.WiderBWChanSwitchAnn.present = 1;
4743
4744 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4745 if ( DOT11F_FAILED( nStatus ) )
4746 {
4747 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004748 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004749 nStatus );
4750 // We'll fall back on the worst case scenario:
4751 nPayload = sizeof( tDot11fChannelSwitch );
4752 }
4753 else if ( DOT11F_WARNED( nStatus ) )
4754 {
4755 limLog( pMac, LOGW, FL("There were warnings while calculating"
4756 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004757 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004758 }
4759
4760 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4761
4762 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4763 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4764 {
4765 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004766 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004767 return eSIR_FAILURE;
4768 }
4769 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304770 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004771
4772 // Next, we fill out the buffer descriptor:
4773 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4774 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4775 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304776 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4777 (tANI_U8 *) psessionEntry->bssId,
4778 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004779 if ( eSIR_SUCCESS != nSirStatus )
4780 {
4781 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004782 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004783 nSirStatus );
4784 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4785 return eSIR_FAILURE; // just allocated...
4786 }
4787 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4788 sizeof(tSirMacMgmtHdr),
4789 nPayload, &nPayload );
4790 if ( DOT11F_FAILED( nStatus ) )
4791 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004792 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004793 nStatus );
4794 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4795 return eSIR_FAILURE; // allocated!
4796 }
4797 else if ( DOT11F_WARNED( nStatus ) )
4798 {
4799 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004800 "hannel Switch (0x%08x).") );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004801 }
4802
4803 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004804 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4805 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004806 )
4807 {
4808 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4809 }
4810 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4811 HAL_TXRX_FRM_802_11_MGMT,
4812 ANI_TXDIR_TODS,
4813 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4814 limTxComplete, pFrame, txFlag );
4815 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4816 {
4817 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004818 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004819 nSirStatus );
4820 //Pkt will be freed up by the callback
4821 return eSIR_FAILURE;
4822 }
4823
4824 return eSIR_SUCCESS;
4825
4826} // End limSendVHTChannelSwitchMgmtFrame.
4827
4828
4829
Mohit Khanna4a70d262012-09-11 16:30:12 -07004830#endif
4831
Jeff Johnson295189b2012-06-20 16:38:30 -07004832/**
4833 * \brief Send an ADDBA Req Action Frame to peer
4834 *
4835 * \sa limSendAddBAReq
4836 *
4837 * \param pMac The global tpAniSirGlobal object
4838 *
4839 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4840 * the necessary parameters reqd by PE send the ADDBA Req Action
4841 * Frame to the peer
4842 *
4843 * \return eSIR_SUCCESS if setup completes successfully
4844 * eSIR_FAILURE is some problem is encountered
4845 */
4846tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304847 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004848{
4849 tDot11fAddBAReq frmAddBAReq;
4850 tANI_U8 *pAddBAReqBuffer = NULL;
4851 tpSirMacMgmtHdr pMacHdr;
4852 tANI_U32 frameLen = 0, nStatus, nPayload;
4853 tSirRetStatus statusCode;
4854 eHalStatus halStatus;
4855 void *pPacket;
4856 tANI_U8 txFlag = 0;
4857
4858 if(NULL == psessionEntry)
4859 {
4860 return eSIR_FAILURE;
4861 }
4862
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304863 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004864
4865 // Category - 3 (BA)
4866 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4867
4868 // Action - 0 (ADDBA Req)
4869 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4870
4871 // FIXME - Dialog Token, generalize this...
4872 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4873
4874 // Fill the ADDBA Parameter Set
4875 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4876 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4877 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4878
4879 // BA timeout
4880 // 0 - indicates no BA timeout
4881 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4882
4883 // BA Starting Sequence Number
4884 // Fragment number will always be zero
4885 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4886 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4887 }
4888
4889 frmAddBAReq.BAStartingSequenceControl.ssn =
4890 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4891
4892 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4893
4894 if( DOT11F_FAILED( nStatus ))
4895 {
4896 limLog( pMac, LOGW,
4897 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004898 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 nStatus );
4900
4901 // We'll fall back on the worst case scenario:
4902 nPayload = sizeof( tDot11fAddBAReq );
4903 }
4904 else if( DOT11F_WARNED( nStatus ))
4905 {
4906 limLog( pMac, LOGW,
4907 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004908 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 nStatus );
4910 }
4911
4912 // Add the MGMT header to frame length
4913 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4914
4915 // Need to allocate a buffer for ADDBA AF
4916 if( eHAL_STATUS_SUCCESS !=
4917 (halStatus = palPktAlloc( pMac->hHdd,
4918 HAL_TXRX_FRM_802_11_MGMT,
4919 (tANI_U16) frameLen,
4920 (void **) &pAddBAReqBuffer,
4921 (void **) &pPacket )))
4922 {
4923 // Log error
4924 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004925 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 frameLen,
4927 halStatus );
4928
4929 statusCode = eSIR_MEM_ALLOC_FAILED;
4930 goto returnAfterError;
4931 }
4932
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304933 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004934
4935 // Copy necessary info to BD
4936 if( eSIR_SUCCESS !=
4937 (statusCode = limPopulateMacHeader( pMac,
4938 pAddBAReqBuffer,
4939 SIR_MAC_MGMT_FRAME,
4940 SIR_MAC_MGMT_ACTION,
4941 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4942 goto returnAfterError;
4943
4944 // Update A3 with the BSSID
4945 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4946
4947 #if 0
4948 cfgLen = SIR_MAC_ADDR_LENGTH;
4949 if( eSIR_SUCCESS != cfgGetStr( pMac,
4950 WNI_CFG_BSSID,
4951 (tANI_U8 *) pMacHdr->bssId,
4952 &cfgLen ))
4953 {
4954 limLog( pMac, LOGP,
4955 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004956 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004957
4958 // FIXME - Need to convert to tSirRetStatus
4959 statusCode = eSIR_FAILURE;
4960 goto returnAfterError;
4961 }
4962 #endif//TO SUPPORT BT-AMP
4963 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4964
Chet Lanctot186b5732013-03-18 10:26:30 -07004965#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004966 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004967#endif
4968
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 // Now, we're ready to "pack" the frames
4970 nStatus = dot11fPackAddBAReq( pMac,
4971 &frmAddBAReq,
4972 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4973 nPayload,
4974 &nPayload );
4975
4976 if( DOT11F_FAILED( nStatus ))
4977 {
4978 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004979 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 nStatus );
4981
4982 // FIXME - Need to convert to tSirRetStatus
4983 statusCode = eSIR_FAILURE;
4984 goto returnAfterError;
4985 }
4986 else if( DOT11F_WARNED( nStatus ))
4987 {
4988 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004989 FL( "There were warnings while packing an ADDBA Req (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 }
4991
4992 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004993 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4995
4996 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4998 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 )
5000 {
5001 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5002 }
5003
5004 if( eHAL_STATUS_SUCCESS !=
5005 (halStatus = halTxFrame( pMac,
5006 pPacket,
5007 (tANI_U16) frameLen,
5008 HAL_TXRX_FRM_802_11_MGMT,
5009 ANI_TXDIR_TODS,
5010 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5011 limTxComplete,
5012 pAddBAReqBuffer, txFlag )))
5013 {
5014 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005015 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 halStatus );
5017
5018 // FIXME - Need to convert eHalStatus to tSirRetStatus
5019 statusCode = eSIR_FAILURE;
5020 //Pkt will be freed up by the callback
5021 return statusCode;
5022 }
5023 else
5024 return eSIR_SUCCESS;
5025
5026returnAfterError:
5027
5028 // Release buffer, if allocated
5029 if( NULL != pAddBAReqBuffer )
5030 palPktFree( pMac->hHdd,
5031 HAL_TXRX_FRM_802_11_MGMT,
5032 (void *) pAddBAReqBuffer,
5033 (void *) pPacket );
5034
5035 return statusCode;
5036}
5037
5038/**
5039 * \brief Send an ADDBA Rsp Action Frame to peer
5040 *
5041 * \sa limSendAddBARsp
5042 *
5043 * \param pMac The global tpAniSirGlobal object
5044 *
5045 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5046 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5047 * Frame to the peer
5048 *
5049 * \return eSIR_SUCCESS if setup completes successfully
5050 * eSIR_FAILURE is some problem is encountered
5051 */
5052tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5053 tpLimMlmAddBARsp pMlmAddBARsp,
5054 tpPESession psessionEntry)
5055{
5056 tDot11fAddBARsp frmAddBARsp;
5057 tANI_U8 *pAddBARspBuffer = NULL;
5058 tpSirMacMgmtHdr pMacHdr;
5059 tANI_U32 frameLen = 0, nStatus, nPayload;
5060 tSirRetStatus statusCode;
5061 eHalStatus halStatus;
5062 void *pPacket;
5063 tANI_U8 txFlag = 0;
5064
5065 if(NULL == psessionEntry)
5066 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005067 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 return eSIR_FAILURE;
5069 }
5070
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305071 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005072
5073 // Category - 3 (BA)
5074 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5075 // Action - 1 (ADDBA Rsp)
5076 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5077
5078 // Should be same as the one we received in the ADDBA Req
5079 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5080
5081 // ADDBA Req status
5082 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5083
5084 // Fill the ADDBA Parameter Set as provided by caller
5085 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5086 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5087 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
Kiran Kumar Lokere2ac471f2013-05-30 16:08:48 -07005088 frmAddBARsp.AddBAParameterSet.amsduSupported = psessionEntry->amsduSupportedInBA;
Jeff Johnson295189b2012-06-20 16:38:30 -07005089
5090 // BA timeout
5091 // 0 - indicates no BA timeout
5092 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5093
5094 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5095
5096 if( DOT11F_FAILED( nStatus ))
5097 {
5098 limLog( pMac, LOGW,
5099 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005100 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 nStatus );
5102
5103 // We'll fall back on the worst case scenario:
5104 nPayload = sizeof( tDot11fAddBARsp );
5105 }
5106 else if( DOT11F_WARNED( nStatus ))
5107 {
5108 limLog( pMac, LOGW,
5109 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005110 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005111 nStatus );
5112 }
5113
5114 // Need to allocate a buffer for ADDBA AF
5115 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5116
5117 // Allocate shared memory
5118 if( eHAL_STATUS_SUCCESS !=
5119 (halStatus = palPktAlloc( pMac->hHdd,
5120 HAL_TXRX_FRM_802_11_MGMT,
5121 (tANI_U16) frameLen,
5122 (void **) &pAddBARspBuffer,
5123 (void **) &pPacket )))
5124 {
5125 // Log error
5126 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005127 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 frameLen,
5129 halStatus );
5130
5131 statusCode = eSIR_MEM_ALLOC_FAILED;
5132 goto returnAfterError;
5133 }
5134
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305135 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005136
5137 // Copy necessary info to BD
5138 if( eSIR_SUCCESS !=
5139 (statusCode = limPopulateMacHeader( pMac,
5140 pAddBARspBuffer,
5141 SIR_MAC_MGMT_FRAME,
5142 SIR_MAC_MGMT_ACTION,
5143 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5144 goto returnAfterError;
5145
5146 // Update A3 with the BSSID
5147
5148 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5149
5150 #if 0
5151 cfgLen = SIR_MAC_ADDR_LENGTH;
5152 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5153 WNI_CFG_BSSID,
5154 (tANI_U8 *) pMacHdr->bssId,
5155 &cfgLen ))
5156 {
5157 limLog( pMac, LOGP,
5158 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005159 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005160
5161 // FIXME - Need to convert to tSirRetStatus
5162 statusCode = eSIR_FAILURE;
5163 goto returnAfterError;
5164 }
5165 #endif // TO SUPPORT BT-AMP
5166 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5167
Chet Lanctot186b5732013-03-18 10:26:30 -07005168#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005169 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005170#endif
5171
Jeff Johnson295189b2012-06-20 16:38:30 -07005172 // Now, we're ready to "pack" the frames
5173 nStatus = dot11fPackAddBARsp( pMac,
5174 &frmAddBARsp,
5175 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5176 nPayload,
5177 &nPayload );
5178
5179 if( DOT11F_FAILED( nStatus ))
5180 {
5181 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005182 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 nStatus );
5184
5185 // FIXME - Need to convert to tSirRetStatus
5186 statusCode = eSIR_FAILURE;
5187 goto returnAfterError;
5188 }
5189 else if( DOT11F_WARNED( nStatus ))
5190 {
5191 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005192 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 }
5194
5195 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005196 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005197 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5198
5199 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5201 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005202 )
5203 {
5204 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5205 }
5206
5207 if( eHAL_STATUS_SUCCESS !=
5208 (halStatus = halTxFrame( pMac,
5209 pPacket,
5210 (tANI_U16) frameLen,
5211 HAL_TXRX_FRM_802_11_MGMT,
5212 ANI_TXDIR_TODS,
5213 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5214 limTxComplete,
5215 pAddBARspBuffer, txFlag )))
5216 {
5217 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005218 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 halStatus );
5220
5221 // FIXME - HAL error codes are different from PE error
5222 // codes!! And, this routine is returning tSirRetStatus
5223 statusCode = eSIR_FAILURE;
5224 //Pkt will be freed up by the callback
5225 return statusCode;
5226 }
5227 else
5228 return eSIR_SUCCESS;
5229
5230 returnAfterError:
5231
5232 // Release buffer, if allocated
5233 if( NULL != pAddBARspBuffer )
5234 palPktFree( pMac->hHdd,
5235 HAL_TXRX_FRM_802_11_MGMT,
5236 (void *) pAddBARspBuffer,
5237 (void *) pPacket );
5238
5239 return statusCode;
5240}
5241
5242/**
5243 * \brief Send a DELBA Indication Action Frame to peer
5244 *
5245 * \sa limSendDelBAInd
5246 *
5247 * \param pMac The global tpAniSirGlobal object
5248 *
5249 * \param peerMacAddr MAC Address of peer
5250 *
5251 * \param reasonCode Reason for the DELBA notification
5252 *
5253 * \param pBAParameterSet The DELBA Parameter Set.
5254 * This identifies the TID for which the BA session is
5255 * being deleted.
5256 *
5257 * \return eSIR_SUCCESS if setup completes successfully
5258 * eSIR_FAILURE is some problem is encountered
5259 */
5260tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5261 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5262{
5263 tDot11fDelBAInd frmDelBAInd;
5264 tANI_U8 *pDelBAIndBuffer = NULL;
5265 //tANI_U32 val;
5266 tpSirMacMgmtHdr pMacHdr;
5267 tANI_U32 frameLen = 0, nStatus, nPayload;
5268 tSirRetStatus statusCode;
5269 eHalStatus halStatus;
5270 void *pPacket;
5271 tANI_U8 txFlag = 0;
5272
5273 if(NULL == psessionEntry)
5274 {
5275 return eSIR_FAILURE;
5276 }
5277
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305278 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005279
5280 // Category - 3 (BA)
5281 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5282 // Action - 2 (DELBA)
5283 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5284
5285 // Fill the DELBA Parameter Set as provided by caller
5286 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5287 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5288
5289 // BA Starting Sequence Number
5290 // Fragment number will always be zero
5291 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5292
5293 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5294
5295 if( DOT11F_FAILED( nStatus ))
5296 {
5297 limLog( pMac, LOGW,
5298 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005299 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 nStatus );
5301
5302 // We'll fall back on the worst case scenario:
5303 nPayload = sizeof( tDot11fDelBAInd );
5304 }
5305 else if( DOT11F_WARNED( nStatus ))
5306 {
5307 limLog( pMac, LOGW,
5308 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005309 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 nStatus );
5311 }
5312
5313 // Add the MGMT header to frame length
5314 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5315
5316 // Allocate shared memory
5317 if( eHAL_STATUS_SUCCESS !=
5318 (halStatus = palPktAlloc( pMac->hHdd,
5319 HAL_TXRX_FRM_802_11_MGMT,
5320 (tANI_U16) frameLen,
5321 (void **) &pDelBAIndBuffer,
5322 (void **) &pPacket )))
5323 {
5324 // Log error
5325 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005326 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 frameLen,
5328 halStatus );
5329
5330 statusCode = eSIR_MEM_ALLOC_FAILED;
5331 goto returnAfterError;
5332 }
5333
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305334 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005335
5336 // Copy necessary info to BD
5337 if( eSIR_SUCCESS !=
5338 (statusCode = limPopulateMacHeader( pMac,
5339 pDelBAIndBuffer,
5340 SIR_MAC_MGMT_FRAME,
5341 SIR_MAC_MGMT_ACTION,
5342 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5343 goto returnAfterError;
5344
5345 // Update A3 with the BSSID
5346 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5347
5348 #if 0
5349 cfgLen = SIR_MAC_ADDR_LENGTH;
5350 if( eSIR_SUCCESS != cfgGetStr( pMac,
5351 WNI_CFG_BSSID,
5352 (tANI_U8 *) pMacHdr->bssId,
5353 &cfgLen ))
5354 {
5355 limLog( pMac, LOGP,
5356 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005357 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005358
5359 // FIXME - Need to convert to tSirRetStatus
5360 statusCode = eSIR_FAILURE;
5361 goto returnAfterError;
5362 }
5363 #endif //TO SUPPORT BT-AMP
5364 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5365
Chet Lanctot186b5732013-03-18 10:26:30 -07005366#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005367 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005368#endif
5369
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 // Now, we're ready to "pack" the frames
5371 nStatus = dot11fPackDelBAInd( pMac,
5372 &frmDelBAInd,
5373 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5374 nPayload,
5375 &nPayload );
5376
5377 if( DOT11F_FAILED( nStatus ))
5378 {
5379 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005380 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 nStatus );
5382
5383 // FIXME - Need to convert to tSirRetStatus
5384 statusCode = eSIR_FAILURE;
5385 goto returnAfterError;
5386 }
5387 else if( DOT11F_WARNED( nStatus ))
5388 {
5389 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005390 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 }
5392
5393 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005394 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5396
5397 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5399 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 )
5401 {
5402 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5403 }
5404
5405 if( eHAL_STATUS_SUCCESS !=
5406 (halStatus = halTxFrame( pMac,
5407 pPacket,
5408 (tANI_U16) frameLen,
5409 HAL_TXRX_FRM_802_11_MGMT,
5410 ANI_TXDIR_TODS,
5411 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5412 limTxComplete,
5413 pDelBAIndBuffer, txFlag )))
5414 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005415 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 statusCode = eSIR_FAILURE;
5417 //Pkt will be freed up by the callback
5418 return statusCode;
5419 }
5420 else
5421 return eSIR_SUCCESS;
5422
5423 returnAfterError:
5424
5425 // Release buffer, if allocated
5426 if( NULL != pDelBAIndBuffer )
5427 palPktFree( pMac->hHdd,
5428 HAL_TXRX_FRM_802_11_MGMT,
5429 (void *) pDelBAIndBuffer,
5430 (void *) pPacket );
5431
5432 return statusCode;
5433}
5434
5435#if defined WLAN_FEATURE_VOWIFI
5436
5437/**
5438 * \brief Send a Neighbor Report Request Action frame
5439 *
5440 *
5441 * \param pMac Pointer to the global MAC structure
5442 *
5443 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5444 *
5445 * \param peer mac address of peer station.
5446 *
5447 * \param psessionEntry address of session entry.
5448 *
5449 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5450 *
5451 *
5452 */
5453
5454tSirRetStatus
5455limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5456 tpSirMacNeighborReportReq pNeighborReq,
5457 tSirMacAddr peer,
5458 tpPESession psessionEntry
5459 )
5460{
5461 tSirRetStatus statusCode = eSIR_SUCCESS;
5462 tDot11fNeighborReportRequest frm;
5463 tANI_U8 *pFrame;
5464 tpSirMacMgmtHdr pMacHdr;
5465 tANI_U32 nBytes, nPayload, nStatus;
5466 void *pPacket;
5467 eHalStatus halstatus;
5468 tANI_U8 txFlag = 0;
5469
5470 if ( psessionEntry == NULL )
5471 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005472 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 return eSIR_FAILURE;
5474 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305475 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005476
5477 frm.Category.category = SIR_MAC_ACTION_RRM;
5478 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5479 frm.DialogToken.token = pNeighborReq->dialogToken;
5480
5481
5482 if( pNeighborReq->ssid_present )
5483 {
5484 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5485 }
5486
5487 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5488 if ( DOT11F_FAILED( nStatus ) )
5489 {
5490 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005491 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 nStatus );
5493 // We'll fall back on the worst case scenario:
5494 nPayload = sizeof( tDot11fNeighborReportRequest );
5495 }
5496 else if ( DOT11F_WARNED( nStatus ) )
5497 {
5498 limLog( pMac, LOGW, FL("There were warnings while calculating"
5499 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005500 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 }
5502
5503 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5504
5505 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5506 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5507 {
5508 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005509 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 return eSIR_FAILURE;
5511 }
5512
5513 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305514 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005515
5516 // Copy necessary info to BD
5517 if( eSIR_SUCCESS !=
5518 (statusCode = limPopulateMacHeader( pMac,
5519 pFrame,
5520 SIR_MAC_MGMT_FRAME,
5521 SIR_MAC_MGMT_ACTION,
5522 peer, psessionEntry->selfMacAddr)))
5523 goto returnAfterError;
5524
5525 // Update A3 with the BSSID
5526 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5527
5528 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5529
Chet Lanctot186b5732013-03-18 10:26:30 -07005530#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005531 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005532#endif
5533
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 // Now, we're ready to "pack" the frames
5535 nStatus = dot11fPackNeighborReportRequest( pMac,
5536 &frm,
5537 pFrame + sizeof( tSirMacMgmtHdr ),
5538 nPayload,
5539 &nPayload );
5540
5541 if( DOT11F_FAILED( nStatus ))
5542 {
5543 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005544 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 nStatus );
5546
5547 // FIXME - Need to convert to tSirRetStatus
5548 statusCode = eSIR_FAILURE;
5549 goto returnAfterError;
5550 }
5551 else if( DOT11F_WARNED( nStatus ))
5552 {
5553 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005554 FL( "There were warnings while packing Neighbor Report Request (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 }
5556
5557 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005558 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 limPrintMacAddr( pMac, peer, LOGW );
5560
5561 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5563 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 )
5565 {
5566 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5567 }
5568
5569 if( eHAL_STATUS_SUCCESS !=
5570 (halstatus = halTxFrame( pMac,
5571 pPacket,
5572 (tANI_U16) nBytes,
5573 HAL_TXRX_FRM_802_11_MGMT,
5574 ANI_TXDIR_TODS,
5575 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5576 limTxComplete,
5577 pFrame, txFlag )))
5578 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005579 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 statusCode = eSIR_FAILURE;
5581 //Pkt will be freed up by the callback
5582 return statusCode;
5583 }
5584 else
5585 return eSIR_SUCCESS;
5586
5587returnAfterError:
5588 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5589
5590 return statusCode;
5591} // End limSendNeighborReportRequestFrame.
5592
5593/**
5594 * \brief Send a Link Report Action frame
5595 *
5596 *
5597 * \param pMac Pointer to the global MAC structure
5598 *
5599 * \param pLinkReport Address of a tSirMacLinkReport
5600 *
5601 * \param peer mac address of peer station.
5602 *
5603 * \param psessionEntry address of session entry.
5604 *
5605 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5606 *
5607 *
5608 */
5609
5610tSirRetStatus
5611limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5612 tpSirMacLinkReport pLinkReport,
5613 tSirMacAddr peer,
5614 tpPESession psessionEntry
5615 )
5616{
5617 tSirRetStatus statusCode = eSIR_SUCCESS;
5618 tDot11fLinkMeasurementReport frm;
5619 tANI_U8 *pFrame;
5620 tpSirMacMgmtHdr pMacHdr;
5621 tANI_U32 nBytes, nPayload, nStatus;
5622 void *pPacket;
5623 eHalStatus halstatus;
5624 tANI_U8 txFlag = 0;
5625
5626
5627 if ( psessionEntry == NULL )
5628 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005629 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 return eSIR_FAILURE;
5631 }
5632
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305633 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005634
5635 frm.Category.category = SIR_MAC_ACTION_RRM;
5636 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5637 frm.DialogToken.token = pLinkReport->dialogToken;
5638
5639
5640 //IEEE Std. 802.11 7.3.2.18. for the report element.
5641 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5642 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5643 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5644 //such case this way than changing the frame parser.
5645 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5646 frm.TPCEleLen.TPCLen = 2;
5647 frm.TxPower.txPower = pLinkReport->txPower;
5648 frm.LinkMargin.linkMargin = 0;
5649
5650 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5651 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5652 frm.RCPI.rcpi = pLinkReport->rcpi;
5653 frm.RSNI.rsni = pLinkReport->rsni;
5654
5655 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5656 if ( DOT11F_FAILED( nStatus ) )
5657 {
5658 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005659 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 nStatus );
5661 // We'll fall back on the worst case scenario:
5662 nPayload = sizeof( tDot11fLinkMeasurementReport );
5663 }
5664 else if ( DOT11F_WARNED( nStatus ) )
5665 {
5666 limLog( pMac, LOGW, FL("There were warnings while calculating"
5667 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005668 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 }
5670
5671 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5672
5673 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5674 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5675 {
5676 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005677 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 return eSIR_FAILURE;
5679 }
5680
5681 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305682 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005683
5684 // Copy necessary info to BD
5685 if( eSIR_SUCCESS !=
5686 (statusCode = limPopulateMacHeader( pMac,
5687 pFrame,
5688 SIR_MAC_MGMT_FRAME,
5689 SIR_MAC_MGMT_ACTION,
5690 peer, psessionEntry->selfMacAddr)))
5691 goto returnAfterError;
5692
5693 // Update A3 with the BSSID
5694 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5695
5696 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5697
Chet Lanctot186b5732013-03-18 10:26:30 -07005698#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005699 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005700#endif
5701
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 // Now, we're ready to "pack" the frames
5703 nStatus = dot11fPackLinkMeasurementReport( pMac,
5704 &frm,
5705 pFrame + sizeof( tSirMacMgmtHdr ),
5706 nPayload,
5707 &nPayload );
5708
5709 if( DOT11F_FAILED( nStatus ))
5710 {
5711 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005712 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 nStatus );
5714
5715 // FIXME - Need to convert to tSirRetStatus
5716 statusCode = eSIR_FAILURE;
5717 goto returnAfterError;
5718 }
5719 else if( DOT11F_WARNED( nStatus ))
5720 {
5721 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005722 FL( "There were warnings while packing Link Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 }
5724
5725 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005726 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 limPrintMacAddr( pMac, peer, LOGW );
5728
5729 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5731 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 )
5733 {
5734 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5735 }
5736
5737 if( eHAL_STATUS_SUCCESS !=
5738 (halstatus = halTxFrame( pMac,
5739 pPacket,
5740 (tANI_U16) nBytes,
5741 HAL_TXRX_FRM_802_11_MGMT,
5742 ANI_TXDIR_TODS,
5743 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5744 limTxComplete,
5745 pFrame, txFlag )))
5746 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005747 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 statusCode = eSIR_FAILURE;
5749 //Pkt will be freed up by the callback
5750 return statusCode;
5751 }
5752 else
5753 return eSIR_SUCCESS;
5754
5755returnAfterError:
5756 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5757
5758 return statusCode;
5759} // End limSendLinkReportActionFrame.
5760
5761/**
5762 * \brief Send a Beacon Report Action frame
5763 *
5764 *
5765 * \param pMac Pointer to the global MAC structure
5766 *
5767 * \param dialog_token dialog token to be used in the action frame.
5768 *
5769 * \param num_report number of reports in pRRMReport.
5770 *
5771 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5772 *
5773 * \param peer mac address of peer station.
5774 *
5775 * \param psessionEntry address of session entry.
5776 *
5777 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5778 *
5779 *
5780 */
5781
5782tSirRetStatus
5783limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5784 tANI_U8 dialog_token,
5785 tANI_U8 num_report,
5786 tpSirMacRadioMeasureReport pRRMReport,
5787 tSirMacAddr peer,
5788 tpPESession psessionEntry
5789 )
5790{
5791 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 tANI_U8 *pFrame;
5793 tpSirMacMgmtHdr pMacHdr;
5794 tANI_U32 nBytes, nPayload, nStatus;
5795 void *pPacket;
5796 eHalStatus halstatus;
5797 tANI_U8 i;
5798 tANI_U8 txFlag = 0;
5799
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005800 tDot11fRadioMeasurementReport *frm =
5801 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5802 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005803 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005804 return eSIR_FAILURE;
5805 }
5806
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 if ( psessionEntry == NULL )
5808 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005809 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005810 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 return eSIR_FAILURE;
5812 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305813 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005814
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005815 frm->Category.category = SIR_MAC_ACTION_RRM;
5816 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5817 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005818
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005819 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 -07005820
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005821 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005823 frm->MeasurementReport[i].type = pRRMReport[i].type;
5824 frm->MeasurementReport[i].token = pRRMReport[i].token;
5825 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 switch( pRRMReport[i].type )
5827 {
5828 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005829 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5830 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5831 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5832 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 break;
5834 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305835 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5836 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005837 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 break;
5839 }
5840 }
5841
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005842 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 if ( DOT11F_FAILED( nStatus ) )
5844 {
5845 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005846 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 nStatus );
5848 // We'll fall back on the worst case scenario:
5849 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005850 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 return eSIR_FAILURE;
5852 }
5853 else if ( DOT11F_WARNED( nStatus ) )
5854 {
5855 limLog( pMac, LOGW, FL("There were warnings while calculating"
5856 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005857 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 }
5859
5860 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5861
5862 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5863 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5864 {
5865 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005866 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005867 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 return eSIR_FAILURE;
5869 }
5870
5871 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305872 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005873
5874 // Copy necessary info to BD
5875 if( eSIR_SUCCESS !=
5876 (statusCode = limPopulateMacHeader( pMac,
5877 pFrame,
5878 SIR_MAC_MGMT_FRAME,
5879 SIR_MAC_MGMT_ACTION,
5880 peer, psessionEntry->selfMacAddr)))
5881 goto returnAfterError;
5882
5883 // Update A3 with the BSSID
5884 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5885
5886 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5887
Chet Lanctot186b5732013-03-18 10:26:30 -07005888#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005889 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005890#endif
5891
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 // Now, we're ready to "pack" the frames
5893 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005894 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005895 pFrame + sizeof( tSirMacMgmtHdr ),
5896 nPayload,
5897 &nPayload );
5898
5899 if( DOT11F_FAILED( nStatus ))
5900 {
5901 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005902 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 nStatus );
5904
5905 // FIXME - Need to convert to tSirRetStatus
5906 statusCode = eSIR_FAILURE;
5907 goto returnAfterError;
5908 }
5909 else if( DOT11F_WARNED( nStatus ))
5910 {
5911 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005912 FL( "There were warnings while packing Radio Measure Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 }
5914
5915 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005916 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 limPrintMacAddr( pMac, peer, LOGW );
5918
5919 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5921 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 )
5923 {
5924 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5925 }
5926
5927 if( eHAL_STATUS_SUCCESS !=
5928 (halstatus = halTxFrame( pMac,
5929 pPacket,
5930 (tANI_U16) nBytes,
5931 HAL_TXRX_FRM_802_11_MGMT,
5932 ANI_TXDIR_TODS,
5933 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5934 limTxComplete,
5935 pFrame, txFlag )))
5936 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005937 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 statusCode = eSIR_FAILURE;
5939 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005940 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 return statusCode;
5942 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005943 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005944 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005947
5948returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005949 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 return statusCode;
5952} // End limSendBeaconReportActionFrame.
5953
5954#endif
5955
5956#ifdef WLAN_FEATURE_11W
5957/**
5958 * \brief Send SA query response action frame to peer
5959 *
5960 * \sa limSendSaQueryResponseFrame
5961 *
5962 *
5963 * \param pMac The global tpAniSirGlobal object
5964 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005965 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005967 * \param peer The Mac address of the AP to which this action frame is addressed
5968 *
5969 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 *
5971 * \return eSIR_SUCCESS if setup completes successfully
5972 * eSIR_FAILURE is some problem is encountered
5973 */
5974
Chet Lanctot186b5732013-03-18 10:26:30 -07005975tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005976tSirMacAddr peer,tpPESession psessionEntry)
5977{
5978
Chet Lanctot186b5732013-03-18 10:26:30 -07005979 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 tANI_U8 *pFrame;
5981 tSirRetStatus nSirStatus;
5982 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07005983 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 void *pPacket;
5985 eHalStatus halstatus;
Chet Lanctot186b5732013-03-18 10:26:30 -07005986 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005987
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305988 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07005989 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
5990 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 action: 0 --> SA query request action frame
5992 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07005993 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
5994 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07005996 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005997
Chet Lanctot186b5732013-03-18 10:26:30 -07005998 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
5999 if ( DOT11F_FAILED( nStatus ) )
6000 {
6001 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6002 "or a SA Query Response (0x%08x)."),
6003 nStatus );
6004 // We'll fall back on the worst case scenario:
6005 nPayload = sizeof( tDot11fSaQueryRsp );
6006 }
6007 else if ( DOT11F_WARNED( nStatus ) )
6008 {
6009 limLog( pMac, LOGW, FL("There were warnings while calculating"
6010 "the packed size for an SA Query Response"
6011 " (0x%08x)."), nStatus );
6012 }
6013
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6015 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6016 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6017 {
6018 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006019 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 return eSIR_FAILURE;
6021 }
6022
6023 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306024 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006025
Chet Lanctot186b5732013-03-18 10:26:30 -07006026 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006027 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006028 pFrame,
6029 SIR_MAC_MGMT_FRAME,
6030 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006031 peer, psessionEntry->selfMacAddr );
6032 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006033 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006034
Chet Lanctot186b5732013-03-18 10:26:30 -07006035 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6037
Chet Lanctot186b5732013-03-18 10:26:30 -07006038 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006039
Chet Lanctot186b5732013-03-18 10:26:30 -07006040 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6041 // in the FC
6042 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006043 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006044 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 }
6046
Chet Lanctot186b5732013-03-18 10:26:30 -07006047 // Pack 11w SA query response frame
6048 nStatus = dot11fPackSaQueryRsp( pMac,
6049 &frm,
6050 pFrame + sizeof( tSirMacMgmtHdr ),
6051 nPayload,
6052 &nPayload );
6053
6054 if ( DOT11F_FAILED( nStatus ))
6055 {
6056 limLog( pMac, LOGE,
6057 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6058 nStatus );
6059 // FIXME - Need to convert to tSirRetStatus
6060 nSirStatus = eSIR_FAILURE;
6061 goto returnAfterError;
6062 }
6063 else if ( DOT11F_WARNED( nStatus ))
6064 {
6065 limLog( pMac, LOGW,
6066 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6067 nStatus);
6068 }
6069
6070 limLog( pMac, LOG1,
6071 FL( "Sending a SA Query Response to " ));
6072 limPrintMacAddr( pMac, peer, LOGW );
6073
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006074 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006075#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006076 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6077 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006078#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006079 )
6080 {
6081 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6082 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006083
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006084 halstatus = halTxFrame( pMac,
6085 pPacket,
6086 (tANI_U16) nBytes,
6087 HAL_TXRX_FRM_802_11_MGMT,
6088 ANI_TXDIR_TODS,
6089 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6090 limTxComplete,
6091 pFrame, txFlag );
6092 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006093 {
6094 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6095 nSirStatus = eSIR_FAILURE;
6096 //Pkt will be freed up by the callback
6097 return nSirStatus;
6098 }
6099 else {
6100 return eSIR_SUCCESS;
6101 }
6102
6103returnAfterError:
6104 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6105 return nSirStatus;
6106} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006107#endif