blob: 980ebe60b0334ad9b775a14529ac2be2a04a29d8 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Jeff Johnson295189b2012-06-20 16:38:30 -07005 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006/**
7 * \file limSendManagementFrames.c
8 *
9 * \brief Code for preparing and sending 802.11 Management frames
10 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080011 * Copyright (C) 2005-2007 Airgo Networks, Incorporated
Jeff Johnson295189b2012-06-20 16:38:30 -070012 *
13 */
14
15#include "sirApi.h"
16#include "aniGlobal.h"
17#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070018#include "cfgApi.h"
19#include "utilsApi.h"
20#include "limTypes.h"
21#include "limUtils.h"
22#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070023#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070024#include "dot11f.h"
25#include "limStaHashApi.h"
26#include "schApi.h"
27#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080028#include "limAssocUtils.h"
29#include "limFT.h"
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031#if defined WLAN_FEATURE_VOWIFI
32#include "rrmApi.h"
33#endif
34
Jeff Johnson295189b2012-06-20 16:38:30 -070035#include "wlan_qct_wda.h"
36#ifdef WLAN_FEATURE_11W
37#include "dot11fdefs.h"
38#endif
39
40
41////////////////////////////////////////////////////////////////////////
42
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44/**
45 *
46 * \brief This function is called by various LIM modules to prepare the
47 * 802.11 frame MAC header
48 *
49 *
50 * \param pMac Pointer to Global MAC structure
51 *
52 * \param pBD Pointer to the frame buffer that needs to be populate
53 *
54 * \param type Type of the frame
55 *
56 * \param subType Subtype of the frame
57 *
58 * \return eHalStatus
59 *
60 *
61 * The pFrameBuf argument points to the beginning of the frame buffer to
62 * which - a) The 802.11 MAC header is set b) Following this MAC header
63 * will be the MGMT frame payload The payload itself is populated by the
64 * caller API
65 *
66 *
67 */
68
69tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
70 tANI_U8* pBD,
71 tANI_U8 type,
72 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +053073 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070074{
75 tSirRetStatus statusCode = eSIR_SUCCESS;
76 tpSirMacMgmtHdr pMacHdr;
77
78 /// Prepare MAC management header
79 pMacHdr = (tpSirMacMgmtHdr) (pBD);
80
81 // Prepare FC
82 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
83 pMacHdr->fc.type = type;
84 pMacHdr->fc.subType = subType;
85
86 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +053087 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -070088 (tANI_U8 *) peerAddr,
89 sizeof( tSirMacAddr ));
90
91 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -070092 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
93
94 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +053095 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -070096 (tANI_U8 *) peerAddr,
97 sizeof( tSirMacAddr ));
98 return statusCode;
99} /*** end limPopulateMacHeader() ***/
100
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700101#ifdef WLAN_FEATURE_11W
102/**
103 *
104 * \brief This function is called by various LIM modules to correctly set
105 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
106 *
107 *
108 * \param pMac Pointer to Global MAC structure
109 *
110 * \param psessionEntry Pointer to session corresponding to the connection
111 *
112 * \param peer Peer address of the STA to which the frame is to be sent
113 *
114 * \param pMacHdr Pointer to the frame MAC header
115 *
116 * \return nothing
117 *
118 *
119 */
120void
121limSetProtectedBit(tpAniSirGlobal pMac,
122 tpPESession psessionEntry,
123 tSirMacAddr peer,
124 tpSirMacMgmtHdr pMacHdr)
125{
126 tANI_U16 aid;
127 tpDphHashNode pStaDs;
128
129 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
130 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
131 {
132
133 pStaDs = dphLookupHashEntry( pMac, peer, &aid, &psessionEntry->dph.dphHashTable );
134 if( pStaDs != NULL )
135 if( pStaDs->rmfEnabled )
136 pMacHdr->fc.wep = 1;
137 }
138 else if ( psessionEntry->limRmfEnabled )
139 pMacHdr->fc.wep = 1;
140} /*** end limSetProtectedBit() ***/
141#endif
142
Jeff Johnson295189b2012-06-20 16:38:30 -0700143/**
144 * \brief limSendProbeReqMgmtFrame
145 *
146 *
147 * \param pMac Pointer to Global MAC structure
148 *
149 * \param pSsid SSID to be sent in Probe Request frame
150 *
151 * \param bssid BSSID to be sent in Probe Request frame
152 *
153 * \param nProbeDelay probe delay to be used before sending Probe Request
154 * frame
155 *
156 * \param nChannelNum Channel # on which the Probe Request is going out
157 *
158 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
159 *
160 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
161 *
162 * This function is called by various LIM modules to send Probe Request frame
163 * during active scan/learn phase.
164 * Probe request is sent out in the following scenarios:
165 * --heartbeat failure: session needed
166 * --join req: session needed
167 * --foreground scan: no session
168 * --background scan: no session
169 * --schBeaconProcessing: to get EDCA parameters: session needed
170 *
171 *
172 */
173tSirRetStatus
174limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
175 tSirMacSSid *pSsid,
176 tSirMacAddr bssid,
177 tANI_U8 nChannelNum,
178 tSirMacAddr SelfMacAddr,
179 tANI_U32 dot11mode,
180 tANI_U32 nAdditionalIELen,
181 tANI_U8 *pAdditionalIE)
182{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530183 tDot11fProbeRequest pr;
184 tANI_U32 nStatus, nBytes, nPayload;
185 tSirRetStatus nSirStatus;
186 tANI_U8 *pFrame;
187 void *pPacket;
188 eHalStatus halstatus;
189 tpPESession psessionEntry;
190 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700191 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530192 tANI_U32 txFlag = 0;
Sandeep Puligilla60342762014-01-30 21:05:37 +0530193 tANI_U32 chanbond24G = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700194
195#ifndef GEN4_SCAN
196 return eSIR_FAILURE;
197#endif
198
199#if defined ( ANI_DVT_DEBUG )
200 return eSIR_FAILURE;
201#endif
202
Abhishek Singh4beed422014-02-03 16:47:17 +0530203 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
204 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
205 * is false and dot11mode is 11ac set it to 11n.
206 */
207 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
208 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
209 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
210 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
211 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 /*
213 * session context may or may not be present, when probe request needs to be sent out.
214 * following cases exist:
215 * --heartbeat failure: session needed
216 * --join req: session needed
217 * --foreground scan: no session
218 * --background scan: no session
219 * --schBeaconProcessing: to get EDCA parameters: session needed
220 * If session context does not exist, some IEs will be populated from CFGs,
221 * e.g. Supported and Extended rate set IEs
222 */
223 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
224
225 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
226 // and then hand it off to 'dot11fPackProbeRequest' (for
227 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530228 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700229
230 // & delegating to assorted helpers:
231 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
232
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 if( nAdditionalIELen && pAdditionalIE )
234 {
235 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
236 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700237 /* Don't include 11b rate only when device is doing P2P Search */
238 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
239 ( p2pIe != NULL ) &&
240 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
241 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
242 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
243 ( ( psessionEntry != NULL ) &&
244 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
245 )
246 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 {
248 /* In the below API pass channel number > 14, do that it fills only
249 * 11a rates in supported rates */
250 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
251 }
252 else
253 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 PopulateDot11fSuppRates( pMac, nChannelNum,
255 &pr.SuppRates,psessionEntry);
256
257 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
258 {
259 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
260 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700262
263#if defined WLAN_FEATURE_VOWIFI
264 //Table 7-14 in IEEE Std. 802.11k-2008 says
265 //DS params "can" be present in RRM is disabled and "is" present if
266 //RRM is enabled. It should be ok even if we add it into probe req when
267 //RRM is not enabled.
268 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
269 //Call RRM module to get the tx power for management used.
270 {
271 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
272 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
273 }
274#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700275
276 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700277 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700279 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700280 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700281 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700283 } else { //psessionEntry == NULL
284 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700286 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 }
288 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800289
Sandeep Puligilla60342762014-01-30 21:05:37 +0530290 /* Get HT40 capability for 2.4GHz band */
291 wlan_cfgGetInt(pMac,WNI_CFG_CHANNEL_BONDING_24G,&chanbond24G);
292 if( (nChannelNum <= SIR_11B_CHANNEL_END) && chanbond24G != TRUE)
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800293 {
294 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
295 pr.HTCaps.shortGI40MHz = 0;
296 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700297#ifdef WLAN_FEATURE_11AC
298 if (psessionEntry != NULL ) {
299 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
300 //Include HT Capability IE
301 if (psessionEntry->vhtCapability)
302 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700303 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
304 }
305 } else {
306 if (IS_DOT11_MODE_VHT(dot11mode))
307 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700308 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
309 }
310 }
311#endif
312
Jeff Johnson295189b2012-06-20 16:38:30 -0700313
314 // That's it-- now we pack it. First, how much space are we going to
315 // need?
316 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
317 if ( DOT11F_FAILED( nStatus ) )
318 {
319 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700320 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 // We'll fall back on the worst case scenario:
322 nPayload = sizeof( tDot11fProbeRequest );
323 }
324 else if ( DOT11F_WARNED( nStatus ) )
325 {
326 limLog( pMac, LOGW, FL("There were warnings while calculating"
327 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700328 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 }
330
331 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
332
333 // Ok-- try to allocate some memory:
334 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
335 ( tANI_U16 )nBytes, ( void** ) &pFrame,
336 ( void** ) &pPacket );
337 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
338 {
339 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700340 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700341 return eSIR_MEM_ALLOC_FAILED;
342 }
343
344 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530345 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700346
347 // Next, we fill out the buffer descriptor:
348 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530349 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 if ( eSIR_SUCCESS != nSirStatus )
351 {
352 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700353 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 nSirStatus );
355 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
356 ( void* ) pFrame, ( void* ) pPacket );
357 return nSirStatus; // allocated!
358 }
359
360 // That done, pack the Probe Request:
361 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
362 sizeof( tSirMacMgmtHdr ),
363 nPayload, &nPayload );
364 if ( DOT11F_FAILED( nStatus ) )
365 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700366 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 nStatus );
368 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
369 return eSIR_FAILURE; // allocated!
370 }
371 else if ( DOT11F_WARNED( nStatus ) )
372 {
373 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800374 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 }
376
377 // Append any AddIE if present.
378 if( nAdditionalIELen )
379 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530380 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 pAdditionalIE, nAdditionalIELen );
382 nPayload += nAdditionalIELen;
383 }
384
385 /* If this probe request is sent during P2P Search State, then we need
386 * to send it at OFDM rate.
387 */
388 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
390 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530391 /* For unicast probe req mgmt from Join function
392 we don't set above variables. So we need to add
393 one more check whether it is pePersona is P2P_CLIENT or not */
394 || ( ( psessionEntry != NULL ) &&
395 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700396 )
397 {
398 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
399 }
400
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
402 HAL_TXRX_FRM_802_11_MGMT,
403 ANI_TXDIR_TODS,
404 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
405 limTxComplete, pFrame, txFlag );
406 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
407 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700408 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 //Pkt will be freed up by the callback
410 return eSIR_FAILURE;
411 }
412
413 return eSIR_SUCCESS;
414} // End limSendProbeReqMgmtFrame.
415
Jeff Johnson295189b2012-06-20 16:38:30 -0700416tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
417 tANI_U8* addIE, tANI_U16 *addnIELen,
418 tANI_U8 probeReqP2pIe)
419{
420 /* If Probe request doesn't have P2P IE, then take out P2P IE
421 from additional IE */
422 if(!probeReqP2pIe)
423 {
424 tANI_U8* tempbuf = NULL;
425 tANI_U16 tempLen = 0;
426 int left = *addnIELen;
427 v_U8_t *ptr = addIE;
428 v_U8_t elem_id, elem_len;
429
430 if(NULL == addIE)
431 {
432 PELOGE(limLog(pMac, LOGE,
433 FL(" NULL addIE pointer"));)
434 return eSIR_FAILURE;
435 }
436
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530437 tempbuf = vos_mem_malloc(left);
438 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 {
440 PELOGE(limLog(pMac, LOGE,
441 FL("Unable to allocate memory to store addn IE"));)
442 return eSIR_MEM_ALLOC_FAILED;
443 }
444
445 while(left >= 2)
446 {
447 elem_id = ptr[0];
448 elem_len = ptr[1];
449 left -= 2;
450 if(elem_len > left)
451 {
452 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700453 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700454 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530455 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 return eSIR_FAILURE;
457 }
458 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
459 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
460 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530461 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 tempLen += (elem_len + 2);
463 }
464 left -= elem_len;
465 ptr += (elem_len + 2);
466 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530467 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530469 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 }
471 return eSIR_SUCCESS;
472}
Jeff Johnson295189b2012-06-20 16:38:30 -0700473
474void
475limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
476 tSirMacAddr peerMacAddr,
477 tpAniSSID pSsid,
478 short nStaId,
479 tANI_U8 nKeepAlive,
480 tpPESession psessionEntry,
481 tANI_U8 probeReqP2pIe)
482{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700483 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530484 tSirRetStatus nSirStatus;
485 tANI_U32 cfg, nPayload, nBytes, nStatus;
486 tpSirMacMgmtHdr pMacHdr;
487 tANI_U8 *pFrame;
488 void *pPacket;
489 eHalStatus halstatus;
490 tANI_U32 addnIEPresent;
491 tANI_U32 addnIE1Len=0;
492 tANI_U32 addnIE2Len=0;
493 tANI_U32 addnIE3Len=0;
494 tANI_U16 totalAddnIeLen = 0;
495 tANI_U32 wpsApEnable=0, tmp;
496 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530498 tANI_U8 *pP2pIe = NULL;
499 tANI_U8 noaLen = 0;
500 tANI_U8 total_noaLen = 0;
501 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530503 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700504
505 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
506 {
507 return; // in this case.
508 }
509
510 if(NULL == psessionEntry)
511 {
512 return;
513 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530514
515 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
516 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700517 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530518 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700519 return;
520 }
521
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 // Fill out 'frm', after which we'll just hand the struct off to
523 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530524 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700525
526 // Timestamp to be updated by TFP, below.
527
528 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
530 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700531 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 }
533 else
534 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800535 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
536 if (eSIR_SUCCESS != nSirStatus)
537 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700538 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800539 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530540 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800541 return;
542 }
543 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800544 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700545
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700546 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
547 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700549 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700550
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700551 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
552 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700553
Jeff Johnson295189b2012-06-20 16:38:30 -0700554
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
556 {
557 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
558 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700559 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 }
561 }
562 else
563 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800564 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700565 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800567 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700568
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800569 if (wpsApEnable)
570 {
571 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
572 }
573
574 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
575 {
576 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
577 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
578 }
579
580 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
581 {
582 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
583 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
584 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700586
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700587 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
588 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700589
Jeff Johnson295189b2012-06-20 16:38:30 -0700590
591 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700592 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700593
594
595 // N.B. In earlier implementations, the RSN IE would be placed in
596 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
597 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700598 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700599
600 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700601 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700603 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700604 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700606#ifdef WLAN_FEATURE_11AC
607 if(psessionEntry->vhtCapability)
608 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800609 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700610 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
611 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700612 // we do not support multi users yet
613 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Sandeep Puligilla60342762014-01-30 21:05:37 +0530614 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700615 }
616#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700617
Sandeep Puligilla60342762014-01-30 21:05:37 +0530618
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 if ( psessionEntry->pLimStartBssReq )
620 {
621 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700622 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700623 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
624 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 }
626
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700627 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700628
629#if defined(FEATURE_WLAN_WAPI)
630 if( psessionEntry->pLimStartBssReq )
631 {
632 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700633 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 }
635
636#endif // defined(FEATURE_WLAN_WAPI)
637
638
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700639 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 if ( DOT11F_FAILED( nStatus ) )
641 {
642 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700643 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 nStatus );
645 // We'll fall back on the worst case scenario:
646 nPayload = sizeof( tDot11fProbeResponse );
647 }
648 else if ( DOT11F_WARNED( nStatus ) )
649 {
650 limLog( pMac, LOGW, FL("There were warnings while calculating"
651 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700652 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 }
654
655 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
656
657 addnIEPresent = false;
658
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 if( pMac->lim.gpLimRemainOnChanReq )
660 {
661 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
662 }
663 //Only use CFG for non-listen mode. This CFG is not working for concurrency
664 //In listening mode, probe rsp IEs is passed in the message from SME to PE
665 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 {
667
668 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
669 &addnIEPresent) != eSIR_SUCCESS)
670 {
671 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530672 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 return;
674 }
675 }
676
677 if (addnIEPresent)
678 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530679
680 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
681 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 {
683 PELOGE(limLog(pMac, LOGE,
684 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530685 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700686 return;
687 }
688
689 //Probe rsp IE available
690 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
691 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
692 {
693 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530694 vos_mem_free(addIE);
695 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 return;
697 }
698 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
699 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
700 {
701 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
702 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
703 &addnIE1Len) )
704 {
705 limLog(pMac, LOGP,
706 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530707 vos_mem_free(addIE);
708 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700709 return;
710 }
711 }
712
713 //Probe rsp IE available
714 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
715 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
716 {
717 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530718 vos_mem_free(addIE);
719 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 return;
721 }
722 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
723 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
724 {
725 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
726 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
727 &addnIE2Len) )
728 {
729 limLog(pMac, LOGP,
730 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530731 vos_mem_free(addIE);
732 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 return;
734 }
735 }
736
737 //Probe rsp IE available
738 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
739 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
740 {
741 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530742 vos_mem_free(addIE);
743 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 return;
745 }
746 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
747 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
748 {
749 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
750 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
751 &addIE[addnIE1Len + addnIE2Len],
752 &addnIE3Len) )
753 {
754 limLog(pMac, LOGP,
755 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530756 vos_mem_free(addIE);
757 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 return;
759 }
760 }
761 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
762
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
764 {
765 limLog(pMac, LOGP,
766 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530767 vos_mem_free(addIE);
768 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 return;
770 }
771 nBytes = nBytes + totalAddnIeLen;
772
773 if (probeReqP2pIe)
774 {
775 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
776 if (pP2pIe != NULL)
777 {
778 //get NoA attribute stream P2P IE
779 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
780 if (noaLen != 0)
781 {
782 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
783 &noaStream[0], noaLen);
784 nBytes = nBytes + total_noaLen;
785 }
786 }
787 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 }
789
790 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
791 ( tANI_U16 )nBytes, ( void** ) &pFrame,
792 ( void** ) &pPacket );
793 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
794 {
795 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700796 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 if ( addIE != NULL )
798 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530799 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700800 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530801 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 return;
803 }
804
805 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530806 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700807
808 // Next, we fill out the buffer descriptor:
809 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
810 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
811 if ( eSIR_SUCCESS != nSirStatus )
812 {
813 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700814 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 nSirStatus );
816 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
817 ( void* ) pFrame, ( void* ) pPacket );
818 if ( addIE != NULL )
819 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530820 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530822 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700823 return;
824 }
825
826 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
827
828 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
829
830 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700831 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 nPayload, &nPayload );
833 if ( DOT11F_FAILED( nStatus ) )
834 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700835 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 nStatus );
837 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
838 if ( addIE != NULL )
839 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530840 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530842 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 return; // allocated!
844 }
845 else if ( DOT11F_WARNED( nStatus ) )
846 {
847 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800848 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 }
850
851 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
852 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
853
854 pMac->sys.probeRespond++;
855
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 if( pMac->lim.gpLimRemainOnChanReq )
857 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530858 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
860 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700861
862 if ( addnIEPresent )
863 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530864 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 if (noaLen != 0)
867 {
Krunal Soni81b24262013-05-15 17:46:41 -0700868 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 {
870 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +0530871 FL("Not able to insert NoA because of length constraint."
872 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530873 vos_mem_free(addIE);
874 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -0700875 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
876 ( void* ) pFrame, ( void* ) pPacket );
877 return;
878 }
879 else
880 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530881 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -0700882 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 }
884 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700885
886 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
888 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 )
890 {
891 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
892 }
893
894 // Queue Probe Response frame in high priority WQ
895 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
896 ( tANI_U16 ) nBytes,
897 HAL_TXRX_FRM_802_11_MGMT,
898 ANI_TXDIR_TODS,
899 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
900 limTxComplete, pFrame, txFlag );
901 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
902 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700903 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 //Pkt will be freed up by the callback
905 }
906
907 if ( addIE != NULL )
908 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530909 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 }
911
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530912 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700913 return;
914
915
Jeff Johnson295189b2012-06-20 16:38:30 -0700916} // End limSendProbeRspMgmtFrame.
917
918void
919limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
920 tSirMacAddr peerMacAddr,
921 tSirAddtsReqInfo *pAddTS,
922 tpPESession psessionEntry)
923{
924 tANI_U16 i;
925 tANI_U8 *pFrame;
926 tSirRetStatus nSirStatus;
927 tDot11fAddTSRequest AddTSReq;
928 tDot11fWMMAddTSRequest WMMAddTSReq;
929 tANI_U32 nPayload, nBytes, nStatus;
930 tpSirMacMgmtHdr pMacHdr;
931 void *pPacket;
932#ifdef FEATURE_WLAN_CCX
933 tANI_U32 phyMode;
934#endif
935 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530936 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700937
938 if(NULL == psessionEntry)
939 {
940 return;
941 }
942
943 if ( ! pAddTS->wmeTspecPresent )
944 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530945 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700946
947 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
948 AddTSReq.DialogToken.token = pAddTS->dialogToken;
949 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
950 if ( pAddTS->lleTspecPresent )
951 {
952 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
953 }
954 else
955 {
956 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
957 }
958
959 if ( pAddTS->lleTspecPresent )
960 {
961 AddTSReq.num_WMMTCLAS = 0;
962 AddTSReq.num_TCLAS = pAddTS->numTclas;
963 for ( i = 0; i < pAddTS->numTclas; ++i)
964 {
965 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
966 &AddTSReq.TCLAS[i] );
967 }
968 }
969 else
970 {
971 AddTSReq.num_TCLAS = 0;
972 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
973 for ( i = 0; i < pAddTS->numTclas; ++i)
974 {
975 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
976 &AddTSReq.WMMTCLAS[i] );
977 }
978 }
979
980 if ( pAddTS->tclasProcPresent )
981 {
982 if ( pAddTS->lleTspecPresent )
983 {
984 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
985 AddTSReq.TCLASSPROC.present = 1;
986 }
987 else
988 {
989 AddTSReq.WMMTCLASPROC.version = 1;
990 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
991 AddTSReq.WMMTCLASPROC.present = 1;
992 }
993 }
994
995 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
996 if ( DOT11F_FAILED( nStatus ) )
997 {
998 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700999 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 nStatus );
1001 // We'll fall back on the worst case scenario:
1002 nPayload = sizeof( tDot11fAddTSRequest );
1003 }
1004 else if ( DOT11F_WARNED( nStatus ) )
1005 {
1006 limLog( pMac, LOGW, FL("There were warnings while calculating"
1007 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001008 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 }
1010 }
1011 else
1012 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301013 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001014
1015 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1016 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1017 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1018
1019 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1020 WMMAddTSReq.StatusCode.statusCode = 0;
1021
1022 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1023#ifdef FEATURE_WLAN_CCX
1024 limGetPhyMode(pMac, &phyMode, psessionEntry);
1025
1026 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1027 {
1028 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1029 }
1030 else
1031 {
1032 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1033 }
1034 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1035#endif
1036 // fillWmeTspecIE
1037
1038 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1039 if ( DOT11F_FAILED( nStatus ) )
1040 {
1041 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001042 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 nStatus );
1044 // We'll fall back on the worst case scenario:
1045 nPayload = sizeof( tDot11fAddTSRequest );
1046 }
1047 else if ( DOT11F_WARNED( nStatus ) )
1048 {
1049 limLog( pMac, LOGW, FL("There were warnings while calculating"
1050 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001051 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 }
1053 }
1054
1055 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1056
1057 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1058 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1059 ( void** ) &pPacket );
1060 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1061 {
1062 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001063 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 return;
1065 }
1066
1067 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301068 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001069
1070 // Next, we fill out the buffer descriptor:
1071 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1072 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1073 if ( eSIR_SUCCESS != nSirStatus )
1074 {
1075 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001076 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 nSirStatus );
1078 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1079 ( void* ) pFrame, ( void* ) pPacket );
1080 return;
1081 }
1082
1083 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1084
1085 #if 0
1086 cfgLen = SIR_MAC_ADDR_LENGTH;
1087 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1088 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1089 {
1090 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001091 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1093 ( void* ) pFrame, ( void* ) pPacket );
1094 return;
1095 }
1096 #endif //TO SUPPORT BT-AMP
1097
1098 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1099
Chet Lanctot186b5732013-03-18 10:26:30 -07001100#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001101 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001102#endif
1103
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 // That done, pack the struct:
1105 if ( ! pAddTS->wmeTspecPresent )
1106 {
1107 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1108 pFrame + sizeof(tSirMacMgmtHdr),
1109 nPayload, &nPayload );
1110 if ( DOT11F_FAILED( nStatus ) )
1111 {
1112 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001113 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 nStatus );
1115 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1116 return; // allocated!
1117 }
1118 else if ( DOT11F_WARNED( nStatus ) )
1119 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001120 limLog( pMac, LOGW, FL("There were warnings while packing "
1121 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 }
1123 }
1124 else
1125 {
1126 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1127 pFrame + sizeof(tSirMacMgmtHdr),
1128 nPayload, &nPayload );
1129 if ( DOT11F_FAILED( nStatus ) )
1130 {
1131 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001132 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 nStatus );
1134 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1135 return; // allocated!
1136 }
1137 else if ( DOT11F_WARNED( nStatus ) )
1138 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001139 limLog( pMac, LOGW, FL("There were warnings while packing "
1140 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001141 }
1142 }
1143
1144 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1145 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1146
1147 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1149 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001150 )
1151 {
1152 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1153 }
1154
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301155 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1156 psessionEntry->peSessionId,
1157 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001158 // Queue Addts Response frame in high priority WQ
1159 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1160 HAL_TXRX_FRM_802_11_MGMT,
1161 ANI_TXDIR_TODS,
1162 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1163 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301164 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1165 psessionEntry->peSessionId,
1166 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001167 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1168 {
1169 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001170 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001171 //Pkt will be freed up by the callback
1172 }
1173
1174} // End limSendAddtsReqActionFrame.
1175
Jeff Johnson295189b2012-06-20 16:38:30 -07001176
1177
1178void
1179limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1180 tANI_U16 statusCode,
1181 tANI_U16 aid,
1182 tSirMacAddr peerMacAddr,
1183 tANI_U8 subType,
1184 tpDphHashNode pSta,tpPESession psessionEntry)
1185{
1186 static tDot11fAssocResponse frm;
1187 tANI_U8 *pFrame, *macAddr;
1188 tpSirMacMgmtHdr pMacHdr;
1189 tSirRetStatus nSirStatus;
1190 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1191 tHalBitVal qosMode, wmeMode;
1192 tANI_U32 nPayload, nBytes, nStatus;
1193 void *pPacket;
1194 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301195 tUpdateBeaconParams beaconParams;
1196 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 tANI_U32 addnIEPresent = false;
1198 tANI_U32 addnIELen=0;
1199 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1200 tpSirAssocReq pAssocReq = NULL;
1201
1202 if(NULL == psessionEntry)
1203 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301204 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001205 return;
1206 }
1207
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301208 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001209
1210 limGetQosMode(psessionEntry, &qosMode);
1211 limGetWmeMode(psessionEntry, &wmeMode);
1212
1213 // An Add TS IE is added only if the AP supports it and the requesting
1214 // STA sent a traffic spec.
1215 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1216
1217 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1218
1219 frm.Status.status = statusCode;
1220
1221 frm.AID.associd = aid | LIM_AID_MASK;
1222
1223 if ( NULL == pSta )
1224 {
1225 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1226 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1227 }
1228 else
1229 {
1230 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1231 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1232 }
1233
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1235 {
1236 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1237 {
1238 pAssocReq =
1239 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1241 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1242 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001244 }
1245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001246
1247 if ( NULL != pSta )
1248 {
1249 if ( eHAL_SET == qosMode )
1250 {
1251 if ( pSta->lleEnabled )
1252 {
1253 lleMode = 1;
1254 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1255 {
1256 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1257
1258// FramesToDo:...
1259// if ( fAddTS )
1260// {
1261// tANI_U8 *pAf = pBody;
1262// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1263// tANI_U32 tlen;
1264// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1265// &tlen, bufLen - frameLen);
1266// } // End if on Add TS.
1267 }
1268 } // End if on .11e enabled in 'pSta'.
1269 } // End if on QOS Mode on.
1270
1271 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1272 {
1273 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1274 {
1275
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001277
1278 if ( pSta->wsmEnabled )
1279 {
1280 PopulateDot11fWMMCaps(&frm.WMMCaps );
1281 }
1282 }
1283 }
1284
1285 if ( pSta->aniPeer )
1286 {
1287 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1288 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1289 {
1290 edcaInclude = 1;
1291 }
1292
1293 } // End if on Airgo peer.
1294
1295 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001296 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001298 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001301
1302#ifdef WLAN_FEATURE_11AC
1303 if( pSta->mlmStaContext.vhtCapability &&
1304 psessionEntry->vhtCapability )
1305 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001306 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001307 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1308 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Sandeep Puligilla60342762014-01-30 21:05:37 +05301309 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001310 }
1311#endif
1312
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 } // End if on non-NULL 'pSta'.
1314
1315
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301316 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001317
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1319 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1320 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001322
1323 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1324 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1325
1326 beaconParams.bssIdx = psessionEntry->bssIdx;
1327
1328 //Send message to HAL about beacon parameter change.
1329 if(beaconParams.paramChangeBitmap)
1330 {
1331 schSetFixedBeaconFields(pMac,psessionEntry);
1332 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1333 }
1334
1335 // Allocate a buffer for this frame:
1336 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1337 if ( DOT11F_FAILED( nStatus ) )
1338 {
1339 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001340 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 nStatus );
1342 return;
1343 }
1344 else if ( DOT11F_WARNED( nStatus ) )
1345 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001346 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001348 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 }
1350
1351 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1352
1353 if ( pAssocReq != NULL )
1354 {
1355 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1356 &addnIEPresent) != eSIR_SUCCESS)
1357 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301358 limLog(pMac, LOGP, FL("Unable to get "
1359 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 return;
1361 }
1362
1363 if (addnIEPresent)
1364 {
1365 //Assoc rsp IE available
1366 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1367 &addnIELen) != eSIR_SUCCESS)
1368 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301369 limLog(pMac, LOGP, FL("Unable to get "
1370 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 return;
1372 }
1373
1374 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1375 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1376 {
1377 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1378 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1379 {
1380 nBytes = nBytes + addnIELen;
1381 }
1382 }
1383 }
1384 }
1385
1386 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1387 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1388 ( void** ) &pPacket );
1389 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1390 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001391 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 return;
1393 }
1394
1395 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301396 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001397
1398 // Next, we fill out the buffer descriptor:
1399 nSirStatus = limPopulateMacHeader( pMac,
1400 pFrame,
1401 SIR_MAC_MGMT_FRAME,
1402 ( LIM_ASSOC == subType ) ?
1403 SIR_MAC_MGMT_ASSOC_RSP :
1404 SIR_MAC_MGMT_REASSOC_RSP,
1405 peerMacAddr,psessionEntry->selfMacAddr);
1406 if ( eSIR_SUCCESS != nSirStatus )
1407 {
1408 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001409 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 nSirStatus );
1411 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1412 ( void* ) pFrame, ( void* ) pPacket );
1413 return;
1414 }
1415
1416 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1417
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1419
1420 nStatus = dot11fPackAssocResponse( pMac, &frm,
1421 pFrame + sizeof( tSirMacMgmtHdr ),
1422 nPayload, &nPayload );
1423 if ( DOT11F_FAILED( nStatus ) )
1424 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301425 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1426 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1428 ( void* ) pFrame, ( void* ) pPacket );
1429 return; // allocated!
1430 }
1431 else if ( DOT11F_WARNED( nStatus ) )
1432 {
1433 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001434 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 }
1436
1437 macAddr = pMacHdr->da;
1438
1439 if (subType == LIM_ASSOC)
1440 {
1441 PELOG1(limLog(pMac, LOG1,
1442 FL("*** Sending Assoc Resp status %d aid %d to "),
1443 statusCode, aid);)
1444 }
1445 else{
1446 PELOG1(limLog(pMac, LOG1,
1447 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1448 statusCode, aid);)
1449 }
1450 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1451
1452 if ( addnIEPresent )
1453 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301454 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 }
1456
1457 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1459 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 )
1461 {
1462 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1463 }
1464
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301465 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1466 psessionEntry->peSessionId,
1467 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 /// Queue Association Response frame in high priority WQ
1469 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1470 HAL_TXRX_FRM_802_11_MGMT,
1471 ANI_TXDIR_TODS,
1472 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1473 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301474 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1475 psessionEntry->peSessionId,
1476 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1478 {
1479 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001480 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 nSirStatus);
1482
1483 //Pkt will be freed up by the callback
1484 }
1485
1486 // update the ANI peer station count
1487 //FIXME_PROTECTION : take care of different type of station
1488 // counter inside this function.
1489 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1490
1491} // End limSendAssocRspMgmtFrame.
1492
1493
1494
1495void
1496limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1497 tSirMacAddr peer,
1498 tANI_U16 nStatusCode,
1499 tSirAddtsReqInfo *pAddTS,
1500 tSirMacScheduleIE *pSchedule,
1501 tpPESession psessionEntry)
1502{
1503 tANI_U8 *pFrame;
1504 tpSirMacMgmtHdr pMacHdr;
1505 tDot11fAddTSResponse AddTSRsp;
1506 tDot11fWMMAddTSResponse WMMAddTSRsp;
1507 tSirRetStatus nSirStatus;
1508 tANI_U32 i, nBytes, nPayload, nStatus;
1509 void *pPacket;
1510 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301511 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001512
1513 if(NULL == psessionEntry)
1514 {
1515 return;
1516 }
1517
1518 if ( ! pAddTS->wmeTspecPresent )
1519 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301520 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001521
1522 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1523 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1524 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1525 AddTSRsp.Status.status = nStatusCode;
1526
1527 // The TsDelay information element is only filled in for a specific
1528 // status code:
1529 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1530 {
1531 if ( pAddTS->wsmTspecPresent )
1532 {
1533 AddTSRsp.WMMTSDelay.version = 1;
1534 AddTSRsp.WMMTSDelay.delay = 10;
1535 AddTSRsp.WMMTSDelay.present = 1;
1536 }
1537 else
1538 {
1539 AddTSRsp.TSDelay.delay = 10;
1540 AddTSRsp.TSDelay.present = 1;
1541 }
1542 }
1543
1544 if ( pAddTS->wsmTspecPresent )
1545 {
1546 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1547 }
1548 else
1549 {
1550 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1551 }
1552
1553 if ( pAddTS->wsmTspecPresent )
1554 {
1555 AddTSRsp.num_WMMTCLAS = 0;
1556 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1557 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1558 {
1559 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1560 &AddTSRsp.TCLAS[i] );
1561 }
1562 }
1563 else
1564 {
1565 AddTSRsp.num_TCLAS = 0;
1566 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1567 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1568 {
1569 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1570 &AddTSRsp.WMMTCLAS[i] );
1571 }
1572 }
1573
1574 if ( pAddTS->tclasProcPresent )
1575 {
1576 if ( pAddTS->wsmTspecPresent )
1577 {
1578 AddTSRsp.WMMTCLASPROC.version = 1;
1579 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1580 AddTSRsp.WMMTCLASPROC.present = 1;
1581 }
1582 else
1583 {
1584 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1585 AddTSRsp.TCLASSPROC.present = 1;
1586 }
1587 }
1588
1589 // schedule element is included only if requested in the tspec and we are
1590 // using hcca (or both edca and hcca)
1591 // 11e-D8.0 is inconsistent on whether the schedule element is included
1592 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1593 // pg 46, line 17-18 says something else. So just include it and let the
1594 // sta figure it out
1595 if ((pSchedule != NULL) &&
1596 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1597 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1598 {
1599 if ( pAddTS->wsmTspecPresent )
1600 {
1601 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1602 }
1603 else
1604 {
1605 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1606 }
1607 }
1608
1609 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1610 if ( DOT11F_FAILED( nStatus ) )
1611 {
1612 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001613 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 nStatus );
1615 // We'll fall back on the worst case scenario:
1616 nPayload = sizeof( tDot11fAddTSResponse );
1617 }
1618 else if ( DOT11F_WARNED( nStatus ) )
1619 {
1620 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001621 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001622 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 }
1624 }
1625 else
1626 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301627 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001628
1629 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1630 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1631 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1632 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1633
1634 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1635
1636 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1637 if ( DOT11F_FAILED( nStatus ) )
1638 {
1639 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001640 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 nStatus );
1642 // We'll fall back on the worst case scenario:
1643 nPayload = sizeof( tDot11fWMMAddTSResponse );
1644 }
1645 else if ( DOT11F_WARNED( nStatus ) )
1646 {
1647 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001648 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001649 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 }
1651 }
1652
1653 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1654
1655 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1656 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1657 {
1658 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001659 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 return;
1661 }
1662
1663 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301664 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001665
1666 // Next, we fill out the buffer descriptor:
1667 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1668 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1669 if ( eSIR_SUCCESS != nSirStatus )
1670 {
1671 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001672 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 nSirStatus );
1674 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1675 return; // allocated!
1676 }
1677
1678 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1679
1680
1681 #if 0
1682 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1683 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1684 {
1685 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001686 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1688 return; // allocated!
1689 }
1690 #endif //TO SUPPORT BT-AMP
1691 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1692
Chet Lanctot186b5732013-03-18 10:26:30 -07001693#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001694 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001695#endif
1696
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 // That done, pack the struct:
1698 if ( ! pAddTS->wmeTspecPresent )
1699 {
1700 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1701 pFrame + sizeof( tSirMacMgmtHdr ),
1702 nPayload, &nPayload );
1703 if ( DOT11F_FAILED( nStatus ) )
1704 {
1705 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001706 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 nStatus );
1708 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1709 return;
1710 }
1711 else if ( DOT11F_WARNED( nStatus ) )
1712 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001713 limLog( pMac, LOGW, FL("There were warnings while packing "
1714 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 }
1716 }
1717 else
1718 {
1719 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1720 pFrame + sizeof( tSirMacMgmtHdr ),
1721 nPayload, &nPayload );
1722 if ( DOT11F_FAILED( nStatus ) )
1723 {
1724 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001725 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 nStatus );
1727 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1728 return;
1729 }
1730 else if ( DOT11F_WARNED( nStatus ) )
1731 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001732 limLog( pMac, LOGW, FL("There were warnings while packing "
1733 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 }
1735 }
1736
1737 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1738 nStatusCode );
1739 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1740
1741 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1743 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 )
1745 {
1746 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1747 }
1748
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301749 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1750 psessionEntry->peSessionId,
1751 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 // Queue the frame in high priority WQ:
1753 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1754 HAL_TXRX_FRM_802_11_MGMT,
1755 ANI_TXDIR_TODS,
1756 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1757 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301758 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1759 psessionEntry->peSessionId,
1760 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1762 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001763 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 nSirStatus );
1765 //Pkt will be freed up by the callback
1766 }
1767
1768} // End limSendAddtsRspActionFrame.
1769
1770void
1771limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1772 tSirMacAddr peer,
1773 tANI_U8 wmmTspecPresent,
1774 tSirMacTSInfo *pTsinfo,
1775 tSirMacTspecIE *pTspecIe,
1776 tpPESession psessionEntry)
1777{
1778 tANI_U8 *pFrame;
1779 tpSirMacMgmtHdr pMacHdr;
1780 tDot11fDelTS DelTS;
1781 tDot11fWMMDelTS WMMDelTS;
1782 tSirRetStatus nSirStatus;
1783 tANI_U32 nBytes, nPayload, nStatus;
1784 void *pPacket;
1785 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301786 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001787
1788 if(NULL == psessionEntry)
1789 {
1790 return;
1791 }
1792
1793 if ( ! wmmTspecPresent )
1794 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301795 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001796
1797 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1798 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1799 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1800
1801 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1802 if ( DOT11F_FAILED( nStatus ) )
1803 {
1804 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001805 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 nStatus );
1807 // We'll fall back on the worst case scenario:
1808 nPayload = sizeof( tDot11fDelTS );
1809 }
1810 else if ( DOT11F_WARNED( nStatus ) )
1811 {
1812 limLog( pMac, LOGW, FL("There were warnings while calcula"
1813 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001814 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 }
1816 }
1817 else
1818 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301819 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001820
1821 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1822 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1823 WMMDelTS.DialogToken.token = 0;
1824 WMMDelTS.StatusCode.statusCode = 0;
1825 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1826 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1827 if ( DOT11F_FAILED( nStatus ) )
1828 {
1829 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001830 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 nStatus );
1832 // We'll fall back on the worst case scenario:
1833 nPayload = sizeof( tDot11fDelTS );
1834 }
1835 else if ( DOT11F_WARNED( nStatus ) )
1836 {
1837 limLog( pMac, LOGW, FL("There were warnings while calcula"
1838 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001839 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 }
1841 }
1842
1843 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1844
1845 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1846 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1847 {
1848 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001849 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 return;
1851 }
1852
1853 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301854 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001855
1856 // Next, we fill out the buffer descriptor:
1857 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1858 SIR_MAC_MGMT_ACTION, peer,
1859 psessionEntry->selfMacAddr);
1860 if ( eSIR_SUCCESS != nSirStatus )
1861 {
1862 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001863 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 nSirStatus );
1865 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1866 return; // allocated!
1867 }
1868
1869 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1870
1871 #if 0
1872
1873 cfgLen = SIR_MAC_ADDR_LENGTH;
1874 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1875 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1876 {
1877 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001878 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1880 return; // allocated!
1881 }
1882 #endif //TO SUPPORT BT-AMP
1883 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1884
Chet Lanctot186b5732013-03-18 10:26:30 -07001885#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001886 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001887#endif
1888
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 // That done, pack the struct:
1890 if ( !wmmTspecPresent )
1891 {
1892 nStatus = dot11fPackDelTS( pMac, &DelTS,
1893 pFrame + sizeof( tSirMacMgmtHdr ),
1894 nPayload, &nPayload );
1895 if ( DOT11F_FAILED( nStatus ) )
1896 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001897 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 nStatus );
1899 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1900 return; // allocated!
1901 }
1902 else if ( DOT11F_WARNED( nStatus ) )
1903 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001904 limLog( pMac, LOGW, FL("There were warnings while packing "
1905 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 }
1907 }
1908 else
1909 {
1910 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1911 pFrame + sizeof( tSirMacMgmtHdr ),
1912 nPayload, &nPayload );
1913 if ( DOT11F_FAILED( nStatus ) )
1914 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001915 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 nStatus );
1917 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1918 return; // allocated!
1919 }
1920 else if ( DOT11F_WARNED( nStatus ) )
1921 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001922 limLog( pMac, LOGW, FL("There were warnings while packing "
1923 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 }
1925 }
1926
1927 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1928 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1929
1930 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1932 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 )
1934 {
1935 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1936 }
1937
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301938 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1939 psessionEntry->peSessionId,
1940 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001941 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1942 HAL_TXRX_FRM_802_11_MGMT,
1943 ANI_TXDIR_TODS,
1944 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1945 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301946 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1947 psessionEntry->peSessionId,
1948 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 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
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301978 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301979 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001980
1981 if(NULL == psessionEntry)
1982 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301983 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 return;
1985 }
1986
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 /* check this early to avoid unncessary operation */
1988 if(NULL == psessionEntry->pLimJoinReq)
1989 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301990 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 return;
1992 }
1993 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
1994 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
1995
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301996 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
1997 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001998 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301999 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002000 return;
2001 }
2002
2003
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302004 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002005
2006 caps = pMlmAssocReq->capabilityInfo;
2007 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2008 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2009#if defined(FEATURE_WLAN_WAPI)
2010 /* CR: 262463 :
2011 According to WAPI standard:
2012 7.3.1.4 Capability Information field
2013 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2014 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2015 Reassociation management frames. */
2016 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2017 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2018#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002019 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002020
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002021 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2022 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002024 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002025
2026 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2027 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2028
2029 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2030 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2031
2032 // We prefer .11e asociations:
2033 if ( fQosEnabled ) fWmeEnabled = false;
2034
2035 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2036 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2037
2038 if ( psessionEntry->lim11hEnable &&
2039 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2040 {
2041#if defined WLAN_FEATURE_VOWIFI
2042 PowerCapsPopulated = TRUE;
2043
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002044 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002045#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002046 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002047
2048 }
2049
2050#if defined WLAN_FEATURE_VOWIFI
2051 if( pMac->rrm.rrmPEContext.rrmEnable &&
2052 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2053 {
2054 if (PowerCapsPopulated == FALSE)
2055 {
2056 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002057 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 }
2059 }
2060#endif
2061
2062 if ( fQosEnabled &&
2063 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002064 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002065
2066 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002067 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002068
2069#if defined WLAN_FEATURE_VOWIFI
2070 if( pMac->rrm.rrmPEContext.rrmEnable &&
2071 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2072 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002073 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 }
2075#endif
2076 // The join request *should* contain zero or one of the WPA and RSN
2077 // IEs. The payload send along with the request is a
2078 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2079
2080 // typedef struct sSirRSNie
2081 // {
2082 // tANI_U16 length;
2083 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2084 // } tSirRSNie, *tpSirRSNie;
2085
2086 // So, we should be able to make the following two calls harmlessly,
2087 // since they do nothing if they don't find the given IE in the
2088 // bytestream with which they're provided.
2089
2090 // The net effect of this will be to faithfully transmit whatever
2091 // security IE is in the join request.
2092
2093 // *However*, if we're associating for the purpose of WPS
2094 // enrollment, and we've been configured to indicate that by
2095 // eliding the WPA or RSN IE, we just skip this:
2096 if( nAddIELen && pAddIE )
2097 {
2098 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2099 }
2100 if ( NULL == wpsIe )
2101 {
2102 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002103 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002105 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002106#if defined(FEATURE_WLAN_WAPI)
2107 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002108 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002109#endif // defined(FEATURE_WLAN_WAPI)
2110 }
2111
2112 // include WME EDCA IE as well
2113 if ( fWmeEnabled )
2114 {
2115 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2116 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002117 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 }
2119
2120 if ( fWsmEnabled &&
2121 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2122 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002123 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 }
2125 }
2126
2127 //Populate HT IEs, when operating in 11n or Taurus modes AND
2128 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002129 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 pMac->lim.htCapabilityPresentInBeacon)
2131 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002132 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002133#ifdef DISABLE_GF_FOR_INTEROP
2134
2135 /*
2136 * To resolve the interop problem with Broadcom AP,
2137 * where TQ STA could not pass traffic with GF enabled,
2138 * TQ STA will do Greenfield only with TQ AP, for
2139 * everybody else it will be turned off.
2140 */
2141
2142 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2143 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302144 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2145 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002146 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 }
2148#endif
2149
2150 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002151#ifdef WLAN_FEATURE_11AC
2152 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002153 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002154 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002155 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002156 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
Jeff Johnsone7245742012-09-05 17:12:55 -07002157 }
2158#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302159 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002160
2161#if defined WLAN_FEATURE_VOWIFI_11R
2162 if (psessionEntry->pLimJoinReq->is11Rconnection)
2163 {
2164#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002165 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2167 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2168 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2169#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302170 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2171 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302173 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 {
2175 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302176 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 }
2178#endif
2179
2180#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302181 /* For CCX Associations fill the CCX IEs */
2182 if (psessionEntry->isCCXconnection &&
2183 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002185#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002186 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002187#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302188 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 }
2190#endif
2191
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002192 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 if ( DOT11F_FAILED( nStatus ) )
2194 {
2195 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002196 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 nStatus );
2198 // We'll fall back on the worst case scenario:
2199 nPayload = sizeof( tDot11fAssocRequest );
2200 }
2201 else if ( DOT11F_WARNED( nStatus ) )
2202 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002203 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002205 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 }
2207
2208 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2209
2210 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2211 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2212 ( void** ) &pPacket );
2213 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2214 {
2215 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002216 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002217
2218 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002219 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002220
2221
2222 /* Update PE session id*/
2223 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2224
2225 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2226
2227 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2228 ( void* ) pFrame, ( void* ) pPacket );
2229
2230 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2231 ( tANI_U32* ) &mlmAssocCnf);
2232
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302233 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 return;
2235 }
2236
2237 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302238 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002239
2240 // Next, we fill out the buffer descriptor:
2241 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2242 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2243 if ( eSIR_SUCCESS != nSirStatus )
2244 {
2245 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002246 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 nSirStatus );
2248 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302249 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 return;
2251 }
2252
2253
Abhishek Singh57aebef2014-02-03 18:47:44 +05302254 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002255 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 sizeof(tSirMacMgmtHdr),
2257 nPayload, &nPayload );
2258 if ( DOT11F_FAILED( nStatus ) )
2259 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302260 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002261 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 nStatus );
2263 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2264 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302265 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 return;
2267 }
2268 else if ( DOT11F_WARNED( nStatus ) )
2269 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302270 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2271 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 }
2273
2274 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002275 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 nBytes );)
2277 // limPrintMacAddr( pMac, bssid, LOG1 );
2278
2279 if( psessionEntry->assocReq != NULL )
2280 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302281 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 psessionEntry->assocReq = NULL;
2283 }
2284
2285 if( nAddIELen )
2286 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302287 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2288 pAddIE,
2289 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 nPayload += nAddIELen;
2291 }
2292
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302293 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2294 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302296 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2297 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 }
2299 else
2300 {
2301 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302302 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 psessionEntry->assocReqLen = nPayload;
2304 }
2305
2306 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2308 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 )
2310 {
2311 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2312 }
2313
Ganesh K08bce952012-12-13 15:04:41 -08002314 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2315 {
2316 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2317 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302318
2319 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2320 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2321 psessionEntry->peSessionId,
2322 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2324 HAL_TXRX_FRM_802_11_MGMT,
2325 ANI_TXDIR_TODS,
2326 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2327 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302328 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2329 psessionEntry->peSessionId,
2330 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2332 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002333 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 halstatus );
2335 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302336 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 return;
2338 }
2339
2340 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302341 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002342 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302343 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002344 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002345} // End limSendAssocReqMgmtFrame
2346
2347
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002348#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002349/*------------------------------------------------------------------------------------
2350 *
2351 * Send Reassoc Req with FTIEs.
2352 *
2353 *-----------------------------------------------------------------------------------
2354 */
2355void
2356limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2357 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2358{
2359 static tDot11fReAssocRequest frm;
2360 tANI_U16 caps;
2361 tANI_U8 *pFrame;
2362 tSirRetStatus nSirStatus;
2363 tANI_U32 nBytes, nPayload, nStatus;
2364 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2365 void *pPacket;
2366 eHalStatus halstatus;
2367#if defined WLAN_FEATURE_VOWIFI
2368 tANI_U8 PowerCapsPopulated = FALSE;
2369#endif
2370 tANI_U16 ft_ies_length = 0;
2371 tANI_U8 *pBody;
2372 tANI_U16 nAddIELen;
2373 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002374#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 tANI_U8 *wpsIe = NULL;
2376#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302377 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302378 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002379
2380 if (NULL == psessionEntry)
2381 {
2382 return;
2383 }
2384
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 /* check this early to avoid unncessary operation */
2386 if(NULL == psessionEntry->pLimReAssocReq)
2387 {
2388 return;
2389 }
2390 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2391 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002392 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2393 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002394
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302395 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002396
2397 caps = pMlmReassocReq->capabilityInfo;
2398 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2399 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2400#if defined(FEATURE_WLAN_WAPI)
2401 /* CR: 262463 :
2402 According to WAPI standard:
2403 7.3.1.4 Capability Information field
2404 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2405 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2406 Reassociation management frames. */
2407 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2408 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2409#endif
2410 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2411
2412 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2413
2414 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302415 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002416 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2417
2418 PopulateDot11fSSID2( pMac, &frm.SSID );
2419 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2420 &frm.SuppRates,psessionEntry);
2421
2422 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2423 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2424
2425 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2426 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2427
2428 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2429 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2430
2431 if ( psessionEntry->lim11hEnable &&
2432 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2433 {
2434#if defined WLAN_FEATURE_VOWIFI
2435 PowerCapsPopulated = TRUE;
2436
2437 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2438 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2439#endif
2440 }
2441
2442#if defined WLAN_FEATURE_VOWIFI
2443 if( pMac->rrm.rrmPEContext.rrmEnable &&
2444 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2445 {
2446 if (PowerCapsPopulated == FALSE)
2447 {
2448 PowerCapsPopulated = TRUE;
2449 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2450 }
2451 }
2452#endif
2453
2454 if ( fQosEnabled &&
2455 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2456 {
2457 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2458 }
2459
2460 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2461 &frm.ExtSuppRates, psessionEntry );
2462
2463#if defined WLAN_FEATURE_VOWIFI
2464 if( pMac->rrm.rrmPEContext.rrmEnable &&
2465 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2466 {
2467 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2468 }
2469#endif
2470
2471 // Ideally this should be enabled for 11r also. But 11r does
2472 // not follow the usual norm of using the Opaque object
2473 // for rsnie and fties. Instead we just add
2474 // the rsnie and fties at the end of the pack routine for 11r.
2475 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002476#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 //
2478 // The join request *should* contain zero or one of the WPA and RSN
2479 // IEs. The payload send along with the request is a
2480 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2481
2482 // typedef struct sSirRSNie
2483 // {
2484 // tANI_U16 length;
2485 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2486 // } tSirRSNie, *tpSirRSNie;
2487
2488 // So, we should be able to make the following two calls harmlessly,
2489 // since they do nothing if they don't find the given IE in the
2490 // bytestream with which they're provided.
2491
2492 // The net effect of this will be to faithfully transmit whatever
2493 // security IE is in the join request.
2494
2495 // *However*, if we're associating for the purpose of WPS
2496 // enrollment, and we've been configured to indicate that by
2497 // eliding the WPA or RSN IE, we just skip this:
2498 if (!psessionEntry->is11Rconnection)
2499 {
2500 if( nAddIELen && pAddIE )
2501 {
2502 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2503 }
2504 if ( NULL == wpsIe )
2505 {
2506 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2507 &frm.RSNOpaque );
2508 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2509 &frm.WPAOpaque );
2510 }
2511
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002512#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302513 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 {
2515 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2516 &frm.CCXCckmOpaque );
2517 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002518#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 }
2520
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002521#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302523 if (psessionEntry->isCCXconnection &&
2524 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002526#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002527 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002528#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302529 PopulateDot11fCCXVersion(&frm.CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302531#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002532#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002533
2534 // include WME EDCA IE as well
2535 if ( fWmeEnabled )
2536 {
2537 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2538 {
2539 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2540 }
2541
2542 if ( fWsmEnabled &&
2543 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2544 {
2545 PopulateDot11fWMMCaps( &frm.WMMCaps );
2546 }
2547#ifdef FEATURE_WLAN_CCX
2548 if (psessionEntry->isCCXconnection)
2549 {
2550 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2551
2552 // Populate the TSRS IE if TSPEC is included in the reassoc request
2553 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2554 {
2555 tANI_U32 phyMode;
2556 tSirMacCCXTSRSIE tsrsIE;
2557 limGetPhyMode(pMac, &phyMode, psessionEntry);
2558
2559 tsrsIE.tsid = 0;
2560 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2561 {
2562 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2563 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302564 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 {
2566 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2567 }
2568 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2569 }
2570 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302571#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002572 }
2573
Jeff Johnsone7245742012-09-05 17:12:55 -07002574 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 pMac->lim.htCapabilityPresentInBeacon)
2576 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002577 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 }
2579
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002580#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302581 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2582#if defined FEATURE_WLAN_CCX
2583 && !psessionEntry->isCCXconnection
2584#endif
2585 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002586 {
2587 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2588 }
2589#endif
2590
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002591#ifdef WLAN_FEATURE_11AC
2592 if ( psessionEntry->vhtCapability &&
2593 psessionEntry->vhtCapabilityPresentInBeacon)
2594 {
2595 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2596 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002597 }
2598#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302599 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002600
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2602 if ( DOT11F_FAILED( nStatus ) )
2603 {
2604 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002605 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 nStatus );
2607 // We'll fall back on the worst case scenario:
2608 nPayload = sizeof( tDot11fReAssocRequest );
2609 }
2610 else if ( DOT11F_WARNED( nStatus ) )
2611 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002612 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002614 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 }
2616
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002617 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002618
2619#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002620 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2622#endif
2623
2624#if defined WLAN_FEATURE_VOWIFI_11R
2625 if (psessionEntry->is11Rconnection)
2626 {
2627 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2628 }
2629#endif
2630
2631 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2632 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2633 ( void** ) &pPacket );
2634 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2635 {
2636 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002637 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002638 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002639 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 goto end;
2641 }
2642
2643 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302644 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002645
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002646#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002647 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002648#endif
2649 // Next, we fill out the buffer descriptor:
2650 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2651 SIR_MAC_MGMT_REASSOC_REQ,
2652 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2653 if ( eSIR_SUCCESS != nSirStatus )
2654 {
2655 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002656 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 nSirStatus );
2658 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2659 goto end;
2660 }
2661
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302662 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 // That done, pack the ReAssoc Request:
2664 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2665 sizeof(tSirMacMgmtHdr),
2666 nPayload, &nPayload );
2667 if ( DOT11F_FAILED( nStatus ) )
2668 {
2669 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002670 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 nStatus );
2672 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2673 goto end;
2674 }
2675 else if ( DOT11F_WARNED( nStatus ) )
2676 {
2677 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002678 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 }
2680
2681 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002682 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 nBytes, nPayload );)
2684 if( psessionEntry->assocReq != NULL )
2685 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302686 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 psessionEntry->assocReq = NULL;
2688 }
2689
2690 if( nAddIELen )
2691 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302692 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2693 pAddIE,
2694 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 nPayload += nAddIELen;
2696 }
2697
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302698 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2699 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 {
2701 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002702 }
2703 else
2704 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302706 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002709
2710 if (psessionEntry->is11Rconnection)
2711 {
2712 {
2713 int i = 0;
2714
2715 pBody = pFrame + nBytes;
2716 for (i=0; i<ft_ies_length; i++)
2717 {
2718 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2719 pBody++;
2720 }
2721 }
2722 }
2723
2724#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002725 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2726 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 (tANI_U8 *)pFrame,
2728 (nBytes + ft_ies_length));)
2729#endif
2730
2731
2732 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2734 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 )
2736 {
2737 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2738 }
2739
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002740 if( NULL != psessionEntry->assocReq )
2741 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302742 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002743 psessionEntry->assocReq = NULL;
2744 }
2745
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302746 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2747 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002748 {
2749 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002750 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002751 }
2752 else
2753 {
2754 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302755 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2756 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002757 psessionEntry->assocReqLen = (ft_ies_length);
2758 }
2759
2760
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302761 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2762 psessionEntry->peSessionId,
2763 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2765 HAL_TXRX_FRM_802_11_MGMT,
2766 ANI_TXDIR_TODS,
2767 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2768 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302769 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2770 psessionEntry->peSessionId,
2771 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2773 {
2774 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002775 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 nSirStatus );
2777 //Pkt will be freed up by the callback
2778 goto end;
2779 }
2780
2781end:
2782 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302783 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 psessionEntry->pLimMlmReassocReq = NULL;
2785
2786}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002787
2788void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2789 tLimMlmReassocReq *pMlmReassocReq,
2790 tpPESession psessionEntry)
2791{
2792 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2793 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2794 if(NULL == pTmpMlmReassocReq)
2795 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302796 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2797 if ( NULL == pTmpMlmReassocReq ) goto end;
2798 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2799 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002800 }
2801
2802 // Prepare and send Reassociation request frame
2803 // start reassoc timer.
2804 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2805 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002806 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002807 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2808 != TX_SUCCESS)
2809 {
2810 // Could not start reassoc failure timer.
2811 // Log error
2812 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002813 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002814 // Return Reassoc confirm with
2815 // Resources Unavailable
2816 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2817 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2818 goto end;
2819 }
2820
2821 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2822 return;
2823
2824end:
2825 // Free up buffer allocated for reassocReq
2826 if (pMlmReassocReq != NULL)
2827 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302828 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002829 pMlmReassocReq = NULL;
2830 }
2831 if (pTmpMlmReassocReq != NULL)
2832 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302833 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002834 pTmpMlmReassocReq = NULL;
2835 }
2836 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2837 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2838 /* Update PE sessio Id*/
2839 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2840
2841 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2842}
2843
Jeff Johnson295189b2012-06-20 16:38:30 -07002844#endif /* WLAN_FEATURE_VOWIFI_11R */
2845
2846
2847void
2848limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2849 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2850{
2851 static tDot11fReAssocRequest frm;
2852 tANI_U16 caps;
2853 tANI_U8 *pFrame;
2854 tSirRetStatus nSirStatus;
2855 tANI_U32 nBytes, nPayload, nStatus;
2856 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2857 void *pPacket;
2858 eHalStatus halstatus;
2859 tANI_U16 nAddIELen;
2860 tANI_U8 *pAddIE;
2861 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302862 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002863#if defined WLAN_FEATURE_VOWIFI
2864 tANI_U8 PowerCapsPopulated = FALSE;
2865#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302866 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002867
2868 if(NULL == psessionEntry)
2869 {
2870 return;
2871 }
2872
2873 /* check this early to avoid unncessary operation */
2874 if(NULL == psessionEntry->pLimReAssocReq)
2875 {
2876 return;
2877 }
2878 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2879 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2880
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302881 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002882
2883 caps = pMlmReassocReq->capabilityInfo;
2884 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2885 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2886#if defined(FEATURE_WLAN_WAPI)
2887 /* CR: 262463 :
2888 According to WAPI standard:
2889 7.3.1.4 Capability Information field
2890 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2891 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2892 Reassociation management frames. */
2893 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2894 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2895#endif
2896 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2897
2898 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2899
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302900 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2901 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002902
2903 PopulateDot11fSSID2( pMac, &frm.SSID );
2904 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2905 &frm.SuppRates,psessionEntry);
2906
2907 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2908 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2909
2910 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2911 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2912
2913 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2914 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2915
2916
2917 if ( psessionEntry->lim11hEnable &&
2918 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2919 {
2920#if defined WLAN_FEATURE_VOWIFI
2921 PowerCapsPopulated = TRUE;
2922 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2923 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2924#endif
2925 }
2926
2927#if defined WLAN_FEATURE_VOWIFI
2928 if( pMac->rrm.rrmPEContext.rrmEnable &&
2929 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2930 {
2931 if (PowerCapsPopulated == FALSE)
2932 {
2933 PowerCapsPopulated = TRUE;
2934 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2935 }
2936 }
2937#endif
2938
2939 if ( fQosEnabled &&
2940 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2941 {
2942 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2943 }
2944
2945 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2946 &frm.ExtSuppRates, psessionEntry );
2947
2948#if defined WLAN_FEATURE_VOWIFI
2949 if( pMac->rrm.rrmPEContext.rrmEnable &&
2950 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2951 {
2952 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2953 }
2954#endif
2955 // The join request *should* contain zero or one of the WPA and RSN
2956 // IEs. The payload send along with the request is a
2957 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2958
2959 // typedef struct sSirRSNie
2960 // {
2961 // tANI_U16 length;
2962 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2963 // } tSirRSNie, *tpSirRSNie;
2964
2965 // So, we should be able to make the following two calls harmlessly,
2966 // since they do nothing if they don't find the given IE in the
2967 // bytestream with which they're provided.
2968
2969 // The net effect of this will be to faithfully transmit whatever
2970 // security IE is in the join request.
2971
2972 // *However*, if we're associating for the purpose of WPS
2973 // enrollment, and we've been configured to indicate that by
2974 // eliding the WPA or RSN IE, we just skip this:
2975 if( nAddIELen && pAddIE )
2976 {
2977 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2978 }
2979 if ( NULL == wpsIe )
2980 {
2981 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2982 &frm.RSNOpaque );
2983 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2984 &frm.WPAOpaque );
2985#if defined(FEATURE_WLAN_WAPI)
2986 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2987 &frm.WAPIOpaque );
2988#endif // defined(FEATURE_WLAN_WAPI)
2989 }
2990
2991 // include WME EDCA IE as well
2992 if ( fWmeEnabled )
2993 {
2994 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2995 {
2996 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2997 }
2998
2999 if ( fWsmEnabled &&
3000 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3001 {
3002 PopulateDot11fWMMCaps( &frm.WMMCaps );
3003 }
3004 }
3005
Jeff Johnsone7245742012-09-05 17:12:55 -07003006 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 pMac->lim.htCapabilityPresentInBeacon)
3008 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003009 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003011#ifdef WLAN_FEATURE_11AC
3012 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003013 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003014 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003015 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003016 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303017 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003018 }
3019#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003020
3021 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3022 if ( DOT11F_FAILED( nStatus ) )
3023 {
3024 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003025 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 nStatus );
3027 // We'll fall back on the worst case scenario:
3028 nPayload = sizeof( tDot11fReAssocRequest );
3029 }
3030 else if ( DOT11F_WARNED( nStatus ) )
3031 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003032 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003034 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 }
3036
3037 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3038
3039 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3040 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3041 ( void** ) &pPacket );
3042 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3043 {
3044 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003045 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003047 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 goto end;
3049 }
3050
3051 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303052 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003053
3054 // Next, we fill out the buffer descriptor:
3055 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3056 SIR_MAC_MGMT_REASSOC_REQ,
3057 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3058 if ( eSIR_SUCCESS != nSirStatus )
3059 {
3060 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003061 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 nSirStatus );
3063 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3064 goto end;
3065 }
3066
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303067 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 // That done, pack the Probe Request:
3069 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3070 sizeof(tSirMacMgmtHdr),
3071 nPayload, &nPayload );
3072 if ( DOT11F_FAILED( nStatus ) )
3073 {
3074 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003075 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 nStatus );
3077 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3078 goto end;
3079 }
3080 else if ( DOT11F_WARNED( nStatus ) )
3081 {
3082 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003083 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 }
3085
3086 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003087 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 nBytes );)
3089
3090 if( psessionEntry->assocReq != NULL )
3091 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303092 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 psessionEntry->assocReq = NULL;
3094 }
3095
3096 if( nAddIELen )
3097 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303098 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3099 pAddIE,
3100 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 nPayload += nAddIELen;
3102 }
3103
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303104 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3105 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 {
3107 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003108 }
3109 else
3110 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303112 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003115
3116 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3118 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 )
3120 {
3121 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3122 }
3123
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003124 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003125 {
3126 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3127 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003128
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303129 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3130 psessionEntry->peSessionId,
3131 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3133 HAL_TXRX_FRM_802_11_MGMT,
3134 ANI_TXDIR_TODS,
3135 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3136 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303137 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3138 psessionEntry->peSessionId,
3139 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3141 {
3142 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003143 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 nSirStatus );
3145 //Pkt will be freed up by the callback
3146 goto end;
3147 }
3148
3149end:
3150 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303151 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 psessionEntry->pLimMlmReassocReq = NULL;
3153
3154} // limSendReassocReqMgmtFrame
3155
3156/**
3157 * \brief Send an Authentication frame
3158 *
3159 *
3160 * \param pMac Pointer to Global MAC structure
3161 *
3162 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3163 * to be sent
3164 *
3165 * \param peerMacAddr MAC address of the peer entity to which Authentication
3166 * frame is destined
3167 *
3168 * \param wepBit Indicates whether wep bit to be set in FC while sending
3169 * Authentication frame3
3170 *
3171 *
3172 * This function is called by limProcessMlmMessages(). Authentication frame
3173 * is formatted and sent when this function is called.
3174 *
3175 *
3176 */
3177
3178void
3179limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3180 tpSirMacAuthFrameBody pAuthFrameBody,
3181 tSirMacAddr peerMacAddr,
3182 tANI_U8 wepBit,
3183 tpPESession psessionEntry
3184 )
3185{
3186 tANI_U8 *pFrame, *pBody;
3187 tANI_U32 frameLen = 0, bodyLen = 0;
3188 tpSirMacMgmtHdr pMacHdr;
3189 tANI_U16 i;
3190 void *pPacket;
3191 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303192 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003193
3194 if(NULL == psessionEntry)
3195 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303196 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 return;
3198 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303199
3200 limLog(pMac, LOG1,
3201 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3202 pAuthFrameBody->authTransactionSeqNumber,
3203 pAuthFrameBody->authStatusCode,
3204 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3205 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 if (wepBit == LIM_WEP_IN_FC)
3207 {
3208 /// Auth frame3 to be sent with encrypted framebody
3209 /**
3210 * Allocate buffer for Authenticaton frame of size equal
3211 * to management frame header length plus 2 bytes each for
3212 * auth algorithm number, transaction number, status code,
3213 * 128 bytes for challenge text and 4 bytes each for
3214 * IV & ICV.
3215 */
3216
3217 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3218
3219 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3220 } // if (wepBit == LIM_WEP_IN_FC)
3221 else
3222 {
3223 switch (pAuthFrameBody->authTransactionSeqNumber)
3224 {
3225 case SIR_MAC_AUTH_FRAME_1:
3226 /**
3227 * Allocate buffer for Authenticaton frame of size
3228 * equal to management frame header length plus 2 bytes
3229 * each for auth algorithm number, transaction number
3230 * and status code.
3231 */
3232
3233 frameLen = sizeof(tSirMacMgmtHdr) +
3234 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3235 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3236
3237#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003238 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3239 {
3240 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003242 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003243 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003244 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003246 else
3247 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303248 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3249 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003250 frameLen += (2+SIR_MDIE_SIZE);
3251 }
3252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003253#endif
3254 break;
3255
3256 case SIR_MAC_AUTH_FRAME_2:
3257 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3258 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3259 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3260 {
3261 /**
3262 * Allocate buffer for Authenticaton frame of size
3263 * equal to management frame header length plus
3264 * 2 bytes each for auth algorithm number,
3265 * transaction number and status code.
3266 */
3267
3268 frameLen = sizeof(tSirMacMgmtHdr) +
3269 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3270 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3271 }
3272 else
3273 {
3274 // Shared Key algorithm with challenge text
3275 // to be sent
3276 /**
3277 * Allocate buffer for Authenticaton frame of size
3278 * equal to management frame header length plus
3279 * 2 bytes each for auth algorithm number,
3280 * transaction number, status code and 128 bytes
3281 * for challenge text.
3282 */
3283
3284 frameLen = sizeof(tSirMacMgmtHdr) +
3285 sizeof(tSirMacAuthFrame);
3286 bodyLen = sizeof(tSirMacAuthFrameBody);
3287 }
3288
3289 break;
3290
3291 case SIR_MAC_AUTH_FRAME_3:
3292 /// Auth frame3 to be sent without encrypted framebody
3293 /**
3294 * Allocate buffer for Authenticaton frame of size equal
3295 * to management frame header length plus 2 bytes each
3296 * for auth algorithm number, transaction number and
3297 * status code.
3298 */
3299
3300 frameLen = sizeof(tSirMacMgmtHdr) +
3301 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3302 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3303
3304 break;
3305
3306 case SIR_MAC_AUTH_FRAME_4:
3307 /**
3308 * Allocate buffer for Authenticaton frame of size equal
3309 * to management frame header length plus 2 bytes each
3310 * for auth algorithm number, transaction number and
3311 * status code.
3312 */
3313
3314 frameLen = sizeof(tSirMacMgmtHdr) +
3315 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3316 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3317
3318 break;
3319 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3320 } // end if (wepBit == LIM_WEP_IN_FC)
3321
3322
3323 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3324
3325 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3326 {
3327 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003328 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003329
3330 return;
3331 }
3332
3333 for (i = 0; i < frameLen; i++)
3334 pFrame[i] = 0;
3335
3336 // Prepare BD
3337 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3338 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3339 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303340 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3341 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3343 return;
3344 }
3345
3346 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3347 pMacHdr->fc.wep = wepBit;
3348
3349 // Prepare BSSId
3350 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3351 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303352 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3353 (tANI_U8 *) psessionEntry->bssId,
3354 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 }
3356
3357 /// Prepare Authentication frame body
3358 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3359
3360 if (wepBit == LIM_WEP_IN_FC)
3361 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303362 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003363
3364 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303365 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303367 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3368 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003369
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 }
3371 else
3372 {
3373 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3374 pBody += sizeof(tANI_U16);
3375 bodyLen -= sizeof(tANI_U16);
3376
3377 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3378 pBody += sizeof(tANI_U16);
3379 bodyLen -= sizeof(tANI_U16);
3380
3381 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3382 pBody += sizeof(tANI_U16);
3383 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003384 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3385 sizeof (pAuthFrameBody->length) +
3386 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303387 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003388
3389#if defined WLAN_FEATURE_VOWIFI_11R
3390 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3391 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3392 {
3393
3394 {
3395 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3397 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003398#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003399 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3400 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 (tANI_U8 *)pBody,
3402 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003403#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003404 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3405 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003406 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3407 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003408 }
3409 }
3410 else
3411 {
3412 /* MDID attr is 54*/
3413 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003415 *pBody = SIR_MDIE_SIZE;
3416 pBody++;
3417 for(i=0;i<SIR_MDIE_SIZE;i++)
3418 {
3419 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3420 pBody++;
3421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 }
3423 }
3424 }
3425#endif
3426
3427 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303428 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 pAuthFrameBody->authTransactionSeqNumber,
3430 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303431 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3432 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 }
3434 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3435
3436 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3438 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003439#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303440 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003441 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 )
3444 {
3445 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3446 }
3447
Ganesh K08bce952012-12-13 15:04:41 -08003448 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3449 {
3450 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3451 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003452
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303453 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3454 psessionEntry->peSessionId,
3455 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 /// Queue Authentication frame in high priority WQ
3457 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3458 HAL_TXRX_FRM_802_11_MGMT,
3459 ANI_TXDIR_TODS,
3460 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3461 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303462 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3463 psessionEntry->peSessionId,
3464 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3466 {
3467 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003468 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 halstatus);
3470
3471 //Pkt will be freed up by the callback
3472 }
3473
3474 return;
3475} /*** end limSendAuthMgmtFrame() ***/
3476
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003477eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3478{
3479 tANI_U16 aid;
3480 tpDphHashNode pStaDs;
3481 tLimMlmDeauthReq *pMlmDeauthReq;
3482 tLimMlmDeauthCnf mlmDeauthCnf;
3483 tpPESession psessionEntry;
3484
3485 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3486 if (pMlmDeauthReq)
3487 {
3488 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3489 {
3490 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3491 }
3492
3493 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3494 {
3495
3496 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003497 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003498 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3499 goto end;
3500 }
3501
3502 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3503 if (pStaDs == NULL)
3504 {
3505 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3506 goto end;
3507 }
3508
3509
3510 /// Receive path cleanup with dummy packet
3511 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3512 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303513 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003514 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3515 }
3516 return eHAL_STATUS_SUCCESS;
3517end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303518 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003519 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3520 sizeof(tSirMacAddr));
3521 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3522 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3523 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3524
3525 // Free up buffer allocated
3526 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303527 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003528
3529 limPostSmeMessage(pMac,
3530 LIM_MLM_DEAUTH_CNF,
3531 (tANI_U32 *) &mlmDeauthCnf);
3532 return eHAL_STATUS_SUCCESS;
3533}
3534
3535eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3536{
3537 tANI_U16 aid;
3538 tpDphHashNode pStaDs;
3539 tLimMlmDisassocCnf mlmDisassocCnf;
3540 tpPESession psessionEntry;
3541 tLimMlmDisassocReq *pMlmDisassocReq;
3542
3543 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3544 if (pMlmDisassocReq)
3545 {
3546 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3547 {
3548 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3549 }
3550
3551 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3552 {
3553
3554 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003555 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003556 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3557 goto end;
3558 }
3559
3560 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3561 if (pStaDs == NULL)
3562 {
3563 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3564 goto end;
3565 }
3566
3567 /// Receive path cleanup with dummy packet
3568 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3569 {
3570 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3571 goto end;
3572 }
3573
3574#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003575 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303576 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003577#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303578 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003579#endif
3580#ifdef FEATURE_WLAN_LFR
3581 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003582#endif
3583 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303584 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003585 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003586 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303587 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003588 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003589 psessionEntry, psessionEntry->peSessionId););
3590 limFTCleanup(pMac);
3591 }
3592 else
3593 {
3594 PELOGE(limLog(pMac, LOGE,
3595 FL("No FT Preauth Session Cleanup in role %d"
3596#ifdef FEATURE_WLAN_CCX
3597 " isCCX %d"
3598#endif
3599#ifdef FEATURE_WLAN_LFR
3600 " isLFR %d"
3601#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003602 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003603 psessionEntry->limSystemRole,
3604#ifdef FEATURE_WLAN_CCX
3605 psessionEntry->isCCXconnection,
3606#endif
3607#ifdef FEATURE_WLAN_LFR
3608 psessionEntry->isFastRoamIniFeatureEnabled,
3609#endif
3610 psessionEntry->is11Rconnection,
3611 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003612 }
3613#endif
3614
3615 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303616 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003617 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3618 return eHAL_STATUS_SUCCESS;
3619 }
3620 else
3621 {
3622 return eHAL_STATUS_SUCCESS;
3623 }
3624end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303625 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003626 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3627 sizeof(tSirMacAddr));
3628 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3629 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3630
3631 /* Update PE session ID*/
3632 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3633
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003634 if(pMlmDisassocReq != NULL)
3635 {
3636 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303637 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003638 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3639 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003640
3641 limPostSmeMessage(pMac,
3642 LIM_MLM_DISASSOC_CNF,
3643 (tANI_U32 *) &mlmDisassocCnf);
3644 return eHAL_STATUS_SUCCESS;
3645}
3646
3647eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3648{
3649 return limSendDisassocCnf(pMac);
3650}
3651
3652eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3653{
3654 return limSendDeauthCnf(pMac);
3655}
3656
Jeff Johnson295189b2012-06-20 16:38:30 -07003657/**
3658 * \brief This function is called to send Disassociate frame.
3659 *
3660 *
3661 * \param pMac Pointer to Global MAC structure
3662 *
3663 * \param nReason Indicates the reason that need to be sent in
3664 * Disassociation frame
3665 *
3666 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3667 * sent
3668 *
3669 *
3670 */
3671
3672void
3673limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3674 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003675 tSirMacAddr peer,
3676 tpPESession psessionEntry,
3677 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003678{
3679 tDot11fDisassociation frm;
3680 tANI_U8 *pFrame;
3681 tSirRetStatus nSirStatus;
3682 tpSirMacMgmtHdr pMacHdr;
3683 tANI_U32 nBytes, nPayload, nStatus;
3684 void *pPacket;
3685 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303686 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003687 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 if(NULL == psessionEntry)
3689 {
3690 return;
3691 }
3692
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303693 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003694
3695 frm.Reason.code = nReason;
3696
3697 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3698 if ( DOT11F_FAILED( nStatus ) )
3699 {
3700 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003701 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 nStatus );
3703 // We'll fall back on the worst case scenario:
3704 nPayload = sizeof( tDot11fDisassociation );
3705 }
3706 else if ( DOT11F_WARNED( nStatus ) )
3707 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003708 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003710 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 }
3712
3713 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3714
3715 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3716 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3717 ( void** ) &pPacket );
3718 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3719 {
3720 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003721 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 return;
3723 }
3724
3725 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303726 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003727
3728 // Next, we fill out the buffer descriptor:
3729 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3730 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3731 if ( eSIR_SUCCESS != nSirStatus )
3732 {
3733 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003734 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 nSirStatus );
3736 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3737 ( void* ) pFrame, ( void* ) pPacket );
3738 return; // just allocated...
3739 }
3740
3741 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3742
3743 // Prepare the BSSID
3744 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3745
Chet Lanctot186b5732013-03-18 10:26:30 -07003746#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003747 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003748#endif
3749
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3751 sizeof(tSirMacMgmtHdr),
3752 nPayload, &nPayload );
3753 if ( DOT11F_FAILED( nStatus ) )
3754 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003755 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 nStatus );
3757 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3758 ( void* ) pFrame, ( void* ) pPacket );
3759 return; // allocated!
3760 }
3761 else if ( DOT11F_WARNED( nStatus ) )
3762 {
3763 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003764 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 }
3766
Abhishek Singhcd09b562013-12-24 16:02:20 +05303767 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
3768 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
3769 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
3770 MAC_ADDR_ARRAY(pMacHdr->da),
3771 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003772
3773 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3775 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 )
3777 {
3778 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3779 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003780
Ganesh K08bce952012-12-13 15:04:41 -08003781 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303782 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3783 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003784 {
3785 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3786 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003787
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303788 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3789 {
3790 /* This frame will be sent on air by firmware,
3791 which will ensure that this frame goes out
3792 even though DEL_STA is sent immediately */
3793 /* Without this for DEL_STA command there is
3794 risk of flushing frame in BTQM queue without
3795 sending on air */
3796 txFlag |= HAL_USE_FW_IN_TX_PATH;
3797 }
3798
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003799 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303801 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3802 psessionEntry->peSessionId,
3803 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003804 // Queue Disassociation frame in high priority WQ
3805 /* get the duration from the request */
3806 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3807 HAL_TXRX_FRM_802_11_MGMT,
3808 ANI_TXDIR_TODS,
3809 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3810 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3811 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303812 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3813 psessionEntry->peSessionId,
3814 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003815 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003816
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003817 if (tx_timer_change(
3818 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3819 != TX_SUCCESS)
3820 {
3821 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003822 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003823 return;
3824 }
3825 else if(TX_SUCCESS != tx_timer_activate(
3826 &pMac->lim.limTimers.gLimDisassocAckTimer))
3827 {
3828 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003829 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003830 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3831 return;
3832 }
3833 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003834 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003835 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303836 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3837 psessionEntry->peSessionId,
3838 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003839 // Queue Disassociation frame in high priority WQ
3840 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3841 HAL_TXRX_FRM_802_11_MGMT,
3842 ANI_TXDIR_TODS,
3843 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3844 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303845 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3846 psessionEntry->peSessionId,
3847 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003848 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3849 {
3850 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003851 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003852 nSirStatus );
3853 //Pkt will be freed up by the callback
3854 return;
3855 }
3856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003857} // End limSendDisassocMgmtFrame.
3858
3859/**
3860 * \brief This function is called to send a Deauthenticate frame
3861 *
3862 *
3863 * \param pMac Pointer to global MAC structure
3864 *
3865 * \param nReason Indicates the reason that need to be sent in the
3866 * Deauthenticate frame
3867 *
3868 * \param peeer address of the STA to which the frame is to be sent
3869 *
3870 *
3871 */
3872
3873void
3874limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3875 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003876 tSirMacAddr peer,
3877 tpPESession psessionEntry,
3878 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003879{
3880 tDot11fDeAuth frm;
3881 tANI_U8 *pFrame;
3882 tSirRetStatus nSirStatus;
3883 tpSirMacMgmtHdr pMacHdr;
3884 tANI_U32 nBytes, nPayload, nStatus;
3885 void *pPacket;
3886 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303887 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003888 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003889#ifdef FEATURE_WLAN_TDLS
3890 tANI_U16 aid;
3891 tpDphHashNode pStaDs;
3892#endif
3893
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 if(NULL == psessionEntry)
3895 {
3896 return;
3897 }
3898
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303899 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003900
3901 frm.Reason.code = nReason;
3902
3903 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3904 if ( DOT11F_FAILED( nStatus ) )
3905 {
3906 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003907 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 nStatus );
3909 // We'll fall back on the worst case scenario:
3910 nPayload = sizeof( tDot11fDeAuth );
3911 }
3912 else if ( DOT11F_WARNED( nStatus ) )
3913 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003914 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003916 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 }
3918
3919 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3920
3921 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3922 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3923 ( void** ) &pPacket );
3924 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3925 {
3926 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003927 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 return;
3929 }
3930
3931 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303932 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003933
3934 // Next, we fill out the buffer descriptor:
3935 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3936 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3937 if ( eSIR_SUCCESS != nSirStatus )
3938 {
3939 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003940 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 nSirStatus );
3942 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3943 ( void* ) pFrame, ( void* ) pPacket );
3944 return; // just allocated...
3945 }
3946
3947 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3948
3949 // Prepare the BSSID
3950 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3951
Chet Lanctot186b5732013-03-18 10:26:30 -07003952#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003953 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003954#endif
3955
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3957 sizeof(tSirMacMgmtHdr),
3958 nPayload, &nPayload );
3959 if ( DOT11F_FAILED( nStatus ) )
3960 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003961 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 nStatus );
3963 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3964 ( void* ) pFrame, ( void* ) pPacket );
3965 return;
3966 }
3967 else if ( DOT11F_WARNED( nStatus ) )
3968 {
3969 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003970 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05303972 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
3973 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
3974 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
3975 MAC_ADDR_ARRAY(pMacHdr->da),
3976 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003977
3978 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3980 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 )
3982 {
3983 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3984 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003985
Ganesh K08bce952012-12-13 15:04:41 -08003986 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303987 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3988 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003989 {
3990 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3991 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003992
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303993 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3994 {
3995 /* This frame will be sent on air by firmware,
3996 which will ensure that this frame goes out
3997 even though DEL_STA is sent immediately */
3998 /* Without this for DEL_STA command there is
3999 risk of flushing frame in BTQM queue without
4000 sending on air */
4001 txFlag |= HAL_USE_FW_IN_TX_PATH;
4002 }
4003
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004004#ifdef FEATURE_WLAN_TDLS
4005 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4006#endif
4007
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004008 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304010 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4011 psessionEntry->peSessionId,
4012 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004013 // Queue Disassociation frame in high priority WQ
4014 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4015 HAL_TXRX_FRM_802_11_MGMT,
4016 ANI_TXDIR_TODS,
4017 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4018 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304019 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4020 psessionEntry->peSessionId,
4021 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304022 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004023 {
4024 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304025 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004026 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004027 //Pkt will be freed up by the callback limTxComplete
4028
4029 /*Call limProcessDeauthAckTimeout which will send
4030 * DeauthCnf for this frame
4031 */
4032 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004033 return;
4034 }
4035
4036 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4037
4038 if (tx_timer_change(
4039 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4040 != TX_SUCCESS)
4041 {
4042 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004043 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004044 return;
4045 }
4046 else if(TX_SUCCESS != tx_timer_activate(
4047 &pMac->lim.limTimers.gLimDeauthAckTimer))
4048 {
4049 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004050 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004051 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4052 return;
4053 }
4054 }
4055 else
4056 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304057 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4058 psessionEntry->peSessionId,
4059 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004060#ifdef FEATURE_WLAN_TDLS
4061 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4062 {
4063 // Queue Disassociation frame in high priority WQ
4064 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004065 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004066 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004067 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4068 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004069 }
4070 else
4071 {
4072#endif
4073 // Queue Disassociation frame in high priority WQ
4074 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4075 HAL_TXRX_FRM_802_11_MGMT,
4076 ANI_TXDIR_TODS,
4077 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4078 limTxComplete, pFrame, txFlag );
4079#ifdef FEATURE_WLAN_TDLS
4080 }
4081#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304082 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4083 psessionEntry->peSessionId,
4084 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004085 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4086 {
4087 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004088 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004089 nSirStatus );
4090 //Pkt will be freed up by the callback
4091 return;
4092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 }
4094
4095} // End limSendDeauthMgmtFrame.
4096
4097
4098#ifdef ANI_SUPPORT_11H
4099/**
4100 * \brief Send a Measurement Report Action frame
4101 *
4102 *
4103 * \param pMac Pointer to the global MAC structure
4104 *
4105 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4106 *
4107 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4108 *
4109 *
4110 */
4111
4112tSirRetStatus
4113limSendMeasReportFrame(tpAniSirGlobal pMac,
4114 tpSirMacMeasReqActionFrame pMeasReqFrame,
4115 tSirMacAddr peer)
4116{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304117 tDot11fMeasurementReport frm;
4118 tANI_U8 *pFrame;
4119 tSirRetStatus nSirStatus;
4120 tpSirMacMgmtHdr pMacHdr;
4121 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4122 void *pPacket;
4123 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004124
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304125 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004126
4127 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4128 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4129 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4130
4131 switch ( pMeasReqFrame->measReqIE.measType )
4132 {
4133 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4134 nSirStatus =
4135 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4136 &frm.MeasurementReport );
4137 break;
4138 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4139 nSirStatus =
4140 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4141 &frm.MeasurementReport );
4142 break;
4143 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4144 nSirStatus =
4145 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4146 &frm.MeasurementReport );
4147 break;
4148 default:
4149 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004150 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 pMeasReqFrame->measReqIE.measType );
4152 return eSIR_FAILURE;
4153 }
4154
4155 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4156
4157 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4158 if ( DOT11F_FAILED( nStatus ) )
4159 {
4160 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004161 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 nStatus );
4163 // We'll fall back on the worst case scenario:
4164 nPayload = sizeof( tDot11fMeasurementReport );
4165 }
4166 else if ( DOT11F_WARNED( nStatus ) )
4167 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004168 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004170 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 }
4172
4173 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4174
4175 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4176 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4177 {
4178 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004179 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 return eSIR_FAILURE;
4181 }
4182
4183 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304184 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004185
4186 // Next, we fill out the buffer descriptor:
4187 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4188 SIR_MAC_MGMT_ACTION, peer);
4189 if ( eSIR_SUCCESS != nSirStatus )
4190 {
4191 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004192 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 nSirStatus );
4194 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4195 return eSIR_FAILURE; // just allocated...
4196 }
4197
4198 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4199
4200 nCfg = 6;
4201 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4202 if ( eSIR_SUCCESS != nSirStatus )
4203 {
4204 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004205 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 nSirStatus );
4207 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4208 return eSIR_FAILURE; // just allocated...
4209 }
4210
Chet Lanctot186b5732013-03-18 10:26:30 -07004211#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004212 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004213#endif
4214
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4216 sizeof(tSirMacMgmtHdr),
4217 nPayload, &nPayload );
4218 if ( DOT11F_FAILED( nStatus ) )
4219 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004220 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 nStatus );
4222 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4223 return eSIR_FAILURE; // allocated!
4224 }
4225 else if ( DOT11F_WARNED( nStatus ) )
4226 {
4227 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004228 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 }
4230
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304231 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4232 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4233 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4235 HAL_TXRX_FRM_802_11_MGMT,
4236 ANI_TXDIR_TODS,
4237 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4238 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304239 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4240 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4241 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4243 {
4244 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004245 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 nSirStatus );
4247 //Pkt will be freed up by the callback
4248 return eSIR_FAILURE; // just allocated...
4249 }
4250
4251 return eSIR_SUCCESS;
4252
4253} // End limSendMeasReportFrame.
4254
4255
4256/**
4257 * \brief Send a TPC Request Action frame
4258 *
4259 *
4260 * \param pMac Pointer to the global MAC datastructure
4261 *
4262 * \param peer MAC address to which the frame should be sent
4263 *
4264 *
4265 */
4266
4267void
4268limSendTpcRequestFrame(tpAniSirGlobal pMac,
4269 tSirMacAddr peer)
4270{
4271 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304272 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 tSirRetStatus nSirStatus;
4274 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304275 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4276 void *pPacket;
4277 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004278
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304279 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004280
4281 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4282 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4283 frm.DialogToken.token = 1;
4284 frm.TPCRequest.present = 1;
4285
4286 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4287 if ( DOT11F_FAILED( nStatus ) )
4288 {
4289 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004290 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 nStatus );
4292 // We'll fall back on the worst case scenario:
4293 nPayload = sizeof( tDot11fTPCRequest );
4294 }
4295 else if ( DOT11F_WARNED( nStatus ) )
4296 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004297 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004299 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 }
4301
4302 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4303
4304 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4305 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4306 {
4307 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004308 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 return;
4310 }
4311
4312 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304313 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004314
4315 // Next, we fill out the buffer descriptor:
4316 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4317 SIR_MAC_MGMT_ACTION, peer);
4318 if ( eSIR_SUCCESS != nSirStatus )
4319 {
4320 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004321 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 nSirStatus );
4323 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4324 return; // just allocated...
4325 }
4326
4327 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4328
4329 nCfg = 6;
4330 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4331 if ( eSIR_SUCCESS != nSirStatus )
4332 {
4333 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004334 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 nSirStatus );
4336 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4337 return; // just allocated...
4338 }
4339
Chet Lanctot186b5732013-03-18 10:26:30 -07004340#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004341 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004342#endif
4343
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4345 sizeof(tSirMacMgmtHdr),
4346 nPayload, &nPayload );
4347 if ( DOT11F_FAILED( nStatus ) )
4348 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004349 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 nStatus );
4351 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4352 return; // allocated!
4353 }
4354 else if ( DOT11F_WARNED( nStatus ) )
4355 {
4356 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004357 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 }
4359
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304360 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4361 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4362 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4364 HAL_TXRX_FRM_802_11_MGMT,
4365 ANI_TXDIR_TODS,
4366 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4367 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304368 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4369 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4370 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4372 {
4373 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004374 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 nSirStatus );
4376 //Pkt will be freed up by the callback
4377 return;
4378 }
4379
4380} // End limSendTpcRequestFrame.
4381
4382
4383/**
4384 * \brief Send a TPC Report Action frame
4385 *
4386 *
4387 * \param pMac Pointer to the global MAC datastructure
4388 *
4389 * \param pTpcReqFrame Pointer to the received TPC Request
4390 *
4391 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4392 *
4393 *
4394 */
4395
4396tSirRetStatus
4397limSendTpcReportFrame(tpAniSirGlobal pMac,
4398 tpSirMacTpcReqActionFrame pTpcReqFrame,
4399 tSirMacAddr peer)
4400{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304401 tDot11fTPCReport frm;
4402 tANI_U8 *pFrame;
4403 tSirRetStatus nSirStatus;
4404 tpSirMacMgmtHdr pMacHdr;
4405 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4406 void *pPacket;
4407 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004408
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304409 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004410
4411 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4412 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4413 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4414
4415 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4416 // "misplaced this function, need to replace:
4417 // txPower = halGetRateToPwrValue(pMac, staid,
4418 // pMac->lim.gLimCurrentChannelId, 0);
4419 frm.TPCReport.tx_power = 0;
4420 frm.TPCReport.link_margin = 0;
4421 frm.TPCReport.present = 1;
4422
4423 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4424 if ( DOT11F_FAILED( nStatus ) )
4425 {
4426 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004427 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 nStatus );
4429 // We'll fall back on the worst case scenario:
4430 nPayload = sizeof( tDot11fTPCReport );
4431 }
4432 else if ( DOT11F_WARNED( nStatus ) )
4433 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004434 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004436 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 }
4438
4439 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4440
4441 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4442 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4443 {
4444 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004445 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 return eSIR_FAILURE;
4447 }
4448
4449 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304450 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004451
4452 // Next, we fill out the buffer descriptor:
4453 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4454 SIR_MAC_MGMT_ACTION, peer);
4455 if ( eSIR_SUCCESS != nSirStatus )
4456 {
4457 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004458 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 nSirStatus );
4460 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4461 return eSIR_FAILURE; // just allocated...
4462 }
4463
4464 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4465
4466 nCfg = 6;
4467 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4468 if ( eSIR_SUCCESS != nSirStatus )
4469 {
4470 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004471 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 nSirStatus );
4473 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4474 return eSIR_FAILURE; // just allocated...
4475 }
4476
Chet Lanctot186b5732013-03-18 10:26:30 -07004477#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004478 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004479#endif
4480
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4482 sizeof(tSirMacMgmtHdr),
4483 nPayload, &nPayload );
4484 if ( DOT11F_FAILED( nStatus ) )
4485 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004486 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 nStatus );
4488 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4489 return eSIR_FAILURE; // allocated!
4490 }
4491 else if ( DOT11F_WARNED( nStatus ) )
4492 {
4493 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004494 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 }
4496
4497
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304498 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4499 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4500 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4502 HAL_TXRX_FRM_802_11_MGMT,
4503 ANI_TXDIR_TODS,
4504 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4505 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304506 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4507 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4508 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4510 {
4511 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004512 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 nSirStatus );
4514 //Pkt will be freed up by the callback
4515 return eSIR_FAILURE; // just allocated...
4516 }
4517
4518 return eSIR_SUCCESS;
4519
4520} // End limSendTpcReportFrame.
4521#endif //ANI_SUPPORT_11H
4522
4523
Jeff Johnson295189b2012-06-20 16:38:30 -07004524/**
4525 * \brief Send a Channel Switch Announcement
4526 *
4527 *
4528 * \param pMac Pointer to the global MAC datastructure
4529 *
4530 * \param peer MAC address to which this frame will be sent
4531 *
4532 * \param nMode
4533 *
4534 * \param nNewChannel
4535 *
4536 * \param nCount
4537 *
4538 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4539 *
4540 *
4541 */
4542
4543tSirRetStatus
4544limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4545 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004546 tANI_U8 nMode,
4547 tANI_U8 nNewChannel,
4548 tANI_U8 nCount,
4549 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004550{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304551 tDot11fChannelSwitch frm;
4552 tANI_U8 *pFrame;
4553 tSirRetStatus nSirStatus;
4554 tpSirMacMgmtHdr pMacHdr;
4555 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4556 void *pPacket;
4557 eHalStatus halstatus;
4558 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004559
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304560 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004561
4562 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4563 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4564 frm.ChanSwitchAnn.switchMode = nMode;
4565 frm.ChanSwitchAnn.newChannel = nNewChannel;
4566 frm.ChanSwitchAnn.switchCount = nCount;
4567 frm.ChanSwitchAnn.present = 1;
4568
4569 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4570 if ( DOT11F_FAILED( nStatus ) )
4571 {
4572 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004573 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 nStatus );
4575 // We'll fall back on the worst case scenario:
4576 nPayload = sizeof( tDot11fChannelSwitch );
4577 }
4578 else if ( DOT11F_WARNED( nStatus ) )
4579 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004580 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004582 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 }
4584
4585 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4586
4587 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4588 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4589 {
4590 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004591 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 return eSIR_FAILURE;
4593 }
4594
4595 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304596 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004597
4598 // Next, we fill out the buffer descriptor:
4599 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004600 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4601 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304602 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4603 (tANI_U8 *) psessionEntry->bssId,
4604 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 if ( eSIR_SUCCESS != nSirStatus )
4606 {
4607 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004608 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 nSirStatus );
4610 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4611 return eSIR_FAILURE; // just allocated...
4612 }
4613
Jeff Johnsone7245742012-09-05 17:12:55 -07004614#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4616
4617 nCfg = 6;
4618 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4619 if ( eSIR_SUCCESS != nSirStatus )
4620 {
4621 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004622 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 nSirStatus );
4624 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4625 return eSIR_FAILURE; // just allocated...
4626 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004627#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004628
4629#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004630 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004631#endif
4632
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4634 sizeof(tSirMacMgmtHdr),
4635 nPayload, &nPayload );
4636 if ( DOT11F_FAILED( nStatus ) )
4637 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004638 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 nStatus );
4640 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4641 return eSIR_FAILURE; // allocated!
4642 }
4643 else if ( DOT11F_WARNED( nStatus ) )
4644 {
4645 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004646 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 }
4648
Jeff Johnsone7245742012-09-05 17:12:55 -07004649 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004650 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4651 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004652 )
4653 {
4654 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4655 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304656
4657 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4658 psessionEntry->peSessionId,
4659 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4661 HAL_TXRX_FRM_802_11_MGMT,
4662 ANI_TXDIR_TODS,
4663 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004664 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304665 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4666 psessionEntry->peSessionId,
4667 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4669 {
4670 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004671 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 nSirStatus );
4673 //Pkt will be freed up by the callback
4674 return eSIR_FAILURE;
4675 }
4676
4677 return eSIR_SUCCESS;
4678
4679} // End limSendChannelSwitchMgmtFrame.
4680
Jeff Johnson295189b2012-06-20 16:38:30 -07004681
4682
Mohit Khanna4a70d262012-09-11 16:30:12 -07004683#ifdef WLAN_FEATURE_11AC
4684tSirRetStatus
4685limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4686 tSirMacAddr peer,
4687 tANI_U8 nMode,
4688 tpPESession psessionEntry )
4689{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304690 tDot11fOperatingMode frm;
4691 tANI_U8 *pFrame;
4692 tSirRetStatus nSirStatus;
4693 tpSirMacMgmtHdr pMacHdr;
4694 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4695 void *pPacket;
4696 eHalStatus halstatus;
4697 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07004698
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304699 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004700
4701 frm.Category.category = SIR_MAC_ACTION_VHT;
4702 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4703 frm.OperatingMode.chanWidth = nMode;
4704 frm.OperatingMode.rxNSS = 0;
4705 frm.OperatingMode.rxNSSType = 0;
4706
4707 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4708 if ( DOT11F_FAILED( nStatus ) )
4709 {
4710 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004711 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004712 nStatus );
4713 // We'll fall back on the worst case scenario:
4714 nPayload = sizeof( tDot11fOperatingMode);
4715 }
4716 else if ( DOT11F_WARNED( nStatus ) )
4717 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004718 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004719 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004720 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004721 }
4722
4723 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4724
4725 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4726 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4727 {
4728 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004729 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004730 return eSIR_FAILURE;
4731 }
4732
4733 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304734 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004735
4736
4737 // Next, we fill out the buffer descriptor:
4738 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4739 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4740 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4741 } else
4742 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4743 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4744 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304745 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4746 (tANI_U8 *) psessionEntry->bssId,
4747 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004748 if ( eSIR_SUCCESS != nSirStatus )
4749 {
4750 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004751 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004752 nSirStatus );
4753 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4754 return eSIR_FAILURE; // just allocated...
4755 }
4756 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4757 sizeof(tSirMacMgmtHdr),
4758 nPayload, &nPayload );
4759 if ( DOT11F_FAILED( nStatus ) )
4760 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004761 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004762 nStatus );
4763 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4764 return eSIR_FAILURE; // allocated!
4765 }
4766 else if ( DOT11F_WARNED( nStatus ) )
4767 {
4768 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004769 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004770 }
4771 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004772 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4773 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004774 )
4775 {
4776 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4777 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304778
4779 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4780 psessionEntry->peSessionId,
4781 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004782 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4783 HAL_TXRX_FRM_802_11_MGMT,
4784 ANI_TXDIR_TODS,
4785 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4786 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304787 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4788 psessionEntry->peSessionId,
4789 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004790 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4791 {
4792 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004793 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004794 nSirStatus );
4795 //Pkt will be freed up by the callback
4796 return eSIR_FAILURE;
4797 }
4798
4799 return eSIR_SUCCESS;
4800}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004801
4802/**
4803 * \brief Send a VHT Channel Switch Announcement
4804 *
4805 *
4806 * \param pMac Pointer to the global MAC datastructure
4807 *
4808 * \param peer MAC address to which this frame will be sent
4809 *
4810 * \param nChanWidth
4811 *
4812 * \param nNewChannel
4813 *
4814 *
4815 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4816 *
4817 *
4818 */
4819
4820tSirRetStatus
4821limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4822 tSirMacAddr peer,
4823 tANI_U8 nChanWidth,
4824 tANI_U8 nNewChannel,
4825 tANI_U8 ncbMode,
4826 tpPESession psessionEntry )
4827{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304828 tDot11fChannelSwitch frm;
4829 tANI_U8 *pFrame;
4830 tSirRetStatus nSirStatus;
4831 tpSirMacMgmtHdr pMacHdr;
4832 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4833 void *pPacket;
4834 eHalStatus halstatus;
4835 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004836
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304837 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004838
4839
4840 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4841 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4842 frm.ChanSwitchAnn.switchMode = 1;
4843 frm.ChanSwitchAnn.newChannel = nNewChannel;
4844 frm.ChanSwitchAnn.switchCount = 1;
4845 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4846 frm.ExtChanSwitchAnn.present = 1;
4847 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4848 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4849 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4850 frm.ChanSwitchAnn.present = 1;
4851 frm.WiderBWChanSwitchAnn.present = 1;
4852
4853 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4854 if ( DOT11F_FAILED( nStatus ) )
4855 {
4856 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004857 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004858 nStatus );
4859 // We'll fall back on the worst case scenario:
4860 nPayload = sizeof( tDot11fChannelSwitch );
4861 }
4862 else if ( DOT11F_WARNED( nStatus ) )
4863 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004864 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004865 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004866 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004867 }
4868
4869 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4870
4871 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4872 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4873 {
4874 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004875 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004876 return eSIR_FAILURE;
4877 }
4878 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304879 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004880
4881 // Next, we fill out the buffer descriptor:
4882 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4883 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4884 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304885 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4886 (tANI_U8 *) psessionEntry->bssId,
4887 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004888 if ( eSIR_SUCCESS != nSirStatus )
4889 {
4890 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004891 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004892 nSirStatus );
4893 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4894 return eSIR_FAILURE; // just allocated...
4895 }
4896 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4897 sizeof(tSirMacMgmtHdr),
4898 nPayload, &nPayload );
4899 if ( DOT11F_FAILED( nStatus ) )
4900 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004901 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004902 nStatus );
4903 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4904 return eSIR_FAILURE; // allocated!
4905 }
4906 else if ( DOT11F_WARNED( nStatus ) )
4907 {
4908 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004909 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004910 }
4911
4912 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004913 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4914 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004915 )
4916 {
4917 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4918 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304919
4920 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4921 psessionEntry->peSessionId,
4922 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004923 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4924 HAL_TXRX_FRM_802_11_MGMT,
4925 ANI_TXDIR_TODS,
4926 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4927 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304928 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4929 psessionEntry->peSessionId,
4930 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004931 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4932 {
4933 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004934 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004935 nSirStatus );
4936 //Pkt will be freed up by the callback
4937 return eSIR_FAILURE;
4938 }
4939
4940 return eSIR_SUCCESS;
4941
4942} // End limSendVHTChannelSwitchMgmtFrame.
4943
4944
4945
Mohit Khanna4a70d262012-09-11 16:30:12 -07004946#endif
4947
Jeff Johnson295189b2012-06-20 16:38:30 -07004948/**
4949 * \brief Send an ADDBA Req Action Frame to peer
4950 *
4951 * \sa limSendAddBAReq
4952 *
4953 * \param pMac The global tpAniSirGlobal object
4954 *
4955 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4956 * the necessary parameters reqd by PE send the ADDBA Req Action
4957 * Frame to the peer
4958 *
4959 * \return eSIR_SUCCESS if setup completes successfully
4960 * eSIR_FAILURE is some problem is encountered
4961 */
4962tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304963 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004964{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304965 tDot11fAddBAReq frmAddBAReq;
4966 tANI_U8 *pAddBAReqBuffer = NULL;
4967 tpSirMacMgmtHdr pMacHdr;
4968 tANI_U32 frameLen = 0, nStatus, nPayload;
4969 tSirRetStatus statusCode;
4970 eHalStatus halStatus;
4971 void *pPacket;
4972 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004973
4974 if(NULL == psessionEntry)
4975 {
4976 return eSIR_FAILURE;
4977 }
4978
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304979 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004980
4981 // Category - 3 (BA)
4982 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4983
4984 // Action - 0 (ADDBA Req)
4985 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4986
4987 // FIXME - Dialog Token, generalize this...
4988 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4989
4990 // Fill the ADDBA Parameter Set
4991 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4992 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4993 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4994
4995 // BA timeout
4996 // 0 - indicates no BA timeout
4997 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4998
4999 // BA Starting Sequence Number
5000 // Fragment number will always be zero
5001 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5002 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5003 }
5004
5005 frmAddBAReq.BAStartingSequenceControl.ssn =
5006 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5007
5008 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5009
5010 if( DOT11F_FAILED( nStatus ))
5011 {
5012 limLog( pMac, LOGW,
5013 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005014 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 nStatus );
5016
5017 // We'll fall back on the worst case scenario:
5018 nPayload = sizeof( tDot11fAddBAReq );
5019 }
5020 else if( DOT11F_WARNED( nStatus ))
5021 {
5022 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005023 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005024 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 nStatus );
5026 }
5027
5028 // Add the MGMT header to frame length
5029 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5030
5031 // Need to allocate a buffer for ADDBA AF
5032 if( eHAL_STATUS_SUCCESS !=
5033 (halStatus = palPktAlloc( pMac->hHdd,
5034 HAL_TXRX_FRM_802_11_MGMT,
5035 (tANI_U16) frameLen,
5036 (void **) &pAddBAReqBuffer,
5037 (void **) &pPacket )))
5038 {
5039 // Log error
5040 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005041 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 frameLen,
5043 halStatus );
5044
5045 statusCode = eSIR_MEM_ALLOC_FAILED;
5046 goto returnAfterError;
5047 }
5048
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305049 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005050
5051 // Copy necessary info to BD
5052 if( eSIR_SUCCESS !=
5053 (statusCode = limPopulateMacHeader( pMac,
5054 pAddBAReqBuffer,
5055 SIR_MAC_MGMT_FRAME,
5056 SIR_MAC_MGMT_ACTION,
5057 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5058 goto returnAfterError;
5059
5060 // Update A3 with the BSSID
5061 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5062
5063 #if 0
5064 cfgLen = SIR_MAC_ADDR_LENGTH;
5065 if( eSIR_SUCCESS != cfgGetStr( pMac,
5066 WNI_CFG_BSSID,
5067 (tANI_U8 *) pMacHdr->bssId,
5068 &cfgLen ))
5069 {
5070 limLog( pMac, LOGP,
5071 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005072 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005073
5074 // FIXME - Need to convert to tSirRetStatus
5075 statusCode = eSIR_FAILURE;
5076 goto returnAfterError;
5077 }
5078 #endif//TO SUPPORT BT-AMP
5079 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5080
Chet Lanctot186b5732013-03-18 10:26:30 -07005081#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005082 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005083#endif
5084
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 // Now, we're ready to "pack" the frames
5086 nStatus = dot11fPackAddBAReq( pMac,
5087 &frmAddBAReq,
5088 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5089 nPayload,
5090 &nPayload );
5091
5092 if( DOT11F_FAILED( nStatus ))
5093 {
5094 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005095 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 nStatus );
5097
5098 // FIXME - Need to convert to tSirRetStatus
5099 statusCode = eSIR_FAILURE;
5100 goto returnAfterError;
5101 }
5102 else if( DOT11F_WARNED( nStatus ))
5103 {
5104 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005105 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5106 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 }
5108
5109 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005110 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005111 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5112
5113 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5115 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 )
5117 {
5118 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5119 }
5120
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305121 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5122 psessionEntry->peSessionId,
5123 pMacHdr->fc.subType));
5124 halStatus = halTxFrame( pMac,
5125 pPacket,
5126 (tANI_U16) frameLen,
5127 HAL_TXRX_FRM_802_11_MGMT,
5128 ANI_TXDIR_TODS,
5129 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5130 limTxComplete,
5131 pAddBAReqBuffer, txFlag );
5132 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5133 psessionEntry->peSessionId,
5134 halStatus));
5135 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005136 {
5137 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005138 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005139 halStatus );
5140
5141 // FIXME - Need to convert eHalStatus to tSirRetStatus
5142 statusCode = eSIR_FAILURE;
5143 //Pkt will be freed up by the callback
5144 return statusCode;
5145 }
5146 else
5147 return eSIR_SUCCESS;
5148
5149returnAfterError:
5150
5151 // Release buffer, if allocated
5152 if( NULL != pAddBAReqBuffer )
5153 palPktFree( pMac->hHdd,
5154 HAL_TXRX_FRM_802_11_MGMT,
5155 (void *) pAddBAReqBuffer,
5156 (void *) pPacket );
5157
5158 return statusCode;
5159}
5160
5161/**
5162 * \brief Send an ADDBA Rsp Action Frame to peer
5163 *
5164 * \sa limSendAddBARsp
5165 *
5166 * \param pMac The global tpAniSirGlobal object
5167 *
5168 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5169 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5170 * Frame to the peer
5171 *
5172 * \return eSIR_SUCCESS if setup completes successfully
5173 * eSIR_FAILURE is some problem is encountered
5174 */
5175tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5176 tpLimMlmAddBARsp pMlmAddBARsp,
5177 tpPESession psessionEntry)
5178{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305179 tDot11fAddBARsp frmAddBARsp;
5180 tANI_U8 *pAddBARspBuffer = NULL;
5181 tpSirMacMgmtHdr pMacHdr;
5182 tANI_U32 frameLen = 0, nStatus, nPayload;
5183 tSirRetStatus statusCode;
5184 eHalStatus halStatus;
5185 void *pPacket;
5186 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005187
5188 if(NULL == psessionEntry)
5189 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005190 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 return eSIR_FAILURE;
5192 }
5193
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305194 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005195
5196 // Category - 3 (BA)
5197 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5198 // Action - 1 (ADDBA Rsp)
5199 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5200
5201 // Should be same as the one we received in the ADDBA Req
5202 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5203
5204 // ADDBA Req status
5205 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5206
5207 // Fill the ADDBA Parameter Set as provided by caller
5208 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5209 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5210 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005211
5212 if(psessionEntry->isAmsduSupportInAMPDU)
5213 {
5214 frmAddBARsp.AddBAParameterSet.amsduSupported =
5215 psessionEntry->amsduSupportedInBA;
5216 }
5217 else
5218 {
5219 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005221
5222 // BA timeout
5223 // 0 - indicates no BA timeout
5224 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5225
5226 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5227
5228 if( DOT11F_FAILED( nStatus ))
5229 {
5230 limLog( pMac, LOGW,
5231 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005232 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 nStatus );
5234
5235 // We'll fall back on the worst case scenario:
5236 nPayload = sizeof( tDot11fAddBARsp );
5237 }
5238 else if( DOT11F_WARNED( nStatus ))
5239 {
5240 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005241 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005242 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 nStatus );
5244 }
5245
5246 // Need to allocate a buffer for ADDBA AF
5247 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5248
5249 // Allocate shared memory
5250 if( eHAL_STATUS_SUCCESS !=
5251 (halStatus = palPktAlloc( pMac->hHdd,
5252 HAL_TXRX_FRM_802_11_MGMT,
5253 (tANI_U16) frameLen,
5254 (void **) &pAddBARspBuffer,
5255 (void **) &pPacket )))
5256 {
5257 // Log error
5258 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005259 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005260 frameLen,
5261 halStatus );
5262
5263 statusCode = eSIR_MEM_ALLOC_FAILED;
5264 goto returnAfterError;
5265 }
5266
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305267 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005268
5269 // Copy necessary info to BD
5270 if( eSIR_SUCCESS !=
5271 (statusCode = limPopulateMacHeader( pMac,
5272 pAddBARspBuffer,
5273 SIR_MAC_MGMT_FRAME,
5274 SIR_MAC_MGMT_ACTION,
5275 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5276 goto returnAfterError;
5277
5278 // Update A3 with the BSSID
5279
5280 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5281
5282 #if 0
5283 cfgLen = SIR_MAC_ADDR_LENGTH;
5284 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5285 WNI_CFG_BSSID,
5286 (tANI_U8 *) pMacHdr->bssId,
5287 &cfgLen ))
5288 {
5289 limLog( pMac, LOGP,
5290 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005291 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005292
5293 // FIXME - Need to convert to tSirRetStatus
5294 statusCode = eSIR_FAILURE;
5295 goto returnAfterError;
5296 }
5297 #endif // TO SUPPORT BT-AMP
5298 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5299
Chet Lanctot186b5732013-03-18 10:26:30 -07005300#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005301 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005302#endif
5303
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 // Now, we're ready to "pack" the frames
5305 nStatus = dot11fPackAddBARsp( pMac,
5306 &frmAddBARsp,
5307 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5308 nPayload,
5309 &nPayload );
5310
5311 if( DOT11F_FAILED( nStatus ))
5312 {
5313 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005314 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 nStatus );
5316
5317 // FIXME - Need to convert to tSirRetStatus
5318 statusCode = eSIR_FAILURE;
5319 goto returnAfterError;
5320 }
5321 else if( DOT11F_WARNED( nStatus ))
5322 {
5323 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005324 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5325 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005326 }
5327
5328 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005329 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5331
5332 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5334 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 )
5336 {
5337 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5338 }
5339
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305340 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5341 psessionEntry->peSessionId,
5342 pMacHdr->fc.subType));
5343 halStatus = halTxFrame( pMac,
5344 pPacket,
5345 (tANI_U16) frameLen,
5346 HAL_TXRX_FRM_802_11_MGMT,
5347 ANI_TXDIR_TODS,
5348 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5349 limTxComplete,
5350 pAddBARspBuffer, txFlag );
5351 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5352 psessionEntry->peSessionId,
5353 halStatus));
5354 if( eHAL_STATUS_SUCCESS != halStatus )
5355 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005357 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 halStatus );
5359
5360 // FIXME - HAL error codes are different from PE error
5361 // codes!! And, this routine is returning tSirRetStatus
5362 statusCode = eSIR_FAILURE;
5363 //Pkt will be freed up by the callback
5364 return statusCode;
5365 }
5366 else
5367 return eSIR_SUCCESS;
5368
5369 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 // Release buffer, if allocated
5371 if( NULL != pAddBARspBuffer )
5372 palPktFree( pMac->hHdd,
5373 HAL_TXRX_FRM_802_11_MGMT,
5374 (void *) pAddBARspBuffer,
5375 (void *) pPacket );
5376
5377 return statusCode;
5378}
5379
5380/**
5381 * \brief Send a DELBA Indication Action Frame to peer
5382 *
5383 * \sa limSendDelBAInd
5384 *
5385 * \param pMac The global tpAniSirGlobal object
5386 *
5387 * \param peerMacAddr MAC Address of peer
5388 *
5389 * \param reasonCode Reason for the DELBA notification
5390 *
5391 * \param pBAParameterSet The DELBA Parameter Set.
5392 * This identifies the TID for which the BA session is
5393 * being deleted.
5394 *
5395 * \return eSIR_SUCCESS if setup completes successfully
5396 * eSIR_FAILURE is some problem is encountered
5397 */
5398tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5399 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5400{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305401 tDot11fDelBAInd frmDelBAInd;
5402 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305404 tpSirMacMgmtHdr pMacHdr;
5405 tANI_U32 frameLen = 0, nStatus, nPayload;
5406 tSirRetStatus statusCode;
5407 eHalStatus halStatus;
5408 void *pPacket;
5409 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005410
5411 if(NULL == psessionEntry)
5412 {
5413 return eSIR_FAILURE;
5414 }
5415
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305416 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005417
5418 // Category - 3 (BA)
5419 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5420 // Action - 2 (DELBA)
5421 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5422
5423 // Fill the DELBA Parameter Set as provided by caller
5424 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5425 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5426
5427 // BA Starting Sequence Number
5428 // Fragment number will always be zero
5429 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5430
5431 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5432
5433 if( DOT11F_FAILED( nStatus ))
5434 {
5435 limLog( pMac, LOGW,
5436 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005437 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 nStatus );
5439
5440 // We'll fall back on the worst case scenario:
5441 nPayload = sizeof( tDot11fDelBAInd );
5442 }
5443 else if( DOT11F_WARNED( nStatus ))
5444 {
5445 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005446 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005447 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 nStatus );
5449 }
5450
5451 // Add the MGMT header to frame length
5452 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5453
5454 // Allocate shared memory
5455 if( eHAL_STATUS_SUCCESS !=
5456 (halStatus = palPktAlloc( pMac->hHdd,
5457 HAL_TXRX_FRM_802_11_MGMT,
5458 (tANI_U16) frameLen,
5459 (void **) &pDelBAIndBuffer,
5460 (void **) &pPacket )))
5461 {
5462 // Log error
5463 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005464 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 frameLen,
5466 halStatus );
5467
5468 statusCode = eSIR_MEM_ALLOC_FAILED;
5469 goto returnAfterError;
5470 }
5471
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305472 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005473
5474 // Copy necessary info to BD
5475 if( eSIR_SUCCESS !=
5476 (statusCode = limPopulateMacHeader( pMac,
5477 pDelBAIndBuffer,
5478 SIR_MAC_MGMT_FRAME,
5479 SIR_MAC_MGMT_ACTION,
5480 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5481 goto returnAfterError;
5482
5483 // Update A3 with the BSSID
5484 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5485
5486 #if 0
5487 cfgLen = SIR_MAC_ADDR_LENGTH;
5488 if( eSIR_SUCCESS != cfgGetStr( pMac,
5489 WNI_CFG_BSSID,
5490 (tANI_U8 *) pMacHdr->bssId,
5491 &cfgLen ))
5492 {
5493 limLog( pMac, LOGP,
5494 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005495 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005496
5497 // FIXME - Need to convert to tSirRetStatus
5498 statusCode = eSIR_FAILURE;
5499 goto returnAfterError;
5500 }
5501 #endif //TO SUPPORT BT-AMP
5502 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5503
Chet Lanctot186b5732013-03-18 10:26:30 -07005504#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005505 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005506#endif
5507
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 // Now, we're ready to "pack" the frames
5509 nStatus = dot11fPackDelBAInd( pMac,
5510 &frmDelBAInd,
5511 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5512 nPayload,
5513 &nPayload );
5514
5515 if( DOT11F_FAILED( nStatus ))
5516 {
5517 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005518 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 nStatus );
5520
5521 // FIXME - Need to convert to tSirRetStatus
5522 statusCode = eSIR_FAILURE;
5523 goto returnAfterError;
5524 }
5525 else if( DOT11F_WARNED( nStatus ))
5526 {
5527 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005528 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5529 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 }
5531
5532 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005533 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5535
5536 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5538 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 )
5540 {
5541 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5542 }
5543
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305544 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5545 psessionEntry->peSessionId,
5546 pMacHdr->fc.subType));
5547 halStatus = halTxFrame( pMac,
5548 pPacket,
5549 (tANI_U16) frameLen,
5550 HAL_TXRX_FRM_802_11_MGMT,
5551 ANI_TXDIR_TODS,
5552 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5553 limTxComplete,
5554 pDelBAIndBuffer, txFlag );
5555 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5556 psessionEntry->peSessionId,
5557 halStatus));
5558 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005560 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 statusCode = eSIR_FAILURE;
5562 //Pkt will be freed up by the callback
5563 return statusCode;
5564 }
5565 else
5566 return eSIR_SUCCESS;
5567
5568 returnAfterError:
5569
5570 // Release buffer, if allocated
5571 if( NULL != pDelBAIndBuffer )
5572 palPktFree( pMac->hHdd,
5573 HAL_TXRX_FRM_802_11_MGMT,
5574 (void *) pDelBAIndBuffer,
5575 (void *) pPacket );
5576
5577 return statusCode;
5578}
5579
5580#if defined WLAN_FEATURE_VOWIFI
5581
5582/**
5583 * \brief Send a Neighbor Report Request Action frame
5584 *
5585 *
5586 * \param pMac Pointer to the global MAC structure
5587 *
5588 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5589 *
5590 * \param peer mac address of peer station.
5591 *
5592 * \param psessionEntry address of session entry.
5593 *
5594 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5595 *
5596 *
5597 */
5598
5599tSirRetStatus
5600limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5601 tpSirMacNeighborReportReq pNeighborReq,
5602 tSirMacAddr peer,
5603 tpPESession psessionEntry
5604 )
5605{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305606 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 tDot11fNeighborReportRequest frm;
5608 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305609 tpSirMacMgmtHdr pMacHdr;
5610 tANI_U32 nBytes, nPayload, nStatus;
5611 void *pPacket;
5612 eHalStatus halstatus;
5613 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005614
5615 if ( psessionEntry == NULL )
5616 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005617 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 return eSIR_FAILURE;
5619 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305620 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005621
5622 frm.Category.category = SIR_MAC_ACTION_RRM;
5623 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5624 frm.DialogToken.token = pNeighborReq->dialogToken;
5625
5626
5627 if( pNeighborReq->ssid_present )
5628 {
5629 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5630 }
5631
5632 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5633 if ( DOT11F_FAILED( nStatus ) )
5634 {
5635 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005636 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 nStatus );
5638 // We'll fall back on the worst case scenario:
5639 nPayload = sizeof( tDot11fNeighborReportRequest );
5640 }
5641 else if ( DOT11F_WARNED( nStatus ) )
5642 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005643 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005645 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 }
5647
5648 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5649
5650 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5651 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5652 {
5653 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005654 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 return eSIR_FAILURE;
5656 }
5657
5658 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305659 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005660
5661 // Copy necessary info to BD
5662 if( eSIR_SUCCESS !=
5663 (statusCode = limPopulateMacHeader( pMac,
5664 pFrame,
5665 SIR_MAC_MGMT_FRAME,
5666 SIR_MAC_MGMT_ACTION,
5667 peer, psessionEntry->selfMacAddr)))
5668 goto returnAfterError;
5669
5670 // Update A3 with the BSSID
5671 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5672
5673 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5674
Chet Lanctot186b5732013-03-18 10:26:30 -07005675#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005676 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005677#endif
5678
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 // Now, we're ready to "pack" the frames
5680 nStatus = dot11fPackNeighborReportRequest( pMac,
5681 &frm,
5682 pFrame + sizeof( tSirMacMgmtHdr ),
5683 nPayload,
5684 &nPayload );
5685
5686 if( DOT11F_FAILED( nStatus ))
5687 {
5688 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005689 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 nStatus );
5691
5692 // FIXME - Need to convert to tSirRetStatus
5693 statusCode = eSIR_FAILURE;
5694 goto returnAfterError;
5695 }
5696 else if( DOT11F_WARNED( nStatus ))
5697 {
5698 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005699 FL( "There were warnings while packing Neighbor Report "
5700 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 }
5702
5703 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005704 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 limPrintMacAddr( pMac, peer, LOGW );
5706
5707 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5709 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 )
5711 {
5712 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5713 }
5714
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305715 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5716 psessionEntry->peSessionId,
5717 pMacHdr->fc.subType));
5718 halstatus = halTxFrame( pMac,
5719 pPacket,
5720 (tANI_U16) nBytes,
5721 HAL_TXRX_FRM_802_11_MGMT,
5722 ANI_TXDIR_TODS,
5723 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5724 limTxComplete,
5725 pFrame, txFlag );
5726 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5727 psessionEntry->peSessionId,
5728 halstatus));
5729 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005731 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 statusCode = eSIR_FAILURE;
5733 //Pkt will be freed up by the callback
5734 return statusCode;
5735 }
5736 else
5737 return eSIR_SUCCESS;
5738
5739returnAfterError:
5740 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5741
5742 return statusCode;
5743} // End limSendNeighborReportRequestFrame.
5744
5745/**
5746 * \brief Send a Link Report Action frame
5747 *
5748 *
5749 * \param pMac Pointer to the global MAC structure
5750 *
5751 * \param pLinkReport Address of a tSirMacLinkReport
5752 *
5753 * \param peer mac address of peer station.
5754 *
5755 * \param psessionEntry address of session entry.
5756 *
5757 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5758 *
5759 *
5760 */
5761
5762tSirRetStatus
5763limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5764 tpSirMacLinkReport pLinkReport,
5765 tSirMacAddr peer,
5766 tpPESession psessionEntry
5767 )
5768{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305769 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 tDot11fLinkMeasurementReport frm;
5771 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305772 tpSirMacMgmtHdr pMacHdr;
5773 tANI_U32 nBytes, nPayload, nStatus;
5774 void *pPacket;
5775 eHalStatus halstatus;
5776 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005777
5778
5779 if ( psessionEntry == NULL )
5780 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005781 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 return eSIR_FAILURE;
5783 }
5784
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305785 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005786
5787 frm.Category.category = SIR_MAC_ACTION_RRM;
5788 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5789 frm.DialogToken.token = pLinkReport->dialogToken;
5790
5791
5792 //IEEE Std. 802.11 7.3.2.18. for the report element.
5793 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5794 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5795 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5796 //such case this way than changing the frame parser.
5797 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5798 frm.TPCEleLen.TPCLen = 2;
5799 frm.TxPower.txPower = pLinkReport->txPower;
5800 frm.LinkMargin.linkMargin = 0;
5801
5802 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5803 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5804 frm.RCPI.rcpi = pLinkReport->rcpi;
5805 frm.RSNI.rsni = pLinkReport->rsni;
5806
5807 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5808 if ( DOT11F_FAILED( nStatus ) )
5809 {
5810 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005811 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 nStatus );
5813 // We'll fall back on the worst case scenario:
5814 nPayload = sizeof( tDot11fLinkMeasurementReport );
5815 }
5816 else if ( DOT11F_WARNED( nStatus ) )
5817 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005818 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005820 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 }
5822
5823 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5824
5825 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5826 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5827 {
5828 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005829 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 return eSIR_FAILURE;
5831 }
5832
5833 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305834 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005835
5836 // Copy necessary info to BD
5837 if( eSIR_SUCCESS !=
5838 (statusCode = limPopulateMacHeader( pMac,
5839 pFrame,
5840 SIR_MAC_MGMT_FRAME,
5841 SIR_MAC_MGMT_ACTION,
5842 peer, psessionEntry->selfMacAddr)))
5843 goto returnAfterError;
5844
5845 // Update A3 with the BSSID
5846 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5847
5848 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5849
Chet Lanctot186b5732013-03-18 10:26:30 -07005850#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005851 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005852#endif
5853
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 // Now, we're ready to "pack" the frames
5855 nStatus = dot11fPackLinkMeasurementReport( pMac,
5856 &frm,
5857 pFrame + sizeof( tSirMacMgmtHdr ),
5858 nPayload,
5859 &nPayload );
5860
5861 if( DOT11F_FAILED( nStatus ))
5862 {
5863 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005864 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 nStatus );
5866
5867 // FIXME - Need to convert to tSirRetStatus
5868 statusCode = eSIR_FAILURE;
5869 goto returnAfterError;
5870 }
5871 else if( DOT11F_WARNED( nStatus ))
5872 {
5873 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005874 FL( "There were warnings while packing Link Report (0x%08x)." ),
5875 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 }
5877
5878 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005879 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 limPrintMacAddr( pMac, peer, LOGW );
5881
5882 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5884 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 )
5886 {
5887 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5888 }
5889
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305890 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5891 psessionEntry->peSessionId,
5892 pMacHdr->fc.subType));
5893 halstatus = halTxFrame( pMac,
5894 pPacket,
5895 (tANI_U16) nBytes,
5896 HAL_TXRX_FRM_802_11_MGMT,
5897 ANI_TXDIR_TODS,
5898 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5899 limTxComplete,
5900 pFrame, txFlag );
5901 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5902 psessionEntry->peSessionId,
5903 halstatus));
5904 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005906 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 statusCode = eSIR_FAILURE;
5908 //Pkt will be freed up by the callback
5909 return statusCode;
5910 }
5911 else
5912 return eSIR_SUCCESS;
5913
5914returnAfterError:
5915 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5916
5917 return statusCode;
5918} // End limSendLinkReportActionFrame.
5919
5920/**
5921 * \brief Send a Beacon Report Action frame
5922 *
5923 *
5924 * \param pMac Pointer to the global MAC structure
5925 *
5926 * \param dialog_token dialog token to be used in the action frame.
5927 *
5928 * \param num_report number of reports in pRRMReport.
5929 *
5930 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5931 *
5932 * \param peer mac address of peer station.
5933 *
5934 * \param psessionEntry address of session entry.
5935 *
5936 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5937 *
5938 *
5939 */
5940
5941tSirRetStatus
5942limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5943 tANI_U8 dialog_token,
5944 tANI_U8 num_report,
5945 tpSirMacRadioMeasureReport pRRMReport,
5946 tSirMacAddr peer,
5947 tpPESession psessionEntry
5948 )
5949{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305950 tSirRetStatus statusCode = eSIR_SUCCESS;
5951 tANI_U8 *pFrame;
5952 tpSirMacMgmtHdr pMacHdr;
5953 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305955 eHalStatus halstatus;
5956 tANI_U8 i;
5957 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005958
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005959 tDot11fRadioMeasurementReport *frm =
5960 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5961 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005962 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005963 return eSIR_FAILURE;
5964 }
5965
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 if ( psessionEntry == NULL )
5967 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005968 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005969 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 return eSIR_FAILURE;
5971 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305972 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005973
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005974 frm->Category.category = SIR_MAC_ACTION_RRM;
5975 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5976 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005977
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005978 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 -07005979
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005980 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005982 frm->MeasurementReport[i].type = pRRMReport[i].type;
5983 frm->MeasurementReport[i].token = pRRMReport[i].token;
5984 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 switch( pRRMReport[i].type )
5986 {
5987 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005988 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5989 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5990 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5991 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 break;
5993 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305994 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5995 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005996 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 break;
5998 }
5999 }
6000
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006001 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 if ( DOT11F_FAILED( nStatus ) )
6003 {
6004 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006005 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 nStatus );
6007 // We'll fall back on the worst case scenario:
6008 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006009 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 return eSIR_FAILURE;
6011 }
6012 else if ( DOT11F_WARNED( nStatus ) )
6013 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006014 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006016 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 }
6018
6019 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6020
6021 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6022 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6023 {
6024 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006025 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006026 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 return eSIR_FAILURE;
6028 }
6029
6030 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306031 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006032
6033 // Copy necessary info to BD
6034 if( eSIR_SUCCESS !=
6035 (statusCode = limPopulateMacHeader( pMac,
6036 pFrame,
6037 SIR_MAC_MGMT_FRAME,
6038 SIR_MAC_MGMT_ACTION,
6039 peer, psessionEntry->selfMacAddr)))
6040 goto returnAfterError;
6041
6042 // Update A3 with the BSSID
6043 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6044
6045 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6046
Chet Lanctot186b5732013-03-18 10:26:30 -07006047#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006048 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006049#endif
6050
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 // Now, we're ready to "pack" the frames
6052 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006053 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 pFrame + sizeof( tSirMacMgmtHdr ),
6055 nPayload,
6056 &nPayload );
6057
6058 if( DOT11F_FAILED( nStatus ))
6059 {
6060 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006061 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 nStatus );
6063
6064 // FIXME - Need to convert to tSirRetStatus
6065 statusCode = eSIR_FAILURE;
6066 goto returnAfterError;
6067 }
6068 else if( DOT11F_WARNED( nStatus ))
6069 {
6070 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006071 FL( "There were warnings while packing Radio "
6072 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 }
6074
6075 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006076 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 limPrintMacAddr( pMac, peer, LOGW );
6078
6079 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006080 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6081 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 )
6083 {
6084 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6085 }
6086
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306087 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6088 psessionEntry->peSessionId,
6089 pMacHdr->fc.subType));
6090 halstatus = halTxFrame( pMac,
6091 pPacket,
6092 (tANI_U16) nBytes,
6093 HAL_TXRX_FRM_802_11_MGMT,
6094 ANI_TXDIR_TODS,
6095 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6096 limTxComplete,
6097 pFrame, txFlag );
6098 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6099 psessionEntry->peSessionId,
6100 halstatus));
6101 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006103 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 statusCode = eSIR_FAILURE;
6105 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006106 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 return statusCode;
6108 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006109 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006110 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006113
6114returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006115 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 return statusCode;
6118} // End limSendBeaconReportActionFrame.
6119
6120#endif
6121
6122#ifdef WLAN_FEATURE_11W
6123/**
6124 * \brief Send SA query response action frame to peer
6125 *
6126 * \sa limSendSaQueryResponseFrame
6127 *
6128 *
6129 * \param pMac The global tpAniSirGlobal object
6130 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006131 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006133 * \param peer The Mac address of the AP to which this action frame is addressed
6134 *
6135 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 *
6137 * \return eSIR_SUCCESS if setup completes successfully
6138 * eSIR_FAILURE is some problem is encountered
6139 */
6140
Chet Lanctot186b5732013-03-18 10:26:30 -07006141tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006142tSirMacAddr peer,tpPESession psessionEntry)
6143{
6144
Chet Lanctot186b5732013-03-18 10:26:30 -07006145 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 tANI_U8 *pFrame;
6147 tSirRetStatus nSirStatus;
6148 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006149 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 void *pPacket;
6151 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306152 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006153
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306154 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006155 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6156 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 action: 0 --> SA query request action frame
6158 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006159 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6160 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006162 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006163
Chet Lanctot186b5732013-03-18 10:26:30 -07006164 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6165 if ( DOT11F_FAILED( nStatus ) )
6166 {
6167 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6168 "or a SA Query Response (0x%08x)."),
6169 nStatus );
6170 // We'll fall back on the worst case scenario:
6171 nPayload = sizeof( tDot11fSaQueryRsp );
6172 }
6173 else if ( DOT11F_WARNED( nStatus ) )
6174 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006175 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006176 "the packed size for an SA Query Response"
6177 " (0x%08x)."), nStatus );
6178 }
6179
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6181 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6182 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6183 {
6184 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006185 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 return eSIR_FAILURE;
6187 }
6188
6189 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306190 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006191
Chet Lanctot186b5732013-03-18 10:26:30 -07006192 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006193 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006194 pFrame,
6195 SIR_MAC_MGMT_FRAME,
6196 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006197 peer, psessionEntry->selfMacAddr );
6198 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006199 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006200
Chet Lanctot186b5732013-03-18 10:26:30 -07006201 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6203
Chet Lanctot186b5732013-03-18 10:26:30 -07006204 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006205
Chet Lanctot186b5732013-03-18 10:26:30 -07006206 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6207 // in the FC
6208 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006210 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 }
6212
Chet Lanctot186b5732013-03-18 10:26:30 -07006213 // Pack 11w SA query response frame
6214 nStatus = dot11fPackSaQueryRsp( pMac,
6215 &frm,
6216 pFrame + sizeof( tSirMacMgmtHdr ),
6217 nPayload,
6218 &nPayload );
6219
6220 if ( DOT11F_FAILED( nStatus ))
6221 {
6222 limLog( pMac, LOGE,
6223 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6224 nStatus );
6225 // FIXME - Need to convert to tSirRetStatus
6226 nSirStatus = eSIR_FAILURE;
6227 goto returnAfterError;
6228 }
6229 else if ( DOT11F_WARNED( nStatus ))
6230 {
6231 limLog( pMac, LOGW,
6232 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6233 nStatus);
6234 }
6235
6236 limLog( pMac, LOG1,
6237 FL( "Sending a SA Query Response to " ));
6238 limPrintMacAddr( pMac, peer, LOGW );
6239
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006240 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006241#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006242 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6243 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006244#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006245 )
6246 {
6247 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6248 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006249
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306250 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6251 psessionEntry->peSessionId,
6252 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006253 halstatus = halTxFrame( pMac,
6254 pPacket,
6255 (tANI_U16) nBytes,
6256 HAL_TXRX_FRM_802_11_MGMT,
6257 ANI_TXDIR_TODS,
6258 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6259 limTxComplete,
6260 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306261 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6262 psessionEntry->peSessionId,
6263 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006264 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006265 {
6266 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6267 nSirStatus = eSIR_FAILURE;
6268 //Pkt will be freed up by the callback
6269 return nSirStatus;
6270 }
6271 else {
6272 return eSIR_SUCCESS;
6273 }
6274
6275returnAfterError:
6276 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6277 return nSirStatus;
6278} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006279#endif