blob: 161ef7839a4a6fd29dc1361d4d9ad37d570be670 [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
2544 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length) )
2545 {
2546 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2547 }
2548#endif
2549
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2551 if ( DOT11F_FAILED( nStatus ) )
2552 {
2553 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002554 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 nStatus );
2556 // We'll fall back on the worst case scenario:
2557 nPayload = sizeof( tDot11fReAssocRequest );
2558 }
2559 else if ( DOT11F_WARNED( nStatus ) )
2560 {
2561 limLog( pMac, LOGW, FL("There were warnings while calculating"
2562 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002563 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 }
2565
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002566 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002567
2568#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002569 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2571#endif
2572
2573#if defined WLAN_FEATURE_VOWIFI_11R
2574 if (psessionEntry->is11Rconnection)
2575 {
2576 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2577 }
2578#endif
2579
2580 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2581 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2582 ( void** ) &pPacket );
2583 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2584 {
2585 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002586 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002587 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002588 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 goto end;
2590 }
2591
2592 // Paranoia:
2593 palZeroMemory( pMac->hHdd, pFrame, nBytes + ft_ies_length);
2594
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002595#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002596 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002597#endif
2598 // Next, we fill out the buffer descriptor:
2599 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2600 SIR_MAC_MGMT_REASSOC_REQ,
2601 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2602 if ( eSIR_SUCCESS != nSirStatus )
2603 {
2604 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002605 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 nSirStatus );
2607 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2608 goto end;
2609 }
2610
2611
2612 // That done, pack the ReAssoc Request:
2613 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2614 sizeof(tSirMacMgmtHdr),
2615 nPayload, &nPayload );
2616 if ( DOT11F_FAILED( nStatus ) )
2617 {
2618 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002619 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 nStatus );
2621 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2622 goto end;
2623 }
2624 else if ( DOT11F_WARNED( nStatus ) )
2625 {
2626 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002627 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 }
2629
2630 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002631 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 nBytes, nPayload );)
2633 if( psessionEntry->assocReq != NULL )
2634 {
2635 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2636 psessionEntry->assocReq = NULL;
2637 }
2638
2639 if( nAddIELen )
2640 {
2641 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2642 pAddIE,
2643 nAddIELen );
2644 nPayload += nAddIELen;
2645 }
2646
Jeff Johnson43971f52012-07-17 12:26:56 -07002647 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2648 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 {
2650 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002651 }
2652 else
2653 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2655 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2656 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002658
2659 if (psessionEntry->is11Rconnection)
2660 {
2661 {
2662 int i = 0;
2663
2664 pBody = pFrame + nBytes;
2665 for (i=0; i<ft_ies_length; i++)
2666 {
2667 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2668 pBody++;
2669 }
2670 }
2671 }
2672
2673#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002674 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2675 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 (tANI_U8 *)pFrame,
2677 (nBytes + ft_ies_length));)
2678#endif
2679
2680
2681 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2683 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 )
2685 {
2686 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2687 }
2688
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002689 if( NULL != psessionEntry->assocReq )
2690 {
2691 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2692 psessionEntry->assocReq = NULL;
2693 }
2694
2695 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2696 (ft_ies_length))) != eHAL_STATUS_SUCCESS )
2697 {
2698 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002699 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002700 }
2701 else
2702 {
2703 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2704 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2705 (ft_ies_length));
2706 psessionEntry->assocReqLen = (ft_ies_length);
2707 }
2708
2709
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2711 HAL_TXRX_FRM_802_11_MGMT,
2712 ANI_TXDIR_TODS,
2713 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2714 limTxComplete, pFrame, txFlag );
2715 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2716 {
2717 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002718 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 nSirStatus );
2720 //Pkt will be freed up by the callback
2721 goto end;
2722 }
2723
2724end:
2725 // Free up buffer allocated for mlmAssocReq
2726 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
2727 psessionEntry->pLimMlmReassocReq = NULL;
2728
2729}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002730
2731void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2732 tLimMlmReassocReq *pMlmReassocReq,
2733 tpPESession psessionEntry)
2734{
2735 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2736 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2737 if(NULL == pTmpMlmReassocReq)
2738 {
2739 if ( !HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pTmpMlmReassocReq, sizeof(tLimMlmReassocReq))) ) goto end;
2740 palZeroMemory(pMac->hHdd, pTmpMlmReassocReq, sizeof(tLimMlmReassocReq));
2741 palCopyMemory( pMac->hHdd, pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
2742 }
2743
2744 // Prepare and send Reassociation request frame
2745 // start reassoc timer.
2746 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2747 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002748 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002749 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2750 != TX_SUCCESS)
2751 {
2752 // Could not start reassoc failure timer.
2753 // Log error
2754 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002755 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002756 // Return Reassoc confirm with
2757 // Resources Unavailable
2758 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2759 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2760 goto end;
2761 }
2762
2763 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2764 return;
2765
2766end:
2767 // Free up buffer allocated for reassocReq
2768 if (pMlmReassocReq != NULL)
2769 {
2770 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
2771 pMlmReassocReq = NULL;
2772 }
2773 if (pTmpMlmReassocReq != NULL)
2774 {
2775 palFreeMemory( pMac->hHdd, (tANI_U8 *) pTmpMlmReassocReq);
2776 pTmpMlmReassocReq = NULL;
2777 }
2778 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2779 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2780 /* Update PE sessio Id*/
2781 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2782
2783 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2784}
2785
Jeff Johnson295189b2012-06-20 16:38:30 -07002786#endif /* WLAN_FEATURE_VOWIFI_11R */
2787
2788
2789void
2790limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2791 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2792{
2793 static tDot11fReAssocRequest frm;
2794 tANI_U16 caps;
2795 tANI_U8 *pFrame;
2796 tSirRetStatus nSirStatus;
2797 tANI_U32 nBytes, nPayload, nStatus;
2798 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2799 void *pPacket;
2800 eHalStatus halstatus;
2801 tANI_U16 nAddIELen;
2802 tANI_U8 *pAddIE;
2803 tANI_U8 *wpsIe = NULL;
2804 tANI_U8 txFlag = 0;
2805#if defined WLAN_FEATURE_VOWIFI
2806 tANI_U8 PowerCapsPopulated = FALSE;
2807#endif
2808
2809 if(NULL == psessionEntry)
2810 {
2811 return;
2812 }
2813
2814 /* check this early to avoid unncessary operation */
2815 if(NULL == psessionEntry->pLimReAssocReq)
2816 {
2817 return;
2818 }
2819 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2820 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2821
2822 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
2823
2824 caps = pMlmReassocReq->capabilityInfo;
2825 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2826 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2827#if defined(FEATURE_WLAN_WAPI)
2828 /* CR: 262463 :
2829 According to WAPI standard:
2830 7.3.1.4 Capability Information field
2831 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2832 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2833 Reassociation management frames. */
2834 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2835 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2836#endif
2837 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2838
2839 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2840
2841 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
2842 ( tANI_U8* )psessionEntry->bssId, 6 );
2843
2844 PopulateDot11fSSID2( pMac, &frm.SSID );
2845 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2846 &frm.SuppRates,psessionEntry);
2847
2848 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2849 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2850
2851 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2852 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2853
2854 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2855 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2856
2857
2858 if ( psessionEntry->lim11hEnable &&
2859 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2860 {
2861#if defined WLAN_FEATURE_VOWIFI
2862 PowerCapsPopulated = TRUE;
2863 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2864 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2865#endif
2866 }
2867
2868#if defined WLAN_FEATURE_VOWIFI
2869 if( pMac->rrm.rrmPEContext.rrmEnable &&
2870 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2871 {
2872 if (PowerCapsPopulated == FALSE)
2873 {
2874 PowerCapsPopulated = TRUE;
2875 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2876 }
2877 }
2878#endif
2879
2880 if ( fQosEnabled &&
2881 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2882 {
2883 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2884 }
2885
2886 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2887 &frm.ExtSuppRates, psessionEntry );
2888
2889#if defined WLAN_FEATURE_VOWIFI
2890 if( pMac->rrm.rrmPEContext.rrmEnable &&
2891 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2892 {
2893 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2894 }
2895#endif
2896 // The join request *should* contain zero or one of the WPA and RSN
2897 // IEs. The payload send along with the request is a
2898 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2899
2900 // typedef struct sSirRSNie
2901 // {
2902 // tANI_U16 length;
2903 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2904 // } tSirRSNie, *tpSirRSNie;
2905
2906 // So, we should be able to make the following two calls harmlessly,
2907 // since they do nothing if they don't find the given IE in the
2908 // bytestream with which they're provided.
2909
2910 // The net effect of this will be to faithfully transmit whatever
2911 // security IE is in the join request.
2912
2913 // *However*, if we're associating for the purpose of WPS
2914 // enrollment, and we've been configured to indicate that by
2915 // eliding the WPA or RSN IE, we just skip this:
2916 if( nAddIELen && pAddIE )
2917 {
2918 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2919 }
2920 if ( NULL == wpsIe )
2921 {
2922 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2923 &frm.RSNOpaque );
2924 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2925 &frm.WPAOpaque );
2926#if defined(FEATURE_WLAN_WAPI)
2927 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2928 &frm.WAPIOpaque );
2929#endif // defined(FEATURE_WLAN_WAPI)
2930 }
2931
2932 // include WME EDCA IE as well
2933 if ( fWmeEnabled )
2934 {
2935 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2936 {
2937 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2938 }
2939
2940 if ( fWsmEnabled &&
2941 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2942 {
2943 PopulateDot11fWMMCaps( &frm.WMMCaps );
2944 }
2945 }
2946
Jeff Johnsone7245742012-09-05 17:12:55 -07002947 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 pMac->lim.htCapabilityPresentInBeacon)
2949 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002950 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002952#ifdef WLAN_FEATURE_11AC
2953 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002954 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002955 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002956 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002957 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07002958 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002959 }
2960#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002961
2962 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2963 if ( DOT11F_FAILED( nStatus ) )
2964 {
2965 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002966 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 nStatus );
2968 // We'll fall back on the worst case scenario:
2969 nPayload = sizeof( tDot11fReAssocRequest );
2970 }
2971 else if ( DOT11F_WARNED( nStatus ) )
2972 {
2973 limLog( pMac, LOGW, FL("There were warnings while calculating"
2974 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002975 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 }
2977
2978 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2979
2980 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2981 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2982 ( void** ) &pPacket );
2983 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2984 {
2985 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002986 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002988 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 goto end;
2990 }
2991
2992 // Paranoia:
2993 palZeroMemory( pMac->hHdd, pFrame, nBytes );
2994
2995 // Next, we fill out the buffer descriptor:
2996 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2997 SIR_MAC_MGMT_REASSOC_REQ,
2998 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2999 if ( eSIR_SUCCESS != nSirStatus )
3000 {
3001 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003002 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 nSirStatus );
3004 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3005 goto end;
3006 }
3007
3008
3009 // That done, pack the Probe Request:
3010 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3011 sizeof(tSirMacMgmtHdr),
3012 nPayload, &nPayload );
3013 if ( DOT11F_FAILED( nStatus ) )
3014 {
3015 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003016 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003017 nStatus );
3018 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3019 goto end;
3020 }
3021 else if ( DOT11F_WARNED( nStatus ) )
3022 {
3023 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003024 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003025 }
3026
3027 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003028 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 nBytes );)
3030
3031 if( psessionEntry->assocReq != NULL )
3032 {
3033 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
3034 psessionEntry->assocReq = NULL;
3035 }
3036
3037 if( nAddIELen )
3038 {
3039 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3040 pAddIE,
3041 nAddIELen );
3042 nPayload += nAddIELen;
3043 }
3044
Jeff Johnson43971f52012-07-17 12:26:56 -07003045 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
3046 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 {
3048 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003049 }
3050 else
3051 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3053 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
3054 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003056
3057 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3059 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 )
3061 {
3062 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3063 }
3064
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003065 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003066 {
3067 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3068 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003069
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3071 HAL_TXRX_FRM_802_11_MGMT,
3072 ANI_TXDIR_TODS,
3073 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3074 limTxComplete, pFrame, txFlag );
3075 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3076 {
3077 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003078 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 nSirStatus );
3080 //Pkt will be freed up by the callback
3081 goto end;
3082 }
3083
3084end:
3085 // Free up buffer allocated for mlmAssocReq
3086 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3087 psessionEntry->pLimMlmReassocReq = NULL;
3088
3089} // limSendReassocReqMgmtFrame
3090
3091/**
3092 * \brief Send an Authentication frame
3093 *
3094 *
3095 * \param pMac Pointer to Global MAC structure
3096 *
3097 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3098 * to be sent
3099 *
3100 * \param peerMacAddr MAC address of the peer entity to which Authentication
3101 * frame is destined
3102 *
3103 * \param wepBit Indicates whether wep bit to be set in FC while sending
3104 * Authentication frame3
3105 *
3106 *
3107 * This function is called by limProcessMlmMessages(). Authentication frame
3108 * is formatted and sent when this function is called.
3109 *
3110 *
3111 */
3112
3113void
3114limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3115 tpSirMacAuthFrameBody pAuthFrameBody,
3116 tSirMacAddr peerMacAddr,
3117 tANI_U8 wepBit,
3118 tpPESession psessionEntry
3119 )
3120{
3121 tANI_U8 *pFrame, *pBody;
3122 tANI_U32 frameLen = 0, bodyLen = 0;
3123 tpSirMacMgmtHdr pMacHdr;
3124 tANI_U16 i;
3125 void *pPacket;
3126 eHalStatus halstatus;
3127 tANI_U8 txFlag = 0;
3128
3129 if(NULL == psessionEntry)
3130 {
3131 return;
3132 }
3133
3134 if (wepBit == LIM_WEP_IN_FC)
3135 {
3136 /// Auth frame3 to be sent with encrypted framebody
3137 /**
3138 * Allocate buffer for Authenticaton frame of size equal
3139 * to management frame header length plus 2 bytes each for
3140 * auth algorithm number, transaction number, status code,
3141 * 128 bytes for challenge text and 4 bytes each for
3142 * IV & ICV.
3143 */
3144
3145 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3146
3147 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3148 } // if (wepBit == LIM_WEP_IN_FC)
3149 else
3150 {
3151 switch (pAuthFrameBody->authTransactionSeqNumber)
3152 {
3153 case SIR_MAC_AUTH_FRAME_1:
3154 /**
3155 * Allocate buffer for Authenticaton frame of size
3156 * equal to management frame header length plus 2 bytes
3157 * each for auth algorithm number, transaction number
3158 * and status code.
3159 */
3160
3161 frameLen = sizeof(tSirMacMgmtHdr) +
3162 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3163 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3164
3165#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003166 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3167 {
3168 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003170 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003171 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003172 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003174 else
3175 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003176 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003177 frameLen += (2+SIR_MDIE_SIZE);
3178 }
3179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003180#endif
3181 break;
3182
3183 case SIR_MAC_AUTH_FRAME_2:
3184 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3185 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3186 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3187 {
3188 /**
3189 * Allocate buffer for Authenticaton frame of size
3190 * equal to management frame header length plus
3191 * 2 bytes each for auth algorithm number,
3192 * transaction number and status code.
3193 */
3194
3195 frameLen = sizeof(tSirMacMgmtHdr) +
3196 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3197 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3198 }
3199 else
3200 {
3201 // Shared Key algorithm with challenge text
3202 // to be sent
3203 /**
3204 * Allocate buffer for Authenticaton frame of size
3205 * equal to management frame header length plus
3206 * 2 bytes each for auth algorithm number,
3207 * transaction number, status code and 128 bytes
3208 * for challenge text.
3209 */
3210
3211 frameLen = sizeof(tSirMacMgmtHdr) +
3212 sizeof(tSirMacAuthFrame);
3213 bodyLen = sizeof(tSirMacAuthFrameBody);
3214 }
3215
3216 break;
3217
3218 case SIR_MAC_AUTH_FRAME_3:
3219 /// Auth frame3 to be sent without encrypted framebody
3220 /**
3221 * Allocate buffer for Authenticaton frame of size equal
3222 * to management frame header length plus 2 bytes each
3223 * for auth algorithm number, transaction number and
3224 * status code.
3225 */
3226
3227 frameLen = sizeof(tSirMacMgmtHdr) +
3228 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3229 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3230
3231 break;
3232
3233 case SIR_MAC_AUTH_FRAME_4:
3234 /**
3235 * Allocate buffer for Authenticaton frame of size equal
3236 * to management frame header length plus 2 bytes each
3237 * for auth algorithm number, transaction number and
3238 * status code.
3239 */
3240
3241 frameLen = sizeof(tSirMacMgmtHdr) +
3242 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3243 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3244
3245 break;
3246 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3247 } // end if (wepBit == LIM_WEP_IN_FC)
3248
3249
3250 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3251
3252 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3253 {
3254 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003255 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003256
3257 return;
3258 }
3259
3260 for (i = 0; i < frameLen; i++)
3261 pFrame[i] = 0;
3262
3263 // Prepare BD
3264 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3265 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3266 {
3267 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3268 return;
3269 }
3270
3271 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3272 pMacHdr->fc.wep = wepBit;
3273
3274 // Prepare BSSId
3275 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3276 {
3277 palCopyMemory( pMac->hHdd,(tANI_U8 *) pMacHdr->bssId,
3278 (tANI_U8 *) psessionEntry->bssId,
3279 sizeof( tSirMacAddr ));
3280 }
3281
3282 /// Prepare Authentication frame body
3283 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3284
3285 if (wepBit == LIM_WEP_IN_FC)
3286 {
3287 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
3288
3289 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003290 FL("*** Sending Auth seq# 3 status %d (%d) to"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 pAuthFrameBody->authStatusCode,
3292 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3293
3294 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3295 }
3296 else
3297 {
3298 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3299 pBody += sizeof(tANI_U16);
3300 bodyLen -= sizeof(tANI_U16);
3301
3302 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3303 pBody += sizeof(tANI_U16);
3304 bodyLen -= sizeof(tANI_U16);
3305
3306 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3307 pBody += sizeof(tANI_U16);
3308 bodyLen -= sizeof(tANI_U16);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07003309 if ( bodyLen < sizeof (pAuthFrameBody->type) + sizeof (pAuthFrameBody->length) + sizeof (pAuthFrameBody->challengeText))
3310 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003311
3312#if defined WLAN_FEATURE_VOWIFI_11R
3313 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3314 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3315 {
3316
3317 {
3318 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3320 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003321#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3323 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3324 (tANI_U8 *)pBody,
3325 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003326#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003327 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3328 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003329 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3330 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003331 }
3332 }
3333 else
3334 {
3335 /* MDID attr is 54*/
3336 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003338 *pBody = SIR_MDIE_SIZE;
3339 pBody++;
3340 for(i=0;i<SIR_MDIE_SIZE;i++)
3341 {
3342 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3343 pBody++;
3344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 }
3346 }
3347 }
3348#endif
3349
3350 PELOG1(limLog(pMac, LOG1,
3351 FL("*** Sending Auth seq# %d status %d (%d) to "),
3352 pAuthFrameBody->authTransactionSeqNumber,
3353 pAuthFrameBody->authStatusCode,
3354 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3355
3356 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3357 }
3358 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3359
3360 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3362 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003363#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
3364 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
3365 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3366#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 )
3368 {
3369 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3370 }
3371
Ganesh K08bce952012-12-13 15:04:41 -08003372 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3373 {
3374 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3375 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003376
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 /// Queue Authentication frame in high priority WQ
3378 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3379 HAL_TXRX_FRM_802_11_MGMT,
3380 ANI_TXDIR_TODS,
3381 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3382 limTxComplete, pFrame, txFlag );
3383 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3384 {
3385 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003386 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 halstatus);
3388
3389 //Pkt will be freed up by the callback
3390 }
3391
3392 return;
3393} /*** end limSendAuthMgmtFrame() ***/
3394
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003395eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3396{
3397 tANI_U16 aid;
3398 tpDphHashNode pStaDs;
3399 tLimMlmDeauthReq *pMlmDeauthReq;
3400 tLimMlmDeauthCnf mlmDeauthCnf;
3401 tpPESession psessionEntry;
3402
3403 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3404 if (pMlmDeauthReq)
3405 {
3406 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3407 {
3408 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3409 }
3410
3411 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3412 {
3413
3414 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003415 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003416 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3417 goto end;
3418 }
3419
3420 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3421 if (pStaDs == NULL)
3422 {
3423 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3424 goto end;
3425 }
3426
3427
3428 /// Receive path cleanup with dummy packet
3429 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3430 /// Free up buffer allocated for mlmDeauthReq
3431 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3432 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3433 }
3434 return eHAL_STATUS_SUCCESS;
3435end:
3436 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3437 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3438 sizeof(tSirMacAddr));
3439 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3440 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3441 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3442
3443 // Free up buffer allocated
3444 // for mlmDeauthReq
3445 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3446
3447 limPostSmeMessage(pMac,
3448 LIM_MLM_DEAUTH_CNF,
3449 (tANI_U32 *) &mlmDeauthCnf);
3450 return eHAL_STATUS_SUCCESS;
3451}
3452
3453eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3454{
3455 tANI_U16 aid;
3456 tpDphHashNode pStaDs;
3457 tLimMlmDisassocCnf mlmDisassocCnf;
3458 tpPESession psessionEntry;
3459 tLimMlmDisassocReq *pMlmDisassocReq;
3460
3461 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3462 if (pMlmDisassocReq)
3463 {
3464 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3465 {
3466 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3467 }
3468
3469 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3470 {
3471
3472 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003473 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003474 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3475 goto end;
3476 }
3477
3478 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3479 if (pStaDs == NULL)
3480 {
3481 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3482 goto end;
3483 }
3484
3485 /// Receive path cleanup with dummy packet
3486 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3487 {
3488 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3489 goto end;
3490 }
3491
3492#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003493 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3494 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003495#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003496 (psessionEntry->isCCXconnection ) ||
3497#endif
3498#ifdef FEATURE_WLAN_LFR
3499 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003500#endif
3501 (psessionEntry->is11Rconnection )) &&
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003502 (pMlmDisassocReq->reasonCode !=
3503 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003504 {
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003505 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003506 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003507 psessionEntry, psessionEntry->peSessionId););
3508 limFTCleanup(pMac);
3509 }
3510 else
3511 {
3512 PELOGE(limLog(pMac, LOGE,
3513 FL("No FT Preauth Session Cleanup in role %d"
3514#ifdef FEATURE_WLAN_CCX
3515 " isCCX %d"
3516#endif
3517#ifdef FEATURE_WLAN_LFR
3518 " isLFR %d"
3519#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003520 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003521 psessionEntry->limSystemRole,
3522#ifdef FEATURE_WLAN_CCX
3523 psessionEntry->isCCXconnection,
3524#endif
3525#ifdef FEATURE_WLAN_LFR
3526 psessionEntry->isFastRoamIniFeatureEnabled,
3527#endif
3528 psessionEntry->is11Rconnection,
3529 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003530 }
3531#endif
3532
3533 /// Free up buffer allocated for mlmDisassocReq
3534 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3535 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3536 return eHAL_STATUS_SUCCESS;
3537 }
3538 else
3539 {
3540 return eHAL_STATUS_SUCCESS;
3541 }
3542end:
3543 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
3544 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3545 sizeof(tSirMacAddr));
3546 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3547 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3548
3549 /* Update PE session ID*/
3550 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3551
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003552 if(pMlmDisassocReq != NULL)
3553 {
3554 /// Free up buffer allocated for mlmDisassocReq
3555 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3556 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3557 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003558
3559 limPostSmeMessage(pMac,
3560 LIM_MLM_DISASSOC_CNF,
3561 (tANI_U32 *) &mlmDisassocCnf);
3562 return eHAL_STATUS_SUCCESS;
3563}
3564
3565eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3566{
3567 return limSendDisassocCnf(pMac);
3568}
3569
3570eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3571{
3572 return limSendDeauthCnf(pMac);
3573}
3574
Jeff Johnson295189b2012-06-20 16:38:30 -07003575/**
3576 * \brief This function is called to send Disassociate frame.
3577 *
3578 *
3579 * \param pMac Pointer to Global MAC structure
3580 *
3581 * \param nReason Indicates the reason that need to be sent in
3582 * Disassociation frame
3583 *
3584 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3585 * sent
3586 *
3587 *
3588 */
3589
3590void
3591limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3592 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003593 tSirMacAddr peer,
3594 tpPESession psessionEntry,
3595 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003596{
3597 tDot11fDisassociation frm;
3598 tANI_U8 *pFrame;
3599 tSirRetStatus nSirStatus;
3600 tpSirMacMgmtHdr pMacHdr;
3601 tANI_U32 nBytes, nPayload, nStatus;
3602 void *pPacket;
3603 eHalStatus halstatus;
3604 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003605 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003606 if(NULL == psessionEntry)
3607 {
3608 return;
3609 }
3610
3611 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3612
3613 frm.Reason.code = nReason;
3614
3615 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3616 if ( DOT11F_FAILED( nStatus ) )
3617 {
3618 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003619 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 nStatus );
3621 // We'll fall back on the worst case scenario:
3622 nPayload = sizeof( tDot11fDisassociation );
3623 }
3624 else if ( DOT11F_WARNED( nStatus ) )
3625 {
3626 limLog( pMac, LOGW, FL("There were warnings while calculating"
3627 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003628 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 }
3630
3631 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3632
3633 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3634 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3635 ( void** ) &pPacket );
3636 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3637 {
3638 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003639 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 return;
3641 }
3642
3643 // Paranoia:
3644 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3645
3646 // Next, we fill out the buffer descriptor:
3647 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3648 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3649 if ( eSIR_SUCCESS != nSirStatus )
3650 {
3651 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003652 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 nSirStatus );
3654 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3655 ( void* ) pFrame, ( void* ) pPacket );
3656 return; // just allocated...
3657 }
3658
3659 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3660
3661 // Prepare the BSSID
3662 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3663
Chet Lanctot186b5732013-03-18 10:26:30 -07003664#ifdef WLAN_FEATURE_11W
3665 if ( psessionEntry->limRmfEnabled )
3666 {
3667 pMacHdr->fc.wep = 1;
3668 }
3669#endif
3670
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3672 sizeof(tSirMacMgmtHdr),
3673 nPayload, &nPayload );
3674 if ( DOT11F_FAILED( nStatus ) )
3675 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003676 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 nStatus );
3678 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3679 ( void* ) pFrame, ( void* ) pPacket );
3680 return; // allocated!
3681 }
3682 else if ( DOT11F_WARNED( nStatus ) )
3683 {
3684 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003685 "isassociation (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 }
3687
3688 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003689 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3691
3692 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3694 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 )
3696 {
3697 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3698 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003699
Ganesh K08bce952012-12-13 15:04:41 -08003700 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3701 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3702 {
3703 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3704 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003705
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003706 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003708 // Queue Disassociation frame in high priority WQ
3709 /* get the duration from the request */
3710 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3711 HAL_TXRX_FRM_802_11_MGMT,
3712 ANI_TXDIR_TODS,
3713 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3714 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3715 txFlag );
3716 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003717
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003718 if (tx_timer_change(
3719 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3720 != TX_SUCCESS)
3721 {
3722 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003723 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003724 return;
3725 }
3726 else if(TX_SUCCESS != tx_timer_activate(
3727 &pMac->lim.limTimers.gLimDisassocAckTimer))
3728 {
3729 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003730 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003731 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3732 return;
3733 }
3734 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003735 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003736 {
3737 // Queue Disassociation frame in high priority WQ
3738 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3739 HAL_TXRX_FRM_802_11_MGMT,
3740 ANI_TXDIR_TODS,
3741 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3742 limTxComplete, pFrame, txFlag );
3743 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3744 {
3745 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003746 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003747 nSirStatus );
3748 //Pkt will be freed up by the callback
3749 return;
3750 }
3751 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003752} // End limSendDisassocMgmtFrame.
3753
3754/**
3755 * \brief This function is called to send a Deauthenticate frame
3756 *
3757 *
3758 * \param pMac Pointer to global MAC structure
3759 *
3760 * \param nReason Indicates the reason that need to be sent in the
3761 * Deauthenticate frame
3762 *
3763 * \param peeer address of the STA to which the frame is to be sent
3764 *
3765 *
3766 */
3767
3768void
3769limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3770 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003771 tSirMacAddr peer,
3772 tpPESession psessionEntry,
3773 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003774{
3775 tDot11fDeAuth frm;
3776 tANI_U8 *pFrame;
3777 tSirRetStatus nSirStatus;
3778 tpSirMacMgmtHdr pMacHdr;
3779 tANI_U32 nBytes, nPayload, nStatus;
3780 void *pPacket;
3781 eHalStatus halstatus;
3782 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003783 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003784#ifdef FEATURE_WLAN_TDLS
3785 tANI_U16 aid;
3786 tpDphHashNode pStaDs;
3787#endif
3788
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 if(NULL == psessionEntry)
3790 {
3791 return;
3792 }
3793
3794 palZeroMemory( pMac->hHdd, ( tANI_U8* ) &frm, sizeof( frm ) );
3795
3796 frm.Reason.code = nReason;
3797
3798 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3799 if ( DOT11F_FAILED( nStatus ) )
3800 {
3801 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003802 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 nStatus );
3804 // We'll fall back on the worst case scenario:
3805 nPayload = sizeof( tDot11fDeAuth );
3806 }
3807 else if ( DOT11F_WARNED( nStatus ) )
3808 {
3809 limLog( pMac, LOGW, FL("There were warnings while calculating"
3810 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003811 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 }
3813
3814 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3815
3816 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3817 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3818 ( void** ) &pPacket );
3819 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3820 {
3821 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003822 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 return;
3824 }
3825
3826 // Paranoia:
3827 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3828
3829 // Next, we fill out the buffer descriptor:
3830 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3831 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3832 if ( eSIR_SUCCESS != nSirStatus )
3833 {
3834 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003835 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 nSirStatus );
3837 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3838 ( void* ) pFrame, ( void* ) pPacket );
3839 return; // just allocated...
3840 }
3841
3842 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3843
3844 // Prepare the BSSID
3845 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3846
Chet Lanctot186b5732013-03-18 10:26:30 -07003847#ifdef WLAN_FEATURE_11W
3848 if ( psessionEntry->limRmfEnabled )
3849 {
3850 pMacHdr->fc.wep = 1;
3851 }
3852#endif
3853
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3855 sizeof(tSirMacMgmtHdr),
3856 nPayload, &nPayload );
3857 if ( DOT11F_FAILED( nStatus ) )
3858 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003859 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 nStatus );
3861 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3862 ( void* ) pFrame, ( void* ) pPacket );
3863 return;
3864 }
3865 else if ( DOT11F_WARNED( nStatus ) )
3866 {
3867 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003868 "e-Authentication (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 }
3870
3871 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003872 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3874
3875 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3877 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 )
3879 {
3880 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3881 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003882
Ganesh K08bce952012-12-13 15:04:41 -08003883 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3884 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3885 {
3886 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3887 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003888
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003889#ifdef FEATURE_WLAN_TDLS
3890 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3891#endif
3892
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003893 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003895 // Queue Disassociation frame in high priority WQ
3896 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3897 HAL_TXRX_FRM_802_11_MGMT,
3898 ANI_TXDIR_TODS,
3899 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3900 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
3901 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3902 {
3903 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003904 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003905 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003906 //Pkt will be freed up by the callback limTxComplete
3907
3908 /*Call limProcessDeauthAckTimeout which will send
3909 * DeauthCnf for this frame
3910 */
3911 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003912 return;
3913 }
3914
3915 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3916
3917 if (tx_timer_change(
3918 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3919 != TX_SUCCESS)
3920 {
3921 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003922 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003923 return;
3924 }
3925 else if(TX_SUCCESS != tx_timer_activate(
3926 &pMac->lim.limTimers.gLimDeauthAckTimer))
3927 {
3928 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003929 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003930 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3931 return;
3932 }
3933 }
3934 else
3935 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003936#ifdef FEATURE_WLAN_TDLS
3937 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
3938 {
3939 // Queue Disassociation frame in high priority WQ
3940 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003941 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003942 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003943 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3944 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003945 }
3946 else
3947 {
3948#endif
3949 // Queue Disassociation frame in high priority WQ
3950 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3951 HAL_TXRX_FRM_802_11_MGMT,
3952 ANI_TXDIR_TODS,
3953 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3954 limTxComplete, pFrame, txFlag );
3955#ifdef FEATURE_WLAN_TDLS
3956 }
3957#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003958 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3959 {
3960 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003961 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003962 nSirStatus );
3963 //Pkt will be freed up by the callback
3964 return;
3965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 }
3967
3968} // End limSendDeauthMgmtFrame.
3969
3970
3971#ifdef ANI_SUPPORT_11H
3972/**
3973 * \brief Send a Measurement Report Action frame
3974 *
3975 *
3976 * \param pMac Pointer to the global MAC structure
3977 *
3978 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3979 *
3980 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3981 *
3982 *
3983 */
3984
3985tSirRetStatus
3986limSendMeasReportFrame(tpAniSirGlobal pMac,
3987 tpSirMacMeasReqActionFrame pMeasReqFrame,
3988 tSirMacAddr peer)
3989{
3990 tDot11fMeasurementReport frm;
3991 tANI_U8 *pFrame;
3992 tSirRetStatus nSirStatus;
3993 tpSirMacMgmtHdr pMacHdr;
3994 tANI_U32 nBytes, nPayload, nStatus, nCfg;
3995 void *pPacket;
3996 eHalStatus halstatus;
3997
3998 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3999
4000 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4001 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4002 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4003
4004 switch ( pMeasReqFrame->measReqIE.measType )
4005 {
4006 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4007 nSirStatus =
4008 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4009 &frm.MeasurementReport );
4010 break;
4011 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4012 nSirStatus =
4013 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4014 &frm.MeasurementReport );
4015 break;
4016 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4017 nSirStatus =
4018 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4019 &frm.MeasurementReport );
4020 break;
4021 default:
4022 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004023 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 pMeasReqFrame->measReqIE.measType );
4025 return eSIR_FAILURE;
4026 }
4027
4028 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4029
4030 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4031 if ( DOT11F_FAILED( nStatus ) )
4032 {
4033 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004034 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 nStatus );
4036 // We'll fall back on the worst case scenario:
4037 nPayload = sizeof( tDot11fMeasurementReport );
4038 }
4039 else if ( DOT11F_WARNED( nStatus ) )
4040 {
4041 limLog( pMac, LOGW, FL("There were warnings while calculating"
4042 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004043 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 }
4045
4046 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4047
4048 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4049 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4050 {
4051 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004052 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 return eSIR_FAILURE;
4054 }
4055
4056 // Paranoia:
4057 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4058
4059 // Next, we fill out the buffer descriptor:
4060 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4061 SIR_MAC_MGMT_ACTION, peer);
4062 if ( eSIR_SUCCESS != nSirStatus )
4063 {
4064 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004065 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 nSirStatus );
4067 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4068 return eSIR_FAILURE; // just allocated...
4069 }
4070
4071 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4072
4073 nCfg = 6;
4074 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4075 if ( eSIR_SUCCESS != nSirStatus )
4076 {
4077 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004078 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 nSirStatus );
4080 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4081 return eSIR_FAILURE; // just allocated...
4082 }
4083
Chet Lanctot186b5732013-03-18 10:26:30 -07004084#ifdef WLAN_FEATURE_11W
4085 if ( psessionEntry->limRmfEnabled )
4086 {
4087 pMacHdr->fc.wep = 1;
4088 }
4089#endif
4090
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4092 sizeof(tSirMacMgmtHdr),
4093 nPayload, &nPayload );
4094 if ( DOT11F_FAILED( nStatus ) )
4095 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004096 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 nStatus );
4098 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4099 return eSIR_FAILURE; // allocated!
4100 }
4101 else if ( DOT11F_WARNED( nStatus ) )
4102 {
4103 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004104 "easurement Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 }
4106
4107 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4108 HAL_TXRX_FRM_802_11_MGMT,
4109 ANI_TXDIR_TODS,
4110 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4111 limTxComplete, pFrame, 0 );
4112 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4113 {
4114 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004115 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 nSirStatus );
4117 //Pkt will be freed up by the callback
4118 return eSIR_FAILURE; // just allocated...
4119 }
4120
4121 return eSIR_SUCCESS;
4122
4123} // End limSendMeasReportFrame.
4124
4125
4126/**
4127 * \brief Send a TPC Request Action frame
4128 *
4129 *
4130 * \param pMac Pointer to the global MAC datastructure
4131 *
4132 * \param peer MAC address to which the frame should be sent
4133 *
4134 *
4135 */
4136
4137void
4138limSendTpcRequestFrame(tpAniSirGlobal pMac,
4139 tSirMacAddr peer)
4140{
4141 tDot11fTPCRequest frm;
4142 tANI_U8 *pFrame;
4143 tSirRetStatus nSirStatus;
4144 tpSirMacMgmtHdr pMacHdr;
4145 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4146 void *pPacket;
4147 eHalStatus halstatus;
4148
4149 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4150
4151 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4152 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4153 frm.DialogToken.token = 1;
4154 frm.TPCRequest.present = 1;
4155
4156 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4157 if ( DOT11F_FAILED( nStatus ) )
4158 {
4159 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004160 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 nStatus );
4162 // We'll fall back on the worst case scenario:
4163 nPayload = sizeof( tDot11fTPCRequest );
4164 }
4165 else if ( DOT11F_WARNED( nStatus ) )
4166 {
4167 limLog( pMac, LOGW, FL("There were warnings while calculating"
4168 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004169 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 }
4171
4172 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4173
4174 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4175 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4176 {
4177 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004178 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 return;
4180 }
4181
4182 // Paranoia:
4183 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4184
4185 // Next, we fill out the buffer descriptor:
4186 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4187 SIR_MAC_MGMT_ACTION, peer);
4188 if ( eSIR_SUCCESS != nSirStatus )
4189 {
4190 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004191 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 nSirStatus );
4193 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4194 return; // just allocated...
4195 }
4196
4197 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4198
4199 nCfg = 6;
4200 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4201 if ( eSIR_SUCCESS != nSirStatus )
4202 {
4203 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004204 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 nSirStatus );
4206 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4207 return; // just allocated...
4208 }
4209
Chet Lanctot186b5732013-03-18 10:26:30 -07004210#ifdef WLAN_FEATURE_11W
4211 if ( psessionEntry->limRmfEnabled )
4212 {
4213 pMacHdr->fc.wep = 1;
4214 }
4215#endif
4216
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4218 sizeof(tSirMacMgmtHdr),
4219 nPayload, &nPayload );
4220 if ( DOT11F_FAILED( nStatus ) )
4221 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004222 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 nStatus );
4224 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4225 return; // allocated!
4226 }
4227 else if ( DOT11F_WARNED( nStatus ) )
4228 {
4229 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004230 "PC Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 }
4232
4233 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4234 HAL_TXRX_FRM_802_11_MGMT,
4235 ANI_TXDIR_TODS,
4236 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4237 limTxComplete, pFrame, 0 );
4238 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4239 {
4240 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004241 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 nSirStatus );
4243 //Pkt will be freed up by the callback
4244 return;
4245 }
4246
4247} // End limSendTpcRequestFrame.
4248
4249
4250/**
4251 * \brief Send a TPC Report Action frame
4252 *
4253 *
4254 * \param pMac Pointer to the global MAC datastructure
4255 *
4256 * \param pTpcReqFrame Pointer to the received TPC Request
4257 *
4258 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4259 *
4260 *
4261 */
4262
4263tSirRetStatus
4264limSendTpcReportFrame(tpAniSirGlobal pMac,
4265 tpSirMacTpcReqActionFrame pTpcReqFrame,
4266 tSirMacAddr peer)
4267{
4268 tDot11fTPCReport frm;
4269 tANI_U8 *pFrame;
4270 tSirRetStatus nSirStatus;
4271 tpSirMacMgmtHdr pMacHdr;
4272 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4273 void *pPacket;
4274 eHalStatus halstatus;
4275
4276 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4277
4278 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4279 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4280 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4281
4282 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4283 // "misplaced this function, need to replace:
4284 // txPower = halGetRateToPwrValue(pMac, staid,
4285 // pMac->lim.gLimCurrentChannelId, 0);
4286 frm.TPCReport.tx_power = 0;
4287 frm.TPCReport.link_margin = 0;
4288 frm.TPCReport.present = 1;
4289
4290 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4291 if ( DOT11F_FAILED( nStatus ) )
4292 {
4293 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004294 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 nStatus );
4296 // We'll fall back on the worst case scenario:
4297 nPayload = sizeof( tDot11fTPCReport );
4298 }
4299 else if ( DOT11F_WARNED( nStatus ) )
4300 {
4301 limLog( pMac, LOGW, FL("There were warnings while calculating"
4302 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004303 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 }
4305
4306 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4307
4308 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4309 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4310 {
4311 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004312 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 return eSIR_FAILURE;
4314 }
4315
4316 // Paranoia:
4317 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4318
4319 // Next, we fill out the buffer descriptor:
4320 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4321 SIR_MAC_MGMT_ACTION, peer);
4322 if ( eSIR_SUCCESS != nSirStatus )
4323 {
4324 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004325 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 nSirStatus );
4327 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4328 return eSIR_FAILURE; // just allocated...
4329 }
4330
4331 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4332
4333 nCfg = 6;
4334 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4335 if ( eSIR_SUCCESS != nSirStatus )
4336 {
4337 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004338 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 nSirStatus );
4340 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4341 return eSIR_FAILURE; // just allocated...
4342 }
4343
Chet Lanctot186b5732013-03-18 10:26:30 -07004344#ifdef WLAN_FEATURE_11W
4345 if ( psessionEntry->limRmfEnabled )
4346 {
4347 pMacHdr->fc.wep = 1;
4348 }
4349#endif
4350
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4352 sizeof(tSirMacMgmtHdr),
4353 nPayload, &nPayload );
4354 if ( DOT11F_FAILED( nStatus ) )
4355 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004356 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 nStatus );
4358 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4359 return eSIR_FAILURE; // allocated!
4360 }
4361 else if ( DOT11F_WARNED( nStatus ) )
4362 {
4363 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004364 "PC Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004365 }
4366
4367
4368 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4369 HAL_TXRX_FRM_802_11_MGMT,
4370 ANI_TXDIR_TODS,
4371 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4372 limTxComplete, pFrame, 0 );
4373 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4374 {
4375 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004376 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 nSirStatus );
4378 //Pkt will be freed up by the callback
4379 return eSIR_FAILURE; // just allocated...
4380 }
4381
4382 return eSIR_SUCCESS;
4383
4384} // End limSendTpcReportFrame.
4385#endif //ANI_SUPPORT_11H
4386
4387
Jeff Johnson295189b2012-06-20 16:38:30 -07004388/**
4389 * \brief Send a Channel Switch Announcement
4390 *
4391 *
4392 * \param pMac Pointer to the global MAC datastructure
4393 *
4394 * \param peer MAC address to which this frame will be sent
4395 *
4396 * \param nMode
4397 *
4398 * \param nNewChannel
4399 *
4400 * \param nCount
4401 *
4402 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4403 *
4404 *
4405 */
4406
4407tSirRetStatus
4408limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4409 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004410 tANI_U8 nMode,
4411 tANI_U8 nNewChannel,
4412 tANI_U8 nCount,
4413 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004414{
4415 tDot11fChannelSwitch frm;
4416 tANI_U8 *pFrame;
4417 tSirRetStatus nSirStatus;
4418 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004419 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 void *pPacket;
4421 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004422 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004423
4424 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4425
4426 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4427 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4428 frm.ChanSwitchAnn.switchMode = nMode;
4429 frm.ChanSwitchAnn.newChannel = nNewChannel;
4430 frm.ChanSwitchAnn.switchCount = nCount;
4431 frm.ChanSwitchAnn.present = 1;
4432
4433 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4434 if ( DOT11F_FAILED( nStatus ) )
4435 {
4436 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004437 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 nStatus );
4439 // We'll fall back on the worst case scenario:
4440 nPayload = sizeof( tDot11fChannelSwitch );
4441 }
4442 else if ( DOT11F_WARNED( nStatus ) )
4443 {
4444 limLog( pMac, LOGW, FL("There were warnings while calculating"
4445 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004446 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 }
4448
4449 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4450
4451 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4452 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4453 {
4454 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004455 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 return eSIR_FAILURE;
4457 }
4458
4459 // Paranoia:
4460 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4461
4462 // Next, we fill out the buffer descriptor:
4463 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004464 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4465 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4466 palCopyMemory( pMac->hHdd,
4467 (tANI_U8 *) pMacHdr->bssId,
4468 (tANI_U8 *) psessionEntry->bssId,
4469 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 if ( eSIR_SUCCESS != nSirStatus )
4471 {
4472 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004473 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 nSirStatus );
4475 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4476 return eSIR_FAILURE; // just allocated...
4477 }
4478
Jeff Johnsone7245742012-09-05 17:12:55 -07004479#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4481
4482 nCfg = 6;
4483 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4484 if ( eSIR_SUCCESS != nSirStatus )
4485 {
4486 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004487 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 nSirStatus );
4489 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4490 return eSIR_FAILURE; // just allocated...
4491 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004492#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004493
4494#ifdef WLAN_FEATURE_11W
4495 if ( psessionEntry->limRmfEnabled )
4496 {
4497 pMacHdr->fc.wep = 1;
4498 }
4499#endif
4500
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4502 sizeof(tSirMacMgmtHdr),
4503 nPayload, &nPayload );
4504 if ( DOT11F_FAILED( nStatus ) )
4505 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004506 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004507 nStatus );
4508 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4509 return eSIR_FAILURE; // allocated!
4510 }
4511 else if ( DOT11F_WARNED( nStatus ) )
4512 {
4513 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004514 "hannel Switch (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 }
4516
Jeff Johnsone7245742012-09-05 17:12:55 -07004517 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004518 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4519 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004520 )
4521 {
4522 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4525 HAL_TXRX_FRM_802_11_MGMT,
4526 ANI_TXDIR_TODS,
4527 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004528 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4530 {
4531 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004532 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 nSirStatus );
4534 //Pkt will be freed up by the callback
4535 return eSIR_FAILURE;
4536 }
4537
4538 return eSIR_SUCCESS;
4539
4540} // End limSendChannelSwitchMgmtFrame.
4541
Jeff Johnson295189b2012-06-20 16:38:30 -07004542
4543
Mohit Khanna4a70d262012-09-11 16:30:12 -07004544#ifdef WLAN_FEATURE_11AC
4545tSirRetStatus
4546limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4547 tSirMacAddr peer,
4548 tANI_U8 nMode,
4549 tpPESession psessionEntry )
4550{
4551 tDot11fOperatingMode frm;
4552 tANI_U8 *pFrame;
4553 tSirRetStatus nSirStatus;
4554 tpSirMacMgmtHdr pMacHdr;
4555 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4556 void *pPacket;
4557 eHalStatus halstatus;
4558 tANI_U8 txFlag = 0;
4559
4560 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4561
4562 frm.Category.category = SIR_MAC_ACTION_VHT;
4563 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4564 frm.OperatingMode.chanWidth = nMode;
4565 frm.OperatingMode.rxNSS = 0;
4566 frm.OperatingMode.rxNSSType = 0;
4567
4568 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4569 if ( DOT11F_FAILED( nStatus ) )
4570 {
4571 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004572 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004573 nStatus );
4574 // We'll fall back on the worst case scenario:
4575 nPayload = sizeof( tDot11fOperatingMode);
4576 }
4577 else if ( DOT11F_WARNED( nStatus ) )
4578 {
4579 limLog( pMac, LOGW, FL("There were warnings while calculating"
4580 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004581 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004582 }
4583
4584 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4585
4586 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4587 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4588 {
4589 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004590 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004591 return eSIR_FAILURE;
4592 }
4593
4594 // Paranoia:
4595 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4596
4597
4598 // Next, we fill out the buffer descriptor:
4599 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4600 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4601 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4602 } else
4603 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4604 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4605 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4606 palCopyMemory( pMac->hHdd,
4607 (tANI_U8 *) pMacHdr->bssId,
4608 (tANI_U8 *) psessionEntry->bssId,
4609 sizeof( tSirMacAddr ));
4610 if ( eSIR_SUCCESS != nSirStatus )
4611 {
4612 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004613 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004614 nSirStatus );
4615 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4616 return eSIR_FAILURE; // just allocated...
4617 }
4618 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4619 sizeof(tSirMacMgmtHdr),
4620 nPayload, &nPayload );
4621 if ( DOT11F_FAILED( nStatus ) )
4622 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004623 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004624 nStatus );
4625 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4626 return eSIR_FAILURE; // allocated!
4627 }
4628 else if ( DOT11F_WARNED( nStatus ) )
4629 {
4630 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004631 " (0x%08x).") );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004632 }
4633 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004634 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4635 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004636 )
4637 {
4638 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4639 }
4640 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4641 HAL_TXRX_FRM_802_11_MGMT,
4642 ANI_TXDIR_TODS,
4643 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4644 limTxComplete, pFrame, txFlag );
4645 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4646 {
4647 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004648 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004649 nSirStatus );
4650 //Pkt will be freed up by the callback
4651 return eSIR_FAILURE;
4652 }
4653
4654 return eSIR_SUCCESS;
4655}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004656
4657/**
4658 * \brief Send a VHT Channel Switch Announcement
4659 *
4660 *
4661 * \param pMac Pointer to the global MAC datastructure
4662 *
4663 * \param peer MAC address to which this frame will be sent
4664 *
4665 * \param nChanWidth
4666 *
4667 * \param nNewChannel
4668 *
4669 *
4670 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4671 *
4672 *
4673 */
4674
4675tSirRetStatus
4676limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4677 tSirMacAddr peer,
4678 tANI_U8 nChanWidth,
4679 tANI_U8 nNewChannel,
4680 tANI_U8 ncbMode,
4681 tpPESession psessionEntry )
4682{
4683 tDot11fChannelSwitch frm;
4684 tANI_U8 *pFrame;
4685 tSirRetStatus nSirStatus;
4686 tpSirMacMgmtHdr pMacHdr;
4687 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4688 void *pPacket;
4689 eHalStatus halstatus;
4690 tANI_U8 txFlag = 0;
4691
4692 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4693
4694
4695 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4696 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4697 frm.ChanSwitchAnn.switchMode = 1;
4698 frm.ChanSwitchAnn.newChannel = nNewChannel;
4699 frm.ChanSwitchAnn.switchCount = 1;
4700 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4701 frm.ExtChanSwitchAnn.present = 1;
4702 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4703 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4704 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4705 frm.ChanSwitchAnn.present = 1;
4706 frm.WiderBWChanSwitchAnn.present = 1;
4707
4708 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4709 if ( DOT11F_FAILED( nStatus ) )
4710 {
4711 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004712 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004713 nStatus );
4714 // We'll fall back on the worst case scenario:
4715 nPayload = sizeof( tDot11fChannelSwitch );
4716 }
4717 else if ( DOT11F_WARNED( nStatus ) )
4718 {
4719 limLog( pMac, LOGW, FL("There were warnings while calculating"
4720 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004721 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004722 }
4723
4724 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4725
4726 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4727 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4728 {
4729 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004730 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004731 return eSIR_FAILURE;
4732 }
4733 // Paranoia:
4734 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4735
4736 // Next, we fill out the buffer descriptor:
4737 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4738 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4739 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4740 palCopyMemory( pMac->hHdd,
4741 (tANI_U8 *) pMacHdr->bssId,
4742 (tANI_U8 *) psessionEntry->bssId,
4743 sizeof( tSirMacAddr ));
4744 if ( eSIR_SUCCESS != nSirStatus )
4745 {
4746 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004747 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004748 nSirStatus );
4749 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4750 return eSIR_FAILURE; // just allocated...
4751 }
4752 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4753 sizeof(tSirMacMgmtHdr),
4754 nPayload, &nPayload );
4755 if ( DOT11F_FAILED( nStatus ) )
4756 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004757 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004758 nStatus );
4759 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4760 return eSIR_FAILURE; // allocated!
4761 }
4762 else if ( DOT11F_WARNED( nStatus ) )
4763 {
4764 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004765 "hannel Switch (0x%08x).") );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004766 }
4767
4768 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004769 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4770 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004771 )
4772 {
4773 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4774 }
4775 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4776 HAL_TXRX_FRM_802_11_MGMT,
4777 ANI_TXDIR_TODS,
4778 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4779 limTxComplete, pFrame, txFlag );
4780 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4781 {
4782 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004783 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004784 nSirStatus );
4785 //Pkt will be freed up by the callback
4786 return eSIR_FAILURE;
4787 }
4788
4789 return eSIR_SUCCESS;
4790
4791} // End limSendVHTChannelSwitchMgmtFrame.
4792
4793
4794
Mohit Khanna4a70d262012-09-11 16:30:12 -07004795#endif
4796
Jeff Johnson295189b2012-06-20 16:38:30 -07004797/**
4798 * \brief Send an ADDBA Req Action Frame to peer
4799 *
4800 * \sa limSendAddBAReq
4801 *
4802 * \param pMac The global tpAniSirGlobal object
4803 *
4804 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4805 * the necessary parameters reqd by PE send the ADDBA Req Action
4806 * Frame to the peer
4807 *
4808 * \return eSIR_SUCCESS if setup completes successfully
4809 * eSIR_FAILURE is some problem is encountered
4810 */
4811tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
4812 tpLimMlmAddBAReq pMlmAddBAReq ,tpPESession psessionEntry)
4813{
4814 tDot11fAddBAReq frmAddBAReq;
4815 tANI_U8 *pAddBAReqBuffer = NULL;
4816 tpSirMacMgmtHdr pMacHdr;
4817 tANI_U32 frameLen = 0, nStatus, nPayload;
4818 tSirRetStatus statusCode;
4819 eHalStatus halStatus;
4820 void *pPacket;
4821 tANI_U8 txFlag = 0;
4822
4823 if(NULL == psessionEntry)
4824 {
4825 return eSIR_FAILURE;
4826 }
4827
4828 palZeroMemory( pMac->hHdd, (void *) &frmAddBAReq, sizeof( frmAddBAReq ));
4829
4830 // Category - 3 (BA)
4831 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4832
4833 // Action - 0 (ADDBA Req)
4834 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4835
4836 // FIXME - Dialog Token, generalize this...
4837 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4838
4839 // Fill the ADDBA Parameter Set
4840 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4841 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4842 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4843
4844 // BA timeout
4845 // 0 - indicates no BA timeout
4846 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4847
4848 // BA Starting Sequence Number
4849 // Fragment number will always be zero
4850 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4851 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4852 }
4853
4854 frmAddBAReq.BAStartingSequenceControl.ssn =
4855 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4856
4857 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4858
4859 if( DOT11F_FAILED( nStatus ))
4860 {
4861 limLog( pMac, LOGW,
4862 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004863 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 nStatus );
4865
4866 // We'll fall back on the worst case scenario:
4867 nPayload = sizeof( tDot11fAddBAReq );
4868 }
4869 else if( DOT11F_WARNED( nStatus ))
4870 {
4871 limLog( pMac, LOGW,
4872 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004873 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 nStatus );
4875 }
4876
4877 // Add the MGMT header to frame length
4878 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4879
4880 // Need to allocate a buffer for ADDBA AF
4881 if( eHAL_STATUS_SUCCESS !=
4882 (halStatus = palPktAlloc( pMac->hHdd,
4883 HAL_TXRX_FRM_802_11_MGMT,
4884 (tANI_U16) frameLen,
4885 (void **) &pAddBAReqBuffer,
4886 (void **) &pPacket )))
4887 {
4888 // Log error
4889 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004890 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 frameLen,
4892 halStatus );
4893
4894 statusCode = eSIR_MEM_ALLOC_FAILED;
4895 goto returnAfterError;
4896 }
4897
4898 palZeroMemory( pMac->hHdd, (void *) pAddBAReqBuffer, frameLen );
4899
4900 // Copy necessary info to BD
4901 if( eSIR_SUCCESS !=
4902 (statusCode = limPopulateMacHeader( pMac,
4903 pAddBAReqBuffer,
4904 SIR_MAC_MGMT_FRAME,
4905 SIR_MAC_MGMT_ACTION,
4906 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4907 goto returnAfterError;
4908
4909 // Update A3 with the BSSID
4910 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4911
4912 #if 0
4913 cfgLen = SIR_MAC_ADDR_LENGTH;
4914 if( eSIR_SUCCESS != cfgGetStr( pMac,
4915 WNI_CFG_BSSID,
4916 (tANI_U8 *) pMacHdr->bssId,
4917 &cfgLen ))
4918 {
4919 limLog( pMac, LOGP,
4920 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004921 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004922
4923 // FIXME - Need to convert to tSirRetStatus
4924 statusCode = eSIR_FAILURE;
4925 goto returnAfterError;
4926 }
4927 #endif//TO SUPPORT BT-AMP
4928 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4929
Chet Lanctot186b5732013-03-18 10:26:30 -07004930#ifdef WLAN_FEATURE_11W
4931 if ( psessionEntry->limRmfEnabled )
4932 {
4933 pMacHdr->fc.wep = 1;
4934 }
4935#endif
4936
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 // Now, we're ready to "pack" the frames
4938 nStatus = dot11fPackAddBAReq( pMac,
4939 &frmAddBAReq,
4940 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4941 nPayload,
4942 &nPayload );
4943
4944 if( DOT11F_FAILED( nStatus ))
4945 {
4946 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004947 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 nStatus );
4949
4950 // FIXME - Need to convert to tSirRetStatus
4951 statusCode = eSIR_FAILURE;
4952 goto returnAfterError;
4953 }
4954 else if( DOT11F_WARNED( nStatus ))
4955 {
4956 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004957 FL( "There were warnings while packing an ADDBA Req (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004958 }
4959
4960 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004961 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4963
4964 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4966 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 )
4968 {
4969 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4970 }
4971
4972 if( eHAL_STATUS_SUCCESS !=
4973 (halStatus = halTxFrame( pMac,
4974 pPacket,
4975 (tANI_U16) frameLen,
4976 HAL_TXRX_FRM_802_11_MGMT,
4977 ANI_TXDIR_TODS,
4978 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4979 limTxComplete,
4980 pAddBAReqBuffer, txFlag )))
4981 {
4982 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004983 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 halStatus );
4985
4986 // FIXME - Need to convert eHalStatus to tSirRetStatus
4987 statusCode = eSIR_FAILURE;
4988 //Pkt will be freed up by the callback
4989 return statusCode;
4990 }
4991 else
4992 return eSIR_SUCCESS;
4993
4994returnAfterError:
4995
4996 // Release buffer, if allocated
4997 if( NULL != pAddBAReqBuffer )
4998 palPktFree( pMac->hHdd,
4999 HAL_TXRX_FRM_802_11_MGMT,
5000 (void *) pAddBAReqBuffer,
5001 (void *) pPacket );
5002
5003 return statusCode;
5004}
5005
5006/**
5007 * \brief Send an ADDBA Rsp Action Frame to peer
5008 *
5009 * \sa limSendAddBARsp
5010 *
5011 * \param pMac The global tpAniSirGlobal object
5012 *
5013 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5014 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5015 * Frame to the peer
5016 *
5017 * \return eSIR_SUCCESS if setup completes successfully
5018 * eSIR_FAILURE is some problem is encountered
5019 */
5020tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5021 tpLimMlmAddBARsp pMlmAddBARsp,
5022 tpPESession psessionEntry)
5023{
5024 tDot11fAddBARsp frmAddBARsp;
5025 tANI_U8 *pAddBARspBuffer = NULL;
5026 tpSirMacMgmtHdr pMacHdr;
5027 tANI_U32 frameLen = 0, nStatus, nPayload;
5028 tSirRetStatus statusCode;
5029 eHalStatus halStatus;
5030 void *pPacket;
5031 tANI_U8 txFlag = 0;
5032
5033 if(NULL == psessionEntry)
5034 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005035 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 return eSIR_FAILURE;
5037 }
5038
5039 palZeroMemory( pMac->hHdd, (void *) &frmAddBARsp, sizeof( frmAddBARsp ));
5040
5041 // Category - 3 (BA)
5042 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5043 // Action - 1 (ADDBA Rsp)
5044 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5045
5046 // Should be same as the one we received in the ADDBA Req
5047 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5048
5049 // ADDBA Req status
5050 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5051
5052 // Fill the ADDBA Parameter Set as provided by caller
5053 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5054 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5055 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
5056
5057 // BA timeout
5058 // 0 - indicates no BA timeout
5059 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5060
5061 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5062
5063 if( DOT11F_FAILED( nStatus ))
5064 {
5065 limLog( pMac, LOGW,
5066 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005067 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 nStatus );
5069
5070 // We'll fall back on the worst case scenario:
5071 nPayload = sizeof( tDot11fAddBARsp );
5072 }
5073 else if( DOT11F_WARNED( nStatus ))
5074 {
5075 limLog( pMac, LOGW,
5076 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005077 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 nStatus );
5079 }
5080
5081 // Need to allocate a buffer for ADDBA AF
5082 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5083
5084 // Allocate shared memory
5085 if( eHAL_STATUS_SUCCESS !=
5086 (halStatus = palPktAlloc( pMac->hHdd,
5087 HAL_TXRX_FRM_802_11_MGMT,
5088 (tANI_U16) frameLen,
5089 (void **) &pAddBARspBuffer,
5090 (void **) &pPacket )))
5091 {
5092 // Log error
5093 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005094 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 frameLen,
5096 halStatus );
5097
5098 statusCode = eSIR_MEM_ALLOC_FAILED;
5099 goto returnAfterError;
5100 }
5101
5102 palZeroMemory( pMac->hHdd, (void *) pAddBARspBuffer, frameLen );
5103
5104 // Copy necessary info to BD
5105 if( eSIR_SUCCESS !=
5106 (statusCode = limPopulateMacHeader( pMac,
5107 pAddBARspBuffer,
5108 SIR_MAC_MGMT_FRAME,
5109 SIR_MAC_MGMT_ACTION,
5110 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5111 goto returnAfterError;
5112
5113 // Update A3 with the BSSID
5114
5115 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5116
5117 #if 0
5118 cfgLen = SIR_MAC_ADDR_LENGTH;
5119 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5120 WNI_CFG_BSSID,
5121 (tANI_U8 *) pMacHdr->bssId,
5122 &cfgLen ))
5123 {
5124 limLog( pMac, LOGP,
5125 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005126 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005127
5128 // FIXME - Need to convert to tSirRetStatus
5129 statusCode = eSIR_FAILURE;
5130 goto returnAfterError;
5131 }
5132 #endif // TO SUPPORT BT-AMP
5133 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5134
Chet Lanctot186b5732013-03-18 10:26:30 -07005135#ifdef WLAN_FEATURE_11W
5136 if ( psessionEntry->limRmfEnabled )
5137 {
5138 pMacHdr->fc.wep = 1;
5139 }
5140#endif
5141
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 // Now, we're ready to "pack" the frames
5143 nStatus = dot11fPackAddBARsp( pMac,
5144 &frmAddBARsp,
5145 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5146 nPayload,
5147 &nPayload );
5148
5149 if( DOT11F_FAILED( nStatus ))
5150 {
5151 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005152 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 nStatus );
5154
5155 // FIXME - Need to convert to tSirRetStatus
5156 statusCode = eSIR_FAILURE;
5157 goto returnAfterError;
5158 }
5159 else if( DOT11F_WARNED( nStatus ))
5160 {
5161 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005162 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005163 }
5164
5165 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005166 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5168
5169 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5171 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005172 )
5173 {
5174 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5175 }
5176
5177 if( eHAL_STATUS_SUCCESS !=
5178 (halStatus = halTxFrame( pMac,
5179 pPacket,
5180 (tANI_U16) frameLen,
5181 HAL_TXRX_FRM_802_11_MGMT,
5182 ANI_TXDIR_TODS,
5183 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5184 limTxComplete,
5185 pAddBARspBuffer, txFlag )))
5186 {
5187 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005188 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 halStatus );
5190
5191 // FIXME - HAL error codes are different from PE error
5192 // codes!! And, this routine is returning tSirRetStatus
5193 statusCode = eSIR_FAILURE;
5194 //Pkt will be freed up by the callback
5195 return statusCode;
5196 }
5197 else
5198 return eSIR_SUCCESS;
5199
5200 returnAfterError:
5201
5202 // Release buffer, if allocated
5203 if( NULL != pAddBARspBuffer )
5204 palPktFree( pMac->hHdd,
5205 HAL_TXRX_FRM_802_11_MGMT,
5206 (void *) pAddBARspBuffer,
5207 (void *) pPacket );
5208
5209 return statusCode;
5210}
5211
5212/**
5213 * \brief Send a DELBA Indication Action Frame to peer
5214 *
5215 * \sa limSendDelBAInd
5216 *
5217 * \param pMac The global tpAniSirGlobal object
5218 *
5219 * \param peerMacAddr MAC Address of peer
5220 *
5221 * \param reasonCode Reason for the DELBA notification
5222 *
5223 * \param pBAParameterSet The DELBA Parameter Set.
5224 * This identifies the TID for which the BA session is
5225 * being deleted.
5226 *
5227 * \return eSIR_SUCCESS if setup completes successfully
5228 * eSIR_FAILURE is some problem is encountered
5229 */
5230tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5231 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5232{
5233 tDot11fDelBAInd frmDelBAInd;
5234 tANI_U8 *pDelBAIndBuffer = NULL;
5235 //tANI_U32 val;
5236 tpSirMacMgmtHdr pMacHdr;
5237 tANI_U32 frameLen = 0, nStatus, nPayload;
5238 tSirRetStatus statusCode;
5239 eHalStatus halStatus;
5240 void *pPacket;
5241 tANI_U8 txFlag = 0;
5242
5243 if(NULL == psessionEntry)
5244 {
5245 return eSIR_FAILURE;
5246 }
5247
5248 palZeroMemory( pMac->hHdd, (void *) &frmDelBAInd, sizeof( frmDelBAInd ));
5249
5250 // Category - 3 (BA)
5251 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5252 // Action - 2 (DELBA)
5253 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5254
5255 // Fill the DELBA Parameter Set as provided by caller
5256 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5257 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5258
5259 // BA Starting Sequence Number
5260 // Fragment number will always be zero
5261 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5262
5263 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5264
5265 if( DOT11F_FAILED( nStatus ))
5266 {
5267 limLog( pMac, LOGW,
5268 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005269 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 nStatus );
5271
5272 // We'll fall back on the worst case scenario:
5273 nPayload = sizeof( tDot11fDelBAInd );
5274 }
5275 else if( DOT11F_WARNED( nStatus ))
5276 {
5277 limLog( pMac, LOGW,
5278 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005279 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005280 nStatus );
5281 }
5282
5283 // Add the MGMT header to frame length
5284 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5285
5286 // Allocate shared memory
5287 if( eHAL_STATUS_SUCCESS !=
5288 (halStatus = palPktAlloc( pMac->hHdd,
5289 HAL_TXRX_FRM_802_11_MGMT,
5290 (tANI_U16) frameLen,
5291 (void **) &pDelBAIndBuffer,
5292 (void **) &pPacket )))
5293 {
5294 // Log error
5295 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005296 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005297 frameLen,
5298 halStatus );
5299
5300 statusCode = eSIR_MEM_ALLOC_FAILED;
5301 goto returnAfterError;
5302 }
5303
5304 palZeroMemory( pMac->hHdd, (void *) pDelBAIndBuffer, frameLen );
5305
5306 // Copy necessary info to BD
5307 if( eSIR_SUCCESS !=
5308 (statusCode = limPopulateMacHeader( pMac,
5309 pDelBAIndBuffer,
5310 SIR_MAC_MGMT_FRAME,
5311 SIR_MAC_MGMT_ACTION,
5312 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5313 goto returnAfterError;
5314
5315 // Update A3 with the BSSID
5316 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5317
5318 #if 0
5319 cfgLen = SIR_MAC_ADDR_LENGTH;
5320 if( eSIR_SUCCESS != cfgGetStr( pMac,
5321 WNI_CFG_BSSID,
5322 (tANI_U8 *) pMacHdr->bssId,
5323 &cfgLen ))
5324 {
5325 limLog( pMac, LOGP,
5326 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005327 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005328
5329 // FIXME - Need to convert to tSirRetStatus
5330 statusCode = eSIR_FAILURE;
5331 goto returnAfterError;
5332 }
5333 #endif //TO SUPPORT BT-AMP
5334 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5335
Chet Lanctot186b5732013-03-18 10:26:30 -07005336#ifdef WLAN_FEATURE_11W
5337 if ( psessionEntry->limRmfEnabled )
5338 {
5339 pMacHdr->fc.wep = 1;
5340 }
5341#endif
5342
Jeff Johnson295189b2012-06-20 16:38:30 -07005343 // Now, we're ready to "pack" the frames
5344 nStatus = dot11fPackDelBAInd( pMac,
5345 &frmDelBAInd,
5346 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5347 nPayload,
5348 &nPayload );
5349
5350 if( DOT11F_FAILED( nStatus ))
5351 {
5352 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005353 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 nStatus );
5355
5356 // FIXME - Need to convert to tSirRetStatus
5357 statusCode = eSIR_FAILURE;
5358 goto returnAfterError;
5359 }
5360 else if( DOT11F_WARNED( nStatus ))
5361 {
5362 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005363 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 }
5365
5366 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005367 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5369
5370 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5372 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 )
5374 {
5375 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5376 }
5377
5378 if( eHAL_STATUS_SUCCESS !=
5379 (halStatus = halTxFrame( pMac,
5380 pPacket,
5381 (tANI_U16) frameLen,
5382 HAL_TXRX_FRM_802_11_MGMT,
5383 ANI_TXDIR_TODS,
5384 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5385 limTxComplete,
5386 pDelBAIndBuffer, txFlag )))
5387 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005388 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 statusCode = eSIR_FAILURE;
5390 //Pkt will be freed up by the callback
5391 return statusCode;
5392 }
5393 else
5394 return eSIR_SUCCESS;
5395
5396 returnAfterError:
5397
5398 // Release buffer, if allocated
5399 if( NULL != pDelBAIndBuffer )
5400 palPktFree( pMac->hHdd,
5401 HAL_TXRX_FRM_802_11_MGMT,
5402 (void *) pDelBAIndBuffer,
5403 (void *) pPacket );
5404
5405 return statusCode;
5406}
5407
5408#if defined WLAN_FEATURE_VOWIFI
5409
5410/**
5411 * \brief Send a Neighbor Report Request Action frame
5412 *
5413 *
5414 * \param pMac Pointer to the global MAC structure
5415 *
5416 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5417 *
5418 * \param peer mac address of peer station.
5419 *
5420 * \param psessionEntry address of session entry.
5421 *
5422 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5423 *
5424 *
5425 */
5426
5427tSirRetStatus
5428limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5429 tpSirMacNeighborReportReq pNeighborReq,
5430 tSirMacAddr peer,
5431 tpPESession psessionEntry
5432 )
5433{
5434 tSirRetStatus statusCode = eSIR_SUCCESS;
5435 tDot11fNeighborReportRequest frm;
5436 tANI_U8 *pFrame;
5437 tpSirMacMgmtHdr pMacHdr;
5438 tANI_U32 nBytes, nPayload, nStatus;
5439 void *pPacket;
5440 eHalStatus halstatus;
5441 tANI_U8 txFlag = 0;
5442
5443 if ( psessionEntry == NULL )
5444 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005445 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 return eSIR_FAILURE;
5447 }
5448 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5449
5450 frm.Category.category = SIR_MAC_ACTION_RRM;
5451 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5452 frm.DialogToken.token = pNeighborReq->dialogToken;
5453
5454
5455 if( pNeighborReq->ssid_present )
5456 {
5457 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5458 }
5459
5460 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5461 if ( DOT11F_FAILED( nStatus ) )
5462 {
5463 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005464 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 nStatus );
5466 // We'll fall back on the worst case scenario:
5467 nPayload = sizeof( tDot11fNeighborReportRequest );
5468 }
5469 else if ( DOT11F_WARNED( nStatus ) )
5470 {
5471 limLog( pMac, LOGW, FL("There were warnings while calculating"
5472 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005473 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005474 }
5475
5476 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5477
5478 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5479 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5480 {
5481 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005482 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 return eSIR_FAILURE;
5484 }
5485
5486 // Paranoia:
5487 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5488
5489 // Copy necessary info to BD
5490 if( eSIR_SUCCESS !=
5491 (statusCode = limPopulateMacHeader( pMac,
5492 pFrame,
5493 SIR_MAC_MGMT_FRAME,
5494 SIR_MAC_MGMT_ACTION,
5495 peer, psessionEntry->selfMacAddr)))
5496 goto returnAfterError;
5497
5498 // Update A3 with the BSSID
5499 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5500
5501 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5502
Chet Lanctot186b5732013-03-18 10:26:30 -07005503#ifdef WLAN_FEATURE_11W
5504 if ( psessionEntry->limRmfEnabled )
5505 {
5506 pMacHdr->fc.wep = 1;
5507 }
5508#endif
5509
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 // Now, we're ready to "pack" the frames
5511 nStatus = dot11fPackNeighborReportRequest( pMac,
5512 &frm,
5513 pFrame + sizeof( tSirMacMgmtHdr ),
5514 nPayload,
5515 &nPayload );
5516
5517 if( DOT11F_FAILED( nStatus ))
5518 {
5519 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005520 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 nStatus );
5522
5523 // FIXME - Need to convert to tSirRetStatus
5524 statusCode = eSIR_FAILURE;
5525 goto returnAfterError;
5526 }
5527 else if( DOT11F_WARNED( nStatus ))
5528 {
5529 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005530 FL( "There were warnings while packing Neighbor Report Request (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 }
5532
5533 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005534 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 limPrintMacAddr( pMac, peer, LOGW );
5536
5537 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5539 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 )
5541 {
5542 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5543 }
5544
5545 if( eHAL_STATUS_SUCCESS !=
5546 (halstatus = halTxFrame( pMac,
5547 pPacket,
5548 (tANI_U16) nBytes,
5549 HAL_TXRX_FRM_802_11_MGMT,
5550 ANI_TXDIR_TODS,
5551 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5552 limTxComplete,
5553 pFrame, txFlag )))
5554 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005555 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 statusCode = eSIR_FAILURE;
5557 //Pkt will be freed up by the callback
5558 return statusCode;
5559 }
5560 else
5561 return eSIR_SUCCESS;
5562
5563returnAfterError:
5564 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5565
5566 return statusCode;
5567} // End limSendNeighborReportRequestFrame.
5568
5569/**
5570 * \brief Send a Link Report Action frame
5571 *
5572 *
5573 * \param pMac Pointer to the global MAC structure
5574 *
5575 * \param pLinkReport Address of a tSirMacLinkReport
5576 *
5577 * \param peer mac address of peer station.
5578 *
5579 * \param psessionEntry address of session entry.
5580 *
5581 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5582 *
5583 *
5584 */
5585
5586tSirRetStatus
5587limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5588 tpSirMacLinkReport pLinkReport,
5589 tSirMacAddr peer,
5590 tpPESession psessionEntry
5591 )
5592{
5593 tSirRetStatus statusCode = eSIR_SUCCESS;
5594 tDot11fLinkMeasurementReport frm;
5595 tANI_U8 *pFrame;
5596 tpSirMacMgmtHdr pMacHdr;
5597 tANI_U32 nBytes, nPayload, nStatus;
5598 void *pPacket;
5599 eHalStatus halstatus;
5600 tANI_U8 txFlag = 0;
5601
5602
5603 if ( psessionEntry == NULL )
5604 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005605 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 return eSIR_FAILURE;
5607 }
5608
5609 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5610
5611 frm.Category.category = SIR_MAC_ACTION_RRM;
5612 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5613 frm.DialogToken.token = pLinkReport->dialogToken;
5614
5615
5616 //IEEE Std. 802.11 7.3.2.18. for the report element.
5617 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5618 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5619 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5620 //such case this way than changing the frame parser.
5621 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5622 frm.TPCEleLen.TPCLen = 2;
5623 frm.TxPower.txPower = pLinkReport->txPower;
5624 frm.LinkMargin.linkMargin = 0;
5625
5626 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5627 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5628 frm.RCPI.rcpi = pLinkReport->rcpi;
5629 frm.RSNI.rsni = pLinkReport->rsni;
5630
5631 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5632 if ( DOT11F_FAILED( nStatus ) )
5633 {
5634 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005635 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 nStatus );
5637 // We'll fall back on the worst case scenario:
5638 nPayload = sizeof( tDot11fLinkMeasurementReport );
5639 }
5640 else if ( DOT11F_WARNED( nStatus ) )
5641 {
5642 limLog( pMac, LOGW, FL("There were warnings while calculating"
5643 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005644 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005645 }
5646
5647 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5648
5649 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5650 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5651 {
5652 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005653 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 return eSIR_FAILURE;
5655 }
5656
5657 // Paranoia:
5658 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5659
5660 // Copy necessary info to BD
5661 if( eSIR_SUCCESS !=
5662 (statusCode = limPopulateMacHeader( pMac,
5663 pFrame,
5664 SIR_MAC_MGMT_FRAME,
5665 SIR_MAC_MGMT_ACTION,
5666 peer, psessionEntry->selfMacAddr)))
5667 goto returnAfterError;
5668
5669 // Update A3 with the BSSID
5670 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5671
5672 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5673
Chet Lanctot186b5732013-03-18 10:26:30 -07005674#ifdef WLAN_FEATURE_11W
5675 if ( psessionEntry->limRmfEnabled )
5676 {
5677 pMacHdr->fc.wep = 1;
5678 }
5679#endif
5680
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 // Now, we're ready to "pack" the frames
5682 nStatus = dot11fPackLinkMeasurementReport( pMac,
5683 &frm,
5684 pFrame + sizeof( tSirMacMgmtHdr ),
5685 nPayload,
5686 &nPayload );
5687
5688 if( DOT11F_FAILED( nStatus ))
5689 {
5690 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005691 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 nStatus );
5693
5694 // FIXME - Need to convert to tSirRetStatus
5695 statusCode = eSIR_FAILURE;
5696 goto returnAfterError;
5697 }
5698 else if( DOT11F_WARNED( nStatus ))
5699 {
5700 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005701 FL( "There were warnings while packing Link Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 }
5703
5704 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005705 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 limPrintMacAddr( pMac, peer, LOGW );
5707
5708 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5710 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 )
5712 {
5713 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5714 }
5715
5716 if( eHAL_STATUS_SUCCESS !=
5717 (halstatus = halTxFrame( pMac,
5718 pPacket,
5719 (tANI_U16) nBytes,
5720 HAL_TXRX_FRM_802_11_MGMT,
5721 ANI_TXDIR_TODS,
5722 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5723 limTxComplete,
5724 pFrame, txFlag )))
5725 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005726 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 statusCode = eSIR_FAILURE;
5728 //Pkt will be freed up by the callback
5729 return statusCode;
5730 }
5731 else
5732 return eSIR_SUCCESS;
5733
5734returnAfterError:
5735 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5736
5737 return statusCode;
5738} // End limSendLinkReportActionFrame.
5739
5740/**
5741 * \brief Send a Beacon Report Action frame
5742 *
5743 *
5744 * \param pMac Pointer to the global MAC structure
5745 *
5746 * \param dialog_token dialog token to be used in the action frame.
5747 *
5748 * \param num_report number of reports in pRRMReport.
5749 *
5750 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5751 *
5752 * \param peer mac address of peer station.
5753 *
5754 * \param psessionEntry address of session entry.
5755 *
5756 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5757 *
5758 *
5759 */
5760
5761tSirRetStatus
5762limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5763 tANI_U8 dialog_token,
5764 tANI_U8 num_report,
5765 tpSirMacRadioMeasureReport pRRMReport,
5766 tSirMacAddr peer,
5767 tpPESession psessionEntry
5768 )
5769{
5770 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 tANI_U8 *pFrame;
5772 tpSirMacMgmtHdr pMacHdr;
5773 tANI_U32 nBytes, nPayload, nStatus;
5774 void *pPacket;
5775 eHalStatus halstatus;
5776 tANI_U8 i;
5777 tANI_U8 txFlag = 0;
5778
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005779 tDot11fRadioMeasurementReport *frm =
5780 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5781 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005782 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005783 return eSIR_FAILURE;
5784 }
5785
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 if ( psessionEntry == NULL )
5787 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005788 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005789 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 return eSIR_FAILURE;
5791 }
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005792 palZeroMemory( pMac->hHdd, ( tANI_U8* )frm, sizeof( *frm ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005793
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005794 frm->Category.category = SIR_MAC_ACTION_RRM;
5795 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5796 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005797
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005798 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 -07005799
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005800 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005802 frm->MeasurementReport[i].type = pRRMReport[i].type;
5803 frm->MeasurementReport[i].token = pRRMReport[i].token;
5804 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 switch( pRRMReport[i].type )
5806 {
5807 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005808 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5809 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5810 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5811 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 break;
5813 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305814 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5815 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005816 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 break;
5818 }
5819 }
5820
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005821 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 if ( DOT11F_FAILED( nStatus ) )
5823 {
5824 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005825 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 nStatus );
5827 // We'll fall back on the worst case scenario:
5828 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005829 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 return eSIR_FAILURE;
5831 }
5832 else if ( DOT11F_WARNED( nStatus ) )
5833 {
5834 limLog( pMac, LOGW, FL("There were warnings while calculating"
5835 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005836 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 }
5838
5839 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5840
5841 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5842 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5843 {
5844 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005845 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005846 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 return eSIR_FAILURE;
5848 }
5849
5850 // Paranoia:
5851 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5852
5853 // Copy necessary info to BD
5854 if( eSIR_SUCCESS !=
5855 (statusCode = limPopulateMacHeader( pMac,
5856 pFrame,
5857 SIR_MAC_MGMT_FRAME,
5858 SIR_MAC_MGMT_ACTION,
5859 peer, psessionEntry->selfMacAddr)))
5860 goto returnAfterError;
5861
5862 // Update A3 with the BSSID
5863 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5864
5865 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5866
Chet Lanctot186b5732013-03-18 10:26:30 -07005867#ifdef WLAN_FEATURE_11W
5868 if ( psessionEntry->limRmfEnabled )
5869 {
5870 pMacHdr->fc.wep = 1;
5871 }
5872#endif
5873
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 // Now, we're ready to "pack" the frames
5875 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005876 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 pFrame + sizeof( tSirMacMgmtHdr ),
5878 nPayload,
5879 &nPayload );
5880
5881 if( DOT11F_FAILED( nStatus ))
5882 {
5883 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005884 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 nStatus );
5886
5887 // FIXME - Need to convert to tSirRetStatus
5888 statusCode = eSIR_FAILURE;
5889 goto returnAfterError;
5890 }
5891 else if( DOT11F_WARNED( nStatus ))
5892 {
5893 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005894 FL( "There were warnings while packing Radio Measure Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005895 }
5896
5897 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005898 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 limPrintMacAddr( pMac, peer, LOGW );
5900
5901 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5903 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005904 )
5905 {
5906 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5907 }
5908
5909 if( eHAL_STATUS_SUCCESS !=
5910 (halstatus = halTxFrame( pMac,
5911 pPacket,
5912 (tANI_U16) nBytes,
5913 HAL_TXRX_FRM_802_11_MGMT,
5914 ANI_TXDIR_TODS,
5915 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5916 limTxComplete,
5917 pFrame, txFlag )))
5918 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005919 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 statusCode = eSIR_FAILURE;
5921 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005922 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 return statusCode;
5924 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005925 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005926 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005928 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005929
5930returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005931 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 return statusCode;
5934} // End limSendBeaconReportActionFrame.
5935
5936#endif
5937
5938#ifdef WLAN_FEATURE_11W
5939/**
5940 * \brief Send SA query response action frame to peer
5941 *
5942 * \sa limSendSaQueryResponseFrame
5943 *
5944 *
5945 * \param pMac The global tpAniSirGlobal object
5946 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005947 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005949 * \param peer The Mac address of the AP to which this action frame is addressed
5950 *
5951 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 *
5953 * \return eSIR_SUCCESS if setup completes successfully
5954 * eSIR_FAILURE is some problem is encountered
5955 */
5956
Chet Lanctot186b5732013-03-18 10:26:30 -07005957tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005958tSirMacAddr peer,tpPESession psessionEntry)
5959{
5960
Chet Lanctot186b5732013-03-18 10:26:30 -07005961 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 tANI_U8 *pFrame;
5963 tSirRetStatus nSirStatus;
5964 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07005965 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 void *pPacket;
5967 eHalStatus halstatus;
Chet Lanctot186b5732013-03-18 10:26:30 -07005968 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005969
5970 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
Chet Lanctot186b5732013-03-18 10:26:30 -07005971 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
5972 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 action: 0 --> SA query request action frame
5974 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07005975 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
5976 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07005978 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005979
Chet Lanctot186b5732013-03-18 10:26:30 -07005980 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
5981 if ( DOT11F_FAILED( nStatus ) )
5982 {
5983 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5984 "or a SA Query Response (0x%08x)."),
5985 nStatus );
5986 // We'll fall back on the worst case scenario:
5987 nPayload = sizeof( tDot11fSaQueryRsp );
5988 }
5989 else if ( DOT11F_WARNED( nStatus ) )
5990 {
5991 limLog( pMac, LOGW, FL("There were warnings while calculating"
5992 "the packed size for an SA Query Response"
5993 " (0x%08x)."), nStatus );
5994 }
5995
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5997 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5998 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5999 {
6000 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006001 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 return eSIR_FAILURE;
6003 }
6004
6005 // Paranoia:
6006 palZeroMemory( pMac->hHdd, pFrame, nBytes );
6007
Chet Lanctot186b5732013-03-18 10:26:30 -07006008 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006009 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006010 pFrame,
6011 SIR_MAC_MGMT_FRAME,
6012 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006013 peer, psessionEntry->selfMacAddr );
6014 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006015 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006016
Chet Lanctot186b5732013-03-18 10:26:30 -07006017 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6019
Chet Lanctot186b5732013-03-18 10:26:30 -07006020 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006021
Chet Lanctot186b5732013-03-18 10:26:30 -07006022 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6023 // in the FC
6024 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006026 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 }
6028
Chet Lanctot186b5732013-03-18 10:26:30 -07006029 // Pack 11w SA query response frame
6030 nStatus = dot11fPackSaQueryRsp( pMac,
6031 &frm,
6032 pFrame + sizeof( tSirMacMgmtHdr ),
6033 nPayload,
6034 &nPayload );
6035
6036 if ( DOT11F_FAILED( nStatus ))
6037 {
6038 limLog( pMac, LOGE,
6039 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6040 nStatus );
6041 // FIXME - Need to convert to tSirRetStatus
6042 nSirStatus = eSIR_FAILURE;
6043 goto returnAfterError;
6044 }
6045 else if ( DOT11F_WARNED( nStatus ))
6046 {
6047 limLog( pMac, LOGW,
6048 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6049 nStatus);
6050 }
6051
6052 limLog( pMac, LOG1,
6053 FL( "Sending a SA Query Response to " ));
6054 limPrintMacAddr( pMac, peer, LOGW );
6055
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006056 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006057#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006058 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6059 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006060#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006061 )
6062 {
6063 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6064 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006065
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006066 halstatus = halTxFrame( pMac,
6067 pPacket,
6068 (tANI_U16) nBytes,
6069 HAL_TXRX_FRM_802_11_MGMT,
6070 ANI_TXDIR_TODS,
6071 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6072 limTxComplete,
6073 pFrame, txFlag );
6074 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006075 {
6076 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6077 nSirStatus = eSIR_FAILURE;
6078 //Pkt will be freed up by the callback
6079 return nSirStatus;
6080 }
6081 else {
6082 return eSIR_SUCCESS;
6083 }
6084
6085returnAfterError:
6086 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6087 return nSirStatus;
6088} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006089#endif