blob: 440ea01225ef7cec727d1bc51d9ff0f40e441cc3 [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
647 if ( psessionEntry->pLimStartBssReq )
648 {
649 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700650 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700651 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
652 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 }
654
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700655 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700656
657#if defined(FEATURE_WLAN_WAPI)
658 if( psessionEntry->pLimStartBssReq )
659 {
660 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700661 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 }
663
664#endif // defined(FEATURE_WLAN_WAPI)
665
666
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700667 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 if ( DOT11F_FAILED( nStatus ) )
669 {
670 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700671 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 nStatus );
673 // We'll fall back on the worst case scenario:
674 nPayload = sizeof( tDot11fProbeResponse );
675 }
676 else if ( DOT11F_WARNED( nStatus ) )
677 {
678 limLog( pMac, LOGW, FL("There were warnings while calculating"
679 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700680 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700681 }
682
683 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
684
685 addnIEPresent = false;
686
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 if( pMac->lim.gpLimRemainOnChanReq )
688 {
689 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
690 }
691 //Only use CFG for non-listen mode. This CFG is not working for concurrency
692 //In listening mode, probe rsp IEs is passed in the message from SME to PE
693 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 {
695
696 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
697 &addnIEPresent) != eSIR_SUCCESS)
698 {
699 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530700 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 return;
702 }
703 }
704
705 if (addnIEPresent)
706 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530707
708 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
709 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 {
711 PELOGE(limLog(pMac, LOGE,
712 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530713 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 return;
715 }
716
717 //Probe rsp IE available
718 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
719 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
720 {
721 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530722 vos_mem_free(addIE);
723 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 return;
725 }
726 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
727 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
728 {
729 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
730 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
731 &addnIE1Len) )
732 {
733 limLog(pMac, LOGP,
734 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530735 vos_mem_free(addIE);
736 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 return;
738 }
739 }
740
741 //Probe rsp IE available
742 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
743 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
744 {
745 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530746 vos_mem_free(addIE);
747 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 return;
749 }
750 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
751 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
752 {
753 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
754 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
755 &addnIE2Len) )
756 {
757 limLog(pMac, LOGP,
758 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530759 vos_mem_free(addIE);
760 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 return;
762 }
763 }
764
765 //Probe rsp IE available
766 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
767 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
768 {
769 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530770 vos_mem_free(addIE);
771 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 return;
773 }
774 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
775 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
776 {
777 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
778 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
779 &addIE[addnIE1Len + addnIE2Len],
780 &addnIE3Len) )
781 {
782 limLog(pMac, LOGP,
783 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530784 vos_mem_free(addIE);
785 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 return;
787 }
788 }
789 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
790
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
792 {
793 limLog(pMac, LOGP,
794 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530795 vos_mem_free(addIE);
796 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 return;
798 }
799 nBytes = nBytes + totalAddnIeLen;
800
801 if (probeReqP2pIe)
802 {
803 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
804 if (pP2pIe != NULL)
805 {
806 //get NoA attribute stream P2P IE
807 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
808 if (noaLen != 0)
809 {
810 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
811 &noaStream[0], noaLen);
812 nBytes = nBytes + total_noaLen;
813 }
814 }
815 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700816 }
817
818 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
819 ( tANI_U16 )nBytes, ( void** ) &pFrame,
820 ( void** ) &pPacket );
821 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
822 {
823 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700824 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 if ( addIE != NULL )
826 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530827 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530829 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 return;
831 }
832
833 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530834 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700835
836 // Next, we fill out the buffer descriptor:
837 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
838 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
839 if ( eSIR_SUCCESS != nSirStatus )
840 {
841 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700842 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 nSirStatus );
844 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
845 ( void* ) pFrame, ( void* ) pPacket );
846 if ( addIE != NULL )
847 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530848 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530850 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 return;
852 }
853
854 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
855
856 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
857
858 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700859 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 nPayload, &nPayload );
861 if ( DOT11F_FAILED( nStatus ) )
862 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700863 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 nStatus );
865 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
866 if ( addIE != NULL )
867 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530868 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530870 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 return; // allocated!
872 }
873 else if ( DOT11F_WARNED( nStatus ) )
874 {
875 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700876 "robe Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 }
878
879 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
880 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
881
882 pMac->sys.probeRespond++;
883
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 if( pMac->lim.gpLimRemainOnChanReq )
885 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530886 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
888 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700889
890 if ( addnIEPresent )
891 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530892 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 if (noaLen != 0)
895 {
Krunal Soni81b24262013-05-15 17:46:41 -0700896 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 {
898 limLog(pMac, LOGE,
899 FL("Not able to insert NoA because of length constraint"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530900 vos_mem_free(addIE);
901 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -0700902 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
903 ( void* ) pFrame, ( void* ) pPacket );
904 return;
905 }
906 else
907 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530908 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -0700909 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 }
911 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700912
913 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
915 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 )
917 {
918 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
919 }
920
921 // Queue Probe Response frame in high priority WQ
922 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
923 ( tANI_U16 ) nBytes,
924 HAL_TXRX_FRM_802_11_MGMT,
925 ANI_TXDIR_TODS,
926 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
927 limTxComplete, pFrame, txFlag );
928 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
929 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700930 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 //Pkt will be freed up by the callback
932 }
933
934 if ( addIE != NULL )
935 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530936 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 }
938
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530939 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700940 return;
941
942
Jeff Johnson295189b2012-06-20 16:38:30 -0700943} // End limSendProbeRspMgmtFrame.
944
945void
946limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
947 tSirMacAddr peerMacAddr,
948 tSirAddtsReqInfo *pAddTS,
949 tpPESession psessionEntry)
950{
951 tANI_U16 i;
952 tANI_U8 *pFrame;
953 tSirRetStatus nSirStatus;
954 tDot11fAddTSRequest AddTSReq;
955 tDot11fWMMAddTSRequest WMMAddTSReq;
956 tANI_U32 nPayload, nBytes, nStatus;
957 tpSirMacMgmtHdr pMacHdr;
958 void *pPacket;
959#ifdef FEATURE_WLAN_CCX
960 tANI_U32 phyMode;
961#endif
962 eHalStatus halstatus;
963 tANI_U8 txFlag = 0;
964
965 if(NULL == psessionEntry)
966 {
967 return;
968 }
969
970 if ( ! pAddTS->wmeTspecPresent )
971 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530972 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700973
974 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
975 AddTSReq.DialogToken.token = pAddTS->dialogToken;
976 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
977 if ( pAddTS->lleTspecPresent )
978 {
979 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
980 }
981 else
982 {
983 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
984 }
985
986 if ( pAddTS->lleTspecPresent )
987 {
988 AddTSReq.num_WMMTCLAS = 0;
989 AddTSReq.num_TCLAS = pAddTS->numTclas;
990 for ( i = 0; i < pAddTS->numTclas; ++i)
991 {
992 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
993 &AddTSReq.TCLAS[i] );
994 }
995 }
996 else
997 {
998 AddTSReq.num_TCLAS = 0;
999 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1000 for ( i = 0; i < pAddTS->numTclas; ++i)
1001 {
1002 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1003 &AddTSReq.WMMTCLAS[i] );
1004 }
1005 }
1006
1007 if ( pAddTS->tclasProcPresent )
1008 {
1009 if ( pAddTS->lleTspecPresent )
1010 {
1011 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1012 AddTSReq.TCLASSPROC.present = 1;
1013 }
1014 else
1015 {
1016 AddTSReq.WMMTCLASPROC.version = 1;
1017 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1018 AddTSReq.WMMTCLASPROC.present = 1;
1019 }
1020 }
1021
1022 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1023 if ( DOT11F_FAILED( nStatus ) )
1024 {
1025 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001026 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 nStatus );
1028 // We'll fall back on the worst case scenario:
1029 nPayload = sizeof( tDot11fAddTSRequest );
1030 }
1031 else if ( DOT11F_WARNED( nStatus ) )
1032 {
1033 limLog( pMac, LOGW, FL("There were warnings while calculating"
1034 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001035 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 }
1037 }
1038 else
1039 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301040 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001041
1042 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1043 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1044 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1045
1046 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1047 WMMAddTSReq.StatusCode.statusCode = 0;
1048
1049 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1050#ifdef FEATURE_WLAN_CCX
1051 limGetPhyMode(pMac, &phyMode, psessionEntry);
1052
1053 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1054 {
1055 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1056 }
1057 else
1058 {
1059 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1060 }
1061 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1062#endif
1063 // fillWmeTspecIE
1064
1065 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1066 if ( DOT11F_FAILED( nStatus ) )
1067 {
1068 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001069 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 nStatus );
1071 // We'll fall back on the worst case scenario:
1072 nPayload = sizeof( tDot11fAddTSRequest );
1073 }
1074 else if ( DOT11F_WARNED( nStatus ) )
1075 {
1076 limLog( pMac, LOGW, FL("There were warnings while calculating"
1077 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001078 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 }
1080 }
1081
1082 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1083
1084 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1085 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1086 ( void** ) &pPacket );
1087 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1088 {
1089 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001090 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 return;
1092 }
1093
1094 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301095 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001096
1097 // Next, we fill out the buffer descriptor:
1098 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1099 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1100 if ( eSIR_SUCCESS != nSirStatus )
1101 {
1102 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001103 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 nSirStatus );
1105 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1106 ( void* ) pFrame, ( void* ) pPacket );
1107 return;
1108 }
1109
1110 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1111
1112 #if 0
1113 cfgLen = SIR_MAC_ADDR_LENGTH;
1114 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1115 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1116 {
1117 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001118 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1120 ( void* ) pFrame, ( void* ) pPacket );
1121 return;
1122 }
1123 #endif //TO SUPPORT BT-AMP
1124
1125 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1126
Chet Lanctot186b5732013-03-18 10:26:30 -07001127#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001128 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001129#endif
1130
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 // That done, pack the struct:
1132 if ( ! pAddTS->wmeTspecPresent )
1133 {
1134 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1135 pFrame + sizeof(tSirMacMgmtHdr),
1136 nPayload, &nPayload );
1137 if ( DOT11F_FAILED( nStatus ) )
1138 {
1139 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001140 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001141 nStatus );
1142 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1143 return; // allocated!
1144 }
1145 else if ( DOT11F_WARNED( nStatus ) )
1146 {
1147 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001148 "an Add TS Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 }
1150 }
1151 else
1152 {
1153 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1154 pFrame + sizeof(tSirMacMgmtHdr),
1155 nPayload, &nPayload );
1156 if ( DOT11F_FAILED( nStatus ) )
1157 {
1158 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001159 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 nStatus );
1161 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1162 return; // allocated!
1163 }
1164 else if ( DOT11F_WARNED( nStatus ) )
1165 {
1166 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001167 "a WMM Add TS Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 }
1169 }
1170
1171 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1172 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1173
1174 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1176 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 )
1178 {
1179 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1180 }
1181
1182 // Queue Addts Response frame in high priority WQ
1183 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1184 HAL_TXRX_FRM_802_11_MGMT,
1185 ANI_TXDIR_TODS,
1186 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1187 limTxComplete, pFrame, txFlag );
1188 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1189 {
1190 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001191 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 //Pkt will be freed up by the callback
1193 }
1194
1195} // End limSendAddtsReqActionFrame.
1196
Jeff Johnson295189b2012-06-20 16:38:30 -07001197
1198
1199void
1200limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1201 tANI_U16 statusCode,
1202 tANI_U16 aid,
1203 tSirMacAddr peerMacAddr,
1204 tANI_U8 subType,
1205 tpDphHashNode pSta,tpPESession psessionEntry)
1206{
1207 static tDot11fAssocResponse frm;
1208 tANI_U8 *pFrame, *macAddr;
1209 tpSirMacMgmtHdr pMacHdr;
1210 tSirRetStatus nSirStatus;
1211 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1212 tHalBitVal qosMode, wmeMode;
1213 tANI_U32 nPayload, nBytes, nStatus;
1214 void *pPacket;
1215 eHalStatus halstatus;
1216 tUpdateBeaconParams beaconParams;
1217 tANI_U8 txFlag = 0;
1218 tANI_U32 addnIEPresent = false;
1219 tANI_U32 addnIELen=0;
1220 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1221 tpSirAssocReq pAssocReq = NULL;
1222
1223 if(NULL == psessionEntry)
1224 {
1225 return;
1226 }
1227
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301228 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001229
1230 limGetQosMode(psessionEntry, &qosMode);
1231 limGetWmeMode(psessionEntry, &wmeMode);
1232
1233 // An Add TS IE is added only if the AP supports it and the requesting
1234 // STA sent a traffic spec.
1235 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1236
1237 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1238
1239 frm.Status.status = statusCode;
1240
1241 frm.AID.associd = aid | LIM_AID_MASK;
1242
1243 if ( NULL == pSta )
1244 {
1245 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1246 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1247 }
1248 else
1249 {
1250 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1251 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1252 }
1253
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1255 {
1256 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1257 {
1258 pAssocReq =
1259 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1261 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1262 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1263 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001264 }
1265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001266
1267 if ( NULL != pSta )
1268 {
1269 if ( eHAL_SET == qosMode )
1270 {
1271 if ( pSta->lleEnabled )
1272 {
1273 lleMode = 1;
1274 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1275 {
1276 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1277
1278// FramesToDo:...
1279// if ( fAddTS )
1280// {
1281// tANI_U8 *pAf = pBody;
1282// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1283// tANI_U32 tlen;
1284// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1285// &tlen, bufLen - frameLen);
1286// } // End if on Add TS.
1287 }
1288 } // End if on .11e enabled in 'pSta'.
1289 } // End if on QOS Mode on.
1290
1291 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1292 {
1293 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1294 {
1295
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001297
1298 if ( pSta->wsmEnabled )
1299 {
1300 PopulateDot11fWMMCaps(&frm.WMMCaps );
1301 }
1302 }
1303 }
1304
1305 if ( pSta->aniPeer )
1306 {
1307 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1308 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1309 {
1310 edcaInclude = 1;
1311 }
1312
1313 } // End if on Airgo peer.
1314
1315 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001316 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001318 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001321
1322#ifdef WLAN_FEATURE_11AC
1323 if( pSta->mlmStaContext.vhtCapability &&
1324 psessionEntry->vhtCapability )
1325 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001326 limLog( pMac, LOGW, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001327 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1328 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001329 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001330 }
1331#endif
1332
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 } // End if on non-NULL 'pSta'.
1334
1335
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301336 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001337
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1339 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1340 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001342
1343 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1344 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1345
1346 beaconParams.bssIdx = psessionEntry->bssIdx;
1347
1348 //Send message to HAL about beacon parameter change.
1349 if(beaconParams.paramChangeBitmap)
1350 {
1351 schSetFixedBeaconFields(pMac,psessionEntry);
1352 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1353 }
1354
1355 // Allocate a buffer for this frame:
1356 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1357 if ( DOT11F_FAILED( nStatus ) )
1358 {
1359 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001360 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 nStatus );
1362 return;
1363 }
1364 else if ( DOT11F_WARNED( nStatus ) )
1365 {
1366 limLog( pMac, LOGW, FL("There were warnings while calculating"
1367 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001368 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001369 }
1370
1371 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1372
1373 if ( pAssocReq != NULL )
1374 {
1375 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1376 &addnIEPresent) != eSIR_SUCCESS)
1377 {
1378 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
1379 return;
1380 }
1381
1382 if (addnIEPresent)
1383 {
1384 //Assoc rsp IE available
1385 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1386 &addnIELen) != eSIR_SUCCESS)
1387 {
1388 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
1389 return;
1390 }
1391
1392 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1393 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1394 {
1395 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1396 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1397 {
1398 nBytes = nBytes + addnIELen;
1399 }
1400 }
1401 }
1402 }
1403
1404 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1405 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1406 ( void** ) &pPacket );
1407 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1408 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001409 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 return;
1411 }
1412
1413 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301414 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001415
1416 // Next, we fill out the buffer descriptor:
1417 nSirStatus = limPopulateMacHeader( pMac,
1418 pFrame,
1419 SIR_MAC_MGMT_FRAME,
1420 ( LIM_ASSOC == subType ) ?
1421 SIR_MAC_MGMT_ASSOC_RSP :
1422 SIR_MAC_MGMT_REASSOC_RSP,
1423 peerMacAddr,psessionEntry->selfMacAddr);
1424 if ( eSIR_SUCCESS != nSirStatus )
1425 {
1426 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001427 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 nSirStatus );
1429 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1430 ( void* ) pFrame, ( void* ) pPacket );
1431 return;
1432 }
1433
1434 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1435
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1437
1438 nStatus = dot11fPackAssocResponse( pMac, &frm,
1439 pFrame + sizeof( tSirMacMgmtHdr ),
1440 nPayload, &nPayload );
1441 if ( DOT11F_FAILED( nStatus ) )
1442 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001443 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 nStatus );
1445 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1446 ( void* ) pFrame, ( void* ) pPacket );
1447 return; // allocated!
1448 }
1449 else if ( DOT11F_WARNED( nStatus ) )
1450 {
1451 limLog( pMac, LOGW, FL("There were warnings while packing an "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001452 "Association Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 }
1454
1455 macAddr = pMacHdr->da;
1456
1457 if (subType == LIM_ASSOC)
1458 {
1459 PELOG1(limLog(pMac, LOG1,
1460 FL("*** Sending Assoc Resp status %d aid %d to "),
1461 statusCode, aid);)
1462 }
1463 else{
1464 PELOG1(limLog(pMac, LOG1,
1465 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1466 statusCode, aid);)
1467 }
1468 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1469
1470 if ( addnIEPresent )
1471 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301472 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 }
1474
1475 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1477 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 )
1479 {
1480 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1481 }
1482
1483 /// Queue Association Response frame in high priority WQ
1484 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1485 HAL_TXRX_FRM_802_11_MGMT,
1486 ANI_TXDIR_TODS,
1487 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1488 limTxComplete, pFrame, txFlag );
1489 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1490 {
1491 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001492 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 nSirStatus);
1494
1495 //Pkt will be freed up by the callback
1496 }
1497
1498 // update the ANI peer station count
1499 //FIXME_PROTECTION : take care of different type of station
1500 // counter inside this function.
1501 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1502
1503} // End limSendAssocRspMgmtFrame.
1504
1505
1506
1507void
1508limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1509 tSirMacAddr peer,
1510 tANI_U16 nStatusCode,
1511 tSirAddtsReqInfo *pAddTS,
1512 tSirMacScheduleIE *pSchedule,
1513 tpPESession psessionEntry)
1514{
1515 tANI_U8 *pFrame;
1516 tpSirMacMgmtHdr pMacHdr;
1517 tDot11fAddTSResponse AddTSRsp;
1518 tDot11fWMMAddTSResponse WMMAddTSRsp;
1519 tSirRetStatus nSirStatus;
1520 tANI_U32 i, nBytes, nPayload, nStatus;
1521 void *pPacket;
1522 eHalStatus halstatus;
1523 tANI_U8 txFlag = 0;
1524
1525 if(NULL == psessionEntry)
1526 {
1527 return;
1528 }
1529
1530 if ( ! pAddTS->wmeTspecPresent )
1531 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301532 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001533
1534 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1535 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1536 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1537 AddTSRsp.Status.status = nStatusCode;
1538
1539 // The TsDelay information element is only filled in for a specific
1540 // status code:
1541 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1542 {
1543 if ( pAddTS->wsmTspecPresent )
1544 {
1545 AddTSRsp.WMMTSDelay.version = 1;
1546 AddTSRsp.WMMTSDelay.delay = 10;
1547 AddTSRsp.WMMTSDelay.present = 1;
1548 }
1549 else
1550 {
1551 AddTSRsp.TSDelay.delay = 10;
1552 AddTSRsp.TSDelay.present = 1;
1553 }
1554 }
1555
1556 if ( pAddTS->wsmTspecPresent )
1557 {
1558 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1559 }
1560 else
1561 {
1562 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1563 }
1564
1565 if ( pAddTS->wsmTspecPresent )
1566 {
1567 AddTSRsp.num_WMMTCLAS = 0;
1568 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1569 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1570 {
1571 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1572 &AddTSRsp.TCLAS[i] );
1573 }
1574 }
1575 else
1576 {
1577 AddTSRsp.num_TCLAS = 0;
1578 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1579 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1580 {
1581 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1582 &AddTSRsp.WMMTCLAS[i] );
1583 }
1584 }
1585
1586 if ( pAddTS->tclasProcPresent )
1587 {
1588 if ( pAddTS->wsmTspecPresent )
1589 {
1590 AddTSRsp.WMMTCLASPROC.version = 1;
1591 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1592 AddTSRsp.WMMTCLASPROC.present = 1;
1593 }
1594 else
1595 {
1596 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1597 AddTSRsp.TCLASSPROC.present = 1;
1598 }
1599 }
1600
1601 // schedule element is included only if requested in the tspec and we are
1602 // using hcca (or both edca and hcca)
1603 // 11e-D8.0 is inconsistent on whether the schedule element is included
1604 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1605 // pg 46, line 17-18 says something else. So just include it and let the
1606 // sta figure it out
1607 if ((pSchedule != NULL) &&
1608 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1609 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1610 {
1611 if ( pAddTS->wsmTspecPresent )
1612 {
1613 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1614 }
1615 else
1616 {
1617 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1618 }
1619 }
1620
1621 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1622 if ( DOT11F_FAILED( nStatus ) )
1623 {
1624 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001625 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 nStatus );
1627 // We'll fall back on the worst case scenario:
1628 nPayload = sizeof( tDot11fAddTSResponse );
1629 }
1630 else if ( DOT11F_WARNED( nStatus ) )
1631 {
1632 limLog( pMac, LOGW, FL("There were warnings while calcula"
1633 "tingthe packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001634 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 }
1636 }
1637 else
1638 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301639 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001640
1641 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1642 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1643 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1644 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1645
1646 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1647
1648 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1649 if ( DOT11F_FAILED( nStatus ) )
1650 {
1651 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001652 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 nStatus );
1654 // We'll fall back on the worst case scenario:
1655 nPayload = sizeof( tDot11fWMMAddTSResponse );
1656 }
1657 else if ( DOT11F_WARNED( nStatus ) )
1658 {
1659 limLog( pMac, LOGW, FL("There were warnings while calcula"
1660 "tingthe packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001661 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 }
1663 }
1664
1665 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1666
1667 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1668 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1669 {
1670 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001671 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 return;
1673 }
1674
1675 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301676 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001677
1678 // Next, we fill out the buffer descriptor:
1679 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1680 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1681 if ( eSIR_SUCCESS != nSirStatus )
1682 {
1683 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001684 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 nSirStatus );
1686 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1687 return; // allocated!
1688 }
1689
1690 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1691
1692
1693 #if 0
1694 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1695 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1696 {
1697 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001698 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1700 return; // allocated!
1701 }
1702 #endif //TO SUPPORT BT-AMP
1703 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1704
Chet Lanctot186b5732013-03-18 10:26:30 -07001705#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001706 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001707#endif
1708
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 // That done, pack the struct:
1710 if ( ! pAddTS->wmeTspecPresent )
1711 {
1712 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1713 pFrame + sizeof( tSirMacMgmtHdr ),
1714 nPayload, &nPayload );
1715 if ( DOT11F_FAILED( nStatus ) )
1716 {
1717 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001718 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 nStatus );
1720 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1721 return;
1722 }
1723 else if ( DOT11F_WARNED( nStatus ) )
1724 {
1725 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001726 "an Add TS Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 }
1728 }
1729 else
1730 {
1731 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1732 pFrame + sizeof( tSirMacMgmtHdr ),
1733 nPayload, &nPayload );
1734 if ( DOT11F_FAILED( nStatus ) )
1735 {
1736 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001737 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 nStatus );
1739 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1740 return;
1741 }
1742 else if ( DOT11F_WARNED( nStatus ) )
1743 {
1744 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001745 "a WMM Add TS Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 }
1747 }
1748
1749 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1750 nStatusCode );
1751 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1752
1753 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1755 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 )
1757 {
1758 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1759 }
1760
1761 // Queue the frame in high priority WQ:
1762 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1763 HAL_TXRX_FRM_802_11_MGMT,
1764 ANI_TXDIR_TODS,
1765 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1766 limTxComplete, pFrame, txFlag );
1767 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1768 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001769 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 nSirStatus );
1771 //Pkt will be freed up by the callback
1772 }
1773
1774} // End limSendAddtsRspActionFrame.
1775
1776void
1777limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1778 tSirMacAddr peer,
1779 tANI_U8 wmmTspecPresent,
1780 tSirMacTSInfo *pTsinfo,
1781 tSirMacTspecIE *pTspecIe,
1782 tpPESession psessionEntry)
1783{
1784 tANI_U8 *pFrame;
1785 tpSirMacMgmtHdr pMacHdr;
1786 tDot11fDelTS DelTS;
1787 tDot11fWMMDelTS WMMDelTS;
1788 tSirRetStatus nSirStatus;
1789 tANI_U32 nBytes, nPayload, nStatus;
1790 void *pPacket;
1791 eHalStatus halstatus;
1792 tANI_U8 txFlag = 0;
1793
1794 if(NULL == psessionEntry)
1795 {
1796 return;
1797 }
1798
1799 if ( ! wmmTspecPresent )
1800 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301801 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001802
1803 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1804 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1805 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1806
1807 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1808 if ( DOT11F_FAILED( nStatus ) )
1809 {
1810 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001811 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 nStatus );
1813 // We'll fall back on the worst case scenario:
1814 nPayload = sizeof( tDot11fDelTS );
1815 }
1816 else if ( DOT11F_WARNED( nStatus ) )
1817 {
1818 limLog( pMac, LOGW, FL("There were warnings while calcula"
1819 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001820 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 }
1822 }
1823 else
1824 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301825 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001826
1827 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1828 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1829 WMMDelTS.DialogToken.token = 0;
1830 WMMDelTS.StatusCode.statusCode = 0;
1831 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1832 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1833 if ( DOT11F_FAILED( nStatus ) )
1834 {
1835 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001836 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 nStatus );
1838 // We'll fall back on the worst case scenario:
1839 nPayload = sizeof( tDot11fDelTS );
1840 }
1841 else if ( DOT11F_WARNED( nStatus ) )
1842 {
1843 limLog( pMac, LOGW, FL("There were warnings while calcula"
1844 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001845 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001846 }
1847 }
1848
1849 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1850
1851 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1852 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1853 {
1854 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001855 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 return;
1857 }
1858
1859 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301860 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001861
1862 // Next, we fill out the buffer descriptor:
1863 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1864 SIR_MAC_MGMT_ACTION, peer,
1865 psessionEntry->selfMacAddr);
1866 if ( eSIR_SUCCESS != nSirStatus )
1867 {
1868 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001869 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 nSirStatus );
1871 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1872 return; // allocated!
1873 }
1874
1875 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1876
1877 #if 0
1878
1879 cfgLen = SIR_MAC_ADDR_LENGTH;
1880 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1881 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1882 {
1883 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001884 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1886 return; // allocated!
1887 }
1888 #endif //TO SUPPORT BT-AMP
1889 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1890
Chet Lanctot186b5732013-03-18 10:26:30 -07001891#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001892 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001893#endif
1894
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 // That done, pack the struct:
1896 if ( !wmmTspecPresent )
1897 {
1898 nStatus = dot11fPackDelTS( pMac, &DelTS,
1899 pFrame + sizeof( tSirMacMgmtHdr ),
1900 nPayload, &nPayload );
1901 if ( DOT11F_FAILED( nStatus ) )
1902 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001903 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 nStatus );
1905 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1906 return; // allocated!
1907 }
1908 else if ( DOT11F_WARNED( nStatus ) )
1909 {
1910 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001911 "a Del TS frame (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 }
1913 }
1914 else
1915 {
1916 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1917 pFrame + sizeof( tSirMacMgmtHdr ),
1918 nPayload, &nPayload );
1919 if ( DOT11F_FAILED( nStatus ) )
1920 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001921 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 nStatus );
1923 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1924 return; // allocated!
1925 }
1926 else if ( DOT11F_WARNED( nStatus ) )
1927 {
1928 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001929 "a WMM Del TS frame (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 }
1931 }
1932
1933 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1934 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1935
1936 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1938 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 )
1940 {
1941 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1942 }
1943
1944 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1945 HAL_TXRX_FRM_802_11_MGMT,
1946 ANI_TXDIR_TODS,
1947 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1948 limTxComplete, pFrame, txFlag );
1949 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1950 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001951 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 nSirStatus );
1953 //Pkt will be freed up by the callback
1954 }
1955
1956} // End limSendDeltsReqActionFrame.
1957
1958void
1959limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1960 tLimMlmAssocReq *pMlmAssocReq,
1961 tpPESession psessionEntry)
1962{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001963 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 tANI_U16 caps;
1965 tANI_U8 *pFrame;
1966 tSirRetStatus nSirStatus;
1967 tLimMlmAssocCnf mlmAssocCnf;
1968 tANI_U32 nBytes, nPayload, nStatus;
1969 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1970 void *pPacket;
1971 eHalStatus halstatus;
1972 tANI_U16 nAddIELen;
1973 tANI_U8 *pAddIE;
1974 tANI_U8 *wpsIe = NULL;
1975#if defined WLAN_FEATURE_VOWIFI
1976 tANI_U8 PowerCapsPopulated = FALSE;
1977#endif
1978 tANI_U8 txFlag = 0;
1979
1980 if(NULL == psessionEntry)
1981 {
1982 return;
1983 }
1984
1985 if(NULL == psessionEntry->pLimJoinReq)
1986 {
1987 return;
1988 }
1989
1990 /* check this early to avoid unncessary operation */
1991 if(NULL == psessionEntry->pLimJoinReq)
1992 {
1993 return;
1994 }
1995 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
1996 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
1997
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301998 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
1999 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002000 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302001 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendAssocReqMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002002 return;
2003 }
2004
2005
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302006 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002007
2008 caps = pMlmAssocReq->capabilityInfo;
2009 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2010 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2011#if defined(FEATURE_WLAN_WAPI)
2012 /* CR: 262463 :
2013 According to WAPI standard:
2014 7.3.1.4 Capability Information field
2015 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2016 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2017 Reassociation management frames. */
2018 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2019 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2020#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002021 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002022
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002023 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2024 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002026 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002027
2028 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2029 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2030
2031 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2032 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2033
2034 // We prefer .11e asociations:
2035 if ( fQosEnabled ) fWmeEnabled = false;
2036
2037 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2038 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2039
2040 if ( psessionEntry->lim11hEnable &&
2041 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2042 {
2043#if defined WLAN_FEATURE_VOWIFI
2044 PowerCapsPopulated = TRUE;
2045
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002046 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002047#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002048 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002049
2050 }
2051
2052#if defined WLAN_FEATURE_VOWIFI
2053 if( pMac->rrm.rrmPEContext.rrmEnable &&
2054 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2055 {
2056 if (PowerCapsPopulated == FALSE)
2057 {
2058 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002059 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 }
2061 }
2062#endif
2063
2064 if ( fQosEnabled &&
2065 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002066 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002067
2068 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002069 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002070
2071#if defined WLAN_FEATURE_VOWIFI
2072 if( pMac->rrm.rrmPEContext.rrmEnable &&
2073 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2074 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002075 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 }
2077#endif
2078 // The join request *should* contain zero or one of the WPA and RSN
2079 // IEs. The payload send along with the request is a
2080 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2081
2082 // typedef struct sSirRSNie
2083 // {
2084 // tANI_U16 length;
2085 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2086 // } tSirRSNie, *tpSirRSNie;
2087
2088 // So, we should be able to make the following two calls harmlessly,
2089 // since they do nothing if they don't find the given IE in the
2090 // bytestream with which they're provided.
2091
2092 // The net effect of this will be to faithfully transmit whatever
2093 // security IE is in the join request.
2094
2095 // *However*, if we're associating for the purpose of WPS
2096 // enrollment, and we've been configured to indicate that by
2097 // eliding the WPA or RSN IE, we just skip this:
2098 if( nAddIELen && pAddIE )
2099 {
2100 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2101 }
2102 if ( NULL == wpsIe )
2103 {
2104 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002105 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002107 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002108#if defined(FEATURE_WLAN_WAPI)
2109 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002110 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002111#endif // defined(FEATURE_WLAN_WAPI)
2112 }
2113
2114 // include WME EDCA IE as well
2115 if ( fWmeEnabled )
2116 {
2117 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2118 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002119 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 }
2121
2122 if ( fWsmEnabled &&
2123 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2124 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002125 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 }
2127 }
2128
2129 //Populate HT IEs, when operating in 11n or Taurus modes AND
2130 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002131 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 pMac->lim.htCapabilityPresentInBeacon)
2133 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002134 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002135#ifdef DISABLE_GF_FOR_INTEROP
2136
2137 /*
2138 * To resolve the interop problem with Broadcom AP,
2139 * where TQ STA could not pass traffic with GF enabled,
2140 * TQ STA will do Greenfield only with TQ AP, for
2141 * everybody else it will be turned off.
2142 */
2143
2144 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2145 {
2146 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002147 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 }
2149#endif
2150
2151 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002152#ifdef WLAN_FEATURE_11AC
2153 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002154 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002155 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002156 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002157 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2158 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002159 }
2160#endif
2161
Jeff Johnson295189b2012-06-20 16:38:30 -07002162
2163#if defined WLAN_FEATURE_VOWIFI_11R
2164 if (psessionEntry->pLimJoinReq->is11Rconnection)
2165 {
2166#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002167 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2169 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2170 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2171#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302172 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2173 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302175 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 {
2177 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302178 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 }
2180#endif
2181
2182#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302183 /* CCX Version IE will be included in association request
2184 when CCX is enabled on DUT through ini */
2185 if (psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
2186 {
2187 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
2188 }
2189 /* For CCX Associations fill the CCX IEs */
2190 if (psessionEntry->isCCXconnection &&
2191 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002193#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002194 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002195#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 }
2197#endif
2198
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002199 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 if ( DOT11F_FAILED( nStatus ) )
2201 {
2202 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002203 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 nStatus );
2205 // We'll fall back on the worst case scenario:
2206 nPayload = sizeof( tDot11fAssocRequest );
2207 }
2208 else if ( DOT11F_WARNED( nStatus ) )
2209 {
2210 limLog( pMac, LOGW, FL("There were warnings while calculating"
2211 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002212 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 }
2214
2215 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2216
2217 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2218 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2219 ( void** ) &pPacket );
2220 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2221 {
2222 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002223 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002224
2225 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002226 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002227
2228
2229 /* Update PE session id*/
2230 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2231
2232 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2233
2234 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2235 ( void* ) pFrame, ( void* ) pPacket );
2236
2237 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2238 ( tANI_U32* ) &mlmAssocCnf);
2239
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302240 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 return;
2242 }
2243
2244 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302245 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002246
2247 // Next, we fill out the buffer descriptor:
2248 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2249 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2250 if ( eSIR_SUCCESS != nSirStatus )
2251 {
2252 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002253 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 nSirStatus );
2255 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302256 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 return;
2258 }
2259
2260
2261 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002262 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 sizeof(tSirMacMgmtHdr),
2264 nPayload, &nPayload );
2265 if ( DOT11F_FAILED( nStatus ) )
2266 {
2267 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002268 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 nStatus );
2270 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2271 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302272 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 return;
2274 }
2275 else if ( DOT11F_WARNED( nStatus ) )
2276 {
2277 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002278 "robe Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 }
2280
2281 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002282 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 nBytes );)
2284 // limPrintMacAddr( pMac, bssid, LOG1 );
2285
2286 if( psessionEntry->assocReq != NULL )
2287 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302288 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 psessionEntry->assocReq = NULL;
2290 }
2291
2292 if( nAddIELen )
2293 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302294 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2295 pAddIE,
2296 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 nPayload += nAddIELen;
2298 }
2299
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302300 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2301 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 {
2303 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2304 }
2305 else
2306 {
2307 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302308 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 psessionEntry->assocReqLen = nPayload;
2310 }
2311
2312 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2314 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 )
2316 {
2317 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2318 }
2319
Ganesh K08bce952012-12-13 15:04:41 -08002320 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2321 {
2322 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2323 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002324
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2326 HAL_TXRX_FRM_802_11_MGMT,
2327 ANI_TXDIR_TODS,
2328 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2329 limTxComplete, pFrame, txFlag );
2330 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2331 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002332 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002333 halstatus );
2334 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302335 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 return;
2337 }
2338
2339 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302340 vos_mem_free(pMlmAssocReq);
2341 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002342 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002343} // End limSendAssocReqMgmtFrame
2344
2345
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002346#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002347/*------------------------------------------------------------------------------------
2348 *
2349 * Send Reassoc Req with FTIEs.
2350 *
2351 *-----------------------------------------------------------------------------------
2352 */
2353void
2354limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2355 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2356{
2357 static tDot11fReAssocRequest frm;
2358 tANI_U16 caps;
2359 tANI_U8 *pFrame;
2360 tSirRetStatus nSirStatus;
2361 tANI_U32 nBytes, nPayload, nStatus;
2362 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2363 void *pPacket;
2364 eHalStatus halstatus;
2365#if defined WLAN_FEATURE_VOWIFI
2366 tANI_U8 PowerCapsPopulated = FALSE;
2367#endif
2368 tANI_U16 ft_ies_length = 0;
2369 tANI_U8 *pBody;
2370 tANI_U16 nAddIELen;
2371 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002372#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 tANI_U8 *wpsIe = NULL;
2374#endif
2375 tANI_U8 txFlag = 0;
2376
2377 if (NULL == psessionEntry)
2378 {
2379 return;
2380 }
2381
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 /* check this early to avoid unncessary operation */
2383 if(NULL == psessionEntry->pLimReAssocReq)
2384 {
2385 return;
2386 }
2387 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2388 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002389 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2390 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002391
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302392 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002393
2394 caps = pMlmReassocReq->capabilityInfo;
2395 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2396 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2397#if defined(FEATURE_WLAN_WAPI)
2398 /* CR: 262463 :
2399 According to WAPI standard:
2400 7.3.1.4 Capability Information field
2401 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2402 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2403 Reassociation management frames. */
2404 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2405 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2406#endif
2407 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2408
2409 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2410
2411 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302412 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2414
2415 PopulateDot11fSSID2( pMac, &frm.SSID );
2416 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2417 &frm.SuppRates,psessionEntry);
2418
2419 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2420 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2421
2422 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2423 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2424
2425 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2426 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2427
2428 if ( psessionEntry->lim11hEnable &&
2429 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2430 {
2431#if defined WLAN_FEATURE_VOWIFI
2432 PowerCapsPopulated = TRUE;
2433
2434 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2435 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2436#endif
2437 }
2438
2439#if defined WLAN_FEATURE_VOWIFI
2440 if( pMac->rrm.rrmPEContext.rrmEnable &&
2441 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2442 {
2443 if (PowerCapsPopulated == FALSE)
2444 {
2445 PowerCapsPopulated = TRUE;
2446 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2447 }
2448 }
2449#endif
2450
2451 if ( fQosEnabled &&
2452 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2453 {
2454 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2455 }
2456
2457 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2458 &frm.ExtSuppRates, psessionEntry );
2459
2460#if defined WLAN_FEATURE_VOWIFI
2461 if( pMac->rrm.rrmPEContext.rrmEnable &&
2462 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2463 {
2464 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2465 }
2466#endif
2467
2468 // Ideally this should be enabled for 11r also. But 11r does
2469 // not follow the usual norm of using the Opaque object
2470 // for rsnie and fties. Instead we just add
2471 // the rsnie and fties at the end of the pack routine for 11r.
2472 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002473#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 //
2475 // The join request *should* contain zero or one of the WPA and RSN
2476 // IEs. The payload send along with the request is a
2477 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2478
2479 // typedef struct sSirRSNie
2480 // {
2481 // tANI_U16 length;
2482 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2483 // } tSirRSNie, *tpSirRSNie;
2484
2485 // So, we should be able to make the following two calls harmlessly,
2486 // since they do nothing if they don't find the given IE in the
2487 // bytestream with which they're provided.
2488
2489 // The net effect of this will be to faithfully transmit whatever
2490 // security IE is in the join request.
2491
2492 // *However*, if we're associating for the purpose of WPS
2493 // enrollment, and we've been configured to indicate that by
2494 // eliding the WPA or RSN IE, we just skip this:
2495 if (!psessionEntry->is11Rconnection)
2496 {
2497 if( nAddIELen && pAddIE )
2498 {
2499 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2500 }
2501 if ( NULL == wpsIe )
2502 {
2503 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2504 &frm.RSNOpaque );
2505 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2506 &frm.WPAOpaque );
2507 }
2508
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002509#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302510 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 {
2512 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2513 &frm.CCXCckmOpaque );
2514 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002515#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 }
2517
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002518#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302519 /* CCX Version IE will be included in reassociation request
2520 when CCX is enabled on DUT through ini */
2521 if (psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
2522 {
2523 PopulateDot11fCCXVersion(&frm.CCXVersion);
2524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302526 if (psessionEntry->isCCXconnection &&
2527 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002529#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002531#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302533#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002534#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002535
2536 // include WME EDCA IE as well
2537 if ( fWmeEnabled )
2538 {
2539 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2540 {
2541 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2542 }
2543
2544 if ( fWsmEnabled &&
2545 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2546 {
2547 PopulateDot11fWMMCaps( &frm.WMMCaps );
2548 }
2549#ifdef FEATURE_WLAN_CCX
2550 if (psessionEntry->isCCXconnection)
2551 {
2552 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2553
2554 // Populate the TSRS IE if TSPEC is included in the reassoc request
2555 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2556 {
2557 tANI_U32 phyMode;
2558 tSirMacCCXTSRSIE tsrsIE;
2559 limGetPhyMode(pMac, &phyMode, psessionEntry);
2560
2561 tsrsIE.tsid = 0;
2562 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2563 {
2564 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2565 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302566 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 {
2568 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2569 }
2570 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2571 }
2572 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302573#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 }
2575
Jeff Johnsone7245742012-09-05 17:12:55 -07002576 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 pMac->lim.htCapabilityPresentInBeacon)
2578 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002579 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 }
2581
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002582#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302583 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2584#if defined FEATURE_WLAN_CCX
2585 && !psessionEntry->isCCXconnection
2586#endif
2587 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002588 {
2589 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2590 }
2591#endif
2592
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2594 if ( DOT11F_FAILED( nStatus ) )
2595 {
2596 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002597 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 nStatus );
2599 // We'll fall back on the worst case scenario:
2600 nPayload = sizeof( tDot11fReAssocRequest );
2601 }
2602 else if ( DOT11F_WARNED( nStatus ) )
2603 {
2604 limLog( pMac, LOGW, FL("There were warnings while calculating"
2605 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002606 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 }
2608
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002609 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002610
2611#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002612 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2614#endif
2615
2616#if defined WLAN_FEATURE_VOWIFI_11R
2617 if (psessionEntry->is11Rconnection)
2618 {
2619 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2620 }
2621#endif
2622
2623 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2624 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2625 ( void** ) &pPacket );
2626 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2627 {
2628 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002629 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002631 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 goto end;
2633 }
2634
2635 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302636 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002637
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002638#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002639 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002640#endif
2641 // Next, we fill out the buffer descriptor:
2642 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2643 SIR_MAC_MGMT_REASSOC_REQ,
2644 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2645 if ( eSIR_SUCCESS != nSirStatus )
2646 {
2647 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002648 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 nSirStatus );
2650 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2651 goto end;
2652 }
2653
2654
2655 // That done, pack the ReAssoc Request:
2656 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2657 sizeof(tSirMacMgmtHdr),
2658 nPayload, &nPayload );
2659 if ( DOT11F_FAILED( nStatus ) )
2660 {
2661 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002662 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 nStatus );
2664 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2665 goto end;
2666 }
2667 else if ( DOT11F_WARNED( nStatus ) )
2668 {
2669 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002670 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 }
2672
2673 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002674 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 nBytes, nPayload );)
2676 if( psessionEntry->assocReq != NULL )
2677 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302678 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 psessionEntry->assocReq = NULL;
2680 }
2681
2682 if( nAddIELen )
2683 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302684 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2685 pAddIE,
2686 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 nPayload += nAddIELen;
2688 }
2689
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302690 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2691 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 {
2693 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002694 }
2695 else
2696 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302698 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002701
2702 if (psessionEntry->is11Rconnection)
2703 {
2704 {
2705 int i = 0;
2706
2707 pBody = pFrame + nBytes;
2708 for (i=0; i<ft_ies_length; i++)
2709 {
2710 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2711 pBody++;
2712 }
2713 }
2714 }
2715
2716#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002717 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2718 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 (tANI_U8 *)pFrame,
2720 (nBytes + ft_ies_length));)
2721#endif
2722
2723
2724 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2726 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 )
2728 {
2729 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2730 }
2731
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002732 if( NULL != psessionEntry->assocReq )
2733 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302734 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002735 psessionEntry->assocReq = NULL;
2736 }
2737
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302738 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2739 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002740 {
2741 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002742 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002743 }
2744 else
2745 {
2746 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302747 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2748 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002749 psessionEntry->assocReqLen = (ft_ies_length);
2750 }
2751
2752
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2754 HAL_TXRX_FRM_802_11_MGMT,
2755 ANI_TXDIR_TODS,
2756 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2757 limTxComplete, pFrame, txFlag );
2758 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2759 {
2760 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002761 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 nSirStatus );
2763 //Pkt will be freed up by the callback
2764 goto end;
2765 }
2766
2767end:
2768 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302769 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 psessionEntry->pLimMlmReassocReq = NULL;
2771
2772}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002773
2774void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2775 tLimMlmReassocReq *pMlmReassocReq,
2776 tpPESession psessionEntry)
2777{
2778 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2779 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2780 if(NULL == pTmpMlmReassocReq)
2781 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302782 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2783 if ( NULL == pTmpMlmReassocReq ) goto end;
2784 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2785 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002786 }
2787
2788 // Prepare and send Reassociation request frame
2789 // start reassoc timer.
2790 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2791 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002792 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002793 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2794 != TX_SUCCESS)
2795 {
2796 // Could not start reassoc failure timer.
2797 // Log error
2798 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002799 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002800 // Return Reassoc confirm with
2801 // Resources Unavailable
2802 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2803 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2804 goto end;
2805 }
2806
2807 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2808 return;
2809
2810end:
2811 // Free up buffer allocated for reassocReq
2812 if (pMlmReassocReq != NULL)
2813 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302814 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002815 pMlmReassocReq = NULL;
2816 }
2817 if (pTmpMlmReassocReq != NULL)
2818 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302819 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002820 pTmpMlmReassocReq = NULL;
2821 }
2822 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2823 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2824 /* Update PE sessio Id*/
2825 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2826
2827 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2828}
2829
Jeff Johnson295189b2012-06-20 16:38:30 -07002830#endif /* WLAN_FEATURE_VOWIFI_11R */
2831
2832
2833void
2834limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2835 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2836{
2837 static tDot11fReAssocRequest frm;
2838 tANI_U16 caps;
2839 tANI_U8 *pFrame;
2840 tSirRetStatus nSirStatus;
2841 tANI_U32 nBytes, nPayload, nStatus;
2842 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2843 void *pPacket;
2844 eHalStatus halstatus;
2845 tANI_U16 nAddIELen;
2846 tANI_U8 *pAddIE;
2847 tANI_U8 *wpsIe = NULL;
2848 tANI_U8 txFlag = 0;
2849#if defined WLAN_FEATURE_VOWIFI
2850 tANI_U8 PowerCapsPopulated = FALSE;
2851#endif
2852
2853 if(NULL == psessionEntry)
2854 {
2855 return;
2856 }
2857
2858 /* check this early to avoid unncessary operation */
2859 if(NULL == psessionEntry->pLimReAssocReq)
2860 {
2861 return;
2862 }
2863 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2864 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2865
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302866 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002867
2868 caps = pMlmReassocReq->capabilityInfo;
2869 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2870 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2871#if defined(FEATURE_WLAN_WAPI)
2872 /* CR: 262463 :
2873 According to WAPI standard:
2874 7.3.1.4 Capability Information field
2875 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2876 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2877 Reassociation management frames. */
2878 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2879 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2880#endif
2881 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2882
2883 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2884
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302885 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2886 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002887
2888 PopulateDot11fSSID2( pMac, &frm.SSID );
2889 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2890 &frm.SuppRates,psessionEntry);
2891
2892 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2893 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2894
2895 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2896 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2897
2898 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2899 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2900
2901
2902 if ( psessionEntry->lim11hEnable &&
2903 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2904 {
2905#if defined WLAN_FEATURE_VOWIFI
2906 PowerCapsPopulated = TRUE;
2907 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2908 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2909#endif
2910 }
2911
2912#if defined WLAN_FEATURE_VOWIFI
2913 if( pMac->rrm.rrmPEContext.rrmEnable &&
2914 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2915 {
2916 if (PowerCapsPopulated == FALSE)
2917 {
2918 PowerCapsPopulated = TRUE;
2919 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2920 }
2921 }
2922#endif
2923
2924 if ( fQosEnabled &&
2925 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2926 {
2927 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2928 }
2929
2930 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2931 &frm.ExtSuppRates, psessionEntry );
2932
2933#if defined WLAN_FEATURE_VOWIFI
2934 if( pMac->rrm.rrmPEContext.rrmEnable &&
2935 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2936 {
2937 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2938 }
2939#endif
2940 // The join request *should* contain zero or one of the WPA and RSN
2941 // IEs. The payload send along with the request is a
2942 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2943
2944 // typedef struct sSirRSNie
2945 // {
2946 // tANI_U16 length;
2947 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2948 // } tSirRSNie, *tpSirRSNie;
2949
2950 // So, we should be able to make the following two calls harmlessly,
2951 // since they do nothing if they don't find the given IE in the
2952 // bytestream with which they're provided.
2953
2954 // The net effect of this will be to faithfully transmit whatever
2955 // security IE is in the join request.
2956
2957 // *However*, if we're associating for the purpose of WPS
2958 // enrollment, and we've been configured to indicate that by
2959 // eliding the WPA or RSN IE, we just skip this:
2960 if( nAddIELen && pAddIE )
2961 {
2962 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2963 }
2964 if ( NULL == wpsIe )
2965 {
2966 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2967 &frm.RSNOpaque );
2968 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2969 &frm.WPAOpaque );
2970#if defined(FEATURE_WLAN_WAPI)
2971 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2972 &frm.WAPIOpaque );
2973#endif // defined(FEATURE_WLAN_WAPI)
2974 }
2975
2976 // include WME EDCA IE as well
2977 if ( fWmeEnabled )
2978 {
2979 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2980 {
2981 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2982 }
2983
2984 if ( fWsmEnabled &&
2985 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2986 {
2987 PopulateDot11fWMMCaps( &frm.WMMCaps );
2988 }
2989 }
2990
Jeff Johnsone7245742012-09-05 17:12:55 -07002991 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 pMac->lim.htCapabilityPresentInBeacon)
2993 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002994 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002996#ifdef WLAN_FEATURE_11AC
2997 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002998 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002999 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003000 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003001 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07003002 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003003 }
3004#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003005
3006 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3007 if ( DOT11F_FAILED( nStatus ) )
3008 {
3009 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003010 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 nStatus );
3012 // We'll fall back on the worst case scenario:
3013 nPayload = sizeof( tDot11fReAssocRequest );
3014 }
3015 else if ( DOT11F_WARNED( nStatus ) )
3016 {
3017 limLog( pMac, LOGW, FL("There were warnings while calculating"
3018 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003019 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 }
3021
3022 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3023
3024 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3025 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3026 ( void** ) &pPacket );
3027 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3028 {
3029 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003030 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003032 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 goto end;
3034 }
3035
3036 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303037 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003038
3039 // Next, we fill out the buffer descriptor:
3040 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3041 SIR_MAC_MGMT_REASSOC_REQ,
3042 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3043 if ( eSIR_SUCCESS != nSirStatus )
3044 {
3045 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003046 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 nSirStatus );
3048 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3049 goto end;
3050 }
3051
3052
3053 // That done, pack the Probe Request:
3054 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3055 sizeof(tSirMacMgmtHdr),
3056 nPayload, &nPayload );
3057 if ( DOT11F_FAILED( nStatus ) )
3058 {
3059 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003060 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 nStatus );
3062 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3063 goto end;
3064 }
3065 else if ( DOT11F_WARNED( nStatus ) )
3066 {
3067 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003068 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 }
3070
3071 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003072 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 nBytes );)
3074
3075 if( psessionEntry->assocReq != NULL )
3076 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303077 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 psessionEntry->assocReq = NULL;
3079 }
3080
3081 if( nAddIELen )
3082 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303083 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3084 pAddIE,
3085 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 nPayload += nAddIELen;
3087 }
3088
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303089 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3090 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 {
3092 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003093 }
3094 else
3095 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303097 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003100
3101 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3103 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 )
3105 {
3106 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3107 }
3108
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003109 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003110 {
3111 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3112 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003113
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3115 HAL_TXRX_FRM_802_11_MGMT,
3116 ANI_TXDIR_TODS,
3117 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3118 limTxComplete, pFrame, txFlag );
3119 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3120 {
3121 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003122 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 nSirStatus );
3124 //Pkt will be freed up by the callback
3125 goto end;
3126 }
3127
3128end:
3129 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303130 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 psessionEntry->pLimMlmReassocReq = NULL;
3132
3133} // limSendReassocReqMgmtFrame
3134
3135/**
3136 * \brief Send an Authentication frame
3137 *
3138 *
3139 * \param pMac Pointer to Global MAC structure
3140 *
3141 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3142 * to be sent
3143 *
3144 * \param peerMacAddr MAC address of the peer entity to which Authentication
3145 * frame is destined
3146 *
3147 * \param wepBit Indicates whether wep bit to be set in FC while sending
3148 * Authentication frame3
3149 *
3150 *
3151 * This function is called by limProcessMlmMessages(). Authentication frame
3152 * is formatted and sent when this function is called.
3153 *
3154 *
3155 */
3156
3157void
3158limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3159 tpSirMacAuthFrameBody pAuthFrameBody,
3160 tSirMacAddr peerMacAddr,
3161 tANI_U8 wepBit,
3162 tpPESession psessionEntry
3163 )
3164{
3165 tANI_U8 *pFrame, *pBody;
3166 tANI_U32 frameLen = 0, bodyLen = 0;
3167 tpSirMacMgmtHdr pMacHdr;
3168 tANI_U16 i;
3169 void *pPacket;
3170 eHalStatus halstatus;
3171 tANI_U8 txFlag = 0;
3172
3173 if(NULL == psessionEntry)
3174 {
3175 return;
3176 }
3177
3178 if (wepBit == LIM_WEP_IN_FC)
3179 {
3180 /// Auth frame3 to be sent with encrypted framebody
3181 /**
3182 * Allocate buffer for Authenticaton frame of size equal
3183 * to management frame header length plus 2 bytes each for
3184 * auth algorithm number, transaction number, status code,
3185 * 128 bytes for challenge text and 4 bytes each for
3186 * IV & ICV.
3187 */
3188
3189 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3190
3191 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3192 } // if (wepBit == LIM_WEP_IN_FC)
3193 else
3194 {
3195 switch (pAuthFrameBody->authTransactionSeqNumber)
3196 {
3197 case SIR_MAC_AUTH_FRAME_1:
3198 /**
3199 * Allocate buffer for Authenticaton frame of size
3200 * equal to management frame header length plus 2 bytes
3201 * each for auth algorithm number, transaction number
3202 * and status code.
3203 */
3204
3205 frameLen = sizeof(tSirMacMgmtHdr) +
3206 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3207 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3208
3209#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003210 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3211 {
3212 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003214 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003215 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003216 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003218 else
3219 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003220 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003221 frameLen += (2+SIR_MDIE_SIZE);
3222 }
3223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003224#endif
3225 break;
3226
3227 case SIR_MAC_AUTH_FRAME_2:
3228 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3229 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3230 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3231 {
3232 /**
3233 * Allocate buffer for Authenticaton frame of size
3234 * equal to management frame header length plus
3235 * 2 bytes each for auth algorithm number,
3236 * transaction number and status code.
3237 */
3238
3239 frameLen = sizeof(tSirMacMgmtHdr) +
3240 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3241 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3242 }
3243 else
3244 {
3245 // Shared Key algorithm with challenge text
3246 // to be sent
3247 /**
3248 * Allocate buffer for Authenticaton frame of size
3249 * equal to management frame header length plus
3250 * 2 bytes each for auth algorithm number,
3251 * transaction number, status code and 128 bytes
3252 * for challenge text.
3253 */
3254
3255 frameLen = sizeof(tSirMacMgmtHdr) +
3256 sizeof(tSirMacAuthFrame);
3257 bodyLen = sizeof(tSirMacAuthFrameBody);
3258 }
3259
3260 break;
3261
3262 case SIR_MAC_AUTH_FRAME_3:
3263 /// Auth frame3 to be sent without encrypted framebody
3264 /**
3265 * Allocate buffer for Authenticaton frame of size equal
3266 * to management frame header length plus 2 bytes each
3267 * for auth algorithm number, transaction number and
3268 * status code.
3269 */
3270
3271 frameLen = sizeof(tSirMacMgmtHdr) +
3272 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3273 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3274
3275 break;
3276
3277 case SIR_MAC_AUTH_FRAME_4:
3278 /**
3279 * Allocate buffer for Authenticaton frame of size equal
3280 * to management frame header length plus 2 bytes each
3281 * for auth algorithm number, transaction number and
3282 * status code.
3283 */
3284
3285 frameLen = sizeof(tSirMacMgmtHdr) +
3286 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3287 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3288
3289 break;
3290 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3291 } // end if (wepBit == LIM_WEP_IN_FC)
3292
3293
3294 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3295
3296 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3297 {
3298 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003299 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003300
3301 return;
3302 }
3303
3304 for (i = 0; i < frameLen; i++)
3305 pFrame[i] = 0;
3306
3307 // Prepare BD
3308 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3309 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3310 {
3311 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3312 return;
3313 }
3314
3315 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3316 pMacHdr->fc.wep = wepBit;
3317
3318 // Prepare BSSId
3319 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3320 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303321 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3322 (tANI_U8 *) psessionEntry->bssId,
3323 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 }
3325
3326 /// Prepare Authentication frame body
3327 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3328
3329 if (wepBit == LIM_WEP_IN_FC)
3330 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303331 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003332
3333 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003334 FL("*** Sending Auth seq# 3 status %d (%d) to"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 pAuthFrameBody->authStatusCode,
3336 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3337
3338 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3339 }
3340 else
3341 {
3342 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3343 pBody += sizeof(tANI_U16);
3344 bodyLen -= sizeof(tANI_U16);
3345
3346 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3347 pBody += sizeof(tANI_U16);
3348 bodyLen -= sizeof(tANI_U16);
3349
3350 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3351 pBody += sizeof(tANI_U16);
3352 bodyLen -= sizeof(tANI_U16);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07003353 if ( bodyLen < sizeof (pAuthFrameBody->type) + sizeof (pAuthFrameBody->length) + sizeof (pAuthFrameBody->challengeText))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303354 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003355
3356#if defined WLAN_FEATURE_VOWIFI_11R
3357 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3358 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3359 {
3360
3361 {
3362 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3364 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003365#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3367 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3368 (tANI_U8 *)pBody,
3369 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003370#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003371 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3372 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003373 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3374 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003375 }
3376 }
3377 else
3378 {
3379 /* MDID attr is 54*/
3380 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003382 *pBody = SIR_MDIE_SIZE;
3383 pBody++;
3384 for(i=0;i<SIR_MDIE_SIZE;i++)
3385 {
3386 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3387 pBody++;
3388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 }
3390 }
3391 }
3392#endif
3393
3394 PELOG1(limLog(pMac, LOG1,
3395 FL("*** Sending Auth seq# %d status %d (%d) to "),
3396 pAuthFrameBody->authTransactionSeqNumber,
3397 pAuthFrameBody->authStatusCode,
3398 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3399
3400 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3401 }
3402 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3403
3404 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3406 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003407#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303408 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003409 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3410#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 )
3412 {
3413 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3414 }
3415
Ganesh K08bce952012-12-13 15:04:41 -08003416 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3417 {
3418 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3419 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003420
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 /// Queue Authentication frame in high priority WQ
3422 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3423 HAL_TXRX_FRM_802_11_MGMT,
3424 ANI_TXDIR_TODS,
3425 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3426 limTxComplete, pFrame, txFlag );
3427 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3428 {
3429 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003430 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 halstatus);
3432
3433 //Pkt will be freed up by the callback
3434 }
3435
3436 return;
3437} /*** end limSendAuthMgmtFrame() ***/
3438
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003439eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3440{
3441 tANI_U16 aid;
3442 tpDphHashNode pStaDs;
3443 tLimMlmDeauthReq *pMlmDeauthReq;
3444 tLimMlmDeauthCnf mlmDeauthCnf;
3445 tpPESession psessionEntry;
3446
3447 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3448 if (pMlmDeauthReq)
3449 {
3450 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3451 {
3452 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3453 }
3454
3455 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3456 {
3457
3458 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003459 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003460 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3461 goto end;
3462 }
3463
3464 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3465 if (pStaDs == NULL)
3466 {
3467 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3468 goto end;
3469 }
3470
3471
3472 /// Receive path cleanup with dummy packet
3473 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3474 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303475 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003476 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3477 }
3478 return eHAL_STATUS_SUCCESS;
3479end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303480 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003481 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3482 sizeof(tSirMacAddr));
3483 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3484 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3485 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3486
3487 // Free up buffer allocated
3488 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303489 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003490
3491 limPostSmeMessage(pMac,
3492 LIM_MLM_DEAUTH_CNF,
3493 (tANI_U32 *) &mlmDeauthCnf);
3494 return eHAL_STATUS_SUCCESS;
3495}
3496
3497eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3498{
3499 tANI_U16 aid;
3500 tpDphHashNode pStaDs;
3501 tLimMlmDisassocCnf mlmDisassocCnf;
3502 tpPESession psessionEntry;
3503 tLimMlmDisassocReq *pMlmDisassocReq;
3504
3505 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3506 if (pMlmDisassocReq)
3507 {
3508 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3509 {
3510 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3511 }
3512
3513 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3514 {
3515
3516 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003517 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003518 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3519 goto end;
3520 }
3521
3522 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3523 if (pStaDs == NULL)
3524 {
3525 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3526 goto end;
3527 }
3528
3529 /// Receive path cleanup with dummy packet
3530 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3531 {
3532 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3533 goto end;
3534 }
3535
3536#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003537 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303538 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003539#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303540 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003541#endif
3542#ifdef FEATURE_WLAN_LFR
3543 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003544#endif
3545 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303546 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003547 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003548 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303549 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003550 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003551 psessionEntry, psessionEntry->peSessionId););
3552 limFTCleanup(pMac);
3553 }
3554 else
3555 {
3556 PELOGE(limLog(pMac, LOGE,
3557 FL("No FT Preauth Session Cleanup in role %d"
3558#ifdef FEATURE_WLAN_CCX
3559 " isCCX %d"
3560#endif
3561#ifdef FEATURE_WLAN_LFR
3562 " isLFR %d"
3563#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003564 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003565 psessionEntry->limSystemRole,
3566#ifdef FEATURE_WLAN_CCX
3567 psessionEntry->isCCXconnection,
3568#endif
3569#ifdef FEATURE_WLAN_LFR
3570 psessionEntry->isFastRoamIniFeatureEnabled,
3571#endif
3572 psessionEntry->is11Rconnection,
3573 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003574 }
3575#endif
3576
3577 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303578 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003579 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3580 return eHAL_STATUS_SUCCESS;
3581 }
3582 else
3583 {
3584 return eHAL_STATUS_SUCCESS;
3585 }
3586end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303587 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003588 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3589 sizeof(tSirMacAddr));
3590 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3591 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3592
3593 /* Update PE session ID*/
3594 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3595
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003596 if(pMlmDisassocReq != NULL)
3597 {
3598 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303599 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003600 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3601 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003602
3603 limPostSmeMessage(pMac,
3604 LIM_MLM_DISASSOC_CNF,
3605 (tANI_U32 *) &mlmDisassocCnf);
3606 return eHAL_STATUS_SUCCESS;
3607}
3608
3609eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3610{
3611 return limSendDisassocCnf(pMac);
3612}
3613
3614eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3615{
3616 return limSendDeauthCnf(pMac);
3617}
3618
Jeff Johnson295189b2012-06-20 16:38:30 -07003619/**
3620 * \brief This function is called to send Disassociate frame.
3621 *
3622 *
3623 * \param pMac Pointer to Global MAC structure
3624 *
3625 * \param nReason Indicates the reason that need to be sent in
3626 * Disassociation frame
3627 *
3628 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3629 * sent
3630 *
3631 *
3632 */
3633
3634void
3635limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3636 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003637 tSirMacAddr peer,
3638 tpPESession psessionEntry,
3639 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003640{
3641 tDot11fDisassociation frm;
3642 tANI_U8 *pFrame;
3643 tSirRetStatus nSirStatus;
3644 tpSirMacMgmtHdr pMacHdr;
3645 tANI_U32 nBytes, nPayload, nStatus;
3646 void *pPacket;
3647 eHalStatus halstatus;
3648 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003649 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 if(NULL == psessionEntry)
3651 {
3652 return;
3653 }
3654
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303655 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003656
3657 frm.Reason.code = nReason;
3658
3659 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3660 if ( DOT11F_FAILED( nStatus ) )
3661 {
3662 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003663 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 nStatus );
3665 // We'll fall back on the worst case scenario:
3666 nPayload = sizeof( tDot11fDisassociation );
3667 }
3668 else if ( DOT11F_WARNED( nStatus ) )
3669 {
3670 limLog( pMac, LOGW, FL("There were warnings while calculating"
3671 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003672 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003673 }
3674
3675 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3676
3677 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3678 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3679 ( void** ) &pPacket );
3680 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3681 {
3682 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003683 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 return;
3685 }
3686
3687 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303688 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003689
3690 // Next, we fill out the buffer descriptor:
3691 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3692 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3693 if ( eSIR_SUCCESS != nSirStatus )
3694 {
3695 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003696 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 nSirStatus );
3698 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3699 ( void* ) pFrame, ( void* ) pPacket );
3700 return; // just allocated...
3701 }
3702
3703 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3704
3705 // Prepare the BSSID
3706 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3707
Chet Lanctot186b5732013-03-18 10:26:30 -07003708#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003709 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003710#endif
3711
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3713 sizeof(tSirMacMgmtHdr),
3714 nPayload, &nPayload );
3715 if ( DOT11F_FAILED( nStatus ) )
3716 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003717 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 nStatus );
3719 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3720 ( void* ) pFrame, ( void* ) pPacket );
3721 return; // allocated!
3722 }
3723 else if ( DOT11F_WARNED( nStatus ) )
3724 {
3725 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003726 "isassociation (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 }
3728
3729 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003730 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3732
3733 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3735 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 )
3737 {
3738 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3739 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003740
Ganesh K08bce952012-12-13 15:04:41 -08003741 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3742 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3743 {
3744 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3745 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003746
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003747 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003749 // Queue Disassociation frame in high priority WQ
3750 /* get the duration from the request */
3751 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3752 HAL_TXRX_FRM_802_11_MGMT,
3753 ANI_TXDIR_TODS,
3754 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3755 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3756 txFlag );
3757 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003758
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003759 if (tx_timer_change(
3760 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3761 != TX_SUCCESS)
3762 {
3763 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003764 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003765 return;
3766 }
3767 else if(TX_SUCCESS != tx_timer_activate(
3768 &pMac->lim.limTimers.gLimDisassocAckTimer))
3769 {
3770 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003771 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003772 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3773 return;
3774 }
3775 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003776 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003777 {
3778 // Queue Disassociation frame in high priority WQ
3779 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3780 HAL_TXRX_FRM_802_11_MGMT,
3781 ANI_TXDIR_TODS,
3782 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3783 limTxComplete, pFrame, txFlag );
3784 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3785 {
3786 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003787 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003788 nSirStatus );
3789 //Pkt will be freed up by the callback
3790 return;
3791 }
3792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003793} // End limSendDisassocMgmtFrame.
3794
3795/**
3796 * \brief This function is called to send a Deauthenticate frame
3797 *
3798 *
3799 * \param pMac Pointer to global MAC structure
3800 *
3801 * \param nReason Indicates the reason that need to be sent in the
3802 * Deauthenticate frame
3803 *
3804 * \param peeer address of the STA to which the frame is to be sent
3805 *
3806 *
3807 */
3808
3809void
3810limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3811 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003812 tSirMacAddr peer,
3813 tpPESession psessionEntry,
3814 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003815{
3816 tDot11fDeAuth frm;
3817 tANI_U8 *pFrame;
3818 tSirRetStatus nSirStatus;
3819 tpSirMacMgmtHdr pMacHdr;
3820 tANI_U32 nBytes, nPayload, nStatus;
3821 void *pPacket;
3822 eHalStatus halstatus;
3823 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003824 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003825#ifdef FEATURE_WLAN_TDLS
3826 tANI_U16 aid;
3827 tpDphHashNode pStaDs;
3828#endif
3829
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 if(NULL == psessionEntry)
3831 {
3832 return;
3833 }
3834
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303835 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003836
3837 frm.Reason.code = nReason;
3838
3839 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3840 if ( DOT11F_FAILED( nStatus ) )
3841 {
3842 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003843 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 nStatus );
3845 // We'll fall back on the worst case scenario:
3846 nPayload = sizeof( tDot11fDeAuth );
3847 }
3848 else if ( DOT11F_WARNED( nStatus ) )
3849 {
3850 limLog( pMac, LOGW, FL("There were warnings while calculating"
3851 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003852 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 }
3854
3855 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3856
3857 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3858 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3859 ( void** ) &pPacket );
3860 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3861 {
3862 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003863 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 return;
3865 }
3866
3867 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303868 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003869
3870 // Next, we fill out the buffer descriptor:
3871 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3872 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3873 if ( eSIR_SUCCESS != nSirStatus )
3874 {
3875 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003876 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 nSirStatus );
3878 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3879 ( void* ) pFrame, ( void* ) pPacket );
3880 return; // just allocated...
3881 }
3882
3883 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3884
3885 // Prepare the BSSID
3886 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3887
Chet Lanctot186b5732013-03-18 10:26:30 -07003888#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003889 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003890#endif
3891
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3893 sizeof(tSirMacMgmtHdr),
3894 nPayload, &nPayload );
3895 if ( DOT11F_FAILED( nStatus ) )
3896 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003897 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 nStatus );
3899 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3900 ( void* ) pFrame, ( void* ) pPacket );
3901 return;
3902 }
3903 else if ( DOT11F_WARNED( nStatus ) )
3904 {
3905 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003906 "e-Authentication (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 }
3908
3909 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003910 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3912
3913 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3915 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 )
3917 {
3918 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3919 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003920
Ganesh K08bce952012-12-13 15:04:41 -08003921 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3922 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3923 {
3924 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3925 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003926
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003927#ifdef FEATURE_WLAN_TDLS
3928 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3929#endif
3930
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003931 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003933 // Queue Disassociation frame in high priority WQ
3934 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3935 HAL_TXRX_FRM_802_11_MGMT,
3936 ANI_TXDIR_TODS,
3937 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3938 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
3939 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3940 {
3941 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003942 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003943 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003944 //Pkt will be freed up by the callback limTxComplete
3945
3946 /*Call limProcessDeauthAckTimeout which will send
3947 * DeauthCnf for this frame
3948 */
3949 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003950 return;
3951 }
3952
3953 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3954
3955 if (tx_timer_change(
3956 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3957 != TX_SUCCESS)
3958 {
3959 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003960 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003961 return;
3962 }
3963 else if(TX_SUCCESS != tx_timer_activate(
3964 &pMac->lim.limTimers.gLimDeauthAckTimer))
3965 {
3966 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003967 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003968 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3969 return;
3970 }
3971 }
3972 else
3973 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003974#ifdef FEATURE_WLAN_TDLS
3975 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
3976 {
3977 // Queue Disassociation frame in high priority WQ
3978 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003979 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003980 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003981 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3982 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003983 }
3984 else
3985 {
3986#endif
3987 // Queue Disassociation frame in high priority WQ
3988 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3989 HAL_TXRX_FRM_802_11_MGMT,
3990 ANI_TXDIR_TODS,
3991 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3992 limTxComplete, pFrame, txFlag );
3993#ifdef FEATURE_WLAN_TDLS
3994 }
3995#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003996 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3997 {
3998 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003999 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004000 nSirStatus );
4001 //Pkt will be freed up by the callback
4002 return;
4003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 }
4005
4006} // End limSendDeauthMgmtFrame.
4007
4008
4009#ifdef ANI_SUPPORT_11H
4010/**
4011 * \brief Send a Measurement Report Action frame
4012 *
4013 *
4014 * \param pMac Pointer to the global MAC structure
4015 *
4016 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4017 *
4018 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4019 *
4020 *
4021 */
4022
4023tSirRetStatus
4024limSendMeasReportFrame(tpAniSirGlobal pMac,
4025 tpSirMacMeasReqActionFrame pMeasReqFrame,
4026 tSirMacAddr peer)
4027{
4028 tDot11fMeasurementReport frm;
4029 tANI_U8 *pFrame;
4030 tSirRetStatus nSirStatus;
4031 tpSirMacMgmtHdr pMacHdr;
4032 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4033 void *pPacket;
4034 eHalStatus halstatus;
4035
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304036 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004037
4038 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4039 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4040 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4041
4042 switch ( pMeasReqFrame->measReqIE.measType )
4043 {
4044 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4045 nSirStatus =
4046 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4047 &frm.MeasurementReport );
4048 break;
4049 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4050 nSirStatus =
4051 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4052 &frm.MeasurementReport );
4053 break;
4054 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4055 nSirStatus =
4056 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4057 &frm.MeasurementReport );
4058 break;
4059 default:
4060 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004061 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 pMeasReqFrame->measReqIE.measType );
4063 return eSIR_FAILURE;
4064 }
4065
4066 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4067
4068 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4069 if ( DOT11F_FAILED( nStatus ) )
4070 {
4071 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004072 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 nStatus );
4074 // We'll fall back on the worst case scenario:
4075 nPayload = sizeof( tDot11fMeasurementReport );
4076 }
4077 else if ( DOT11F_WARNED( nStatus ) )
4078 {
4079 limLog( pMac, LOGW, FL("There were warnings while calculating"
4080 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004081 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 }
4083
4084 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4085
4086 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4087 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4088 {
4089 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004090 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 return eSIR_FAILURE;
4092 }
4093
4094 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304095 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004096
4097 // Next, we fill out the buffer descriptor:
4098 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4099 SIR_MAC_MGMT_ACTION, peer);
4100 if ( eSIR_SUCCESS != nSirStatus )
4101 {
4102 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004103 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 nSirStatus );
4105 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4106 return eSIR_FAILURE; // just allocated...
4107 }
4108
4109 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4110
4111 nCfg = 6;
4112 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4113 if ( eSIR_SUCCESS != nSirStatus )
4114 {
4115 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004116 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 nSirStatus );
4118 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4119 return eSIR_FAILURE; // just allocated...
4120 }
4121
Chet Lanctot186b5732013-03-18 10:26:30 -07004122#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004123 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004124#endif
4125
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4127 sizeof(tSirMacMgmtHdr),
4128 nPayload, &nPayload );
4129 if ( DOT11F_FAILED( nStatus ) )
4130 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004131 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 nStatus );
4133 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4134 return eSIR_FAILURE; // allocated!
4135 }
4136 else if ( DOT11F_WARNED( nStatus ) )
4137 {
4138 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004139 "easurement Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 }
4141
4142 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4143 HAL_TXRX_FRM_802_11_MGMT,
4144 ANI_TXDIR_TODS,
4145 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4146 limTxComplete, pFrame, 0 );
4147 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4148 {
4149 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004150 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 nSirStatus );
4152 //Pkt will be freed up by the callback
4153 return eSIR_FAILURE; // just allocated...
4154 }
4155
4156 return eSIR_SUCCESS;
4157
4158} // End limSendMeasReportFrame.
4159
4160
4161/**
4162 * \brief Send a TPC Request Action frame
4163 *
4164 *
4165 * \param pMac Pointer to the global MAC datastructure
4166 *
4167 * \param peer MAC address to which the frame should be sent
4168 *
4169 *
4170 */
4171
4172void
4173limSendTpcRequestFrame(tpAniSirGlobal pMac,
4174 tSirMacAddr peer)
4175{
4176 tDot11fTPCRequest frm;
4177 tANI_U8 *pFrame;
4178 tSirRetStatus nSirStatus;
4179 tpSirMacMgmtHdr pMacHdr;
4180 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4181 void *pPacket;
4182 eHalStatus halstatus;
4183
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304184 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004185
4186 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4187 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4188 frm.DialogToken.token = 1;
4189 frm.TPCRequest.present = 1;
4190
4191 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4192 if ( DOT11F_FAILED( nStatus ) )
4193 {
4194 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004195 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 nStatus );
4197 // We'll fall back on the worst case scenario:
4198 nPayload = sizeof( tDot11fTPCRequest );
4199 }
4200 else if ( DOT11F_WARNED( nStatus ) )
4201 {
4202 limLog( pMac, LOGW, FL("There were warnings while calculating"
4203 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004204 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 }
4206
4207 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4208
4209 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4210 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4211 {
4212 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004213 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 return;
4215 }
4216
4217 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304218 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004219
4220 // Next, we fill out the buffer descriptor:
4221 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4222 SIR_MAC_MGMT_ACTION, peer);
4223 if ( eSIR_SUCCESS != nSirStatus )
4224 {
4225 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004226 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 nSirStatus );
4228 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4229 return; // just allocated...
4230 }
4231
4232 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4233
4234 nCfg = 6;
4235 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4236 if ( eSIR_SUCCESS != nSirStatus )
4237 {
4238 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004239 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 nSirStatus );
4241 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4242 return; // just allocated...
4243 }
4244
Chet Lanctot186b5732013-03-18 10:26:30 -07004245#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004246 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004247#endif
4248
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4250 sizeof(tSirMacMgmtHdr),
4251 nPayload, &nPayload );
4252 if ( DOT11F_FAILED( nStatus ) )
4253 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004254 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 nStatus );
4256 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4257 return; // allocated!
4258 }
4259 else if ( DOT11F_WARNED( nStatus ) )
4260 {
4261 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004262 "PC Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 }
4264
4265 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4266 HAL_TXRX_FRM_802_11_MGMT,
4267 ANI_TXDIR_TODS,
4268 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4269 limTxComplete, pFrame, 0 );
4270 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4271 {
4272 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004273 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 nSirStatus );
4275 //Pkt will be freed up by the callback
4276 return;
4277 }
4278
4279} // End limSendTpcRequestFrame.
4280
4281
4282/**
4283 * \brief Send a TPC Report Action frame
4284 *
4285 *
4286 * \param pMac Pointer to the global MAC datastructure
4287 *
4288 * \param pTpcReqFrame Pointer to the received TPC Request
4289 *
4290 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4291 *
4292 *
4293 */
4294
4295tSirRetStatus
4296limSendTpcReportFrame(tpAniSirGlobal pMac,
4297 tpSirMacTpcReqActionFrame pTpcReqFrame,
4298 tSirMacAddr peer)
4299{
4300 tDot11fTPCReport frm;
4301 tANI_U8 *pFrame;
4302 tSirRetStatus nSirStatus;
4303 tpSirMacMgmtHdr pMacHdr;
4304 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4305 void *pPacket;
4306 eHalStatus halstatus;
4307
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304308 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004309
4310 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4311 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4312 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4313
4314 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4315 // "misplaced this function, need to replace:
4316 // txPower = halGetRateToPwrValue(pMac, staid,
4317 // pMac->lim.gLimCurrentChannelId, 0);
4318 frm.TPCReport.tx_power = 0;
4319 frm.TPCReport.link_margin = 0;
4320 frm.TPCReport.present = 1;
4321
4322 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4323 if ( DOT11F_FAILED( nStatus ) )
4324 {
4325 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004326 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 nStatus );
4328 // We'll fall back on the worst case scenario:
4329 nPayload = sizeof( tDot11fTPCReport );
4330 }
4331 else if ( DOT11F_WARNED( nStatus ) )
4332 {
4333 limLog( pMac, LOGW, FL("There were warnings while calculating"
4334 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004335 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 }
4337
4338 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4339
4340 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4341 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4342 {
4343 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004344 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 return eSIR_FAILURE;
4346 }
4347
4348 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304349 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004350
4351 // Next, we fill out the buffer descriptor:
4352 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4353 SIR_MAC_MGMT_ACTION, peer);
4354 if ( eSIR_SUCCESS != nSirStatus )
4355 {
4356 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004357 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 nSirStatus );
4359 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4360 return eSIR_FAILURE; // just allocated...
4361 }
4362
4363 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4364
4365 nCfg = 6;
4366 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4367 if ( eSIR_SUCCESS != nSirStatus )
4368 {
4369 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004370 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 nSirStatus );
4372 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4373 return eSIR_FAILURE; // just allocated...
4374 }
4375
Chet Lanctot186b5732013-03-18 10:26:30 -07004376#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004377 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004378#endif
4379
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4381 sizeof(tSirMacMgmtHdr),
4382 nPayload, &nPayload );
4383 if ( DOT11F_FAILED( nStatus ) )
4384 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004385 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 nStatus );
4387 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4388 return eSIR_FAILURE; // allocated!
4389 }
4390 else if ( DOT11F_WARNED( nStatus ) )
4391 {
4392 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004393 "PC Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 }
4395
4396
4397 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4398 HAL_TXRX_FRM_802_11_MGMT,
4399 ANI_TXDIR_TODS,
4400 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4401 limTxComplete, pFrame, 0 );
4402 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4403 {
4404 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004405 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 nSirStatus );
4407 //Pkt will be freed up by the callback
4408 return eSIR_FAILURE; // just allocated...
4409 }
4410
4411 return eSIR_SUCCESS;
4412
4413} // End limSendTpcReportFrame.
4414#endif //ANI_SUPPORT_11H
4415
4416
Jeff Johnson295189b2012-06-20 16:38:30 -07004417/**
4418 * \brief Send a Channel Switch Announcement
4419 *
4420 *
4421 * \param pMac Pointer to the global MAC datastructure
4422 *
4423 * \param peer MAC address to which this frame will be sent
4424 *
4425 * \param nMode
4426 *
4427 * \param nNewChannel
4428 *
4429 * \param nCount
4430 *
4431 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4432 *
4433 *
4434 */
4435
4436tSirRetStatus
4437limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4438 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004439 tANI_U8 nMode,
4440 tANI_U8 nNewChannel,
4441 tANI_U8 nCount,
4442 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004443{
4444 tDot11fChannelSwitch frm;
4445 tANI_U8 *pFrame;
4446 tSirRetStatus nSirStatus;
4447 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004448 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 void *pPacket;
4450 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004451 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004452
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304453 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004454
4455 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4456 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4457 frm.ChanSwitchAnn.switchMode = nMode;
4458 frm.ChanSwitchAnn.newChannel = nNewChannel;
4459 frm.ChanSwitchAnn.switchCount = nCount;
4460 frm.ChanSwitchAnn.present = 1;
4461
4462 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4463 if ( DOT11F_FAILED( nStatus ) )
4464 {
4465 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004466 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 nStatus );
4468 // We'll fall back on the worst case scenario:
4469 nPayload = sizeof( tDot11fChannelSwitch );
4470 }
4471 else if ( DOT11F_WARNED( nStatus ) )
4472 {
4473 limLog( pMac, LOGW, FL("There were warnings while calculating"
4474 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004475 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 }
4477
4478 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4479
4480 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4481 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4482 {
4483 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004484 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 return eSIR_FAILURE;
4486 }
4487
4488 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304489 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004490
4491 // Next, we fill out the buffer descriptor:
4492 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004493 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4494 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304495 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4496 (tANI_U8 *) psessionEntry->bssId,
4497 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 if ( eSIR_SUCCESS != nSirStatus )
4499 {
4500 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004501 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 nSirStatus );
4503 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4504 return eSIR_FAILURE; // just allocated...
4505 }
4506
Jeff Johnsone7245742012-09-05 17:12:55 -07004507#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4509
4510 nCfg = 6;
4511 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4512 if ( eSIR_SUCCESS != nSirStatus )
4513 {
4514 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004515 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 nSirStatus );
4517 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4518 return eSIR_FAILURE; // just allocated...
4519 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004520#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004521
4522#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004523 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004524#endif
4525
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4527 sizeof(tSirMacMgmtHdr),
4528 nPayload, &nPayload );
4529 if ( DOT11F_FAILED( nStatus ) )
4530 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004531 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 nStatus );
4533 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4534 return eSIR_FAILURE; // allocated!
4535 }
4536 else if ( DOT11F_WARNED( nStatus ) )
4537 {
4538 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004539 "hannel Switch (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 }
4541
Jeff Johnsone7245742012-09-05 17:12:55 -07004542 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004543 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4544 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004545 )
4546 {
4547 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4550 HAL_TXRX_FRM_802_11_MGMT,
4551 ANI_TXDIR_TODS,
4552 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004553 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4555 {
4556 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004557 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 nSirStatus );
4559 //Pkt will be freed up by the callback
4560 return eSIR_FAILURE;
4561 }
4562
4563 return eSIR_SUCCESS;
4564
4565} // End limSendChannelSwitchMgmtFrame.
4566
Jeff Johnson295189b2012-06-20 16:38:30 -07004567
4568
Mohit Khanna4a70d262012-09-11 16:30:12 -07004569#ifdef WLAN_FEATURE_11AC
4570tSirRetStatus
4571limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4572 tSirMacAddr peer,
4573 tANI_U8 nMode,
4574 tpPESession psessionEntry )
4575{
4576 tDot11fOperatingMode frm;
4577 tANI_U8 *pFrame;
4578 tSirRetStatus nSirStatus;
4579 tpSirMacMgmtHdr pMacHdr;
4580 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4581 void *pPacket;
4582 eHalStatus halstatus;
4583 tANI_U8 txFlag = 0;
4584
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304585 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004586
4587 frm.Category.category = SIR_MAC_ACTION_VHT;
4588 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4589 frm.OperatingMode.chanWidth = nMode;
4590 frm.OperatingMode.rxNSS = 0;
4591 frm.OperatingMode.rxNSSType = 0;
4592
4593 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4594 if ( DOT11F_FAILED( nStatus ) )
4595 {
4596 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004597 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004598 nStatus );
4599 // We'll fall back on the worst case scenario:
4600 nPayload = sizeof( tDot11fOperatingMode);
4601 }
4602 else if ( DOT11F_WARNED( nStatus ) )
4603 {
4604 limLog( pMac, LOGW, FL("There were warnings while calculating"
4605 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004606 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004607 }
4608
4609 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4610
4611 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4612 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4613 {
4614 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004615 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004616 return eSIR_FAILURE;
4617 }
4618
4619 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304620 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004621
4622
4623 // Next, we fill out the buffer descriptor:
4624 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4625 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4626 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4627 } else
4628 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4629 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4630 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304631 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4632 (tANI_U8 *) psessionEntry->bssId,
4633 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004634 if ( eSIR_SUCCESS != nSirStatus )
4635 {
4636 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004637 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004638 nSirStatus );
4639 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4640 return eSIR_FAILURE; // just allocated...
4641 }
4642 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4643 sizeof(tSirMacMgmtHdr),
4644 nPayload, &nPayload );
4645 if ( DOT11F_FAILED( nStatus ) )
4646 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004647 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004648 nStatus );
4649 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4650 return eSIR_FAILURE; // allocated!
4651 }
4652 else if ( DOT11F_WARNED( nStatus ) )
4653 {
4654 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004655 " (0x%08x).") );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004656 }
4657 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004658 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4659 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004660 )
4661 {
4662 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4663 }
4664 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4665 HAL_TXRX_FRM_802_11_MGMT,
4666 ANI_TXDIR_TODS,
4667 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4668 limTxComplete, pFrame, txFlag );
4669 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4670 {
4671 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004672 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004673 nSirStatus );
4674 //Pkt will be freed up by the callback
4675 return eSIR_FAILURE;
4676 }
4677
4678 return eSIR_SUCCESS;
4679}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004680
4681/**
4682 * \brief Send a VHT Channel Switch Announcement
4683 *
4684 *
4685 * \param pMac Pointer to the global MAC datastructure
4686 *
4687 * \param peer MAC address to which this frame will be sent
4688 *
4689 * \param nChanWidth
4690 *
4691 * \param nNewChannel
4692 *
4693 *
4694 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4695 *
4696 *
4697 */
4698
4699tSirRetStatus
4700limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4701 tSirMacAddr peer,
4702 tANI_U8 nChanWidth,
4703 tANI_U8 nNewChannel,
4704 tANI_U8 ncbMode,
4705 tpPESession psessionEntry )
4706{
4707 tDot11fChannelSwitch frm;
4708 tANI_U8 *pFrame;
4709 tSirRetStatus nSirStatus;
4710 tpSirMacMgmtHdr pMacHdr;
4711 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4712 void *pPacket;
4713 eHalStatus halstatus;
4714 tANI_U8 txFlag = 0;
4715
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304716 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004717
4718
4719 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4720 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4721 frm.ChanSwitchAnn.switchMode = 1;
4722 frm.ChanSwitchAnn.newChannel = nNewChannel;
4723 frm.ChanSwitchAnn.switchCount = 1;
4724 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4725 frm.ExtChanSwitchAnn.present = 1;
4726 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4727 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4728 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4729 frm.ChanSwitchAnn.present = 1;
4730 frm.WiderBWChanSwitchAnn.present = 1;
4731
4732 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4733 if ( DOT11F_FAILED( nStatus ) )
4734 {
4735 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004736 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004737 nStatus );
4738 // We'll fall back on the worst case scenario:
4739 nPayload = sizeof( tDot11fChannelSwitch );
4740 }
4741 else if ( DOT11F_WARNED( nStatus ) )
4742 {
4743 limLog( pMac, LOGW, FL("There were warnings while calculating"
4744 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004745 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004746 }
4747
4748 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4749
4750 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4751 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4752 {
4753 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004754 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004755 return eSIR_FAILURE;
4756 }
4757 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304758 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004759
4760 // Next, we fill out the buffer descriptor:
4761 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4762 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4763 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304764 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4765 (tANI_U8 *) psessionEntry->bssId,
4766 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004767 if ( eSIR_SUCCESS != nSirStatus )
4768 {
4769 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004770 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004771 nSirStatus );
4772 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4773 return eSIR_FAILURE; // just allocated...
4774 }
4775 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4776 sizeof(tSirMacMgmtHdr),
4777 nPayload, &nPayload );
4778 if ( DOT11F_FAILED( nStatus ) )
4779 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004780 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004781 nStatus );
4782 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4783 return eSIR_FAILURE; // allocated!
4784 }
4785 else if ( DOT11F_WARNED( nStatus ) )
4786 {
4787 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004788 "hannel Switch (0x%08x).") );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004789 }
4790
4791 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004792 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4793 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004794 )
4795 {
4796 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4797 }
4798 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4799 HAL_TXRX_FRM_802_11_MGMT,
4800 ANI_TXDIR_TODS,
4801 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4802 limTxComplete, pFrame, txFlag );
4803 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4804 {
4805 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004806 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004807 nSirStatus );
4808 //Pkt will be freed up by the callback
4809 return eSIR_FAILURE;
4810 }
4811
4812 return eSIR_SUCCESS;
4813
4814} // End limSendVHTChannelSwitchMgmtFrame.
4815
4816
4817
Mohit Khanna4a70d262012-09-11 16:30:12 -07004818#endif
4819
Jeff Johnson295189b2012-06-20 16:38:30 -07004820/**
4821 * \brief Send an ADDBA Req Action Frame to peer
4822 *
4823 * \sa limSendAddBAReq
4824 *
4825 * \param pMac The global tpAniSirGlobal object
4826 *
4827 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4828 * the necessary parameters reqd by PE send the ADDBA Req Action
4829 * Frame to the peer
4830 *
4831 * \return eSIR_SUCCESS if setup completes successfully
4832 * eSIR_FAILURE is some problem is encountered
4833 */
4834tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304835 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004836{
4837 tDot11fAddBAReq frmAddBAReq;
4838 tANI_U8 *pAddBAReqBuffer = NULL;
4839 tpSirMacMgmtHdr pMacHdr;
4840 tANI_U32 frameLen = 0, nStatus, nPayload;
4841 tSirRetStatus statusCode;
4842 eHalStatus halStatus;
4843 void *pPacket;
4844 tANI_U8 txFlag = 0;
4845
4846 if(NULL == psessionEntry)
4847 {
4848 return eSIR_FAILURE;
4849 }
4850
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304851 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004852
4853 // Category - 3 (BA)
4854 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4855
4856 // Action - 0 (ADDBA Req)
4857 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4858
4859 // FIXME - Dialog Token, generalize this...
4860 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4861
4862 // Fill the ADDBA Parameter Set
4863 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4864 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4865 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4866
4867 // BA timeout
4868 // 0 - indicates no BA timeout
4869 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4870
4871 // BA Starting Sequence Number
4872 // Fragment number will always be zero
4873 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4874 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4875 }
4876
4877 frmAddBAReq.BAStartingSequenceControl.ssn =
4878 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4879
4880 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4881
4882 if( DOT11F_FAILED( nStatus ))
4883 {
4884 limLog( pMac, LOGW,
4885 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004886 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 nStatus );
4888
4889 // We'll fall back on the worst case scenario:
4890 nPayload = sizeof( tDot11fAddBAReq );
4891 }
4892 else if( DOT11F_WARNED( nStatus ))
4893 {
4894 limLog( pMac, LOGW,
4895 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004896 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 nStatus );
4898 }
4899
4900 // Add the MGMT header to frame length
4901 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4902
4903 // Need to allocate a buffer for ADDBA AF
4904 if( eHAL_STATUS_SUCCESS !=
4905 (halStatus = palPktAlloc( pMac->hHdd,
4906 HAL_TXRX_FRM_802_11_MGMT,
4907 (tANI_U16) frameLen,
4908 (void **) &pAddBAReqBuffer,
4909 (void **) &pPacket )))
4910 {
4911 // Log error
4912 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004913 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004914 frameLen,
4915 halStatus );
4916
4917 statusCode = eSIR_MEM_ALLOC_FAILED;
4918 goto returnAfterError;
4919 }
4920
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304921 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004922
4923 // Copy necessary info to BD
4924 if( eSIR_SUCCESS !=
4925 (statusCode = limPopulateMacHeader( pMac,
4926 pAddBAReqBuffer,
4927 SIR_MAC_MGMT_FRAME,
4928 SIR_MAC_MGMT_ACTION,
4929 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4930 goto returnAfterError;
4931
4932 // Update A3 with the BSSID
4933 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4934
4935 #if 0
4936 cfgLen = SIR_MAC_ADDR_LENGTH;
4937 if( eSIR_SUCCESS != cfgGetStr( pMac,
4938 WNI_CFG_BSSID,
4939 (tANI_U8 *) pMacHdr->bssId,
4940 &cfgLen ))
4941 {
4942 limLog( pMac, LOGP,
4943 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004944 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004945
4946 // FIXME - Need to convert to tSirRetStatus
4947 statusCode = eSIR_FAILURE;
4948 goto returnAfterError;
4949 }
4950 #endif//TO SUPPORT BT-AMP
4951 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4952
Chet Lanctot186b5732013-03-18 10:26:30 -07004953#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004954 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004955#endif
4956
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 // Now, we're ready to "pack" the frames
4958 nStatus = dot11fPackAddBAReq( pMac,
4959 &frmAddBAReq,
4960 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4961 nPayload,
4962 &nPayload );
4963
4964 if( DOT11F_FAILED( nStatus ))
4965 {
4966 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004967 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 nStatus );
4969
4970 // FIXME - Need to convert to tSirRetStatus
4971 statusCode = eSIR_FAILURE;
4972 goto returnAfterError;
4973 }
4974 else if( DOT11F_WARNED( nStatus ))
4975 {
4976 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004977 FL( "There were warnings while packing an ADDBA Req (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 }
4979
4980 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004981 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4983
4984 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4986 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 )
4988 {
4989 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4990 }
4991
4992 if( eHAL_STATUS_SUCCESS !=
4993 (halStatus = halTxFrame( pMac,
4994 pPacket,
4995 (tANI_U16) frameLen,
4996 HAL_TXRX_FRM_802_11_MGMT,
4997 ANI_TXDIR_TODS,
4998 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4999 limTxComplete,
5000 pAddBAReqBuffer, txFlag )))
5001 {
5002 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005003 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 halStatus );
5005
5006 // FIXME - Need to convert eHalStatus to tSirRetStatus
5007 statusCode = eSIR_FAILURE;
5008 //Pkt will be freed up by the callback
5009 return statusCode;
5010 }
5011 else
5012 return eSIR_SUCCESS;
5013
5014returnAfterError:
5015
5016 // Release buffer, if allocated
5017 if( NULL != pAddBAReqBuffer )
5018 palPktFree( pMac->hHdd,
5019 HAL_TXRX_FRM_802_11_MGMT,
5020 (void *) pAddBAReqBuffer,
5021 (void *) pPacket );
5022
5023 return statusCode;
5024}
5025
5026/**
5027 * \brief Send an ADDBA Rsp Action Frame to peer
5028 *
5029 * \sa limSendAddBARsp
5030 *
5031 * \param pMac The global tpAniSirGlobal object
5032 *
5033 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5034 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5035 * Frame to the peer
5036 *
5037 * \return eSIR_SUCCESS if setup completes successfully
5038 * eSIR_FAILURE is some problem is encountered
5039 */
5040tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5041 tpLimMlmAddBARsp pMlmAddBARsp,
5042 tpPESession psessionEntry)
5043{
5044 tDot11fAddBARsp frmAddBARsp;
5045 tANI_U8 *pAddBARspBuffer = NULL;
5046 tpSirMacMgmtHdr pMacHdr;
5047 tANI_U32 frameLen = 0, nStatus, nPayload;
5048 tSirRetStatus statusCode;
5049 eHalStatus halStatus;
5050 void *pPacket;
5051 tANI_U8 txFlag = 0;
5052
5053 if(NULL == psessionEntry)
5054 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005055 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 return eSIR_FAILURE;
5057 }
5058
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305059 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005060
5061 // Category - 3 (BA)
5062 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5063 // Action - 1 (ADDBA Rsp)
5064 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5065
5066 // Should be same as the one we received in the ADDBA Req
5067 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5068
5069 // ADDBA Req status
5070 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5071
5072 // Fill the ADDBA Parameter Set as provided by caller
5073 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5074 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5075 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
Kiran Kumar Lokere2ac471f2013-05-30 16:08:48 -07005076 frmAddBARsp.AddBAParameterSet.amsduSupported = psessionEntry->amsduSupportedInBA;
Jeff Johnson295189b2012-06-20 16:38:30 -07005077
5078 // BA timeout
5079 // 0 - indicates no BA timeout
5080 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5081
5082 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5083
5084 if( DOT11F_FAILED( nStatus ))
5085 {
5086 limLog( pMac, LOGW,
5087 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005088 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 nStatus );
5090
5091 // We'll fall back on the worst case scenario:
5092 nPayload = sizeof( tDot11fAddBARsp );
5093 }
5094 else if( DOT11F_WARNED( nStatus ))
5095 {
5096 limLog( pMac, LOGW,
5097 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005098 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 nStatus );
5100 }
5101
5102 // Need to allocate a buffer for ADDBA AF
5103 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5104
5105 // Allocate shared memory
5106 if( eHAL_STATUS_SUCCESS !=
5107 (halStatus = palPktAlloc( pMac->hHdd,
5108 HAL_TXRX_FRM_802_11_MGMT,
5109 (tANI_U16) frameLen,
5110 (void **) &pAddBARspBuffer,
5111 (void **) &pPacket )))
5112 {
5113 // Log error
5114 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005115 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 frameLen,
5117 halStatus );
5118
5119 statusCode = eSIR_MEM_ALLOC_FAILED;
5120 goto returnAfterError;
5121 }
5122
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305123 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005124
5125 // Copy necessary info to BD
5126 if( eSIR_SUCCESS !=
5127 (statusCode = limPopulateMacHeader( pMac,
5128 pAddBARspBuffer,
5129 SIR_MAC_MGMT_FRAME,
5130 SIR_MAC_MGMT_ACTION,
5131 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5132 goto returnAfterError;
5133
5134 // Update A3 with the BSSID
5135
5136 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5137
5138 #if 0
5139 cfgLen = SIR_MAC_ADDR_LENGTH;
5140 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5141 WNI_CFG_BSSID,
5142 (tANI_U8 *) pMacHdr->bssId,
5143 &cfgLen ))
5144 {
5145 limLog( pMac, LOGP,
5146 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005147 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005148
5149 // FIXME - Need to convert to tSirRetStatus
5150 statusCode = eSIR_FAILURE;
5151 goto returnAfterError;
5152 }
5153 #endif // TO SUPPORT BT-AMP
5154 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5155
Chet Lanctot186b5732013-03-18 10:26:30 -07005156#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005157 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005158#endif
5159
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 // Now, we're ready to "pack" the frames
5161 nStatus = dot11fPackAddBARsp( pMac,
5162 &frmAddBARsp,
5163 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5164 nPayload,
5165 &nPayload );
5166
5167 if( DOT11F_FAILED( nStatus ))
5168 {
5169 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005170 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 nStatus );
5172
5173 // FIXME - Need to convert to tSirRetStatus
5174 statusCode = eSIR_FAILURE;
5175 goto returnAfterError;
5176 }
5177 else if( DOT11F_WARNED( nStatus ))
5178 {
5179 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005180 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005181 }
5182
5183 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005184 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5186
5187 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005188 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5189 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 )
5191 {
5192 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5193 }
5194
5195 if( eHAL_STATUS_SUCCESS !=
5196 (halStatus = halTxFrame( pMac,
5197 pPacket,
5198 (tANI_U16) frameLen,
5199 HAL_TXRX_FRM_802_11_MGMT,
5200 ANI_TXDIR_TODS,
5201 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5202 limTxComplete,
5203 pAddBARspBuffer, txFlag )))
5204 {
5205 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005206 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 halStatus );
5208
5209 // FIXME - HAL error codes are different from PE error
5210 // codes!! And, this routine is returning tSirRetStatus
5211 statusCode = eSIR_FAILURE;
5212 //Pkt will be freed up by the callback
5213 return statusCode;
5214 }
5215 else
5216 return eSIR_SUCCESS;
5217
5218 returnAfterError:
5219
5220 // Release buffer, if allocated
5221 if( NULL != pAddBARspBuffer )
5222 palPktFree( pMac->hHdd,
5223 HAL_TXRX_FRM_802_11_MGMT,
5224 (void *) pAddBARspBuffer,
5225 (void *) pPacket );
5226
5227 return statusCode;
5228}
5229
5230/**
5231 * \brief Send a DELBA Indication Action Frame to peer
5232 *
5233 * \sa limSendDelBAInd
5234 *
5235 * \param pMac The global tpAniSirGlobal object
5236 *
5237 * \param peerMacAddr MAC Address of peer
5238 *
5239 * \param reasonCode Reason for the DELBA notification
5240 *
5241 * \param pBAParameterSet The DELBA Parameter Set.
5242 * This identifies the TID for which the BA session is
5243 * being deleted.
5244 *
5245 * \return eSIR_SUCCESS if setup completes successfully
5246 * eSIR_FAILURE is some problem is encountered
5247 */
5248tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5249 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5250{
5251 tDot11fDelBAInd frmDelBAInd;
5252 tANI_U8 *pDelBAIndBuffer = NULL;
5253 //tANI_U32 val;
5254 tpSirMacMgmtHdr pMacHdr;
5255 tANI_U32 frameLen = 0, nStatus, nPayload;
5256 tSirRetStatus statusCode;
5257 eHalStatus halStatus;
5258 void *pPacket;
5259 tANI_U8 txFlag = 0;
5260
5261 if(NULL == psessionEntry)
5262 {
5263 return eSIR_FAILURE;
5264 }
5265
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305266 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005267
5268 // Category - 3 (BA)
5269 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5270 // Action - 2 (DELBA)
5271 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5272
5273 // Fill the DELBA Parameter Set as provided by caller
5274 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5275 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5276
5277 // BA Starting Sequence Number
5278 // Fragment number will always be zero
5279 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5280
5281 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5282
5283 if( DOT11F_FAILED( nStatus ))
5284 {
5285 limLog( pMac, LOGW,
5286 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005287 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 nStatus );
5289
5290 // We'll fall back on the worst case scenario:
5291 nPayload = sizeof( tDot11fDelBAInd );
5292 }
5293 else if( DOT11F_WARNED( nStatus ))
5294 {
5295 limLog( pMac, LOGW,
5296 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005297 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 nStatus );
5299 }
5300
5301 // Add the MGMT header to frame length
5302 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5303
5304 // Allocate shared memory
5305 if( eHAL_STATUS_SUCCESS !=
5306 (halStatus = palPktAlloc( pMac->hHdd,
5307 HAL_TXRX_FRM_802_11_MGMT,
5308 (tANI_U16) frameLen,
5309 (void **) &pDelBAIndBuffer,
5310 (void **) &pPacket )))
5311 {
5312 // Log error
5313 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005314 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 frameLen,
5316 halStatus );
5317
5318 statusCode = eSIR_MEM_ALLOC_FAILED;
5319 goto returnAfterError;
5320 }
5321
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305322 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005323
5324 // Copy necessary info to BD
5325 if( eSIR_SUCCESS !=
5326 (statusCode = limPopulateMacHeader( pMac,
5327 pDelBAIndBuffer,
5328 SIR_MAC_MGMT_FRAME,
5329 SIR_MAC_MGMT_ACTION,
5330 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5331 goto returnAfterError;
5332
5333 // Update A3 with the BSSID
5334 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5335
5336 #if 0
5337 cfgLen = SIR_MAC_ADDR_LENGTH;
5338 if( eSIR_SUCCESS != cfgGetStr( pMac,
5339 WNI_CFG_BSSID,
5340 (tANI_U8 *) pMacHdr->bssId,
5341 &cfgLen ))
5342 {
5343 limLog( pMac, LOGP,
5344 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005345 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005346
5347 // FIXME - Need to convert to tSirRetStatus
5348 statusCode = eSIR_FAILURE;
5349 goto returnAfterError;
5350 }
5351 #endif //TO SUPPORT BT-AMP
5352 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5353
Chet Lanctot186b5732013-03-18 10:26:30 -07005354#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005355 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005356#endif
5357
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 // Now, we're ready to "pack" the frames
5359 nStatus = dot11fPackDelBAInd( pMac,
5360 &frmDelBAInd,
5361 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5362 nPayload,
5363 &nPayload );
5364
5365 if( DOT11F_FAILED( nStatus ))
5366 {
5367 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005368 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 nStatus );
5370
5371 // FIXME - Need to convert to tSirRetStatus
5372 statusCode = eSIR_FAILURE;
5373 goto returnAfterError;
5374 }
5375 else if( DOT11F_WARNED( nStatus ))
5376 {
5377 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005378 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 }
5380
5381 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005382 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5384
5385 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5387 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 )
5389 {
5390 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5391 }
5392
5393 if( eHAL_STATUS_SUCCESS !=
5394 (halStatus = halTxFrame( pMac,
5395 pPacket,
5396 (tANI_U16) frameLen,
5397 HAL_TXRX_FRM_802_11_MGMT,
5398 ANI_TXDIR_TODS,
5399 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5400 limTxComplete,
5401 pDelBAIndBuffer, txFlag )))
5402 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005403 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 statusCode = eSIR_FAILURE;
5405 //Pkt will be freed up by the callback
5406 return statusCode;
5407 }
5408 else
5409 return eSIR_SUCCESS;
5410
5411 returnAfterError:
5412
5413 // Release buffer, if allocated
5414 if( NULL != pDelBAIndBuffer )
5415 palPktFree( pMac->hHdd,
5416 HAL_TXRX_FRM_802_11_MGMT,
5417 (void *) pDelBAIndBuffer,
5418 (void *) pPacket );
5419
5420 return statusCode;
5421}
5422
5423#if defined WLAN_FEATURE_VOWIFI
5424
5425/**
5426 * \brief Send a Neighbor Report Request Action frame
5427 *
5428 *
5429 * \param pMac Pointer to the global MAC structure
5430 *
5431 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5432 *
5433 * \param peer mac address of peer station.
5434 *
5435 * \param psessionEntry address of session entry.
5436 *
5437 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5438 *
5439 *
5440 */
5441
5442tSirRetStatus
5443limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5444 tpSirMacNeighborReportReq pNeighborReq,
5445 tSirMacAddr peer,
5446 tpPESession psessionEntry
5447 )
5448{
5449 tSirRetStatus statusCode = eSIR_SUCCESS;
5450 tDot11fNeighborReportRequest frm;
5451 tANI_U8 *pFrame;
5452 tpSirMacMgmtHdr pMacHdr;
5453 tANI_U32 nBytes, nPayload, nStatus;
5454 void *pPacket;
5455 eHalStatus halstatus;
5456 tANI_U8 txFlag = 0;
5457
5458 if ( psessionEntry == NULL )
5459 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005460 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 return eSIR_FAILURE;
5462 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305463 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005464
5465 frm.Category.category = SIR_MAC_ACTION_RRM;
5466 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5467 frm.DialogToken.token = pNeighborReq->dialogToken;
5468
5469
5470 if( pNeighborReq->ssid_present )
5471 {
5472 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5473 }
5474
5475 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5476 if ( DOT11F_FAILED( nStatus ) )
5477 {
5478 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005479 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 nStatus );
5481 // We'll fall back on the worst case scenario:
5482 nPayload = sizeof( tDot11fNeighborReportRequest );
5483 }
5484 else if ( DOT11F_WARNED( nStatus ) )
5485 {
5486 limLog( pMac, LOGW, FL("There were warnings while calculating"
5487 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005488 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 }
5490
5491 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5492
5493 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5494 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5495 {
5496 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005497 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 return eSIR_FAILURE;
5499 }
5500
5501 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305502 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005503
5504 // Copy necessary info to BD
5505 if( eSIR_SUCCESS !=
5506 (statusCode = limPopulateMacHeader( pMac,
5507 pFrame,
5508 SIR_MAC_MGMT_FRAME,
5509 SIR_MAC_MGMT_ACTION,
5510 peer, psessionEntry->selfMacAddr)))
5511 goto returnAfterError;
5512
5513 // Update A3 with the BSSID
5514 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5515
5516 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5517
Chet Lanctot186b5732013-03-18 10:26:30 -07005518#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005519 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005520#endif
5521
Jeff Johnson295189b2012-06-20 16:38:30 -07005522 // Now, we're ready to "pack" the frames
5523 nStatus = dot11fPackNeighborReportRequest( pMac,
5524 &frm,
5525 pFrame + sizeof( tSirMacMgmtHdr ),
5526 nPayload,
5527 &nPayload );
5528
5529 if( DOT11F_FAILED( nStatus ))
5530 {
5531 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005532 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 nStatus );
5534
5535 // FIXME - Need to convert to tSirRetStatus
5536 statusCode = eSIR_FAILURE;
5537 goto returnAfterError;
5538 }
5539 else if( DOT11F_WARNED( nStatus ))
5540 {
5541 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005542 FL( "There were warnings while packing Neighbor Report Request (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 }
5544
5545 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005546 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 limPrintMacAddr( pMac, peer, LOGW );
5548
5549 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5551 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 )
5553 {
5554 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5555 }
5556
5557 if( eHAL_STATUS_SUCCESS !=
5558 (halstatus = halTxFrame( pMac,
5559 pPacket,
5560 (tANI_U16) nBytes,
5561 HAL_TXRX_FRM_802_11_MGMT,
5562 ANI_TXDIR_TODS,
5563 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5564 limTxComplete,
5565 pFrame, txFlag )))
5566 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005567 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 statusCode = eSIR_FAILURE;
5569 //Pkt will be freed up by the callback
5570 return statusCode;
5571 }
5572 else
5573 return eSIR_SUCCESS;
5574
5575returnAfterError:
5576 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5577
5578 return statusCode;
5579} // End limSendNeighborReportRequestFrame.
5580
5581/**
5582 * \brief Send a Link Report Action frame
5583 *
5584 *
5585 * \param pMac Pointer to the global MAC structure
5586 *
5587 * \param pLinkReport Address of a tSirMacLinkReport
5588 *
5589 * \param peer mac address of peer station.
5590 *
5591 * \param psessionEntry address of session entry.
5592 *
5593 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5594 *
5595 *
5596 */
5597
5598tSirRetStatus
5599limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5600 tpSirMacLinkReport pLinkReport,
5601 tSirMacAddr peer,
5602 tpPESession psessionEntry
5603 )
5604{
5605 tSirRetStatus statusCode = eSIR_SUCCESS;
5606 tDot11fLinkMeasurementReport frm;
5607 tANI_U8 *pFrame;
5608 tpSirMacMgmtHdr pMacHdr;
5609 tANI_U32 nBytes, nPayload, nStatus;
5610 void *pPacket;
5611 eHalStatus halstatus;
5612 tANI_U8 txFlag = 0;
5613
5614
5615 if ( psessionEntry == NULL )
5616 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005617 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 return eSIR_FAILURE;
5619 }
5620
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305621 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005622
5623 frm.Category.category = SIR_MAC_ACTION_RRM;
5624 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5625 frm.DialogToken.token = pLinkReport->dialogToken;
5626
5627
5628 //IEEE Std. 802.11 7.3.2.18. for the report element.
5629 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5630 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5631 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5632 //such case this way than changing the frame parser.
5633 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5634 frm.TPCEleLen.TPCLen = 2;
5635 frm.TxPower.txPower = pLinkReport->txPower;
5636 frm.LinkMargin.linkMargin = 0;
5637
5638 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5639 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5640 frm.RCPI.rcpi = pLinkReport->rcpi;
5641 frm.RSNI.rsni = pLinkReport->rsni;
5642
5643 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5644 if ( DOT11F_FAILED( nStatus ) )
5645 {
5646 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005647 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 nStatus );
5649 // We'll fall back on the worst case scenario:
5650 nPayload = sizeof( tDot11fLinkMeasurementReport );
5651 }
5652 else if ( DOT11F_WARNED( nStatus ) )
5653 {
5654 limLog( pMac, LOGW, FL("There were warnings while calculating"
5655 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005656 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 }
5658
5659 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5660
5661 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5662 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5663 {
5664 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005665 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 return eSIR_FAILURE;
5667 }
5668
5669 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305670 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005671
5672 // Copy necessary info to BD
5673 if( eSIR_SUCCESS !=
5674 (statusCode = limPopulateMacHeader( pMac,
5675 pFrame,
5676 SIR_MAC_MGMT_FRAME,
5677 SIR_MAC_MGMT_ACTION,
5678 peer, psessionEntry->selfMacAddr)))
5679 goto returnAfterError;
5680
5681 // Update A3 with the BSSID
5682 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5683
5684 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5685
Chet Lanctot186b5732013-03-18 10:26:30 -07005686#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005687 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005688#endif
5689
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 // Now, we're ready to "pack" the frames
5691 nStatus = dot11fPackLinkMeasurementReport( pMac,
5692 &frm,
5693 pFrame + sizeof( tSirMacMgmtHdr ),
5694 nPayload,
5695 &nPayload );
5696
5697 if( DOT11F_FAILED( nStatus ))
5698 {
5699 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005700 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 nStatus );
5702
5703 // FIXME - Need to convert to tSirRetStatus
5704 statusCode = eSIR_FAILURE;
5705 goto returnAfterError;
5706 }
5707 else if( DOT11F_WARNED( nStatus ))
5708 {
5709 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005710 FL( "There were warnings while packing Link Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 }
5712
5713 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005714 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 limPrintMacAddr( pMac, peer, LOGW );
5716
5717 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5719 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 )
5721 {
5722 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5723 }
5724
5725 if( eHAL_STATUS_SUCCESS !=
5726 (halstatus = halTxFrame( pMac,
5727 pPacket,
5728 (tANI_U16) nBytes,
5729 HAL_TXRX_FRM_802_11_MGMT,
5730 ANI_TXDIR_TODS,
5731 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5732 limTxComplete,
5733 pFrame, txFlag )))
5734 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005735 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005736 statusCode = eSIR_FAILURE;
5737 //Pkt will be freed up by the callback
5738 return statusCode;
5739 }
5740 else
5741 return eSIR_SUCCESS;
5742
5743returnAfterError:
5744 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5745
5746 return statusCode;
5747} // End limSendLinkReportActionFrame.
5748
5749/**
5750 * \brief Send a Beacon Report Action frame
5751 *
5752 *
5753 * \param pMac Pointer to the global MAC structure
5754 *
5755 * \param dialog_token dialog token to be used in the action frame.
5756 *
5757 * \param num_report number of reports in pRRMReport.
5758 *
5759 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5760 *
5761 * \param peer mac address of peer station.
5762 *
5763 * \param psessionEntry address of session entry.
5764 *
5765 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5766 *
5767 *
5768 */
5769
5770tSirRetStatus
5771limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5772 tANI_U8 dialog_token,
5773 tANI_U8 num_report,
5774 tpSirMacRadioMeasureReport pRRMReport,
5775 tSirMacAddr peer,
5776 tpPESession psessionEntry
5777 )
5778{
5779 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 tANI_U8 *pFrame;
5781 tpSirMacMgmtHdr pMacHdr;
5782 tANI_U32 nBytes, nPayload, nStatus;
5783 void *pPacket;
5784 eHalStatus halstatus;
5785 tANI_U8 i;
5786 tANI_U8 txFlag = 0;
5787
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005788 tDot11fRadioMeasurementReport *frm =
5789 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5790 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005791 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005792 return eSIR_FAILURE;
5793 }
5794
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 if ( psessionEntry == NULL )
5796 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005797 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005798 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 return eSIR_FAILURE;
5800 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305801 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005802
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005803 frm->Category.category = SIR_MAC_ACTION_RRM;
5804 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5805 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005806
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005807 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 -07005808
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005809 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005811 frm->MeasurementReport[i].type = pRRMReport[i].type;
5812 frm->MeasurementReport[i].token = pRRMReport[i].token;
5813 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 switch( pRRMReport[i].type )
5815 {
5816 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005817 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5818 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5819 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5820 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 break;
5822 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305823 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5824 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005825 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 break;
5827 }
5828 }
5829
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005830 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005831 if ( DOT11F_FAILED( nStatus ) )
5832 {
5833 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005834 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 nStatus );
5836 // We'll fall back on the worst case scenario:
5837 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005838 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 return eSIR_FAILURE;
5840 }
5841 else if ( DOT11F_WARNED( nStatus ) )
5842 {
5843 limLog( pMac, LOGW, FL("There were warnings while calculating"
5844 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005845 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 }
5847
5848 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5849
5850 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5851 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5852 {
5853 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005854 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005855 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 return eSIR_FAILURE;
5857 }
5858
5859 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305860 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005861
5862 // Copy necessary info to BD
5863 if( eSIR_SUCCESS !=
5864 (statusCode = limPopulateMacHeader( pMac,
5865 pFrame,
5866 SIR_MAC_MGMT_FRAME,
5867 SIR_MAC_MGMT_ACTION,
5868 peer, psessionEntry->selfMacAddr)))
5869 goto returnAfterError;
5870
5871 // Update A3 with the BSSID
5872 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5873
5874 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5875
Chet Lanctot186b5732013-03-18 10:26:30 -07005876#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005877 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005878#endif
5879
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 // Now, we're ready to "pack" the frames
5881 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005882 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 pFrame + sizeof( tSirMacMgmtHdr ),
5884 nPayload,
5885 &nPayload );
5886
5887 if( DOT11F_FAILED( nStatus ))
5888 {
5889 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005890 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 nStatus );
5892
5893 // FIXME - Need to convert to tSirRetStatus
5894 statusCode = eSIR_FAILURE;
5895 goto returnAfterError;
5896 }
5897 else if( DOT11F_WARNED( nStatus ))
5898 {
5899 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005900 FL( "There were warnings while packing Radio Measure Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 }
5902
5903 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005904 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 limPrintMacAddr( pMac, peer, LOGW );
5906
5907 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5909 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 )
5911 {
5912 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5913 }
5914
5915 if( eHAL_STATUS_SUCCESS !=
5916 (halstatus = halTxFrame( pMac,
5917 pPacket,
5918 (tANI_U16) nBytes,
5919 HAL_TXRX_FRM_802_11_MGMT,
5920 ANI_TXDIR_TODS,
5921 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5922 limTxComplete,
5923 pFrame, txFlag )))
5924 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005925 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005926 statusCode = eSIR_FAILURE;
5927 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005928 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 return statusCode;
5930 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005931 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005932 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005935
5936returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005937 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 return statusCode;
5940} // End limSendBeaconReportActionFrame.
5941
5942#endif
5943
5944#ifdef WLAN_FEATURE_11W
5945/**
5946 * \brief Send SA query response action frame to peer
5947 *
5948 * \sa limSendSaQueryResponseFrame
5949 *
5950 *
5951 * \param pMac The global tpAniSirGlobal object
5952 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005953 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005955 * \param peer The Mac address of the AP to which this action frame is addressed
5956 *
5957 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 *
5959 * \return eSIR_SUCCESS if setup completes successfully
5960 * eSIR_FAILURE is some problem is encountered
5961 */
5962
Chet Lanctot186b5732013-03-18 10:26:30 -07005963tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005964tSirMacAddr peer,tpPESession psessionEntry)
5965{
5966
Chet Lanctot186b5732013-03-18 10:26:30 -07005967 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 tANI_U8 *pFrame;
5969 tSirRetStatus nSirStatus;
5970 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07005971 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 void *pPacket;
5973 eHalStatus halstatus;
Chet Lanctot186b5732013-03-18 10:26:30 -07005974 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005975
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305976 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07005977 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
5978 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 action: 0 --> SA query request action frame
5980 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07005981 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
5982 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07005984 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005985
Chet Lanctot186b5732013-03-18 10:26:30 -07005986 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
5987 if ( DOT11F_FAILED( nStatus ) )
5988 {
5989 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5990 "or a SA Query Response (0x%08x)."),
5991 nStatus );
5992 // We'll fall back on the worst case scenario:
5993 nPayload = sizeof( tDot11fSaQueryRsp );
5994 }
5995 else if ( DOT11F_WARNED( nStatus ) )
5996 {
5997 limLog( pMac, LOGW, FL("There were warnings while calculating"
5998 "the packed size for an SA Query Response"
5999 " (0x%08x)."), nStatus );
6000 }
6001
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6003 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6004 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6005 {
6006 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006007 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 return eSIR_FAILURE;
6009 }
6010
6011 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306012 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006013
Chet Lanctot186b5732013-03-18 10:26:30 -07006014 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006015 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006016 pFrame,
6017 SIR_MAC_MGMT_FRAME,
6018 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006019 peer, psessionEntry->selfMacAddr );
6020 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006021 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006022
Chet Lanctot186b5732013-03-18 10:26:30 -07006023 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6025
Chet Lanctot186b5732013-03-18 10:26:30 -07006026 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006027
Chet Lanctot186b5732013-03-18 10:26:30 -07006028 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6029 // in the FC
6030 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006032 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 }
6034
Chet Lanctot186b5732013-03-18 10:26:30 -07006035 // Pack 11w SA query response frame
6036 nStatus = dot11fPackSaQueryRsp( pMac,
6037 &frm,
6038 pFrame + sizeof( tSirMacMgmtHdr ),
6039 nPayload,
6040 &nPayload );
6041
6042 if ( DOT11F_FAILED( nStatus ))
6043 {
6044 limLog( pMac, LOGE,
6045 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6046 nStatus );
6047 // FIXME - Need to convert to tSirRetStatus
6048 nSirStatus = eSIR_FAILURE;
6049 goto returnAfterError;
6050 }
6051 else if ( DOT11F_WARNED( nStatus ))
6052 {
6053 limLog( pMac, LOGW,
6054 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6055 nStatus);
6056 }
6057
6058 limLog( pMac, LOG1,
6059 FL( "Sending a SA Query Response to " ));
6060 limPrintMacAddr( pMac, peer, LOGW );
6061
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006062 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006063#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006064 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6065 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006066#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006067 )
6068 {
6069 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6070 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006071
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006072 halstatus = halTxFrame( pMac,
6073 pPacket,
6074 (tANI_U16) nBytes,
6075 HAL_TXRX_FRM_802_11_MGMT,
6076 ANI_TXDIR_TODS,
6077 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6078 limTxComplete,
6079 pFrame, txFlag );
6080 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006081 {
6082 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6083 nSirStatus = eSIR_FAILURE;
6084 //Pkt will be freed up by the callback
6085 return nSirStatus;
6086 }
6087 else {
6088 return eSIR_SUCCESS;
6089 }
6090
6091returnAfterError:
6092 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6093 return nSirStatus;
6094} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006095#endif