blob: 405f29e1d5dd78e31651cbaf05dc24203a4130a2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
Jeff Johnson295189b2012-06-20 16:38:30 -070041/**
42 * \file limSendManagementFrames.c
43 *
44 * \brief Code for preparing and sending 802.11 Management frames
45 *
46 * Copyright (C) 2005-2007 Airgo Networks, Incorporated
47 *
48 */
49
50#include "sirApi.h"
51#include "aniGlobal.h"
52#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include "cfgApi.h"
54#include "utilsApi.h"
55#include "limTypes.h"
56#include "limUtils.h"
57#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070058#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070059#include "dot11f.h"
60#include "limStaHashApi.h"
61#include "schApi.h"
62#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080063#include "limAssocUtils.h"
64#include "limFT.h"
65
Jeff Johnson295189b2012-06-20 16:38:30 -070066#if defined WLAN_FEATURE_VOWIFI
67#include "rrmApi.h"
68#endif
69
70#ifdef FEATURE_WLAN_CCX
71#include <limCcxparserApi.h>
72#endif
73#include "wlan_qct_wda.h"
74#ifdef WLAN_FEATURE_11W
75#include "dot11fdefs.h"
76#endif
77
78
79////////////////////////////////////////////////////////////////////////
80
Jeff Johnson295189b2012-06-20 16:38:30 -070081
82/**
83 *
84 * \brief This function is called by various LIM modules to prepare the
85 * 802.11 frame MAC header
86 *
87 *
88 * \param pMac Pointer to Global MAC structure
89 *
90 * \param pBD Pointer to the frame buffer that needs to be populate
91 *
92 * \param type Type of the frame
93 *
94 * \param subType Subtype of the frame
95 *
96 * \return eHalStatus
97 *
98 *
99 * The pFrameBuf argument points to the beginning of the frame buffer to
100 * which - a) The 802.11 MAC header is set b) Following this MAC header
101 * will be the MGMT frame payload The payload itself is populated by the
102 * caller API
103 *
104 *
105 */
106
107tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
108 tANI_U8* pBD,
109 tANI_U8 type,
110 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530111 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700112{
113 tSirRetStatus statusCode = eSIR_SUCCESS;
114 tpSirMacMgmtHdr pMacHdr;
115
116 /// Prepare MAC management header
117 pMacHdr = (tpSirMacMgmtHdr) (pBD);
118
119 // Prepare FC
120 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
121 pMacHdr->fc.type = type;
122 pMacHdr->fc.subType = subType;
123
124 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530125 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700126 (tANI_U8 *) peerAddr,
127 sizeof( tSirMacAddr ));
128
129 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700130 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
131
132 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530133 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 (tANI_U8 *) peerAddr,
135 sizeof( tSirMacAddr ));
136 return statusCode;
137} /*** end limPopulateMacHeader() ***/
138
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700139#ifdef WLAN_FEATURE_11W
140/**
141 *
142 * \brief This function is called by various LIM modules to correctly set
143 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
144 *
145 *
146 * \param pMac Pointer to Global MAC structure
147 *
148 * \param psessionEntry Pointer to session corresponding to the connection
149 *
150 * \param peer Peer address of the STA to which the frame is to be sent
151 *
152 * \param pMacHdr Pointer to the frame MAC header
153 *
154 * \return nothing
155 *
156 *
157 */
158void
159limSetProtectedBit(tpAniSirGlobal pMac,
160 tpPESession psessionEntry,
161 tSirMacAddr peer,
162 tpSirMacMgmtHdr pMacHdr)
163{
164 tANI_U16 aid;
165 tpDphHashNode pStaDs;
166
167 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
168 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
169 {
170
171 pStaDs = dphLookupHashEntry( pMac, peer, &aid, &psessionEntry->dph.dphHashTable );
172 if( pStaDs != NULL )
173 if( pStaDs->rmfEnabled )
174 pMacHdr->fc.wep = 1;
175 }
176 else if ( psessionEntry->limRmfEnabled )
177 pMacHdr->fc.wep = 1;
178} /*** end limSetProtectedBit() ***/
179#endif
180
Jeff Johnson295189b2012-06-20 16:38:30 -0700181/**
182 * \brief limSendProbeReqMgmtFrame
183 *
184 *
185 * \param pMac Pointer to Global MAC structure
186 *
187 * \param pSsid SSID to be sent in Probe Request frame
188 *
189 * \param bssid BSSID to be sent in Probe Request frame
190 *
191 * \param nProbeDelay probe delay to be used before sending Probe Request
192 * frame
193 *
194 * \param nChannelNum Channel # on which the Probe Request is going out
195 *
196 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
197 *
198 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
199 *
200 * This function is called by various LIM modules to send Probe Request frame
201 * during active scan/learn phase.
202 * Probe request is sent out in the following scenarios:
203 * --heartbeat failure: session needed
204 * --join req: session needed
205 * --foreground scan: no session
206 * --background scan: no session
207 * --schBeaconProcessing: to get EDCA parameters: session needed
208 *
209 *
210 */
211tSirRetStatus
212limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
213 tSirMacSSid *pSsid,
214 tSirMacAddr bssid,
215 tANI_U8 nChannelNum,
216 tSirMacAddr SelfMacAddr,
217 tANI_U32 dot11mode,
218 tANI_U32 nAdditionalIELen,
219 tANI_U8 *pAdditionalIE)
220{
221 tDot11fProbeRequest pr;
222 tANI_U32 nStatus, nBytes, nPayload;
223 tSirRetStatus nSirStatus;
224 tANI_U8 *pFrame;
225 void *pPacket;
226 eHalStatus halstatus;
227 tpPESession psessionEntry;
228 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700230 tANI_U8 txFlag = 0;
231
232#ifndef GEN4_SCAN
233 return eSIR_FAILURE;
234#endif
235
236#if defined ( ANI_DVT_DEBUG )
237 return eSIR_FAILURE;
238#endif
239
240 /*
241 * session context may or may not be present, when probe request needs to be sent out.
242 * following cases exist:
243 * --heartbeat failure: session needed
244 * --join req: session needed
245 * --foreground scan: no session
246 * --background scan: no session
247 * --schBeaconProcessing: to get EDCA parameters: session needed
248 * If session context does not exist, some IEs will be populated from CFGs,
249 * e.g. Supported and Extended rate set IEs
250 */
251 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
252
253 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
254 // and then hand it off to 'dot11fPackProbeRequest' (for
255 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530256 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700257
258 // & delegating to assorted helpers:
259 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
260
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 if( nAdditionalIELen && pAdditionalIE )
262 {
263 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
264 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700265 /* Don't include 11b rate only when device is doing P2P Search */
266 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
267 ( p2pIe != NULL ) &&
268 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
269 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
270 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
271 ( ( psessionEntry != NULL ) &&
272 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
273 )
274 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 {
276 /* In the below API pass channel number > 14, do that it fills only
277 * 11a rates in supported rates */
278 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
279 }
280 else
281 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 PopulateDot11fSuppRates( pMac, nChannelNum,
283 &pr.SuppRates,psessionEntry);
284
285 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
286 {
287 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
288 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700290
291#if defined WLAN_FEATURE_VOWIFI
292 //Table 7-14 in IEEE Std. 802.11k-2008 says
293 //DS params "can" be present in RRM is disabled and "is" present if
294 //RRM is enabled. It should be ok even if we add it into probe req when
295 //RRM is not enabled.
296 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
297 //Call RRM module to get the tx power for management used.
298 {
299 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
300 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
301 }
302#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700303
304 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700305 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700306 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700307 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700308 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700309 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700311 } else { //psessionEntry == NULL
312 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700314 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 }
316 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800317
318 /* Set channelbonding information as "disabled" when tunned to a 2.4 GHz channel */
319 if( nChannelNum <= SIR_11B_CHANNEL_END)
320 {
321 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
322 pr.HTCaps.shortGI40MHz = 0;
323 }
324
Jeff Johnsone7245742012-09-05 17:12:55 -0700325#ifdef WLAN_FEATURE_11AC
326 if (psessionEntry != NULL ) {
327 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
328 //Include HT Capability IE
329 if (psessionEntry->vhtCapability)
330 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700331 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
332 }
333 } else {
334 if (IS_DOT11_MODE_VHT(dot11mode))
335 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700336 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
337 }
338 }
339#endif
340
Jeff Johnson295189b2012-06-20 16:38:30 -0700341
342 // That's it-- now we pack it. First, how much space are we going to
343 // need?
344 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
345 if ( DOT11F_FAILED( nStatus ) )
346 {
347 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700348 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 // We'll fall back on the worst case scenario:
350 nPayload = sizeof( tDot11fProbeRequest );
351 }
352 else if ( DOT11F_WARNED( nStatus ) )
353 {
354 limLog( pMac, LOGW, FL("There were warnings while calculating"
355 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700356 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 }
358
359 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
360
361 // Ok-- try to allocate some memory:
362 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
363 ( tANI_U16 )nBytes, ( void** ) &pFrame,
364 ( void** ) &pPacket );
365 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
366 {
367 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700368 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 return eSIR_MEM_ALLOC_FAILED;
370 }
371
372 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530373 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700374
375 // Next, we fill out the buffer descriptor:
376 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530377 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 if ( eSIR_SUCCESS != nSirStatus )
379 {
380 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700381 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 nSirStatus );
383 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
384 ( void* ) pFrame, ( void* ) pPacket );
385 return nSirStatus; // allocated!
386 }
387
388 // That done, pack the Probe Request:
389 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
390 sizeof( tSirMacMgmtHdr ),
391 nPayload, &nPayload );
392 if ( DOT11F_FAILED( nStatus ) )
393 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700394 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 nStatus );
396 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
397 return eSIR_FAILURE; // allocated!
398 }
399 else if ( DOT11F_WARNED( nStatus ) )
400 {
401 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700402 "robe Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700403 }
404
405 // Append any AddIE if present.
406 if( nAdditionalIELen )
407 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530408 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 pAdditionalIE, nAdditionalIELen );
410 nPayload += nAdditionalIELen;
411 }
412
413 /* If this probe request is sent during P2P Search State, then we need
414 * to send it at OFDM rate.
415 */
416 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700417 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
418 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530419 /* For unicast probe req mgmt from Join function
420 we don't set above variables. So we need to add
421 one more check whether it is pePersona is P2P_CLIENT or not */
422 || ( ( psessionEntry != NULL ) &&
423 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700424 )
425 {
426 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
427 }
428
429
430 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
431 HAL_TXRX_FRM_802_11_MGMT,
432 ANI_TXDIR_TODS,
433 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
434 limTxComplete, pFrame, txFlag );
435 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
436 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700437 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700438 //Pkt will be freed up by the callback
439 return eSIR_FAILURE;
440 }
441
442 return eSIR_SUCCESS;
443} // End limSendProbeReqMgmtFrame.
444
Jeff Johnson295189b2012-06-20 16:38:30 -0700445tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
446 tANI_U8* addIE, tANI_U16 *addnIELen,
447 tANI_U8 probeReqP2pIe)
448{
449 /* If Probe request doesn't have P2P IE, then take out P2P IE
450 from additional IE */
451 if(!probeReqP2pIe)
452 {
453 tANI_U8* tempbuf = NULL;
454 tANI_U16 tempLen = 0;
455 int left = *addnIELen;
456 v_U8_t *ptr = addIE;
457 v_U8_t elem_id, elem_len;
458
459 if(NULL == addIE)
460 {
461 PELOGE(limLog(pMac, LOGE,
462 FL(" NULL addIE pointer"));)
463 return eSIR_FAILURE;
464 }
465
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530466 tempbuf = vos_mem_malloc(left);
467 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 {
469 PELOGE(limLog(pMac, LOGE,
470 FL("Unable to allocate memory to store addn IE"));)
471 return eSIR_MEM_ALLOC_FAILED;
472 }
473
474 while(left >= 2)
475 {
476 elem_id = ptr[0];
477 elem_len = ptr[1];
478 left -= 2;
479 if(elem_len > left)
480 {
481 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700482 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700483 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530484 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 return eSIR_FAILURE;
486 }
487 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
488 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
489 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530490 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 tempLen += (elem_len + 2);
492 }
493 left -= elem_len;
494 ptr += (elem_len + 2);
495 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530496 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530498 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 }
500 return eSIR_SUCCESS;
501}
Jeff Johnson295189b2012-06-20 16:38:30 -0700502
503void
504limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
505 tSirMacAddr peerMacAddr,
506 tpAniSSID pSsid,
507 short nStaId,
508 tANI_U8 nKeepAlive,
509 tpPESession psessionEntry,
510 tANI_U8 probeReqP2pIe)
511{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700512 tDot11fProbeResponse *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 tSirRetStatus nSirStatus;
514 tANI_U32 cfg, nPayload, nBytes, nStatus;
515 tpSirMacMgmtHdr pMacHdr;
516 tANI_U8 *pFrame;
517 void *pPacket;
518 eHalStatus halstatus;
519 tANI_U32 addnIEPresent;
520 tANI_U32 addnIE1Len=0;
521 tANI_U32 addnIE2Len=0;
522 tANI_U32 addnIE3Len=0;
523 tANI_U16 totalAddnIeLen = 0;
524 tANI_U32 wpsApEnable=0, tmp;
525 tANI_U8 txFlag = 0;
526 tANI_U8 *addIE = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 tANI_U8 *pP2pIe = NULL;
528 tANI_U8 noaLen = 0;
529 tANI_U8 total_noaLen = 0;
530 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
531 + SIR_P2P_IE_HEADER_LEN];
532 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
534 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
535 {
536 return; // in this case.
537 }
538
539 if(NULL == psessionEntry)
540 {
541 return;
542 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530543
544 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
545 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700546 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530547 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700548 return;
549 }
550
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 // Fill out 'frm', after which we'll just hand the struct off to
552 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530553 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700554
555 // Timestamp to be updated by TFP, below.
556
557 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
559 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700560 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 }
562 else
563 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800564 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
565 if (eSIR_SUCCESS != nSirStatus)
566 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700567 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800568 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530569 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800570 return;
571 }
572 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800573 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700574
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700575 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
576 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700578 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700580 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
581 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700582
Jeff Johnson295189b2012-06-20 16:38:30 -0700583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
585 {
586 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
587 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700588 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 }
590 }
591 else
592 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800593 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700594 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700595
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800596 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700597
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800598 if (wpsApEnable)
599 {
600 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
601 }
602
603 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
604 {
605 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
606 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
607 }
608
609 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
610 {
611 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
612 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
613 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700615
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700616 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
617 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700618
Jeff Johnson295189b2012-06-20 16:38:30 -0700619
620 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700621 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700622
623
624 // N.B. In earlier implementations, the RSN IE would be placed in
625 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
626 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700627 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700628
629 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700630 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700632 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700633 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700635#ifdef WLAN_FEATURE_11AC
636 if(psessionEntry->vhtCapability)
637 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700638 limLog( pMac, LOGW, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700639 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
640 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700641 // we do not support multi users yet
642 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700643 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700644 }
645#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700646
647 if ( psessionEntry->pLimStartBssReq )
648 {
649 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700650 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700651 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
652 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 }
654
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700655 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700656
657#if defined(FEATURE_WLAN_WAPI)
658 if( psessionEntry->pLimStartBssReq )
659 {
660 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700661 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 }
663
664#endif // defined(FEATURE_WLAN_WAPI)
665
666
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700667 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 if ( DOT11F_FAILED( nStatus ) )
669 {
670 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700671 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 nStatus );
673 // We'll fall back on the worst case scenario:
674 nPayload = sizeof( tDot11fProbeResponse );
675 }
676 else if ( DOT11F_WARNED( nStatus ) )
677 {
678 limLog( pMac, LOGW, FL("There were warnings while calculating"
679 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700680 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700681 }
682
683 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
684
685 addnIEPresent = false;
686
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 if( pMac->lim.gpLimRemainOnChanReq )
688 {
689 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
690 }
691 //Only use CFG for non-listen mode. This CFG is not working for concurrency
692 //In listening mode, probe rsp IEs is passed in the message from SME to PE
693 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 {
695
696 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
697 &addnIEPresent) != eSIR_SUCCESS)
698 {
699 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530700 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 return;
702 }
703 }
704
705 if (addnIEPresent)
706 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530707
708 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
709 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 {
711 PELOGE(limLog(pMac, LOGE,
712 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530713 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 return;
715 }
716
717 //Probe rsp IE available
718 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
719 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
720 {
721 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530722 vos_mem_free(addIE);
723 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 return;
725 }
726 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
727 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
728 {
729 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
730 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
731 &addnIE1Len) )
732 {
733 limLog(pMac, LOGP,
734 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530735 vos_mem_free(addIE);
736 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 return;
738 }
739 }
740
741 //Probe rsp IE available
742 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
743 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
744 {
745 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530746 vos_mem_free(addIE);
747 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 return;
749 }
750 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
751 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
752 {
753 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
754 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
755 &addnIE2Len) )
756 {
757 limLog(pMac, LOGP,
758 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530759 vos_mem_free(addIE);
760 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 return;
762 }
763 }
764
765 //Probe rsp IE available
766 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
767 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
768 {
769 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530770 vos_mem_free(addIE);
771 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 return;
773 }
774 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
775 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
776 {
777 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
778 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
779 &addIE[addnIE1Len + addnIE2Len],
780 &addnIE3Len) )
781 {
782 limLog(pMac, LOGP,
783 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530784 vos_mem_free(addIE);
785 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 return;
787 }
788 }
789 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
790
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
792 {
793 limLog(pMac, LOGP,
794 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530795 vos_mem_free(addIE);
796 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 return;
798 }
799 nBytes = nBytes + totalAddnIeLen;
800
801 if (probeReqP2pIe)
802 {
803 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
804 if (pP2pIe != NULL)
805 {
806 //get NoA attribute stream P2P IE
807 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
808 if (noaLen != 0)
809 {
810 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
811 &noaStream[0], noaLen);
812 nBytes = nBytes + total_noaLen;
813 }
814 }
815 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700816 }
817
818 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
819 ( tANI_U16 )nBytes, ( void** ) &pFrame,
820 ( void** ) &pPacket );
821 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
822 {
823 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700824 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 if ( addIE != NULL )
826 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530827 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530829 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 return;
831 }
832
833 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530834 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700835
836 // Next, we fill out the buffer descriptor:
837 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
838 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
839 if ( eSIR_SUCCESS != nSirStatus )
840 {
841 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700842 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 nSirStatus );
844 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
845 ( void* ) pFrame, ( void* ) pPacket );
846 if ( addIE != NULL )
847 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530848 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530850 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 return;
852 }
853
854 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
855
856 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
857
858 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700859 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 nPayload, &nPayload );
861 if ( DOT11F_FAILED( nStatus ) )
862 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700863 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 nStatus );
865 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
866 if ( addIE != NULL )
867 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530868 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530870 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 return; // allocated!
872 }
873 else if ( DOT11F_WARNED( nStatus ) )
874 {
875 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700876 "robe Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 }
878
879 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
880 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
881
882 pMac->sys.probeRespond++;
883
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 if( pMac->lim.gpLimRemainOnChanReq )
885 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530886 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
888 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700889
890 if ( addnIEPresent )
891 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530892 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 if (noaLen != 0)
895 {
Krunal Soni81b24262013-05-15 17:46:41 -0700896 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 {
898 limLog(pMac, LOGE,
899 FL("Not able to insert NoA because of length constraint"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530900 vos_mem_free(addIE);
901 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -0700902 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
903 ( void* ) pFrame, ( void* ) pPacket );
904 return;
905 }
906 else
907 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530908 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -0700909 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 }
911 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700912
913 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
915 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 )
917 {
918 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
919 }
920
921 // Queue Probe Response frame in high priority WQ
922 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
923 ( tANI_U16 ) nBytes,
924 HAL_TXRX_FRM_802_11_MGMT,
925 ANI_TXDIR_TODS,
926 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
927 limTxComplete, pFrame, txFlag );
928 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
929 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700930 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 //Pkt will be freed up by the callback
932 }
933
934 if ( addIE != NULL )
935 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530936 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 }
938
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530939 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700940 return;
941
942
Jeff Johnson295189b2012-06-20 16:38:30 -0700943} // End limSendProbeRspMgmtFrame.
944
945void
946limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
947 tSirMacAddr peerMacAddr,
948 tSirAddtsReqInfo *pAddTS,
949 tpPESession psessionEntry)
950{
951 tANI_U16 i;
952 tANI_U8 *pFrame;
953 tSirRetStatus nSirStatus;
954 tDot11fAddTSRequest AddTSReq;
955 tDot11fWMMAddTSRequest WMMAddTSReq;
956 tANI_U32 nPayload, nBytes, nStatus;
957 tpSirMacMgmtHdr pMacHdr;
958 void *pPacket;
959#ifdef FEATURE_WLAN_CCX
960 tANI_U32 phyMode;
961#endif
962 eHalStatus halstatus;
963 tANI_U8 txFlag = 0;
964
965 if(NULL == psessionEntry)
966 {
967 return;
968 }
969
970 if ( ! pAddTS->wmeTspecPresent )
971 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530972 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700973
974 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
975 AddTSReq.DialogToken.token = pAddTS->dialogToken;
976 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
977 if ( pAddTS->lleTspecPresent )
978 {
979 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
980 }
981 else
982 {
983 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
984 }
985
986 if ( pAddTS->lleTspecPresent )
987 {
988 AddTSReq.num_WMMTCLAS = 0;
989 AddTSReq.num_TCLAS = pAddTS->numTclas;
990 for ( i = 0; i < pAddTS->numTclas; ++i)
991 {
992 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
993 &AddTSReq.TCLAS[i] );
994 }
995 }
996 else
997 {
998 AddTSReq.num_TCLAS = 0;
999 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1000 for ( i = 0; i < pAddTS->numTclas; ++i)
1001 {
1002 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1003 &AddTSReq.WMMTCLAS[i] );
1004 }
1005 }
1006
1007 if ( pAddTS->tclasProcPresent )
1008 {
1009 if ( pAddTS->lleTspecPresent )
1010 {
1011 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1012 AddTSReq.TCLASSPROC.present = 1;
1013 }
1014 else
1015 {
1016 AddTSReq.WMMTCLASPROC.version = 1;
1017 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1018 AddTSReq.WMMTCLASPROC.present = 1;
1019 }
1020 }
1021
1022 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1023 if ( DOT11F_FAILED( nStatus ) )
1024 {
1025 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001026 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 nStatus );
1028 // We'll fall back on the worst case scenario:
1029 nPayload = sizeof( tDot11fAddTSRequest );
1030 }
1031 else if ( DOT11F_WARNED( nStatus ) )
1032 {
1033 limLog( pMac, LOGW, FL("There were warnings while calculating"
1034 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001035 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 }
1037 }
1038 else
1039 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301040 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001041
1042 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1043 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1044 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1045
1046 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1047 WMMAddTSReq.StatusCode.statusCode = 0;
1048
1049 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1050#ifdef FEATURE_WLAN_CCX
1051 limGetPhyMode(pMac, &phyMode, psessionEntry);
1052
1053 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1054 {
1055 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1056 }
1057 else
1058 {
1059 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1060 }
1061 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1062#endif
1063 // fillWmeTspecIE
1064
1065 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1066 if ( DOT11F_FAILED( nStatus ) )
1067 {
1068 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001069 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 nStatus );
1071 // We'll fall back on the worst case scenario:
1072 nPayload = sizeof( tDot11fAddTSRequest );
1073 }
1074 else if ( DOT11F_WARNED( nStatus ) )
1075 {
1076 limLog( pMac, LOGW, FL("There were warnings while calculating"
1077 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001078 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 }
1080 }
1081
1082 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1083
1084 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1085 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1086 ( void** ) &pPacket );
1087 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1088 {
1089 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001090 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 return;
1092 }
1093
1094 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301095 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001096
1097 // Next, we fill out the buffer descriptor:
1098 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1099 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1100 if ( eSIR_SUCCESS != nSirStatus )
1101 {
1102 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001103 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 nSirStatus );
1105 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1106 ( void* ) pFrame, ( void* ) pPacket );
1107 return;
1108 }
1109
1110 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1111
1112 #if 0
1113 cfgLen = SIR_MAC_ADDR_LENGTH;
1114 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1115 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1116 {
1117 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001118 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1120 ( void* ) pFrame, ( void* ) pPacket );
1121 return;
1122 }
1123 #endif //TO SUPPORT BT-AMP
1124
1125 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1126
Chet Lanctot186b5732013-03-18 10:26:30 -07001127#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001128 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001129#endif
1130
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 // That done, pack the struct:
1132 if ( ! pAddTS->wmeTspecPresent )
1133 {
1134 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1135 pFrame + sizeof(tSirMacMgmtHdr),
1136 nPayload, &nPayload );
1137 if ( DOT11F_FAILED( nStatus ) )
1138 {
1139 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001140 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001141 nStatus );
1142 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1143 return; // allocated!
1144 }
1145 else if ( DOT11F_WARNED( nStatus ) )
1146 {
1147 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001148 "an Add TS Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 }
1150 }
1151 else
1152 {
1153 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1154 pFrame + sizeof(tSirMacMgmtHdr),
1155 nPayload, &nPayload );
1156 if ( DOT11F_FAILED( nStatus ) )
1157 {
1158 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001159 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 nStatus );
1161 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1162 return; // allocated!
1163 }
1164 else if ( DOT11F_WARNED( nStatus ) )
1165 {
1166 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001167 "a WMM Add TS Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 }
1169 }
1170
1171 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1172 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1173
1174 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1176 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 )
1178 {
1179 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1180 }
1181
1182 // Queue Addts Response frame in high priority WQ
1183 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1184 HAL_TXRX_FRM_802_11_MGMT,
1185 ANI_TXDIR_TODS,
1186 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1187 limTxComplete, pFrame, txFlag );
1188 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1189 {
1190 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001191 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 //Pkt will be freed up by the callback
1193 }
1194
1195} // End limSendAddtsReqActionFrame.
1196
Jeff Johnson295189b2012-06-20 16:38:30 -07001197
1198
1199void
1200limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1201 tANI_U16 statusCode,
1202 tANI_U16 aid,
1203 tSirMacAddr peerMacAddr,
1204 tANI_U8 subType,
1205 tpDphHashNode pSta,tpPESession psessionEntry)
1206{
1207 static tDot11fAssocResponse frm;
1208 tANI_U8 *pFrame, *macAddr;
1209 tpSirMacMgmtHdr pMacHdr;
1210 tSirRetStatus nSirStatus;
1211 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1212 tHalBitVal qosMode, wmeMode;
1213 tANI_U32 nPayload, nBytes, nStatus;
1214 void *pPacket;
1215 eHalStatus halstatus;
1216 tUpdateBeaconParams beaconParams;
1217 tANI_U8 txFlag = 0;
1218 tANI_U32 addnIEPresent = false;
1219 tANI_U32 addnIELen=0;
1220 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1221 tpSirAssocReq pAssocReq = NULL;
1222
1223 if(NULL == psessionEntry)
1224 {
1225 return;
1226 }
1227
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301228 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001229
1230 limGetQosMode(psessionEntry, &qosMode);
1231 limGetWmeMode(psessionEntry, &wmeMode);
1232
1233 // An Add TS IE is added only if the AP supports it and the requesting
1234 // STA sent a traffic spec.
1235 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1236
1237 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1238
1239 frm.Status.status = statusCode;
1240
1241 frm.AID.associd = aid | LIM_AID_MASK;
1242
1243 if ( NULL == pSta )
1244 {
1245 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1246 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1247 }
1248 else
1249 {
1250 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1251 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1252 }
1253
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1255 {
1256 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1257 {
1258 pAssocReq =
1259 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1261 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1262 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1263 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001264 }
1265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001266
1267 if ( NULL != pSta )
1268 {
1269 if ( eHAL_SET == qosMode )
1270 {
1271 if ( pSta->lleEnabled )
1272 {
1273 lleMode = 1;
1274 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1275 {
1276 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1277
1278// FramesToDo:...
1279// if ( fAddTS )
1280// {
1281// tANI_U8 *pAf = pBody;
1282// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1283// tANI_U32 tlen;
1284// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1285// &tlen, bufLen - frameLen);
1286// } // End if on Add TS.
1287 }
1288 } // End if on .11e enabled in 'pSta'.
1289 } // End if on QOS Mode on.
1290
1291 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1292 {
1293 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1294 {
1295
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001297
1298 if ( pSta->wsmEnabled )
1299 {
1300 PopulateDot11fWMMCaps(&frm.WMMCaps );
1301 }
1302 }
1303 }
1304
1305 if ( pSta->aniPeer )
1306 {
1307 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1308 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1309 {
1310 edcaInclude = 1;
1311 }
1312
1313 } // End if on Airgo peer.
1314
1315 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001316 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001318 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001321
1322#ifdef WLAN_FEATURE_11AC
1323 if( pSta->mlmStaContext.vhtCapability &&
1324 psessionEntry->vhtCapability )
1325 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001326 limLog( pMac, LOGW, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001327 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1328 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001329 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001330 }
1331#endif
1332
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 } // End if on non-NULL 'pSta'.
1334
1335
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301336 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001337
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1339 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1340 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001342
1343 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1344 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1345
1346 beaconParams.bssIdx = psessionEntry->bssIdx;
1347
1348 //Send message to HAL about beacon parameter change.
1349 if(beaconParams.paramChangeBitmap)
1350 {
1351 schSetFixedBeaconFields(pMac,psessionEntry);
1352 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1353 }
1354
1355 // Allocate a buffer for this frame:
1356 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1357 if ( DOT11F_FAILED( nStatus ) )
1358 {
1359 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001360 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 nStatus );
1362 return;
1363 }
1364 else if ( DOT11F_WARNED( nStatus ) )
1365 {
1366 limLog( pMac, LOGW, FL("There were warnings while calculating"
1367 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001368 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001369 }
1370
1371 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1372
1373 if ( pAssocReq != NULL )
1374 {
1375 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1376 &addnIEPresent) != eSIR_SUCCESS)
1377 {
1378 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
1379 return;
1380 }
1381
1382 if (addnIEPresent)
1383 {
1384 //Assoc rsp IE available
1385 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1386 &addnIELen) != eSIR_SUCCESS)
1387 {
1388 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
1389 return;
1390 }
1391
1392 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1393 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1394 {
1395 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1396 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1397 {
1398 nBytes = nBytes + addnIELen;
1399 }
1400 }
1401 }
1402 }
1403
1404 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1405 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1406 ( void** ) &pPacket );
1407 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1408 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001409 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 return;
1411 }
1412
1413 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301414 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001415
1416 // Next, we fill out the buffer descriptor:
1417 nSirStatus = limPopulateMacHeader( pMac,
1418 pFrame,
1419 SIR_MAC_MGMT_FRAME,
1420 ( LIM_ASSOC == subType ) ?
1421 SIR_MAC_MGMT_ASSOC_RSP :
1422 SIR_MAC_MGMT_REASSOC_RSP,
1423 peerMacAddr,psessionEntry->selfMacAddr);
1424 if ( eSIR_SUCCESS != nSirStatus )
1425 {
1426 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001427 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 nSirStatus );
1429 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1430 ( void* ) pFrame, ( void* ) pPacket );
1431 return;
1432 }
1433
1434 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1435
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1437
1438 nStatus = dot11fPackAssocResponse( pMac, &frm,
1439 pFrame + sizeof( tSirMacMgmtHdr ),
1440 nPayload, &nPayload );
1441 if ( DOT11F_FAILED( nStatus ) )
1442 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001443 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 nStatus );
1445 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1446 ( void* ) pFrame, ( void* ) pPacket );
1447 return; // allocated!
1448 }
1449 else if ( DOT11F_WARNED( nStatus ) )
1450 {
1451 limLog( pMac, LOGW, FL("There were warnings while packing an "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001452 "Association Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 }
1454
1455 macAddr = pMacHdr->da;
1456
1457 if (subType == LIM_ASSOC)
1458 {
1459 PELOG1(limLog(pMac, LOG1,
1460 FL("*** Sending Assoc Resp status %d aid %d to "),
1461 statusCode, aid);)
1462 }
1463 else{
1464 PELOG1(limLog(pMac, LOG1,
1465 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1466 statusCode, aid);)
1467 }
1468 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1469
1470 if ( addnIEPresent )
1471 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301472 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 }
1474
1475 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1477 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 )
1479 {
1480 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1481 }
1482
1483 /// Queue Association Response frame in high priority WQ
1484 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1485 HAL_TXRX_FRM_802_11_MGMT,
1486 ANI_TXDIR_TODS,
1487 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1488 limTxComplete, pFrame, txFlag );
1489 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1490 {
1491 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001492 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 nSirStatus);
1494
1495 //Pkt will be freed up by the callback
1496 }
1497
1498 // update the ANI peer station count
1499 //FIXME_PROTECTION : take care of different type of station
1500 // counter inside this function.
1501 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1502
1503} // End limSendAssocRspMgmtFrame.
1504
1505
1506
1507void
1508limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1509 tSirMacAddr peer,
1510 tANI_U16 nStatusCode,
1511 tSirAddtsReqInfo *pAddTS,
1512 tSirMacScheduleIE *pSchedule,
1513 tpPESession psessionEntry)
1514{
1515 tANI_U8 *pFrame;
1516 tpSirMacMgmtHdr pMacHdr;
1517 tDot11fAddTSResponse AddTSRsp;
1518 tDot11fWMMAddTSResponse WMMAddTSRsp;
1519 tSirRetStatus nSirStatus;
1520 tANI_U32 i, nBytes, nPayload, nStatus;
1521 void *pPacket;
1522 eHalStatus halstatus;
1523 tANI_U8 txFlag = 0;
1524
1525 if(NULL == psessionEntry)
1526 {
1527 return;
1528 }
1529
1530 if ( ! pAddTS->wmeTspecPresent )
1531 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301532 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001533
1534 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1535 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1536 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1537 AddTSRsp.Status.status = nStatusCode;
1538
1539 // The TsDelay information element is only filled in for a specific
1540 // status code:
1541 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1542 {
1543 if ( pAddTS->wsmTspecPresent )
1544 {
1545 AddTSRsp.WMMTSDelay.version = 1;
1546 AddTSRsp.WMMTSDelay.delay = 10;
1547 AddTSRsp.WMMTSDelay.present = 1;
1548 }
1549 else
1550 {
1551 AddTSRsp.TSDelay.delay = 10;
1552 AddTSRsp.TSDelay.present = 1;
1553 }
1554 }
1555
1556 if ( pAddTS->wsmTspecPresent )
1557 {
1558 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1559 }
1560 else
1561 {
1562 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1563 }
1564
1565 if ( pAddTS->wsmTspecPresent )
1566 {
1567 AddTSRsp.num_WMMTCLAS = 0;
1568 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1569 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1570 {
1571 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1572 &AddTSRsp.TCLAS[i] );
1573 }
1574 }
1575 else
1576 {
1577 AddTSRsp.num_TCLAS = 0;
1578 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1579 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1580 {
1581 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1582 &AddTSRsp.WMMTCLAS[i] );
1583 }
1584 }
1585
1586 if ( pAddTS->tclasProcPresent )
1587 {
1588 if ( pAddTS->wsmTspecPresent )
1589 {
1590 AddTSRsp.WMMTCLASPROC.version = 1;
1591 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1592 AddTSRsp.WMMTCLASPROC.present = 1;
1593 }
1594 else
1595 {
1596 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1597 AddTSRsp.TCLASSPROC.present = 1;
1598 }
1599 }
1600
1601 // schedule element is included only if requested in the tspec and we are
1602 // using hcca (or both edca and hcca)
1603 // 11e-D8.0 is inconsistent on whether the schedule element is included
1604 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1605 // pg 46, line 17-18 says something else. So just include it and let the
1606 // sta figure it out
1607 if ((pSchedule != NULL) &&
1608 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1609 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1610 {
1611 if ( pAddTS->wsmTspecPresent )
1612 {
1613 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1614 }
1615 else
1616 {
1617 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1618 }
1619 }
1620
1621 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1622 if ( DOT11F_FAILED( nStatus ) )
1623 {
1624 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001625 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 nStatus );
1627 // We'll fall back on the worst case scenario:
1628 nPayload = sizeof( tDot11fAddTSResponse );
1629 }
1630 else if ( DOT11F_WARNED( nStatus ) )
1631 {
1632 limLog( pMac, LOGW, FL("There were warnings while calcula"
1633 "tingthe packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001634 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 }
1636 }
1637 else
1638 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301639 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001640
1641 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1642 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1643 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1644 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1645
1646 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1647
1648 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1649 if ( DOT11F_FAILED( nStatus ) )
1650 {
1651 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001652 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 nStatus );
1654 // We'll fall back on the worst case scenario:
1655 nPayload = sizeof( tDot11fWMMAddTSResponse );
1656 }
1657 else if ( DOT11F_WARNED( nStatus ) )
1658 {
1659 limLog( pMac, LOGW, FL("There were warnings while calcula"
1660 "tingthe packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001661 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 }
1663 }
1664
1665 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1666
1667 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1668 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1669 {
1670 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001671 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 return;
1673 }
1674
1675 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301676 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001677
1678 // Next, we fill out the buffer descriptor:
1679 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1680 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1681 if ( eSIR_SUCCESS != nSirStatus )
1682 {
1683 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001684 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 nSirStatus );
1686 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1687 return; // allocated!
1688 }
1689
1690 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1691
1692
1693 #if 0
1694 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1695 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1696 {
1697 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001698 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1700 return; // allocated!
1701 }
1702 #endif //TO SUPPORT BT-AMP
1703 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1704
Chet Lanctot186b5732013-03-18 10:26:30 -07001705#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001706 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001707#endif
1708
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 // That done, pack the struct:
1710 if ( ! pAddTS->wmeTspecPresent )
1711 {
1712 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1713 pFrame + sizeof( tSirMacMgmtHdr ),
1714 nPayload, &nPayload );
1715 if ( DOT11F_FAILED( nStatus ) )
1716 {
1717 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001718 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 nStatus );
1720 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1721 return;
1722 }
1723 else if ( DOT11F_WARNED( nStatus ) )
1724 {
1725 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001726 "an Add TS Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 }
1728 }
1729 else
1730 {
1731 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1732 pFrame + sizeof( tSirMacMgmtHdr ),
1733 nPayload, &nPayload );
1734 if ( DOT11F_FAILED( nStatus ) )
1735 {
1736 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001737 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 nStatus );
1739 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1740 return;
1741 }
1742 else if ( DOT11F_WARNED( nStatus ) )
1743 {
1744 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001745 "a WMM Add TS Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 }
1747 }
1748
1749 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1750 nStatusCode );
1751 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1752
1753 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1755 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 )
1757 {
1758 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1759 }
1760
1761 // Queue the frame in high priority WQ:
1762 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1763 HAL_TXRX_FRM_802_11_MGMT,
1764 ANI_TXDIR_TODS,
1765 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1766 limTxComplete, pFrame, txFlag );
1767 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1768 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001769 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 nSirStatus );
1771 //Pkt will be freed up by the callback
1772 }
1773
1774} // End limSendAddtsRspActionFrame.
1775
1776void
1777limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1778 tSirMacAddr peer,
1779 tANI_U8 wmmTspecPresent,
1780 tSirMacTSInfo *pTsinfo,
1781 tSirMacTspecIE *pTspecIe,
1782 tpPESession psessionEntry)
1783{
1784 tANI_U8 *pFrame;
1785 tpSirMacMgmtHdr pMacHdr;
1786 tDot11fDelTS DelTS;
1787 tDot11fWMMDelTS WMMDelTS;
1788 tSirRetStatus nSirStatus;
1789 tANI_U32 nBytes, nPayload, nStatus;
1790 void *pPacket;
1791 eHalStatus halstatus;
1792 tANI_U8 txFlag = 0;
1793
1794 if(NULL == psessionEntry)
1795 {
1796 return;
1797 }
1798
1799 if ( ! wmmTspecPresent )
1800 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301801 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001802
1803 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1804 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1805 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1806
1807 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1808 if ( DOT11F_FAILED( nStatus ) )
1809 {
1810 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001811 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 nStatus );
1813 // We'll fall back on the worst case scenario:
1814 nPayload = sizeof( tDot11fDelTS );
1815 }
1816 else if ( DOT11F_WARNED( nStatus ) )
1817 {
1818 limLog( pMac, LOGW, FL("There were warnings while calcula"
1819 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001820 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 }
1822 }
1823 else
1824 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301825 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001826
1827 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1828 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1829 WMMDelTS.DialogToken.token = 0;
1830 WMMDelTS.StatusCode.statusCode = 0;
1831 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1832 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1833 if ( DOT11F_FAILED( nStatus ) )
1834 {
1835 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001836 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 nStatus );
1838 // We'll fall back on the worst case scenario:
1839 nPayload = sizeof( tDot11fDelTS );
1840 }
1841 else if ( DOT11F_WARNED( nStatus ) )
1842 {
1843 limLog( pMac, LOGW, FL("There were warnings while calcula"
1844 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001845 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001846 }
1847 }
1848
1849 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1850
1851 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1852 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1853 {
1854 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001855 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 return;
1857 }
1858
1859 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301860 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001861
1862 // Next, we fill out the buffer descriptor:
1863 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1864 SIR_MAC_MGMT_ACTION, peer,
1865 psessionEntry->selfMacAddr);
1866 if ( eSIR_SUCCESS != nSirStatus )
1867 {
1868 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001869 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 nSirStatus );
1871 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1872 return; // allocated!
1873 }
1874
1875 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1876
1877 #if 0
1878
1879 cfgLen = SIR_MAC_ADDR_LENGTH;
1880 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1881 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1882 {
1883 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001884 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1886 return; // allocated!
1887 }
1888 #endif //TO SUPPORT BT-AMP
1889 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1890
Chet Lanctot186b5732013-03-18 10:26:30 -07001891#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001892 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001893#endif
1894
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 // That done, pack the struct:
1896 if ( !wmmTspecPresent )
1897 {
1898 nStatus = dot11fPackDelTS( pMac, &DelTS,
1899 pFrame + sizeof( tSirMacMgmtHdr ),
1900 nPayload, &nPayload );
1901 if ( DOT11F_FAILED( nStatus ) )
1902 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001903 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 nStatus );
1905 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1906 return; // allocated!
1907 }
1908 else if ( DOT11F_WARNED( nStatus ) )
1909 {
1910 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001911 "a Del TS frame (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 }
1913 }
1914 else
1915 {
1916 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1917 pFrame + sizeof( tSirMacMgmtHdr ),
1918 nPayload, &nPayload );
1919 if ( DOT11F_FAILED( nStatus ) )
1920 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001921 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 nStatus );
1923 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1924 return; // allocated!
1925 }
1926 else if ( DOT11F_WARNED( nStatus ) )
1927 {
1928 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001929 "a WMM Del TS frame (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 }
1931 }
1932
1933 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1934 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1935
1936 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1938 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 )
1940 {
1941 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1942 }
1943
1944 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1945 HAL_TXRX_FRM_802_11_MGMT,
1946 ANI_TXDIR_TODS,
1947 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1948 limTxComplete, pFrame, txFlag );
1949 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1950 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001951 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 nSirStatus );
1953 //Pkt will be freed up by the callback
1954 }
1955
1956} // End limSendDeltsReqActionFrame.
1957
1958void
1959limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1960 tLimMlmAssocReq *pMlmAssocReq,
1961 tpPESession psessionEntry)
1962{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001963 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 tANI_U16 caps;
1965 tANI_U8 *pFrame;
1966 tSirRetStatus nSirStatus;
1967 tLimMlmAssocCnf mlmAssocCnf;
1968 tANI_U32 nBytes, nPayload, nStatus;
1969 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1970 void *pPacket;
1971 eHalStatus halstatus;
1972 tANI_U16 nAddIELen;
1973 tANI_U8 *pAddIE;
1974 tANI_U8 *wpsIe = NULL;
1975#if defined WLAN_FEATURE_VOWIFI
1976 tANI_U8 PowerCapsPopulated = FALSE;
1977#endif
1978 tANI_U8 txFlag = 0;
1979
1980 if(NULL == psessionEntry)
1981 {
1982 return;
1983 }
1984
1985 if(NULL == psessionEntry->pLimJoinReq)
1986 {
1987 return;
1988 }
1989
1990 /* check this early to avoid unncessary operation */
1991 if(NULL == psessionEntry->pLimJoinReq)
1992 {
1993 return;
1994 }
1995 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
1996 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
1997
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301998 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
1999 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002000 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302001 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendAssocReqMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002002 return;
2003 }
2004
2005
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302006 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002007
2008 caps = pMlmAssocReq->capabilityInfo;
2009 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2010 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2011#if defined(FEATURE_WLAN_WAPI)
2012 /* CR: 262463 :
2013 According to WAPI standard:
2014 7.3.1.4 Capability Information field
2015 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2016 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2017 Reassociation management frames. */
2018 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2019 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2020#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002021 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002022
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002023 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2024 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002026 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002027
2028 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2029 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2030
2031 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2032 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2033
2034 // We prefer .11e asociations:
2035 if ( fQosEnabled ) fWmeEnabled = false;
2036
2037 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2038 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2039
2040 if ( psessionEntry->lim11hEnable &&
2041 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2042 {
2043#if defined WLAN_FEATURE_VOWIFI
2044 PowerCapsPopulated = TRUE;
2045
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002046 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002047#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002048 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002049
2050 }
2051
2052#if defined WLAN_FEATURE_VOWIFI
2053 if( pMac->rrm.rrmPEContext.rrmEnable &&
2054 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2055 {
2056 if (PowerCapsPopulated == FALSE)
2057 {
2058 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002059 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 }
2061 }
2062#endif
2063
2064 if ( fQosEnabled &&
2065 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002066 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002067
2068 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002069 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002070
2071#if defined WLAN_FEATURE_VOWIFI
2072 if( pMac->rrm.rrmPEContext.rrmEnable &&
2073 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2074 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002075 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 }
2077#endif
2078 // The join request *should* contain zero or one of the WPA and RSN
2079 // IEs. The payload send along with the request is a
2080 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2081
2082 // typedef struct sSirRSNie
2083 // {
2084 // tANI_U16 length;
2085 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2086 // } tSirRSNie, *tpSirRSNie;
2087
2088 // So, we should be able to make the following two calls harmlessly,
2089 // since they do nothing if they don't find the given IE in the
2090 // bytestream with which they're provided.
2091
2092 // The net effect of this will be to faithfully transmit whatever
2093 // security IE is in the join request.
2094
2095 // *However*, if we're associating for the purpose of WPS
2096 // enrollment, and we've been configured to indicate that by
2097 // eliding the WPA or RSN IE, we just skip this:
2098 if( nAddIELen && pAddIE )
2099 {
2100 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2101 }
2102 if ( NULL == wpsIe )
2103 {
2104 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002105 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002107 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002108#if defined(FEATURE_WLAN_WAPI)
2109 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002110 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002111#endif // defined(FEATURE_WLAN_WAPI)
2112 }
2113
2114 // include WME EDCA IE as well
2115 if ( fWmeEnabled )
2116 {
2117 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2118 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002119 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 }
2121
2122 if ( fWsmEnabled &&
2123 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2124 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002125 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 }
2127 }
2128
2129 //Populate HT IEs, when operating in 11n or Taurus modes AND
2130 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002131 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 pMac->lim.htCapabilityPresentInBeacon)
2133 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002134 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002135#ifdef DISABLE_GF_FOR_INTEROP
2136
2137 /*
2138 * To resolve the interop problem with Broadcom AP,
2139 * where TQ STA could not pass traffic with GF enabled,
2140 * TQ STA will do Greenfield only with TQ AP, for
2141 * everybody else it will be turned off.
2142 */
2143
2144 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2145 {
2146 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002147 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 }
2149#endif
2150
2151 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002152#ifdef WLAN_FEATURE_11AC
2153 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002154 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002155 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002156 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002157 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2158 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002159 }
2160#endif
2161
Jeff Johnson295189b2012-06-20 16:38:30 -07002162
2163#if defined WLAN_FEATURE_VOWIFI_11R
2164 if (psessionEntry->pLimJoinReq->is11Rconnection)
2165 {
2166#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002167 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2169 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2170 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2171#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302172 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2173 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302175 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 {
2177 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302178 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 }
2180#endif
2181
2182#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302183 /* CCX Version IE will be included in association request
2184 when CCX is enabled on DUT through ini */
2185 if (psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
2186 {
2187 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
2188 }
2189 /* For CCX Associations fill the CCX IEs */
2190 if (psessionEntry->isCCXconnection &&
2191 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002193#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002194 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002195#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 }
2197#endif
2198
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002199 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 if ( DOT11F_FAILED( nStatus ) )
2201 {
2202 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002203 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 nStatus );
2205 // We'll fall back on the worst case scenario:
2206 nPayload = sizeof( tDot11fAssocRequest );
2207 }
2208 else if ( DOT11F_WARNED( nStatus ) )
2209 {
2210 limLog( pMac, LOGW, FL("There were warnings while calculating"
2211 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002212 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 }
2214
2215 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2216
2217 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2218 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2219 ( void** ) &pPacket );
2220 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2221 {
2222 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002223 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002224
2225 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002226 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002227
2228
2229 /* Update PE session id*/
2230 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2231
2232 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2233
2234 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2235 ( void* ) pFrame, ( void* ) pPacket );
2236
2237 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2238 ( tANI_U32* ) &mlmAssocCnf);
2239
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302240 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 return;
2242 }
2243
2244 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302245 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002246
2247 // Next, we fill out the buffer descriptor:
2248 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2249 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2250 if ( eSIR_SUCCESS != nSirStatus )
2251 {
2252 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002253 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 nSirStatus );
2255 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302256 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 return;
2258 }
2259
2260
2261 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002262 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 sizeof(tSirMacMgmtHdr),
2264 nPayload, &nPayload );
2265 if ( DOT11F_FAILED( nStatus ) )
2266 {
2267 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002268 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 nStatus );
2270 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2271 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302272 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 return;
2274 }
2275 else if ( DOT11F_WARNED( nStatus ) )
2276 {
2277 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002278 "robe Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 }
2280
2281 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002282 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 nBytes );)
2284 // limPrintMacAddr( pMac, bssid, LOG1 );
2285
2286 if( psessionEntry->assocReq != NULL )
2287 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302288 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 psessionEntry->assocReq = NULL;
2290 }
2291
2292 if( nAddIELen )
2293 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302294 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2295 pAddIE,
2296 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 nPayload += nAddIELen;
2298 }
2299
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302300 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2301 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 {
2303 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2304 }
2305 else
2306 {
2307 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302308 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 psessionEntry->assocReqLen = nPayload;
2310 }
2311
2312 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2314 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 )
2316 {
2317 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2318 }
2319
Ganesh K08bce952012-12-13 15:04:41 -08002320 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2321 {
2322 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2323 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002324
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2326 HAL_TXRX_FRM_802_11_MGMT,
2327 ANI_TXDIR_TODS,
2328 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2329 limTxComplete, pFrame, txFlag );
2330 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2331 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002332 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002333 halstatus );
2334 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302335 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 return;
2337 }
2338
2339 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302340 vos_mem_free(pMlmAssocReq);
2341 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002342 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002343} // End limSendAssocReqMgmtFrame
2344
2345
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002346#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002347/*------------------------------------------------------------------------------------
2348 *
2349 * Send Reassoc Req with FTIEs.
2350 *
2351 *-----------------------------------------------------------------------------------
2352 */
2353void
2354limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2355 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2356{
2357 static tDot11fReAssocRequest frm;
2358 tANI_U16 caps;
2359 tANI_U8 *pFrame;
2360 tSirRetStatus nSirStatus;
2361 tANI_U32 nBytes, nPayload, nStatus;
2362 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2363 void *pPacket;
2364 eHalStatus halstatus;
2365#if defined WLAN_FEATURE_VOWIFI
2366 tANI_U8 PowerCapsPopulated = FALSE;
2367#endif
2368 tANI_U16 ft_ies_length = 0;
2369 tANI_U8 *pBody;
2370 tANI_U16 nAddIELen;
2371 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002372#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 tANI_U8 *wpsIe = NULL;
2374#endif
2375 tANI_U8 txFlag = 0;
2376
2377 if (NULL == psessionEntry)
2378 {
2379 return;
2380 }
2381
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 /* check this early to avoid unncessary operation */
2383 if(NULL == psessionEntry->pLimReAssocReq)
2384 {
2385 return;
2386 }
2387 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2388 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002389 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2390 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002391
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302392 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002393
2394 caps = pMlmReassocReq->capabilityInfo;
2395 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2396 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2397#if defined(FEATURE_WLAN_WAPI)
2398 /* CR: 262463 :
2399 According to WAPI standard:
2400 7.3.1.4 Capability Information field
2401 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2402 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2403 Reassociation management frames. */
2404 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2405 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2406#endif
2407 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2408
2409 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2410
2411 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302412 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2414
2415 PopulateDot11fSSID2( pMac, &frm.SSID );
2416 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2417 &frm.SuppRates,psessionEntry);
2418
2419 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2420 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2421
2422 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2423 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2424
2425 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2426 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2427
2428 if ( psessionEntry->lim11hEnable &&
2429 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2430 {
2431#if defined WLAN_FEATURE_VOWIFI
2432 PowerCapsPopulated = TRUE;
2433
2434 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2435 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2436#endif
2437 }
2438
2439#if defined WLAN_FEATURE_VOWIFI
2440 if( pMac->rrm.rrmPEContext.rrmEnable &&
2441 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2442 {
2443 if (PowerCapsPopulated == FALSE)
2444 {
2445 PowerCapsPopulated = TRUE;
2446 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2447 }
2448 }
2449#endif
2450
2451 if ( fQosEnabled &&
2452 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2453 {
2454 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2455 }
2456
2457 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2458 &frm.ExtSuppRates, psessionEntry );
2459
2460#if defined WLAN_FEATURE_VOWIFI
2461 if( pMac->rrm.rrmPEContext.rrmEnable &&
2462 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2463 {
2464 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2465 }
2466#endif
2467
2468 // Ideally this should be enabled for 11r also. But 11r does
2469 // not follow the usual norm of using the Opaque object
2470 // for rsnie and fties. Instead we just add
2471 // the rsnie and fties at the end of the pack routine for 11r.
2472 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002473#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 //
2475 // The join request *should* contain zero or one of the WPA and RSN
2476 // IEs. The payload send along with the request is a
2477 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2478
2479 // typedef struct sSirRSNie
2480 // {
2481 // tANI_U16 length;
2482 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2483 // } tSirRSNie, *tpSirRSNie;
2484
2485 // So, we should be able to make the following two calls harmlessly,
2486 // since they do nothing if they don't find the given IE in the
2487 // bytestream with which they're provided.
2488
2489 // The net effect of this will be to faithfully transmit whatever
2490 // security IE is in the join request.
2491
2492 // *However*, if we're associating for the purpose of WPS
2493 // enrollment, and we've been configured to indicate that by
2494 // eliding the WPA or RSN IE, we just skip this:
2495 if (!psessionEntry->is11Rconnection)
2496 {
2497 if( nAddIELen && pAddIE )
2498 {
2499 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2500 }
2501 if ( NULL == wpsIe )
2502 {
2503 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2504 &frm.RSNOpaque );
2505 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2506 &frm.WPAOpaque );
2507 }
2508
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002509#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302510 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 {
2512 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2513 &frm.CCXCckmOpaque );
2514 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002515#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 }
2517
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002518#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302519 /* CCX Version IE will be included in reassociation request
2520 when CCX is enabled on DUT through ini */
2521 if (psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
2522 {
2523 PopulateDot11fCCXVersion(&frm.CCXVersion);
2524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302526 if (psessionEntry->isCCXconnection &&
2527 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002529#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002531#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302533#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002534#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002535
2536 // include WME EDCA IE as well
2537 if ( fWmeEnabled )
2538 {
2539 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2540 {
2541 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2542 }
2543
2544 if ( fWsmEnabled &&
2545 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2546 {
2547 PopulateDot11fWMMCaps( &frm.WMMCaps );
2548 }
2549#ifdef FEATURE_WLAN_CCX
2550 if (psessionEntry->isCCXconnection)
2551 {
2552 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2553
2554 // Populate the TSRS IE if TSPEC is included in the reassoc request
2555 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2556 {
2557 tANI_U32 phyMode;
2558 tSirMacCCXTSRSIE tsrsIE;
2559 limGetPhyMode(pMac, &phyMode, psessionEntry);
2560
2561 tsrsIE.tsid = 0;
2562 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2563 {
2564 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2565 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302566 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 {
2568 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2569 }
2570 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2571 }
2572 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302573#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 }
2575
Jeff Johnsone7245742012-09-05 17:12:55 -07002576 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 pMac->lim.htCapabilityPresentInBeacon)
2578 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002579 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 }
2581
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002582#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302583 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2584#if defined FEATURE_WLAN_CCX
2585 && !psessionEntry->isCCXconnection
2586#endif
2587 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002588 {
2589 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2590 }
2591#endif
2592
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2594 if ( DOT11F_FAILED( nStatus ) )
2595 {
2596 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002597 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 nStatus );
2599 // We'll fall back on the worst case scenario:
2600 nPayload = sizeof( tDot11fReAssocRequest );
2601 }
2602 else if ( DOT11F_WARNED( nStatus ) )
2603 {
2604 limLog( pMac, LOGW, FL("There were warnings while calculating"
2605 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002606 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 }
2608
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002609 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002610
2611#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002612 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2614#endif
2615
2616#if defined WLAN_FEATURE_VOWIFI_11R
2617 if (psessionEntry->is11Rconnection)
2618 {
2619 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2620 }
2621#endif
2622
2623 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2624 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2625 ( void** ) &pPacket );
2626 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2627 {
2628 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002629 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002631 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 goto end;
2633 }
2634
2635 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302636 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002637
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002638#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002639 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002640#endif
2641 // Next, we fill out the buffer descriptor:
2642 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2643 SIR_MAC_MGMT_REASSOC_REQ,
2644 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2645 if ( eSIR_SUCCESS != nSirStatus )
2646 {
2647 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002648 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 nSirStatus );
2650 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2651 goto end;
2652 }
2653
2654
2655 // That done, pack the ReAssoc Request:
2656 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2657 sizeof(tSirMacMgmtHdr),
2658 nPayload, &nPayload );
2659 if ( DOT11F_FAILED( nStatus ) )
2660 {
2661 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002662 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 nStatus );
2664 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2665 goto end;
2666 }
2667 else if ( DOT11F_WARNED( nStatus ) )
2668 {
2669 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002670 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 }
2672
2673 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002674 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 nBytes, nPayload );)
2676 if( psessionEntry->assocReq != NULL )
2677 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302678 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 psessionEntry->assocReq = NULL;
2680 }
2681
2682 if( nAddIELen )
2683 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302684 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2685 pAddIE,
2686 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 nPayload += nAddIELen;
2688 }
2689
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302690 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2691 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 {
2693 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002694 }
2695 else
2696 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302698 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002701
2702 if (psessionEntry->is11Rconnection)
2703 {
2704 {
2705 int i = 0;
2706
2707 pBody = pFrame + nBytes;
2708 for (i=0; i<ft_ies_length; i++)
2709 {
2710 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2711 pBody++;
2712 }
2713 }
2714 }
2715
2716#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002717 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2718 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 (tANI_U8 *)pFrame,
2720 (nBytes + ft_ies_length));)
2721#endif
2722
2723
2724 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2726 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 )
2728 {
2729 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2730 }
2731
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002732 if( NULL != psessionEntry->assocReq )
2733 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302734 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002735 psessionEntry->assocReq = NULL;
2736 }
2737
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302738 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2739 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002740 {
2741 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002742 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002743 }
2744 else
2745 {
2746 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302747 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2748 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002749 psessionEntry->assocReqLen = (ft_ies_length);
2750 }
2751
2752
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2754 HAL_TXRX_FRM_802_11_MGMT,
2755 ANI_TXDIR_TODS,
2756 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2757 limTxComplete, pFrame, txFlag );
2758 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2759 {
2760 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002761 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 nSirStatus );
2763 //Pkt will be freed up by the callback
2764 goto end;
2765 }
2766
2767end:
2768 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302769 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 psessionEntry->pLimMlmReassocReq = NULL;
2771
2772}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002773
2774void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2775 tLimMlmReassocReq *pMlmReassocReq,
2776 tpPESession psessionEntry)
2777{
2778 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2779 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2780 if(NULL == pTmpMlmReassocReq)
2781 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302782 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2783 if ( NULL == pTmpMlmReassocReq ) goto end;
2784 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2785 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002786 }
2787
2788 // Prepare and send Reassociation request frame
2789 // start reassoc timer.
2790 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2791 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002792 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002793 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2794 != TX_SUCCESS)
2795 {
2796 // Could not start reassoc failure timer.
2797 // Log error
2798 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002799 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002800 // Return Reassoc confirm with
2801 // Resources Unavailable
2802 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2803 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2804 goto end;
2805 }
2806
2807 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2808 return;
2809
2810end:
2811 // Free up buffer allocated for reassocReq
2812 if (pMlmReassocReq != NULL)
2813 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302814 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002815 pMlmReassocReq = NULL;
2816 }
2817 if (pTmpMlmReassocReq != NULL)
2818 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302819 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002820 pTmpMlmReassocReq = NULL;
2821 }
2822 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2823 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2824 /* Update PE sessio Id*/
2825 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2826
2827 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2828}
2829
Jeff Johnson295189b2012-06-20 16:38:30 -07002830#endif /* WLAN_FEATURE_VOWIFI_11R */
2831
2832
2833void
2834limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2835 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2836{
2837 static tDot11fReAssocRequest frm;
2838 tANI_U16 caps;
2839 tANI_U8 *pFrame;
2840 tSirRetStatus nSirStatus;
2841 tANI_U32 nBytes, nPayload, nStatus;
2842 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2843 void *pPacket;
2844 eHalStatus halstatus;
2845 tANI_U16 nAddIELen;
2846 tANI_U8 *pAddIE;
2847 tANI_U8 *wpsIe = NULL;
2848 tANI_U8 txFlag = 0;
2849#if defined WLAN_FEATURE_VOWIFI
2850 tANI_U8 PowerCapsPopulated = FALSE;
2851#endif
2852
2853 if(NULL == psessionEntry)
2854 {
2855 return;
2856 }
2857
2858 /* check this early to avoid unncessary operation */
2859 if(NULL == psessionEntry->pLimReAssocReq)
2860 {
2861 return;
2862 }
2863 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2864 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2865
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302866 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002867
2868 caps = pMlmReassocReq->capabilityInfo;
2869 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2870 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2871#if defined(FEATURE_WLAN_WAPI)
2872 /* CR: 262463 :
2873 According to WAPI standard:
2874 7.3.1.4 Capability Information field
2875 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2876 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2877 Reassociation management frames. */
2878 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2879 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2880#endif
2881 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2882
2883 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2884
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302885 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2886 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002887
2888 PopulateDot11fSSID2( pMac, &frm.SSID );
2889 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2890 &frm.SuppRates,psessionEntry);
2891
2892 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2893 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2894
2895 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2896 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2897
2898 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2899 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2900
2901
2902 if ( psessionEntry->lim11hEnable &&
2903 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2904 {
2905#if defined WLAN_FEATURE_VOWIFI
2906 PowerCapsPopulated = TRUE;
2907 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2908 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2909#endif
2910 }
2911
2912#if defined WLAN_FEATURE_VOWIFI
2913 if( pMac->rrm.rrmPEContext.rrmEnable &&
2914 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2915 {
2916 if (PowerCapsPopulated == FALSE)
2917 {
2918 PowerCapsPopulated = TRUE;
2919 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2920 }
2921 }
2922#endif
2923
2924 if ( fQosEnabled &&
2925 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2926 {
2927 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2928 }
2929
2930 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2931 &frm.ExtSuppRates, psessionEntry );
2932
2933#if defined WLAN_FEATURE_VOWIFI
2934 if( pMac->rrm.rrmPEContext.rrmEnable &&
2935 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2936 {
2937 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2938 }
2939#endif
2940 // The join request *should* contain zero or one of the WPA and RSN
2941 // IEs. The payload send along with the request is a
2942 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2943
2944 // typedef struct sSirRSNie
2945 // {
2946 // tANI_U16 length;
2947 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2948 // } tSirRSNie, *tpSirRSNie;
2949
2950 // So, we should be able to make the following two calls harmlessly,
2951 // since they do nothing if they don't find the given IE in the
2952 // bytestream with which they're provided.
2953
2954 // The net effect of this will be to faithfully transmit whatever
2955 // security IE is in the join request.
2956
2957 // *However*, if we're associating for the purpose of WPS
2958 // enrollment, and we've been configured to indicate that by
2959 // eliding the WPA or RSN IE, we just skip this:
2960 if( nAddIELen && pAddIE )
2961 {
2962 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2963 }
2964 if ( NULL == wpsIe )
2965 {
2966 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2967 &frm.RSNOpaque );
2968 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2969 &frm.WPAOpaque );
2970#if defined(FEATURE_WLAN_WAPI)
2971 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2972 &frm.WAPIOpaque );
2973#endif // defined(FEATURE_WLAN_WAPI)
2974 }
2975
2976 // include WME EDCA IE as well
2977 if ( fWmeEnabled )
2978 {
2979 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2980 {
2981 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2982 }
2983
2984 if ( fWsmEnabled &&
2985 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2986 {
2987 PopulateDot11fWMMCaps( &frm.WMMCaps );
2988 }
2989 }
2990
Jeff Johnsone7245742012-09-05 17:12:55 -07002991 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 pMac->lim.htCapabilityPresentInBeacon)
2993 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002994 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002996#ifdef WLAN_FEATURE_11AC
2997 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002998 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002999 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003000 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003001 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07003002 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003003 }
3004#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003005
3006 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3007 if ( DOT11F_FAILED( nStatus ) )
3008 {
3009 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003010 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 nStatus );
3012 // We'll fall back on the worst case scenario:
3013 nPayload = sizeof( tDot11fReAssocRequest );
3014 }
3015 else if ( DOT11F_WARNED( nStatus ) )
3016 {
3017 limLog( pMac, LOGW, FL("There were warnings while calculating"
3018 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003019 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 }
3021
3022 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3023
3024 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3025 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3026 ( void** ) &pPacket );
3027 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3028 {
3029 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003030 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003032 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 goto end;
3034 }
3035
3036 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303037 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003038
3039 // Next, we fill out the buffer descriptor:
3040 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3041 SIR_MAC_MGMT_REASSOC_REQ,
3042 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3043 if ( eSIR_SUCCESS != nSirStatus )
3044 {
3045 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003046 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 nSirStatus );
3048 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3049 goto end;
3050 }
3051
3052
3053 // That done, pack the Probe Request:
3054 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3055 sizeof(tSirMacMgmtHdr),
3056 nPayload, &nPayload );
3057 if ( DOT11F_FAILED( nStatus ) )
3058 {
3059 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003060 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 nStatus );
3062 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3063 goto end;
3064 }
3065 else if ( DOT11F_WARNED( nStatus ) )
3066 {
3067 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003068 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 }
3070
3071 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003072 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 nBytes );)
3074
3075 if( psessionEntry->assocReq != NULL )
3076 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303077 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 psessionEntry->assocReq = NULL;
3079 }
3080
3081 if( nAddIELen )
3082 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303083 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3084 pAddIE,
3085 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 nPayload += nAddIELen;
3087 }
3088
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303089 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3090 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 {
3092 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003093 }
3094 else
3095 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303097 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003100
3101 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3103 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 )
3105 {
3106 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3107 }
3108
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003109 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003110 {
3111 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3112 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003113
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3115 HAL_TXRX_FRM_802_11_MGMT,
3116 ANI_TXDIR_TODS,
3117 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3118 limTxComplete, pFrame, txFlag );
3119 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3120 {
3121 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003122 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 nSirStatus );
3124 //Pkt will be freed up by the callback
3125 goto end;
3126 }
3127
3128end:
3129 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303130 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 psessionEntry->pLimMlmReassocReq = NULL;
3132
3133} // limSendReassocReqMgmtFrame
3134
3135/**
3136 * \brief Send an Authentication frame
3137 *
3138 *
3139 * \param pMac Pointer to Global MAC structure
3140 *
3141 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3142 * to be sent
3143 *
3144 * \param peerMacAddr MAC address of the peer entity to which Authentication
3145 * frame is destined
3146 *
3147 * \param wepBit Indicates whether wep bit to be set in FC while sending
3148 * Authentication frame3
3149 *
3150 *
3151 * This function is called by limProcessMlmMessages(). Authentication frame
3152 * is formatted and sent when this function is called.
3153 *
3154 *
3155 */
3156
3157void
3158limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3159 tpSirMacAuthFrameBody pAuthFrameBody,
3160 tSirMacAddr peerMacAddr,
3161 tANI_U8 wepBit,
3162 tpPESession psessionEntry
3163 )
3164{
3165 tANI_U8 *pFrame, *pBody;
3166 tANI_U32 frameLen = 0, bodyLen = 0;
3167 tpSirMacMgmtHdr pMacHdr;
3168 tANI_U16 i;
3169 void *pPacket;
3170 eHalStatus halstatus;
3171 tANI_U8 txFlag = 0;
3172
3173 if(NULL == psessionEntry)
3174 {
3175 return;
3176 }
3177
3178 if (wepBit == LIM_WEP_IN_FC)
3179 {
3180 /// Auth frame3 to be sent with encrypted framebody
3181 /**
3182 * Allocate buffer for Authenticaton frame of size equal
3183 * to management frame header length plus 2 bytes each for
3184 * auth algorithm number, transaction number, status code,
3185 * 128 bytes for challenge text and 4 bytes each for
3186 * IV & ICV.
3187 */
3188
3189 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3190
3191 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3192 } // if (wepBit == LIM_WEP_IN_FC)
3193 else
3194 {
3195 switch (pAuthFrameBody->authTransactionSeqNumber)
3196 {
3197 case SIR_MAC_AUTH_FRAME_1:
3198 /**
3199 * Allocate buffer for Authenticaton frame of size
3200 * equal to management frame header length plus 2 bytes
3201 * each for auth algorithm number, transaction number
3202 * and status code.
3203 */
3204
3205 frameLen = sizeof(tSirMacMgmtHdr) +
3206 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3207 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3208
3209#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003210 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3211 {
3212 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003214 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003215 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003216 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003218 else
3219 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003220 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003221 frameLen += (2+SIR_MDIE_SIZE);
3222 }
3223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003224#endif
3225 break;
3226
3227 case SIR_MAC_AUTH_FRAME_2:
3228 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3229 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3230 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3231 {
3232 /**
3233 * Allocate buffer for Authenticaton frame of size
3234 * equal to management frame header length plus
3235 * 2 bytes each for auth algorithm number,
3236 * transaction number and status code.
3237 */
3238
3239 frameLen = sizeof(tSirMacMgmtHdr) +
3240 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3241 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3242 }
3243 else
3244 {
3245 // Shared Key algorithm with challenge text
3246 // to be sent
3247 /**
3248 * Allocate buffer for Authenticaton frame of size
3249 * equal to management frame header length plus
3250 * 2 bytes each for auth algorithm number,
3251 * transaction number, status code and 128 bytes
3252 * for challenge text.
3253 */
3254
3255 frameLen = sizeof(tSirMacMgmtHdr) +
3256 sizeof(tSirMacAuthFrame);
3257 bodyLen = sizeof(tSirMacAuthFrameBody);
3258 }
3259
3260 break;
3261
3262 case SIR_MAC_AUTH_FRAME_3:
3263 /// Auth frame3 to be sent without encrypted framebody
3264 /**
3265 * Allocate buffer for Authenticaton frame of size equal
3266 * to management frame header length plus 2 bytes each
3267 * for auth algorithm number, transaction number and
3268 * status code.
3269 */
3270
3271 frameLen = sizeof(tSirMacMgmtHdr) +
3272 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3273 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3274
3275 break;
3276
3277 case SIR_MAC_AUTH_FRAME_4:
3278 /**
3279 * Allocate buffer for Authenticaton frame of size equal
3280 * to management frame header length plus 2 bytes each
3281 * for auth algorithm number, transaction number and
3282 * status code.
3283 */
3284
3285 frameLen = sizeof(tSirMacMgmtHdr) +
3286 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3287 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3288
3289 break;
3290 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3291 } // end if (wepBit == LIM_WEP_IN_FC)
3292
3293
3294 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3295
3296 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3297 {
3298 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003299 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003300
3301 return;
3302 }
3303
3304 for (i = 0; i < frameLen; i++)
3305 pFrame[i] = 0;
3306
3307 // Prepare BD
3308 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3309 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3310 {
3311 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3312 return;
3313 }
3314
3315 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3316 pMacHdr->fc.wep = wepBit;
3317
3318 // Prepare BSSId
3319 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3320 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303321 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3322 (tANI_U8 *) psessionEntry->bssId,
3323 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 }
3325
3326 /// Prepare Authentication frame body
3327 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3328
3329 if (wepBit == LIM_WEP_IN_FC)
3330 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303331 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003332
3333 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003334 FL("*** Sending Auth seq# 3 status %d (%d) to"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 pAuthFrameBody->authStatusCode,
3336 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3337
3338 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3339 }
3340 else
3341 {
3342 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3343 pBody += sizeof(tANI_U16);
3344 bodyLen -= sizeof(tANI_U16);
3345
3346 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3347 pBody += sizeof(tANI_U16);
3348 bodyLen -= sizeof(tANI_U16);
3349
3350 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3351 pBody += sizeof(tANI_U16);
3352 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003353 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3354 sizeof (pAuthFrameBody->length) +
3355 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303356 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003357
3358#if defined WLAN_FEATURE_VOWIFI_11R
3359 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3360 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3361 {
3362
3363 {
3364 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3366 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003367#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3369 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3370 (tANI_U8 *)pBody,
3371 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003372#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003373 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3374 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003375 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3376 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003377 }
3378 }
3379 else
3380 {
3381 /* MDID attr is 54*/
3382 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003384 *pBody = SIR_MDIE_SIZE;
3385 pBody++;
3386 for(i=0;i<SIR_MDIE_SIZE;i++)
3387 {
3388 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3389 pBody++;
3390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 }
3392 }
3393 }
3394#endif
3395
3396 PELOG1(limLog(pMac, LOG1,
3397 FL("*** Sending Auth seq# %d status %d (%d) to "),
3398 pAuthFrameBody->authTransactionSeqNumber,
3399 pAuthFrameBody->authStatusCode,
3400 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3401
3402 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3403 }
3404 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3405
3406 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3408 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003409#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303410 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003411 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3412#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 )
3414 {
3415 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3416 }
3417
Ganesh K08bce952012-12-13 15:04:41 -08003418 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3419 {
3420 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3421 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003422
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 /// Queue Authentication frame in high priority WQ
3424 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3425 HAL_TXRX_FRM_802_11_MGMT,
3426 ANI_TXDIR_TODS,
3427 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3428 limTxComplete, pFrame, txFlag );
3429 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3430 {
3431 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003432 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 halstatus);
3434
3435 //Pkt will be freed up by the callback
3436 }
3437
3438 return;
3439} /*** end limSendAuthMgmtFrame() ***/
3440
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003441eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3442{
3443 tANI_U16 aid;
3444 tpDphHashNode pStaDs;
3445 tLimMlmDeauthReq *pMlmDeauthReq;
3446 tLimMlmDeauthCnf mlmDeauthCnf;
3447 tpPESession psessionEntry;
3448
3449 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3450 if (pMlmDeauthReq)
3451 {
3452 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3453 {
3454 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3455 }
3456
3457 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3458 {
3459
3460 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003461 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003462 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3463 goto end;
3464 }
3465
3466 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3467 if (pStaDs == NULL)
3468 {
3469 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3470 goto end;
3471 }
3472
3473
3474 /// Receive path cleanup with dummy packet
3475 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3476 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303477 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003478 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3479 }
3480 return eHAL_STATUS_SUCCESS;
3481end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303482 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003483 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3484 sizeof(tSirMacAddr));
3485 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3486 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3487 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3488
3489 // Free up buffer allocated
3490 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303491 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003492
3493 limPostSmeMessage(pMac,
3494 LIM_MLM_DEAUTH_CNF,
3495 (tANI_U32 *) &mlmDeauthCnf);
3496 return eHAL_STATUS_SUCCESS;
3497}
3498
3499eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3500{
3501 tANI_U16 aid;
3502 tpDphHashNode pStaDs;
3503 tLimMlmDisassocCnf mlmDisassocCnf;
3504 tpPESession psessionEntry;
3505 tLimMlmDisassocReq *pMlmDisassocReq;
3506
3507 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3508 if (pMlmDisassocReq)
3509 {
3510 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3511 {
3512 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3513 }
3514
3515 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3516 {
3517
3518 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003519 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003520 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3521 goto end;
3522 }
3523
3524 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3525 if (pStaDs == NULL)
3526 {
3527 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3528 goto end;
3529 }
3530
3531 /// Receive path cleanup with dummy packet
3532 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3533 {
3534 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3535 goto end;
3536 }
3537
3538#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003539 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303540 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003541#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303542 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003543#endif
3544#ifdef FEATURE_WLAN_LFR
3545 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003546#endif
3547 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303548 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003549 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003550 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303551 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003552 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003553 psessionEntry, psessionEntry->peSessionId););
3554 limFTCleanup(pMac);
3555 }
3556 else
3557 {
3558 PELOGE(limLog(pMac, LOGE,
3559 FL("No FT Preauth Session Cleanup in role %d"
3560#ifdef FEATURE_WLAN_CCX
3561 " isCCX %d"
3562#endif
3563#ifdef FEATURE_WLAN_LFR
3564 " isLFR %d"
3565#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003566 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003567 psessionEntry->limSystemRole,
3568#ifdef FEATURE_WLAN_CCX
3569 psessionEntry->isCCXconnection,
3570#endif
3571#ifdef FEATURE_WLAN_LFR
3572 psessionEntry->isFastRoamIniFeatureEnabled,
3573#endif
3574 psessionEntry->is11Rconnection,
3575 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003576 }
3577#endif
3578
3579 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303580 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003581 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3582 return eHAL_STATUS_SUCCESS;
3583 }
3584 else
3585 {
3586 return eHAL_STATUS_SUCCESS;
3587 }
3588end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303589 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003590 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3591 sizeof(tSirMacAddr));
3592 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3593 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3594
3595 /* Update PE session ID*/
3596 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3597
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003598 if(pMlmDisassocReq != NULL)
3599 {
3600 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303601 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003602 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3603 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003604
3605 limPostSmeMessage(pMac,
3606 LIM_MLM_DISASSOC_CNF,
3607 (tANI_U32 *) &mlmDisassocCnf);
3608 return eHAL_STATUS_SUCCESS;
3609}
3610
3611eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3612{
3613 return limSendDisassocCnf(pMac);
3614}
3615
3616eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3617{
3618 return limSendDeauthCnf(pMac);
3619}
3620
Jeff Johnson295189b2012-06-20 16:38:30 -07003621/**
3622 * \brief This function is called to send Disassociate frame.
3623 *
3624 *
3625 * \param pMac Pointer to Global MAC structure
3626 *
3627 * \param nReason Indicates the reason that need to be sent in
3628 * Disassociation frame
3629 *
3630 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3631 * sent
3632 *
3633 *
3634 */
3635
3636void
3637limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3638 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003639 tSirMacAddr peer,
3640 tpPESession psessionEntry,
3641 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003642{
3643 tDot11fDisassociation frm;
3644 tANI_U8 *pFrame;
3645 tSirRetStatus nSirStatus;
3646 tpSirMacMgmtHdr pMacHdr;
3647 tANI_U32 nBytes, nPayload, nStatus;
3648 void *pPacket;
3649 eHalStatus halstatus;
3650 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003651 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 if(NULL == psessionEntry)
3653 {
3654 return;
3655 }
3656
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303657 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003658
3659 frm.Reason.code = nReason;
3660
3661 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3662 if ( DOT11F_FAILED( nStatus ) )
3663 {
3664 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003665 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 nStatus );
3667 // We'll fall back on the worst case scenario:
3668 nPayload = sizeof( tDot11fDisassociation );
3669 }
3670 else if ( DOT11F_WARNED( nStatus ) )
3671 {
3672 limLog( pMac, LOGW, FL("There were warnings while calculating"
3673 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003674 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 }
3676
3677 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3678
3679 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3680 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3681 ( void** ) &pPacket );
3682 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3683 {
3684 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003685 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 return;
3687 }
3688
3689 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303690 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003691
3692 // Next, we fill out the buffer descriptor:
3693 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3694 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3695 if ( eSIR_SUCCESS != nSirStatus )
3696 {
3697 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003698 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 nSirStatus );
3700 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3701 ( void* ) pFrame, ( void* ) pPacket );
3702 return; // just allocated...
3703 }
3704
3705 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3706
3707 // Prepare the BSSID
3708 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3709
Chet Lanctot186b5732013-03-18 10:26:30 -07003710#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003711 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003712#endif
3713
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3715 sizeof(tSirMacMgmtHdr),
3716 nPayload, &nPayload );
3717 if ( DOT11F_FAILED( nStatus ) )
3718 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003719 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 nStatus );
3721 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3722 ( void* ) pFrame, ( void* ) pPacket );
3723 return; // allocated!
3724 }
3725 else if ( DOT11F_WARNED( nStatus ) )
3726 {
3727 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003728 "isassociation (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 }
3730
3731 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003732 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3734
3735 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3737 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 )
3739 {
3740 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3741 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003742
Ganesh K08bce952012-12-13 15:04:41 -08003743 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3744 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3745 {
3746 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3747 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003748
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003749 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003751 // Queue Disassociation frame in high priority WQ
3752 /* get the duration from the request */
3753 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3754 HAL_TXRX_FRM_802_11_MGMT,
3755 ANI_TXDIR_TODS,
3756 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3757 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3758 txFlag );
3759 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003760
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003761 if (tx_timer_change(
3762 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3763 != TX_SUCCESS)
3764 {
3765 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003766 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003767 return;
3768 }
3769 else if(TX_SUCCESS != tx_timer_activate(
3770 &pMac->lim.limTimers.gLimDisassocAckTimer))
3771 {
3772 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003773 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003774 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3775 return;
3776 }
3777 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003778 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003779 {
3780 // Queue Disassociation frame in high priority WQ
3781 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3782 HAL_TXRX_FRM_802_11_MGMT,
3783 ANI_TXDIR_TODS,
3784 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3785 limTxComplete, pFrame, txFlag );
3786 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3787 {
3788 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003789 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003790 nSirStatus );
3791 //Pkt will be freed up by the callback
3792 return;
3793 }
3794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003795} // End limSendDisassocMgmtFrame.
3796
3797/**
3798 * \brief This function is called to send a Deauthenticate frame
3799 *
3800 *
3801 * \param pMac Pointer to global MAC structure
3802 *
3803 * \param nReason Indicates the reason that need to be sent in the
3804 * Deauthenticate frame
3805 *
3806 * \param peeer address of the STA to which the frame is to be sent
3807 *
3808 *
3809 */
3810
3811void
3812limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3813 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003814 tSirMacAddr peer,
3815 tpPESession psessionEntry,
3816 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003817{
3818 tDot11fDeAuth frm;
3819 tANI_U8 *pFrame;
3820 tSirRetStatus nSirStatus;
3821 tpSirMacMgmtHdr pMacHdr;
3822 tANI_U32 nBytes, nPayload, nStatus;
3823 void *pPacket;
3824 eHalStatus halstatus;
3825 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003826 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003827#ifdef FEATURE_WLAN_TDLS
3828 tANI_U16 aid;
3829 tpDphHashNode pStaDs;
3830#endif
3831
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 if(NULL == psessionEntry)
3833 {
3834 return;
3835 }
3836
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303837 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003838
3839 frm.Reason.code = nReason;
3840
3841 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3842 if ( DOT11F_FAILED( nStatus ) )
3843 {
3844 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003845 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 nStatus );
3847 // We'll fall back on the worst case scenario:
3848 nPayload = sizeof( tDot11fDeAuth );
3849 }
3850 else if ( DOT11F_WARNED( nStatus ) )
3851 {
3852 limLog( pMac, LOGW, FL("There were warnings while calculating"
3853 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003854 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 }
3856
3857 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3858
3859 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3860 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3861 ( void** ) &pPacket );
3862 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3863 {
3864 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003865 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 return;
3867 }
3868
3869 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303870 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003871
3872 // Next, we fill out the buffer descriptor:
3873 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3874 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3875 if ( eSIR_SUCCESS != nSirStatus )
3876 {
3877 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003878 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 nSirStatus );
3880 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3881 ( void* ) pFrame, ( void* ) pPacket );
3882 return; // just allocated...
3883 }
3884
3885 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3886
3887 // Prepare the BSSID
3888 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3889
Chet Lanctot186b5732013-03-18 10:26:30 -07003890#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003891 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003892#endif
3893
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3895 sizeof(tSirMacMgmtHdr),
3896 nPayload, &nPayload );
3897 if ( DOT11F_FAILED( nStatus ) )
3898 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003899 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 nStatus );
3901 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3902 ( void* ) pFrame, ( void* ) pPacket );
3903 return;
3904 }
3905 else if ( DOT11F_WARNED( nStatus ) )
3906 {
3907 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003908 "e-Authentication (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 }
3910
3911 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003912 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3914
3915 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3917 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 )
3919 {
3920 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3921 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003922
Ganesh K08bce952012-12-13 15:04:41 -08003923 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3924 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3925 {
3926 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3927 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003928
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003929#ifdef FEATURE_WLAN_TDLS
3930 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3931#endif
3932
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003933 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003935 // Queue Disassociation frame in high priority WQ
3936 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3937 HAL_TXRX_FRM_802_11_MGMT,
3938 ANI_TXDIR_TODS,
3939 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3940 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
3941 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3942 {
3943 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003944 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003945 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003946 //Pkt will be freed up by the callback limTxComplete
3947
3948 /*Call limProcessDeauthAckTimeout which will send
3949 * DeauthCnf for this frame
3950 */
3951 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003952 return;
3953 }
3954
3955 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3956
3957 if (tx_timer_change(
3958 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3959 != TX_SUCCESS)
3960 {
3961 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003962 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003963 return;
3964 }
3965 else if(TX_SUCCESS != tx_timer_activate(
3966 &pMac->lim.limTimers.gLimDeauthAckTimer))
3967 {
3968 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003969 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003970 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3971 return;
3972 }
3973 }
3974 else
3975 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003976#ifdef FEATURE_WLAN_TDLS
3977 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
3978 {
3979 // Queue Disassociation frame in high priority WQ
3980 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003981 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003982 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003983 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3984 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003985 }
3986 else
3987 {
3988#endif
3989 // Queue Disassociation frame in high priority WQ
3990 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3991 HAL_TXRX_FRM_802_11_MGMT,
3992 ANI_TXDIR_TODS,
3993 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3994 limTxComplete, pFrame, txFlag );
3995#ifdef FEATURE_WLAN_TDLS
3996 }
3997#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003998 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3999 {
4000 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004001 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004002 nSirStatus );
4003 //Pkt will be freed up by the callback
4004 return;
4005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 }
4007
4008} // End limSendDeauthMgmtFrame.
4009
4010
4011#ifdef ANI_SUPPORT_11H
4012/**
4013 * \brief Send a Measurement Report Action frame
4014 *
4015 *
4016 * \param pMac Pointer to the global MAC structure
4017 *
4018 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4019 *
4020 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4021 *
4022 *
4023 */
4024
4025tSirRetStatus
4026limSendMeasReportFrame(tpAniSirGlobal pMac,
4027 tpSirMacMeasReqActionFrame pMeasReqFrame,
4028 tSirMacAddr peer)
4029{
4030 tDot11fMeasurementReport frm;
4031 tANI_U8 *pFrame;
4032 tSirRetStatus nSirStatus;
4033 tpSirMacMgmtHdr pMacHdr;
4034 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4035 void *pPacket;
4036 eHalStatus halstatus;
4037
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304038 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004039
4040 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4041 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4042 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4043
4044 switch ( pMeasReqFrame->measReqIE.measType )
4045 {
4046 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4047 nSirStatus =
4048 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4049 &frm.MeasurementReport );
4050 break;
4051 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4052 nSirStatus =
4053 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4054 &frm.MeasurementReport );
4055 break;
4056 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4057 nSirStatus =
4058 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4059 &frm.MeasurementReport );
4060 break;
4061 default:
4062 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004063 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 pMeasReqFrame->measReqIE.measType );
4065 return eSIR_FAILURE;
4066 }
4067
4068 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4069
4070 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4071 if ( DOT11F_FAILED( nStatus ) )
4072 {
4073 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004074 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 nStatus );
4076 // We'll fall back on the worst case scenario:
4077 nPayload = sizeof( tDot11fMeasurementReport );
4078 }
4079 else if ( DOT11F_WARNED( nStatus ) )
4080 {
4081 limLog( pMac, LOGW, FL("There were warnings while calculating"
4082 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004083 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 }
4085
4086 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4087
4088 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4089 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4090 {
4091 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004092 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 return eSIR_FAILURE;
4094 }
4095
4096 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304097 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004098
4099 // Next, we fill out the buffer descriptor:
4100 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4101 SIR_MAC_MGMT_ACTION, peer);
4102 if ( eSIR_SUCCESS != nSirStatus )
4103 {
4104 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004105 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 nSirStatus );
4107 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4108 return eSIR_FAILURE; // just allocated...
4109 }
4110
4111 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4112
4113 nCfg = 6;
4114 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4115 if ( eSIR_SUCCESS != nSirStatus )
4116 {
4117 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004118 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 nSirStatus );
4120 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4121 return eSIR_FAILURE; // just allocated...
4122 }
4123
Chet Lanctot186b5732013-03-18 10:26:30 -07004124#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004125 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004126#endif
4127
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4129 sizeof(tSirMacMgmtHdr),
4130 nPayload, &nPayload );
4131 if ( DOT11F_FAILED( nStatus ) )
4132 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004133 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 nStatus );
4135 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4136 return eSIR_FAILURE; // allocated!
4137 }
4138 else if ( DOT11F_WARNED( nStatus ) )
4139 {
4140 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004141 "easurement Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 }
4143
4144 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4145 HAL_TXRX_FRM_802_11_MGMT,
4146 ANI_TXDIR_TODS,
4147 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4148 limTxComplete, pFrame, 0 );
4149 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4150 {
4151 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004152 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 nSirStatus );
4154 //Pkt will be freed up by the callback
4155 return eSIR_FAILURE; // just allocated...
4156 }
4157
4158 return eSIR_SUCCESS;
4159
4160} // End limSendMeasReportFrame.
4161
4162
4163/**
4164 * \brief Send a TPC Request Action frame
4165 *
4166 *
4167 * \param pMac Pointer to the global MAC datastructure
4168 *
4169 * \param peer MAC address to which the frame should be sent
4170 *
4171 *
4172 */
4173
4174void
4175limSendTpcRequestFrame(tpAniSirGlobal pMac,
4176 tSirMacAddr peer)
4177{
4178 tDot11fTPCRequest frm;
4179 tANI_U8 *pFrame;
4180 tSirRetStatus nSirStatus;
4181 tpSirMacMgmtHdr pMacHdr;
4182 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4183 void *pPacket;
4184 eHalStatus halstatus;
4185
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304186 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004187
4188 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4189 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4190 frm.DialogToken.token = 1;
4191 frm.TPCRequest.present = 1;
4192
4193 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4194 if ( DOT11F_FAILED( nStatus ) )
4195 {
4196 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004197 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 nStatus );
4199 // We'll fall back on the worst case scenario:
4200 nPayload = sizeof( tDot11fTPCRequest );
4201 }
4202 else if ( DOT11F_WARNED( nStatus ) )
4203 {
4204 limLog( pMac, LOGW, FL("There were warnings while calculating"
4205 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004206 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 }
4208
4209 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4210
4211 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4212 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4213 {
4214 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004215 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 return;
4217 }
4218
4219 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304220 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004221
4222 // Next, we fill out the buffer descriptor:
4223 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4224 SIR_MAC_MGMT_ACTION, peer);
4225 if ( eSIR_SUCCESS != nSirStatus )
4226 {
4227 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004228 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 nSirStatus );
4230 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4231 return; // just allocated...
4232 }
4233
4234 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4235
4236 nCfg = 6;
4237 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4238 if ( eSIR_SUCCESS != nSirStatus )
4239 {
4240 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004241 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 nSirStatus );
4243 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4244 return; // just allocated...
4245 }
4246
Chet Lanctot186b5732013-03-18 10:26:30 -07004247#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004248 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004249#endif
4250
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4252 sizeof(tSirMacMgmtHdr),
4253 nPayload, &nPayload );
4254 if ( DOT11F_FAILED( nStatus ) )
4255 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004256 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 nStatus );
4258 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4259 return; // allocated!
4260 }
4261 else if ( DOT11F_WARNED( nStatus ) )
4262 {
4263 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004264 "PC Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 }
4266
4267 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4268 HAL_TXRX_FRM_802_11_MGMT,
4269 ANI_TXDIR_TODS,
4270 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4271 limTxComplete, pFrame, 0 );
4272 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4273 {
4274 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004275 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 nSirStatus );
4277 //Pkt will be freed up by the callback
4278 return;
4279 }
4280
4281} // End limSendTpcRequestFrame.
4282
4283
4284/**
4285 * \brief Send a TPC Report Action frame
4286 *
4287 *
4288 * \param pMac Pointer to the global MAC datastructure
4289 *
4290 * \param pTpcReqFrame Pointer to the received TPC Request
4291 *
4292 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4293 *
4294 *
4295 */
4296
4297tSirRetStatus
4298limSendTpcReportFrame(tpAniSirGlobal pMac,
4299 tpSirMacTpcReqActionFrame pTpcReqFrame,
4300 tSirMacAddr peer)
4301{
4302 tDot11fTPCReport frm;
4303 tANI_U8 *pFrame;
4304 tSirRetStatus nSirStatus;
4305 tpSirMacMgmtHdr pMacHdr;
4306 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4307 void *pPacket;
4308 eHalStatus halstatus;
4309
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304310 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004311
4312 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4313 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4314 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4315
4316 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4317 // "misplaced this function, need to replace:
4318 // txPower = halGetRateToPwrValue(pMac, staid,
4319 // pMac->lim.gLimCurrentChannelId, 0);
4320 frm.TPCReport.tx_power = 0;
4321 frm.TPCReport.link_margin = 0;
4322 frm.TPCReport.present = 1;
4323
4324 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4325 if ( DOT11F_FAILED( nStatus ) )
4326 {
4327 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004328 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 nStatus );
4330 // We'll fall back on the worst case scenario:
4331 nPayload = sizeof( tDot11fTPCReport );
4332 }
4333 else if ( DOT11F_WARNED( nStatus ) )
4334 {
4335 limLog( pMac, LOGW, FL("There were warnings while calculating"
4336 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004337 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 }
4339
4340 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4341
4342 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4343 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4344 {
4345 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004346 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 return eSIR_FAILURE;
4348 }
4349
4350 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304351 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004352
4353 // Next, we fill out the buffer descriptor:
4354 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4355 SIR_MAC_MGMT_ACTION, peer);
4356 if ( eSIR_SUCCESS != nSirStatus )
4357 {
4358 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004359 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 nSirStatus );
4361 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4362 return eSIR_FAILURE; // just allocated...
4363 }
4364
4365 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4366
4367 nCfg = 6;
4368 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4369 if ( eSIR_SUCCESS != nSirStatus )
4370 {
4371 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004372 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 nSirStatus );
4374 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4375 return eSIR_FAILURE; // just allocated...
4376 }
4377
Chet Lanctot186b5732013-03-18 10:26:30 -07004378#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004379 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004380#endif
4381
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4383 sizeof(tSirMacMgmtHdr),
4384 nPayload, &nPayload );
4385 if ( DOT11F_FAILED( nStatus ) )
4386 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004387 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 nStatus );
4389 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4390 return eSIR_FAILURE; // allocated!
4391 }
4392 else if ( DOT11F_WARNED( nStatus ) )
4393 {
4394 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004395 "PC Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 }
4397
4398
4399 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4400 HAL_TXRX_FRM_802_11_MGMT,
4401 ANI_TXDIR_TODS,
4402 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4403 limTxComplete, pFrame, 0 );
4404 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4405 {
4406 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004407 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 nSirStatus );
4409 //Pkt will be freed up by the callback
4410 return eSIR_FAILURE; // just allocated...
4411 }
4412
4413 return eSIR_SUCCESS;
4414
4415} // End limSendTpcReportFrame.
4416#endif //ANI_SUPPORT_11H
4417
4418
Jeff Johnson295189b2012-06-20 16:38:30 -07004419/**
4420 * \brief Send a Channel Switch Announcement
4421 *
4422 *
4423 * \param pMac Pointer to the global MAC datastructure
4424 *
4425 * \param peer MAC address to which this frame will be sent
4426 *
4427 * \param nMode
4428 *
4429 * \param nNewChannel
4430 *
4431 * \param nCount
4432 *
4433 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4434 *
4435 *
4436 */
4437
4438tSirRetStatus
4439limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4440 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004441 tANI_U8 nMode,
4442 tANI_U8 nNewChannel,
4443 tANI_U8 nCount,
4444 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004445{
4446 tDot11fChannelSwitch frm;
4447 tANI_U8 *pFrame;
4448 tSirRetStatus nSirStatus;
4449 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004450 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 void *pPacket;
4452 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004453 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004454
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304455 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004456
4457 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4458 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4459 frm.ChanSwitchAnn.switchMode = nMode;
4460 frm.ChanSwitchAnn.newChannel = nNewChannel;
4461 frm.ChanSwitchAnn.switchCount = nCount;
4462 frm.ChanSwitchAnn.present = 1;
4463
4464 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4465 if ( DOT11F_FAILED( nStatus ) )
4466 {
4467 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004468 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 nStatus );
4470 // We'll fall back on the worst case scenario:
4471 nPayload = sizeof( tDot11fChannelSwitch );
4472 }
4473 else if ( DOT11F_WARNED( nStatus ) )
4474 {
4475 limLog( pMac, LOGW, FL("There were warnings while calculating"
4476 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004477 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 }
4479
4480 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4481
4482 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4483 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4484 {
4485 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004486 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 return eSIR_FAILURE;
4488 }
4489
4490 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304491 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004492
4493 // Next, we fill out the buffer descriptor:
4494 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004495 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4496 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304497 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4498 (tANI_U8 *) psessionEntry->bssId,
4499 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 if ( eSIR_SUCCESS != nSirStatus )
4501 {
4502 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004503 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 nSirStatus );
4505 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4506 return eSIR_FAILURE; // just allocated...
4507 }
4508
Jeff Johnsone7245742012-09-05 17:12:55 -07004509#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4511
4512 nCfg = 6;
4513 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4514 if ( eSIR_SUCCESS != nSirStatus )
4515 {
4516 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004517 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 nSirStatus );
4519 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4520 return eSIR_FAILURE; // just allocated...
4521 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004522#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004523
4524#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004525 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004526#endif
4527
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4529 sizeof(tSirMacMgmtHdr),
4530 nPayload, &nPayload );
4531 if ( DOT11F_FAILED( nStatus ) )
4532 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004533 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 nStatus );
4535 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4536 return eSIR_FAILURE; // allocated!
4537 }
4538 else if ( DOT11F_WARNED( nStatus ) )
4539 {
4540 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004541 "hannel Switch (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 }
4543
Jeff Johnsone7245742012-09-05 17:12:55 -07004544 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004545 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4546 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004547 )
4548 {
4549 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4552 HAL_TXRX_FRM_802_11_MGMT,
4553 ANI_TXDIR_TODS,
4554 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004555 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4557 {
4558 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004559 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 nSirStatus );
4561 //Pkt will be freed up by the callback
4562 return eSIR_FAILURE;
4563 }
4564
4565 return eSIR_SUCCESS;
4566
4567} // End limSendChannelSwitchMgmtFrame.
4568
Jeff Johnson295189b2012-06-20 16:38:30 -07004569
4570
Mohit Khanna4a70d262012-09-11 16:30:12 -07004571#ifdef WLAN_FEATURE_11AC
4572tSirRetStatus
4573limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4574 tSirMacAddr peer,
4575 tANI_U8 nMode,
4576 tpPESession psessionEntry )
4577{
4578 tDot11fOperatingMode frm;
4579 tANI_U8 *pFrame;
4580 tSirRetStatus nSirStatus;
4581 tpSirMacMgmtHdr pMacHdr;
4582 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4583 void *pPacket;
4584 eHalStatus halstatus;
4585 tANI_U8 txFlag = 0;
4586
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304587 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004588
4589 frm.Category.category = SIR_MAC_ACTION_VHT;
4590 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4591 frm.OperatingMode.chanWidth = nMode;
4592 frm.OperatingMode.rxNSS = 0;
4593 frm.OperatingMode.rxNSSType = 0;
4594
4595 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4596 if ( DOT11F_FAILED( nStatus ) )
4597 {
4598 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004599 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004600 nStatus );
4601 // We'll fall back on the worst case scenario:
4602 nPayload = sizeof( tDot11fOperatingMode);
4603 }
4604 else if ( DOT11F_WARNED( nStatus ) )
4605 {
4606 limLog( pMac, LOGW, FL("There were warnings while calculating"
4607 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004608 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004609 }
4610
4611 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4612
4613 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4614 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4615 {
4616 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004617 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004618 return eSIR_FAILURE;
4619 }
4620
4621 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304622 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004623
4624
4625 // Next, we fill out the buffer descriptor:
4626 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4627 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4628 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4629 } else
4630 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4631 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4632 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304633 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4634 (tANI_U8 *) psessionEntry->bssId,
4635 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004636 if ( eSIR_SUCCESS != nSirStatus )
4637 {
4638 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004639 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004640 nSirStatus );
4641 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4642 return eSIR_FAILURE; // just allocated...
4643 }
4644 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4645 sizeof(tSirMacMgmtHdr),
4646 nPayload, &nPayload );
4647 if ( DOT11F_FAILED( nStatus ) )
4648 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004649 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004650 nStatus );
4651 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4652 return eSIR_FAILURE; // allocated!
4653 }
4654 else if ( DOT11F_WARNED( nStatus ) )
4655 {
4656 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004657 " (0x%08x).") );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004658 }
4659 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004660 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4661 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004662 )
4663 {
4664 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4665 }
4666 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4667 HAL_TXRX_FRM_802_11_MGMT,
4668 ANI_TXDIR_TODS,
4669 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4670 limTxComplete, pFrame, txFlag );
4671 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4672 {
4673 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004674 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004675 nSirStatus );
4676 //Pkt will be freed up by the callback
4677 return eSIR_FAILURE;
4678 }
4679
4680 return eSIR_SUCCESS;
4681}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004682
4683/**
4684 * \brief Send a VHT Channel Switch Announcement
4685 *
4686 *
4687 * \param pMac Pointer to the global MAC datastructure
4688 *
4689 * \param peer MAC address to which this frame will be sent
4690 *
4691 * \param nChanWidth
4692 *
4693 * \param nNewChannel
4694 *
4695 *
4696 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4697 *
4698 *
4699 */
4700
4701tSirRetStatus
4702limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4703 tSirMacAddr peer,
4704 tANI_U8 nChanWidth,
4705 tANI_U8 nNewChannel,
4706 tANI_U8 ncbMode,
4707 tpPESession psessionEntry )
4708{
4709 tDot11fChannelSwitch frm;
4710 tANI_U8 *pFrame;
4711 tSirRetStatus nSirStatus;
4712 tpSirMacMgmtHdr pMacHdr;
4713 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4714 void *pPacket;
4715 eHalStatus halstatus;
4716 tANI_U8 txFlag = 0;
4717
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304718 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004719
4720
4721 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4722 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4723 frm.ChanSwitchAnn.switchMode = 1;
4724 frm.ChanSwitchAnn.newChannel = nNewChannel;
4725 frm.ChanSwitchAnn.switchCount = 1;
4726 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4727 frm.ExtChanSwitchAnn.present = 1;
4728 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4729 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4730 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4731 frm.ChanSwitchAnn.present = 1;
4732 frm.WiderBWChanSwitchAnn.present = 1;
4733
4734 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4735 if ( DOT11F_FAILED( nStatus ) )
4736 {
4737 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004738 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004739 nStatus );
4740 // We'll fall back on the worst case scenario:
4741 nPayload = sizeof( tDot11fChannelSwitch );
4742 }
4743 else if ( DOT11F_WARNED( nStatus ) )
4744 {
4745 limLog( pMac, LOGW, FL("There were warnings while calculating"
4746 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004747 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004748 }
4749
4750 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4751
4752 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4753 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4754 {
4755 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004756 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004757 return eSIR_FAILURE;
4758 }
4759 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304760 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004761
4762 // Next, we fill out the buffer descriptor:
4763 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4764 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4765 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304766 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4767 (tANI_U8 *) psessionEntry->bssId,
4768 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004769 if ( eSIR_SUCCESS != nSirStatus )
4770 {
4771 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004772 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004773 nSirStatus );
4774 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4775 return eSIR_FAILURE; // just allocated...
4776 }
4777 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4778 sizeof(tSirMacMgmtHdr),
4779 nPayload, &nPayload );
4780 if ( DOT11F_FAILED( nStatus ) )
4781 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004782 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004783 nStatus );
4784 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4785 return eSIR_FAILURE; // allocated!
4786 }
4787 else if ( DOT11F_WARNED( nStatus ) )
4788 {
4789 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004790 "hannel Switch (0x%08x).") );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004791 }
4792
4793 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004794 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4795 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004796 )
4797 {
4798 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4799 }
4800 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4801 HAL_TXRX_FRM_802_11_MGMT,
4802 ANI_TXDIR_TODS,
4803 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4804 limTxComplete, pFrame, txFlag );
4805 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4806 {
4807 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004808 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004809 nSirStatus );
4810 //Pkt will be freed up by the callback
4811 return eSIR_FAILURE;
4812 }
4813
4814 return eSIR_SUCCESS;
4815
4816} // End limSendVHTChannelSwitchMgmtFrame.
4817
4818
4819
Mohit Khanna4a70d262012-09-11 16:30:12 -07004820#endif
4821
Jeff Johnson295189b2012-06-20 16:38:30 -07004822/**
4823 * \brief Send an ADDBA Req Action Frame to peer
4824 *
4825 * \sa limSendAddBAReq
4826 *
4827 * \param pMac The global tpAniSirGlobal object
4828 *
4829 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4830 * the necessary parameters reqd by PE send the ADDBA Req Action
4831 * Frame to the peer
4832 *
4833 * \return eSIR_SUCCESS if setup completes successfully
4834 * eSIR_FAILURE is some problem is encountered
4835 */
4836tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304837 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004838{
4839 tDot11fAddBAReq frmAddBAReq;
4840 tANI_U8 *pAddBAReqBuffer = NULL;
4841 tpSirMacMgmtHdr pMacHdr;
4842 tANI_U32 frameLen = 0, nStatus, nPayload;
4843 tSirRetStatus statusCode;
4844 eHalStatus halStatus;
4845 void *pPacket;
4846 tANI_U8 txFlag = 0;
4847
4848 if(NULL == psessionEntry)
4849 {
4850 return eSIR_FAILURE;
4851 }
4852
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304853 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004854
4855 // Category - 3 (BA)
4856 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4857
4858 // Action - 0 (ADDBA Req)
4859 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4860
4861 // FIXME - Dialog Token, generalize this...
4862 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4863
4864 // Fill the ADDBA Parameter Set
4865 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4866 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4867 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4868
4869 // BA timeout
4870 // 0 - indicates no BA timeout
4871 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4872
4873 // BA Starting Sequence Number
4874 // Fragment number will always be zero
4875 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4876 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4877 }
4878
4879 frmAddBAReq.BAStartingSequenceControl.ssn =
4880 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4881
4882 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4883
4884 if( DOT11F_FAILED( nStatus ))
4885 {
4886 limLog( pMac, LOGW,
4887 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004888 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 nStatus );
4890
4891 // We'll fall back on the worst case scenario:
4892 nPayload = sizeof( tDot11fAddBAReq );
4893 }
4894 else if( DOT11F_WARNED( nStatus ))
4895 {
4896 limLog( pMac, LOGW,
4897 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004898 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 nStatus );
4900 }
4901
4902 // Add the MGMT header to frame length
4903 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4904
4905 // Need to allocate a buffer for ADDBA AF
4906 if( eHAL_STATUS_SUCCESS !=
4907 (halStatus = palPktAlloc( pMac->hHdd,
4908 HAL_TXRX_FRM_802_11_MGMT,
4909 (tANI_U16) frameLen,
4910 (void **) &pAddBAReqBuffer,
4911 (void **) &pPacket )))
4912 {
4913 // Log error
4914 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004915 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 frameLen,
4917 halStatus );
4918
4919 statusCode = eSIR_MEM_ALLOC_FAILED;
4920 goto returnAfterError;
4921 }
4922
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304923 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004924
4925 // Copy necessary info to BD
4926 if( eSIR_SUCCESS !=
4927 (statusCode = limPopulateMacHeader( pMac,
4928 pAddBAReqBuffer,
4929 SIR_MAC_MGMT_FRAME,
4930 SIR_MAC_MGMT_ACTION,
4931 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4932 goto returnAfterError;
4933
4934 // Update A3 with the BSSID
4935 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4936
4937 #if 0
4938 cfgLen = SIR_MAC_ADDR_LENGTH;
4939 if( eSIR_SUCCESS != cfgGetStr( pMac,
4940 WNI_CFG_BSSID,
4941 (tANI_U8 *) pMacHdr->bssId,
4942 &cfgLen ))
4943 {
4944 limLog( pMac, LOGP,
4945 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004946 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004947
4948 // FIXME - Need to convert to tSirRetStatus
4949 statusCode = eSIR_FAILURE;
4950 goto returnAfterError;
4951 }
4952 #endif//TO SUPPORT BT-AMP
4953 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4954
Chet Lanctot186b5732013-03-18 10:26:30 -07004955#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004956 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004957#endif
4958
Jeff Johnson295189b2012-06-20 16:38:30 -07004959 // Now, we're ready to "pack" the frames
4960 nStatus = dot11fPackAddBAReq( pMac,
4961 &frmAddBAReq,
4962 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4963 nPayload,
4964 &nPayload );
4965
4966 if( DOT11F_FAILED( nStatus ))
4967 {
4968 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004969 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 nStatus );
4971
4972 // FIXME - Need to convert to tSirRetStatus
4973 statusCode = eSIR_FAILURE;
4974 goto returnAfterError;
4975 }
4976 else if( DOT11F_WARNED( nStatus ))
4977 {
4978 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004979 FL( "There were warnings while packing an ADDBA Req (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 }
4981
4982 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004983 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4985
4986 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4988 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 )
4990 {
4991 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4992 }
4993
4994 if( eHAL_STATUS_SUCCESS !=
4995 (halStatus = halTxFrame( pMac,
4996 pPacket,
4997 (tANI_U16) frameLen,
4998 HAL_TXRX_FRM_802_11_MGMT,
4999 ANI_TXDIR_TODS,
5000 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5001 limTxComplete,
5002 pAddBAReqBuffer, txFlag )))
5003 {
5004 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005005 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 halStatus );
5007
5008 // FIXME - Need to convert eHalStatus to tSirRetStatus
5009 statusCode = eSIR_FAILURE;
5010 //Pkt will be freed up by the callback
5011 return statusCode;
5012 }
5013 else
5014 return eSIR_SUCCESS;
5015
5016returnAfterError:
5017
5018 // Release buffer, if allocated
5019 if( NULL != pAddBAReqBuffer )
5020 palPktFree( pMac->hHdd,
5021 HAL_TXRX_FRM_802_11_MGMT,
5022 (void *) pAddBAReqBuffer,
5023 (void *) pPacket );
5024
5025 return statusCode;
5026}
5027
5028/**
5029 * \brief Send an ADDBA Rsp Action Frame to peer
5030 *
5031 * \sa limSendAddBARsp
5032 *
5033 * \param pMac The global tpAniSirGlobal object
5034 *
5035 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5036 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5037 * Frame to the peer
5038 *
5039 * \return eSIR_SUCCESS if setup completes successfully
5040 * eSIR_FAILURE is some problem is encountered
5041 */
5042tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5043 tpLimMlmAddBARsp pMlmAddBARsp,
5044 tpPESession psessionEntry)
5045{
5046 tDot11fAddBARsp frmAddBARsp;
5047 tANI_U8 *pAddBARspBuffer = NULL;
5048 tpSirMacMgmtHdr pMacHdr;
5049 tANI_U32 frameLen = 0, nStatus, nPayload;
5050 tSirRetStatus statusCode;
5051 eHalStatus halStatus;
5052 void *pPacket;
5053 tANI_U8 txFlag = 0;
5054
5055 if(NULL == psessionEntry)
5056 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005057 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 return eSIR_FAILURE;
5059 }
5060
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305061 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005062
5063 // Category - 3 (BA)
5064 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5065 // Action - 1 (ADDBA Rsp)
5066 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5067
5068 // Should be same as the one we received in the ADDBA Req
5069 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5070
5071 // ADDBA Req status
5072 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5073
5074 // Fill the ADDBA Parameter Set as provided by caller
5075 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5076 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5077 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005078
5079 if(psessionEntry->isAmsduSupportInAMPDU)
5080 {
5081 frmAddBARsp.AddBAParameterSet.amsduSupported =
5082 psessionEntry->amsduSupportedInBA;
5083 }
5084 else
5085 {
5086 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005088
5089 // BA timeout
5090 // 0 - indicates no BA timeout
5091 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5092
5093 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5094
5095 if( DOT11F_FAILED( nStatus ))
5096 {
5097 limLog( pMac, LOGW,
5098 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005099 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 nStatus );
5101
5102 // We'll fall back on the worst case scenario:
5103 nPayload = sizeof( tDot11fAddBARsp );
5104 }
5105 else if( DOT11F_WARNED( nStatus ))
5106 {
5107 limLog( pMac, LOGW,
5108 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005109 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 nStatus );
5111 }
5112
5113 // Need to allocate a buffer for ADDBA AF
5114 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5115
5116 // Allocate shared memory
5117 if( eHAL_STATUS_SUCCESS !=
5118 (halStatus = palPktAlloc( pMac->hHdd,
5119 HAL_TXRX_FRM_802_11_MGMT,
5120 (tANI_U16) frameLen,
5121 (void **) &pAddBARspBuffer,
5122 (void **) &pPacket )))
5123 {
5124 // Log error
5125 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005126 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005127 frameLen,
5128 halStatus );
5129
5130 statusCode = eSIR_MEM_ALLOC_FAILED;
5131 goto returnAfterError;
5132 }
5133
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305134 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005135
5136 // Copy necessary info to BD
5137 if( eSIR_SUCCESS !=
5138 (statusCode = limPopulateMacHeader( pMac,
5139 pAddBARspBuffer,
5140 SIR_MAC_MGMT_FRAME,
5141 SIR_MAC_MGMT_ACTION,
5142 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5143 goto returnAfterError;
5144
5145 // Update A3 with the BSSID
5146
5147 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5148
5149 #if 0
5150 cfgLen = SIR_MAC_ADDR_LENGTH;
5151 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5152 WNI_CFG_BSSID,
5153 (tANI_U8 *) pMacHdr->bssId,
5154 &cfgLen ))
5155 {
5156 limLog( pMac, LOGP,
5157 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005158 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005159
5160 // FIXME - Need to convert to tSirRetStatus
5161 statusCode = eSIR_FAILURE;
5162 goto returnAfterError;
5163 }
5164 #endif // TO SUPPORT BT-AMP
5165 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5166
Chet Lanctot186b5732013-03-18 10:26:30 -07005167#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005168 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005169#endif
5170
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 // Now, we're ready to "pack" the frames
5172 nStatus = dot11fPackAddBARsp( pMac,
5173 &frmAddBARsp,
5174 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5175 nPayload,
5176 &nPayload );
5177
5178 if( DOT11F_FAILED( nStatus ))
5179 {
5180 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005181 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 nStatus );
5183
5184 // FIXME - Need to convert to tSirRetStatus
5185 statusCode = eSIR_FAILURE;
5186 goto returnAfterError;
5187 }
5188 else if( DOT11F_WARNED( nStatus ))
5189 {
5190 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005191 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 }
5193
5194 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005195 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5197
5198 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005199 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5200 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 )
5202 {
5203 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5204 }
5205
5206 if( eHAL_STATUS_SUCCESS !=
5207 (halStatus = halTxFrame( pMac,
5208 pPacket,
5209 (tANI_U16) frameLen,
5210 HAL_TXRX_FRM_802_11_MGMT,
5211 ANI_TXDIR_TODS,
5212 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5213 limTxComplete,
5214 pAddBARspBuffer, txFlag )))
5215 {
5216 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005217 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 halStatus );
5219
5220 // FIXME - HAL error codes are different from PE error
5221 // codes!! And, this routine is returning tSirRetStatus
5222 statusCode = eSIR_FAILURE;
5223 //Pkt will be freed up by the callback
5224 return statusCode;
5225 }
5226 else
5227 return eSIR_SUCCESS;
5228
5229 returnAfterError:
5230
5231 // Release buffer, if allocated
5232 if( NULL != pAddBARspBuffer )
5233 palPktFree( pMac->hHdd,
5234 HAL_TXRX_FRM_802_11_MGMT,
5235 (void *) pAddBARspBuffer,
5236 (void *) pPacket );
5237
5238 return statusCode;
5239}
5240
5241/**
5242 * \brief Send a DELBA Indication Action Frame to peer
5243 *
5244 * \sa limSendDelBAInd
5245 *
5246 * \param pMac The global tpAniSirGlobal object
5247 *
5248 * \param peerMacAddr MAC Address of peer
5249 *
5250 * \param reasonCode Reason for the DELBA notification
5251 *
5252 * \param pBAParameterSet The DELBA Parameter Set.
5253 * This identifies the TID for which the BA session is
5254 * being deleted.
5255 *
5256 * \return eSIR_SUCCESS if setup completes successfully
5257 * eSIR_FAILURE is some problem is encountered
5258 */
5259tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5260 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5261{
5262 tDot11fDelBAInd frmDelBAInd;
5263 tANI_U8 *pDelBAIndBuffer = NULL;
5264 //tANI_U32 val;
5265 tpSirMacMgmtHdr pMacHdr;
5266 tANI_U32 frameLen = 0, nStatus, nPayload;
5267 tSirRetStatus statusCode;
5268 eHalStatus halStatus;
5269 void *pPacket;
5270 tANI_U8 txFlag = 0;
5271
5272 if(NULL == psessionEntry)
5273 {
5274 return eSIR_FAILURE;
5275 }
5276
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305277 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005278
5279 // Category - 3 (BA)
5280 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5281 // Action - 2 (DELBA)
5282 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5283
5284 // Fill the DELBA Parameter Set as provided by caller
5285 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5286 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5287
5288 // BA Starting Sequence Number
5289 // Fragment number will always be zero
5290 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5291
5292 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5293
5294 if( DOT11F_FAILED( nStatus ))
5295 {
5296 limLog( pMac, LOGW,
5297 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005298 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 nStatus );
5300
5301 // We'll fall back on the worst case scenario:
5302 nPayload = sizeof( tDot11fDelBAInd );
5303 }
5304 else if( DOT11F_WARNED( nStatus ))
5305 {
5306 limLog( pMac, LOGW,
5307 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005308 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005309 nStatus );
5310 }
5311
5312 // Add the MGMT header to frame length
5313 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5314
5315 // Allocate shared memory
5316 if( eHAL_STATUS_SUCCESS !=
5317 (halStatus = palPktAlloc( pMac->hHdd,
5318 HAL_TXRX_FRM_802_11_MGMT,
5319 (tANI_U16) frameLen,
5320 (void **) &pDelBAIndBuffer,
5321 (void **) &pPacket )))
5322 {
5323 // Log error
5324 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005325 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005326 frameLen,
5327 halStatus );
5328
5329 statusCode = eSIR_MEM_ALLOC_FAILED;
5330 goto returnAfterError;
5331 }
5332
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305333 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005334
5335 // Copy necessary info to BD
5336 if( eSIR_SUCCESS !=
5337 (statusCode = limPopulateMacHeader( pMac,
5338 pDelBAIndBuffer,
5339 SIR_MAC_MGMT_FRAME,
5340 SIR_MAC_MGMT_ACTION,
5341 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5342 goto returnAfterError;
5343
5344 // Update A3 with the BSSID
5345 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5346
5347 #if 0
5348 cfgLen = SIR_MAC_ADDR_LENGTH;
5349 if( eSIR_SUCCESS != cfgGetStr( pMac,
5350 WNI_CFG_BSSID,
5351 (tANI_U8 *) pMacHdr->bssId,
5352 &cfgLen ))
5353 {
5354 limLog( pMac, LOGP,
5355 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005356 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005357
5358 // FIXME - Need to convert to tSirRetStatus
5359 statusCode = eSIR_FAILURE;
5360 goto returnAfterError;
5361 }
5362 #endif //TO SUPPORT BT-AMP
5363 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5364
Chet Lanctot186b5732013-03-18 10:26:30 -07005365#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005366 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005367#endif
5368
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 // Now, we're ready to "pack" the frames
5370 nStatus = dot11fPackDelBAInd( pMac,
5371 &frmDelBAInd,
5372 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5373 nPayload,
5374 &nPayload );
5375
5376 if( DOT11F_FAILED( nStatus ))
5377 {
5378 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005379 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 nStatus );
5381
5382 // FIXME - Need to convert to tSirRetStatus
5383 statusCode = eSIR_FAILURE;
5384 goto returnAfterError;
5385 }
5386 else if( DOT11F_WARNED( nStatus ))
5387 {
5388 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005389 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 }
5391
5392 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005393 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5395
5396 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5398 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 )
5400 {
5401 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5402 }
5403
5404 if( eHAL_STATUS_SUCCESS !=
5405 (halStatus = halTxFrame( pMac,
5406 pPacket,
5407 (tANI_U16) frameLen,
5408 HAL_TXRX_FRM_802_11_MGMT,
5409 ANI_TXDIR_TODS,
5410 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5411 limTxComplete,
5412 pDelBAIndBuffer, txFlag )))
5413 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005414 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 statusCode = eSIR_FAILURE;
5416 //Pkt will be freed up by the callback
5417 return statusCode;
5418 }
5419 else
5420 return eSIR_SUCCESS;
5421
5422 returnAfterError:
5423
5424 // Release buffer, if allocated
5425 if( NULL != pDelBAIndBuffer )
5426 palPktFree( pMac->hHdd,
5427 HAL_TXRX_FRM_802_11_MGMT,
5428 (void *) pDelBAIndBuffer,
5429 (void *) pPacket );
5430
5431 return statusCode;
5432}
5433
5434#if defined WLAN_FEATURE_VOWIFI
5435
5436/**
5437 * \brief Send a Neighbor Report Request Action frame
5438 *
5439 *
5440 * \param pMac Pointer to the global MAC structure
5441 *
5442 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5443 *
5444 * \param peer mac address of peer station.
5445 *
5446 * \param psessionEntry address of session entry.
5447 *
5448 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5449 *
5450 *
5451 */
5452
5453tSirRetStatus
5454limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5455 tpSirMacNeighborReportReq pNeighborReq,
5456 tSirMacAddr peer,
5457 tpPESession psessionEntry
5458 )
5459{
5460 tSirRetStatus statusCode = eSIR_SUCCESS;
5461 tDot11fNeighborReportRequest frm;
5462 tANI_U8 *pFrame;
5463 tpSirMacMgmtHdr pMacHdr;
5464 tANI_U32 nBytes, nPayload, nStatus;
5465 void *pPacket;
5466 eHalStatus halstatus;
5467 tANI_U8 txFlag = 0;
5468
5469 if ( psessionEntry == NULL )
5470 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005471 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 return eSIR_FAILURE;
5473 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305474 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005475
5476 frm.Category.category = SIR_MAC_ACTION_RRM;
5477 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5478 frm.DialogToken.token = pNeighborReq->dialogToken;
5479
5480
5481 if( pNeighborReq->ssid_present )
5482 {
5483 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5484 }
5485
5486 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5487 if ( DOT11F_FAILED( nStatus ) )
5488 {
5489 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005490 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 nStatus );
5492 // We'll fall back on the worst case scenario:
5493 nPayload = sizeof( tDot11fNeighborReportRequest );
5494 }
5495 else if ( DOT11F_WARNED( nStatus ) )
5496 {
5497 limLog( pMac, LOGW, FL("There were warnings while calculating"
5498 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005499 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 }
5501
5502 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5503
5504 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5505 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5506 {
5507 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005508 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 return eSIR_FAILURE;
5510 }
5511
5512 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305513 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005514
5515 // Copy necessary info to BD
5516 if( eSIR_SUCCESS !=
5517 (statusCode = limPopulateMacHeader( pMac,
5518 pFrame,
5519 SIR_MAC_MGMT_FRAME,
5520 SIR_MAC_MGMT_ACTION,
5521 peer, psessionEntry->selfMacAddr)))
5522 goto returnAfterError;
5523
5524 // Update A3 with the BSSID
5525 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5526
5527 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5528
Chet Lanctot186b5732013-03-18 10:26:30 -07005529#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005530 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005531#endif
5532
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 // Now, we're ready to "pack" the frames
5534 nStatus = dot11fPackNeighborReportRequest( pMac,
5535 &frm,
5536 pFrame + sizeof( tSirMacMgmtHdr ),
5537 nPayload,
5538 &nPayload );
5539
5540 if( DOT11F_FAILED( nStatus ))
5541 {
5542 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005543 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 nStatus );
5545
5546 // FIXME - Need to convert to tSirRetStatus
5547 statusCode = eSIR_FAILURE;
5548 goto returnAfterError;
5549 }
5550 else if( DOT11F_WARNED( nStatus ))
5551 {
5552 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005553 FL( "There were warnings while packing Neighbor Report Request (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 }
5555
5556 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005557 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 limPrintMacAddr( pMac, peer, LOGW );
5559
5560 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5562 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 )
5564 {
5565 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5566 }
5567
5568 if( eHAL_STATUS_SUCCESS !=
5569 (halstatus = halTxFrame( pMac,
5570 pPacket,
5571 (tANI_U16) nBytes,
5572 HAL_TXRX_FRM_802_11_MGMT,
5573 ANI_TXDIR_TODS,
5574 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5575 limTxComplete,
5576 pFrame, txFlag )))
5577 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005578 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 statusCode = eSIR_FAILURE;
5580 //Pkt will be freed up by the callback
5581 return statusCode;
5582 }
5583 else
5584 return eSIR_SUCCESS;
5585
5586returnAfterError:
5587 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5588
5589 return statusCode;
5590} // End limSendNeighborReportRequestFrame.
5591
5592/**
5593 * \brief Send a Link Report Action frame
5594 *
5595 *
5596 * \param pMac Pointer to the global MAC structure
5597 *
5598 * \param pLinkReport Address of a tSirMacLinkReport
5599 *
5600 * \param peer mac address of peer station.
5601 *
5602 * \param psessionEntry address of session entry.
5603 *
5604 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5605 *
5606 *
5607 */
5608
5609tSirRetStatus
5610limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5611 tpSirMacLinkReport pLinkReport,
5612 tSirMacAddr peer,
5613 tpPESession psessionEntry
5614 )
5615{
5616 tSirRetStatus statusCode = eSIR_SUCCESS;
5617 tDot11fLinkMeasurementReport frm;
5618 tANI_U8 *pFrame;
5619 tpSirMacMgmtHdr pMacHdr;
5620 tANI_U32 nBytes, nPayload, nStatus;
5621 void *pPacket;
5622 eHalStatus halstatus;
5623 tANI_U8 txFlag = 0;
5624
5625
5626 if ( psessionEntry == NULL )
5627 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005628 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005629 return eSIR_FAILURE;
5630 }
5631
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305632 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005633
5634 frm.Category.category = SIR_MAC_ACTION_RRM;
5635 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5636 frm.DialogToken.token = pLinkReport->dialogToken;
5637
5638
5639 //IEEE Std. 802.11 7.3.2.18. for the report element.
5640 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5641 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5642 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5643 //such case this way than changing the frame parser.
5644 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5645 frm.TPCEleLen.TPCLen = 2;
5646 frm.TxPower.txPower = pLinkReport->txPower;
5647 frm.LinkMargin.linkMargin = 0;
5648
5649 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5650 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5651 frm.RCPI.rcpi = pLinkReport->rcpi;
5652 frm.RSNI.rsni = pLinkReport->rsni;
5653
5654 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5655 if ( DOT11F_FAILED( nStatus ) )
5656 {
5657 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005658 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 nStatus );
5660 // We'll fall back on the worst case scenario:
5661 nPayload = sizeof( tDot11fLinkMeasurementReport );
5662 }
5663 else if ( DOT11F_WARNED( nStatus ) )
5664 {
5665 limLog( pMac, LOGW, FL("There were warnings while calculating"
5666 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005667 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 }
5669
5670 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5671
5672 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5673 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5674 {
5675 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005676 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 return eSIR_FAILURE;
5678 }
5679
5680 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305681 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005682
5683 // Copy necessary info to BD
5684 if( eSIR_SUCCESS !=
5685 (statusCode = limPopulateMacHeader( pMac,
5686 pFrame,
5687 SIR_MAC_MGMT_FRAME,
5688 SIR_MAC_MGMT_ACTION,
5689 peer, psessionEntry->selfMacAddr)))
5690 goto returnAfterError;
5691
5692 // Update A3 with the BSSID
5693 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5694
5695 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5696
Chet Lanctot186b5732013-03-18 10:26:30 -07005697#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005698 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005699#endif
5700
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 // Now, we're ready to "pack" the frames
5702 nStatus = dot11fPackLinkMeasurementReport( pMac,
5703 &frm,
5704 pFrame + sizeof( tSirMacMgmtHdr ),
5705 nPayload,
5706 &nPayload );
5707
5708 if( DOT11F_FAILED( nStatus ))
5709 {
5710 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005711 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 nStatus );
5713
5714 // FIXME - Need to convert to tSirRetStatus
5715 statusCode = eSIR_FAILURE;
5716 goto returnAfterError;
5717 }
5718 else if( DOT11F_WARNED( nStatus ))
5719 {
5720 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005721 FL( "There were warnings while packing Link Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 }
5723
5724 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005725 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 limPrintMacAddr( pMac, peer, LOGW );
5727
5728 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005729 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5730 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 )
5732 {
5733 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5734 }
5735
5736 if( eHAL_STATUS_SUCCESS !=
5737 (halstatus = halTxFrame( pMac,
5738 pPacket,
5739 (tANI_U16) nBytes,
5740 HAL_TXRX_FRM_802_11_MGMT,
5741 ANI_TXDIR_TODS,
5742 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5743 limTxComplete,
5744 pFrame, txFlag )))
5745 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005746 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 statusCode = eSIR_FAILURE;
5748 //Pkt will be freed up by the callback
5749 return statusCode;
5750 }
5751 else
5752 return eSIR_SUCCESS;
5753
5754returnAfterError:
5755 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5756
5757 return statusCode;
5758} // End limSendLinkReportActionFrame.
5759
5760/**
5761 * \brief Send a Beacon Report Action frame
5762 *
5763 *
5764 * \param pMac Pointer to the global MAC structure
5765 *
5766 * \param dialog_token dialog token to be used in the action frame.
5767 *
5768 * \param num_report number of reports in pRRMReport.
5769 *
5770 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5771 *
5772 * \param peer mac address of peer station.
5773 *
5774 * \param psessionEntry address of session entry.
5775 *
5776 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5777 *
5778 *
5779 */
5780
5781tSirRetStatus
5782limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5783 tANI_U8 dialog_token,
5784 tANI_U8 num_report,
5785 tpSirMacRadioMeasureReport pRRMReport,
5786 tSirMacAddr peer,
5787 tpPESession psessionEntry
5788 )
5789{
5790 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 tANI_U8 *pFrame;
5792 tpSirMacMgmtHdr pMacHdr;
5793 tANI_U32 nBytes, nPayload, nStatus;
5794 void *pPacket;
5795 eHalStatus halstatus;
5796 tANI_U8 i;
5797 tANI_U8 txFlag = 0;
5798
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005799 tDot11fRadioMeasurementReport *frm =
5800 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5801 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005802 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005803 return eSIR_FAILURE;
5804 }
5805
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 if ( psessionEntry == NULL )
5807 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005808 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005809 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 return eSIR_FAILURE;
5811 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305812 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005813
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005814 frm->Category.category = SIR_MAC_ACTION_RRM;
5815 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5816 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005817
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005818 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 -07005819
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005820 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005822 frm->MeasurementReport[i].type = pRRMReport[i].type;
5823 frm->MeasurementReport[i].token = pRRMReport[i].token;
5824 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 switch( pRRMReport[i].type )
5826 {
5827 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005828 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5829 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5830 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5831 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 break;
5833 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305834 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5835 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005836 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 break;
5838 }
5839 }
5840
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005841 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 if ( DOT11F_FAILED( nStatus ) )
5843 {
5844 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005845 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 nStatus );
5847 // We'll fall back on the worst case scenario:
5848 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005849 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 return eSIR_FAILURE;
5851 }
5852 else if ( DOT11F_WARNED( nStatus ) )
5853 {
5854 limLog( pMac, LOGW, FL("There were warnings while calculating"
5855 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005856 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 }
5858
5859 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5860
5861 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5862 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5863 {
5864 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005865 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005866 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 return eSIR_FAILURE;
5868 }
5869
5870 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305871 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005872
5873 // Copy necessary info to BD
5874 if( eSIR_SUCCESS !=
5875 (statusCode = limPopulateMacHeader( pMac,
5876 pFrame,
5877 SIR_MAC_MGMT_FRAME,
5878 SIR_MAC_MGMT_ACTION,
5879 peer, psessionEntry->selfMacAddr)))
5880 goto returnAfterError;
5881
5882 // Update A3 with the BSSID
5883 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5884
5885 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5886
Chet Lanctot186b5732013-03-18 10:26:30 -07005887#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005888 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005889#endif
5890
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 // Now, we're ready to "pack" the frames
5892 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005893 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 pFrame + sizeof( tSirMacMgmtHdr ),
5895 nPayload,
5896 &nPayload );
5897
5898 if( DOT11F_FAILED( nStatus ))
5899 {
5900 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005901 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 nStatus );
5903
5904 // FIXME - Need to convert to tSirRetStatus
5905 statusCode = eSIR_FAILURE;
5906 goto returnAfterError;
5907 }
5908 else if( DOT11F_WARNED( nStatus ))
5909 {
5910 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005911 FL( "There were warnings while packing Radio Measure Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 }
5913
5914 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005915 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 limPrintMacAddr( pMac, peer, LOGW );
5917
5918 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5920 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 )
5922 {
5923 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5924 }
5925
5926 if( eHAL_STATUS_SUCCESS !=
5927 (halstatus = halTxFrame( pMac,
5928 pPacket,
5929 (tANI_U16) nBytes,
5930 HAL_TXRX_FRM_802_11_MGMT,
5931 ANI_TXDIR_TODS,
5932 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5933 limTxComplete,
5934 pFrame, txFlag )))
5935 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005936 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 statusCode = eSIR_FAILURE;
5938 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005939 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 return statusCode;
5941 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005942 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005943 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005945 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005946
5947returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005948 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 return statusCode;
5951} // End limSendBeaconReportActionFrame.
5952
5953#endif
5954
5955#ifdef WLAN_FEATURE_11W
5956/**
5957 * \brief Send SA query response action frame to peer
5958 *
5959 * \sa limSendSaQueryResponseFrame
5960 *
5961 *
5962 * \param pMac The global tpAniSirGlobal object
5963 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005964 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005966 * \param peer The Mac address of the AP to which this action frame is addressed
5967 *
5968 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 *
5970 * \return eSIR_SUCCESS if setup completes successfully
5971 * eSIR_FAILURE is some problem is encountered
5972 */
5973
Chet Lanctot186b5732013-03-18 10:26:30 -07005974tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005975tSirMacAddr peer,tpPESession psessionEntry)
5976{
5977
Chet Lanctot186b5732013-03-18 10:26:30 -07005978 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 tANI_U8 *pFrame;
5980 tSirRetStatus nSirStatus;
5981 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07005982 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 void *pPacket;
5984 eHalStatus halstatus;
Chet Lanctot186b5732013-03-18 10:26:30 -07005985 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005986
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305987 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07005988 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
5989 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 action: 0 --> SA query request action frame
5991 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07005992 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
5993 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07005995 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005996
Chet Lanctot186b5732013-03-18 10:26:30 -07005997 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
5998 if ( DOT11F_FAILED( nStatus ) )
5999 {
6000 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6001 "or a SA Query Response (0x%08x)."),
6002 nStatus );
6003 // We'll fall back on the worst case scenario:
6004 nPayload = sizeof( tDot11fSaQueryRsp );
6005 }
6006 else if ( DOT11F_WARNED( nStatus ) )
6007 {
6008 limLog( pMac, LOGW, FL("There were warnings while calculating"
6009 "the packed size for an SA Query Response"
6010 " (0x%08x)."), nStatus );
6011 }
6012
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6014 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6015 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6016 {
6017 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006018 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 return eSIR_FAILURE;
6020 }
6021
6022 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306023 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006024
Chet Lanctot186b5732013-03-18 10:26:30 -07006025 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006026 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006027 pFrame,
6028 SIR_MAC_MGMT_FRAME,
6029 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006030 peer, psessionEntry->selfMacAddr );
6031 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006032 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006033
Chet Lanctot186b5732013-03-18 10:26:30 -07006034 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6036
Chet Lanctot186b5732013-03-18 10:26:30 -07006037 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006038
Chet Lanctot186b5732013-03-18 10:26:30 -07006039 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6040 // in the FC
6041 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006043 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 }
6045
Chet Lanctot186b5732013-03-18 10:26:30 -07006046 // Pack 11w SA query response frame
6047 nStatus = dot11fPackSaQueryRsp( pMac,
6048 &frm,
6049 pFrame + sizeof( tSirMacMgmtHdr ),
6050 nPayload,
6051 &nPayload );
6052
6053 if ( DOT11F_FAILED( nStatus ))
6054 {
6055 limLog( pMac, LOGE,
6056 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6057 nStatus );
6058 // FIXME - Need to convert to tSirRetStatus
6059 nSirStatus = eSIR_FAILURE;
6060 goto returnAfterError;
6061 }
6062 else if ( DOT11F_WARNED( nStatus ))
6063 {
6064 limLog( pMac, LOGW,
6065 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6066 nStatus);
6067 }
6068
6069 limLog( pMac, LOG1,
6070 FL( "Sending a SA Query Response to " ));
6071 limPrintMacAddr( pMac, peer, LOGW );
6072
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006073 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006074#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006075 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6076 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006077#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006078 )
6079 {
6080 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6081 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006082
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006083 halstatus = halTxFrame( pMac,
6084 pPacket,
6085 (tANI_U16) nBytes,
6086 HAL_TXRX_FRM_802_11_MGMT,
6087 ANI_TXDIR_TODS,
6088 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6089 limTxComplete,
6090 pFrame, txFlag );
6091 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006092 {
6093 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6094 nSirStatus = eSIR_FAILURE;
6095 //Pkt will be freed up by the callback
6096 return nSirStatus;
6097 }
6098 else {
6099 return eSIR_SUCCESS;
6100 }
6101
6102returnAfterError:
6103 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6104 return nSirStatus;
6105} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006106#endif