blob: cc731c48f4939ba00b0e330d465d0a70e4f07d6c [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302 * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08003 *
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 *
Jeff Johnson295189b2012-06-20 16:38:30 -070046 *
47 */
48
49#include "sirApi.h"
50#include "aniGlobal.h"
51#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070052#include "cfgApi.h"
53#include "utilsApi.h"
54#include "limTypes.h"
55#include "limUtils.h"
56#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070057#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "dot11f.h"
59#include "limStaHashApi.h"
60#include "schApi.h"
61#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080062#include "limAssocUtils.h"
63#include "limFT.h"
64
Jeff Johnson295189b2012-06-20 16:38:30 -070065#if defined WLAN_FEATURE_VOWIFI
66#include "rrmApi.h"
67#endif
68
Jeff Johnson295189b2012-06-20 16:38:30 -070069#include "wlan_qct_wda.h"
70#ifdef WLAN_FEATURE_11W
71#include "dot11fdefs.h"
72#endif
73
74
75////////////////////////////////////////////////////////////////////////
76
Jeff Johnson295189b2012-06-20 16:38:30 -070077
78/**
79 *
80 * \brief This function is called by various LIM modules to prepare the
81 * 802.11 frame MAC header
82 *
83 *
84 * \param pMac Pointer to Global MAC structure
85 *
86 * \param pBD Pointer to the frame buffer that needs to be populate
87 *
88 * \param type Type of the frame
89 *
90 * \param subType Subtype of the frame
91 *
92 * \return eHalStatus
93 *
94 *
95 * The pFrameBuf argument points to the beginning of the frame buffer to
96 * which - a) The 802.11 MAC header is set b) Following this MAC header
97 * will be the MGMT frame payload The payload itself is populated by the
98 * caller API
99 *
100 *
101 */
102
103tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
104 tANI_U8* pBD,
105 tANI_U8 type,
106 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530107 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700108{
109 tSirRetStatus statusCode = eSIR_SUCCESS;
110 tpSirMacMgmtHdr pMacHdr;
111
112 /// Prepare MAC management header
113 pMacHdr = (tpSirMacMgmtHdr) (pBD);
114
115 // Prepare FC
116 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
117 pMacHdr->fc.type = type;
118 pMacHdr->fc.subType = subType;
119
120 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530121 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700122 (tANI_U8 *) peerAddr,
123 sizeof( tSirMacAddr ));
124
125 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700126 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
127
128 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530129 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700130 (tANI_U8 *) peerAddr,
131 sizeof( tSirMacAddr ));
132 return statusCode;
133} /*** end limPopulateMacHeader() ***/
134
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700135#ifdef WLAN_FEATURE_11W
136/**
137 *
138 * \brief This function is called by various LIM modules to correctly set
139 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
140 *
141 *
142 * \param pMac Pointer to Global MAC structure
143 *
144 * \param psessionEntry Pointer to session corresponding to the connection
145 *
146 * \param peer Peer address of the STA to which the frame is to be sent
147 *
148 * \param pMacHdr Pointer to the frame MAC header
149 *
150 * \return nothing
151 *
152 *
153 */
154void
155limSetProtectedBit(tpAniSirGlobal pMac,
156 tpPESession psessionEntry,
157 tSirMacAddr peer,
158 tpSirMacMgmtHdr pMacHdr)
159{
160 tANI_U16 aid;
161 tpDphHashNode pStaDs;
162
163 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
164 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
165 {
166
167 pStaDs = dphLookupHashEntry( pMac, peer, &aid, &psessionEntry->dph.dphHashTable );
168 if( pStaDs != NULL )
169 if( pStaDs->rmfEnabled )
170 pMacHdr->fc.wep = 1;
171 }
172 else if ( psessionEntry->limRmfEnabled )
173 pMacHdr->fc.wep = 1;
174} /*** end limSetProtectedBit() ***/
175#endif
176
Jeff Johnson295189b2012-06-20 16:38:30 -0700177/**
178 * \brief limSendProbeReqMgmtFrame
179 *
180 *
181 * \param pMac Pointer to Global MAC structure
182 *
183 * \param pSsid SSID to be sent in Probe Request frame
184 *
185 * \param bssid BSSID to be sent in Probe Request frame
186 *
187 * \param nProbeDelay probe delay to be used before sending Probe Request
188 * frame
189 *
190 * \param nChannelNum Channel # on which the Probe Request is going out
191 *
192 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
193 *
194 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
195 *
196 * This function is called by various LIM modules to send Probe Request frame
197 * during active scan/learn phase.
198 * Probe request is sent out in the following scenarios:
199 * --heartbeat failure: session needed
200 * --join req: session needed
201 * --foreground scan: no session
202 * --background scan: no session
203 * --schBeaconProcessing: to get EDCA parameters: session needed
204 *
205 *
206 */
207tSirRetStatus
208limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
209 tSirMacSSid *pSsid,
210 tSirMacAddr bssid,
211 tANI_U8 nChannelNum,
212 tSirMacAddr SelfMacAddr,
213 tANI_U32 dot11mode,
214 tANI_U32 nAdditionalIELen,
215 tANI_U8 *pAdditionalIE)
216{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530217 tDot11fProbeRequest pr;
218 tANI_U32 nStatus, nBytes, nPayload;
219 tSirRetStatus nSirStatus;
220 tANI_U8 *pFrame;
221 void *pPacket;
222 eHalStatus halstatus;
223 tpPESession psessionEntry;
224 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700225 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530226 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700227
228#ifndef GEN4_SCAN
229 return eSIR_FAILURE;
230#endif
231
232#if defined ( ANI_DVT_DEBUG )
233 return eSIR_FAILURE;
234#endif
235
236 /*
237 * session context may or may not be present, when probe request needs to be sent out.
238 * following cases exist:
239 * --heartbeat failure: session needed
240 * --join req: session needed
241 * --foreground scan: no session
242 * --background scan: no session
243 * --schBeaconProcessing: to get EDCA parameters: session needed
244 * If session context does not exist, some IEs will be populated from CFGs,
245 * e.g. Supported and Extended rate set IEs
246 */
247 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
248
249 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
250 // and then hand it off to 'dot11fPackProbeRequest' (for
251 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530252 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700253
254 // & delegating to assorted helpers:
255 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
256
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 if( nAdditionalIELen && pAdditionalIE )
258 {
259 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
260 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700261 /* Don't include 11b rate only when device is doing P2P Search */
262 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
263 ( p2pIe != NULL ) &&
264 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
265 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
266 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
267 ( ( psessionEntry != NULL ) &&
268 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
269 )
270 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 {
272 /* In the below API pass channel number > 14, do that it fills only
273 * 11a rates in supported rates */
274 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
275 }
276 else
277 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 PopulateDot11fSuppRates( pMac, nChannelNum,
279 &pr.SuppRates,psessionEntry);
280
281 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
282 {
283 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
284 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700286
287#if defined WLAN_FEATURE_VOWIFI
288 //Table 7-14 in IEEE Std. 802.11k-2008 says
289 //DS params "can" be present in RRM is disabled and "is" present if
290 //RRM is enabled. It should be ok even if we add it into probe req when
291 //RRM is not enabled.
292 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
293 //Call RRM module to get the tx power for management used.
294 {
295 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
296 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
297 }
298#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700299
300 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700301 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700303 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700305 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700306 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700307 } else { //psessionEntry == NULL
308 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700310 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 }
312 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800313
314 /* Set channelbonding information as "disabled" when tunned to a 2.4 GHz channel */
315 if( nChannelNum <= SIR_11B_CHANNEL_END)
316 {
317 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
318 pr.HTCaps.shortGI40MHz = 0;
319 }
320
Jeff Johnsone7245742012-09-05 17:12:55 -0700321#ifdef WLAN_FEATURE_11AC
322 if (psessionEntry != NULL ) {
323 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
324 //Include HT Capability IE
325 if (psessionEntry->vhtCapability)
326 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700327 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
328 }
329 } else {
330 if (IS_DOT11_MODE_VHT(dot11mode))
331 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700332 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
333 }
334 }
335#endif
336
Jeff Johnson295189b2012-06-20 16:38:30 -0700337
338 // That's it-- now we pack it. First, how much space are we going to
339 // need?
340 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
341 if ( DOT11F_FAILED( nStatus ) )
342 {
343 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700344 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 // We'll fall back on the worst case scenario:
346 nPayload = sizeof( tDot11fProbeRequest );
347 }
348 else if ( DOT11F_WARNED( nStatus ) )
349 {
350 limLog( pMac, LOGW, FL("There were warnings while calculating"
351 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700352 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 }
354
355 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
356
357 // Ok-- try to allocate some memory:
358 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
359 ( tANI_U16 )nBytes, ( void** ) &pFrame,
360 ( void** ) &pPacket );
361 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
362 {
363 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700364 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 return eSIR_MEM_ALLOC_FAILED;
366 }
367
368 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530369 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700370
371 // Next, we fill out the buffer descriptor:
372 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530373 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 if ( eSIR_SUCCESS != nSirStatus )
375 {
376 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700377 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 nSirStatus );
379 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
380 ( void* ) pFrame, ( void* ) pPacket );
381 return nSirStatus; // allocated!
382 }
383
384 // That done, pack the Probe Request:
385 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
386 sizeof( tSirMacMgmtHdr ),
387 nPayload, &nPayload );
388 if ( DOT11F_FAILED( nStatus ) )
389 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700390 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 nStatus );
392 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
393 return eSIR_FAILURE; // allocated!
394 }
395 else if ( DOT11F_WARNED( nStatus ) )
396 {
397 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800398 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 }
400
401 // Append any AddIE if present.
402 if( nAdditionalIELen )
403 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530404 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 pAdditionalIE, nAdditionalIELen );
406 nPayload += nAdditionalIELen;
407 }
408
409 /* If this probe request is sent during P2P Search State, then we need
410 * to send it at OFDM rate.
411 */
412 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
414 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530415 /* For unicast probe req mgmt from Join function
416 we don't set above variables. So we need to add
417 one more check whether it is pePersona is P2P_CLIENT or not */
418 || ( ( psessionEntry != NULL ) &&
419 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700420 )
421 {
422 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
423 }
424
425
426 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
427 HAL_TXRX_FRM_802_11_MGMT,
428 ANI_TXDIR_TODS,
429 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
430 limTxComplete, pFrame, txFlag );
431 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
432 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700433 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700434 //Pkt will be freed up by the callback
435 return eSIR_FAILURE;
436 }
437
438 return eSIR_SUCCESS;
439} // End limSendProbeReqMgmtFrame.
440
Jeff Johnson295189b2012-06-20 16:38:30 -0700441tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
442 tANI_U8* addIE, tANI_U16 *addnIELen,
443 tANI_U8 probeReqP2pIe)
444{
445 /* If Probe request doesn't have P2P IE, then take out P2P IE
446 from additional IE */
447 if(!probeReqP2pIe)
448 {
449 tANI_U8* tempbuf = NULL;
450 tANI_U16 tempLen = 0;
451 int left = *addnIELen;
452 v_U8_t *ptr = addIE;
453 v_U8_t elem_id, elem_len;
454
455 if(NULL == addIE)
456 {
457 PELOGE(limLog(pMac, LOGE,
458 FL(" NULL addIE pointer"));)
459 return eSIR_FAILURE;
460 }
461
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530462 tempbuf = vos_mem_malloc(left);
463 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 {
465 PELOGE(limLog(pMac, LOGE,
466 FL("Unable to allocate memory to store addn IE"));)
467 return eSIR_MEM_ALLOC_FAILED;
468 }
469
470 while(left >= 2)
471 {
472 elem_id = ptr[0];
473 elem_len = ptr[1];
474 left -= 2;
475 if(elem_len > left)
476 {
477 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700478 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530480 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 return eSIR_FAILURE;
482 }
483 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
484 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
485 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530486 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 tempLen += (elem_len + 2);
488 }
489 left -= elem_len;
490 ptr += (elem_len + 2);
491 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530492 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530494 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 }
496 return eSIR_SUCCESS;
497}
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
499void
500limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
501 tSirMacAddr peerMacAddr,
502 tpAniSSID pSsid,
503 short nStaId,
504 tANI_U8 nKeepAlive,
505 tpPESession psessionEntry,
506 tANI_U8 probeReqP2pIe)
507{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700508 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530509 tSirRetStatus nSirStatus;
510 tANI_U32 cfg, nPayload, nBytes, nStatus;
511 tpSirMacMgmtHdr pMacHdr;
512 tANI_U8 *pFrame;
513 void *pPacket;
514 eHalStatus halstatus;
515 tANI_U32 addnIEPresent;
516 tANI_U32 addnIE1Len=0;
517 tANI_U32 addnIE2Len=0;
518 tANI_U32 addnIE3Len=0;
519 tANI_U16 totalAddnIeLen = 0;
520 tANI_U32 wpsApEnable=0, tmp;
521 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530523 tANI_U8 *pP2pIe = NULL;
524 tANI_U8 noaLen = 0;
525 tANI_U8 total_noaLen = 0;
526 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530528 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700529
530 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
531 {
532 return; // in this case.
533 }
534
535 if(NULL == psessionEntry)
536 {
537 return;
538 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530539
540 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
541 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700542 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530543 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700544 return;
545 }
546
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 // Fill out 'frm', after which we'll just hand the struct off to
548 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530549 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700550
551 // Timestamp to be updated by TFP, below.
552
553 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
555 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700556 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 }
558 else
559 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800560 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
561 if (eSIR_SUCCESS != nSirStatus)
562 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700563 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800564 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530565 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800566 return;
567 }
568 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800569 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700570
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700571 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
572 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700574 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700575
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700576 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
577 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700578
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
581 {
582 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
583 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700584 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 }
586 }
587 else
588 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800589 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700590 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700591
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800592 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700593
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800594 if (wpsApEnable)
595 {
596 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
597 }
598
599 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
600 {
601 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
602 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
603 }
604
605 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
606 {
607 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
608 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
609 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700611
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700612 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
613 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700614
Jeff Johnson295189b2012-06-20 16:38:30 -0700615
616 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700617 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700618
619
620 // N.B. In earlier implementations, the RSN IE would be placed in
621 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
622 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700623 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700624
625 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700626 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700628 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700629 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700631#ifdef WLAN_FEATURE_11AC
632 if(psessionEntry->vhtCapability)
633 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800634 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700635 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
636 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700637 // we do not support multi users yet
638 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700639 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700640 }
641#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700642
643 if ( psessionEntry->pLimStartBssReq )
644 {
645 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700646 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700647 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
648 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 }
650
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700651 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700652
653#if defined(FEATURE_WLAN_WAPI)
654 if( psessionEntry->pLimStartBssReq )
655 {
656 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700657 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 }
659
660#endif // defined(FEATURE_WLAN_WAPI)
661
662
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700663 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 if ( DOT11F_FAILED( nStatus ) )
665 {
666 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700667 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 nStatus );
669 // We'll fall back on the worst case scenario:
670 nPayload = sizeof( tDot11fProbeResponse );
671 }
672 else if ( DOT11F_WARNED( nStatus ) )
673 {
674 limLog( pMac, LOGW, FL("There were warnings while calculating"
675 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700676 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 }
678
679 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
680
681 addnIEPresent = false;
682
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 if( pMac->lim.gpLimRemainOnChanReq )
684 {
685 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
686 }
687 //Only use CFG for non-listen mode. This CFG is not working for concurrency
688 //In listening mode, probe rsp IEs is passed in the message from SME to PE
689 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 {
691
692 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
693 &addnIEPresent) != eSIR_SUCCESS)
694 {
695 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530696 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 return;
698 }
699 }
700
701 if (addnIEPresent)
702 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530703
704 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
705 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 {
707 PELOGE(limLog(pMac, LOGE,
708 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530709 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 return;
711 }
712
713 //Probe rsp IE available
714 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
715 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
716 {
717 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530718 vos_mem_free(addIE);
719 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 return;
721 }
722 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
723 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
724 {
725 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
726 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
727 &addnIE1Len) )
728 {
729 limLog(pMac, LOGP,
730 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530731 vos_mem_free(addIE);
732 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 return;
734 }
735 }
736
737 //Probe rsp IE available
738 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
739 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
740 {
741 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530742 vos_mem_free(addIE);
743 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 return;
745 }
746 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
747 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
748 {
749 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
750 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
751 &addnIE2Len) )
752 {
753 limLog(pMac, LOGP,
754 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530755 vos_mem_free(addIE);
756 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 return;
758 }
759 }
760
761 //Probe rsp IE available
762 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
763 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
764 {
765 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530766 vos_mem_free(addIE);
767 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 return;
769 }
770 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
771 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
772 {
773 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
774 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
775 &addIE[addnIE1Len + addnIE2Len],
776 &addnIE3Len) )
777 {
778 limLog(pMac, LOGP,
779 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530780 vos_mem_free(addIE);
781 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 return;
783 }
784 }
785 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
786
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
788 {
789 limLog(pMac, LOGP,
790 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530791 vos_mem_free(addIE);
792 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 return;
794 }
795 nBytes = nBytes + totalAddnIeLen;
796
797 if (probeReqP2pIe)
798 {
799 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
800 if (pP2pIe != NULL)
801 {
802 //get NoA attribute stream P2P IE
803 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
804 if (noaLen != 0)
805 {
806 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
807 &noaStream[0], noaLen);
808 nBytes = nBytes + total_noaLen;
809 }
810 }
811 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 }
813
814 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
815 ( tANI_U16 )nBytes, ( void** ) &pFrame,
816 ( void** ) &pPacket );
817 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
818 {
819 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700820 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 if ( addIE != NULL )
822 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530823 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530825 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700826 return;
827 }
828
829 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530830 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700831
832 // Next, we fill out the buffer descriptor:
833 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
834 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
835 if ( eSIR_SUCCESS != nSirStatus )
836 {
837 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700838 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 nSirStatus );
840 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
841 ( void* ) pFrame, ( void* ) pPacket );
842 if ( addIE != NULL )
843 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530844 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530846 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 return;
848 }
849
850 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
851
852 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
853
854 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700855 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 nPayload, &nPayload );
857 if ( DOT11F_FAILED( nStatus ) )
858 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700859 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 nStatus );
861 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
862 if ( addIE != NULL )
863 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530864 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530866 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700867 return; // allocated!
868 }
869 else if ( DOT11F_WARNED( nStatus ) )
870 {
871 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800872 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 }
874
875 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
876 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
877
878 pMac->sys.probeRespond++;
879
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 if( pMac->lim.gpLimRemainOnChanReq )
881 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530882 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
884 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700885
886 if ( addnIEPresent )
887 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530888 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 if (noaLen != 0)
891 {
Krunal Soni81b24262013-05-15 17:46:41 -0700892 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 {
894 limLog(pMac, LOGE,
895 FL("Not able to insert NoA because of length constraint"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530896 vos_mem_free(addIE);
897 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -0700898 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
899 ( void* ) pFrame, ( void* ) pPacket );
900 return;
901 }
902 else
903 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530904 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -0700905 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 }
907 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700908
909 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
911 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 )
913 {
914 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
915 }
916
917 // Queue Probe Response frame in high priority WQ
918 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
919 ( tANI_U16 ) nBytes,
920 HAL_TXRX_FRM_802_11_MGMT,
921 ANI_TXDIR_TODS,
922 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
923 limTxComplete, pFrame, txFlag );
924 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
925 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700926 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 //Pkt will be freed up by the callback
928 }
929
930 if ( addIE != NULL )
931 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530932 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 }
934
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530935 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700936 return;
937
938
Jeff Johnson295189b2012-06-20 16:38:30 -0700939} // End limSendProbeRspMgmtFrame.
940
941void
942limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
943 tSirMacAddr peerMacAddr,
944 tSirAddtsReqInfo *pAddTS,
945 tpPESession psessionEntry)
946{
947 tANI_U16 i;
948 tANI_U8 *pFrame;
949 tSirRetStatus nSirStatus;
950 tDot11fAddTSRequest AddTSReq;
951 tDot11fWMMAddTSRequest WMMAddTSReq;
952 tANI_U32 nPayload, nBytes, nStatus;
953 tpSirMacMgmtHdr pMacHdr;
954 void *pPacket;
955#ifdef FEATURE_WLAN_CCX
956 tANI_U32 phyMode;
957#endif
958 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530959 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700960
961 if(NULL == psessionEntry)
962 {
963 return;
964 }
965
966 if ( ! pAddTS->wmeTspecPresent )
967 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530968 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700969
970 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
971 AddTSReq.DialogToken.token = pAddTS->dialogToken;
972 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
973 if ( pAddTS->lleTspecPresent )
974 {
975 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
976 }
977 else
978 {
979 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
980 }
981
982 if ( pAddTS->lleTspecPresent )
983 {
984 AddTSReq.num_WMMTCLAS = 0;
985 AddTSReq.num_TCLAS = pAddTS->numTclas;
986 for ( i = 0; i < pAddTS->numTclas; ++i)
987 {
988 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
989 &AddTSReq.TCLAS[i] );
990 }
991 }
992 else
993 {
994 AddTSReq.num_TCLAS = 0;
995 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
996 for ( i = 0; i < pAddTS->numTclas; ++i)
997 {
998 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
999 &AddTSReq.WMMTCLAS[i] );
1000 }
1001 }
1002
1003 if ( pAddTS->tclasProcPresent )
1004 {
1005 if ( pAddTS->lleTspecPresent )
1006 {
1007 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1008 AddTSReq.TCLASSPROC.present = 1;
1009 }
1010 else
1011 {
1012 AddTSReq.WMMTCLASPROC.version = 1;
1013 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1014 AddTSReq.WMMTCLASPROC.present = 1;
1015 }
1016 }
1017
1018 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1019 if ( DOT11F_FAILED( nStatus ) )
1020 {
1021 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001022 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 nStatus );
1024 // We'll fall back on the worst case scenario:
1025 nPayload = sizeof( tDot11fAddTSRequest );
1026 }
1027 else if ( DOT11F_WARNED( nStatus ) )
1028 {
1029 limLog( pMac, LOGW, FL("There were warnings while calculating"
1030 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001031 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 }
1033 }
1034 else
1035 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301036 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001037
1038 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1039 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1040 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1041
1042 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1043 WMMAddTSReq.StatusCode.statusCode = 0;
1044
1045 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1046#ifdef FEATURE_WLAN_CCX
1047 limGetPhyMode(pMac, &phyMode, psessionEntry);
1048
1049 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1050 {
1051 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1052 }
1053 else
1054 {
1055 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1056 }
1057 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1058#endif
1059 // fillWmeTspecIE
1060
1061 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1062 if ( DOT11F_FAILED( nStatus ) )
1063 {
1064 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001065 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 nStatus );
1067 // We'll fall back on the worst case scenario:
1068 nPayload = sizeof( tDot11fAddTSRequest );
1069 }
1070 else if ( DOT11F_WARNED( nStatus ) )
1071 {
1072 limLog( pMac, LOGW, FL("There were warnings while calculating"
1073 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001074 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 }
1076 }
1077
1078 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1079
1080 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1081 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1082 ( void** ) &pPacket );
1083 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1084 {
1085 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001086 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 return;
1088 }
1089
1090 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301091 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001092
1093 // Next, we fill out the buffer descriptor:
1094 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1095 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1096 if ( eSIR_SUCCESS != nSirStatus )
1097 {
1098 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001099 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 nSirStatus );
1101 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1102 ( void* ) pFrame, ( void* ) pPacket );
1103 return;
1104 }
1105
1106 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1107
1108 #if 0
1109 cfgLen = SIR_MAC_ADDR_LENGTH;
1110 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1111 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1112 {
1113 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001114 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1116 ( void* ) pFrame, ( void* ) pPacket );
1117 return;
1118 }
1119 #endif //TO SUPPORT BT-AMP
1120
1121 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1122
Chet Lanctot186b5732013-03-18 10:26:30 -07001123#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001124 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001125#endif
1126
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 // That done, pack the struct:
1128 if ( ! pAddTS->wmeTspecPresent )
1129 {
1130 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1131 pFrame + sizeof(tSirMacMgmtHdr),
1132 nPayload, &nPayload );
1133 if ( DOT11F_FAILED( nStatus ) )
1134 {
1135 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001136 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 nStatus );
1138 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1139 return; // allocated!
1140 }
1141 else if ( DOT11F_WARNED( nStatus ) )
1142 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001143 limLog( pMac, LOGW, FL("There were warnings while packing "
1144 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 }
1146 }
1147 else
1148 {
1149 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1150 pFrame + sizeof(tSirMacMgmtHdr),
1151 nPayload, &nPayload );
1152 if ( DOT11F_FAILED( nStatus ) )
1153 {
1154 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001155 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001156 nStatus );
1157 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1158 return; // allocated!
1159 }
1160 else if ( DOT11F_WARNED( nStatus ) )
1161 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001162 limLog( pMac, LOGW, FL("There were warnings while packing "
1163 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 }
1165 }
1166
1167 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1168 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1169
1170 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001171 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1172 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 )
1174 {
1175 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1176 }
1177
1178 // Queue Addts Response frame in high priority WQ
1179 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1180 HAL_TXRX_FRM_802_11_MGMT,
1181 ANI_TXDIR_TODS,
1182 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1183 limTxComplete, pFrame, txFlag );
1184 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1185 {
1186 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001187 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 //Pkt will be freed up by the callback
1189 }
1190
1191} // End limSendAddtsReqActionFrame.
1192
Jeff Johnson295189b2012-06-20 16:38:30 -07001193
1194
1195void
1196limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1197 tANI_U16 statusCode,
1198 tANI_U16 aid,
1199 tSirMacAddr peerMacAddr,
1200 tANI_U8 subType,
1201 tpDphHashNode pSta,tpPESession psessionEntry)
1202{
1203 static tDot11fAssocResponse frm;
1204 tANI_U8 *pFrame, *macAddr;
1205 tpSirMacMgmtHdr pMacHdr;
1206 tSirRetStatus nSirStatus;
1207 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1208 tHalBitVal qosMode, wmeMode;
1209 tANI_U32 nPayload, nBytes, nStatus;
1210 void *pPacket;
1211 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301212 tUpdateBeaconParams beaconParams;
1213 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 tANI_U32 addnIEPresent = false;
1215 tANI_U32 addnIELen=0;
1216 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1217 tpSirAssocReq pAssocReq = NULL;
1218
1219 if(NULL == psessionEntry)
1220 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301221 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 return;
1223 }
1224
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301225 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001226
1227 limGetQosMode(psessionEntry, &qosMode);
1228 limGetWmeMode(psessionEntry, &wmeMode);
1229
1230 // An Add TS IE is added only if the AP supports it and the requesting
1231 // STA sent a traffic spec.
1232 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1233
1234 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1235
1236 frm.Status.status = statusCode;
1237
1238 frm.AID.associd = aid | LIM_AID_MASK;
1239
1240 if ( NULL == pSta )
1241 {
1242 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1243 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1244 }
1245 else
1246 {
1247 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1248 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1249 }
1250
Jeff Johnson295189b2012-06-20 16:38:30 -07001251 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1252 {
1253 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1254 {
1255 pAssocReq =
1256 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1258 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1259 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 }
1262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001263
1264 if ( NULL != pSta )
1265 {
1266 if ( eHAL_SET == qosMode )
1267 {
1268 if ( pSta->lleEnabled )
1269 {
1270 lleMode = 1;
1271 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1272 {
1273 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1274
1275// FramesToDo:...
1276// if ( fAddTS )
1277// {
1278// tANI_U8 *pAf = pBody;
1279// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1280// tANI_U32 tlen;
1281// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1282// &tlen, bufLen - frameLen);
1283// } // End if on Add TS.
1284 }
1285 } // End if on .11e enabled in 'pSta'.
1286 } // End if on QOS Mode on.
1287
1288 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1289 {
1290 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1291 {
1292
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001294
1295 if ( pSta->wsmEnabled )
1296 {
1297 PopulateDot11fWMMCaps(&frm.WMMCaps );
1298 }
1299 }
1300 }
1301
1302 if ( pSta->aniPeer )
1303 {
1304 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1305 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1306 {
1307 edcaInclude = 1;
1308 }
1309
1310 } // End if on Airgo peer.
1311
1312 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001313 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001315 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001318
1319#ifdef WLAN_FEATURE_11AC
1320 if( pSta->mlmStaContext.vhtCapability &&
1321 psessionEntry->vhtCapability )
1322 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001323 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001324 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1325 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001326 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001327 }
1328#endif
1329
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 } // End if on non-NULL 'pSta'.
1331
1332
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301333 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001334
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1336 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1337 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001339
1340 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1341 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1342
1343 beaconParams.bssIdx = psessionEntry->bssIdx;
1344
1345 //Send message to HAL about beacon parameter change.
1346 if(beaconParams.paramChangeBitmap)
1347 {
1348 schSetFixedBeaconFields(pMac,psessionEntry);
1349 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1350 }
1351
1352 // Allocate a buffer for this frame:
1353 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1354 if ( DOT11F_FAILED( nStatus ) )
1355 {
1356 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001357 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 nStatus );
1359 return;
1360 }
1361 else if ( DOT11F_WARNED( nStatus ) )
1362 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001363 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001365 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 }
1367
1368 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1369
1370 if ( pAssocReq != NULL )
1371 {
1372 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1373 &addnIEPresent) != eSIR_SUCCESS)
1374 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301375 limLog(pMac, LOGP, FL("Unable to get "
1376 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 return;
1378 }
1379
1380 if (addnIEPresent)
1381 {
1382 //Assoc rsp IE available
1383 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1384 &addnIELen) != eSIR_SUCCESS)
1385 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301386 limLog(pMac, LOGP, FL("Unable to get "
1387 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 return;
1389 }
1390
1391 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1392 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1393 {
1394 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1395 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1396 {
1397 nBytes = nBytes + addnIELen;
1398 }
1399 }
1400 }
1401 }
1402
1403 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1404 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1405 ( void** ) &pPacket );
1406 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1407 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001408 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 return;
1410 }
1411
1412 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301413 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001414
1415 // Next, we fill out the buffer descriptor:
1416 nSirStatus = limPopulateMacHeader( pMac,
1417 pFrame,
1418 SIR_MAC_MGMT_FRAME,
1419 ( LIM_ASSOC == subType ) ?
1420 SIR_MAC_MGMT_ASSOC_RSP :
1421 SIR_MAC_MGMT_REASSOC_RSP,
1422 peerMacAddr,psessionEntry->selfMacAddr);
1423 if ( eSIR_SUCCESS != nSirStatus )
1424 {
1425 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001426 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 nSirStatus );
1428 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1429 ( void* ) pFrame, ( void* ) pPacket );
1430 return;
1431 }
1432
1433 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1434
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1436
1437 nStatus = dot11fPackAssocResponse( pMac, &frm,
1438 pFrame + sizeof( tSirMacMgmtHdr ),
1439 nPayload, &nPayload );
1440 if ( DOT11F_FAILED( nStatus ) )
1441 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301442 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1443 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1445 ( void* ) pFrame, ( void* ) pPacket );
1446 return; // allocated!
1447 }
1448 else if ( DOT11F_WARNED( nStatus ) )
1449 {
1450 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001451 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 }
1453
1454 macAddr = pMacHdr->da;
1455
1456 if (subType == LIM_ASSOC)
1457 {
1458 PELOG1(limLog(pMac, LOG1,
1459 FL("*** Sending Assoc Resp status %d aid %d to "),
1460 statusCode, aid);)
1461 }
1462 else{
1463 PELOG1(limLog(pMac, LOG1,
1464 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1465 statusCode, aid);)
1466 }
1467 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1468
1469 if ( addnIEPresent )
1470 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301471 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 }
1473
1474 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1476 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 )
1478 {
1479 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1480 }
1481
1482 /// Queue Association Response frame in high priority WQ
1483 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1484 HAL_TXRX_FRM_802_11_MGMT,
1485 ANI_TXDIR_TODS,
1486 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1487 limTxComplete, pFrame, txFlag );
1488 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1489 {
1490 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001491 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 nSirStatus);
1493
1494 //Pkt will be freed up by the callback
1495 }
1496
1497 // update the ANI peer station count
1498 //FIXME_PROTECTION : take care of different type of station
1499 // counter inside this function.
1500 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1501
1502} // End limSendAssocRspMgmtFrame.
1503
1504
1505
1506void
1507limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1508 tSirMacAddr peer,
1509 tANI_U16 nStatusCode,
1510 tSirAddtsReqInfo *pAddTS,
1511 tSirMacScheduleIE *pSchedule,
1512 tpPESession psessionEntry)
1513{
1514 tANI_U8 *pFrame;
1515 tpSirMacMgmtHdr pMacHdr;
1516 tDot11fAddTSResponse AddTSRsp;
1517 tDot11fWMMAddTSResponse WMMAddTSRsp;
1518 tSirRetStatus nSirStatus;
1519 tANI_U32 i, nBytes, nPayload, nStatus;
1520 void *pPacket;
1521 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301522 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001523
1524 if(NULL == psessionEntry)
1525 {
1526 return;
1527 }
1528
1529 if ( ! pAddTS->wmeTspecPresent )
1530 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301531 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001532
1533 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1534 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1535 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1536 AddTSRsp.Status.status = nStatusCode;
1537
1538 // The TsDelay information element is only filled in for a specific
1539 // status code:
1540 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1541 {
1542 if ( pAddTS->wsmTspecPresent )
1543 {
1544 AddTSRsp.WMMTSDelay.version = 1;
1545 AddTSRsp.WMMTSDelay.delay = 10;
1546 AddTSRsp.WMMTSDelay.present = 1;
1547 }
1548 else
1549 {
1550 AddTSRsp.TSDelay.delay = 10;
1551 AddTSRsp.TSDelay.present = 1;
1552 }
1553 }
1554
1555 if ( pAddTS->wsmTspecPresent )
1556 {
1557 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1558 }
1559 else
1560 {
1561 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1562 }
1563
1564 if ( pAddTS->wsmTspecPresent )
1565 {
1566 AddTSRsp.num_WMMTCLAS = 0;
1567 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1568 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1569 {
1570 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1571 &AddTSRsp.TCLAS[i] );
1572 }
1573 }
1574 else
1575 {
1576 AddTSRsp.num_TCLAS = 0;
1577 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1578 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1579 {
1580 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1581 &AddTSRsp.WMMTCLAS[i] );
1582 }
1583 }
1584
1585 if ( pAddTS->tclasProcPresent )
1586 {
1587 if ( pAddTS->wsmTspecPresent )
1588 {
1589 AddTSRsp.WMMTCLASPROC.version = 1;
1590 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1591 AddTSRsp.WMMTCLASPROC.present = 1;
1592 }
1593 else
1594 {
1595 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1596 AddTSRsp.TCLASSPROC.present = 1;
1597 }
1598 }
1599
1600 // schedule element is included only if requested in the tspec and we are
1601 // using hcca (or both edca and hcca)
1602 // 11e-D8.0 is inconsistent on whether the schedule element is included
1603 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1604 // pg 46, line 17-18 says something else. So just include it and let the
1605 // sta figure it out
1606 if ((pSchedule != NULL) &&
1607 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1608 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1609 {
1610 if ( pAddTS->wsmTspecPresent )
1611 {
1612 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1613 }
1614 else
1615 {
1616 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1617 }
1618 }
1619
1620 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1621 if ( DOT11F_FAILED( nStatus ) )
1622 {
1623 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001624 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 nStatus );
1626 // We'll fall back on the worst case scenario:
1627 nPayload = sizeof( tDot11fAddTSResponse );
1628 }
1629 else if ( DOT11F_WARNED( nStatus ) )
1630 {
1631 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001632 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001633 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 }
1635 }
1636 else
1637 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301638 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001639
1640 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1641 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1642 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1643 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1644
1645 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1646
1647 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1648 if ( DOT11F_FAILED( nStatus ) )
1649 {
1650 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001651 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 nStatus );
1653 // We'll fall back on the worst case scenario:
1654 nPayload = sizeof( tDot11fWMMAddTSResponse );
1655 }
1656 else if ( DOT11F_WARNED( nStatus ) )
1657 {
1658 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001659 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001660 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 }
1662 }
1663
1664 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1665
1666 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1667 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1668 {
1669 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001670 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 return;
1672 }
1673
1674 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301675 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001676
1677 // Next, we fill out the buffer descriptor:
1678 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1679 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1680 if ( eSIR_SUCCESS != nSirStatus )
1681 {
1682 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001683 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 nSirStatus );
1685 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1686 return; // allocated!
1687 }
1688
1689 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1690
1691
1692 #if 0
1693 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1694 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1695 {
1696 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001697 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1699 return; // allocated!
1700 }
1701 #endif //TO SUPPORT BT-AMP
1702 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1703
Chet Lanctot186b5732013-03-18 10:26:30 -07001704#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001705 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001706#endif
1707
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 // That done, pack the struct:
1709 if ( ! pAddTS->wmeTspecPresent )
1710 {
1711 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1712 pFrame + sizeof( tSirMacMgmtHdr ),
1713 nPayload, &nPayload );
1714 if ( DOT11F_FAILED( nStatus ) )
1715 {
1716 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001717 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 nStatus );
1719 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1720 return;
1721 }
1722 else if ( DOT11F_WARNED( nStatus ) )
1723 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001724 limLog( pMac, LOGW, FL("There were warnings while packing "
1725 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 }
1727 }
1728 else
1729 {
1730 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1731 pFrame + sizeof( tSirMacMgmtHdr ),
1732 nPayload, &nPayload );
1733 if ( DOT11F_FAILED( nStatus ) )
1734 {
1735 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001736 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 nStatus );
1738 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1739 return;
1740 }
1741 else if ( DOT11F_WARNED( nStatus ) )
1742 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001743 limLog( pMac, LOGW, FL("There were warnings while packing "
1744 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 }
1746 }
1747
1748 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1749 nStatusCode );
1750 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1751
1752 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1754 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 )
1756 {
1757 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1758 }
1759
1760 // Queue the frame in high priority WQ:
1761 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1762 HAL_TXRX_FRM_802_11_MGMT,
1763 ANI_TXDIR_TODS,
1764 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1765 limTxComplete, pFrame, txFlag );
1766 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1767 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001768 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 nSirStatus );
1770 //Pkt will be freed up by the callback
1771 }
1772
1773} // End limSendAddtsRspActionFrame.
1774
1775void
1776limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1777 tSirMacAddr peer,
1778 tANI_U8 wmmTspecPresent,
1779 tSirMacTSInfo *pTsinfo,
1780 tSirMacTspecIE *pTspecIe,
1781 tpPESession psessionEntry)
1782{
1783 tANI_U8 *pFrame;
1784 tpSirMacMgmtHdr pMacHdr;
1785 tDot11fDelTS DelTS;
1786 tDot11fWMMDelTS WMMDelTS;
1787 tSirRetStatus nSirStatus;
1788 tANI_U32 nBytes, nPayload, nStatus;
1789 void *pPacket;
1790 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301791 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001792
1793 if(NULL == psessionEntry)
1794 {
1795 return;
1796 }
1797
1798 if ( ! wmmTspecPresent )
1799 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301800 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001801
1802 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1803 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1804 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1805
1806 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1807 if ( DOT11F_FAILED( nStatus ) )
1808 {
1809 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001810 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 nStatus );
1812 // We'll fall back on the worst case scenario:
1813 nPayload = sizeof( tDot11fDelTS );
1814 }
1815 else if ( DOT11F_WARNED( nStatus ) )
1816 {
1817 limLog( pMac, LOGW, FL("There were warnings while calcula"
1818 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001819 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 }
1821 }
1822 else
1823 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301824 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001825
1826 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1827 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1828 WMMDelTS.DialogToken.token = 0;
1829 WMMDelTS.StatusCode.statusCode = 0;
1830 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1831 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1832 if ( DOT11F_FAILED( nStatus ) )
1833 {
1834 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001835 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 nStatus );
1837 // We'll fall back on the worst case scenario:
1838 nPayload = sizeof( tDot11fDelTS );
1839 }
1840 else if ( DOT11F_WARNED( nStatus ) )
1841 {
1842 limLog( pMac, LOGW, FL("There were warnings while calcula"
1843 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001844 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 }
1846 }
1847
1848 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1849
1850 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1851 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1852 {
1853 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001854 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 return;
1856 }
1857
1858 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301859 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001860
1861 // Next, we fill out the buffer descriptor:
1862 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1863 SIR_MAC_MGMT_ACTION, peer,
1864 psessionEntry->selfMacAddr);
1865 if ( eSIR_SUCCESS != nSirStatus )
1866 {
1867 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001868 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 nSirStatus );
1870 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1871 return; // allocated!
1872 }
1873
1874 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1875
1876 #if 0
1877
1878 cfgLen = SIR_MAC_ADDR_LENGTH;
1879 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1880 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1881 {
1882 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001883 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1885 return; // allocated!
1886 }
1887 #endif //TO SUPPORT BT-AMP
1888 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1889
Chet Lanctot186b5732013-03-18 10:26:30 -07001890#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001891 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001892#endif
1893
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 // That done, pack the struct:
1895 if ( !wmmTspecPresent )
1896 {
1897 nStatus = dot11fPackDelTS( pMac, &DelTS,
1898 pFrame + sizeof( tSirMacMgmtHdr ),
1899 nPayload, &nPayload );
1900 if ( DOT11F_FAILED( nStatus ) )
1901 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001902 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 nStatus );
1904 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1905 return; // allocated!
1906 }
1907 else if ( DOT11F_WARNED( nStatus ) )
1908 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001909 limLog( pMac, LOGW, FL("There were warnings while packing "
1910 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 }
1912 }
1913 else
1914 {
1915 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1916 pFrame + sizeof( tSirMacMgmtHdr ),
1917 nPayload, &nPayload );
1918 if ( DOT11F_FAILED( nStatus ) )
1919 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001920 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 nStatus );
1922 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1923 return; // allocated!
1924 }
1925 else if ( DOT11F_WARNED( nStatus ) )
1926 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001927 limLog( pMac, LOGW, FL("There were warnings while packing "
1928 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 }
1930 }
1931
1932 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1933 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1934
1935 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001936 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1937 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 )
1939 {
1940 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1941 }
1942
1943 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1944 HAL_TXRX_FRM_802_11_MGMT,
1945 ANI_TXDIR_TODS,
1946 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1947 limTxComplete, pFrame, txFlag );
1948 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1949 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001950 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 nSirStatus );
1952 //Pkt will be freed up by the callback
1953 }
1954
1955} // End limSendDeltsReqActionFrame.
1956
1957void
1958limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1959 tLimMlmAssocReq *pMlmAssocReq,
1960 tpPESession psessionEntry)
1961{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001962 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 tANI_U16 caps;
1964 tANI_U8 *pFrame;
1965 tSirRetStatus nSirStatus;
1966 tLimMlmAssocCnf mlmAssocCnf;
1967 tANI_U32 nBytes, nPayload, nStatus;
1968 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1969 void *pPacket;
1970 eHalStatus halstatus;
1971 tANI_U16 nAddIELen;
1972 tANI_U8 *pAddIE;
1973 tANI_U8 *wpsIe = NULL;
1974#if defined WLAN_FEATURE_VOWIFI
1975 tANI_U8 PowerCapsPopulated = FALSE;
1976#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301977 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001978
1979 if(NULL == psessionEntry)
1980 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301981 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001982 return;
1983 }
1984
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 /* check this early to avoid unncessary operation */
1986 if(NULL == psessionEntry->pLimJoinReq)
1987 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301988 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 return;
1990 }
1991 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
1992 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
1993
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301994 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
1995 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001996 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301997 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001998 return;
1999 }
2000
2001
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302002 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002003
2004 caps = pMlmAssocReq->capabilityInfo;
2005 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2006 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2007#if defined(FEATURE_WLAN_WAPI)
2008 /* CR: 262463 :
2009 According to WAPI standard:
2010 7.3.1.4 Capability Information field
2011 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2012 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2013 Reassociation management frames. */
2014 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2015 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2016#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002017 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002018
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002019 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2020 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002022 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002023
2024 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2025 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2026
2027 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2028 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2029
2030 // We prefer .11e asociations:
2031 if ( fQosEnabled ) fWmeEnabled = false;
2032
2033 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2034 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2035
2036 if ( psessionEntry->lim11hEnable &&
2037 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2038 {
2039#if defined WLAN_FEATURE_VOWIFI
2040 PowerCapsPopulated = TRUE;
2041
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002042 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002043#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002044 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002045
2046 }
2047
2048#if defined WLAN_FEATURE_VOWIFI
2049 if( pMac->rrm.rrmPEContext.rrmEnable &&
2050 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2051 {
2052 if (PowerCapsPopulated == FALSE)
2053 {
2054 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002055 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 }
2057 }
2058#endif
2059
2060 if ( fQosEnabled &&
2061 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002062 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
2064 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002065 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002066
2067#if defined WLAN_FEATURE_VOWIFI
2068 if( pMac->rrm.rrmPEContext.rrmEnable &&
2069 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2070 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002071 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 }
2073#endif
2074 // The join request *should* contain zero or one of the WPA and RSN
2075 // IEs. The payload send along with the request is a
2076 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2077
2078 // typedef struct sSirRSNie
2079 // {
2080 // tANI_U16 length;
2081 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2082 // } tSirRSNie, *tpSirRSNie;
2083
2084 // So, we should be able to make the following two calls harmlessly,
2085 // since they do nothing if they don't find the given IE in the
2086 // bytestream with which they're provided.
2087
2088 // The net effect of this will be to faithfully transmit whatever
2089 // security IE is in the join request.
2090
2091 // *However*, if we're associating for the purpose of WPS
2092 // enrollment, and we've been configured to indicate that by
2093 // eliding the WPA or RSN IE, we just skip this:
2094 if( nAddIELen && pAddIE )
2095 {
2096 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2097 }
2098 if ( NULL == wpsIe )
2099 {
2100 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002101 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002103 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002104#if defined(FEATURE_WLAN_WAPI)
2105 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002106 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002107#endif // defined(FEATURE_WLAN_WAPI)
2108 }
2109
2110 // include WME EDCA IE as well
2111 if ( fWmeEnabled )
2112 {
2113 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2114 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002115 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 }
2117
2118 if ( fWsmEnabled &&
2119 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2120 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002121 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 }
2123 }
2124
2125 //Populate HT IEs, when operating in 11n or Taurus modes AND
2126 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002127 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 pMac->lim.htCapabilityPresentInBeacon)
2129 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002130 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002131#ifdef DISABLE_GF_FOR_INTEROP
2132
2133 /*
2134 * To resolve the interop problem with Broadcom AP,
2135 * where TQ STA could not pass traffic with GF enabled,
2136 * TQ STA will do Greenfield only with TQ AP, for
2137 * everybody else it will be turned off.
2138 */
2139
2140 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2141 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302142 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2143 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002144 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 }
2146#endif
2147
2148 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002149#ifdef WLAN_FEATURE_11AC
2150 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002151 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002152 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002153 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002154 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2155 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002156 }
2157#endif
2158
Jeff Johnson295189b2012-06-20 16:38:30 -07002159
2160#if defined WLAN_FEATURE_VOWIFI_11R
2161 if (psessionEntry->pLimJoinReq->is11Rconnection)
2162 {
2163#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002164 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2166 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2167 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2168#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302169 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2170 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302172 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 {
2174 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302175 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 }
2177#endif
2178
2179#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302180 /* For CCX Associations fill the CCX IEs */
2181 if (psessionEntry->isCCXconnection &&
2182 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002184#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002185 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002186#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302187 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 }
2189#endif
2190
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002191 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 if ( DOT11F_FAILED( nStatus ) )
2193 {
2194 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002195 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 nStatus );
2197 // We'll fall back on the worst case scenario:
2198 nPayload = sizeof( tDot11fAssocRequest );
2199 }
2200 else if ( DOT11F_WARNED( nStatus ) )
2201 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002202 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002204 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 }
2206
2207 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2208
2209 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2210 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2211 ( void** ) &pPacket );
2212 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2213 {
2214 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002215 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002216
2217 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002218 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002219
2220
2221 /* Update PE session id*/
2222 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2223
2224 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2225
2226 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2227 ( void* ) pFrame, ( void* ) pPacket );
2228
2229 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2230 ( tANI_U32* ) &mlmAssocCnf);
2231
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302232 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 return;
2234 }
2235
2236 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302237 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002238
2239 // Next, we fill out the buffer descriptor:
2240 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2241 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2242 if ( eSIR_SUCCESS != nSirStatus )
2243 {
2244 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002245 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 nSirStatus );
2247 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302248 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 return;
2250 }
2251
2252
Abhishek Singh57aebef2014-02-03 18:47:44 +05302253 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002254 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 sizeof(tSirMacMgmtHdr),
2256 nPayload, &nPayload );
2257 if ( DOT11F_FAILED( nStatus ) )
2258 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302259 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002260 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002261 nStatus );
2262 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2263 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302264 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 return;
2266 }
2267 else if ( DOT11F_WARNED( nStatus ) )
2268 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302269 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2270 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 }
2272
2273 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002274 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 nBytes );)
2276 // limPrintMacAddr( pMac, bssid, LOG1 );
2277
2278 if( psessionEntry->assocReq != NULL )
2279 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302280 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 psessionEntry->assocReq = NULL;
2282 }
2283
2284 if( nAddIELen )
2285 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302286 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2287 pAddIE,
2288 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 nPayload += nAddIELen;
2290 }
2291
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302292 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2293 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302295 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2296 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 }
2298 else
2299 {
2300 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302301 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 psessionEntry->assocReqLen = nPayload;
2303 }
2304
2305 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2307 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 )
2309 {
2310 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2311 }
2312
Ganesh K08bce952012-12-13 15:04:41 -08002313 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2314 {
2315 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2318 HAL_TXRX_FRM_802_11_MGMT,
2319 ANI_TXDIR_TODS,
2320 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2321 limTxComplete, pFrame, txFlag );
2322 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2323 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002324 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 halstatus );
2326 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302327 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 return;
2329 }
2330
2331 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302332 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002333 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302334 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002335 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002336} // End limSendAssocReqMgmtFrame
2337
2338
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002339#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002340/*------------------------------------------------------------------------------------
2341 *
2342 * Send Reassoc Req with FTIEs.
2343 *
2344 *-----------------------------------------------------------------------------------
2345 */
2346void
2347limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2348 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2349{
2350 static tDot11fReAssocRequest frm;
2351 tANI_U16 caps;
2352 tANI_U8 *pFrame;
2353 tSirRetStatus nSirStatus;
2354 tANI_U32 nBytes, nPayload, nStatus;
2355 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2356 void *pPacket;
2357 eHalStatus halstatus;
2358#if defined WLAN_FEATURE_VOWIFI
2359 tANI_U8 PowerCapsPopulated = FALSE;
2360#endif
2361 tANI_U16 ft_ies_length = 0;
2362 tANI_U8 *pBody;
2363 tANI_U16 nAddIELen;
2364 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002365#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 tANI_U8 *wpsIe = NULL;
2367#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302368 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002369
2370 if (NULL == psessionEntry)
2371 {
2372 return;
2373 }
2374
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 /* check this early to avoid unncessary operation */
2376 if(NULL == psessionEntry->pLimReAssocReq)
2377 {
2378 return;
2379 }
2380 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2381 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002382 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2383 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002384
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302385 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002386
2387 caps = pMlmReassocReq->capabilityInfo;
2388 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2389 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2390#if defined(FEATURE_WLAN_WAPI)
2391 /* CR: 262463 :
2392 According to WAPI standard:
2393 7.3.1.4 Capability Information field
2394 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2395 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2396 Reassociation management frames. */
2397 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2398 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2399#endif
2400 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2401
2402 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2403
2404 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302405 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2407
2408 PopulateDot11fSSID2( pMac, &frm.SSID );
2409 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2410 &frm.SuppRates,psessionEntry);
2411
2412 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2413 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2414
2415 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2416 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2417
2418 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2419 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2420
2421 if ( psessionEntry->lim11hEnable &&
2422 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2423 {
2424#if defined WLAN_FEATURE_VOWIFI
2425 PowerCapsPopulated = TRUE;
2426
2427 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2428 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2429#endif
2430 }
2431
2432#if defined WLAN_FEATURE_VOWIFI
2433 if( pMac->rrm.rrmPEContext.rrmEnable &&
2434 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2435 {
2436 if (PowerCapsPopulated == FALSE)
2437 {
2438 PowerCapsPopulated = TRUE;
2439 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2440 }
2441 }
2442#endif
2443
2444 if ( fQosEnabled &&
2445 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2446 {
2447 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2448 }
2449
2450 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2451 &frm.ExtSuppRates, psessionEntry );
2452
2453#if defined WLAN_FEATURE_VOWIFI
2454 if( pMac->rrm.rrmPEContext.rrmEnable &&
2455 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2456 {
2457 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2458 }
2459#endif
2460
2461 // Ideally this should be enabled for 11r also. But 11r does
2462 // not follow the usual norm of using the Opaque object
2463 // for rsnie and fties. Instead we just add
2464 // the rsnie and fties at the end of the pack routine for 11r.
2465 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002466#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 //
2468 // The join request *should* contain zero or one of the WPA and RSN
2469 // IEs. The payload send along with the request is a
2470 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2471
2472 // typedef struct sSirRSNie
2473 // {
2474 // tANI_U16 length;
2475 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2476 // } tSirRSNie, *tpSirRSNie;
2477
2478 // So, we should be able to make the following two calls harmlessly,
2479 // since they do nothing if they don't find the given IE in the
2480 // bytestream with which they're provided.
2481
2482 // The net effect of this will be to faithfully transmit whatever
2483 // security IE is in the join request.
2484
2485 // *However*, if we're associating for the purpose of WPS
2486 // enrollment, and we've been configured to indicate that by
2487 // eliding the WPA or RSN IE, we just skip this:
2488 if (!psessionEntry->is11Rconnection)
2489 {
2490 if( nAddIELen && pAddIE )
2491 {
2492 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2493 }
2494 if ( NULL == wpsIe )
2495 {
2496 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2497 &frm.RSNOpaque );
2498 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2499 &frm.WPAOpaque );
2500 }
2501
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002502#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302503 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002504 {
2505 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2506 &frm.CCXCckmOpaque );
2507 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002508#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 }
2510
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002511#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302513 if (psessionEntry->isCCXconnection &&
2514 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002516#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002518#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302519 PopulateDot11fCCXVersion(&frm.CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302521#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002522#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002523
2524 // include WME EDCA IE as well
2525 if ( fWmeEnabled )
2526 {
2527 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2528 {
2529 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2530 }
2531
2532 if ( fWsmEnabled &&
2533 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2534 {
2535 PopulateDot11fWMMCaps( &frm.WMMCaps );
2536 }
2537#ifdef FEATURE_WLAN_CCX
2538 if (psessionEntry->isCCXconnection)
2539 {
2540 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2541
2542 // Populate the TSRS IE if TSPEC is included in the reassoc request
2543 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2544 {
2545 tANI_U32 phyMode;
2546 tSirMacCCXTSRSIE tsrsIE;
2547 limGetPhyMode(pMac, &phyMode, psessionEntry);
2548
2549 tsrsIE.tsid = 0;
2550 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2551 {
2552 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2553 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302554 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 {
2556 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2557 }
2558 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2559 }
2560 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302561#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 }
2563
Jeff Johnsone7245742012-09-05 17:12:55 -07002564 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 pMac->lim.htCapabilityPresentInBeacon)
2566 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002567 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 }
2569
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002570#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302571 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2572#if defined FEATURE_WLAN_CCX
2573 && !psessionEntry->isCCXconnection
2574#endif
2575 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002576 {
2577 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2578 }
2579#endif
2580
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002581#ifdef WLAN_FEATURE_11AC
2582 if ( psessionEntry->vhtCapability &&
2583 psessionEntry->vhtCapabilityPresentInBeacon)
2584 {
2585 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2586 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
2587 PopulateDot11fExtCap( pMac, &frm.ExtCap);
2588 }
2589#endif
2590
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2592 if ( DOT11F_FAILED( nStatus ) )
2593 {
2594 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002595 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 nStatus );
2597 // We'll fall back on the worst case scenario:
2598 nPayload = sizeof( tDot11fReAssocRequest );
2599 }
2600 else if ( DOT11F_WARNED( nStatus ) )
2601 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002602 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002604 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 }
2606
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002607 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002608
2609#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002610 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2612#endif
2613
2614#if defined WLAN_FEATURE_VOWIFI_11R
2615 if (psessionEntry->is11Rconnection)
2616 {
2617 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2618 }
2619#endif
2620
2621 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2622 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2623 ( void** ) &pPacket );
2624 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2625 {
2626 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002627 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002629 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 goto end;
2631 }
2632
2633 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302634 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002635
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002636#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002637 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002638#endif
2639 // Next, we fill out the buffer descriptor:
2640 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2641 SIR_MAC_MGMT_REASSOC_REQ,
2642 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2643 if ( eSIR_SUCCESS != nSirStatus )
2644 {
2645 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002646 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 nSirStatus );
2648 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2649 goto end;
2650 }
2651
2652
2653 // That done, pack the ReAssoc Request:
2654 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2655 sizeof(tSirMacMgmtHdr),
2656 nPayload, &nPayload );
2657 if ( DOT11F_FAILED( nStatus ) )
2658 {
2659 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002660 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 nStatus );
2662 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2663 goto end;
2664 }
2665 else if ( DOT11F_WARNED( nStatus ) )
2666 {
2667 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002668 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 }
2670
2671 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002672 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 nBytes, nPayload );)
2674 if( psessionEntry->assocReq != NULL )
2675 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302676 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 psessionEntry->assocReq = NULL;
2678 }
2679
2680 if( nAddIELen )
2681 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302682 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2683 pAddIE,
2684 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 nPayload += nAddIELen;
2686 }
2687
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302688 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2689 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 {
2691 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002692 }
2693 else
2694 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302696 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002699
2700 if (psessionEntry->is11Rconnection)
2701 {
2702 {
2703 int i = 0;
2704
2705 pBody = pFrame + nBytes;
2706 for (i=0; i<ft_ies_length; i++)
2707 {
2708 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2709 pBody++;
2710 }
2711 }
2712 }
2713
2714#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002715 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2716 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 (tANI_U8 *)pFrame,
2718 (nBytes + ft_ies_length));)
2719#endif
2720
2721
2722 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2724 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 )
2726 {
2727 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2728 }
2729
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002730 if( NULL != psessionEntry->assocReq )
2731 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302732 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002733 psessionEntry->assocReq = NULL;
2734 }
2735
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302736 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2737 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002738 {
2739 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002740 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002741 }
2742 else
2743 {
2744 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302745 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2746 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002747 psessionEntry->assocReqLen = (ft_ies_length);
2748 }
2749
2750
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2752 HAL_TXRX_FRM_802_11_MGMT,
2753 ANI_TXDIR_TODS,
2754 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2755 limTxComplete, pFrame, txFlag );
2756 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2757 {
2758 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002759 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 nSirStatus );
2761 //Pkt will be freed up by the callback
2762 goto end;
2763 }
2764
2765end:
2766 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302767 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 psessionEntry->pLimMlmReassocReq = NULL;
2769
2770}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002771
2772void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2773 tLimMlmReassocReq *pMlmReassocReq,
2774 tpPESession psessionEntry)
2775{
2776 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2777 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2778 if(NULL == pTmpMlmReassocReq)
2779 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302780 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2781 if ( NULL == pTmpMlmReassocReq ) goto end;
2782 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2783 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002784 }
2785
2786 // Prepare and send Reassociation request frame
2787 // start reassoc timer.
2788 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2789 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002790 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002791 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2792 != TX_SUCCESS)
2793 {
2794 // Could not start reassoc failure timer.
2795 // Log error
2796 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002797 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002798 // Return Reassoc confirm with
2799 // Resources Unavailable
2800 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2801 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2802 goto end;
2803 }
2804
2805 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2806 return;
2807
2808end:
2809 // Free up buffer allocated for reassocReq
2810 if (pMlmReassocReq != NULL)
2811 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302812 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002813 pMlmReassocReq = NULL;
2814 }
2815 if (pTmpMlmReassocReq != NULL)
2816 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302817 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002818 pTmpMlmReassocReq = NULL;
2819 }
2820 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2821 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2822 /* Update PE sessio Id*/
2823 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2824
2825 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2826}
2827
Jeff Johnson295189b2012-06-20 16:38:30 -07002828#endif /* WLAN_FEATURE_VOWIFI_11R */
2829
2830
2831void
2832limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2833 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2834{
2835 static tDot11fReAssocRequest frm;
2836 tANI_U16 caps;
2837 tANI_U8 *pFrame;
2838 tSirRetStatus nSirStatus;
2839 tANI_U32 nBytes, nPayload, nStatus;
2840 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2841 void *pPacket;
2842 eHalStatus halstatus;
2843 tANI_U16 nAddIELen;
2844 tANI_U8 *pAddIE;
2845 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302846 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002847#if defined WLAN_FEATURE_VOWIFI
2848 tANI_U8 PowerCapsPopulated = FALSE;
2849#endif
2850
2851 if(NULL == psessionEntry)
2852 {
2853 return;
2854 }
2855
2856 /* check this early to avoid unncessary operation */
2857 if(NULL == psessionEntry->pLimReAssocReq)
2858 {
2859 return;
2860 }
2861 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2862 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2863
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302864 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002865
2866 caps = pMlmReassocReq->capabilityInfo;
2867 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2868 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2869#if defined(FEATURE_WLAN_WAPI)
2870 /* CR: 262463 :
2871 According to WAPI standard:
2872 7.3.1.4 Capability Information field
2873 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2874 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2875 Reassociation management frames. */
2876 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2877 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2878#endif
2879 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2880
2881 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2882
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302883 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2884 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002885
2886 PopulateDot11fSSID2( pMac, &frm.SSID );
2887 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2888 &frm.SuppRates,psessionEntry);
2889
2890 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2891 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2892
2893 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2894 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2895
2896 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2897 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2898
2899
2900 if ( psessionEntry->lim11hEnable &&
2901 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2902 {
2903#if defined WLAN_FEATURE_VOWIFI
2904 PowerCapsPopulated = TRUE;
2905 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2906 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2907#endif
2908 }
2909
2910#if defined WLAN_FEATURE_VOWIFI
2911 if( pMac->rrm.rrmPEContext.rrmEnable &&
2912 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2913 {
2914 if (PowerCapsPopulated == FALSE)
2915 {
2916 PowerCapsPopulated = TRUE;
2917 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2918 }
2919 }
2920#endif
2921
2922 if ( fQosEnabled &&
2923 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2924 {
2925 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2926 }
2927
2928 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2929 &frm.ExtSuppRates, psessionEntry );
2930
2931#if defined WLAN_FEATURE_VOWIFI
2932 if( pMac->rrm.rrmPEContext.rrmEnable &&
2933 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2934 {
2935 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2936 }
2937#endif
2938 // The join request *should* contain zero or one of the WPA and RSN
2939 // IEs. The payload send along with the request is a
2940 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2941
2942 // typedef struct sSirRSNie
2943 // {
2944 // tANI_U16 length;
2945 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2946 // } tSirRSNie, *tpSirRSNie;
2947
2948 // So, we should be able to make the following two calls harmlessly,
2949 // since they do nothing if they don't find the given IE in the
2950 // bytestream with which they're provided.
2951
2952 // The net effect of this will be to faithfully transmit whatever
2953 // security IE is in the join request.
2954
2955 // *However*, if we're associating for the purpose of WPS
2956 // enrollment, and we've been configured to indicate that by
2957 // eliding the WPA or RSN IE, we just skip this:
2958 if( nAddIELen && pAddIE )
2959 {
2960 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2961 }
2962 if ( NULL == wpsIe )
2963 {
2964 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2965 &frm.RSNOpaque );
2966 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2967 &frm.WPAOpaque );
2968#if defined(FEATURE_WLAN_WAPI)
2969 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2970 &frm.WAPIOpaque );
2971#endif // defined(FEATURE_WLAN_WAPI)
2972 }
2973
2974 // include WME EDCA IE as well
2975 if ( fWmeEnabled )
2976 {
2977 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2978 {
2979 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2980 }
2981
2982 if ( fWsmEnabled &&
2983 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2984 {
2985 PopulateDot11fWMMCaps( &frm.WMMCaps );
2986 }
2987 }
2988
Jeff Johnsone7245742012-09-05 17:12:55 -07002989 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 pMac->lim.htCapabilityPresentInBeacon)
2991 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002992 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002994#ifdef WLAN_FEATURE_11AC
2995 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002996 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002997 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002998 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002999 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07003000 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003001 }
3002#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003003
3004 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3005 if ( DOT11F_FAILED( nStatus ) )
3006 {
3007 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003008 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 nStatus );
3010 // We'll fall back on the worst case scenario:
3011 nPayload = sizeof( tDot11fReAssocRequest );
3012 }
3013 else if ( DOT11F_WARNED( nStatus ) )
3014 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003015 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003016 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003017 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 }
3019
3020 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3021
3022 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3023 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3024 ( void** ) &pPacket );
3025 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3026 {
3027 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003028 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003030 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 goto end;
3032 }
3033
3034 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303035 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003036
3037 // Next, we fill out the buffer descriptor:
3038 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3039 SIR_MAC_MGMT_REASSOC_REQ,
3040 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3041 if ( eSIR_SUCCESS != nSirStatus )
3042 {
3043 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003044 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 nSirStatus );
3046 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3047 goto end;
3048 }
3049
3050
3051 // That done, pack the Probe Request:
3052 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3053 sizeof(tSirMacMgmtHdr),
3054 nPayload, &nPayload );
3055 if ( DOT11F_FAILED( nStatus ) )
3056 {
3057 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003058 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 nStatus );
3060 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3061 goto end;
3062 }
3063 else if ( DOT11F_WARNED( nStatus ) )
3064 {
3065 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003066 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 }
3068
3069 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003070 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 nBytes );)
3072
3073 if( psessionEntry->assocReq != NULL )
3074 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303075 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 psessionEntry->assocReq = NULL;
3077 }
3078
3079 if( nAddIELen )
3080 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303081 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3082 pAddIE,
3083 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 nPayload += nAddIELen;
3085 }
3086
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303087 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3088 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 {
3090 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003091 }
3092 else
3093 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303095 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003098
3099 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3101 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 )
3103 {
3104 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3105 }
3106
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003107 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003108 {
3109 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3110 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003111
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3113 HAL_TXRX_FRM_802_11_MGMT,
3114 ANI_TXDIR_TODS,
3115 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3116 limTxComplete, pFrame, txFlag );
3117 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3118 {
3119 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003120 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 nSirStatus );
3122 //Pkt will be freed up by the callback
3123 goto end;
3124 }
3125
3126end:
3127 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303128 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 psessionEntry->pLimMlmReassocReq = NULL;
3130
3131} // limSendReassocReqMgmtFrame
3132
3133/**
3134 * \brief Send an Authentication frame
3135 *
3136 *
3137 * \param pMac Pointer to Global MAC structure
3138 *
3139 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3140 * to be sent
3141 *
3142 * \param peerMacAddr MAC address of the peer entity to which Authentication
3143 * frame is destined
3144 *
3145 * \param wepBit Indicates whether wep bit to be set in FC while sending
3146 * Authentication frame3
3147 *
3148 *
3149 * This function is called by limProcessMlmMessages(). Authentication frame
3150 * is formatted and sent when this function is called.
3151 *
3152 *
3153 */
3154
3155void
3156limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3157 tpSirMacAuthFrameBody pAuthFrameBody,
3158 tSirMacAddr peerMacAddr,
3159 tANI_U8 wepBit,
3160 tpPESession psessionEntry
3161 )
3162{
3163 tANI_U8 *pFrame, *pBody;
3164 tANI_U32 frameLen = 0, bodyLen = 0;
3165 tpSirMacMgmtHdr pMacHdr;
3166 tANI_U16 i;
3167 void *pPacket;
3168 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303169 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003170
3171 if(NULL == psessionEntry)
3172 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303173 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 return;
3175 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303176
3177 limLog(pMac, LOG1,
3178 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3179 pAuthFrameBody->authTransactionSeqNumber,
3180 pAuthFrameBody->authStatusCode,
3181 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3182 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003183 if (wepBit == LIM_WEP_IN_FC)
3184 {
3185 /// Auth frame3 to be sent with encrypted framebody
3186 /**
3187 * Allocate buffer for Authenticaton frame of size equal
3188 * to management frame header length plus 2 bytes each for
3189 * auth algorithm number, transaction number, status code,
3190 * 128 bytes for challenge text and 4 bytes each for
3191 * IV & ICV.
3192 */
3193
3194 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3195
3196 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3197 } // if (wepBit == LIM_WEP_IN_FC)
3198 else
3199 {
3200 switch (pAuthFrameBody->authTransactionSeqNumber)
3201 {
3202 case SIR_MAC_AUTH_FRAME_1:
3203 /**
3204 * Allocate buffer for Authenticaton frame of size
3205 * equal to management frame header length plus 2 bytes
3206 * each for auth algorithm number, transaction number
3207 * and status code.
3208 */
3209
3210 frameLen = sizeof(tSirMacMgmtHdr) +
3211 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3212 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3213
3214#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003215 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3216 {
3217 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003219 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003220 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003221 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003223 else
3224 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303225 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3226 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003227 frameLen += (2+SIR_MDIE_SIZE);
3228 }
3229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003230#endif
3231 break;
3232
3233 case SIR_MAC_AUTH_FRAME_2:
3234 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3235 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3236 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3237 {
3238 /**
3239 * Allocate buffer for Authenticaton frame of size
3240 * equal to management frame header length plus
3241 * 2 bytes each for auth algorithm number,
3242 * transaction number and status code.
3243 */
3244
3245 frameLen = sizeof(tSirMacMgmtHdr) +
3246 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3247 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3248 }
3249 else
3250 {
3251 // Shared Key algorithm with challenge text
3252 // to be sent
3253 /**
3254 * Allocate buffer for Authenticaton frame of size
3255 * equal to management frame header length plus
3256 * 2 bytes each for auth algorithm number,
3257 * transaction number, status code and 128 bytes
3258 * for challenge text.
3259 */
3260
3261 frameLen = sizeof(tSirMacMgmtHdr) +
3262 sizeof(tSirMacAuthFrame);
3263 bodyLen = sizeof(tSirMacAuthFrameBody);
3264 }
3265
3266 break;
3267
3268 case SIR_MAC_AUTH_FRAME_3:
3269 /// Auth frame3 to be sent without encrypted framebody
3270 /**
3271 * Allocate buffer for Authenticaton frame of size equal
3272 * to management frame header length plus 2 bytes each
3273 * for auth algorithm number, transaction number and
3274 * status code.
3275 */
3276
3277 frameLen = sizeof(tSirMacMgmtHdr) +
3278 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3279 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3280
3281 break;
3282
3283 case SIR_MAC_AUTH_FRAME_4:
3284 /**
3285 * Allocate buffer for Authenticaton frame of size equal
3286 * to management frame header length plus 2 bytes each
3287 * for auth algorithm number, transaction number and
3288 * status code.
3289 */
3290
3291 frameLen = sizeof(tSirMacMgmtHdr) +
3292 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3293 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3294
3295 break;
3296 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3297 } // end if (wepBit == LIM_WEP_IN_FC)
3298
3299
3300 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3301
3302 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3303 {
3304 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003305 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003306
3307 return;
3308 }
3309
3310 for (i = 0; i < frameLen; i++)
3311 pFrame[i] = 0;
3312
3313 // Prepare BD
3314 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3315 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3316 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303317 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3318 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3320 return;
3321 }
3322
3323 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3324 pMacHdr->fc.wep = wepBit;
3325
3326 // Prepare BSSId
3327 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3328 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303329 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3330 (tANI_U8 *) psessionEntry->bssId,
3331 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 }
3333
3334 /// Prepare Authentication frame body
3335 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3336
3337 if (wepBit == LIM_WEP_IN_FC)
3338 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303339 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003340
3341 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303342 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303344 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3345 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003346
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 }
3348 else
3349 {
3350 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3351 pBody += sizeof(tANI_U16);
3352 bodyLen -= sizeof(tANI_U16);
3353
3354 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3355 pBody += sizeof(tANI_U16);
3356 bodyLen -= sizeof(tANI_U16);
3357
3358 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3359 pBody += sizeof(tANI_U16);
3360 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003361 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3362 sizeof (pAuthFrameBody->length) +
3363 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303364 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003365
3366#if defined WLAN_FEATURE_VOWIFI_11R
3367 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3368 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3369 {
3370
3371 {
3372 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3374 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003375#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3377 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3378 (tANI_U8 *)pBody,
3379 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003380#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003381 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3382 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003383 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3384 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003385 }
3386 }
3387 else
3388 {
3389 /* MDID attr is 54*/
3390 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003392 *pBody = SIR_MDIE_SIZE;
3393 pBody++;
3394 for(i=0;i<SIR_MDIE_SIZE;i++)
3395 {
3396 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3397 pBody++;
3398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 }
3400 }
3401 }
3402#endif
3403
3404 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303405 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 pAuthFrameBody->authTransactionSeqNumber,
3407 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303408 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3409 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 }
3411 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3412
3413 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3415 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003416#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303417 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003418 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3419#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 )
3421 {
3422 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3423 }
3424
Ganesh K08bce952012-12-13 15:04:41 -08003425 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3426 {
3427 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3428 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003429
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 /// Queue Authentication frame in high priority WQ
3431 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3432 HAL_TXRX_FRM_802_11_MGMT,
3433 ANI_TXDIR_TODS,
3434 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3435 limTxComplete, pFrame, txFlag );
3436 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3437 {
3438 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003439 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 halstatus);
3441
3442 //Pkt will be freed up by the callback
3443 }
3444
3445 return;
3446} /*** end limSendAuthMgmtFrame() ***/
3447
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003448eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3449{
3450 tANI_U16 aid;
3451 tpDphHashNode pStaDs;
3452 tLimMlmDeauthReq *pMlmDeauthReq;
3453 tLimMlmDeauthCnf mlmDeauthCnf;
3454 tpPESession psessionEntry;
3455
3456 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3457 if (pMlmDeauthReq)
3458 {
3459 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3460 {
3461 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3462 }
3463
3464 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3465 {
3466
3467 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003468 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003469 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3470 goto end;
3471 }
3472
3473 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3474 if (pStaDs == NULL)
3475 {
3476 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3477 goto end;
3478 }
3479
3480
3481 /// Receive path cleanup with dummy packet
3482 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3483 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303484 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003485 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3486 }
3487 return eHAL_STATUS_SUCCESS;
3488end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303489 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003490 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3491 sizeof(tSirMacAddr));
3492 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3493 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3494 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3495
3496 // Free up buffer allocated
3497 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303498 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003499
3500 limPostSmeMessage(pMac,
3501 LIM_MLM_DEAUTH_CNF,
3502 (tANI_U32 *) &mlmDeauthCnf);
3503 return eHAL_STATUS_SUCCESS;
3504}
3505
3506eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3507{
3508 tANI_U16 aid;
3509 tpDphHashNode pStaDs;
3510 tLimMlmDisassocCnf mlmDisassocCnf;
3511 tpPESession psessionEntry;
3512 tLimMlmDisassocReq *pMlmDisassocReq;
3513
3514 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3515 if (pMlmDisassocReq)
3516 {
3517 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3518 {
3519 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3520 }
3521
3522 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3523 {
3524
3525 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003526 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003527 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3528 goto end;
3529 }
3530
3531 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3532 if (pStaDs == NULL)
3533 {
3534 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3535 goto end;
3536 }
3537
3538 /// Receive path cleanup with dummy packet
3539 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3540 {
3541 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3542 goto end;
3543 }
3544
3545#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003546 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303547 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003548#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303549 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003550#endif
3551#ifdef FEATURE_WLAN_LFR
3552 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003553#endif
3554 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303555 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003556 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003557 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303558 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003559 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003560 psessionEntry, psessionEntry->peSessionId););
3561 limFTCleanup(pMac);
3562 }
3563 else
3564 {
3565 PELOGE(limLog(pMac, LOGE,
3566 FL("No FT Preauth Session Cleanup in role %d"
3567#ifdef FEATURE_WLAN_CCX
3568 " isCCX %d"
3569#endif
3570#ifdef FEATURE_WLAN_LFR
3571 " isLFR %d"
3572#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003573 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003574 psessionEntry->limSystemRole,
3575#ifdef FEATURE_WLAN_CCX
3576 psessionEntry->isCCXconnection,
3577#endif
3578#ifdef FEATURE_WLAN_LFR
3579 psessionEntry->isFastRoamIniFeatureEnabled,
3580#endif
3581 psessionEntry->is11Rconnection,
3582 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003583 }
3584#endif
3585
3586 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303587 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003588 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3589 return eHAL_STATUS_SUCCESS;
3590 }
3591 else
3592 {
3593 return eHAL_STATUS_SUCCESS;
3594 }
3595end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303596 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003597 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3598 sizeof(tSirMacAddr));
3599 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3600 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3601
3602 /* Update PE session ID*/
3603 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3604
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003605 if(pMlmDisassocReq != NULL)
3606 {
3607 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303608 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003609 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3610 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003611
3612 limPostSmeMessage(pMac,
3613 LIM_MLM_DISASSOC_CNF,
3614 (tANI_U32 *) &mlmDisassocCnf);
3615 return eHAL_STATUS_SUCCESS;
3616}
3617
3618eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3619{
3620 return limSendDisassocCnf(pMac);
3621}
3622
3623eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3624{
3625 return limSendDeauthCnf(pMac);
3626}
3627
Jeff Johnson295189b2012-06-20 16:38:30 -07003628/**
3629 * \brief This function is called to send Disassociate frame.
3630 *
3631 *
3632 * \param pMac Pointer to Global MAC structure
3633 *
3634 * \param nReason Indicates the reason that need to be sent in
3635 * Disassociation frame
3636 *
3637 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3638 * sent
3639 *
3640 *
3641 */
3642
3643void
3644limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3645 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003646 tSirMacAddr peer,
3647 tpPESession psessionEntry,
3648 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003649{
3650 tDot11fDisassociation frm;
3651 tANI_U8 *pFrame;
3652 tSirRetStatus nSirStatus;
3653 tpSirMacMgmtHdr pMacHdr;
3654 tANI_U32 nBytes, nPayload, nStatus;
3655 void *pPacket;
3656 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303657 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003658 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 if(NULL == psessionEntry)
3660 {
3661 return;
3662 }
3663
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303664 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003665
3666 frm.Reason.code = nReason;
3667
3668 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3669 if ( DOT11F_FAILED( nStatus ) )
3670 {
3671 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003672 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003673 nStatus );
3674 // We'll fall back on the worst case scenario:
3675 nPayload = sizeof( tDot11fDisassociation );
3676 }
3677 else if ( DOT11F_WARNED( nStatus ) )
3678 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003679 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003681 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 }
3683
3684 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3685
3686 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3687 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3688 ( void** ) &pPacket );
3689 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3690 {
3691 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003692 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 return;
3694 }
3695
3696 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303697 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003698
3699 // Next, we fill out the buffer descriptor:
3700 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3701 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3702 if ( eSIR_SUCCESS != nSirStatus )
3703 {
3704 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003705 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 nSirStatus );
3707 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3708 ( void* ) pFrame, ( void* ) pPacket );
3709 return; // just allocated...
3710 }
3711
3712 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3713
3714 // Prepare the BSSID
3715 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3716
Chet Lanctot186b5732013-03-18 10:26:30 -07003717#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003718 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003719#endif
3720
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3722 sizeof(tSirMacMgmtHdr),
3723 nPayload, &nPayload );
3724 if ( DOT11F_FAILED( nStatus ) )
3725 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003726 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 nStatus );
3728 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3729 ( void* ) pFrame, ( void* ) pPacket );
3730 return; // allocated!
3731 }
3732 else if ( DOT11F_WARNED( nStatus ) )
3733 {
3734 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003735 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 }
3737
3738 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003739 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3741
3742 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3744 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 )
3746 {
3747 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3748 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003749
Ganesh K08bce952012-12-13 15:04:41 -08003750 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303751 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3752 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003753 {
3754 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3755 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003756
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303757 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3758 {
3759 /* This frame will be sent on air by firmware,
3760 which will ensure that this frame goes out
3761 even though DEL_STA is sent immediately */
3762 /* Without this for DEL_STA command there is
3763 risk of flushing frame in BTQM queue without
3764 sending on air */
3765 txFlag |= HAL_USE_FW_IN_TX_PATH;
3766 }
3767
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003768 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003770 // Queue Disassociation frame in high priority WQ
3771 /* get the duration from the request */
3772 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3773 HAL_TXRX_FRM_802_11_MGMT,
3774 ANI_TXDIR_TODS,
3775 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3776 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3777 txFlag );
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303778
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003779 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003780
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003781 if (tx_timer_change(
3782 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3783 != TX_SUCCESS)
3784 {
3785 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003786 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003787 return;
3788 }
3789 else if(TX_SUCCESS != tx_timer_activate(
3790 &pMac->lim.limTimers.gLimDisassocAckTimer))
3791 {
3792 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003793 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003794 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3795 return;
3796 }
3797 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003798 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003799 {
3800 // Queue Disassociation frame in high priority WQ
3801 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3802 HAL_TXRX_FRM_802_11_MGMT,
3803 ANI_TXDIR_TODS,
3804 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3805 limTxComplete, pFrame, txFlag );
3806 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3807 {
3808 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003809 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003810 nSirStatus );
3811 //Pkt will be freed up by the callback
3812 return;
3813 }
3814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003815} // End limSendDisassocMgmtFrame.
3816
3817/**
3818 * \brief This function is called to send a Deauthenticate frame
3819 *
3820 *
3821 * \param pMac Pointer to global MAC structure
3822 *
3823 * \param nReason Indicates the reason that need to be sent in the
3824 * Deauthenticate frame
3825 *
3826 * \param peeer address of the STA to which the frame is to be sent
3827 *
3828 *
3829 */
3830
3831void
3832limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3833 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003834 tSirMacAddr peer,
3835 tpPESession psessionEntry,
3836 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003837{
3838 tDot11fDeAuth frm;
3839 tANI_U8 *pFrame;
3840 tSirRetStatus nSirStatus;
3841 tpSirMacMgmtHdr pMacHdr;
3842 tANI_U32 nBytes, nPayload, nStatus;
3843 void *pPacket;
3844 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303845 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003846 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003847#ifdef FEATURE_WLAN_TDLS
3848 tANI_U16 aid;
3849 tpDphHashNode pStaDs;
3850#endif
3851
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 if(NULL == psessionEntry)
3853 {
3854 return;
3855 }
3856
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303857 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003858
3859 frm.Reason.code = nReason;
3860
3861 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3862 if ( DOT11F_FAILED( nStatus ) )
3863 {
3864 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003865 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 nStatus );
3867 // We'll fall back on the worst case scenario:
3868 nPayload = sizeof( tDot11fDeAuth );
3869 }
3870 else if ( DOT11F_WARNED( nStatus ) )
3871 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003872 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003874 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 }
3876
3877 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3878
3879 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3880 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3881 ( void** ) &pPacket );
3882 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3883 {
3884 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003885 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 return;
3887 }
3888
3889 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303890 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003891
3892 // Next, we fill out the buffer descriptor:
3893 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3894 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3895 if ( eSIR_SUCCESS != nSirStatus )
3896 {
3897 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003898 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 nSirStatus );
3900 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3901 ( void* ) pFrame, ( void* ) pPacket );
3902 return; // just allocated...
3903 }
3904
3905 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3906
3907 // Prepare the BSSID
3908 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3909
Chet Lanctot186b5732013-03-18 10:26:30 -07003910#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003911 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003912#endif
3913
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3915 sizeof(tSirMacMgmtHdr),
3916 nPayload, &nPayload );
3917 if ( DOT11F_FAILED( nStatus ) )
3918 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003919 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 nStatus );
3921 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3922 ( void* ) pFrame, ( void* ) pPacket );
3923 return;
3924 }
3925 else if ( DOT11F_WARNED( nStatus ) )
3926 {
3927 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003928 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 }
3930
3931 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003932 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3934
3935 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3937 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 )
3939 {
3940 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3941 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003942
Ganesh K08bce952012-12-13 15:04:41 -08003943 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303944 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3945 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003946 {
3947 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3948 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003949
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303950 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3951 {
3952 /* This frame will be sent on air by firmware,
3953 which will ensure that this frame goes out
3954 even though DEL_STA is sent immediately */
3955 /* Without this for DEL_STA command there is
3956 risk of flushing frame in BTQM queue without
3957 sending on air */
3958 txFlag |= HAL_USE_FW_IN_TX_PATH;
3959 }
3960
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003961#ifdef FEATURE_WLAN_TDLS
3962 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3963#endif
3964
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003965 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003967 // Queue Disassociation frame in high priority WQ
3968 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3969 HAL_TXRX_FRM_802_11_MGMT,
3970 ANI_TXDIR_TODS,
3971 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3972 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303973
3974 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003975 {
3976 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303977 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003978 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003979 //Pkt will be freed up by the callback limTxComplete
3980
3981 /*Call limProcessDeauthAckTimeout which will send
3982 * DeauthCnf for this frame
3983 */
3984 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003985 return;
3986 }
3987
3988 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3989
3990 if (tx_timer_change(
3991 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3992 != TX_SUCCESS)
3993 {
3994 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003995 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003996 return;
3997 }
3998 else if(TX_SUCCESS != tx_timer_activate(
3999 &pMac->lim.limTimers.gLimDeauthAckTimer))
4000 {
4001 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004002 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004003 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4004 return;
4005 }
4006 }
4007 else
4008 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004009#ifdef FEATURE_WLAN_TDLS
4010 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4011 {
4012 // Queue Disassociation frame in high priority WQ
4013 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004014 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004015 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004016 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4017 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004018 }
4019 else
4020 {
4021#endif
4022 // Queue Disassociation frame in high priority WQ
4023 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4024 HAL_TXRX_FRM_802_11_MGMT,
4025 ANI_TXDIR_TODS,
4026 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4027 limTxComplete, pFrame, txFlag );
4028#ifdef FEATURE_WLAN_TDLS
4029 }
4030#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004031 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4032 {
4033 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004034 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004035 nSirStatus );
4036 //Pkt will be freed up by the callback
4037 return;
4038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 }
4040
4041} // End limSendDeauthMgmtFrame.
4042
4043
4044#ifdef ANI_SUPPORT_11H
4045/**
4046 * \brief Send a Measurement Report Action frame
4047 *
4048 *
4049 * \param pMac Pointer to the global MAC structure
4050 *
4051 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4052 *
4053 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4054 *
4055 *
4056 */
4057
4058tSirRetStatus
4059limSendMeasReportFrame(tpAniSirGlobal pMac,
4060 tpSirMacMeasReqActionFrame pMeasReqFrame,
4061 tSirMacAddr peer)
4062{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304063 tDot11fMeasurementReport frm;
4064 tANI_U8 *pFrame;
4065 tSirRetStatus nSirStatus;
4066 tpSirMacMgmtHdr pMacHdr;
4067 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4068 void *pPacket;
4069 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004070
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304071 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004072
4073 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4074 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4075 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4076
4077 switch ( pMeasReqFrame->measReqIE.measType )
4078 {
4079 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4080 nSirStatus =
4081 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4082 &frm.MeasurementReport );
4083 break;
4084 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4085 nSirStatus =
4086 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4087 &frm.MeasurementReport );
4088 break;
4089 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4090 nSirStatus =
4091 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4092 &frm.MeasurementReport );
4093 break;
4094 default:
4095 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004096 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 pMeasReqFrame->measReqIE.measType );
4098 return eSIR_FAILURE;
4099 }
4100
4101 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4102
4103 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4104 if ( DOT11F_FAILED( nStatus ) )
4105 {
4106 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004107 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 nStatus );
4109 // We'll fall back on the worst case scenario:
4110 nPayload = sizeof( tDot11fMeasurementReport );
4111 }
4112 else if ( DOT11F_WARNED( nStatus ) )
4113 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004114 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004116 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 }
4118
4119 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4120
4121 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4122 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4123 {
4124 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004125 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 return eSIR_FAILURE;
4127 }
4128
4129 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304130 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004131
4132 // Next, we fill out the buffer descriptor:
4133 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4134 SIR_MAC_MGMT_ACTION, peer);
4135 if ( eSIR_SUCCESS != nSirStatus )
4136 {
4137 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004138 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 nSirStatus );
4140 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4141 return eSIR_FAILURE; // just allocated...
4142 }
4143
4144 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4145
4146 nCfg = 6;
4147 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4148 if ( eSIR_SUCCESS != nSirStatus )
4149 {
4150 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004151 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 nSirStatus );
4153 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4154 return eSIR_FAILURE; // just allocated...
4155 }
4156
Chet Lanctot186b5732013-03-18 10:26:30 -07004157#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004158 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004159#endif
4160
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4162 sizeof(tSirMacMgmtHdr),
4163 nPayload, &nPayload );
4164 if ( DOT11F_FAILED( nStatus ) )
4165 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004166 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 nStatus );
4168 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4169 return eSIR_FAILURE; // allocated!
4170 }
4171 else if ( DOT11F_WARNED( nStatus ) )
4172 {
4173 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004174 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 }
4176
4177 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4178 HAL_TXRX_FRM_802_11_MGMT,
4179 ANI_TXDIR_TODS,
4180 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4181 limTxComplete, pFrame, 0 );
4182 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4183 {
4184 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004185 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 nSirStatus );
4187 //Pkt will be freed up by the callback
4188 return eSIR_FAILURE; // just allocated...
4189 }
4190
4191 return eSIR_SUCCESS;
4192
4193} // End limSendMeasReportFrame.
4194
4195
4196/**
4197 * \brief Send a TPC Request Action frame
4198 *
4199 *
4200 * \param pMac Pointer to the global MAC datastructure
4201 *
4202 * \param peer MAC address to which the frame should be sent
4203 *
4204 *
4205 */
4206
4207void
4208limSendTpcRequestFrame(tpAniSirGlobal pMac,
4209 tSirMacAddr peer)
4210{
4211 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304212 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 tSirRetStatus nSirStatus;
4214 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304215 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4216 void *pPacket;
4217 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004218
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304219 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004220
4221 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4222 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4223 frm.DialogToken.token = 1;
4224 frm.TPCRequest.present = 1;
4225
4226 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4227 if ( DOT11F_FAILED( nStatus ) )
4228 {
4229 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004230 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 nStatus );
4232 // We'll fall back on the worst case scenario:
4233 nPayload = sizeof( tDot11fTPCRequest );
4234 }
4235 else if ( DOT11F_WARNED( nStatus ) )
4236 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004237 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004239 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 }
4241
4242 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4243
4244 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4245 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4246 {
4247 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004248 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 return;
4250 }
4251
4252 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304253 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004254
4255 // Next, we fill out the buffer descriptor:
4256 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4257 SIR_MAC_MGMT_ACTION, peer);
4258 if ( eSIR_SUCCESS != nSirStatus )
4259 {
4260 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004261 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 nSirStatus );
4263 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4264 return; // just allocated...
4265 }
4266
4267 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4268
4269 nCfg = 6;
4270 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4271 if ( eSIR_SUCCESS != nSirStatus )
4272 {
4273 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004274 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 nSirStatus );
4276 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4277 return; // just allocated...
4278 }
4279
Chet Lanctot186b5732013-03-18 10:26:30 -07004280#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004281 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004282#endif
4283
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4285 sizeof(tSirMacMgmtHdr),
4286 nPayload, &nPayload );
4287 if ( DOT11F_FAILED( nStatus ) )
4288 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004289 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 nStatus );
4291 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4292 return; // allocated!
4293 }
4294 else if ( DOT11F_WARNED( nStatus ) )
4295 {
4296 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004297 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 }
4299
4300 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4301 HAL_TXRX_FRM_802_11_MGMT,
4302 ANI_TXDIR_TODS,
4303 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4304 limTxComplete, pFrame, 0 );
4305 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4306 {
4307 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004308 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 nSirStatus );
4310 //Pkt will be freed up by the callback
4311 return;
4312 }
4313
4314} // End limSendTpcRequestFrame.
4315
4316
4317/**
4318 * \brief Send a TPC Report Action frame
4319 *
4320 *
4321 * \param pMac Pointer to the global MAC datastructure
4322 *
4323 * \param pTpcReqFrame Pointer to the received TPC Request
4324 *
4325 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4326 *
4327 *
4328 */
4329
4330tSirRetStatus
4331limSendTpcReportFrame(tpAniSirGlobal pMac,
4332 tpSirMacTpcReqActionFrame pTpcReqFrame,
4333 tSirMacAddr peer)
4334{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304335 tDot11fTPCReport frm;
4336 tANI_U8 *pFrame;
4337 tSirRetStatus nSirStatus;
4338 tpSirMacMgmtHdr pMacHdr;
4339 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4340 void *pPacket;
4341 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004342
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304343 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004344
4345 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4346 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4347 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4348
4349 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4350 // "misplaced this function, need to replace:
4351 // txPower = halGetRateToPwrValue(pMac, staid,
4352 // pMac->lim.gLimCurrentChannelId, 0);
4353 frm.TPCReport.tx_power = 0;
4354 frm.TPCReport.link_margin = 0;
4355 frm.TPCReport.present = 1;
4356
4357 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4358 if ( DOT11F_FAILED( nStatus ) )
4359 {
4360 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004361 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 nStatus );
4363 // We'll fall back on the worst case scenario:
4364 nPayload = sizeof( tDot11fTPCReport );
4365 }
4366 else if ( DOT11F_WARNED( nStatus ) )
4367 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004368 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004370 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 }
4372
4373 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4374
4375 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4376 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4377 {
4378 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004379 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 return eSIR_FAILURE;
4381 }
4382
4383 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304384 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004385
4386 // Next, we fill out the buffer descriptor:
4387 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4388 SIR_MAC_MGMT_ACTION, peer);
4389 if ( eSIR_SUCCESS != nSirStatus )
4390 {
4391 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004392 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 nSirStatus );
4394 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4395 return eSIR_FAILURE; // just allocated...
4396 }
4397
4398 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4399
4400 nCfg = 6;
4401 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4402 if ( eSIR_SUCCESS != nSirStatus )
4403 {
4404 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004405 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 nSirStatus );
4407 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4408 return eSIR_FAILURE; // just allocated...
4409 }
4410
Chet Lanctot186b5732013-03-18 10:26:30 -07004411#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004412 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004413#endif
4414
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4416 sizeof(tSirMacMgmtHdr),
4417 nPayload, &nPayload );
4418 if ( DOT11F_FAILED( nStatus ) )
4419 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004420 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 nStatus );
4422 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4423 return eSIR_FAILURE; // allocated!
4424 }
4425 else if ( DOT11F_WARNED( nStatus ) )
4426 {
4427 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004428 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 }
4430
4431
4432 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4433 HAL_TXRX_FRM_802_11_MGMT,
4434 ANI_TXDIR_TODS,
4435 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4436 limTxComplete, pFrame, 0 );
4437 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4438 {
4439 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004440 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 nSirStatus );
4442 //Pkt will be freed up by the callback
4443 return eSIR_FAILURE; // just allocated...
4444 }
4445
4446 return eSIR_SUCCESS;
4447
4448} // End limSendTpcReportFrame.
4449#endif //ANI_SUPPORT_11H
4450
4451
Jeff Johnson295189b2012-06-20 16:38:30 -07004452/**
4453 * \brief Send a Channel Switch Announcement
4454 *
4455 *
4456 * \param pMac Pointer to the global MAC datastructure
4457 *
4458 * \param peer MAC address to which this frame will be sent
4459 *
4460 * \param nMode
4461 *
4462 * \param nNewChannel
4463 *
4464 * \param nCount
4465 *
4466 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4467 *
4468 *
4469 */
4470
4471tSirRetStatus
4472limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4473 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004474 tANI_U8 nMode,
4475 tANI_U8 nNewChannel,
4476 tANI_U8 nCount,
4477 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004478{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304479 tDot11fChannelSwitch frm;
4480 tANI_U8 *pFrame;
4481 tSirRetStatus nSirStatus;
4482 tpSirMacMgmtHdr pMacHdr;
4483 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4484 void *pPacket;
4485 eHalStatus halstatus;
4486 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004487
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304488 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004489
4490 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4491 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4492 frm.ChanSwitchAnn.switchMode = nMode;
4493 frm.ChanSwitchAnn.newChannel = nNewChannel;
4494 frm.ChanSwitchAnn.switchCount = nCount;
4495 frm.ChanSwitchAnn.present = 1;
4496
4497 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4498 if ( DOT11F_FAILED( nStatus ) )
4499 {
4500 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004501 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 nStatus );
4503 // We'll fall back on the worst case scenario:
4504 nPayload = sizeof( tDot11fChannelSwitch );
4505 }
4506 else if ( DOT11F_WARNED( nStatus ) )
4507 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004508 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004510 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 }
4512
4513 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4514
4515 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4516 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4517 {
4518 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004519 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 return eSIR_FAILURE;
4521 }
4522
4523 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304524 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004525
4526 // Next, we fill out the buffer descriptor:
4527 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004528 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4529 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304530 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4531 (tANI_U8 *) psessionEntry->bssId,
4532 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 if ( eSIR_SUCCESS != nSirStatus )
4534 {
4535 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004536 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 nSirStatus );
4538 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4539 return eSIR_FAILURE; // just allocated...
4540 }
4541
Jeff Johnsone7245742012-09-05 17:12:55 -07004542#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4544
4545 nCfg = 6;
4546 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4547 if ( eSIR_SUCCESS != nSirStatus )
4548 {
4549 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004550 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 nSirStatus );
4552 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4553 return eSIR_FAILURE; // just allocated...
4554 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004555#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004556
4557#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004558 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004559#endif
4560
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4562 sizeof(tSirMacMgmtHdr),
4563 nPayload, &nPayload );
4564 if ( DOT11F_FAILED( nStatus ) )
4565 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004566 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 nStatus );
4568 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4569 return eSIR_FAILURE; // allocated!
4570 }
4571 else if ( DOT11F_WARNED( nStatus ) )
4572 {
4573 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004574 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 }
4576
Jeff Johnsone7245742012-09-05 17:12:55 -07004577 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004578 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4579 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004580 )
4581 {
4582 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4585 HAL_TXRX_FRM_802_11_MGMT,
4586 ANI_TXDIR_TODS,
4587 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004588 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4590 {
4591 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004592 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 nSirStatus );
4594 //Pkt will be freed up by the callback
4595 return eSIR_FAILURE;
4596 }
4597
4598 return eSIR_SUCCESS;
4599
4600} // End limSendChannelSwitchMgmtFrame.
4601
Jeff Johnson295189b2012-06-20 16:38:30 -07004602
4603
Mohit Khanna4a70d262012-09-11 16:30:12 -07004604#ifdef WLAN_FEATURE_11AC
4605tSirRetStatus
4606limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4607 tSirMacAddr peer,
4608 tANI_U8 nMode,
4609 tpPESession psessionEntry )
4610{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304611 tDot11fOperatingMode frm;
4612 tANI_U8 *pFrame;
4613 tSirRetStatus nSirStatus;
4614 tpSirMacMgmtHdr pMacHdr;
4615 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4616 void *pPacket;
4617 eHalStatus halstatus;
4618 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07004619
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304620 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004621
4622 frm.Category.category = SIR_MAC_ACTION_VHT;
4623 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4624 frm.OperatingMode.chanWidth = nMode;
4625 frm.OperatingMode.rxNSS = 0;
4626 frm.OperatingMode.rxNSSType = 0;
4627
4628 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4629 if ( DOT11F_FAILED( nStatus ) )
4630 {
4631 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004632 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004633 nStatus );
4634 // We'll fall back on the worst case scenario:
4635 nPayload = sizeof( tDot11fOperatingMode);
4636 }
4637 else if ( DOT11F_WARNED( nStatus ) )
4638 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004639 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004640 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004641 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004642 }
4643
4644 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4645
4646 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4647 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4648 {
4649 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004650 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004651 return eSIR_FAILURE;
4652 }
4653
4654 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304655 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004656
4657
4658 // Next, we fill out the buffer descriptor:
4659 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4660 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4661 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4662 } else
4663 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4664 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4665 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304666 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4667 (tANI_U8 *) psessionEntry->bssId,
4668 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004669 if ( eSIR_SUCCESS != nSirStatus )
4670 {
4671 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004672 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004673 nSirStatus );
4674 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4675 return eSIR_FAILURE; // just allocated...
4676 }
4677 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4678 sizeof(tSirMacMgmtHdr),
4679 nPayload, &nPayload );
4680 if ( DOT11F_FAILED( nStatus ) )
4681 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004682 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004683 nStatus );
4684 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4685 return eSIR_FAILURE; // allocated!
4686 }
4687 else if ( DOT11F_WARNED( nStatus ) )
4688 {
4689 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004690 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004691 }
4692 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004693 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4694 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004695 )
4696 {
4697 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4698 }
4699 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4700 HAL_TXRX_FRM_802_11_MGMT,
4701 ANI_TXDIR_TODS,
4702 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4703 limTxComplete, pFrame, txFlag );
4704 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4705 {
4706 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004707 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004708 nSirStatus );
4709 //Pkt will be freed up by the callback
4710 return eSIR_FAILURE;
4711 }
4712
4713 return eSIR_SUCCESS;
4714}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004715
4716/**
4717 * \brief Send a VHT Channel Switch Announcement
4718 *
4719 *
4720 * \param pMac Pointer to the global MAC datastructure
4721 *
4722 * \param peer MAC address to which this frame will be sent
4723 *
4724 * \param nChanWidth
4725 *
4726 * \param nNewChannel
4727 *
4728 *
4729 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4730 *
4731 *
4732 */
4733
4734tSirRetStatus
4735limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4736 tSirMacAddr peer,
4737 tANI_U8 nChanWidth,
4738 tANI_U8 nNewChannel,
4739 tANI_U8 ncbMode,
4740 tpPESession psessionEntry )
4741{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304742 tDot11fChannelSwitch frm;
4743 tANI_U8 *pFrame;
4744 tSirRetStatus nSirStatus;
4745 tpSirMacMgmtHdr pMacHdr;
4746 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4747 void *pPacket;
4748 eHalStatus halstatus;
4749 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004750
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304751 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004752
4753
4754 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4755 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4756 frm.ChanSwitchAnn.switchMode = 1;
4757 frm.ChanSwitchAnn.newChannel = nNewChannel;
4758 frm.ChanSwitchAnn.switchCount = 1;
4759 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4760 frm.ExtChanSwitchAnn.present = 1;
4761 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4762 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4763 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4764 frm.ChanSwitchAnn.present = 1;
4765 frm.WiderBWChanSwitchAnn.present = 1;
4766
4767 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4768 if ( DOT11F_FAILED( nStatus ) )
4769 {
4770 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004771 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004772 nStatus );
4773 // We'll fall back on the worst case scenario:
4774 nPayload = sizeof( tDot11fChannelSwitch );
4775 }
4776 else if ( DOT11F_WARNED( nStatus ) )
4777 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004778 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004779 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004780 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004781 }
4782
4783 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4784
4785 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4786 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4787 {
4788 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004789 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004790 return eSIR_FAILURE;
4791 }
4792 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304793 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004794
4795 // Next, we fill out the buffer descriptor:
4796 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4797 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4798 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304799 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4800 (tANI_U8 *) psessionEntry->bssId,
4801 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004802 if ( eSIR_SUCCESS != nSirStatus )
4803 {
4804 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004805 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004806 nSirStatus );
4807 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4808 return eSIR_FAILURE; // just allocated...
4809 }
4810 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4811 sizeof(tSirMacMgmtHdr),
4812 nPayload, &nPayload );
4813 if ( DOT11F_FAILED( nStatus ) )
4814 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004815 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004816 nStatus );
4817 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4818 return eSIR_FAILURE; // allocated!
4819 }
4820 else if ( DOT11F_WARNED( nStatus ) )
4821 {
4822 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004823 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004824 }
4825
4826 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004827 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4828 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004829 )
4830 {
4831 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4832 }
4833 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4834 HAL_TXRX_FRM_802_11_MGMT,
4835 ANI_TXDIR_TODS,
4836 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4837 limTxComplete, pFrame, txFlag );
4838 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4839 {
4840 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004841 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004842 nSirStatus );
4843 //Pkt will be freed up by the callback
4844 return eSIR_FAILURE;
4845 }
4846
4847 return eSIR_SUCCESS;
4848
4849} // End limSendVHTChannelSwitchMgmtFrame.
4850
4851
4852
Mohit Khanna4a70d262012-09-11 16:30:12 -07004853#endif
4854
Jeff Johnson295189b2012-06-20 16:38:30 -07004855/**
4856 * \brief Send an ADDBA Req Action Frame to peer
4857 *
4858 * \sa limSendAddBAReq
4859 *
4860 * \param pMac The global tpAniSirGlobal object
4861 *
4862 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4863 * the necessary parameters reqd by PE send the ADDBA Req Action
4864 * Frame to the peer
4865 *
4866 * \return eSIR_SUCCESS if setup completes successfully
4867 * eSIR_FAILURE is some problem is encountered
4868 */
4869tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304870 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004871{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304872 tDot11fAddBAReq frmAddBAReq;
4873 tANI_U8 *pAddBAReqBuffer = NULL;
4874 tpSirMacMgmtHdr pMacHdr;
4875 tANI_U32 frameLen = 0, nStatus, nPayload;
4876 tSirRetStatus statusCode;
4877 eHalStatus halStatus;
4878 void *pPacket;
4879 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004880
4881 if(NULL == psessionEntry)
4882 {
4883 return eSIR_FAILURE;
4884 }
4885
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304886 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004887
4888 // Category - 3 (BA)
4889 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4890
4891 // Action - 0 (ADDBA Req)
4892 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4893
4894 // FIXME - Dialog Token, generalize this...
4895 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4896
4897 // Fill the ADDBA Parameter Set
4898 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4899 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4900 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4901
4902 // BA timeout
4903 // 0 - indicates no BA timeout
4904 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4905
4906 // BA Starting Sequence Number
4907 // Fragment number will always be zero
4908 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4909 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4910 }
4911
4912 frmAddBAReq.BAStartingSequenceControl.ssn =
4913 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4914
4915 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4916
4917 if( DOT11F_FAILED( nStatus ))
4918 {
4919 limLog( pMac, LOGW,
4920 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004921 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 nStatus );
4923
4924 // We'll fall back on the worst case scenario:
4925 nPayload = sizeof( tDot11fAddBAReq );
4926 }
4927 else if( DOT11F_WARNED( nStatus ))
4928 {
4929 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004930 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004931 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 nStatus );
4933 }
4934
4935 // Add the MGMT header to frame length
4936 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4937
4938 // Need to allocate a buffer for ADDBA AF
4939 if( eHAL_STATUS_SUCCESS !=
4940 (halStatus = palPktAlloc( pMac->hHdd,
4941 HAL_TXRX_FRM_802_11_MGMT,
4942 (tANI_U16) frameLen,
4943 (void **) &pAddBAReqBuffer,
4944 (void **) &pPacket )))
4945 {
4946 // Log error
4947 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004948 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 frameLen,
4950 halStatus );
4951
4952 statusCode = eSIR_MEM_ALLOC_FAILED;
4953 goto returnAfterError;
4954 }
4955
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304956 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004957
4958 // Copy necessary info to BD
4959 if( eSIR_SUCCESS !=
4960 (statusCode = limPopulateMacHeader( pMac,
4961 pAddBAReqBuffer,
4962 SIR_MAC_MGMT_FRAME,
4963 SIR_MAC_MGMT_ACTION,
4964 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4965 goto returnAfterError;
4966
4967 // Update A3 with the BSSID
4968 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4969
4970 #if 0
4971 cfgLen = SIR_MAC_ADDR_LENGTH;
4972 if( eSIR_SUCCESS != cfgGetStr( pMac,
4973 WNI_CFG_BSSID,
4974 (tANI_U8 *) pMacHdr->bssId,
4975 &cfgLen ))
4976 {
4977 limLog( pMac, LOGP,
4978 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004979 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004980
4981 // FIXME - Need to convert to tSirRetStatus
4982 statusCode = eSIR_FAILURE;
4983 goto returnAfterError;
4984 }
4985 #endif//TO SUPPORT BT-AMP
4986 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4987
Chet Lanctot186b5732013-03-18 10:26:30 -07004988#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004989 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004990#endif
4991
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 // Now, we're ready to "pack" the frames
4993 nStatus = dot11fPackAddBAReq( pMac,
4994 &frmAddBAReq,
4995 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4996 nPayload,
4997 &nPayload );
4998
4999 if( DOT11F_FAILED( nStatus ))
5000 {
5001 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005002 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 nStatus );
5004
5005 // FIXME - Need to convert to tSirRetStatus
5006 statusCode = eSIR_FAILURE;
5007 goto returnAfterError;
5008 }
5009 else if( DOT11F_WARNED( nStatus ))
5010 {
5011 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005012 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5013 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 }
5015
5016 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005017 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5019
5020 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5022 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 )
5024 {
5025 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5026 }
5027
5028 if( eHAL_STATUS_SUCCESS !=
5029 (halStatus = halTxFrame( pMac,
5030 pPacket,
5031 (tANI_U16) frameLen,
5032 HAL_TXRX_FRM_802_11_MGMT,
5033 ANI_TXDIR_TODS,
5034 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5035 limTxComplete,
5036 pAddBAReqBuffer, txFlag )))
5037 {
5038 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005039 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 halStatus );
5041
5042 // FIXME - Need to convert eHalStatus to tSirRetStatus
5043 statusCode = eSIR_FAILURE;
5044 //Pkt will be freed up by the callback
5045 return statusCode;
5046 }
5047 else
5048 return eSIR_SUCCESS;
5049
5050returnAfterError:
5051
5052 // Release buffer, if allocated
5053 if( NULL != pAddBAReqBuffer )
5054 palPktFree( pMac->hHdd,
5055 HAL_TXRX_FRM_802_11_MGMT,
5056 (void *) pAddBAReqBuffer,
5057 (void *) pPacket );
5058
5059 return statusCode;
5060}
5061
5062/**
5063 * \brief Send an ADDBA Rsp Action Frame to peer
5064 *
5065 * \sa limSendAddBARsp
5066 *
5067 * \param pMac The global tpAniSirGlobal object
5068 *
5069 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5070 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5071 * Frame to the peer
5072 *
5073 * \return eSIR_SUCCESS if setup completes successfully
5074 * eSIR_FAILURE is some problem is encountered
5075 */
5076tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5077 tpLimMlmAddBARsp pMlmAddBARsp,
5078 tpPESession psessionEntry)
5079{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305080 tDot11fAddBARsp frmAddBARsp;
5081 tANI_U8 *pAddBARspBuffer = NULL;
5082 tpSirMacMgmtHdr pMacHdr;
5083 tANI_U32 frameLen = 0, nStatus, nPayload;
5084 tSirRetStatus statusCode;
5085 eHalStatus halStatus;
5086 void *pPacket;
5087 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005088
5089 if(NULL == psessionEntry)
5090 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005091 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 return eSIR_FAILURE;
5093 }
5094
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305095 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005096
5097 // Category - 3 (BA)
5098 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5099 // Action - 1 (ADDBA Rsp)
5100 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5101
5102 // Should be same as the one we received in the ADDBA Req
5103 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5104
5105 // ADDBA Req status
5106 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5107
5108 // Fill the ADDBA Parameter Set as provided by caller
5109 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5110 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5111 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005112
5113 if(psessionEntry->isAmsduSupportInAMPDU)
5114 {
5115 frmAddBARsp.AddBAParameterSet.amsduSupported =
5116 psessionEntry->amsduSupportedInBA;
5117 }
5118 else
5119 {
5120 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005122
5123 // BA timeout
5124 // 0 - indicates no BA timeout
5125 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5126
5127 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5128
5129 if( DOT11F_FAILED( nStatus ))
5130 {
5131 limLog( pMac, LOGW,
5132 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005133 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 nStatus );
5135
5136 // We'll fall back on the worst case scenario:
5137 nPayload = sizeof( tDot11fAddBARsp );
5138 }
5139 else if( DOT11F_WARNED( nStatus ))
5140 {
5141 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005142 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005143 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005144 nStatus );
5145 }
5146
5147 // Need to allocate a buffer for ADDBA AF
5148 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5149
5150 // Allocate shared memory
5151 if( eHAL_STATUS_SUCCESS !=
5152 (halStatus = palPktAlloc( pMac->hHdd,
5153 HAL_TXRX_FRM_802_11_MGMT,
5154 (tANI_U16) frameLen,
5155 (void **) &pAddBARspBuffer,
5156 (void **) &pPacket )))
5157 {
5158 // Log error
5159 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005160 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 frameLen,
5162 halStatus );
5163
5164 statusCode = eSIR_MEM_ALLOC_FAILED;
5165 goto returnAfterError;
5166 }
5167
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305168 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005169
5170 // Copy necessary info to BD
5171 if( eSIR_SUCCESS !=
5172 (statusCode = limPopulateMacHeader( pMac,
5173 pAddBARspBuffer,
5174 SIR_MAC_MGMT_FRAME,
5175 SIR_MAC_MGMT_ACTION,
5176 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5177 goto returnAfterError;
5178
5179 // Update A3 with the BSSID
5180
5181 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5182
5183 #if 0
5184 cfgLen = SIR_MAC_ADDR_LENGTH;
5185 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5186 WNI_CFG_BSSID,
5187 (tANI_U8 *) pMacHdr->bssId,
5188 &cfgLen ))
5189 {
5190 limLog( pMac, LOGP,
5191 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005192 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005193
5194 // FIXME - Need to convert to tSirRetStatus
5195 statusCode = eSIR_FAILURE;
5196 goto returnAfterError;
5197 }
5198 #endif // TO SUPPORT BT-AMP
5199 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5200
Chet Lanctot186b5732013-03-18 10:26:30 -07005201#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005202 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005203#endif
5204
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 // Now, we're ready to "pack" the frames
5206 nStatus = dot11fPackAddBARsp( pMac,
5207 &frmAddBARsp,
5208 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5209 nPayload,
5210 &nPayload );
5211
5212 if( DOT11F_FAILED( nStatus ))
5213 {
5214 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005215 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 nStatus );
5217
5218 // FIXME - Need to convert to tSirRetStatus
5219 statusCode = eSIR_FAILURE;
5220 goto returnAfterError;
5221 }
5222 else if( DOT11F_WARNED( nStatus ))
5223 {
5224 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005225 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5226 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 }
5228
5229 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005230 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5232
5233 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5235 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 )
5237 {
5238 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5239 }
5240
5241 if( eHAL_STATUS_SUCCESS !=
5242 (halStatus = halTxFrame( pMac,
5243 pPacket,
5244 (tANI_U16) frameLen,
5245 HAL_TXRX_FRM_802_11_MGMT,
5246 ANI_TXDIR_TODS,
5247 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5248 limTxComplete,
5249 pAddBARspBuffer, txFlag )))
5250 {
5251 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005252 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005253 halStatus );
5254
5255 // FIXME - HAL error codes are different from PE error
5256 // codes!! And, this routine is returning tSirRetStatus
5257 statusCode = eSIR_FAILURE;
5258 //Pkt will be freed up by the callback
5259 return statusCode;
5260 }
5261 else
5262 return eSIR_SUCCESS;
5263
5264 returnAfterError:
5265
5266 // Release buffer, if allocated
5267 if( NULL != pAddBARspBuffer )
5268 palPktFree( pMac->hHdd,
5269 HAL_TXRX_FRM_802_11_MGMT,
5270 (void *) pAddBARspBuffer,
5271 (void *) pPacket );
5272
5273 return statusCode;
5274}
5275
5276/**
5277 * \brief Send a DELBA Indication Action Frame to peer
5278 *
5279 * \sa limSendDelBAInd
5280 *
5281 * \param pMac The global tpAniSirGlobal object
5282 *
5283 * \param peerMacAddr MAC Address of peer
5284 *
5285 * \param reasonCode Reason for the DELBA notification
5286 *
5287 * \param pBAParameterSet The DELBA Parameter Set.
5288 * This identifies the TID for which the BA session is
5289 * being deleted.
5290 *
5291 * \return eSIR_SUCCESS if setup completes successfully
5292 * eSIR_FAILURE is some problem is encountered
5293 */
5294tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5295 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5296{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305297 tDot11fDelBAInd frmDelBAInd;
5298 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305300 tpSirMacMgmtHdr pMacHdr;
5301 tANI_U32 frameLen = 0, nStatus, nPayload;
5302 tSirRetStatus statusCode;
5303 eHalStatus halStatus;
5304 void *pPacket;
5305 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005306
5307 if(NULL == psessionEntry)
5308 {
5309 return eSIR_FAILURE;
5310 }
5311
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305312 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005313
5314 // Category - 3 (BA)
5315 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5316 // Action - 2 (DELBA)
5317 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5318
5319 // Fill the DELBA Parameter Set as provided by caller
5320 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5321 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5322
5323 // BA Starting Sequence Number
5324 // Fragment number will always be zero
5325 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5326
5327 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5328
5329 if( DOT11F_FAILED( nStatus ))
5330 {
5331 limLog( pMac, LOGW,
5332 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005333 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 nStatus );
5335
5336 // We'll fall back on the worst case scenario:
5337 nPayload = sizeof( tDot11fDelBAInd );
5338 }
5339 else if( DOT11F_WARNED( nStatus ))
5340 {
5341 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005342 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005343 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 nStatus );
5345 }
5346
5347 // Add the MGMT header to frame length
5348 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5349
5350 // Allocate shared memory
5351 if( eHAL_STATUS_SUCCESS !=
5352 (halStatus = palPktAlloc( pMac->hHdd,
5353 HAL_TXRX_FRM_802_11_MGMT,
5354 (tANI_U16) frameLen,
5355 (void **) &pDelBAIndBuffer,
5356 (void **) &pPacket )))
5357 {
5358 // Log error
5359 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005360 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 frameLen,
5362 halStatus );
5363
5364 statusCode = eSIR_MEM_ALLOC_FAILED;
5365 goto returnAfterError;
5366 }
5367
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305368 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005369
5370 // Copy necessary info to BD
5371 if( eSIR_SUCCESS !=
5372 (statusCode = limPopulateMacHeader( pMac,
5373 pDelBAIndBuffer,
5374 SIR_MAC_MGMT_FRAME,
5375 SIR_MAC_MGMT_ACTION,
5376 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5377 goto returnAfterError;
5378
5379 // Update A3 with the BSSID
5380 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5381
5382 #if 0
5383 cfgLen = SIR_MAC_ADDR_LENGTH;
5384 if( eSIR_SUCCESS != cfgGetStr( pMac,
5385 WNI_CFG_BSSID,
5386 (tANI_U8 *) pMacHdr->bssId,
5387 &cfgLen ))
5388 {
5389 limLog( pMac, LOGP,
5390 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005391 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005392
5393 // FIXME - Need to convert to tSirRetStatus
5394 statusCode = eSIR_FAILURE;
5395 goto returnAfterError;
5396 }
5397 #endif //TO SUPPORT BT-AMP
5398 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5399
Chet Lanctot186b5732013-03-18 10:26:30 -07005400#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005401 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005402#endif
5403
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 // Now, we're ready to "pack" the frames
5405 nStatus = dot11fPackDelBAInd( pMac,
5406 &frmDelBAInd,
5407 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5408 nPayload,
5409 &nPayload );
5410
5411 if( DOT11F_FAILED( nStatus ))
5412 {
5413 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005414 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 nStatus );
5416
5417 // FIXME - Need to convert to tSirRetStatus
5418 statusCode = eSIR_FAILURE;
5419 goto returnAfterError;
5420 }
5421 else if( DOT11F_WARNED( nStatus ))
5422 {
5423 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005424 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5425 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 }
5427
5428 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005429 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5431
5432 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5434 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 )
5436 {
5437 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5438 }
5439
5440 if( eHAL_STATUS_SUCCESS !=
5441 (halStatus = halTxFrame( pMac,
5442 pPacket,
5443 (tANI_U16) frameLen,
5444 HAL_TXRX_FRM_802_11_MGMT,
5445 ANI_TXDIR_TODS,
5446 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5447 limTxComplete,
5448 pDelBAIndBuffer, txFlag )))
5449 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005450 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 statusCode = eSIR_FAILURE;
5452 //Pkt will be freed up by the callback
5453 return statusCode;
5454 }
5455 else
5456 return eSIR_SUCCESS;
5457
5458 returnAfterError:
5459
5460 // Release buffer, if allocated
5461 if( NULL != pDelBAIndBuffer )
5462 palPktFree( pMac->hHdd,
5463 HAL_TXRX_FRM_802_11_MGMT,
5464 (void *) pDelBAIndBuffer,
5465 (void *) pPacket );
5466
5467 return statusCode;
5468}
5469
5470#if defined WLAN_FEATURE_VOWIFI
5471
5472/**
5473 * \brief Send a Neighbor Report Request Action frame
5474 *
5475 *
5476 * \param pMac Pointer to the global MAC structure
5477 *
5478 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5479 *
5480 * \param peer mac address of peer station.
5481 *
5482 * \param psessionEntry address of session entry.
5483 *
5484 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5485 *
5486 *
5487 */
5488
5489tSirRetStatus
5490limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5491 tpSirMacNeighborReportReq pNeighborReq,
5492 tSirMacAddr peer,
5493 tpPESession psessionEntry
5494 )
5495{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305496 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 tDot11fNeighborReportRequest frm;
5498 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305499 tpSirMacMgmtHdr pMacHdr;
5500 tANI_U32 nBytes, nPayload, nStatus;
5501 void *pPacket;
5502 eHalStatus halstatus;
5503 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005504
5505 if ( psessionEntry == NULL )
5506 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005507 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 return eSIR_FAILURE;
5509 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305510 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005511
5512 frm.Category.category = SIR_MAC_ACTION_RRM;
5513 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5514 frm.DialogToken.token = pNeighborReq->dialogToken;
5515
5516
5517 if( pNeighborReq->ssid_present )
5518 {
5519 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5520 }
5521
5522 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5523 if ( DOT11F_FAILED( nStatus ) )
5524 {
5525 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005526 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 nStatus );
5528 // We'll fall back on the worst case scenario:
5529 nPayload = sizeof( tDot11fNeighborReportRequest );
5530 }
5531 else if ( DOT11F_WARNED( nStatus ) )
5532 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005533 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005535 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 }
5537
5538 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5539
5540 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5541 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5542 {
5543 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005544 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 return eSIR_FAILURE;
5546 }
5547
5548 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305549 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005550
5551 // Copy necessary info to BD
5552 if( eSIR_SUCCESS !=
5553 (statusCode = limPopulateMacHeader( pMac,
5554 pFrame,
5555 SIR_MAC_MGMT_FRAME,
5556 SIR_MAC_MGMT_ACTION,
5557 peer, psessionEntry->selfMacAddr)))
5558 goto returnAfterError;
5559
5560 // Update A3 with the BSSID
5561 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5562
5563 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5564
Chet Lanctot186b5732013-03-18 10:26:30 -07005565#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005566 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005567#endif
5568
Jeff Johnson295189b2012-06-20 16:38:30 -07005569 // Now, we're ready to "pack" the frames
5570 nStatus = dot11fPackNeighborReportRequest( pMac,
5571 &frm,
5572 pFrame + sizeof( tSirMacMgmtHdr ),
5573 nPayload,
5574 &nPayload );
5575
5576 if( DOT11F_FAILED( nStatus ))
5577 {
5578 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005579 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 nStatus );
5581
5582 // FIXME - Need to convert to tSirRetStatus
5583 statusCode = eSIR_FAILURE;
5584 goto returnAfterError;
5585 }
5586 else if( DOT11F_WARNED( nStatus ))
5587 {
5588 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005589 FL( "There were warnings while packing Neighbor Report "
5590 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 }
5592
5593 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005594 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 limPrintMacAddr( pMac, peer, LOGW );
5596
5597 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5599 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005600 )
5601 {
5602 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5603 }
5604
5605 if( eHAL_STATUS_SUCCESS !=
5606 (halstatus = halTxFrame( pMac,
5607 pPacket,
5608 (tANI_U16) nBytes,
5609 HAL_TXRX_FRM_802_11_MGMT,
5610 ANI_TXDIR_TODS,
5611 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5612 limTxComplete,
5613 pFrame, txFlag )))
5614 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005615 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005616 statusCode = eSIR_FAILURE;
5617 //Pkt will be freed up by the callback
5618 return statusCode;
5619 }
5620 else
5621 return eSIR_SUCCESS;
5622
5623returnAfterError:
5624 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5625
5626 return statusCode;
5627} // End limSendNeighborReportRequestFrame.
5628
5629/**
5630 * \brief Send a Link Report Action frame
5631 *
5632 *
5633 * \param pMac Pointer to the global MAC structure
5634 *
5635 * \param pLinkReport Address of a tSirMacLinkReport
5636 *
5637 * \param peer mac address of peer station.
5638 *
5639 * \param psessionEntry address of session entry.
5640 *
5641 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5642 *
5643 *
5644 */
5645
5646tSirRetStatus
5647limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5648 tpSirMacLinkReport pLinkReport,
5649 tSirMacAddr peer,
5650 tpPESession psessionEntry
5651 )
5652{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305653 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 tDot11fLinkMeasurementReport frm;
5655 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305656 tpSirMacMgmtHdr pMacHdr;
5657 tANI_U32 nBytes, nPayload, nStatus;
5658 void *pPacket;
5659 eHalStatus halstatus;
5660 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005661
5662
5663 if ( psessionEntry == NULL )
5664 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005665 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 return eSIR_FAILURE;
5667 }
5668
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305669 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005670
5671 frm.Category.category = SIR_MAC_ACTION_RRM;
5672 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5673 frm.DialogToken.token = pLinkReport->dialogToken;
5674
5675
5676 //IEEE Std. 802.11 7.3.2.18. for the report element.
5677 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5678 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5679 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5680 //such case this way than changing the frame parser.
5681 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5682 frm.TPCEleLen.TPCLen = 2;
5683 frm.TxPower.txPower = pLinkReport->txPower;
5684 frm.LinkMargin.linkMargin = 0;
5685
5686 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5687 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5688 frm.RCPI.rcpi = pLinkReport->rcpi;
5689 frm.RSNI.rsni = pLinkReport->rsni;
5690
5691 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5692 if ( DOT11F_FAILED( nStatus ) )
5693 {
5694 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005695 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 nStatus );
5697 // We'll fall back on the worst case scenario:
5698 nPayload = sizeof( tDot11fLinkMeasurementReport );
5699 }
5700 else if ( DOT11F_WARNED( nStatus ) )
5701 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005702 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005704 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 }
5706
5707 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5708
5709 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5710 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5711 {
5712 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005713 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 return eSIR_FAILURE;
5715 }
5716
5717 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305718 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005719
5720 // Copy necessary info to BD
5721 if( eSIR_SUCCESS !=
5722 (statusCode = limPopulateMacHeader( pMac,
5723 pFrame,
5724 SIR_MAC_MGMT_FRAME,
5725 SIR_MAC_MGMT_ACTION,
5726 peer, psessionEntry->selfMacAddr)))
5727 goto returnAfterError;
5728
5729 // Update A3 with the BSSID
5730 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5731
5732 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5733
Chet Lanctot186b5732013-03-18 10:26:30 -07005734#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005735 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005736#endif
5737
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 // Now, we're ready to "pack" the frames
5739 nStatus = dot11fPackLinkMeasurementReport( pMac,
5740 &frm,
5741 pFrame + sizeof( tSirMacMgmtHdr ),
5742 nPayload,
5743 &nPayload );
5744
5745 if( DOT11F_FAILED( nStatus ))
5746 {
5747 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005748 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 nStatus );
5750
5751 // FIXME - Need to convert to tSirRetStatus
5752 statusCode = eSIR_FAILURE;
5753 goto returnAfterError;
5754 }
5755 else if( DOT11F_WARNED( nStatus ))
5756 {
5757 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005758 FL( "There were warnings while packing Link Report (0x%08x)." ),
5759 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 }
5761
5762 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005763 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 limPrintMacAddr( pMac, peer, LOGW );
5765
5766 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5768 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 )
5770 {
5771 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5772 }
5773
5774 if( eHAL_STATUS_SUCCESS !=
5775 (halstatus = halTxFrame( pMac,
5776 pPacket,
5777 (tANI_U16) nBytes,
5778 HAL_TXRX_FRM_802_11_MGMT,
5779 ANI_TXDIR_TODS,
5780 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5781 limTxComplete,
5782 pFrame, txFlag )))
5783 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005784 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 statusCode = eSIR_FAILURE;
5786 //Pkt will be freed up by the callback
5787 return statusCode;
5788 }
5789 else
5790 return eSIR_SUCCESS;
5791
5792returnAfterError:
5793 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5794
5795 return statusCode;
5796} // End limSendLinkReportActionFrame.
5797
5798/**
5799 * \brief Send a Beacon Report Action frame
5800 *
5801 *
5802 * \param pMac Pointer to the global MAC structure
5803 *
5804 * \param dialog_token dialog token to be used in the action frame.
5805 *
5806 * \param num_report number of reports in pRRMReport.
5807 *
5808 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5809 *
5810 * \param peer mac address of peer station.
5811 *
5812 * \param psessionEntry address of session entry.
5813 *
5814 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5815 *
5816 *
5817 */
5818
5819tSirRetStatus
5820limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5821 tANI_U8 dialog_token,
5822 tANI_U8 num_report,
5823 tpSirMacRadioMeasureReport pRRMReport,
5824 tSirMacAddr peer,
5825 tpPESession psessionEntry
5826 )
5827{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305828 tSirRetStatus statusCode = eSIR_SUCCESS;
5829 tANI_U8 *pFrame;
5830 tpSirMacMgmtHdr pMacHdr;
5831 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305833 eHalStatus halstatus;
5834 tANI_U8 i;
5835 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005836
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005837 tDot11fRadioMeasurementReport *frm =
5838 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5839 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005840 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005841 return eSIR_FAILURE;
5842 }
5843
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 if ( psessionEntry == NULL )
5845 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005846 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005847 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 return eSIR_FAILURE;
5849 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305850 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005851
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005852 frm->Category.category = SIR_MAC_ACTION_RRM;
5853 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5854 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005855
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005856 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 -07005857
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005858 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005860 frm->MeasurementReport[i].type = pRRMReport[i].type;
5861 frm->MeasurementReport[i].token = pRRMReport[i].token;
5862 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 switch( pRRMReport[i].type )
5864 {
5865 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005866 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5867 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5868 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5869 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 break;
5871 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305872 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5873 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005874 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 break;
5876 }
5877 }
5878
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005879 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 if ( DOT11F_FAILED( nStatus ) )
5881 {
5882 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005883 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 nStatus );
5885 // We'll fall back on the worst case scenario:
5886 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005887 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005888 return eSIR_FAILURE;
5889 }
5890 else if ( DOT11F_WARNED( nStatus ) )
5891 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005892 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005894 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005895 }
5896
5897 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5898
5899 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5900 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5901 {
5902 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005903 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005904 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 return eSIR_FAILURE;
5906 }
5907
5908 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305909 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005910
5911 // Copy necessary info to BD
5912 if( eSIR_SUCCESS !=
5913 (statusCode = limPopulateMacHeader( pMac,
5914 pFrame,
5915 SIR_MAC_MGMT_FRAME,
5916 SIR_MAC_MGMT_ACTION,
5917 peer, psessionEntry->selfMacAddr)))
5918 goto returnAfterError;
5919
5920 // Update A3 with the BSSID
5921 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5922
5923 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5924
Chet Lanctot186b5732013-03-18 10:26:30 -07005925#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005926 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005927#endif
5928
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 // Now, we're ready to "pack" the frames
5930 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005931 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 pFrame + sizeof( tSirMacMgmtHdr ),
5933 nPayload,
5934 &nPayload );
5935
5936 if( DOT11F_FAILED( nStatus ))
5937 {
5938 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005939 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 nStatus );
5941
5942 // FIXME - Need to convert to tSirRetStatus
5943 statusCode = eSIR_FAILURE;
5944 goto returnAfterError;
5945 }
5946 else if( DOT11F_WARNED( nStatus ))
5947 {
5948 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005949 FL( "There were warnings while packing Radio "
5950 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 }
5952
5953 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005954 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 limPrintMacAddr( pMac, peer, LOGW );
5956
5957 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5959 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 )
5961 {
5962 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5963 }
5964
5965 if( eHAL_STATUS_SUCCESS !=
5966 (halstatus = halTxFrame( pMac,
5967 pPacket,
5968 (tANI_U16) nBytes,
5969 HAL_TXRX_FRM_802_11_MGMT,
5970 ANI_TXDIR_TODS,
5971 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5972 limTxComplete,
5973 pFrame, txFlag )))
5974 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005975 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 statusCode = eSIR_FAILURE;
5977 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005978 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 return statusCode;
5980 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005981 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005982 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005985
5986returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005987 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 return statusCode;
5990} // End limSendBeaconReportActionFrame.
5991
5992#endif
5993
5994#ifdef WLAN_FEATURE_11W
5995/**
5996 * \brief Send SA query response action frame to peer
5997 *
5998 * \sa limSendSaQueryResponseFrame
5999 *
6000 *
6001 * \param pMac The global tpAniSirGlobal object
6002 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006003 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006005 * \param peer The Mac address of the AP to which this action frame is addressed
6006 *
6007 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 *
6009 * \return eSIR_SUCCESS if setup completes successfully
6010 * eSIR_FAILURE is some problem is encountered
6011 */
6012
Chet Lanctot186b5732013-03-18 10:26:30 -07006013tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006014tSirMacAddr peer,tpPESession psessionEntry)
6015{
6016
Chet Lanctot186b5732013-03-18 10:26:30 -07006017 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 tANI_U8 *pFrame;
6019 tSirRetStatus nSirStatus;
6020 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006021 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 void *pPacket;
6023 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306024 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006025
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306026 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006027 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6028 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 action: 0 --> SA query request action frame
6030 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006031 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6032 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006034 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006035
Chet Lanctot186b5732013-03-18 10:26:30 -07006036 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6037 if ( DOT11F_FAILED( nStatus ) )
6038 {
6039 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6040 "or a SA Query Response (0x%08x)."),
6041 nStatus );
6042 // We'll fall back on the worst case scenario:
6043 nPayload = sizeof( tDot11fSaQueryRsp );
6044 }
6045 else if ( DOT11F_WARNED( nStatus ) )
6046 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006047 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006048 "the packed size for an SA Query Response"
6049 " (0x%08x)."), nStatus );
6050 }
6051
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6053 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6054 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6055 {
6056 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006057 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 return eSIR_FAILURE;
6059 }
6060
6061 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306062 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006063
Chet Lanctot186b5732013-03-18 10:26:30 -07006064 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006065 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006066 pFrame,
6067 SIR_MAC_MGMT_FRAME,
6068 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006069 peer, psessionEntry->selfMacAddr );
6070 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006071 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006072
Chet Lanctot186b5732013-03-18 10:26:30 -07006073 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6075
Chet Lanctot186b5732013-03-18 10:26:30 -07006076 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006077
Chet Lanctot186b5732013-03-18 10:26:30 -07006078 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6079 // in the FC
6080 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006081 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006082 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 }
6084
Chet Lanctot186b5732013-03-18 10:26:30 -07006085 // Pack 11w SA query response frame
6086 nStatus = dot11fPackSaQueryRsp( pMac,
6087 &frm,
6088 pFrame + sizeof( tSirMacMgmtHdr ),
6089 nPayload,
6090 &nPayload );
6091
6092 if ( DOT11F_FAILED( nStatus ))
6093 {
6094 limLog( pMac, LOGE,
6095 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6096 nStatus );
6097 // FIXME - Need to convert to tSirRetStatus
6098 nSirStatus = eSIR_FAILURE;
6099 goto returnAfterError;
6100 }
6101 else if ( DOT11F_WARNED( nStatus ))
6102 {
6103 limLog( pMac, LOGW,
6104 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6105 nStatus);
6106 }
6107
6108 limLog( pMac, LOG1,
6109 FL( "Sending a SA Query Response to " ));
6110 limPrintMacAddr( pMac, peer, LOGW );
6111
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006112 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006113#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006114 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6115 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006116#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006117 )
6118 {
6119 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6120 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006121
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006122 halstatus = halTxFrame( pMac,
6123 pPacket,
6124 (tANI_U16) nBytes,
6125 HAL_TXRX_FRM_802_11_MGMT,
6126 ANI_TXDIR_TODS,
6127 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6128 limTxComplete,
6129 pFrame, txFlag );
6130 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006131 {
6132 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6133 nSirStatus = eSIR_FAILURE;
6134 //Pkt will be freed up by the callback
6135 return nSirStatus;
6136 }
6137 else {
6138 return eSIR_SUCCESS;
6139 }
6140
6141returnAfterError:
6142 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6143 return nSirStatus;
6144} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006145#endif