blob: 971d6c97f95268dbe5aa3866433f65c742dc66ac [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
Jeff Johnson295189b2012-06-20 16:38:30 -070041/**
42 * \file limSendManagementFrames.c
43 *
44 * \brief Code for preparing and sending 802.11 Management frames
45 *
46 * Copyright (C) 2005-2007 Airgo Networks, Incorporated
47 *
48 */
49
50#include "sirApi.h"
51#include "aniGlobal.h"
52#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include "cfgApi.h"
54#include "utilsApi.h"
55#include "limTypes.h"
56#include "limUtils.h"
57#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070058#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070059#include "dot11f.h"
60#include "limStaHashApi.h"
61#include "schApi.h"
62#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080063#include "limAssocUtils.h"
64#include "limFT.h"
65
Jeff Johnson295189b2012-06-20 16:38:30 -070066#if defined WLAN_FEATURE_VOWIFI
67#include "rrmApi.h"
68#endif
69
70#ifdef FEATURE_WLAN_CCX
71#include <limCcxparserApi.h>
72#endif
73#include "wlan_qct_wda.h"
74#ifdef WLAN_FEATURE_11W
75#include "dot11fdefs.h"
76#endif
77
78
79////////////////////////////////////////////////////////////////////////
80
Jeff Johnson295189b2012-06-20 16:38:30 -070081
82/**
83 *
84 * \brief This function is called by various LIM modules to prepare the
85 * 802.11 frame MAC header
86 *
87 *
88 * \param pMac Pointer to Global MAC structure
89 *
90 * \param pBD Pointer to the frame buffer that needs to be populate
91 *
92 * \param type Type of the frame
93 *
94 * \param subType Subtype of the frame
95 *
96 * \return eHalStatus
97 *
98 *
99 * The pFrameBuf argument points to the beginning of the frame buffer to
100 * which - a) The 802.11 MAC header is set b) Following this MAC header
101 * will be the MGMT frame payload The payload itself is populated by the
102 * caller API
103 *
104 *
105 */
106
107tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
108 tANI_U8* pBD,
109 tANI_U8 type,
110 tANI_U8 subType,
111 tSirMacAddr peerAddr ,tSirMacAddr selfMacAddr)
112{
113 tSirRetStatus statusCode = eSIR_SUCCESS;
114 tpSirMacMgmtHdr pMacHdr;
115
116 /// Prepare MAC management header
117 pMacHdr = (tpSirMacMgmtHdr) (pBD);
118
119 // Prepare FC
120 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
121 pMacHdr->fc.type = type;
122 pMacHdr->fc.subType = subType;
123
124 // Prepare Address 1
125 palCopyMemory( pMac->hHdd,
126 (tANI_U8 *) pMacHdr->da,
127 (tANI_U8 *) peerAddr,
128 sizeof( tSirMacAddr ));
129
130 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
132
133 // Prepare Address 3
134 palCopyMemory( pMac->hHdd,
135 (tANI_U8 *) pMacHdr->bssId,
136 (tANI_U8 *) peerAddr,
137 sizeof( tSirMacAddr ));
138 return statusCode;
139} /*** end limPopulateMacHeader() ***/
140
141/**
142 * \brief limSendProbeReqMgmtFrame
143 *
144 *
145 * \param pMac Pointer to Global MAC structure
146 *
147 * \param pSsid SSID to be sent in Probe Request frame
148 *
149 * \param bssid BSSID to be sent in Probe Request frame
150 *
151 * \param nProbeDelay probe delay to be used before sending Probe Request
152 * frame
153 *
154 * \param nChannelNum Channel # on which the Probe Request is going out
155 *
156 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
157 *
158 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
159 *
160 * This function is called by various LIM modules to send Probe Request frame
161 * during active scan/learn phase.
162 * Probe request is sent out in the following scenarios:
163 * --heartbeat failure: session needed
164 * --join req: session needed
165 * --foreground scan: no session
166 * --background scan: no session
167 * --schBeaconProcessing: to get EDCA parameters: session needed
168 *
169 *
170 */
171tSirRetStatus
172limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
173 tSirMacSSid *pSsid,
174 tSirMacAddr bssid,
175 tANI_U8 nChannelNum,
176 tSirMacAddr SelfMacAddr,
177 tANI_U32 dot11mode,
178 tANI_U32 nAdditionalIELen,
179 tANI_U8 *pAdditionalIE)
180{
181 tDot11fProbeRequest pr;
182 tANI_U32 nStatus, nBytes, nPayload;
183 tSirRetStatus nSirStatus;
184 tANI_U8 *pFrame;
185 void *pPacket;
186 eHalStatus halstatus;
187 tpPESession psessionEntry;
188 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 tANI_U8 txFlag = 0;
191
192#ifndef GEN4_SCAN
193 return eSIR_FAILURE;
194#endif
195
196#if defined ( ANI_DVT_DEBUG )
197 return eSIR_FAILURE;
198#endif
199
200 /*
201 * session context may or may not be present, when probe request needs to be sent out.
202 * following cases exist:
203 * --heartbeat failure: session needed
204 * --join req: session needed
205 * --foreground scan: no session
206 * --background scan: no session
207 * --schBeaconProcessing: to get EDCA parameters: session needed
208 * If session context does not exist, some IEs will be populated from CFGs,
209 * e.g. Supported and Extended rate set IEs
210 */
211 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
212
213 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
214 // and then hand it off to 'dot11fPackProbeRequest' (for
215 // serialization). We start by zero-initializing the structure:
216 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
217
218 // & delegating to assorted helpers:
219 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
220
Jeff Johnson295189b2012-06-20 16:38:30 -0700221 if( nAdditionalIELen && pAdditionalIE )
222 {
223 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
224 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700225 /* Don't include 11b rate only when device is doing P2P Search */
226 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
227 ( p2pIe != NULL ) &&
228 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
229 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
230 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
231 ( ( psessionEntry != NULL ) &&
232 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
233 )
234 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 {
236 /* In the below API pass channel number > 14, do that it fills only
237 * 11a rates in supported rates */
238 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
239 }
240 else
241 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 PopulateDot11fSuppRates( pMac, nChannelNum,
243 &pr.SuppRates,psessionEntry);
244
245 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
246 {
247 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
248 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700249 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700250
251#if defined WLAN_FEATURE_VOWIFI
252 //Table 7-14 in IEEE Std. 802.11k-2008 says
253 //DS params "can" be present in RRM is disabled and "is" present if
254 //RRM is enabled. It should be ok even if we add it into probe req when
255 //RRM is not enabled.
256 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
257 //Call RRM module to get the tx power for management used.
258 {
259 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
260 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
261 }
262#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700263
264 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700265 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700267 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700268 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700269 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700271 } else { //psessionEntry == NULL
272 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700274 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 }
276 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800277
278 /* Set channelbonding information as "disabled" when tunned to a 2.4 GHz channel */
279 if( nChannelNum <= SIR_11B_CHANNEL_END)
280 {
281 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
282 pr.HTCaps.shortGI40MHz = 0;
283 }
284
Jeff Johnsone7245742012-09-05 17:12:55 -0700285#ifdef WLAN_FEATURE_11AC
286 if (psessionEntry != NULL ) {
287 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
288 //Include HT Capability IE
289 if (psessionEntry->vhtCapability)
290 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700291 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
292 }
293 } else {
294 if (IS_DOT11_MODE_VHT(dot11mode))
295 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700296 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
297 }
298 }
299#endif
300
Jeff Johnson295189b2012-06-20 16:38:30 -0700301
302 // That's it-- now we pack it. First, how much space are we going to
303 // need?
304 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
305 if ( DOT11F_FAILED( nStatus ) )
306 {
307 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700308 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 // We'll fall back on the worst case scenario:
310 nPayload = sizeof( tDot11fProbeRequest );
311 }
312 else if ( DOT11F_WARNED( nStatus ) )
313 {
314 limLog( pMac, LOGW, FL("There were warnings while calculating"
315 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700316 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700317 }
318
319 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
320
321 // Ok-- try to allocate some memory:
322 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
323 ( tANI_U16 )nBytes, ( void** ) &pFrame,
324 ( void** ) &pPacket );
325 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
326 {
327 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700328 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 return eSIR_MEM_ALLOC_FAILED;
330 }
331
332 // Paranoia:
333 palZeroMemory( pMac->hHdd, pFrame, nBytes );
334
335 // Next, we fill out the buffer descriptor:
336 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
337 SIR_MAC_MGMT_PROBE_REQ, bssid ,SelfMacAddr);
338 if ( eSIR_SUCCESS != nSirStatus )
339 {
340 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700341 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700342 nSirStatus );
343 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
344 ( void* ) pFrame, ( void* ) pPacket );
345 return nSirStatus; // allocated!
346 }
347
348 // That done, pack the Probe Request:
349 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
350 sizeof( tSirMacMgmtHdr ),
351 nPayload, &nPayload );
352 if ( DOT11F_FAILED( nStatus ) )
353 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700354 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 nStatus );
356 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
357 return eSIR_FAILURE; // allocated!
358 }
359 else if ( DOT11F_WARNED( nStatus ) )
360 {
361 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700362 "robe Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 }
364
365 // Append any AddIE if present.
366 if( nAdditionalIELen )
367 {
368 palCopyMemory( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
369 pAdditionalIE, nAdditionalIELen );
370 nPayload += nAdditionalIELen;
371 }
372
373 /* If this probe request is sent during P2P Search State, then we need
374 * to send it at OFDM rate.
375 */
376 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
378 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530379 /* For unicast probe req mgmt from Join function
380 we don't set above variables. So we need to add
381 one more check whether it is pePersona is P2P_CLIENT or not */
382 || ( ( psessionEntry != NULL ) &&
383 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 )
385 {
386 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
387 }
388
389
390 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
391 HAL_TXRX_FRM_802_11_MGMT,
392 ANI_TXDIR_TODS,
393 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
394 limTxComplete, pFrame, txFlag );
395 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
396 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700397 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700398 //Pkt will be freed up by the callback
399 return eSIR_FAILURE;
400 }
401
402 return eSIR_SUCCESS;
403} // End limSendProbeReqMgmtFrame.
404
Jeff Johnson295189b2012-06-20 16:38:30 -0700405tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
406 tANI_U8* addIE, tANI_U16 *addnIELen,
407 tANI_U8 probeReqP2pIe)
408{
409 /* If Probe request doesn't have P2P IE, then take out P2P IE
410 from additional IE */
411 if(!probeReqP2pIe)
412 {
413 tANI_U8* tempbuf = NULL;
414 tANI_U16 tempLen = 0;
415 int left = *addnIELen;
416 v_U8_t *ptr = addIE;
417 v_U8_t elem_id, elem_len;
418
419 if(NULL == addIE)
420 {
421 PELOGE(limLog(pMac, LOGE,
422 FL(" NULL addIE pointer"));)
423 return eSIR_FAILURE;
424 }
425
426 if( (palAllocateMemory(pMac->hHdd, (void**)&tempbuf,
Jeff Johnson43971f52012-07-17 12:26:56 -0700427 left)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 {
429 PELOGE(limLog(pMac, LOGE,
430 FL("Unable to allocate memory to store addn IE"));)
431 return eSIR_MEM_ALLOC_FAILED;
432 }
433
434 while(left >= 2)
435 {
436 elem_id = ptr[0];
437 elem_len = ptr[1];
438 left -= 2;
439 if(elem_len > left)
440 {
441 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700442 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700443 elem_id,elem_len,left);
444 palFreeMemory(pMac->hHdd, tempbuf);
445 return eSIR_FAILURE;
446 }
447 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
448 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
449 {
450 palCopyMemory ( pMac->hHdd, tempbuf + tempLen, &ptr[0], elem_len + 2);
451 tempLen += (elem_len + 2);
452 }
453 left -= elem_len;
454 ptr += (elem_len + 2);
455 }
456 palCopyMemory ( pMac->hHdd, addIE, tempbuf, tempLen);
457 *addnIELen = tempLen;
458 palFreeMemory(pMac->hHdd, tempbuf);
459 }
460 return eSIR_SUCCESS;
461}
Jeff Johnson295189b2012-06-20 16:38:30 -0700462
463void
464limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
465 tSirMacAddr peerMacAddr,
466 tpAniSSID pSsid,
467 short nStaId,
468 tANI_U8 nKeepAlive,
469 tpPESession psessionEntry,
470 tANI_U8 probeReqP2pIe)
471{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700472 tDot11fProbeResponse *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 tSirRetStatus nSirStatus;
474 tANI_U32 cfg, nPayload, nBytes, nStatus;
475 tpSirMacMgmtHdr pMacHdr;
476 tANI_U8 *pFrame;
477 void *pPacket;
478 eHalStatus halstatus;
479 tANI_U32 addnIEPresent;
480 tANI_U32 addnIE1Len=0;
481 tANI_U32 addnIE2Len=0;
482 tANI_U32 addnIE3Len=0;
483 tANI_U16 totalAddnIeLen = 0;
484 tANI_U32 wpsApEnable=0, tmp;
485 tANI_U8 txFlag = 0;
486 tANI_U8 *addIE = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 tANI_U8 *pP2pIe = NULL;
488 tANI_U8 noaLen = 0;
489 tANI_U8 total_noaLen = 0;
490 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
491 + SIR_P2P_IE_HEADER_LEN];
492 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
494 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
495 {
496 return; // in this case.
497 }
498
499 if(NULL == psessionEntry)
500 {
501 return;
502 }
503
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700504 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
505 (void **)&pFrm, sizeof(tDot11fProbeResponse)))
506 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700507 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700508 return;
509 }
510
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 // Fill out 'frm', after which we'll just hand the struct off to
512 // 'dot11fPackProbeResponse'.
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700513 palZeroMemory( pMac->hHdd, ( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700514
515 // Timestamp to be updated by TFP, below.
516
517 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
519 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700520 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 }
522 else
523 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800524 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
525 if (eSIR_SUCCESS != nSirStatus)
526 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700527 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800528 nSirStatus );
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +0530529 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800530 return;
531 }
532 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800533 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700534
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700535 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
536 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700538 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700539
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700540 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
541 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700542
Jeff Johnson295189b2012-06-20 16:38:30 -0700543
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
545 {
546 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
547 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700548 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 }
550 }
551 else
552 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800553 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700554 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800556 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700557
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800558 if (wpsApEnable)
559 {
560 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
561 }
562
563 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
564 {
565 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
566 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
567 }
568
569 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
570 {
571 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
572 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
573 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700575
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700576 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
577 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700578
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
580 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700581 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700582
583
584 // N.B. In earlier implementations, the RSN IE would be placed in
585 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
586 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700587 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700588
589 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700590 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700592 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700593 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700595#ifdef WLAN_FEATURE_11AC
596 if(psessionEntry->vhtCapability)
597 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700598 limLog( pMac, LOGW, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700599 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
600 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700601 // we do not support multi users yet
602 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700603 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700604 }
605#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700606
607 if ( psessionEntry->pLimStartBssReq )
608 {
609 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700610 &pFrm->WPA );
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 PopulateDot11fRSN( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700612 &pFrm->RSN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 }
614
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700615 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700616
617#if defined(FEATURE_WLAN_WAPI)
618 if( psessionEntry->pLimStartBssReq )
619 {
620 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700621 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 }
623
624#endif // defined(FEATURE_WLAN_WAPI)
625
626
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700627 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 if ( DOT11F_FAILED( nStatus ) )
629 {
630 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700631 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 nStatus );
633 // We'll fall back on the worst case scenario:
634 nPayload = sizeof( tDot11fProbeResponse );
635 }
636 else if ( DOT11F_WARNED( nStatus ) )
637 {
638 limLog( pMac, LOGW, FL("There were warnings while calculating"
639 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700640 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 }
642
643 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
644
645 addnIEPresent = false;
646
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 if( pMac->lim.gpLimRemainOnChanReq )
648 {
649 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
650 }
651 //Only use CFG for non-listen mode. This CFG is not working for concurrency
652 //In listening mode, probe rsp IEs is passed in the message from SME to PE
653 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 {
655
656 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
657 &addnIEPresent) != eSIR_SUCCESS)
658 {
659 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700660 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 return;
662 }
663 }
664
665 if (addnIEPresent)
666 {
667 if( (palAllocateMemory(pMac->hHdd, (void**)&addIE,
Jeff Johnson43971f52012-07-17 12:26:56 -0700668 WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3 )) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 {
670 PELOGE(limLog(pMac, LOGE,
671 FL("Unable to allocate memory to store addn IE"));)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700672 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 return;
674 }
675
676 //Probe rsp IE available
677 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
678 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
679 {
680 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
681 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700682 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 return;
684 }
685 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
686 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
687 {
688 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
689 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
690 &addnIE1Len) )
691 {
692 limLog(pMac, LOGP,
693 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
694 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700695 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 return;
697 }
698 }
699
700 //Probe rsp IE available
701 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
702 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
703 {
704 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
705 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700706 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 return;
708 }
709 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
710 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
711 {
712 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
713 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
714 &addnIE2Len) )
715 {
716 limLog(pMac, LOGP,
717 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
718 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700719 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 return;
721 }
722 }
723
724 //Probe rsp IE available
725 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
726 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
727 {
728 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
729 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700730 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 return;
732 }
733 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
734 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
735 {
736 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
737 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
738 &addIE[addnIE1Len + addnIE2Len],
739 &addnIE3Len) )
740 {
741 limLog(pMac, LOGP,
742 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
743 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700744 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 return;
746 }
747 }
748 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
749
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
751 {
752 limLog(pMac, LOGP,
753 FL("Unable to get final Additional IE for Probe Req"));
754 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700755 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 return;
757 }
758 nBytes = nBytes + totalAddnIeLen;
759
760 if (probeReqP2pIe)
761 {
762 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
763 if (pP2pIe != NULL)
764 {
765 //get NoA attribute stream P2P IE
766 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
767 if (noaLen != 0)
768 {
769 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
770 &noaStream[0], noaLen);
771 nBytes = nBytes + total_noaLen;
772 }
773 }
774 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 }
776
777 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
778 ( tANI_U16 )nBytes, ( void** ) &pFrame,
779 ( void** ) &pPacket );
780 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
781 {
782 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700783 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 if ( addIE != NULL )
785 {
786 palFreeMemory(pMac->hHdd, addIE);
787 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700788 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 return;
790 }
791
792 // Paranoia:
793 palZeroMemory( pMac->hHdd, pFrame, nBytes );
794
795 // Next, we fill out the buffer descriptor:
796 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
797 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
798 if ( eSIR_SUCCESS != nSirStatus )
799 {
800 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700801 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 nSirStatus );
803 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
804 ( void* ) pFrame, ( void* ) pPacket );
805 if ( addIE != NULL )
806 {
807 palFreeMemory(pMac->hHdd, addIE);
808 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700809 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 return;
811 }
812
813 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
814
815 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
816
817 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700818 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 nPayload, &nPayload );
820 if ( DOT11F_FAILED( nStatus ) )
821 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700822 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700823 nStatus );
824 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
825 if ( addIE != NULL )
826 {
827 palFreeMemory(pMac->hHdd, addIE);
828 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700829 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 return; // allocated!
831 }
832 else if ( DOT11F_WARNED( nStatus ) )
833 {
834 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700835 "robe Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 }
837
838 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
839 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
840
841 pMac->sys.probeRespond++;
842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 if( pMac->lim.gpLimRemainOnChanReq )
844 {
845 palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
846 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
847 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700848
849 if ( addnIEPresent )
850 {
851 if (palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson43971f52012-07-17 12:26:56 -0700852 &addIE[0], totalAddnIeLen) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700853 {
854 limLog(pMac, LOGP, FL("Additional Probe Rp IE request failed while Appending: %x"),halstatus);
855 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
856 ( void* ) pFrame, ( void* ) pPacket );
857 if ( addIE != NULL )
858 {
859 palFreeMemory(pMac->hHdd, addIE);
860 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700861 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 return;
863 }
864 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 if (noaLen != 0)
866 {
867 if (palCopyMemory ( pMac->hHdd, &pFrame[nBytes - (total_noaLen)],
Jeff Johnson43971f52012-07-17 12:26:56 -0700868 &noaIe[0], total_noaLen) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 {
870 limLog(pMac, LOGE,
871 FL("Not able to insert NoA because of length constraint"));
872 }
873 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700874
875 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
877 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 )
879 {
880 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
881 }
882
883 // Queue Probe Response frame in high priority WQ
884 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
885 ( tANI_U16 ) nBytes,
886 HAL_TXRX_FRM_802_11_MGMT,
887 ANI_TXDIR_TODS,
888 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
889 limTxComplete, pFrame, txFlag );
890 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
891 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700892 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 //Pkt will be freed up by the callback
894 }
895
896 if ( addIE != NULL )
897 {
898 palFreeMemory(pMac->hHdd, addIE);
899 }
900
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700901 palFreeMemory(pMac->hHdd, pFrm);
902 return;
903
904
Jeff Johnson295189b2012-06-20 16:38:30 -0700905} // End limSendProbeRspMgmtFrame.
906
907void
908limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
909 tSirMacAddr peerMacAddr,
910 tSirAddtsReqInfo *pAddTS,
911 tpPESession psessionEntry)
912{
913 tANI_U16 i;
914 tANI_U8 *pFrame;
915 tSirRetStatus nSirStatus;
916 tDot11fAddTSRequest AddTSReq;
917 tDot11fWMMAddTSRequest WMMAddTSReq;
918 tANI_U32 nPayload, nBytes, nStatus;
919 tpSirMacMgmtHdr pMacHdr;
920 void *pPacket;
921#ifdef FEATURE_WLAN_CCX
922 tANI_U32 phyMode;
923#endif
924 eHalStatus halstatus;
925 tANI_U8 txFlag = 0;
926
927 if(NULL == psessionEntry)
928 {
929 return;
930 }
931
932 if ( ! pAddTS->wmeTspecPresent )
933 {
934 palZeroMemory( pMac->hHdd, ( tANI_U8* )&AddTSReq, sizeof( AddTSReq ) );
935
936 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
937 AddTSReq.DialogToken.token = pAddTS->dialogToken;
938 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
939 if ( pAddTS->lleTspecPresent )
940 {
941 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
942 }
943 else
944 {
945 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
946 }
947
948 if ( pAddTS->lleTspecPresent )
949 {
950 AddTSReq.num_WMMTCLAS = 0;
951 AddTSReq.num_TCLAS = pAddTS->numTclas;
952 for ( i = 0; i < pAddTS->numTclas; ++i)
953 {
954 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
955 &AddTSReq.TCLAS[i] );
956 }
957 }
958 else
959 {
960 AddTSReq.num_TCLAS = 0;
961 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
962 for ( i = 0; i < pAddTS->numTclas; ++i)
963 {
964 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
965 &AddTSReq.WMMTCLAS[i] );
966 }
967 }
968
969 if ( pAddTS->tclasProcPresent )
970 {
971 if ( pAddTS->lleTspecPresent )
972 {
973 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
974 AddTSReq.TCLASSPROC.present = 1;
975 }
976 else
977 {
978 AddTSReq.WMMTCLASPROC.version = 1;
979 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
980 AddTSReq.WMMTCLASPROC.present = 1;
981 }
982 }
983
984 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
985 if ( DOT11F_FAILED( nStatus ) )
986 {
987 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700988 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 nStatus );
990 // We'll fall back on the worst case scenario:
991 nPayload = sizeof( tDot11fAddTSRequest );
992 }
993 else if ( DOT11F_WARNED( nStatus ) )
994 {
995 limLog( pMac, LOGW, FL("There were warnings while calculating"
996 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700997 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 }
999 }
1000 else
1001 {
1002 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ) );
1003
1004 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1005 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1006 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1007
1008 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1009 WMMAddTSReq.StatusCode.statusCode = 0;
1010
1011 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1012#ifdef FEATURE_WLAN_CCX
1013 limGetPhyMode(pMac, &phyMode, psessionEntry);
1014
1015 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1016 {
1017 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1018 }
1019 else
1020 {
1021 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1022 }
1023 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1024#endif
1025 // fillWmeTspecIE
1026
1027 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1028 if ( DOT11F_FAILED( nStatus ) )
1029 {
1030 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001031 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 nStatus );
1033 // We'll fall back on the worst case scenario:
1034 nPayload = sizeof( tDot11fAddTSRequest );
1035 }
1036 else if ( DOT11F_WARNED( nStatus ) )
1037 {
1038 limLog( pMac, LOGW, FL("There were warnings while calculating"
1039 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001040 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 }
1042 }
1043
1044 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1045
1046 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1047 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1048 ( void** ) &pPacket );
1049 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1050 {
1051 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001052 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 return;
1054 }
1055
1056 // Paranoia:
1057 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1058
1059 // Next, we fill out the buffer descriptor:
1060 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1061 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1062 if ( eSIR_SUCCESS != nSirStatus )
1063 {
1064 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001065 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 nSirStatus );
1067 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1068 ( void* ) pFrame, ( void* ) pPacket );
1069 return;
1070 }
1071
1072 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1073
1074 #if 0
1075 cfgLen = SIR_MAC_ADDR_LENGTH;
1076 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1077 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1078 {
1079 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001080 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1082 ( void* ) pFrame, ( void* ) pPacket );
1083 return;
1084 }
1085 #endif //TO SUPPORT BT-AMP
1086
1087 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1088
Chet Lanctot186b5732013-03-18 10:26:30 -07001089#ifdef WLAN_FEATURE_11W
1090 if ( psessionEntry->limRmfEnabled )
1091 {
1092 pMacHdr->fc.wep = 1;
1093 }
1094#endif
1095
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 // That done, pack the struct:
1097 if ( ! pAddTS->wmeTspecPresent )
1098 {
1099 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1100 pFrame + sizeof(tSirMacMgmtHdr),
1101 nPayload, &nPayload );
1102 if ( DOT11F_FAILED( nStatus ) )
1103 {
1104 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001105 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 nStatus );
1107 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1108 return; // allocated!
1109 }
1110 else if ( DOT11F_WARNED( nStatus ) )
1111 {
1112 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001113 "an Add TS Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 }
1115 }
1116 else
1117 {
1118 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1119 pFrame + sizeof(tSirMacMgmtHdr),
1120 nPayload, &nPayload );
1121 if ( DOT11F_FAILED( nStatus ) )
1122 {
1123 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001124 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 nStatus );
1126 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1127 return; // allocated!
1128 }
1129 else if ( DOT11F_WARNED( nStatus ) )
1130 {
1131 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001132 "a WMM Add TS Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 }
1134 }
1135
1136 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1137 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1138
1139 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1141 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 )
1143 {
1144 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1145 }
1146
1147 // Queue Addts Response frame in high priority WQ
1148 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1149 HAL_TXRX_FRM_802_11_MGMT,
1150 ANI_TXDIR_TODS,
1151 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1152 limTxComplete, pFrame, txFlag );
1153 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1154 {
1155 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001156 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 //Pkt will be freed up by the callback
1158 }
1159
1160} // End limSendAddtsReqActionFrame.
1161
Jeff Johnson295189b2012-06-20 16:38:30 -07001162
1163
1164void
1165limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1166 tANI_U16 statusCode,
1167 tANI_U16 aid,
1168 tSirMacAddr peerMacAddr,
1169 tANI_U8 subType,
1170 tpDphHashNode pSta,tpPESession psessionEntry)
1171{
1172 static tDot11fAssocResponse frm;
1173 tANI_U8 *pFrame, *macAddr;
1174 tpSirMacMgmtHdr pMacHdr;
1175 tSirRetStatus nSirStatus;
1176 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1177 tHalBitVal qosMode, wmeMode;
1178 tANI_U32 nPayload, nBytes, nStatus;
1179 void *pPacket;
1180 eHalStatus halstatus;
1181 tUpdateBeaconParams beaconParams;
1182 tANI_U8 txFlag = 0;
1183 tANI_U32 addnIEPresent = false;
1184 tANI_U32 addnIELen=0;
1185 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1186 tpSirAssocReq pAssocReq = NULL;
1187
1188 if(NULL == psessionEntry)
1189 {
1190 return;
1191 }
1192
1193 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
1194
1195 limGetQosMode(psessionEntry, &qosMode);
1196 limGetWmeMode(psessionEntry, &wmeMode);
1197
1198 // An Add TS IE is added only if the AP supports it and the requesting
1199 // STA sent a traffic spec.
1200 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1201
1202 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1203
1204 frm.Status.status = statusCode;
1205
1206 frm.AID.associd = aid | LIM_AID_MASK;
1207
1208 if ( NULL == pSta )
1209 {
1210 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1211 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1212 }
1213 else
1214 {
1215 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1216 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1217 }
1218
Jeff Johnson295189b2012-06-20 16:38:30 -07001219 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1220 {
1221 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1222 {
1223 pAssocReq =
1224 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1226 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1227 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 }
1230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001231
1232 if ( NULL != pSta )
1233 {
1234 if ( eHAL_SET == qosMode )
1235 {
1236 if ( pSta->lleEnabled )
1237 {
1238 lleMode = 1;
1239 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1240 {
1241 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1242
1243// FramesToDo:...
1244// if ( fAddTS )
1245// {
1246// tANI_U8 *pAf = pBody;
1247// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1248// tANI_U32 tlen;
1249// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1250// &tlen, bufLen - frameLen);
1251// } // End if on Add TS.
1252 }
1253 } // End if on .11e enabled in 'pSta'.
1254 } // End if on QOS Mode on.
1255
1256 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1257 {
1258 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1259 {
1260
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001262
1263 if ( pSta->wsmEnabled )
1264 {
1265 PopulateDot11fWMMCaps(&frm.WMMCaps );
1266 }
1267 }
1268 }
1269
1270 if ( pSta->aniPeer )
1271 {
1272 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1273 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1274 {
1275 edcaInclude = 1;
1276 }
1277
1278 } // End if on Airgo peer.
1279
1280 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001281 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001283 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001286
1287#ifdef WLAN_FEATURE_11AC
1288 if( pSta->mlmStaContext.vhtCapability &&
1289 psessionEntry->vhtCapability )
1290 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001291 limLog( pMac, LOGW, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001292 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1293 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001294 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001295 }
1296#endif
1297
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 } // End if on non-NULL 'pSta'.
1299
1300
1301 palZeroMemory( pMac->hHdd, ( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams) );
1302
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1304 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1305 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001307
1308 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1309 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1310
1311 beaconParams.bssIdx = psessionEntry->bssIdx;
1312
1313 //Send message to HAL about beacon parameter change.
1314 if(beaconParams.paramChangeBitmap)
1315 {
1316 schSetFixedBeaconFields(pMac,psessionEntry);
1317 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1318 }
1319
1320 // Allocate a buffer for this frame:
1321 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1322 if ( DOT11F_FAILED( nStatus ) )
1323 {
1324 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001325 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 nStatus );
1327 return;
1328 }
1329 else if ( DOT11F_WARNED( nStatus ) )
1330 {
1331 limLog( pMac, LOGW, FL("There were warnings while calculating"
1332 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001333 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001334 }
1335
1336 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1337
1338 if ( pAssocReq != NULL )
1339 {
1340 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1341 &addnIEPresent) != eSIR_SUCCESS)
1342 {
1343 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
1344 return;
1345 }
1346
1347 if (addnIEPresent)
1348 {
1349 //Assoc rsp IE available
1350 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1351 &addnIELen) != eSIR_SUCCESS)
1352 {
1353 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
1354 return;
1355 }
1356
1357 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1358 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1359 {
1360 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1361 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1362 {
1363 nBytes = nBytes + addnIELen;
1364 }
1365 }
1366 }
1367 }
1368
1369 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1370 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1371 ( void** ) &pPacket );
1372 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1373 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001374 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 return;
1376 }
1377
1378 // Paranoia:
1379 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1380
1381 // Next, we fill out the buffer descriptor:
1382 nSirStatus = limPopulateMacHeader( pMac,
1383 pFrame,
1384 SIR_MAC_MGMT_FRAME,
1385 ( LIM_ASSOC == subType ) ?
1386 SIR_MAC_MGMT_ASSOC_RSP :
1387 SIR_MAC_MGMT_REASSOC_RSP,
1388 peerMacAddr,psessionEntry->selfMacAddr);
1389 if ( eSIR_SUCCESS != nSirStatus )
1390 {
1391 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001392 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 nSirStatus );
1394 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1395 ( void* ) pFrame, ( void* ) pPacket );
1396 return;
1397 }
1398
1399 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1400
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1402
1403 nStatus = dot11fPackAssocResponse( pMac, &frm,
1404 pFrame + sizeof( tSirMacMgmtHdr ),
1405 nPayload, &nPayload );
1406 if ( DOT11F_FAILED( nStatus ) )
1407 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001408 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 nStatus );
1410 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1411 ( void* ) pFrame, ( void* ) pPacket );
1412 return; // allocated!
1413 }
1414 else if ( DOT11F_WARNED( nStatus ) )
1415 {
1416 limLog( pMac, LOGW, FL("There were warnings while packing an "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001417 "Association Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 }
1419
1420 macAddr = pMacHdr->da;
1421
1422 if (subType == LIM_ASSOC)
1423 {
1424 PELOG1(limLog(pMac, LOG1,
1425 FL("*** Sending Assoc Resp status %d aid %d to "),
1426 statusCode, aid);)
1427 }
1428 else{
1429 PELOG1(limLog(pMac, LOG1,
1430 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1431 statusCode, aid);)
1432 }
1433 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1434
1435 if ( addnIEPresent )
1436 {
1437 if (palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson43971f52012-07-17 12:26:56 -07001438 &addIE[0], addnIELen ) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001440 limLog(pMac, LOGP, FL("Additional Assoc IEs request failed while Appending: %x"),halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1442 ( void* ) pFrame, ( void* ) pPacket );
1443 return;
1444 }
1445 }
1446
1447 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1449 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 )
1451 {
1452 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1453 }
1454
1455 /// Queue Association Response frame in high priority WQ
1456 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1457 HAL_TXRX_FRM_802_11_MGMT,
1458 ANI_TXDIR_TODS,
1459 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1460 limTxComplete, pFrame, txFlag );
1461 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1462 {
1463 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001464 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 nSirStatus);
1466
1467 //Pkt will be freed up by the callback
1468 }
1469
1470 // update the ANI peer station count
1471 //FIXME_PROTECTION : take care of different type of station
1472 // counter inside this function.
1473 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1474
1475} // End limSendAssocRspMgmtFrame.
1476
1477
1478
1479void
1480limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1481 tSirMacAddr peer,
1482 tANI_U16 nStatusCode,
1483 tSirAddtsReqInfo *pAddTS,
1484 tSirMacScheduleIE *pSchedule,
1485 tpPESession psessionEntry)
1486{
1487 tANI_U8 *pFrame;
1488 tpSirMacMgmtHdr pMacHdr;
1489 tDot11fAddTSResponse AddTSRsp;
1490 tDot11fWMMAddTSResponse WMMAddTSRsp;
1491 tSirRetStatus nSirStatus;
1492 tANI_U32 i, nBytes, nPayload, nStatus;
1493 void *pPacket;
1494 eHalStatus halstatus;
1495 tANI_U8 txFlag = 0;
1496
1497 if(NULL == psessionEntry)
1498 {
1499 return;
1500 }
1501
1502 if ( ! pAddTS->wmeTspecPresent )
1503 {
1504 palZeroMemory( pMac->hHdd, ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ) );
1505
1506 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1507 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1508 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1509 AddTSRsp.Status.status = nStatusCode;
1510
1511 // The TsDelay information element is only filled in for a specific
1512 // status code:
1513 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1514 {
1515 if ( pAddTS->wsmTspecPresent )
1516 {
1517 AddTSRsp.WMMTSDelay.version = 1;
1518 AddTSRsp.WMMTSDelay.delay = 10;
1519 AddTSRsp.WMMTSDelay.present = 1;
1520 }
1521 else
1522 {
1523 AddTSRsp.TSDelay.delay = 10;
1524 AddTSRsp.TSDelay.present = 1;
1525 }
1526 }
1527
1528 if ( pAddTS->wsmTspecPresent )
1529 {
1530 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1531 }
1532 else
1533 {
1534 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1535 }
1536
1537 if ( pAddTS->wsmTspecPresent )
1538 {
1539 AddTSRsp.num_WMMTCLAS = 0;
1540 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1541 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1542 {
1543 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1544 &AddTSRsp.TCLAS[i] );
1545 }
1546 }
1547 else
1548 {
1549 AddTSRsp.num_TCLAS = 0;
1550 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1551 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1552 {
1553 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1554 &AddTSRsp.WMMTCLAS[i] );
1555 }
1556 }
1557
1558 if ( pAddTS->tclasProcPresent )
1559 {
1560 if ( pAddTS->wsmTspecPresent )
1561 {
1562 AddTSRsp.WMMTCLASPROC.version = 1;
1563 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1564 AddTSRsp.WMMTCLASPROC.present = 1;
1565 }
1566 else
1567 {
1568 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1569 AddTSRsp.TCLASSPROC.present = 1;
1570 }
1571 }
1572
1573 // schedule element is included only if requested in the tspec and we are
1574 // using hcca (or both edca and hcca)
1575 // 11e-D8.0 is inconsistent on whether the schedule element is included
1576 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1577 // pg 46, line 17-18 says something else. So just include it and let the
1578 // sta figure it out
1579 if ((pSchedule != NULL) &&
1580 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1581 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1582 {
1583 if ( pAddTS->wsmTspecPresent )
1584 {
1585 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1586 }
1587 else
1588 {
1589 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1590 }
1591 }
1592
1593 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1594 if ( DOT11F_FAILED( nStatus ) )
1595 {
1596 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001597 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 nStatus );
1599 // We'll fall back on the worst case scenario:
1600 nPayload = sizeof( tDot11fAddTSResponse );
1601 }
1602 else if ( DOT11F_WARNED( nStatus ) )
1603 {
1604 limLog( pMac, LOGW, FL("There were warnings while calcula"
1605 "tingthe packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001606 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 }
1608 }
1609 else
1610 {
1611 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ) );
1612
1613 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1614 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1615 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1616 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1617
1618 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1619
1620 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1621 if ( DOT11F_FAILED( nStatus ) )
1622 {
1623 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001624 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 nStatus );
1626 // We'll fall back on the worst case scenario:
1627 nPayload = sizeof( tDot11fWMMAddTSResponse );
1628 }
1629 else if ( DOT11F_WARNED( nStatus ) )
1630 {
1631 limLog( pMac, LOGW, FL("There were warnings while calcula"
1632 "tingthe packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001633 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 }
1635 }
1636
1637 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1638
1639 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1640 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1641 {
1642 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001643 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001644 return;
1645 }
1646
1647 // Paranoia:
1648 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1649
1650 // Next, we fill out the buffer descriptor:
1651 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1652 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1653 if ( eSIR_SUCCESS != nSirStatus )
1654 {
1655 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001656 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 nSirStatus );
1658 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1659 return; // allocated!
1660 }
1661
1662 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1663
1664
1665 #if 0
1666 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1667 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1668 {
1669 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001670 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1672 return; // allocated!
1673 }
1674 #endif //TO SUPPORT BT-AMP
1675 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1676
Chet Lanctot186b5732013-03-18 10:26:30 -07001677#ifdef WLAN_FEATURE_11W
1678 if ( psessionEntry->limRmfEnabled )
1679 {
1680 pMacHdr->fc.wep = 1;
1681 }
1682#endif
1683
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 // That done, pack the struct:
1685 if ( ! pAddTS->wmeTspecPresent )
1686 {
1687 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1688 pFrame + sizeof( tSirMacMgmtHdr ),
1689 nPayload, &nPayload );
1690 if ( DOT11F_FAILED( nStatus ) )
1691 {
1692 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001693 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 nStatus );
1695 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1696 return;
1697 }
1698 else if ( DOT11F_WARNED( nStatus ) )
1699 {
1700 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001701 "an Add TS Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 }
1703 }
1704 else
1705 {
1706 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1707 pFrame + sizeof( tSirMacMgmtHdr ),
1708 nPayload, &nPayload );
1709 if ( DOT11F_FAILED( nStatus ) )
1710 {
1711 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001712 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 nStatus );
1714 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1715 return;
1716 }
1717 else if ( DOT11F_WARNED( nStatus ) )
1718 {
1719 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001720 "a WMM Add TS Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 }
1722 }
1723
1724 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1725 nStatusCode );
1726 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1727
1728 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1730 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 )
1732 {
1733 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1734 }
1735
1736 // Queue the frame in high priority WQ:
1737 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1738 HAL_TXRX_FRM_802_11_MGMT,
1739 ANI_TXDIR_TODS,
1740 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1741 limTxComplete, pFrame, txFlag );
1742 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1743 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001744 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 nSirStatus );
1746 //Pkt will be freed up by the callback
1747 }
1748
1749} // End limSendAddtsRspActionFrame.
1750
1751void
1752limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1753 tSirMacAddr peer,
1754 tANI_U8 wmmTspecPresent,
1755 tSirMacTSInfo *pTsinfo,
1756 tSirMacTspecIE *pTspecIe,
1757 tpPESession psessionEntry)
1758{
1759 tANI_U8 *pFrame;
1760 tpSirMacMgmtHdr pMacHdr;
1761 tDot11fDelTS DelTS;
1762 tDot11fWMMDelTS WMMDelTS;
1763 tSirRetStatus nSirStatus;
1764 tANI_U32 nBytes, nPayload, nStatus;
1765 void *pPacket;
1766 eHalStatus halstatus;
1767 tANI_U8 txFlag = 0;
1768
1769 if(NULL == psessionEntry)
1770 {
1771 return;
1772 }
1773
1774 if ( ! wmmTspecPresent )
1775 {
1776 palZeroMemory( pMac->hHdd, ( tANI_U8* )&DelTS, sizeof( DelTS ) );
1777
1778 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1779 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1780 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1781
1782 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1783 if ( DOT11F_FAILED( nStatus ) )
1784 {
1785 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001786 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 nStatus );
1788 // We'll fall back on the worst case scenario:
1789 nPayload = sizeof( tDot11fDelTS );
1790 }
1791 else if ( DOT11F_WARNED( nStatus ) )
1792 {
1793 limLog( pMac, LOGW, FL("There were warnings while calcula"
1794 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001795 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 }
1797 }
1798 else
1799 {
1800 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ) );
1801
1802 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1803 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1804 WMMDelTS.DialogToken.token = 0;
1805 WMMDelTS.StatusCode.statusCode = 0;
1806 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1807 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1808 if ( DOT11F_FAILED( nStatus ) )
1809 {
1810 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001811 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 nStatus );
1813 // We'll fall back on the worst case scenario:
1814 nPayload = sizeof( tDot11fDelTS );
1815 }
1816 else if ( DOT11F_WARNED( nStatus ) )
1817 {
1818 limLog( pMac, LOGW, FL("There were warnings while calcula"
1819 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001820 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 }
1822 }
1823
1824 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1825
1826 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1827 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1828 {
1829 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001830 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 return;
1832 }
1833
1834 // Paranoia:
1835 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1836
1837 // Next, we fill out the buffer descriptor:
1838 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1839 SIR_MAC_MGMT_ACTION, peer,
1840 psessionEntry->selfMacAddr);
1841 if ( eSIR_SUCCESS != nSirStatus )
1842 {
1843 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001844 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 nSirStatus );
1846 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1847 return; // allocated!
1848 }
1849
1850 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1851
1852 #if 0
1853
1854 cfgLen = SIR_MAC_ADDR_LENGTH;
1855 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1856 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1857 {
1858 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001859 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001860 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1861 return; // allocated!
1862 }
1863 #endif //TO SUPPORT BT-AMP
1864 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1865
Chet Lanctot186b5732013-03-18 10:26:30 -07001866#ifdef WLAN_FEATURE_11W
1867 if ( psessionEntry->limRmfEnabled )
1868 {
1869 pMacHdr->fc.wep = 1;
1870 }
1871#endif
1872
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 // That done, pack the struct:
1874 if ( !wmmTspecPresent )
1875 {
1876 nStatus = dot11fPackDelTS( pMac, &DelTS,
1877 pFrame + sizeof( tSirMacMgmtHdr ),
1878 nPayload, &nPayload );
1879 if ( DOT11F_FAILED( nStatus ) )
1880 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001881 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 nStatus );
1883 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1884 return; // allocated!
1885 }
1886 else if ( DOT11F_WARNED( nStatus ) )
1887 {
1888 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001889 "a Del TS frame (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 }
1891 }
1892 else
1893 {
1894 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1895 pFrame + sizeof( tSirMacMgmtHdr ),
1896 nPayload, &nPayload );
1897 if ( DOT11F_FAILED( nStatus ) )
1898 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001899 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 nStatus );
1901 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1902 return; // allocated!
1903 }
1904 else if ( DOT11F_WARNED( nStatus ) )
1905 {
1906 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001907 "a WMM Del TS frame (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 }
1909 }
1910
1911 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1912 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1913
1914 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1916 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 )
1918 {
1919 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1920 }
1921
1922 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1923 HAL_TXRX_FRM_802_11_MGMT,
1924 ANI_TXDIR_TODS,
1925 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1926 limTxComplete, pFrame, txFlag );
1927 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1928 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001929 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 nSirStatus );
1931 //Pkt will be freed up by the callback
1932 }
1933
1934} // End limSendDeltsReqActionFrame.
1935
1936void
1937limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1938 tLimMlmAssocReq *pMlmAssocReq,
1939 tpPESession psessionEntry)
1940{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001941 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 tANI_U16 caps;
1943 tANI_U8 *pFrame;
1944 tSirRetStatus nSirStatus;
1945 tLimMlmAssocCnf mlmAssocCnf;
1946 tANI_U32 nBytes, nPayload, nStatus;
1947 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1948 void *pPacket;
1949 eHalStatus halstatus;
1950 tANI_U16 nAddIELen;
1951 tANI_U8 *pAddIE;
1952 tANI_U8 *wpsIe = NULL;
1953#if defined WLAN_FEATURE_VOWIFI
1954 tANI_U8 PowerCapsPopulated = FALSE;
1955#endif
1956 tANI_U8 txFlag = 0;
1957
1958 if(NULL == psessionEntry)
1959 {
1960 return;
1961 }
1962
1963 if(NULL == psessionEntry->pLimJoinReq)
1964 {
1965 return;
1966 }
1967
1968 /* check this early to avoid unncessary operation */
1969 if(NULL == psessionEntry->pLimJoinReq)
1970 {
1971 return;
1972 }
1973 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
1974 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
1975
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001976 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1977 (void **)&pFrm, sizeof(tDot11fAssocRequest)))
1978 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001979 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limSendAssocReqMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001980 return;
1981 }
1982
1983
1984 palZeroMemory( pMac->hHdd, ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001985
1986 caps = pMlmAssocReq->capabilityInfo;
1987 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
1988 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
1989#if defined(FEATURE_WLAN_WAPI)
1990 /* CR: 262463 :
1991 According to WAPI standard:
1992 7.3.1.4 Capability Information field
1993 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
1994 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
1995 Reassociation management frames. */
1996 if ( psessionEntry->encryptType == eSIR_ED_WPI)
1997 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1998#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001999 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002000
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002001 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2002 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002004 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002005
2006 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2007 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2008
2009 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2010 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2011
2012 // We prefer .11e asociations:
2013 if ( fQosEnabled ) fWmeEnabled = false;
2014
2015 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2016 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2017
2018 if ( psessionEntry->lim11hEnable &&
2019 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2020 {
2021#if defined WLAN_FEATURE_VOWIFI
2022 PowerCapsPopulated = TRUE;
2023
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002024 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002025#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002026 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002027
2028 }
2029
2030#if defined WLAN_FEATURE_VOWIFI
2031 if( pMac->rrm.rrmPEContext.rrmEnable &&
2032 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2033 {
2034 if (PowerCapsPopulated == FALSE)
2035 {
2036 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002037 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 }
2039 }
2040#endif
2041
2042 if ( fQosEnabled &&
2043 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002044 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002045
2046 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002047 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002048
2049#if defined WLAN_FEATURE_VOWIFI
2050 if( pMac->rrm.rrmPEContext.rrmEnable &&
2051 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2052 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002053 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 }
2055#endif
2056 // The join request *should* contain zero or one of the WPA and RSN
2057 // IEs. The payload send along with the request is a
2058 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2059
2060 // typedef struct sSirRSNie
2061 // {
2062 // tANI_U16 length;
2063 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2064 // } tSirRSNie, *tpSirRSNie;
2065
2066 // So, we should be able to make the following two calls harmlessly,
2067 // since they do nothing if they don't find the given IE in the
2068 // bytestream with which they're provided.
2069
2070 // The net effect of this will be to faithfully transmit whatever
2071 // security IE is in the join request.
2072
2073 // *However*, if we're associating for the purpose of WPS
2074 // enrollment, and we've been configured to indicate that by
2075 // eliding the WPA or RSN IE, we just skip this:
2076 if( nAddIELen && pAddIE )
2077 {
2078 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2079 }
2080 if ( NULL == wpsIe )
2081 {
2082 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002083 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002085 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002086#if defined(FEATURE_WLAN_WAPI)
2087 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002088 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002089#endif // defined(FEATURE_WLAN_WAPI)
2090 }
2091
2092 // include WME EDCA IE as well
2093 if ( fWmeEnabled )
2094 {
2095 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2096 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002097 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 }
2099
2100 if ( fWsmEnabled &&
2101 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2102 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002103 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 }
2105 }
2106
2107 //Populate HT IEs, when operating in 11n or Taurus modes AND
2108 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002109 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 pMac->lim.htCapabilityPresentInBeacon)
2111 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002112 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002113#ifdef DISABLE_GF_FOR_INTEROP
2114
2115 /*
2116 * To resolve the interop problem with Broadcom AP,
2117 * where TQ STA could not pass traffic with GF enabled,
2118 * TQ STA will do Greenfield only with TQ AP, for
2119 * everybody else it will be turned off.
2120 */
2121
2122 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2123 {
2124 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002125 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 }
2127#endif
2128
2129 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002130#ifdef WLAN_FEATURE_11AC
2131 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002132 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002133 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002134 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002135 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2136 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002137 }
2138#endif
2139
Jeff Johnson295189b2012-06-20 16:38:30 -07002140
2141#if defined WLAN_FEATURE_VOWIFI_11R
2142 if (psessionEntry->pLimJoinReq->is11Rconnection)
2143 {
2144#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002145 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2147 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2148 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2149#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002150 PopulateMDIE( pMac, &pFrm->MobilityDomain, psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002151 }
2152 else
2153 {
2154 // No 11r IEs dont send any MDIE
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002155 limLog( pMac, LOG1, FL("mdie not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 }
2157#endif
2158
2159#ifdef FEATURE_WLAN_CCX
2160 // For CCX Associations fill the CCX IEs
2161 if (psessionEntry->isCCXconnection)
2162 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002163 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
2164 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 }
2166#endif
2167
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002168 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 if ( DOT11F_FAILED( nStatus ) )
2170 {
2171 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002172 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 nStatus );
2174 // We'll fall back on the worst case scenario:
2175 nPayload = sizeof( tDot11fAssocRequest );
2176 }
2177 else if ( DOT11F_WARNED( nStatus ) )
2178 {
2179 limLog( pMac, LOGW, FL("There were warnings while calculating"
2180 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002181 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 }
2183
2184 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2185
2186 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2187 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2188 ( void** ) &pPacket );
2189 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2190 {
2191 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002192 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002193
2194 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002195 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002196
2197
2198 /* Update PE session id*/
2199 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2200
2201 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2202
2203 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2204 ( void* ) pFrame, ( void* ) pPacket );
2205
2206 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2207 ( tANI_U32* ) &mlmAssocCnf);
2208
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002209 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 return;
2211 }
2212
2213 // Paranoia:
2214 palZeroMemory( pMac->hHdd, pFrame, nBytes );
2215
2216 // Next, we fill out the buffer descriptor:
2217 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2218 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2219 if ( eSIR_SUCCESS != nSirStatus )
2220 {
2221 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002222 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 nSirStatus );
2224 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002225 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 return;
2227 }
2228
2229
2230 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002231 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 sizeof(tSirMacMgmtHdr),
2233 nPayload, &nPayload );
2234 if ( DOT11F_FAILED( nStatus ) )
2235 {
2236 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002237 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 nStatus );
2239 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2240 ( void* ) pFrame, ( void* ) pPacket );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002241 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 return;
2243 }
2244 else if ( DOT11F_WARNED( nStatus ) )
2245 {
2246 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002247 "robe Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 }
2249
2250 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002251 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002252 nBytes );)
2253 // limPrintMacAddr( pMac, bssid, LOG1 );
2254
2255 if( psessionEntry->assocReq != NULL )
2256 {
2257 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2258 psessionEntry->assocReq = NULL;
2259 }
2260
2261 if( nAddIELen )
2262 {
2263 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2264 pAddIE,
2265 nAddIELen );
2266 nPayload += nAddIELen;
2267 }
2268
Jeff Johnson43971f52012-07-17 12:26:56 -07002269 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2270 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 {
2272 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2273 }
2274 else
2275 {
2276 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2277 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2278 psessionEntry->assocReqLen = nPayload;
2279 }
2280
2281 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2283 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 )
2285 {
2286 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2287 }
2288
Ganesh K08bce952012-12-13 15:04:41 -08002289 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2290 {
2291 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2292 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002293
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2295 HAL_TXRX_FRM_802_11_MGMT,
2296 ANI_TXDIR_TODS,
2297 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2298 limTxComplete, pFrame, txFlag );
2299 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2300 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002301 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 halstatus );
2303 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002304 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 return;
2306 }
2307
2308 // Free up buffer allocated for mlmAssocReq
2309 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmAssocReq );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002310 palFreeMemory(pMac->hHdd, pFrm);
2311 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002312} // End limSendAssocReqMgmtFrame
2313
2314
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002315#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002316/*------------------------------------------------------------------------------------
2317 *
2318 * Send Reassoc Req with FTIEs.
2319 *
2320 *-----------------------------------------------------------------------------------
2321 */
2322void
2323limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2324 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2325{
2326 static tDot11fReAssocRequest frm;
2327 tANI_U16 caps;
2328 tANI_U8 *pFrame;
2329 tSirRetStatus nSirStatus;
2330 tANI_U32 nBytes, nPayload, nStatus;
2331 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2332 void *pPacket;
2333 eHalStatus halstatus;
2334#if defined WLAN_FEATURE_VOWIFI
2335 tANI_U8 PowerCapsPopulated = FALSE;
2336#endif
2337 tANI_U16 ft_ies_length = 0;
2338 tANI_U8 *pBody;
2339 tANI_U16 nAddIELen;
2340 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002341#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002342 tANI_U8 *wpsIe = NULL;
2343#endif
2344 tANI_U8 txFlag = 0;
2345
2346 if (NULL == psessionEntry)
2347 {
2348 return;
2349 }
2350
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 /* check this early to avoid unncessary operation */
2352 if(NULL == psessionEntry->pLimReAssocReq)
2353 {
2354 return;
2355 }
2356 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2357 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002358 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2359 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002360
2361 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
2362
2363 caps = pMlmReassocReq->capabilityInfo;
2364 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2365 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2366#if defined(FEATURE_WLAN_WAPI)
2367 /* CR: 262463 :
2368 According to WAPI standard:
2369 7.3.1.4 Capability Information field
2370 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2371 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2372 Reassociation management frames. */
2373 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2374 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2375#endif
2376 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2377
2378 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2379
2380 // Get the old bssid of the older AP.
2381 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
2382 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2383
2384 PopulateDot11fSSID2( pMac, &frm.SSID );
2385 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2386 &frm.SuppRates,psessionEntry);
2387
2388 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2389 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2390
2391 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2392 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2393
2394 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2395 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2396
2397 if ( psessionEntry->lim11hEnable &&
2398 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2399 {
2400#if defined WLAN_FEATURE_VOWIFI
2401 PowerCapsPopulated = TRUE;
2402
2403 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2404 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2405#endif
2406 }
2407
2408#if defined WLAN_FEATURE_VOWIFI
2409 if( pMac->rrm.rrmPEContext.rrmEnable &&
2410 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2411 {
2412 if (PowerCapsPopulated == FALSE)
2413 {
2414 PowerCapsPopulated = TRUE;
2415 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2416 }
2417 }
2418#endif
2419
2420 if ( fQosEnabled &&
2421 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2422 {
2423 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2424 }
2425
2426 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2427 &frm.ExtSuppRates, psessionEntry );
2428
2429#if defined WLAN_FEATURE_VOWIFI
2430 if( pMac->rrm.rrmPEContext.rrmEnable &&
2431 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2432 {
2433 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2434 }
2435#endif
2436
2437 // Ideally this should be enabled for 11r also. But 11r does
2438 // not follow the usual norm of using the Opaque object
2439 // for rsnie and fties. Instead we just add
2440 // the rsnie and fties at the end of the pack routine for 11r.
2441 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002442#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 //
2444 // The join request *should* contain zero or one of the WPA and RSN
2445 // IEs. The payload send along with the request is a
2446 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2447
2448 // typedef struct sSirRSNie
2449 // {
2450 // tANI_U16 length;
2451 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2452 // } tSirRSNie, *tpSirRSNie;
2453
2454 // So, we should be able to make the following two calls harmlessly,
2455 // since they do nothing if they don't find the given IE in the
2456 // bytestream with which they're provided.
2457
2458 // The net effect of this will be to faithfully transmit whatever
2459 // security IE is in the join request.
2460
2461 // *However*, if we're associating for the purpose of WPS
2462 // enrollment, and we've been configured to indicate that by
2463 // eliding the WPA or RSN IE, we just skip this:
2464 if (!psessionEntry->is11Rconnection)
2465 {
2466 if( nAddIELen && pAddIE )
2467 {
2468 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2469 }
2470 if ( NULL == wpsIe )
2471 {
2472 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2473 &frm.RSNOpaque );
2474 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2475 &frm.WPAOpaque );
2476 }
2477
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002478#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 if(psessionEntry->pLimReAssocReq->cckmIE.length)
2480 {
2481 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2482 &frm.CCXCckmOpaque );
2483 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002484#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 }
2486
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002487#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002488 // For CCX Associations fill the CCX IEs
2489 if (psessionEntry->isCCXconnection)
2490 {
2491 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
2492 PopulateDot11fCCXVersion(&frm.CCXVersion);
2493 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002494#endif //FEATURE_WLAN_CCX
2495#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002496
2497 // include WME EDCA IE as well
2498 if ( fWmeEnabled )
2499 {
2500 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2501 {
2502 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2503 }
2504
2505 if ( fWsmEnabled &&
2506 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2507 {
2508 PopulateDot11fWMMCaps( &frm.WMMCaps );
2509 }
2510#ifdef FEATURE_WLAN_CCX
2511 if (psessionEntry->isCCXconnection)
2512 {
2513 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2514
2515 // Populate the TSRS IE if TSPEC is included in the reassoc request
2516 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2517 {
2518 tANI_U32 phyMode;
2519 tSirMacCCXTSRSIE tsrsIE;
2520 limGetPhyMode(pMac, &phyMode, psessionEntry);
2521
2522 tsrsIE.tsid = 0;
2523 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2524 {
2525 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2526 }
2527 else
2528 {
2529 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2530 }
2531 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2532 }
2533 }
2534#endif
2535 }
2536
Jeff Johnsone7245742012-09-05 17:12:55 -07002537 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 pMac->lim.htCapabilityPresentInBeacon)
2539 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002540 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 }
2542
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002543#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302544 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2545#if defined FEATURE_WLAN_CCX
2546 && !psessionEntry->isCCXconnection
2547#endif
2548 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002549 {
2550 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2551 }
2552#endif
2553
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2555 if ( DOT11F_FAILED( nStatus ) )
2556 {
2557 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002558 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 nStatus );
2560 // We'll fall back on the worst case scenario:
2561 nPayload = sizeof( tDot11fReAssocRequest );
2562 }
2563 else if ( DOT11F_WARNED( nStatus ) )
2564 {
2565 limLog( pMac, LOGW, FL("There were warnings while calculating"
2566 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002567 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 }
2569
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002570 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002571
2572#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002573 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2575#endif
2576
2577#if defined WLAN_FEATURE_VOWIFI_11R
2578 if (psessionEntry->is11Rconnection)
2579 {
2580 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2581 }
2582#endif
2583
2584 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2585 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2586 ( void** ) &pPacket );
2587 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2588 {
2589 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002590 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002592 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 goto end;
2594 }
2595
2596 // Paranoia:
2597 palZeroMemory( pMac->hHdd, pFrame, nBytes + ft_ies_length);
2598
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002599#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002600 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002601#endif
2602 // Next, we fill out the buffer descriptor:
2603 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2604 SIR_MAC_MGMT_REASSOC_REQ,
2605 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2606 if ( eSIR_SUCCESS != nSirStatus )
2607 {
2608 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002609 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 nSirStatus );
2611 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2612 goto end;
2613 }
2614
2615
2616 // That done, pack the ReAssoc Request:
2617 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2618 sizeof(tSirMacMgmtHdr),
2619 nPayload, &nPayload );
2620 if ( DOT11F_FAILED( nStatus ) )
2621 {
2622 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002623 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 nStatus );
2625 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2626 goto end;
2627 }
2628 else if ( DOT11F_WARNED( nStatus ) )
2629 {
2630 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002631 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 }
2633
2634 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002635 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 nBytes, nPayload );)
2637 if( psessionEntry->assocReq != NULL )
2638 {
2639 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2640 psessionEntry->assocReq = NULL;
2641 }
2642
2643 if( nAddIELen )
2644 {
2645 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2646 pAddIE,
2647 nAddIELen );
2648 nPayload += nAddIELen;
2649 }
2650
Jeff Johnson43971f52012-07-17 12:26:56 -07002651 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2652 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 {
2654 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002655 }
2656 else
2657 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2659 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2660 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002662
2663 if (psessionEntry->is11Rconnection)
2664 {
2665 {
2666 int i = 0;
2667
2668 pBody = pFrame + nBytes;
2669 for (i=0; i<ft_ies_length; i++)
2670 {
2671 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2672 pBody++;
2673 }
2674 }
2675 }
2676
2677#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002678 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2679 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 (tANI_U8 *)pFrame,
2681 (nBytes + ft_ies_length));)
2682#endif
2683
2684
2685 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2687 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 )
2689 {
2690 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2691 }
2692
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002693 if( NULL != psessionEntry->assocReq )
2694 {
2695 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2696 psessionEntry->assocReq = NULL;
2697 }
2698
2699 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2700 (ft_ies_length))) != eHAL_STATUS_SUCCESS )
2701 {
2702 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002703 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002704 }
2705 else
2706 {
2707 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2708 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2709 (ft_ies_length));
2710 psessionEntry->assocReqLen = (ft_ies_length);
2711 }
2712
2713
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2715 HAL_TXRX_FRM_802_11_MGMT,
2716 ANI_TXDIR_TODS,
2717 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2718 limTxComplete, pFrame, txFlag );
2719 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2720 {
2721 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002722 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 nSirStatus );
2724 //Pkt will be freed up by the callback
2725 goto end;
2726 }
2727
2728end:
2729 // Free up buffer allocated for mlmAssocReq
2730 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
2731 psessionEntry->pLimMlmReassocReq = NULL;
2732
2733}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002734
2735void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2736 tLimMlmReassocReq *pMlmReassocReq,
2737 tpPESession psessionEntry)
2738{
2739 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2740 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2741 if(NULL == pTmpMlmReassocReq)
2742 {
2743 if ( !HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pTmpMlmReassocReq, sizeof(tLimMlmReassocReq))) ) goto end;
2744 palZeroMemory(pMac->hHdd, pTmpMlmReassocReq, sizeof(tLimMlmReassocReq));
2745 palCopyMemory( pMac->hHdd, pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
2746 }
2747
2748 // Prepare and send Reassociation request frame
2749 // start reassoc timer.
2750 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2751 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002752 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002753 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2754 != TX_SUCCESS)
2755 {
2756 // Could not start reassoc failure timer.
2757 // Log error
2758 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002759 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002760 // Return Reassoc confirm with
2761 // Resources Unavailable
2762 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2763 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2764 goto end;
2765 }
2766
2767 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2768 return;
2769
2770end:
2771 // Free up buffer allocated for reassocReq
2772 if (pMlmReassocReq != NULL)
2773 {
2774 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
2775 pMlmReassocReq = NULL;
2776 }
2777 if (pTmpMlmReassocReq != NULL)
2778 {
2779 palFreeMemory( pMac->hHdd, (tANI_U8 *) pTmpMlmReassocReq);
2780 pTmpMlmReassocReq = NULL;
2781 }
2782 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2783 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2784 /* Update PE sessio Id*/
2785 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2786
2787 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2788}
2789
Jeff Johnson295189b2012-06-20 16:38:30 -07002790#endif /* WLAN_FEATURE_VOWIFI_11R */
2791
2792
2793void
2794limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2795 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2796{
2797 static tDot11fReAssocRequest frm;
2798 tANI_U16 caps;
2799 tANI_U8 *pFrame;
2800 tSirRetStatus nSirStatus;
2801 tANI_U32 nBytes, nPayload, nStatus;
2802 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2803 void *pPacket;
2804 eHalStatus halstatus;
2805 tANI_U16 nAddIELen;
2806 tANI_U8 *pAddIE;
2807 tANI_U8 *wpsIe = NULL;
2808 tANI_U8 txFlag = 0;
2809#if defined WLAN_FEATURE_VOWIFI
2810 tANI_U8 PowerCapsPopulated = FALSE;
2811#endif
2812
2813 if(NULL == psessionEntry)
2814 {
2815 return;
2816 }
2817
2818 /* check this early to avoid unncessary operation */
2819 if(NULL == psessionEntry->pLimReAssocReq)
2820 {
2821 return;
2822 }
2823 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2824 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2825
2826 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
2827
2828 caps = pMlmReassocReq->capabilityInfo;
2829 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2830 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2831#if defined(FEATURE_WLAN_WAPI)
2832 /* CR: 262463 :
2833 According to WAPI standard:
2834 7.3.1.4 Capability Information field
2835 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2836 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2837 Reassociation management frames. */
2838 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2839 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2840#endif
2841 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2842
2843 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2844
2845 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
2846 ( tANI_U8* )psessionEntry->bssId, 6 );
2847
2848 PopulateDot11fSSID2( pMac, &frm.SSID );
2849 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2850 &frm.SuppRates,psessionEntry);
2851
2852 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2853 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2854
2855 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2856 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2857
2858 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2859 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2860
2861
2862 if ( psessionEntry->lim11hEnable &&
2863 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2864 {
2865#if defined WLAN_FEATURE_VOWIFI
2866 PowerCapsPopulated = TRUE;
2867 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2868 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2869#endif
2870 }
2871
2872#if defined WLAN_FEATURE_VOWIFI
2873 if( pMac->rrm.rrmPEContext.rrmEnable &&
2874 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2875 {
2876 if (PowerCapsPopulated == FALSE)
2877 {
2878 PowerCapsPopulated = TRUE;
2879 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2880 }
2881 }
2882#endif
2883
2884 if ( fQosEnabled &&
2885 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2886 {
2887 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2888 }
2889
2890 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2891 &frm.ExtSuppRates, psessionEntry );
2892
2893#if defined WLAN_FEATURE_VOWIFI
2894 if( pMac->rrm.rrmPEContext.rrmEnable &&
2895 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2896 {
2897 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2898 }
2899#endif
2900 // The join request *should* contain zero or one of the WPA and RSN
2901 // IEs. The payload send along with the request is a
2902 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2903
2904 // typedef struct sSirRSNie
2905 // {
2906 // tANI_U16 length;
2907 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2908 // } tSirRSNie, *tpSirRSNie;
2909
2910 // So, we should be able to make the following two calls harmlessly,
2911 // since they do nothing if they don't find the given IE in the
2912 // bytestream with which they're provided.
2913
2914 // The net effect of this will be to faithfully transmit whatever
2915 // security IE is in the join request.
2916
2917 // *However*, if we're associating for the purpose of WPS
2918 // enrollment, and we've been configured to indicate that by
2919 // eliding the WPA or RSN IE, we just skip this:
2920 if( nAddIELen && pAddIE )
2921 {
2922 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2923 }
2924 if ( NULL == wpsIe )
2925 {
2926 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2927 &frm.RSNOpaque );
2928 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2929 &frm.WPAOpaque );
2930#if defined(FEATURE_WLAN_WAPI)
2931 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2932 &frm.WAPIOpaque );
2933#endif // defined(FEATURE_WLAN_WAPI)
2934 }
2935
2936 // include WME EDCA IE as well
2937 if ( fWmeEnabled )
2938 {
2939 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2940 {
2941 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2942 }
2943
2944 if ( fWsmEnabled &&
2945 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2946 {
2947 PopulateDot11fWMMCaps( &frm.WMMCaps );
2948 }
2949 }
2950
Jeff Johnsone7245742012-09-05 17:12:55 -07002951 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 pMac->lim.htCapabilityPresentInBeacon)
2953 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002954 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002956#ifdef WLAN_FEATURE_11AC
2957 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002958 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002959 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002960 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002961 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07002962 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002963 }
2964#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002965
2966 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2967 if ( DOT11F_FAILED( nStatus ) )
2968 {
2969 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002970 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 nStatus );
2972 // We'll fall back on the worst case scenario:
2973 nPayload = sizeof( tDot11fReAssocRequest );
2974 }
2975 else if ( DOT11F_WARNED( nStatus ) )
2976 {
2977 limLog( pMac, LOGW, FL("There were warnings while calculating"
2978 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002979 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 }
2981
2982 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2983
2984 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2985 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2986 ( void** ) &pPacket );
2987 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2988 {
2989 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002990 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002992 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 goto end;
2994 }
2995
2996 // Paranoia:
2997 palZeroMemory( pMac->hHdd, pFrame, nBytes );
2998
2999 // Next, we fill out the buffer descriptor:
3000 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3001 SIR_MAC_MGMT_REASSOC_REQ,
3002 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3003 if ( eSIR_SUCCESS != nSirStatus )
3004 {
3005 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003006 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 nSirStatus );
3008 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3009 goto end;
3010 }
3011
3012
3013 // That done, pack the Probe Request:
3014 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3015 sizeof(tSirMacMgmtHdr),
3016 nPayload, &nPayload );
3017 if ( DOT11F_FAILED( nStatus ) )
3018 {
3019 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003020 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 nStatus );
3022 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3023 goto end;
3024 }
3025 else if ( DOT11F_WARNED( nStatus ) )
3026 {
3027 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003028 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 }
3030
3031 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003032 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 nBytes );)
3034
3035 if( psessionEntry->assocReq != NULL )
3036 {
3037 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
3038 psessionEntry->assocReq = NULL;
3039 }
3040
3041 if( nAddIELen )
3042 {
3043 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3044 pAddIE,
3045 nAddIELen );
3046 nPayload += nAddIELen;
3047 }
3048
Jeff Johnson43971f52012-07-17 12:26:56 -07003049 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
3050 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 {
3052 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003053 }
3054 else
3055 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3057 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
3058 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003060
3061 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3063 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 )
3065 {
3066 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3067 }
3068
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003069 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003070 {
3071 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3072 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003073
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3075 HAL_TXRX_FRM_802_11_MGMT,
3076 ANI_TXDIR_TODS,
3077 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3078 limTxComplete, pFrame, txFlag );
3079 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3080 {
3081 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003082 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 nSirStatus );
3084 //Pkt will be freed up by the callback
3085 goto end;
3086 }
3087
3088end:
3089 // Free up buffer allocated for mlmAssocReq
3090 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3091 psessionEntry->pLimMlmReassocReq = NULL;
3092
3093} // limSendReassocReqMgmtFrame
3094
3095/**
3096 * \brief Send an Authentication frame
3097 *
3098 *
3099 * \param pMac Pointer to Global MAC structure
3100 *
3101 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3102 * to be sent
3103 *
3104 * \param peerMacAddr MAC address of the peer entity to which Authentication
3105 * frame is destined
3106 *
3107 * \param wepBit Indicates whether wep bit to be set in FC while sending
3108 * Authentication frame3
3109 *
3110 *
3111 * This function is called by limProcessMlmMessages(). Authentication frame
3112 * is formatted and sent when this function is called.
3113 *
3114 *
3115 */
3116
3117void
3118limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3119 tpSirMacAuthFrameBody pAuthFrameBody,
3120 tSirMacAddr peerMacAddr,
3121 tANI_U8 wepBit,
3122 tpPESession psessionEntry
3123 )
3124{
3125 tANI_U8 *pFrame, *pBody;
3126 tANI_U32 frameLen = 0, bodyLen = 0;
3127 tpSirMacMgmtHdr pMacHdr;
3128 tANI_U16 i;
3129 void *pPacket;
3130 eHalStatus halstatus;
3131 tANI_U8 txFlag = 0;
3132
3133 if(NULL == psessionEntry)
3134 {
3135 return;
3136 }
3137
3138 if (wepBit == LIM_WEP_IN_FC)
3139 {
3140 /// Auth frame3 to be sent with encrypted framebody
3141 /**
3142 * Allocate buffer for Authenticaton frame of size equal
3143 * to management frame header length plus 2 bytes each for
3144 * auth algorithm number, transaction number, status code,
3145 * 128 bytes for challenge text and 4 bytes each for
3146 * IV & ICV.
3147 */
3148
3149 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3150
3151 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3152 } // if (wepBit == LIM_WEP_IN_FC)
3153 else
3154 {
3155 switch (pAuthFrameBody->authTransactionSeqNumber)
3156 {
3157 case SIR_MAC_AUTH_FRAME_1:
3158 /**
3159 * Allocate buffer for Authenticaton frame of size
3160 * equal to management frame header length plus 2 bytes
3161 * each for auth algorithm number, transaction number
3162 * and status code.
3163 */
3164
3165 frameLen = sizeof(tSirMacMgmtHdr) +
3166 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3167 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3168
3169#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003170 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3171 {
3172 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003174 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003175 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003176 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003178 else
3179 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003180 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003181 frameLen += (2+SIR_MDIE_SIZE);
3182 }
3183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003184#endif
3185 break;
3186
3187 case SIR_MAC_AUTH_FRAME_2:
3188 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3189 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3190 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3191 {
3192 /**
3193 * Allocate buffer for Authenticaton frame of size
3194 * equal to management frame header length plus
3195 * 2 bytes each for auth algorithm number,
3196 * transaction number and status code.
3197 */
3198
3199 frameLen = sizeof(tSirMacMgmtHdr) +
3200 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3201 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3202 }
3203 else
3204 {
3205 // Shared Key algorithm with challenge text
3206 // to be sent
3207 /**
3208 * Allocate buffer for Authenticaton frame of size
3209 * equal to management frame header length plus
3210 * 2 bytes each for auth algorithm number,
3211 * transaction number, status code and 128 bytes
3212 * for challenge text.
3213 */
3214
3215 frameLen = sizeof(tSirMacMgmtHdr) +
3216 sizeof(tSirMacAuthFrame);
3217 bodyLen = sizeof(tSirMacAuthFrameBody);
3218 }
3219
3220 break;
3221
3222 case SIR_MAC_AUTH_FRAME_3:
3223 /// Auth frame3 to be sent without encrypted framebody
3224 /**
3225 * Allocate buffer for Authenticaton frame of size equal
3226 * to management frame header length plus 2 bytes each
3227 * for auth algorithm number, transaction number and
3228 * status code.
3229 */
3230
3231 frameLen = sizeof(tSirMacMgmtHdr) +
3232 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3233 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3234
3235 break;
3236
3237 case SIR_MAC_AUTH_FRAME_4:
3238 /**
3239 * Allocate buffer for Authenticaton frame of size equal
3240 * to management frame header length plus 2 bytes each
3241 * for auth algorithm number, transaction number and
3242 * status code.
3243 */
3244
3245 frameLen = sizeof(tSirMacMgmtHdr) +
3246 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3247 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3248
3249 break;
3250 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3251 } // end if (wepBit == LIM_WEP_IN_FC)
3252
3253
3254 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3255
3256 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3257 {
3258 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003259 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003260
3261 return;
3262 }
3263
3264 for (i = 0; i < frameLen; i++)
3265 pFrame[i] = 0;
3266
3267 // Prepare BD
3268 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3269 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3270 {
3271 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3272 return;
3273 }
3274
3275 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3276 pMacHdr->fc.wep = wepBit;
3277
3278 // Prepare BSSId
3279 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3280 {
3281 palCopyMemory( pMac->hHdd,(tANI_U8 *) pMacHdr->bssId,
3282 (tANI_U8 *) psessionEntry->bssId,
3283 sizeof( tSirMacAddr ));
3284 }
3285
3286 /// Prepare Authentication frame body
3287 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3288
3289 if (wepBit == LIM_WEP_IN_FC)
3290 {
3291 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
3292
3293 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003294 FL("*** Sending Auth seq# 3 status %d (%d) to"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 pAuthFrameBody->authStatusCode,
3296 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3297
3298 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3299 }
3300 else
3301 {
3302 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3303 pBody += sizeof(tANI_U16);
3304 bodyLen -= sizeof(tANI_U16);
3305
3306 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3307 pBody += sizeof(tANI_U16);
3308 bodyLen -= sizeof(tANI_U16);
3309
3310 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3311 pBody += sizeof(tANI_U16);
3312 bodyLen -= sizeof(tANI_U16);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07003313 if ( bodyLen < sizeof (pAuthFrameBody->type) + sizeof (pAuthFrameBody->length) + sizeof (pAuthFrameBody->challengeText))
3314 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003315
3316#if defined WLAN_FEATURE_VOWIFI_11R
3317 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3318 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3319 {
3320
3321 {
3322 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3324 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003325#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3327 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3328 (tANI_U8 *)pBody,
3329 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003330#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003331 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3332 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003333 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3334 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003335 }
3336 }
3337 else
3338 {
3339 /* MDID attr is 54*/
3340 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003342 *pBody = SIR_MDIE_SIZE;
3343 pBody++;
3344 for(i=0;i<SIR_MDIE_SIZE;i++)
3345 {
3346 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3347 pBody++;
3348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 }
3350 }
3351 }
3352#endif
3353
3354 PELOG1(limLog(pMac, LOG1,
3355 FL("*** Sending Auth seq# %d status %d (%d) to "),
3356 pAuthFrameBody->authTransactionSeqNumber,
3357 pAuthFrameBody->authStatusCode,
3358 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3359
3360 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3361 }
3362 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3363
3364 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3366 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003367#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
3368 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
3369 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3370#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 )
3372 {
3373 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3374 }
3375
Ganesh K08bce952012-12-13 15:04:41 -08003376 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3377 {
3378 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3379 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003380
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 /// Queue Authentication frame in high priority WQ
3382 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3383 HAL_TXRX_FRM_802_11_MGMT,
3384 ANI_TXDIR_TODS,
3385 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3386 limTxComplete, pFrame, txFlag );
3387 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3388 {
3389 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003390 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 halstatus);
3392
3393 //Pkt will be freed up by the callback
3394 }
3395
3396 return;
3397} /*** end limSendAuthMgmtFrame() ***/
3398
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003399eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3400{
3401 tANI_U16 aid;
3402 tpDphHashNode pStaDs;
3403 tLimMlmDeauthReq *pMlmDeauthReq;
3404 tLimMlmDeauthCnf mlmDeauthCnf;
3405 tpPESession psessionEntry;
3406
3407 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3408 if (pMlmDeauthReq)
3409 {
3410 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3411 {
3412 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3413 }
3414
3415 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3416 {
3417
3418 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003419 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003420 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3421 goto end;
3422 }
3423
3424 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3425 if (pStaDs == NULL)
3426 {
3427 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3428 goto end;
3429 }
3430
3431
3432 /// Receive path cleanup with dummy packet
3433 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3434 /// Free up buffer allocated for mlmDeauthReq
3435 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3436 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3437 }
3438 return eHAL_STATUS_SUCCESS;
3439end:
3440 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3441 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3442 sizeof(tSirMacAddr));
3443 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3444 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3445 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3446
3447 // Free up buffer allocated
3448 // for mlmDeauthReq
3449 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3450
3451 limPostSmeMessage(pMac,
3452 LIM_MLM_DEAUTH_CNF,
3453 (tANI_U32 *) &mlmDeauthCnf);
3454 return eHAL_STATUS_SUCCESS;
3455}
3456
3457eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3458{
3459 tANI_U16 aid;
3460 tpDphHashNode pStaDs;
3461 tLimMlmDisassocCnf mlmDisassocCnf;
3462 tpPESession psessionEntry;
3463 tLimMlmDisassocReq *pMlmDisassocReq;
3464
3465 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3466 if (pMlmDisassocReq)
3467 {
3468 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3469 {
3470 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3471 }
3472
3473 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3474 {
3475
3476 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003477 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003478 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3479 goto end;
3480 }
3481
3482 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3483 if (pStaDs == NULL)
3484 {
3485 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3486 goto end;
3487 }
3488
3489 /// Receive path cleanup with dummy packet
3490 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3491 {
3492 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3493 goto end;
3494 }
3495
3496#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003497 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3498 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003499#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003500 (psessionEntry->isCCXconnection ) ||
3501#endif
3502#ifdef FEATURE_WLAN_LFR
3503 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003504#endif
3505 (psessionEntry->is11Rconnection )) &&
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003506 (pMlmDisassocReq->reasonCode !=
3507 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003508 {
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003509 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003510 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003511 psessionEntry, psessionEntry->peSessionId););
3512 limFTCleanup(pMac);
3513 }
3514 else
3515 {
3516 PELOGE(limLog(pMac, LOGE,
3517 FL("No FT Preauth Session Cleanup in role %d"
3518#ifdef FEATURE_WLAN_CCX
3519 " isCCX %d"
3520#endif
3521#ifdef FEATURE_WLAN_LFR
3522 " isLFR %d"
3523#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003524 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003525 psessionEntry->limSystemRole,
3526#ifdef FEATURE_WLAN_CCX
3527 psessionEntry->isCCXconnection,
3528#endif
3529#ifdef FEATURE_WLAN_LFR
3530 psessionEntry->isFastRoamIniFeatureEnabled,
3531#endif
3532 psessionEntry->is11Rconnection,
3533 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003534 }
3535#endif
3536
3537 /// Free up buffer allocated for mlmDisassocReq
3538 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3539 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3540 return eHAL_STATUS_SUCCESS;
3541 }
3542 else
3543 {
3544 return eHAL_STATUS_SUCCESS;
3545 }
3546end:
3547 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
3548 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3549 sizeof(tSirMacAddr));
3550 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3551 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3552
3553 /* Update PE session ID*/
3554 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3555
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003556 if(pMlmDisassocReq != NULL)
3557 {
3558 /// Free up buffer allocated for mlmDisassocReq
3559 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3560 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3561 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003562
3563 limPostSmeMessage(pMac,
3564 LIM_MLM_DISASSOC_CNF,
3565 (tANI_U32 *) &mlmDisassocCnf);
3566 return eHAL_STATUS_SUCCESS;
3567}
3568
3569eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3570{
3571 return limSendDisassocCnf(pMac);
3572}
3573
3574eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3575{
3576 return limSendDeauthCnf(pMac);
3577}
3578
Jeff Johnson295189b2012-06-20 16:38:30 -07003579/**
3580 * \brief This function is called to send Disassociate frame.
3581 *
3582 *
3583 * \param pMac Pointer to Global MAC structure
3584 *
3585 * \param nReason Indicates the reason that need to be sent in
3586 * Disassociation frame
3587 *
3588 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3589 * sent
3590 *
3591 *
3592 */
3593
3594void
3595limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3596 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003597 tSirMacAddr peer,
3598 tpPESession psessionEntry,
3599 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003600{
3601 tDot11fDisassociation frm;
3602 tANI_U8 *pFrame;
3603 tSirRetStatus nSirStatus;
3604 tpSirMacMgmtHdr pMacHdr;
3605 tANI_U32 nBytes, nPayload, nStatus;
3606 void *pPacket;
3607 eHalStatus halstatus;
3608 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003609 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 if(NULL == psessionEntry)
3611 {
3612 return;
3613 }
3614
3615 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3616
3617 frm.Reason.code = nReason;
3618
3619 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3620 if ( DOT11F_FAILED( nStatus ) )
3621 {
3622 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003623 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 nStatus );
3625 // We'll fall back on the worst case scenario:
3626 nPayload = sizeof( tDot11fDisassociation );
3627 }
3628 else if ( DOT11F_WARNED( nStatus ) )
3629 {
3630 limLog( pMac, LOGW, FL("There were warnings while calculating"
3631 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003632 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 }
3634
3635 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3636
3637 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3638 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3639 ( void** ) &pPacket );
3640 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3641 {
3642 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003643 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 return;
3645 }
3646
3647 // Paranoia:
3648 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3649
3650 // Next, we fill out the buffer descriptor:
3651 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3652 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3653 if ( eSIR_SUCCESS != nSirStatus )
3654 {
3655 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003656 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 nSirStatus );
3658 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3659 ( void* ) pFrame, ( void* ) pPacket );
3660 return; // just allocated...
3661 }
3662
3663 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3664
3665 // Prepare the BSSID
3666 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3667
Chet Lanctot186b5732013-03-18 10:26:30 -07003668#ifdef WLAN_FEATURE_11W
3669 if ( psessionEntry->limRmfEnabled )
3670 {
3671 pMacHdr->fc.wep = 1;
3672 }
3673#endif
3674
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3676 sizeof(tSirMacMgmtHdr),
3677 nPayload, &nPayload );
3678 if ( DOT11F_FAILED( nStatus ) )
3679 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003680 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 nStatus );
3682 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3683 ( void* ) pFrame, ( void* ) pPacket );
3684 return; // allocated!
3685 }
3686 else if ( DOT11F_WARNED( nStatus ) )
3687 {
3688 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003689 "isassociation (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 }
3691
3692 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003693 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3695
3696 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3698 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 )
3700 {
3701 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3702 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003703
Ganesh K08bce952012-12-13 15:04:41 -08003704 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3705 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3706 {
3707 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3708 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003709
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003710 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003712 // Queue Disassociation frame in high priority WQ
3713 /* get the duration from the request */
3714 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3715 HAL_TXRX_FRM_802_11_MGMT,
3716 ANI_TXDIR_TODS,
3717 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3718 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3719 txFlag );
3720 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003721
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003722 if (tx_timer_change(
3723 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3724 != TX_SUCCESS)
3725 {
3726 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003727 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003728 return;
3729 }
3730 else if(TX_SUCCESS != tx_timer_activate(
3731 &pMac->lim.limTimers.gLimDisassocAckTimer))
3732 {
3733 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003734 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003735 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3736 return;
3737 }
3738 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003739 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003740 {
3741 // Queue Disassociation frame in high priority WQ
3742 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3743 HAL_TXRX_FRM_802_11_MGMT,
3744 ANI_TXDIR_TODS,
3745 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3746 limTxComplete, pFrame, txFlag );
3747 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3748 {
3749 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003750 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003751 nSirStatus );
3752 //Pkt will be freed up by the callback
3753 return;
3754 }
3755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003756} // End limSendDisassocMgmtFrame.
3757
3758/**
3759 * \brief This function is called to send a Deauthenticate frame
3760 *
3761 *
3762 * \param pMac Pointer to global MAC structure
3763 *
3764 * \param nReason Indicates the reason that need to be sent in the
3765 * Deauthenticate frame
3766 *
3767 * \param peeer address of the STA to which the frame is to be sent
3768 *
3769 *
3770 */
3771
3772void
3773limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3774 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003775 tSirMacAddr peer,
3776 tpPESession psessionEntry,
3777 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003778{
3779 tDot11fDeAuth frm;
3780 tANI_U8 *pFrame;
3781 tSirRetStatus nSirStatus;
3782 tpSirMacMgmtHdr pMacHdr;
3783 tANI_U32 nBytes, nPayload, nStatus;
3784 void *pPacket;
3785 eHalStatus halstatus;
3786 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003787 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003788#ifdef FEATURE_WLAN_TDLS
3789 tANI_U16 aid;
3790 tpDphHashNode pStaDs;
3791#endif
3792
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 if(NULL == psessionEntry)
3794 {
3795 return;
3796 }
3797
3798 palZeroMemory( pMac->hHdd, ( tANI_U8* ) &frm, sizeof( frm ) );
3799
3800 frm.Reason.code = nReason;
3801
3802 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3803 if ( DOT11F_FAILED( nStatus ) )
3804 {
3805 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003806 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003807 nStatus );
3808 // We'll fall back on the worst case scenario:
3809 nPayload = sizeof( tDot11fDeAuth );
3810 }
3811 else if ( DOT11F_WARNED( nStatus ) )
3812 {
3813 limLog( pMac, LOGW, FL("There were warnings while calculating"
3814 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003815 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 }
3817
3818 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3819
3820 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3821 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3822 ( void** ) &pPacket );
3823 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3824 {
3825 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003826 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 return;
3828 }
3829
3830 // Paranoia:
3831 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3832
3833 // Next, we fill out the buffer descriptor:
3834 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3835 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3836 if ( eSIR_SUCCESS != nSirStatus )
3837 {
3838 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003839 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 nSirStatus );
3841 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3842 ( void* ) pFrame, ( void* ) pPacket );
3843 return; // just allocated...
3844 }
3845
3846 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3847
3848 // Prepare the BSSID
3849 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3850
Chet Lanctot186b5732013-03-18 10:26:30 -07003851#ifdef WLAN_FEATURE_11W
3852 if ( psessionEntry->limRmfEnabled )
3853 {
3854 pMacHdr->fc.wep = 1;
3855 }
3856#endif
3857
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3859 sizeof(tSirMacMgmtHdr),
3860 nPayload, &nPayload );
3861 if ( DOT11F_FAILED( nStatus ) )
3862 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003863 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 nStatus );
3865 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3866 ( void* ) pFrame, ( void* ) pPacket );
3867 return;
3868 }
3869 else if ( DOT11F_WARNED( nStatus ) )
3870 {
3871 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003872 "e-Authentication (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 }
3874
3875 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003876 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3878
3879 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003880 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3881 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 )
3883 {
3884 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3885 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003886
Ganesh K08bce952012-12-13 15:04:41 -08003887 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3888 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3889 {
3890 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3891 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003892
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003893#ifdef FEATURE_WLAN_TDLS
3894 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3895#endif
3896
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003897 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003899 // Queue Disassociation frame in high priority WQ
3900 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3901 HAL_TXRX_FRM_802_11_MGMT,
3902 ANI_TXDIR_TODS,
3903 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3904 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
3905 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3906 {
3907 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003908 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003909 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003910 //Pkt will be freed up by the callback limTxComplete
3911
3912 /*Call limProcessDeauthAckTimeout which will send
3913 * DeauthCnf for this frame
3914 */
3915 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003916 return;
3917 }
3918
3919 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3920
3921 if (tx_timer_change(
3922 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3923 != TX_SUCCESS)
3924 {
3925 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003926 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003927 return;
3928 }
3929 else if(TX_SUCCESS != tx_timer_activate(
3930 &pMac->lim.limTimers.gLimDeauthAckTimer))
3931 {
3932 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003933 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003934 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3935 return;
3936 }
3937 }
3938 else
3939 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003940#ifdef FEATURE_WLAN_TDLS
3941 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
3942 {
3943 // Queue Disassociation frame in high priority WQ
3944 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003945 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003946 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003947 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3948 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003949 }
3950 else
3951 {
3952#endif
3953 // Queue Disassociation frame in high priority WQ
3954 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3955 HAL_TXRX_FRM_802_11_MGMT,
3956 ANI_TXDIR_TODS,
3957 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3958 limTxComplete, pFrame, txFlag );
3959#ifdef FEATURE_WLAN_TDLS
3960 }
3961#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003962 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3963 {
3964 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003965 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003966 nSirStatus );
3967 //Pkt will be freed up by the callback
3968 return;
3969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 }
3971
3972} // End limSendDeauthMgmtFrame.
3973
3974
3975#ifdef ANI_SUPPORT_11H
3976/**
3977 * \brief Send a Measurement Report Action frame
3978 *
3979 *
3980 * \param pMac Pointer to the global MAC structure
3981 *
3982 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3983 *
3984 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3985 *
3986 *
3987 */
3988
3989tSirRetStatus
3990limSendMeasReportFrame(tpAniSirGlobal pMac,
3991 tpSirMacMeasReqActionFrame pMeasReqFrame,
3992 tSirMacAddr peer)
3993{
3994 tDot11fMeasurementReport frm;
3995 tANI_U8 *pFrame;
3996 tSirRetStatus nSirStatus;
3997 tpSirMacMgmtHdr pMacHdr;
3998 tANI_U32 nBytes, nPayload, nStatus, nCfg;
3999 void *pPacket;
4000 eHalStatus halstatus;
4001
4002 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4003
4004 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4005 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4006 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4007
4008 switch ( pMeasReqFrame->measReqIE.measType )
4009 {
4010 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4011 nSirStatus =
4012 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4013 &frm.MeasurementReport );
4014 break;
4015 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4016 nSirStatus =
4017 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4018 &frm.MeasurementReport );
4019 break;
4020 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4021 nSirStatus =
4022 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4023 &frm.MeasurementReport );
4024 break;
4025 default:
4026 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004027 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 pMeasReqFrame->measReqIE.measType );
4029 return eSIR_FAILURE;
4030 }
4031
4032 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4033
4034 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4035 if ( DOT11F_FAILED( nStatus ) )
4036 {
4037 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004038 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 nStatus );
4040 // We'll fall back on the worst case scenario:
4041 nPayload = sizeof( tDot11fMeasurementReport );
4042 }
4043 else if ( DOT11F_WARNED( nStatus ) )
4044 {
4045 limLog( pMac, LOGW, FL("There were warnings while calculating"
4046 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004047 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 }
4049
4050 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4051
4052 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4053 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4054 {
4055 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004056 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 return eSIR_FAILURE;
4058 }
4059
4060 // Paranoia:
4061 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4062
4063 // Next, we fill out the buffer descriptor:
4064 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4065 SIR_MAC_MGMT_ACTION, peer);
4066 if ( eSIR_SUCCESS != nSirStatus )
4067 {
4068 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004069 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 nSirStatus );
4071 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4072 return eSIR_FAILURE; // just allocated...
4073 }
4074
4075 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4076
4077 nCfg = 6;
4078 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4079 if ( eSIR_SUCCESS != nSirStatus )
4080 {
4081 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004082 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 nSirStatus );
4084 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4085 return eSIR_FAILURE; // just allocated...
4086 }
4087
Chet Lanctot186b5732013-03-18 10:26:30 -07004088#ifdef WLAN_FEATURE_11W
4089 if ( psessionEntry->limRmfEnabled )
4090 {
4091 pMacHdr->fc.wep = 1;
4092 }
4093#endif
4094
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4096 sizeof(tSirMacMgmtHdr),
4097 nPayload, &nPayload );
4098 if ( DOT11F_FAILED( nStatus ) )
4099 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004100 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 nStatus );
4102 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4103 return eSIR_FAILURE; // allocated!
4104 }
4105 else if ( DOT11F_WARNED( nStatus ) )
4106 {
4107 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004108 "easurement Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 }
4110
4111 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4112 HAL_TXRX_FRM_802_11_MGMT,
4113 ANI_TXDIR_TODS,
4114 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4115 limTxComplete, pFrame, 0 );
4116 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4117 {
4118 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004119 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 nSirStatus );
4121 //Pkt will be freed up by the callback
4122 return eSIR_FAILURE; // just allocated...
4123 }
4124
4125 return eSIR_SUCCESS;
4126
4127} // End limSendMeasReportFrame.
4128
4129
4130/**
4131 * \brief Send a TPC Request Action frame
4132 *
4133 *
4134 * \param pMac Pointer to the global MAC datastructure
4135 *
4136 * \param peer MAC address to which the frame should be sent
4137 *
4138 *
4139 */
4140
4141void
4142limSendTpcRequestFrame(tpAniSirGlobal pMac,
4143 tSirMacAddr peer)
4144{
4145 tDot11fTPCRequest frm;
4146 tANI_U8 *pFrame;
4147 tSirRetStatus nSirStatus;
4148 tpSirMacMgmtHdr pMacHdr;
4149 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4150 void *pPacket;
4151 eHalStatus halstatus;
4152
4153 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4154
4155 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4156 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4157 frm.DialogToken.token = 1;
4158 frm.TPCRequest.present = 1;
4159
4160 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4161 if ( DOT11F_FAILED( nStatus ) )
4162 {
4163 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004164 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 nStatus );
4166 // We'll fall back on the worst case scenario:
4167 nPayload = sizeof( tDot11fTPCRequest );
4168 }
4169 else if ( DOT11F_WARNED( nStatus ) )
4170 {
4171 limLog( pMac, LOGW, FL("There were warnings while calculating"
4172 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004173 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 }
4175
4176 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4177
4178 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4179 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4180 {
4181 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004182 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 return;
4184 }
4185
4186 // Paranoia:
4187 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4188
4189 // Next, we fill out the buffer descriptor:
4190 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4191 SIR_MAC_MGMT_ACTION, peer);
4192 if ( eSIR_SUCCESS != nSirStatus )
4193 {
4194 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004195 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 nSirStatus );
4197 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4198 return; // just allocated...
4199 }
4200
4201 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4202
4203 nCfg = 6;
4204 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4205 if ( eSIR_SUCCESS != nSirStatus )
4206 {
4207 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004208 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 nSirStatus );
4210 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4211 return; // just allocated...
4212 }
4213
Chet Lanctot186b5732013-03-18 10:26:30 -07004214#ifdef WLAN_FEATURE_11W
4215 if ( psessionEntry->limRmfEnabled )
4216 {
4217 pMacHdr->fc.wep = 1;
4218 }
4219#endif
4220
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4222 sizeof(tSirMacMgmtHdr),
4223 nPayload, &nPayload );
4224 if ( DOT11F_FAILED( nStatus ) )
4225 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004226 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 nStatus );
4228 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4229 return; // allocated!
4230 }
4231 else if ( DOT11F_WARNED( nStatus ) )
4232 {
4233 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004234 "PC Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 }
4236
4237 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4238 HAL_TXRX_FRM_802_11_MGMT,
4239 ANI_TXDIR_TODS,
4240 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4241 limTxComplete, pFrame, 0 );
4242 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4243 {
4244 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
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;
4249 }
4250
4251} // End limSendTpcRequestFrame.
4252
4253
4254/**
4255 * \brief Send a TPC Report Action frame
4256 *
4257 *
4258 * \param pMac Pointer to the global MAC datastructure
4259 *
4260 * \param pTpcReqFrame Pointer to the received TPC Request
4261 *
4262 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4263 *
4264 *
4265 */
4266
4267tSirRetStatus
4268limSendTpcReportFrame(tpAniSirGlobal pMac,
4269 tpSirMacTpcReqActionFrame pTpcReqFrame,
4270 tSirMacAddr peer)
4271{
4272 tDot11fTPCReport frm;
4273 tANI_U8 *pFrame;
4274 tSirRetStatus nSirStatus;
4275 tpSirMacMgmtHdr pMacHdr;
4276 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4277 void *pPacket;
4278 eHalStatus halstatus;
4279
4280 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4281
4282 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4283 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4284 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4285
4286 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4287 // "misplaced this function, need to replace:
4288 // txPower = halGetRateToPwrValue(pMac, staid,
4289 // pMac->lim.gLimCurrentChannelId, 0);
4290 frm.TPCReport.tx_power = 0;
4291 frm.TPCReport.link_margin = 0;
4292 frm.TPCReport.present = 1;
4293
4294 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4295 if ( DOT11F_FAILED( nStatus ) )
4296 {
4297 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004298 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 nStatus );
4300 // We'll fall back on the worst case scenario:
4301 nPayload = sizeof( tDot11fTPCReport );
4302 }
4303 else if ( DOT11F_WARNED( nStatus ) )
4304 {
4305 limLog( pMac, LOGW, FL("There were warnings while calculating"
4306 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004307 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 }
4309
4310 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4311
4312 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4313 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4314 {
4315 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004316 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 return eSIR_FAILURE;
4318 }
4319
4320 // Paranoia:
4321 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4322
4323 // Next, we fill out the buffer descriptor:
4324 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4325 SIR_MAC_MGMT_ACTION, peer);
4326 if ( eSIR_SUCCESS != nSirStatus )
4327 {
4328 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004329 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 nSirStatus );
4331 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4332 return eSIR_FAILURE; // just allocated...
4333 }
4334
4335 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4336
4337 nCfg = 6;
4338 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4339 if ( eSIR_SUCCESS != nSirStatus )
4340 {
4341 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004342 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 nSirStatus );
4344 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4345 return eSIR_FAILURE; // just allocated...
4346 }
4347
Chet Lanctot186b5732013-03-18 10:26:30 -07004348#ifdef WLAN_FEATURE_11W
4349 if ( psessionEntry->limRmfEnabled )
4350 {
4351 pMacHdr->fc.wep = 1;
4352 }
4353#endif
4354
Jeff Johnson295189b2012-06-20 16:38:30 -07004355 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4356 sizeof(tSirMacMgmtHdr),
4357 nPayload, &nPayload );
4358 if ( DOT11F_FAILED( nStatus ) )
4359 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004360 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 nStatus );
4362 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4363 return eSIR_FAILURE; // allocated!
4364 }
4365 else if ( DOT11F_WARNED( nStatus ) )
4366 {
4367 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004368 "PC Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 }
4370
4371
4372 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4373 HAL_TXRX_FRM_802_11_MGMT,
4374 ANI_TXDIR_TODS,
4375 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4376 limTxComplete, pFrame, 0 );
4377 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4378 {
4379 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004380 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 nSirStatus );
4382 //Pkt will be freed up by the callback
4383 return eSIR_FAILURE; // just allocated...
4384 }
4385
4386 return eSIR_SUCCESS;
4387
4388} // End limSendTpcReportFrame.
4389#endif //ANI_SUPPORT_11H
4390
4391
Jeff Johnson295189b2012-06-20 16:38:30 -07004392/**
4393 * \brief Send a Channel Switch Announcement
4394 *
4395 *
4396 * \param pMac Pointer to the global MAC datastructure
4397 *
4398 * \param peer MAC address to which this frame will be sent
4399 *
4400 * \param nMode
4401 *
4402 * \param nNewChannel
4403 *
4404 * \param nCount
4405 *
4406 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4407 *
4408 *
4409 */
4410
4411tSirRetStatus
4412limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4413 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004414 tANI_U8 nMode,
4415 tANI_U8 nNewChannel,
4416 tANI_U8 nCount,
4417 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004418{
4419 tDot11fChannelSwitch frm;
4420 tANI_U8 *pFrame;
4421 tSirRetStatus nSirStatus;
4422 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004423 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 void *pPacket;
4425 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004426 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004427
4428 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4429
4430 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4431 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4432 frm.ChanSwitchAnn.switchMode = nMode;
4433 frm.ChanSwitchAnn.newChannel = nNewChannel;
4434 frm.ChanSwitchAnn.switchCount = nCount;
4435 frm.ChanSwitchAnn.present = 1;
4436
4437 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4438 if ( DOT11F_FAILED( nStatus ) )
4439 {
4440 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004441 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004442 nStatus );
4443 // We'll fall back on the worst case scenario:
4444 nPayload = sizeof( tDot11fChannelSwitch );
4445 }
4446 else if ( DOT11F_WARNED( nStatus ) )
4447 {
4448 limLog( pMac, LOGW, FL("There were warnings while calculating"
4449 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004450 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 }
4452
4453 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4454
4455 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4456 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4457 {
4458 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004459 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 return eSIR_FAILURE;
4461 }
4462
4463 // Paranoia:
4464 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4465
4466 // Next, we fill out the buffer descriptor:
4467 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004468 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4469 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4470 palCopyMemory( pMac->hHdd,
4471 (tANI_U8 *) pMacHdr->bssId,
4472 (tANI_U8 *) psessionEntry->bssId,
4473 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 if ( eSIR_SUCCESS != nSirStatus )
4475 {
4476 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004477 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 nSirStatus );
4479 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4480 return eSIR_FAILURE; // just allocated...
4481 }
4482
Jeff Johnsone7245742012-09-05 17:12:55 -07004483#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4485
4486 nCfg = 6;
4487 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4488 if ( eSIR_SUCCESS != nSirStatus )
4489 {
4490 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004491 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 nSirStatus );
4493 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4494 return eSIR_FAILURE; // just allocated...
4495 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004496#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004497
4498#ifdef WLAN_FEATURE_11W
4499 if ( psessionEntry->limRmfEnabled )
4500 {
4501 pMacHdr->fc.wep = 1;
4502 }
4503#endif
4504
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4506 sizeof(tSirMacMgmtHdr),
4507 nPayload, &nPayload );
4508 if ( DOT11F_FAILED( nStatus ) )
4509 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004510 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 nStatus );
4512 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4513 return eSIR_FAILURE; // allocated!
4514 }
4515 else if ( DOT11F_WARNED( nStatus ) )
4516 {
4517 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004518 "hannel Switch (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 }
4520
Jeff Johnsone7245742012-09-05 17:12:55 -07004521 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004522 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4523 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004524 )
4525 {
4526 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4529 HAL_TXRX_FRM_802_11_MGMT,
4530 ANI_TXDIR_TODS,
4531 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004532 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4534 {
4535 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004536 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 nSirStatus );
4538 //Pkt will be freed up by the callback
4539 return eSIR_FAILURE;
4540 }
4541
4542 return eSIR_SUCCESS;
4543
4544} // End limSendChannelSwitchMgmtFrame.
4545
Jeff Johnson295189b2012-06-20 16:38:30 -07004546
4547
Mohit Khanna4a70d262012-09-11 16:30:12 -07004548#ifdef WLAN_FEATURE_11AC
4549tSirRetStatus
4550limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4551 tSirMacAddr peer,
4552 tANI_U8 nMode,
4553 tpPESession psessionEntry )
4554{
4555 tDot11fOperatingMode frm;
4556 tANI_U8 *pFrame;
4557 tSirRetStatus nSirStatus;
4558 tpSirMacMgmtHdr pMacHdr;
4559 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4560 void *pPacket;
4561 eHalStatus halstatus;
4562 tANI_U8 txFlag = 0;
4563
4564 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4565
4566 frm.Category.category = SIR_MAC_ACTION_VHT;
4567 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4568 frm.OperatingMode.chanWidth = nMode;
4569 frm.OperatingMode.rxNSS = 0;
4570 frm.OperatingMode.rxNSSType = 0;
4571
4572 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4573 if ( DOT11F_FAILED( nStatus ) )
4574 {
4575 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004576 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004577 nStatus );
4578 // We'll fall back on the worst case scenario:
4579 nPayload = sizeof( tDot11fOperatingMode);
4580 }
4581 else if ( DOT11F_WARNED( nStatus ) )
4582 {
4583 limLog( pMac, LOGW, FL("There were warnings while calculating"
4584 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004585 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004586 }
4587
4588 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4589
4590 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4591 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4592 {
4593 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004594 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004595 return eSIR_FAILURE;
4596 }
4597
4598 // Paranoia:
4599 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4600
4601
4602 // Next, we fill out the buffer descriptor:
4603 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4604 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4605 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4606 } else
4607 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4608 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4609 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4610 palCopyMemory( pMac->hHdd,
4611 (tANI_U8 *) pMacHdr->bssId,
4612 (tANI_U8 *) psessionEntry->bssId,
4613 sizeof( tSirMacAddr ));
4614 if ( eSIR_SUCCESS != nSirStatus )
4615 {
4616 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004617 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004618 nSirStatus );
4619 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4620 return eSIR_FAILURE; // just allocated...
4621 }
4622 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4623 sizeof(tSirMacMgmtHdr),
4624 nPayload, &nPayload );
4625 if ( DOT11F_FAILED( nStatus ) )
4626 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004627 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004628 nStatus );
4629 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4630 return eSIR_FAILURE; // allocated!
4631 }
4632 else if ( DOT11F_WARNED( nStatus ) )
4633 {
4634 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004635 " (0x%08x).") );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004636 }
4637 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004638 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4639 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004640 )
4641 {
4642 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4643 }
4644 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4645 HAL_TXRX_FRM_802_11_MGMT,
4646 ANI_TXDIR_TODS,
4647 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4648 limTxComplete, pFrame, txFlag );
4649 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4650 {
4651 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004652 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004653 nSirStatus );
4654 //Pkt will be freed up by the callback
4655 return eSIR_FAILURE;
4656 }
4657
4658 return eSIR_SUCCESS;
4659}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004660
4661/**
4662 * \brief Send a VHT Channel Switch Announcement
4663 *
4664 *
4665 * \param pMac Pointer to the global MAC datastructure
4666 *
4667 * \param peer MAC address to which this frame will be sent
4668 *
4669 * \param nChanWidth
4670 *
4671 * \param nNewChannel
4672 *
4673 *
4674 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4675 *
4676 *
4677 */
4678
4679tSirRetStatus
4680limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4681 tSirMacAddr peer,
4682 tANI_U8 nChanWidth,
4683 tANI_U8 nNewChannel,
4684 tANI_U8 ncbMode,
4685 tpPESession psessionEntry )
4686{
4687 tDot11fChannelSwitch frm;
4688 tANI_U8 *pFrame;
4689 tSirRetStatus nSirStatus;
4690 tpSirMacMgmtHdr pMacHdr;
4691 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4692 void *pPacket;
4693 eHalStatus halstatus;
4694 tANI_U8 txFlag = 0;
4695
4696 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4697
4698
4699 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4700 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4701 frm.ChanSwitchAnn.switchMode = 1;
4702 frm.ChanSwitchAnn.newChannel = nNewChannel;
4703 frm.ChanSwitchAnn.switchCount = 1;
4704 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4705 frm.ExtChanSwitchAnn.present = 1;
4706 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4707 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4708 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4709 frm.ChanSwitchAnn.present = 1;
4710 frm.WiderBWChanSwitchAnn.present = 1;
4711
4712 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4713 if ( DOT11F_FAILED( nStatus ) )
4714 {
4715 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004716 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004717 nStatus );
4718 // We'll fall back on the worst case scenario:
4719 nPayload = sizeof( tDot11fChannelSwitch );
4720 }
4721 else if ( DOT11F_WARNED( nStatus ) )
4722 {
4723 limLog( pMac, LOGW, FL("There were warnings while calculating"
4724 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004725 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004726 }
4727
4728 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4729
4730 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4731 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4732 {
4733 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004734 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004735 return eSIR_FAILURE;
4736 }
4737 // Paranoia:
4738 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4739
4740 // Next, we fill out the buffer descriptor:
4741 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4742 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4743 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4744 palCopyMemory( pMac->hHdd,
4745 (tANI_U8 *) pMacHdr->bssId,
4746 (tANI_U8 *) psessionEntry->bssId,
4747 sizeof( tSirMacAddr ));
4748 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 Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -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 = dot11fPackChannelSwitch( 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 Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -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 C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004769 "hannel Switch (0x%08x).") );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004770 }
4771
4772 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004773 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4774 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004775 )
4776 {
4777 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4778 }
4779 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4780 HAL_TXRX_FRM_802_11_MGMT,
4781 ANI_TXDIR_TODS,
4782 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4783 limTxComplete, pFrame, txFlag );
4784 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4785 {
4786 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004787 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004788 nSirStatus );
4789 //Pkt will be freed up by the callback
4790 return eSIR_FAILURE;
4791 }
4792
4793 return eSIR_SUCCESS;
4794
4795} // End limSendVHTChannelSwitchMgmtFrame.
4796
4797
4798
Mohit Khanna4a70d262012-09-11 16:30:12 -07004799#endif
4800
Jeff Johnson295189b2012-06-20 16:38:30 -07004801/**
4802 * \brief Send an ADDBA Req Action Frame to peer
4803 *
4804 * \sa limSendAddBAReq
4805 *
4806 * \param pMac The global tpAniSirGlobal object
4807 *
4808 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4809 * the necessary parameters reqd by PE send the ADDBA Req Action
4810 * Frame to the peer
4811 *
4812 * \return eSIR_SUCCESS if setup completes successfully
4813 * eSIR_FAILURE is some problem is encountered
4814 */
4815tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
4816 tpLimMlmAddBAReq pMlmAddBAReq ,tpPESession psessionEntry)
4817{
4818 tDot11fAddBAReq frmAddBAReq;
4819 tANI_U8 *pAddBAReqBuffer = NULL;
4820 tpSirMacMgmtHdr pMacHdr;
4821 tANI_U32 frameLen = 0, nStatus, nPayload;
4822 tSirRetStatus statusCode;
4823 eHalStatus halStatus;
4824 void *pPacket;
4825 tANI_U8 txFlag = 0;
4826
4827 if(NULL == psessionEntry)
4828 {
4829 return eSIR_FAILURE;
4830 }
4831
4832 palZeroMemory( pMac->hHdd, (void *) &frmAddBAReq, sizeof( frmAddBAReq ));
4833
4834 // Category - 3 (BA)
4835 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4836
4837 // Action - 0 (ADDBA Req)
4838 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4839
4840 // FIXME - Dialog Token, generalize this...
4841 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4842
4843 // Fill the ADDBA Parameter Set
4844 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4845 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4846 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4847
4848 // BA timeout
4849 // 0 - indicates no BA timeout
4850 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4851
4852 // BA Starting Sequence Number
4853 // Fragment number will always be zero
4854 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4855 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4856 }
4857
4858 frmAddBAReq.BAStartingSequenceControl.ssn =
4859 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4860
4861 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4862
4863 if( DOT11F_FAILED( nStatus ))
4864 {
4865 limLog( pMac, LOGW,
4866 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004867 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 nStatus );
4869
4870 // We'll fall back on the worst case scenario:
4871 nPayload = sizeof( tDot11fAddBAReq );
4872 }
4873 else if( DOT11F_WARNED( nStatus ))
4874 {
4875 limLog( pMac, LOGW,
4876 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004877 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 nStatus );
4879 }
4880
4881 // Add the MGMT header to frame length
4882 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4883
4884 // Need to allocate a buffer for ADDBA AF
4885 if( eHAL_STATUS_SUCCESS !=
4886 (halStatus = palPktAlloc( pMac->hHdd,
4887 HAL_TXRX_FRM_802_11_MGMT,
4888 (tANI_U16) frameLen,
4889 (void **) &pAddBAReqBuffer,
4890 (void **) &pPacket )))
4891 {
4892 // Log error
4893 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004894 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 frameLen,
4896 halStatus );
4897
4898 statusCode = eSIR_MEM_ALLOC_FAILED;
4899 goto returnAfterError;
4900 }
4901
4902 palZeroMemory( pMac->hHdd, (void *) pAddBAReqBuffer, frameLen );
4903
4904 // Copy necessary info to BD
4905 if( eSIR_SUCCESS !=
4906 (statusCode = limPopulateMacHeader( pMac,
4907 pAddBAReqBuffer,
4908 SIR_MAC_MGMT_FRAME,
4909 SIR_MAC_MGMT_ACTION,
4910 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4911 goto returnAfterError;
4912
4913 // Update A3 with the BSSID
4914 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4915
4916 #if 0
4917 cfgLen = SIR_MAC_ADDR_LENGTH;
4918 if( eSIR_SUCCESS != cfgGetStr( pMac,
4919 WNI_CFG_BSSID,
4920 (tANI_U8 *) pMacHdr->bssId,
4921 &cfgLen ))
4922 {
4923 limLog( pMac, LOGP,
4924 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004925 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004926
4927 // FIXME - Need to convert to tSirRetStatus
4928 statusCode = eSIR_FAILURE;
4929 goto returnAfterError;
4930 }
4931 #endif//TO SUPPORT BT-AMP
4932 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4933
Chet Lanctot186b5732013-03-18 10:26:30 -07004934#ifdef WLAN_FEATURE_11W
4935 if ( psessionEntry->limRmfEnabled )
4936 {
4937 pMacHdr->fc.wep = 1;
4938 }
4939#endif
4940
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 // Now, we're ready to "pack" the frames
4942 nStatus = dot11fPackAddBAReq( pMac,
4943 &frmAddBAReq,
4944 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4945 nPayload,
4946 &nPayload );
4947
4948 if( DOT11F_FAILED( nStatus ))
4949 {
4950 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004951 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 nStatus );
4953
4954 // FIXME - Need to convert to tSirRetStatus
4955 statusCode = eSIR_FAILURE;
4956 goto returnAfterError;
4957 }
4958 else if( DOT11F_WARNED( nStatus ))
4959 {
4960 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004961 FL( "There were warnings while packing an ADDBA Req (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 }
4963
4964 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004965 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4967
4968 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4970 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 )
4972 {
4973 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4974 }
4975
4976 if( eHAL_STATUS_SUCCESS !=
4977 (halStatus = halTxFrame( pMac,
4978 pPacket,
4979 (tANI_U16) frameLen,
4980 HAL_TXRX_FRM_802_11_MGMT,
4981 ANI_TXDIR_TODS,
4982 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4983 limTxComplete,
4984 pAddBAReqBuffer, txFlag )))
4985 {
4986 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004987 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 halStatus );
4989
4990 // FIXME - Need to convert eHalStatus to tSirRetStatus
4991 statusCode = eSIR_FAILURE;
4992 //Pkt will be freed up by the callback
4993 return statusCode;
4994 }
4995 else
4996 return eSIR_SUCCESS;
4997
4998returnAfterError:
4999
5000 // Release buffer, if allocated
5001 if( NULL != pAddBAReqBuffer )
5002 palPktFree( pMac->hHdd,
5003 HAL_TXRX_FRM_802_11_MGMT,
5004 (void *) pAddBAReqBuffer,
5005 (void *) pPacket );
5006
5007 return statusCode;
5008}
5009
5010/**
5011 * \brief Send an ADDBA Rsp Action Frame to peer
5012 *
5013 * \sa limSendAddBARsp
5014 *
5015 * \param pMac The global tpAniSirGlobal object
5016 *
5017 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5018 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5019 * Frame to the peer
5020 *
5021 * \return eSIR_SUCCESS if setup completes successfully
5022 * eSIR_FAILURE is some problem is encountered
5023 */
5024tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5025 tpLimMlmAddBARsp pMlmAddBARsp,
5026 tpPESession psessionEntry)
5027{
5028 tDot11fAddBARsp frmAddBARsp;
5029 tANI_U8 *pAddBARspBuffer = NULL;
5030 tpSirMacMgmtHdr pMacHdr;
5031 tANI_U32 frameLen = 0, nStatus, nPayload;
5032 tSirRetStatus statusCode;
5033 eHalStatus halStatus;
5034 void *pPacket;
5035 tANI_U8 txFlag = 0;
5036
5037 if(NULL == psessionEntry)
5038 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005039 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 return eSIR_FAILURE;
5041 }
5042
5043 palZeroMemory( pMac->hHdd, (void *) &frmAddBARsp, sizeof( frmAddBARsp ));
5044
5045 // Category - 3 (BA)
5046 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5047 // Action - 1 (ADDBA Rsp)
5048 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5049
5050 // Should be same as the one we received in the ADDBA Req
5051 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5052
5053 // ADDBA Req status
5054 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5055
5056 // Fill the ADDBA Parameter Set as provided by caller
5057 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5058 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5059 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
5060
5061 // BA timeout
5062 // 0 - indicates no BA timeout
5063 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5064
5065 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5066
5067 if( DOT11F_FAILED( nStatus ))
5068 {
5069 limLog( pMac, LOGW,
5070 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005071 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 nStatus );
5073
5074 // We'll fall back on the worst case scenario:
5075 nPayload = sizeof( tDot11fAddBARsp );
5076 }
5077 else if( DOT11F_WARNED( nStatus ))
5078 {
5079 limLog( pMac, LOGW,
5080 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005081 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 nStatus );
5083 }
5084
5085 // Need to allocate a buffer for ADDBA AF
5086 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5087
5088 // Allocate shared memory
5089 if( eHAL_STATUS_SUCCESS !=
5090 (halStatus = palPktAlloc( pMac->hHdd,
5091 HAL_TXRX_FRM_802_11_MGMT,
5092 (tANI_U16) frameLen,
5093 (void **) &pAddBARspBuffer,
5094 (void **) &pPacket )))
5095 {
5096 // Log error
5097 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005098 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 frameLen,
5100 halStatus );
5101
5102 statusCode = eSIR_MEM_ALLOC_FAILED;
5103 goto returnAfterError;
5104 }
5105
5106 palZeroMemory( pMac->hHdd, (void *) pAddBARspBuffer, frameLen );
5107
5108 // Copy necessary info to BD
5109 if( eSIR_SUCCESS !=
5110 (statusCode = limPopulateMacHeader( pMac,
5111 pAddBARspBuffer,
5112 SIR_MAC_MGMT_FRAME,
5113 SIR_MAC_MGMT_ACTION,
5114 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5115 goto returnAfterError;
5116
5117 // Update A3 with the BSSID
5118
5119 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5120
5121 #if 0
5122 cfgLen = SIR_MAC_ADDR_LENGTH;
5123 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5124 WNI_CFG_BSSID,
5125 (tANI_U8 *) pMacHdr->bssId,
5126 &cfgLen ))
5127 {
5128 limLog( pMac, LOGP,
5129 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005130 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005131
5132 // FIXME - Need to convert to tSirRetStatus
5133 statusCode = eSIR_FAILURE;
5134 goto returnAfterError;
5135 }
5136 #endif // TO SUPPORT BT-AMP
5137 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5138
Chet Lanctot186b5732013-03-18 10:26:30 -07005139#ifdef WLAN_FEATURE_11W
5140 if ( psessionEntry->limRmfEnabled )
5141 {
5142 pMacHdr->fc.wep = 1;
5143 }
5144#endif
5145
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 // Now, we're ready to "pack" the frames
5147 nStatus = dot11fPackAddBARsp( pMac,
5148 &frmAddBARsp,
5149 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5150 nPayload,
5151 &nPayload );
5152
5153 if( DOT11F_FAILED( nStatus ))
5154 {
5155 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005156 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 nStatus );
5158
5159 // FIXME - Need to convert to tSirRetStatus
5160 statusCode = eSIR_FAILURE;
5161 goto returnAfterError;
5162 }
5163 else if( DOT11F_WARNED( nStatus ))
5164 {
5165 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005166 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 }
5168
5169 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005170 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5172
5173 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005174 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5175 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 )
5177 {
5178 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5179 }
5180
5181 if( eHAL_STATUS_SUCCESS !=
5182 (halStatus = halTxFrame( pMac,
5183 pPacket,
5184 (tANI_U16) frameLen,
5185 HAL_TXRX_FRM_802_11_MGMT,
5186 ANI_TXDIR_TODS,
5187 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5188 limTxComplete,
5189 pAddBARspBuffer, txFlag )))
5190 {
5191 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005192 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 halStatus );
5194
5195 // FIXME - HAL error codes are different from PE error
5196 // codes!! And, this routine is returning tSirRetStatus
5197 statusCode = eSIR_FAILURE;
5198 //Pkt will be freed up by the callback
5199 return statusCode;
5200 }
5201 else
5202 return eSIR_SUCCESS;
5203
5204 returnAfterError:
5205
5206 // Release buffer, if allocated
5207 if( NULL != pAddBARspBuffer )
5208 palPktFree( pMac->hHdd,
5209 HAL_TXRX_FRM_802_11_MGMT,
5210 (void *) pAddBARspBuffer,
5211 (void *) pPacket );
5212
5213 return statusCode;
5214}
5215
5216/**
5217 * \brief Send a DELBA Indication Action Frame to peer
5218 *
5219 * \sa limSendDelBAInd
5220 *
5221 * \param pMac The global tpAniSirGlobal object
5222 *
5223 * \param peerMacAddr MAC Address of peer
5224 *
5225 * \param reasonCode Reason for the DELBA notification
5226 *
5227 * \param pBAParameterSet The DELBA Parameter Set.
5228 * This identifies the TID for which the BA session is
5229 * being deleted.
5230 *
5231 * \return eSIR_SUCCESS if setup completes successfully
5232 * eSIR_FAILURE is some problem is encountered
5233 */
5234tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5235 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5236{
5237 tDot11fDelBAInd frmDelBAInd;
5238 tANI_U8 *pDelBAIndBuffer = NULL;
5239 //tANI_U32 val;
5240 tpSirMacMgmtHdr pMacHdr;
5241 tANI_U32 frameLen = 0, nStatus, nPayload;
5242 tSirRetStatus statusCode;
5243 eHalStatus halStatus;
5244 void *pPacket;
5245 tANI_U8 txFlag = 0;
5246
5247 if(NULL == psessionEntry)
5248 {
5249 return eSIR_FAILURE;
5250 }
5251
5252 palZeroMemory( pMac->hHdd, (void *) &frmDelBAInd, sizeof( frmDelBAInd ));
5253
5254 // Category - 3 (BA)
5255 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5256 // Action - 2 (DELBA)
5257 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5258
5259 // Fill the DELBA Parameter Set as provided by caller
5260 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5261 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5262
5263 // BA Starting Sequence Number
5264 // Fragment number will always be zero
5265 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5266
5267 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5268
5269 if( DOT11F_FAILED( nStatus ))
5270 {
5271 limLog( pMac, LOGW,
5272 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005273 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 nStatus );
5275
5276 // We'll fall back on the worst case scenario:
5277 nPayload = sizeof( tDot11fDelBAInd );
5278 }
5279 else if( DOT11F_WARNED( nStatus ))
5280 {
5281 limLog( pMac, LOGW,
5282 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005283 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 nStatus );
5285 }
5286
5287 // Add the MGMT header to frame length
5288 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5289
5290 // Allocate shared memory
5291 if( eHAL_STATUS_SUCCESS !=
5292 (halStatus = palPktAlloc( pMac->hHdd,
5293 HAL_TXRX_FRM_802_11_MGMT,
5294 (tANI_U16) frameLen,
5295 (void **) &pDelBAIndBuffer,
5296 (void **) &pPacket )))
5297 {
5298 // Log error
5299 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005300 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005301 frameLen,
5302 halStatus );
5303
5304 statusCode = eSIR_MEM_ALLOC_FAILED;
5305 goto returnAfterError;
5306 }
5307
5308 palZeroMemory( pMac->hHdd, (void *) pDelBAIndBuffer, frameLen );
5309
5310 // Copy necessary info to BD
5311 if( eSIR_SUCCESS !=
5312 (statusCode = limPopulateMacHeader( pMac,
5313 pDelBAIndBuffer,
5314 SIR_MAC_MGMT_FRAME,
5315 SIR_MAC_MGMT_ACTION,
5316 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5317 goto returnAfterError;
5318
5319 // Update A3 with the BSSID
5320 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5321
5322 #if 0
5323 cfgLen = SIR_MAC_ADDR_LENGTH;
5324 if( eSIR_SUCCESS != cfgGetStr( pMac,
5325 WNI_CFG_BSSID,
5326 (tANI_U8 *) pMacHdr->bssId,
5327 &cfgLen ))
5328 {
5329 limLog( pMac, LOGP,
5330 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005331 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005332
5333 // FIXME - Need to convert to tSirRetStatus
5334 statusCode = eSIR_FAILURE;
5335 goto returnAfterError;
5336 }
5337 #endif //TO SUPPORT BT-AMP
5338 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5339
Chet Lanctot186b5732013-03-18 10:26:30 -07005340#ifdef WLAN_FEATURE_11W
5341 if ( psessionEntry->limRmfEnabled )
5342 {
5343 pMacHdr->fc.wep = 1;
5344 }
5345#endif
5346
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 // Now, we're ready to "pack" the frames
5348 nStatus = dot11fPackDelBAInd( pMac,
5349 &frmDelBAInd,
5350 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5351 nPayload,
5352 &nPayload );
5353
5354 if( DOT11F_FAILED( nStatus ))
5355 {
5356 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005357 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 nStatus );
5359
5360 // FIXME - Need to convert to tSirRetStatus
5361 statusCode = eSIR_FAILURE;
5362 goto returnAfterError;
5363 }
5364 else if( DOT11F_WARNED( nStatus ))
5365 {
5366 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005367 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 }
5369
5370 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005371 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5373
5374 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5376 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 )
5378 {
5379 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5380 }
5381
5382 if( eHAL_STATUS_SUCCESS !=
5383 (halStatus = halTxFrame( pMac,
5384 pPacket,
5385 (tANI_U16) frameLen,
5386 HAL_TXRX_FRM_802_11_MGMT,
5387 ANI_TXDIR_TODS,
5388 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5389 limTxComplete,
5390 pDelBAIndBuffer, txFlag )))
5391 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005392 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 statusCode = eSIR_FAILURE;
5394 //Pkt will be freed up by the callback
5395 return statusCode;
5396 }
5397 else
5398 return eSIR_SUCCESS;
5399
5400 returnAfterError:
5401
5402 // Release buffer, if allocated
5403 if( NULL != pDelBAIndBuffer )
5404 palPktFree( pMac->hHdd,
5405 HAL_TXRX_FRM_802_11_MGMT,
5406 (void *) pDelBAIndBuffer,
5407 (void *) pPacket );
5408
5409 return statusCode;
5410}
5411
5412#if defined WLAN_FEATURE_VOWIFI
5413
5414/**
5415 * \brief Send a Neighbor Report Request Action frame
5416 *
5417 *
5418 * \param pMac Pointer to the global MAC structure
5419 *
5420 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5421 *
5422 * \param peer mac address of peer station.
5423 *
5424 * \param psessionEntry address of session entry.
5425 *
5426 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5427 *
5428 *
5429 */
5430
5431tSirRetStatus
5432limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5433 tpSirMacNeighborReportReq pNeighborReq,
5434 tSirMacAddr peer,
5435 tpPESession psessionEntry
5436 )
5437{
5438 tSirRetStatus statusCode = eSIR_SUCCESS;
5439 tDot11fNeighborReportRequest frm;
5440 tANI_U8 *pFrame;
5441 tpSirMacMgmtHdr pMacHdr;
5442 tANI_U32 nBytes, nPayload, nStatus;
5443 void *pPacket;
5444 eHalStatus halstatus;
5445 tANI_U8 txFlag = 0;
5446
5447 if ( psessionEntry == NULL )
5448 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005449 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 return eSIR_FAILURE;
5451 }
5452 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5453
5454 frm.Category.category = SIR_MAC_ACTION_RRM;
5455 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5456 frm.DialogToken.token = pNeighborReq->dialogToken;
5457
5458
5459 if( pNeighborReq->ssid_present )
5460 {
5461 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5462 }
5463
5464 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5465 if ( DOT11F_FAILED( nStatus ) )
5466 {
5467 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005468 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 nStatus );
5470 // We'll fall back on the worst case scenario:
5471 nPayload = sizeof( tDot11fNeighborReportRequest );
5472 }
5473 else if ( DOT11F_WARNED( nStatus ) )
5474 {
5475 limLog( pMac, LOGW, FL("There were warnings while calculating"
5476 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005477 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 }
5479
5480 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5481
5482 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5483 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5484 {
5485 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005486 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 return eSIR_FAILURE;
5488 }
5489
5490 // Paranoia:
5491 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5492
5493 // Copy necessary info to BD
5494 if( eSIR_SUCCESS !=
5495 (statusCode = limPopulateMacHeader( pMac,
5496 pFrame,
5497 SIR_MAC_MGMT_FRAME,
5498 SIR_MAC_MGMT_ACTION,
5499 peer, psessionEntry->selfMacAddr)))
5500 goto returnAfterError;
5501
5502 // Update A3 with the BSSID
5503 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5504
5505 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5506
Chet Lanctot186b5732013-03-18 10:26:30 -07005507#ifdef WLAN_FEATURE_11W
5508 if ( psessionEntry->limRmfEnabled )
5509 {
5510 pMacHdr->fc.wep = 1;
5511 }
5512#endif
5513
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 // Now, we're ready to "pack" the frames
5515 nStatus = dot11fPackNeighborReportRequest( pMac,
5516 &frm,
5517 pFrame + sizeof( tSirMacMgmtHdr ),
5518 nPayload,
5519 &nPayload );
5520
5521 if( DOT11F_FAILED( nStatus ))
5522 {
5523 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005524 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 nStatus );
5526
5527 // FIXME - Need to convert to tSirRetStatus
5528 statusCode = eSIR_FAILURE;
5529 goto returnAfterError;
5530 }
5531 else if( DOT11F_WARNED( nStatus ))
5532 {
5533 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005534 FL( "There were warnings while packing Neighbor Report Request (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 }
5536
5537 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005538 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 limPrintMacAddr( pMac, peer, LOGW );
5540
5541 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5543 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 )
5545 {
5546 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5547 }
5548
5549 if( eHAL_STATUS_SUCCESS !=
5550 (halstatus = halTxFrame( pMac,
5551 pPacket,
5552 (tANI_U16) nBytes,
5553 HAL_TXRX_FRM_802_11_MGMT,
5554 ANI_TXDIR_TODS,
5555 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5556 limTxComplete,
5557 pFrame, txFlag )))
5558 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005559 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 statusCode = eSIR_FAILURE;
5561 //Pkt will be freed up by the callback
5562 return statusCode;
5563 }
5564 else
5565 return eSIR_SUCCESS;
5566
5567returnAfterError:
5568 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5569
5570 return statusCode;
5571} // End limSendNeighborReportRequestFrame.
5572
5573/**
5574 * \brief Send a Link Report Action frame
5575 *
5576 *
5577 * \param pMac Pointer to the global MAC structure
5578 *
5579 * \param pLinkReport Address of a tSirMacLinkReport
5580 *
5581 * \param peer mac address of peer station.
5582 *
5583 * \param psessionEntry address of session entry.
5584 *
5585 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5586 *
5587 *
5588 */
5589
5590tSirRetStatus
5591limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5592 tpSirMacLinkReport pLinkReport,
5593 tSirMacAddr peer,
5594 tpPESession psessionEntry
5595 )
5596{
5597 tSirRetStatus statusCode = eSIR_SUCCESS;
5598 tDot11fLinkMeasurementReport frm;
5599 tANI_U8 *pFrame;
5600 tpSirMacMgmtHdr pMacHdr;
5601 tANI_U32 nBytes, nPayload, nStatus;
5602 void *pPacket;
5603 eHalStatus halstatus;
5604 tANI_U8 txFlag = 0;
5605
5606
5607 if ( psessionEntry == NULL )
5608 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005609 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 return eSIR_FAILURE;
5611 }
5612
5613 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5614
5615 frm.Category.category = SIR_MAC_ACTION_RRM;
5616 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5617 frm.DialogToken.token = pLinkReport->dialogToken;
5618
5619
5620 //IEEE Std. 802.11 7.3.2.18. for the report element.
5621 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5622 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5623 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5624 //such case this way than changing the frame parser.
5625 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5626 frm.TPCEleLen.TPCLen = 2;
5627 frm.TxPower.txPower = pLinkReport->txPower;
5628 frm.LinkMargin.linkMargin = 0;
5629
5630 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5631 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5632 frm.RCPI.rcpi = pLinkReport->rcpi;
5633 frm.RSNI.rsni = pLinkReport->rsni;
5634
5635 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5636 if ( DOT11F_FAILED( nStatus ) )
5637 {
5638 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005639 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 nStatus );
5641 // We'll fall back on the worst case scenario:
5642 nPayload = sizeof( tDot11fLinkMeasurementReport );
5643 }
5644 else if ( DOT11F_WARNED( nStatus ) )
5645 {
5646 limLog( pMac, LOGW, FL("There were warnings while calculating"
5647 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005648 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 }
5650
5651 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5652
5653 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5654 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5655 {
5656 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005657 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 return eSIR_FAILURE;
5659 }
5660
5661 // Paranoia:
5662 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5663
5664 // Copy necessary info to BD
5665 if( eSIR_SUCCESS !=
5666 (statusCode = limPopulateMacHeader( pMac,
5667 pFrame,
5668 SIR_MAC_MGMT_FRAME,
5669 SIR_MAC_MGMT_ACTION,
5670 peer, psessionEntry->selfMacAddr)))
5671 goto returnAfterError;
5672
5673 // Update A3 with the BSSID
5674 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5675
5676 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5677
Chet Lanctot186b5732013-03-18 10:26:30 -07005678#ifdef WLAN_FEATURE_11W
5679 if ( psessionEntry->limRmfEnabled )
5680 {
5681 pMacHdr->fc.wep = 1;
5682 }
5683#endif
5684
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 // Now, we're ready to "pack" the frames
5686 nStatus = dot11fPackLinkMeasurementReport( pMac,
5687 &frm,
5688 pFrame + sizeof( tSirMacMgmtHdr ),
5689 nPayload,
5690 &nPayload );
5691
5692 if( DOT11F_FAILED( nStatus ))
5693 {
5694 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005695 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 nStatus );
5697
5698 // FIXME - Need to convert to tSirRetStatus
5699 statusCode = eSIR_FAILURE;
5700 goto returnAfterError;
5701 }
5702 else if( DOT11F_WARNED( nStatus ))
5703 {
5704 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005705 FL( "There were warnings while packing Link Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 }
5707
5708 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005709 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 limPrintMacAddr( pMac, peer, LOGW );
5711
5712 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5714 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 )
5716 {
5717 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5718 }
5719
5720 if( eHAL_STATUS_SUCCESS !=
5721 (halstatus = halTxFrame( pMac,
5722 pPacket,
5723 (tANI_U16) nBytes,
5724 HAL_TXRX_FRM_802_11_MGMT,
5725 ANI_TXDIR_TODS,
5726 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5727 limTxComplete,
5728 pFrame, txFlag )))
5729 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005730 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 statusCode = eSIR_FAILURE;
5732 //Pkt will be freed up by the callback
5733 return statusCode;
5734 }
5735 else
5736 return eSIR_SUCCESS;
5737
5738returnAfterError:
5739 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5740
5741 return statusCode;
5742} // End limSendLinkReportActionFrame.
5743
5744/**
5745 * \brief Send a Beacon Report Action frame
5746 *
5747 *
5748 * \param pMac Pointer to the global MAC structure
5749 *
5750 * \param dialog_token dialog token to be used in the action frame.
5751 *
5752 * \param num_report number of reports in pRRMReport.
5753 *
5754 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5755 *
5756 * \param peer mac address of peer station.
5757 *
5758 * \param psessionEntry address of session entry.
5759 *
5760 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5761 *
5762 *
5763 */
5764
5765tSirRetStatus
5766limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5767 tANI_U8 dialog_token,
5768 tANI_U8 num_report,
5769 tpSirMacRadioMeasureReport pRRMReport,
5770 tSirMacAddr peer,
5771 tpPESession psessionEntry
5772 )
5773{
5774 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 tANI_U8 *pFrame;
5776 tpSirMacMgmtHdr pMacHdr;
5777 tANI_U32 nBytes, nPayload, nStatus;
5778 void *pPacket;
5779 eHalStatus halstatus;
5780 tANI_U8 i;
5781 tANI_U8 txFlag = 0;
5782
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005783 tDot11fRadioMeasurementReport *frm =
5784 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5785 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005786 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005787 return eSIR_FAILURE;
5788 }
5789
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 if ( psessionEntry == NULL )
5791 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005792 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005793 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 return eSIR_FAILURE;
5795 }
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005796 palZeroMemory( pMac->hHdd, ( tANI_U8* )frm, sizeof( *frm ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005797
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005798 frm->Category.category = SIR_MAC_ACTION_RRM;
5799 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5800 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005801
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005802 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 -07005803
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005804 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005806 frm->MeasurementReport[i].type = pRRMReport[i].type;
5807 frm->MeasurementReport[i].token = pRRMReport[i].token;
5808 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 switch( pRRMReport[i].type )
5810 {
5811 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005812 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5813 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5814 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5815 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 break;
5817 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305818 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5819 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005820 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 break;
5822 }
5823 }
5824
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005825 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 if ( DOT11F_FAILED( nStatus ) )
5827 {
5828 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005829 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 nStatus );
5831 // We'll fall back on the worst case scenario:
5832 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005833 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 return eSIR_FAILURE;
5835 }
5836 else if ( DOT11F_WARNED( nStatus ) )
5837 {
5838 limLog( pMac, LOGW, FL("There were warnings while calculating"
5839 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005840 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 }
5842
5843 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5844
5845 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5846 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5847 {
5848 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005849 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005850 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 return eSIR_FAILURE;
5852 }
5853
5854 // Paranoia:
5855 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5856
5857 // Copy necessary info to BD
5858 if( eSIR_SUCCESS !=
5859 (statusCode = limPopulateMacHeader( pMac,
5860 pFrame,
5861 SIR_MAC_MGMT_FRAME,
5862 SIR_MAC_MGMT_ACTION,
5863 peer, psessionEntry->selfMacAddr)))
5864 goto returnAfterError;
5865
5866 // Update A3 with the BSSID
5867 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5868
5869 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5870
Chet Lanctot186b5732013-03-18 10:26:30 -07005871#ifdef WLAN_FEATURE_11W
5872 if ( psessionEntry->limRmfEnabled )
5873 {
5874 pMacHdr->fc.wep = 1;
5875 }
5876#endif
5877
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 // Now, we're ready to "pack" the frames
5879 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005880 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 pFrame + sizeof( tSirMacMgmtHdr ),
5882 nPayload,
5883 &nPayload );
5884
5885 if( DOT11F_FAILED( nStatus ))
5886 {
5887 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005888 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 nStatus );
5890
5891 // FIXME - Need to convert to tSirRetStatus
5892 statusCode = eSIR_FAILURE;
5893 goto returnAfterError;
5894 }
5895 else if( DOT11F_WARNED( nStatus ))
5896 {
5897 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005898 FL( "There were warnings while packing Radio Measure Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 }
5900
5901 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005902 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 limPrintMacAddr( pMac, peer, LOGW );
5904
5905 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5907 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 )
5909 {
5910 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5911 }
5912
5913 if( eHAL_STATUS_SUCCESS !=
5914 (halstatus = halTxFrame( pMac,
5915 pPacket,
5916 (tANI_U16) nBytes,
5917 HAL_TXRX_FRM_802_11_MGMT,
5918 ANI_TXDIR_TODS,
5919 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5920 limTxComplete,
5921 pFrame, txFlag )))
5922 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005923 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 statusCode = eSIR_FAILURE;
5925 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005926 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 return statusCode;
5928 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005929 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005930 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005932 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005933
5934returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005935 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 return statusCode;
5938} // End limSendBeaconReportActionFrame.
5939
5940#endif
5941
5942#ifdef WLAN_FEATURE_11W
5943/**
5944 * \brief Send SA query response action frame to peer
5945 *
5946 * \sa limSendSaQueryResponseFrame
5947 *
5948 *
5949 * \param pMac The global tpAniSirGlobal object
5950 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005951 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005953 * \param peer The Mac address of the AP to which this action frame is addressed
5954 *
5955 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 *
5957 * \return eSIR_SUCCESS if setup completes successfully
5958 * eSIR_FAILURE is some problem is encountered
5959 */
5960
Chet Lanctot186b5732013-03-18 10:26:30 -07005961tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005962tSirMacAddr peer,tpPESession psessionEntry)
5963{
5964
Chet Lanctot186b5732013-03-18 10:26:30 -07005965 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 tANI_U8 *pFrame;
5967 tSirRetStatus nSirStatus;
5968 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07005969 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 void *pPacket;
5971 eHalStatus halstatus;
Chet Lanctot186b5732013-03-18 10:26:30 -07005972 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005973
5974 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
Chet Lanctot186b5732013-03-18 10:26:30 -07005975 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
5976 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 action: 0 --> SA query request action frame
5978 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07005979 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
5980 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07005982 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005983
Chet Lanctot186b5732013-03-18 10:26:30 -07005984 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
5985 if ( DOT11F_FAILED( nStatus ) )
5986 {
5987 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5988 "or a SA Query Response (0x%08x)."),
5989 nStatus );
5990 // We'll fall back on the worst case scenario:
5991 nPayload = sizeof( tDot11fSaQueryRsp );
5992 }
5993 else if ( DOT11F_WARNED( nStatus ) )
5994 {
5995 limLog( pMac, LOGW, FL("There were warnings while calculating"
5996 "the packed size for an SA Query Response"
5997 " (0x%08x)."), nStatus );
5998 }
5999
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6001 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6002 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6003 {
6004 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006005 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 return eSIR_FAILURE;
6007 }
6008
6009 // Paranoia:
6010 palZeroMemory( pMac->hHdd, pFrame, nBytes );
6011
Chet Lanctot186b5732013-03-18 10:26:30 -07006012 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006013 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006014 pFrame,
6015 SIR_MAC_MGMT_FRAME,
6016 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006017 peer, psessionEntry->selfMacAddr );
6018 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006019 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006020
Chet Lanctot186b5732013-03-18 10:26:30 -07006021 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6023
Chet Lanctot186b5732013-03-18 10:26:30 -07006024 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006025
Chet Lanctot186b5732013-03-18 10:26:30 -07006026 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6027 // in the FC
6028 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006030 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 }
6032
Chet Lanctot186b5732013-03-18 10:26:30 -07006033 // Pack 11w SA query response frame
6034 nStatus = dot11fPackSaQueryRsp( pMac,
6035 &frm,
6036 pFrame + sizeof( tSirMacMgmtHdr ),
6037 nPayload,
6038 &nPayload );
6039
6040 if ( DOT11F_FAILED( nStatus ))
6041 {
6042 limLog( pMac, LOGE,
6043 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6044 nStatus );
6045 // FIXME - Need to convert to tSirRetStatus
6046 nSirStatus = eSIR_FAILURE;
6047 goto returnAfterError;
6048 }
6049 else if ( DOT11F_WARNED( nStatus ))
6050 {
6051 limLog( pMac, LOGW,
6052 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6053 nStatus);
6054 }
6055
6056 limLog( pMac, LOG1,
6057 FL( "Sending a SA Query Response to " ));
6058 limPrintMacAddr( pMac, peer, LOGW );
6059
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006060 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006061#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006062 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6063 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006064#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006065 )
6066 {
6067 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6068 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006069
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006070 halstatus = halTxFrame( pMac,
6071 pPacket,
6072 (tANI_U16) nBytes,
6073 HAL_TXRX_FRM_802_11_MGMT,
6074 ANI_TXDIR_TODS,
6075 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6076 limTxComplete,
6077 pFrame, txFlag );
6078 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006079 {
6080 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6081 nSirStatus = eSIR_FAILURE;
6082 //Pkt will be freed up by the callback
6083 return nSirStatus;
6084 }
6085 else {
6086 return eSIR_SUCCESS;
6087 }
6088
6089returnAfterError:
6090 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6091 return nSirStatus;
6092} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006093#endif