blob: 7753391eb79c7e4e6f38d894a65113871bc86e7a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson32d95a32012-09-10 13:15:23 -07002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -07003 *
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
22/**
23 * \file limSendManagementFrames.c
24 *
25 * \brief Code for preparing and sending 802.11 Management frames
26 *
27 * Copyright (C) 2005-2007 Airgo Networks, Incorporated
28 *
29 */
30
31#include "sirApi.h"
32#include "aniGlobal.h"
33#include "sirMacProtDef.h"
34#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
35#include "halDataStruct.h"
36#endif
37#include "cfgApi.h"
38#include "utilsApi.h"
39#include "limTypes.h"
40#include "limUtils.h"
41#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070042#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043#include "dot11f.h"
44#include "limStaHashApi.h"
45#include "schApi.h"
46#include "limSendMessages.h"
47#if defined WLAN_FEATURE_VOWIFI
48#include "rrmApi.h"
49#endif
50
51#ifdef FEATURE_WLAN_CCX
52#include <limCcxparserApi.h>
53#endif
54#include "wlan_qct_wda.h"
55#ifdef WLAN_FEATURE_11W
56#include "dot11fdefs.h"
57#endif
58
59
60////////////////////////////////////////////////////////////////////////
61
Jeff Johnson295189b2012-06-20 16:38:30 -070062
63/**
64 *
65 * \brief This function is called by various LIM modules to prepare the
66 * 802.11 frame MAC header
67 *
68 *
69 * \param pMac Pointer to Global MAC structure
70 *
71 * \param pBD Pointer to the frame buffer that needs to be populate
72 *
73 * \param type Type of the frame
74 *
75 * \param subType Subtype of the frame
76 *
77 * \return eHalStatus
78 *
79 *
80 * The pFrameBuf argument points to the beginning of the frame buffer to
81 * which - a) The 802.11 MAC header is set b) Following this MAC header
82 * will be the MGMT frame payload The payload itself is populated by the
83 * caller API
84 *
85 *
86 */
87
88tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
89 tANI_U8* pBD,
90 tANI_U8 type,
91 tANI_U8 subType,
92 tSirMacAddr peerAddr ,tSirMacAddr selfMacAddr)
93{
94 tSirRetStatus statusCode = eSIR_SUCCESS;
95 tpSirMacMgmtHdr pMacHdr;
96
97 /// Prepare MAC management header
98 pMacHdr = (tpSirMacMgmtHdr) (pBD);
99
100 // Prepare FC
101 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
102 pMacHdr->fc.type = type;
103 pMacHdr->fc.subType = subType;
104
105 // Prepare Address 1
106 palCopyMemory( pMac->hHdd,
107 (tANI_U8 *) pMacHdr->da,
108 (tANI_U8 *) peerAddr,
109 sizeof( tSirMacAddr ));
110
111 // Prepare Address 2
112 #if 0
113 if ((statusCode = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, (tANI_U8 *) pMacHdr->sa,
114 &cfgLen)) != eSIR_SUCCESS)
115 {
116 // Could not get STA_ID from CFG. Log error.
117 limLog( pMac, LOGP,
118 FL("Failed to retrive STA_ID\n"));
119 return statusCode;
120 }
121 #endif// TO SUPPORT BT-AMP
122 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
123
124 // Prepare Address 3
125 palCopyMemory( pMac->hHdd,
126 (tANI_U8 *) pMacHdr->bssId,
127 (tANI_U8 *) peerAddr,
128 sizeof( tSirMacAddr ));
129 return statusCode;
130} /*** end limPopulateMacHeader() ***/
131
132/**
133 * \brief limSendProbeReqMgmtFrame
134 *
135 *
136 * \param pMac Pointer to Global MAC structure
137 *
138 * \param pSsid SSID to be sent in Probe Request frame
139 *
140 * \param bssid BSSID to be sent in Probe Request frame
141 *
142 * \param nProbeDelay probe delay to be used before sending Probe Request
143 * frame
144 *
145 * \param nChannelNum Channel # on which the Probe Request is going out
146 *
147 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
148 *
149 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
150 *
151 * This function is called by various LIM modules to send Probe Request frame
152 * during active scan/learn phase.
153 * Probe request is sent out in the following scenarios:
154 * --heartbeat failure: session needed
155 * --join req: session needed
156 * --foreground scan: no session
157 * --background scan: no session
158 * --schBeaconProcessing: to get EDCA parameters: session needed
159 *
160 *
161 */
162tSirRetStatus
163limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
164 tSirMacSSid *pSsid,
165 tSirMacAddr bssid,
166 tANI_U8 nChannelNum,
167 tSirMacAddr SelfMacAddr,
168 tANI_U32 dot11mode,
169 tANI_U32 nAdditionalIELen,
170 tANI_U8 *pAdditionalIE)
171{
172 tDot11fProbeRequest pr;
173 tANI_U32 nStatus, nBytes, nPayload;
174 tSirRetStatus nSirStatus;
175 tANI_U8 *pFrame;
176 void *pPacket;
177 eHalStatus halstatus;
178 tpPESession psessionEntry;
179 tANI_U8 sessionId;
180#ifdef WLAN_FEATURE_P2P
181 tANI_U8 *p2pIe = NULL;
182#endif
183 tANI_U8 txFlag = 0;
184
185#ifndef GEN4_SCAN
186 return eSIR_FAILURE;
187#endif
188
189#if defined ( ANI_DVT_DEBUG )
190 return eSIR_FAILURE;
191#endif
192
193 /*
194 * session context may or may not be present, when probe request needs to be sent out.
195 * following cases exist:
196 * --heartbeat failure: session needed
197 * --join req: session needed
198 * --foreground scan: no session
199 * --background scan: no session
200 * --schBeaconProcessing: to get EDCA parameters: session needed
201 * If session context does not exist, some IEs will be populated from CFGs,
202 * e.g. Supported and Extended rate set IEs
203 */
204 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
205
206 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
207 // and then hand it off to 'dot11fPackProbeRequest' (for
208 // serialization). We start by zero-initializing the structure:
209 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
210
211 // & delegating to assorted helpers:
212 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
213
214#ifdef WLAN_FEATURE_P2P
215 if( nAdditionalIELen && pAdditionalIE )
216 {
217 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
218 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700219 /* Don't include 11b rate only when device is doing P2P Search */
220 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
221 ( p2pIe != NULL ) &&
222 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
223 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
224 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
225 ( ( psessionEntry != NULL ) &&
226 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
227 )
228 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 {
230 /* In the below API pass channel number > 14, do that it fills only
231 * 11a rates in supported rates */
232 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
233 }
234 else
235 {
236#endif
237 PopulateDot11fSuppRates( pMac, nChannelNum,
238 &pr.SuppRates,psessionEntry);
239
240 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
241 {
242 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
243 }
244#ifdef WLAN_FEATURE_P2P
245 }
246#endif
247
248#if defined WLAN_FEATURE_VOWIFI
249 //Table 7-14 in IEEE Std. 802.11k-2008 says
250 //DS params "can" be present in RRM is disabled and "is" present if
251 //RRM is enabled. It should be ok even if we add it into probe req when
252 //RRM is not enabled.
253 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
254 //Call RRM module to get the tx power for management used.
255 {
256 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
257 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
258 }
259#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700260
261 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700262 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700263 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700264 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700265 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700266 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700267 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700268 } else { //psessionEntry == NULL
269 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700271 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 }
273 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700274#ifdef WLAN_FEATURE_11AC
275 if (psessionEntry != NULL ) {
276 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
277 //Include HT Capability IE
278 if (psessionEntry->vhtCapability)
279 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700280 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
281 }
282 } else {
283 if (IS_DOT11_MODE_VHT(dot11mode))
284 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700285 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
286 }
287 }
288#endif
289
Jeff Johnson295189b2012-06-20 16:38:30 -0700290
291 // That's it-- now we pack it. First, how much space are we going to
292 // need?
293 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
294 if ( DOT11F_FAILED( nStatus ) )
295 {
296 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
297 "or a Probe Request (0x%08x).\n"), nStatus );
298 // We'll fall back on the worst case scenario:
299 nPayload = sizeof( tDot11fProbeRequest );
300 }
301 else if ( DOT11F_WARNED( nStatus ) )
302 {
303 limLog( pMac, LOGW, FL("There were warnings while calculating"
304 "the packed size for a Probe Request ("
305 "0x%08x).\n"), nStatus );
306 }
307
308 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
309
310 // Ok-- try to allocate some memory:
311 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
312 ( tANI_U16 )nBytes, ( void** ) &pFrame,
313 ( void** ) &pPacket );
314 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
315 {
316 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
317 "be Request.\n"), nBytes );
318 return eSIR_MEM_ALLOC_FAILED;
319 }
320
321 // Paranoia:
322 palZeroMemory( pMac->hHdd, pFrame, nBytes );
323
324 // Next, we fill out the buffer descriptor:
325 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
326 SIR_MAC_MGMT_PROBE_REQ, bssid ,SelfMacAddr);
327 if ( eSIR_SUCCESS != nSirStatus )
328 {
329 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
330 "tor for a Probe Request (%d).\n"),
331 nSirStatus );
332 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
333 ( void* ) pFrame, ( void* ) pPacket );
334 return nSirStatus; // allocated!
335 }
336
337 // That done, pack the Probe Request:
338 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
339 sizeof( tSirMacMgmtHdr ),
340 nPayload, &nPayload );
341 if ( DOT11F_FAILED( nStatus ) )
342 {
343 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x).\n"),
344 nStatus );
345 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
346 return eSIR_FAILURE; // allocated!
347 }
348 else if ( DOT11F_WARNED( nStatus ) )
349 {
350 limLog( pMac, LOGW, FL("There were warnings while packing a P"
351 "robe Request (0x%08x).\n") );
352 }
353
354 // Append any AddIE if present.
355 if( nAdditionalIELen )
356 {
357 palCopyMemory( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
358 pAdditionalIE, nAdditionalIELen );
359 nPayload += nAdditionalIELen;
360 }
361
362 /* If this probe request is sent during P2P Search State, then we need
363 * to send it at OFDM rate.
364 */
365 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
366#ifdef WLAN_FEATURE_P2P
367 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
368 pMac->lim.gpLimMlmScanReq->p2pSearch )
369#endif
370 )
371 {
372 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
373 }
374
375
376 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
377 HAL_TXRX_FRM_802_11_MGMT,
378 ANI_TXDIR_TODS,
379 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
380 limTxComplete, pFrame, txFlag );
381 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
382 {
383 limLog( pMac, LOGE, FL("could not send Probe Request frame!\n" ));
384 //Pkt will be freed up by the callback
385 return eSIR_FAILURE;
386 }
387
388 return eSIR_SUCCESS;
389} // End limSendProbeReqMgmtFrame.
390
391#ifdef WLAN_FEATURE_P2P
392tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
393 tANI_U8* addIE, tANI_U16 *addnIELen,
394 tANI_U8 probeReqP2pIe)
395{
396 /* If Probe request doesn't have P2P IE, then take out P2P IE
397 from additional IE */
398 if(!probeReqP2pIe)
399 {
400 tANI_U8* tempbuf = NULL;
401 tANI_U16 tempLen = 0;
402 int left = *addnIELen;
403 v_U8_t *ptr = addIE;
404 v_U8_t elem_id, elem_len;
405
406 if(NULL == addIE)
407 {
408 PELOGE(limLog(pMac, LOGE,
409 FL(" NULL addIE pointer"));)
410 return eSIR_FAILURE;
411 }
412
413 if( (palAllocateMemory(pMac->hHdd, (void**)&tempbuf,
Jeff Johnson43971f52012-07-17 12:26:56 -0700414 left)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 {
416 PELOGE(limLog(pMac, LOGE,
417 FL("Unable to allocate memory to store addn IE"));)
418 return eSIR_MEM_ALLOC_FAILED;
419 }
420
421 while(left >= 2)
422 {
423 elem_id = ptr[0];
424 elem_len = ptr[1];
425 left -= 2;
426 if(elem_len > left)
427 {
428 limLog( pMac, LOGE,
429 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****\n"),
430 elem_id,elem_len,left);
431 palFreeMemory(pMac->hHdd, tempbuf);
432 return eSIR_FAILURE;
433 }
434 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
435 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
436 {
437 palCopyMemory ( pMac->hHdd, tempbuf + tempLen, &ptr[0], elem_len + 2);
438 tempLen += (elem_len + 2);
439 }
440 left -= elem_len;
441 ptr += (elem_len + 2);
442 }
443 palCopyMemory ( pMac->hHdd, addIE, tempbuf, tempLen);
444 *addnIELen = tempLen;
445 palFreeMemory(pMac->hHdd, tempbuf);
446 }
447 return eSIR_SUCCESS;
448}
449#endif
450
451void
452limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
453 tSirMacAddr peerMacAddr,
454 tpAniSSID pSsid,
455 short nStaId,
456 tANI_U8 nKeepAlive,
457 tpPESession psessionEntry,
458 tANI_U8 probeReqP2pIe)
459{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700460 tDot11fProbeResponse *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -0700461 tSirRetStatus nSirStatus;
462 tANI_U32 cfg, nPayload, nBytes, nStatus;
463 tpSirMacMgmtHdr pMacHdr;
464 tANI_U8 *pFrame;
465 void *pPacket;
466 eHalStatus halstatus;
467 tANI_U32 addnIEPresent;
468 tANI_U32 addnIE1Len=0;
469 tANI_U32 addnIE2Len=0;
470 tANI_U32 addnIE3Len=0;
471 tANI_U16 totalAddnIeLen = 0;
472 tANI_U32 wpsApEnable=0, tmp;
473 tANI_U8 txFlag = 0;
474 tANI_U8 *addIE = NULL;
475#ifdef WLAN_FEATURE_P2P
476 tANI_U8 *pP2pIe = NULL;
477 tANI_U8 noaLen = 0;
478 tANI_U8 total_noaLen = 0;
479 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
480 + SIR_P2P_IE_HEADER_LEN];
481 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
482#endif
483
484 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
485 {
486 return; // in this case.
487 }
488
489 if(NULL == psessionEntry)
490 {
491 return;
492 }
493
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700494 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
495 (void **)&pFrm, sizeof(tDot11fProbeResponse)))
496 {
497 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limSendProbeRspMgmtFrame\n") );
498 return;
499 }
500
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 // Fill out 'frm', after which we'll just hand the struct off to
502 // 'dot11fPackProbeResponse'.
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700503 palZeroMemory( pMac->hHdd, ( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700504
505 // Timestamp to be updated by TFP, below.
506
507 // Beacon Interval:
508#ifdef WLAN_SOFTAP_FEATURE
509 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
510 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700511 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 }
513 else
514 {
515#endif
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800516 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
517 if (eSIR_SUCCESS != nSirStatus)
518 {
519 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d).\n"),
520 nSirStatus );
521 return;
522 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700523 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Jeff Johnson295189b2012-06-20 16:38:30 -0700524#ifdef WLAN_SOFTAP_FEATURE
525 }
526#endif
527
528
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700529 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
530 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700532 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700534 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
535 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700536
537#ifdef ANI_PRODUCT_TYPE_AP
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700538 PopulateDot11fCFParams( pMac, &pFrm->Capabilities, &pFrm->CFParams );
Jeff Johnson295189b2012-06-20 16:38:30 -0700539#endif // AP Image
540
541#ifdef WLAN_SOFTAP_FEATURE
542 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
543 {
544 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
545 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700546 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 }
548 }
549 else
550 {
551#endif
552 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
553 limLog(pMac, LOGP,"Failed to cfg get id %d\n", WNI_CFG_WPS_ENABLE );
554
555 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
556
557 if (wpsApEnable)
558 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700559 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 }
561
562 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
563 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700564 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
566 }
567
568 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
569 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700570 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
572 }
573#ifdef WLAN_SOFTAP_FEATURE
574 }
575#endif
576
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700577 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
578 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
580#ifdef ANI_PRODUCT_TYPE_AP
Jeff Johnsone7245742012-09-05 17:12:55 -0700581 if( pSessionEntry->lim11hEnable )
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700583 PopulateDot11fPowerConstraints( pMac, &pFrm->PowerConstraints );
584 PopulateDot11fTPCReport( pMac, &pFrm->TPCReport, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585
586 // If .11h isenabled & channel switching is not already started and
587 // we're in either PRIMARY_ONLY or PRIMARY_AND_SECONDARY state, then
588 // populate 802.11h channel switch IE
589 if (( pMac->lim.gLimChannelSwitch.switchCount != 0 ) &&
590 ( pMac->lim.gLimChannelSwitch.state ==
591 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY ||
592 pMac->lim.gLimChannelSwitch.state ==
593 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY ) )
594 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700595 PopulateDot11fChanSwitchAnn( pMac, &pFrm->ChanSwitchAnn, psessionEntry );
596 PopulateDot11fExtChanSwitchAnn(pMac, &pFrm->ExtChanSwitchAnn, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 }
598 }
599#endif
600
601 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700602 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700603
604
605 // N.B. In earlier implementations, the RSN IE would be placed in
606 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
607 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700608 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700609
610 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700611 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700613 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700614#ifdef WLAN_SOFTAP_FEATURE
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700615 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700616#else
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700617 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -0700618#endif
619 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700620#ifdef WLAN_FEATURE_11AC
621 if(psessionEntry->vhtCapability)
622 {
623 limLog( pMac, LOGW, FL("Populate VHT IE in Probe Response\n"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700624 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
625 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700626 // we do not support multi users yet
627 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700628 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700629 }
630#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700631
632 if ( psessionEntry->pLimStartBssReq )
633 {
634 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700635 &pFrm->WPA );
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 PopulateDot11fRSN( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700637 &pFrm->RSN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 }
639
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700640 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700641
642#if defined(FEATURE_WLAN_WAPI)
643 if( psessionEntry->pLimStartBssReq )
644 {
645 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700646 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 }
648
649#endif // defined(FEATURE_WLAN_WAPI)
650
651
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700652 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 if ( DOT11F_FAILED( nStatus ) )
654 {
655 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
656 "or a Probe Response (0x%08x).\n"),
657 nStatus );
658 // We'll fall back on the worst case scenario:
659 nPayload = sizeof( tDot11fProbeResponse );
660 }
661 else if ( DOT11F_WARNED( nStatus ) )
662 {
663 limLog( pMac, LOGW, FL("There were warnings while calculating"
664 "the packed size for a Probe Response "
665 "(0x%08x).\n"), nStatus );
666 }
667
668 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
669
670 addnIEPresent = false;
671
672#ifdef WLAN_FEATURE_P2P
673 if( pMac->lim.gpLimRemainOnChanReq )
674 {
675 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
676 }
677 //Only use CFG for non-listen mode. This CFG is not working for concurrency
678 //In listening mode, probe rsp IEs is passed in the message from SME to PE
679 else
680#endif
681 {
682
683 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
684 &addnIEPresent) != eSIR_SUCCESS)
685 {
686 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700687 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 return;
689 }
690 }
691
692 if (addnIEPresent)
693 {
694 if( (palAllocateMemory(pMac->hHdd, (void**)&addIE,
Jeff Johnson43971f52012-07-17 12:26:56 -0700695 WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3 )) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 {
697 PELOGE(limLog(pMac, LOGE,
698 FL("Unable to allocate memory to store addn IE"));)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700699 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 return;
701 }
702
703 //Probe rsp IE available
704 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
705 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
706 {
707 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
708 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700709 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 return;
711 }
712 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
713 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
714 {
715 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
716 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
717 &addnIE1Len) )
718 {
719 limLog(pMac, LOGP,
720 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
721 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700722 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 return;
724 }
725 }
726
727 //Probe rsp IE available
728 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
729 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
730 {
731 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
732 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700733 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 return;
735 }
736 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
737 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
738 {
739 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
740 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
741 &addnIE2Len) )
742 {
743 limLog(pMac, LOGP,
744 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
745 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700746 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 return;
748 }
749 }
750
751 //Probe rsp IE available
752 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
753 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
754 {
755 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
756 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700757 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 return;
759 }
760 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
761 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
762 {
763 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
764 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
765 &addIE[addnIE1Len + addnIE2Len],
766 &addnIE3Len) )
767 {
768 limLog(pMac, LOGP,
769 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
770 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700771 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 return;
773 }
774 }
775 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
776
777#ifdef WLAN_FEATURE_P2P
778 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
779 {
780 limLog(pMac, LOGP,
781 FL("Unable to get final Additional IE for Probe Req"));
782 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700783 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 return;
785 }
786 nBytes = nBytes + totalAddnIeLen;
787
788 if (probeReqP2pIe)
789 {
790 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
791 if (pP2pIe != NULL)
792 {
793 //get NoA attribute stream P2P IE
794 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
795 if (noaLen != 0)
796 {
797 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
798 &noaStream[0], noaLen);
799 nBytes = nBytes + total_noaLen;
800 }
801 }
802 }
803#endif
804 }
805
806 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
807 ( tANI_U16 )nBytes, ( void** ) &pFrame,
808 ( void** ) &pPacket );
809 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
810 {
811 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
812 "be Response.\n"), nBytes );
813 if ( addIE != NULL )
814 {
815 palFreeMemory(pMac->hHdd, addIE);
816 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700817 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 return;
819 }
820
821 // Paranoia:
822 palZeroMemory( pMac->hHdd, pFrame, nBytes );
823
824 // Next, we fill out the buffer descriptor:
825 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
826 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
827 if ( eSIR_SUCCESS != nSirStatus )
828 {
829 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
830 "tor for a Probe Response (%d).\n"),
831 nSirStatus );
832 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
833 ( void* ) pFrame, ( void* ) pPacket );
834 if ( addIE != NULL )
835 {
836 palFreeMemory(pMac->hHdd, addIE);
837 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700838 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 return;
840 }
841
842 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
843
844 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
845
846 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700847 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 nPayload, &nPayload );
849 if ( DOT11F_FAILED( nStatus ) )
850 {
851 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x).\n"),
852 nStatus );
853 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
854 if ( addIE != NULL )
855 {
856 palFreeMemory(pMac->hHdd, addIE);
857 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700858 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 return; // allocated!
860 }
861 else if ( DOT11F_WARNED( nStatus ) )
862 {
863 limLog( pMac, LOGW, FL("There were warnings while packing a P"
864 "robe Response (0x%08x).\n") );
865 }
866
867 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
868 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
869
870 pMac->sys.probeRespond++;
871
872#ifdef WLAN_FEATURE_P2P
873 if( pMac->lim.gpLimRemainOnChanReq )
874 {
875 palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
876 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
877 }
878#endif
879
880 if ( addnIEPresent )
881 {
882 if (palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson43971f52012-07-17 12:26:56 -0700883 &addIE[0], totalAddnIeLen) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 {
885 limLog(pMac, LOGP, FL("Additional Probe Rp IE request failed while Appending: %x"),halstatus);
886 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
887 ( void* ) pFrame, ( void* ) pPacket );
888 if ( addIE != NULL )
889 {
890 palFreeMemory(pMac->hHdd, addIE);
891 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700892 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 return;
894 }
895 }
896#ifdef WLAN_FEATURE_P2P
897 if (noaLen != 0)
898 {
899 if (palCopyMemory ( pMac->hHdd, &pFrame[nBytes - (total_noaLen)],
Jeff Johnson43971f52012-07-17 12:26:56 -0700900 &noaIe[0], total_noaLen) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 {
902 limLog(pMac, LOGE,
903 FL("Not able to insert NoA because of length constraint"));
904 }
905 }
906#endif
907
908 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
909#ifdef WLAN_FEATURE_P2P
910 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
911 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
912#endif
913 )
914 {
915 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
916 }
917
918 // Queue Probe Response frame in high priority WQ
919 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
920 ( tANI_U16 ) nBytes,
921 HAL_TXRX_FRM_802_11_MGMT,
922 ANI_TXDIR_TODS,
923 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
924 limTxComplete, pFrame, txFlag );
925 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
926 {
927 limLog( pMac, LOGE, FL("Could not send Probe Response.\n") );
928 //Pkt will be freed up by the callback
929 }
930
931 if ( addIE != NULL )
932 {
933 palFreeMemory(pMac->hHdd, addIE);
934 }
935
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700936 palFreeMemory(pMac->hHdd, pFrm);
937 return;
938
939
Jeff Johnson295189b2012-06-20 16:38:30 -0700940} // End limSendProbeRspMgmtFrame.
941
942void
943limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
944 tSirMacAddr peerMacAddr,
945 tSirAddtsReqInfo *pAddTS,
946 tpPESession psessionEntry)
947{
948 tANI_U16 i;
949 tANI_U8 *pFrame;
950 tSirRetStatus nSirStatus;
951 tDot11fAddTSRequest AddTSReq;
952 tDot11fWMMAddTSRequest WMMAddTSReq;
953 tANI_U32 nPayload, nBytes, nStatus;
954 tpSirMacMgmtHdr pMacHdr;
955 void *pPacket;
956#ifdef FEATURE_WLAN_CCX
957 tANI_U32 phyMode;
958#endif
959 eHalStatus halstatus;
960 tANI_U8 txFlag = 0;
961
962 if(NULL == psessionEntry)
963 {
964 return;
965 }
966
967 if ( ! pAddTS->wmeTspecPresent )
968 {
969 palZeroMemory( pMac->hHdd, ( tANI_U8* )&AddTSReq, sizeof( AddTSReq ) );
970
971 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
972 AddTSReq.DialogToken.token = pAddTS->dialogToken;
973 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
974 if ( pAddTS->lleTspecPresent )
975 {
976 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
977 }
978 else
979 {
980 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
981 }
982
983 if ( pAddTS->lleTspecPresent )
984 {
985 AddTSReq.num_WMMTCLAS = 0;
986 AddTSReq.num_TCLAS = pAddTS->numTclas;
987 for ( i = 0; i < pAddTS->numTclas; ++i)
988 {
989 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
990 &AddTSReq.TCLAS[i] );
991 }
992 }
993 else
994 {
995 AddTSReq.num_TCLAS = 0;
996 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
997 for ( i = 0; i < pAddTS->numTclas; ++i)
998 {
999 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1000 &AddTSReq.WMMTCLAS[i] );
1001 }
1002 }
1003
1004 if ( pAddTS->tclasProcPresent )
1005 {
1006 if ( pAddTS->lleTspecPresent )
1007 {
1008 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1009 AddTSReq.TCLASSPROC.present = 1;
1010 }
1011 else
1012 {
1013 AddTSReq.WMMTCLASPROC.version = 1;
1014 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1015 AddTSReq.WMMTCLASPROC.present = 1;
1016 }
1017 }
1018
1019 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1020 if ( DOT11F_FAILED( nStatus ) )
1021 {
1022 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
1023 "or an Add TS Request (0x%08x).\n"),
1024 nStatus );
1025 // We'll fall back on the worst case scenario:
1026 nPayload = sizeof( tDot11fAddTSRequest );
1027 }
1028 else if ( DOT11F_WARNED( nStatus ) )
1029 {
1030 limLog( pMac, LOGW, FL("There were warnings while calculating"
1031 "the packed size for an Add TS Request"
1032 " (0x%08x).\n"), nStatus );
1033 }
1034 }
1035 else
1036 {
1037 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ) );
1038
1039 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1040 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1041 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1042
1043 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1044 WMMAddTSReq.StatusCode.statusCode = 0;
1045
1046 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1047#ifdef FEATURE_WLAN_CCX
1048 limGetPhyMode(pMac, &phyMode, psessionEntry);
1049
1050 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1051 {
1052 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1053 }
1054 else
1055 {
1056 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1057 }
1058 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1059#endif
1060 // fillWmeTspecIE
1061
1062 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1063 if ( DOT11F_FAILED( nStatus ) )
1064 {
1065 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
1066 "or a WMM Add TS Request (0x%08x).\n"),
1067 nStatus );
1068 // We'll fall back on the worst case scenario:
1069 nPayload = sizeof( tDot11fAddTSRequest );
1070 }
1071 else if ( DOT11F_WARNED( nStatus ) )
1072 {
1073 limLog( pMac, LOGW, FL("There were warnings while calculating"
1074 "the packed size for a WMM Add TS Requ"
1075 "est (0x%08x).\n"), nStatus );
1076 }
1077 }
1078
1079 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1080
1081 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1082 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1083 ( void** ) &pPacket );
1084 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1085 {
1086 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
1087 "d TS Request.\n"), nBytes );
1088 return;
1089 }
1090
1091 // Paranoia:
1092 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1093
1094 // Next, we fill out the buffer descriptor:
1095 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1096 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1097 if ( eSIR_SUCCESS != nSirStatus )
1098 {
1099 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1100 "tor for an Add TS Request (%d).\n"),
1101 nSirStatus );
1102 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1103 ( void* ) pFrame, ( void* ) pPacket );
1104 return;
1105 }
1106
1107 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1108
1109 #if 0
1110 cfgLen = SIR_MAC_ADDR_LENGTH;
1111 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1112 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1113 {
1114 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1115 "e sending an Add TS Request.\n") );
1116 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1117 ( void* ) pFrame, ( void* ) pPacket );
1118 return;
1119 }
1120 #endif //TO SUPPORT BT-AMP
1121
1122 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1123
1124 // That done, pack the struct:
1125 if ( ! pAddTS->wmeTspecPresent )
1126 {
1127 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1128 pFrame + sizeof(tSirMacMgmtHdr),
1129 nPayload, &nPayload );
1130 if ( DOT11F_FAILED( nStatus ) )
1131 {
1132 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
1133 "(0x%08x).\n"),
1134 nStatus );
1135 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1136 return; // allocated!
1137 }
1138 else if ( DOT11F_WARNED( nStatus ) )
1139 {
1140 limLog( pMac, LOGW, FL("There were warnings while packing"
1141 "an Add TS Request (0x%08x).\n") );
1142 }
1143 }
1144 else
1145 {
1146 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1147 pFrame + sizeof(tSirMacMgmtHdr),
1148 nPayload, &nPayload );
1149 if ( DOT11F_FAILED( nStatus ) )
1150 {
1151 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
1152 "st (0x%08x).\n"),
1153 nStatus );
1154 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1155 return; // allocated!
1156 }
1157 else if ( DOT11F_WARNED( nStatus ) )
1158 {
1159 limLog( pMac, LOGW, FL("There were warnings while packing"
1160 "a WMM Add TS Request (0x%08x).\n") );
1161 }
1162 }
1163
1164 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1165 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1166
1167 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
1168#ifdef WLAN_FEATURE_P2P
1169 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1170 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
1171#endif
1172 )
1173 {
1174 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1175 }
1176
1177 // Queue Addts Response frame in high priority WQ
1178 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1179 HAL_TXRX_FRM_802_11_MGMT,
1180 ANI_TXDIR_TODS,
1181 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1182 limTxComplete, pFrame, txFlag );
1183 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1184 {
1185 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
1186 " (%X) ***\n" ), halstatus );
1187 //Pkt will be freed up by the callback
1188 }
1189
1190} // End limSendAddtsReqActionFrame.
1191
1192/* Added ANI_PRODUCT_TYPE_CLIENT for BT-AMP Support */
1193#ifdef ANI_PRODUCT_TYPE_AP
1194
1195void
1196limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1197 tANI_U16 statusCode,
1198 tANI_U16 aid,
1199 tSirMacAddr peerMacAddr,
1200 tANI_U8 subType,
1201 tpDphHashNode pSta,
1202 tpPESession psessionEntry)
1203{
1204 tDot11fAssocResponse frm;
1205 tANI_U8 *pFrame, *macAddr;
1206 tpSirMacMgmtHdr pMacHdr;
1207 tSirRetStatus nSirStatus;
1208 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1209 tHalBitVal qosMode, wmeMode;
1210 tANI_U32 nPayload, nBytes, nStatus, cfgLen;
1211 void *pPacket;
1212 eHalStatus halstatus;
1213 tUpdateBeaconParams beaconParams;
1214 tANI_U32 wpsApEnable=0, tmp;
1215 tANI_U8 txFlag = 0;
1216
1217 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
1218
1219 limGetQosMode(pMac, &qosMode);
1220 limGetWmeMode(pMac, &wmeMode);
1221
1222 // An Add TS IE is added only if the AP supports it and the requesting
1223 // STA sent a traffic spec.
1224 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1225
1226 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry);
1227
1228 frm.Status.status = statusCode;
1229
1230 frm.AID.associd = aid | LIM_AID_MASK;
1231
1232 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates );
1233
1234 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
1235 limLog(pMac, LOGP,"Failed to cfg get id %d\n", WNI_CFG_WPS_ENABLE );
1236
1237 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
1238
1239 if (wpsApEnable)
1240 {
1241 PopulateDot11fWscInAssocRes(pMac, &frm.WscAssocRes);
1242 }
1243
1244 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1245 &frm.ExtSuppRates, psessionEntry );
1246
1247 if ( NULL != pSta )
1248 {
1249 if ( eHAL_SET == qosMode )
1250 {
1251 if ( pSta->lleEnabled )
1252 {
1253 lleMode = 1;
1254 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1255 {
1256 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1257
1258// FramesToDo:...
1259// if ( fAddTS )
1260// {
1261// tANI_U8 *pAf = pBody;
1262// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1263// tANI_U32 tlen;
1264// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1265// &tlen, bufLen - frameLen);
1266// } // End if on Add TS.
1267 }
1268 } // End if on .11e enabled in 'pSta'.
1269 } // End if on QOS Mode on.
1270
1271 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1272 {
1273 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1274 {
1275 PopulateDot11fWMMParams( pMac, &frm.WMMParams );
1276
1277 if ( pSta->wsmEnabled )
1278 {
1279 PopulateDot11fWMMCaps(&frm.WMMCaps );
1280 }
1281 }
1282 }
1283
1284 if ( pSta->aniPeer )
1285 {
1286 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1287 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1288 {
1289 edcaInclude = 1;
1290 }
1291
1292 } // End if on Airgo peer.
1293
1294 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001295 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001297 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
1298 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 }
1300 } // End if on non-NULL 'pSta'.
1301
1302
1303 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1304 limDecideApProtection(pMac, peerMacAddr, &beaconParams);
1305 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams);
1306 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams);
1307
1308 //Send message to HAL about beacon parameter change.
1309 if(beaconParams.paramChangeBitmap)
1310 {
1311 schSetFixedBeaconFields(pMac,psessionEntry);
1312 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1313 }
1314
1315 // Allocate a buffer for this frame:
1316 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1317 if ( DOT11F_FAILED( nStatus ) )
1318 {
1319 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1320 "or an Association Response (0x%08x).\n"),
1321 nStatus );
1322 return;
1323 }
1324 else if ( DOT11F_WARNED( nStatus ) )
1325 {
1326 limLog( pMac, LOGW, FL("There were warnings while calculating"
1327 "the packed size for an Association Re"
1328 "sponse (0x%08x).\n"), nStatus );
1329 }
1330
1331 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1332
1333 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1334 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1335 ( void** ) &pPacket );
1336 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1337 {
1338 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP.\n"));
1339 return;
1340 }
1341
1342 // Paranoia:
1343 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1344
1345 // Next, we fill out the buffer descriptor:
1346 nSirStatus = limPopulateMacHeader( pMac,
1347 pFrame,
1348 SIR_MAC_MGMT_FRAME,
1349 ( LIM_ASSOC == subType ) ?
1350 SIR_MAC_MGMT_ASSOC_RSP :
1351 SIR_MAC_MGMT_REASSOC_RSP,
1352 peerMacAddr);
1353 if ( eSIR_SUCCESS != nSirStatus )
1354 {
1355 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1356 "tor for an Association Response (%d).\n"),
1357 nSirStatus );
1358 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1359 ( void* ) pFrame, ( void* ) pPacket );
1360 return;
1361 }
1362
1363 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1364
1365
1366 cfgLen = SIR_MAC_ADDR_LENGTH;
1367 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1368 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1369 {
1370 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1371 "e sending an Association Response.\n") );
1372 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1373 return; // allocated!
1374 }
1375
1376 nStatus = dot11fPackAssocResponse( pMac, &frm,
1377 pFrame + sizeof( tSirMacMgmtHdr ),
1378 nPayload, &nPayload );
1379 if ( DOT11F_FAILED( nStatus ) )
1380 {
1381 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x).\n"),
1382 nStatus );
1383 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1384 ( void* ) pFrame, ( void* ) pPacket );
1385 return; // allocated!
1386 }
1387 else if ( DOT11F_WARNED( nStatus ) )
1388 {
1389 limLog( pMac, LOGW, FL("There were warnings while packing an "
1390 "Association Response (0x%08x).\n") );
1391 }
1392
1393 macAddr = pMacHdr->da;
1394
1395 if (subType == LIM_ASSOC)
1396 limLog(pMac, LOG1,
1397 FL("*** Sending Assoc Resp status %d aid %d to "),
1398 statusCode, aid);
1399 else
1400 limLog(pMac, LOG1,
1401 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1402 statusCode, aid);
1403 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
1404
1405 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
1406#ifdef WLAN_FEATURE_P2P
1407 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1408 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
1409#endif
1410 )
1411 {
1412 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1413 }
1414
1415 /// Queue Association Response frame in high priority WQ
1416 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1417 HAL_TXRX_FRM_802_11_MGMT,
1418 ANI_TXDIR_TODS,
1419 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1420 limTxComplete, pFrame, txFlag );
1421 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1422 {
1423 limLog(pMac, LOGE,
1424 FL("*** Could not Send Re/AssocRsp, retCode=%X ***\n"),
1425 nSirStatus);
1426
1427 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1428 (void *) pFrame, (void *) pPacket );
1429 }
1430
1431 // update the ANI peer station count
1432 //FIXME_PROTECTION : take care of different type of station
1433 // counter inside this function.
1434 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1435
1436} // End limSendAssocRspMgmtFrame.
1437
1438
1439#endif // ANI_PRODUCT_TYPE_AP
1440
1441
1442void
1443limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1444 tANI_U16 statusCode,
1445 tANI_U16 aid,
1446 tSirMacAddr peerMacAddr,
1447 tANI_U8 subType,
1448 tpDphHashNode pSta,tpPESession psessionEntry)
1449{
1450 static tDot11fAssocResponse frm;
1451 tANI_U8 *pFrame, *macAddr;
1452 tpSirMacMgmtHdr pMacHdr;
1453 tSirRetStatus nSirStatus;
1454 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1455 tHalBitVal qosMode, wmeMode;
1456 tANI_U32 nPayload, nBytes, nStatus;
1457 void *pPacket;
1458 eHalStatus halstatus;
1459 tUpdateBeaconParams beaconParams;
1460 tANI_U8 txFlag = 0;
1461 tANI_U32 addnIEPresent = false;
1462 tANI_U32 addnIELen=0;
1463 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1464 tpSirAssocReq pAssocReq = NULL;
1465
1466 if(NULL == psessionEntry)
1467 {
1468 return;
1469 }
1470
1471 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
1472
1473 limGetQosMode(psessionEntry, &qosMode);
1474 limGetWmeMode(psessionEntry, &wmeMode);
1475
1476 // An Add TS IE is added only if the AP supports it and the requesting
1477 // STA sent a traffic spec.
1478 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1479
1480 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1481
1482 frm.Status.status = statusCode;
1483
1484 frm.AID.associd = aid | LIM_AID_MASK;
1485
1486 if ( NULL == pSta )
1487 {
1488 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1489 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1490 }
1491 else
1492 {
1493 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1494 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1495 }
1496
1497#ifdef WLAN_SOFTAP_FEATURE
1498 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1499 {
1500 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1501 {
1502 pAssocReq =
1503 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
1504#ifdef WLAN_FEATURE_P2P
1505 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1506 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1507 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1508 }
1509#endif
1510 }
1511 }
1512#endif
1513
1514 if ( NULL != pSta )
1515 {
1516 if ( eHAL_SET == qosMode )
1517 {
1518 if ( pSta->lleEnabled )
1519 {
1520 lleMode = 1;
1521 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1522 {
1523 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1524
1525// FramesToDo:...
1526// if ( fAddTS )
1527// {
1528// tANI_U8 *pAf = pBody;
1529// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1530// tANI_U32 tlen;
1531// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1532// &tlen, bufLen - frameLen);
1533// } // End if on Add TS.
1534 }
1535 } // End if on .11e enabled in 'pSta'.
1536 } // End if on QOS Mode on.
1537
1538 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1539 {
1540 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1541 {
1542
1543#ifdef WLAN_SOFTAP_FEATURE
1544 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
1545#else
1546 PopulateDot11fWMMParams( pMac, &frm.WMMParams );
1547#endif
1548
1549 if ( pSta->wsmEnabled )
1550 {
1551 PopulateDot11fWMMCaps(&frm.WMMCaps );
1552 }
1553 }
1554 }
1555
1556 if ( pSta->aniPeer )
1557 {
1558 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1559 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1560 {
1561 edcaInclude = 1;
1562 }
1563
1564 } // End if on Airgo peer.
1565
1566 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001567 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001569 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001570#ifdef WLAN_SOFTAP_FEATURE
1571 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
1572#else
1573 PopulateDot11fHTInfo( pMac, &frm.HTInfo );
1574#endif
1575 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001576
1577#ifdef WLAN_FEATURE_11AC
1578 if( pSta->mlmStaContext.vhtCapability &&
1579 psessionEntry->vhtCapability )
1580 {
1581 limLog( pMac, LOGW, FL("Populate VHT IEs in Assoc Response\n"));
1582 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1583 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001584 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001585 }
1586#endif
1587
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 } // End if on non-NULL 'pSta'.
1589
1590
1591 palZeroMemory( pMac->hHdd, ( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams) );
1592
1593#ifdef WLAN_SOFTAP_FEATURE
1594 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1595 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1596 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1597 }
1598#endif
1599
1600 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1601 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1602
1603 beaconParams.bssIdx = psessionEntry->bssIdx;
1604
1605 //Send message to HAL about beacon parameter change.
1606 if(beaconParams.paramChangeBitmap)
1607 {
1608 schSetFixedBeaconFields(pMac,psessionEntry);
1609 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1610 }
1611
1612 // Allocate a buffer for this frame:
1613 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1614 if ( DOT11F_FAILED( nStatus ) )
1615 {
1616 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1617 "or an Association Response (0x%08x).\n"),
1618 nStatus );
1619 return;
1620 }
1621 else if ( DOT11F_WARNED( nStatus ) )
1622 {
1623 limLog( pMac, LOGW, FL("There were warnings while calculating"
1624 "the packed size for an Association Re"
1625 "sponse (0x%08x).\n"), nStatus );
1626 }
1627
1628 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1629
1630 if ( pAssocReq != NULL )
1631 {
1632 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1633 &addnIEPresent) != eSIR_SUCCESS)
1634 {
1635 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
1636 return;
1637 }
1638
1639 if (addnIEPresent)
1640 {
1641 //Assoc rsp IE available
1642 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1643 &addnIELen) != eSIR_SUCCESS)
1644 {
1645 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
1646 return;
1647 }
1648
1649 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1650 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1651 {
1652 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1653 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1654 {
1655 nBytes = nBytes + addnIELen;
1656 }
1657 }
1658 }
1659 }
1660
1661 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1662 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1663 ( void** ) &pPacket );
1664 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1665 {
1666 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP.\n"));
1667 return;
1668 }
1669
1670 // Paranoia:
1671 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1672
1673 // Next, we fill out the buffer descriptor:
1674 nSirStatus = limPopulateMacHeader( pMac,
1675 pFrame,
1676 SIR_MAC_MGMT_FRAME,
1677 ( LIM_ASSOC == subType ) ?
1678 SIR_MAC_MGMT_ASSOC_RSP :
1679 SIR_MAC_MGMT_REASSOC_RSP,
1680 peerMacAddr,psessionEntry->selfMacAddr);
1681 if ( eSIR_SUCCESS != nSirStatus )
1682 {
1683 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1684 "tor for an Association Response (%d).\n"),
1685 nSirStatus );
1686 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1687 ( void* ) pFrame, ( void* ) pPacket );
1688 return;
1689 }
1690
1691 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1692
1693 #if 0
1694 cfgLen = SIR_MAC_ADDR_LENGTH;
1695 if ( eSIR_SUCCESS != cfgGetStr( pMac, WNI_CFG_BSSID,
1696 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1697 {
1698 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1699 "e sending an Association Response.\n") );
1700 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1701 return; // allocated!
1702 }
1703 #endif //TO SUPPORT BT-AMP
1704 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1705
1706 nStatus = dot11fPackAssocResponse( pMac, &frm,
1707 pFrame + sizeof( tSirMacMgmtHdr ),
1708 nPayload, &nPayload );
1709 if ( DOT11F_FAILED( nStatus ) )
1710 {
1711 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x).\n"),
1712 nStatus );
1713 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1714 ( void* ) pFrame, ( void* ) pPacket );
1715 return; // allocated!
1716 }
1717 else if ( DOT11F_WARNED( nStatus ) )
1718 {
1719 limLog( pMac, LOGW, FL("There were warnings while packing an "
1720 "Association Response (0x%08x).\n") );
1721 }
1722
1723 macAddr = pMacHdr->da;
1724
1725 if (subType == LIM_ASSOC)
1726 {
1727 PELOG1(limLog(pMac, LOG1,
1728 FL("*** Sending Assoc Resp status %d aid %d to "),
1729 statusCode, aid);)
1730 }
1731 else{
1732 PELOG1(limLog(pMac, LOG1,
1733 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1734 statusCode, aid);)
1735 }
1736 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1737
1738 if ( addnIEPresent )
1739 {
1740 if (palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson43971f52012-07-17 12:26:56 -07001741 &addIE[0], addnIELen ) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 {
1743 limLog(pMac, LOGP, FL("Additional Assoc IEs request failed while Appending: %x\n"),halstatus);
1744 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1745 ( void* ) pFrame, ( void* ) pPacket );
1746 return;
1747 }
1748 }
1749
1750 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
1751#ifdef WLAN_FEATURE_P2P
1752 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1753 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
1754#endif
1755 )
1756 {
1757 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1758 }
1759
1760 /// Queue Association Response frame in high priority WQ
1761 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1762 HAL_TXRX_FRM_802_11_MGMT,
1763 ANI_TXDIR_TODS,
1764 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1765 limTxComplete, pFrame, txFlag );
1766 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1767 {
1768 limLog(pMac, LOGE,
1769 FL("*** Could not Send Re/AssocRsp, retCode=%X ***\n"),
1770 nSirStatus);
1771
1772 //Pkt will be freed up by the callback
1773 }
1774
1775 // update the ANI peer station count
1776 //FIXME_PROTECTION : take care of different type of station
1777 // counter inside this function.
1778 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1779
1780} // End limSendAssocRspMgmtFrame.
1781
1782
1783
1784void
1785limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1786 tSirMacAddr peer,
1787 tANI_U16 nStatusCode,
1788 tSirAddtsReqInfo *pAddTS,
1789 tSirMacScheduleIE *pSchedule,
1790 tpPESession psessionEntry)
1791{
1792 tANI_U8 *pFrame;
1793 tpSirMacMgmtHdr pMacHdr;
1794 tDot11fAddTSResponse AddTSRsp;
1795 tDot11fWMMAddTSResponse WMMAddTSRsp;
1796 tSirRetStatus nSirStatus;
1797 tANI_U32 i, nBytes, nPayload, nStatus;
1798 void *pPacket;
1799 eHalStatus halstatus;
1800 tANI_U8 txFlag = 0;
1801
1802 if(NULL == psessionEntry)
1803 {
1804 return;
1805 }
1806
1807 if ( ! pAddTS->wmeTspecPresent )
1808 {
1809 palZeroMemory( pMac->hHdd, ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ) );
1810
1811 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1812 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1813 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1814 AddTSRsp.Status.status = nStatusCode;
1815
1816 // The TsDelay information element is only filled in for a specific
1817 // status code:
1818 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1819 {
1820 if ( pAddTS->wsmTspecPresent )
1821 {
1822 AddTSRsp.WMMTSDelay.version = 1;
1823 AddTSRsp.WMMTSDelay.delay = 10;
1824 AddTSRsp.WMMTSDelay.present = 1;
1825 }
1826 else
1827 {
1828 AddTSRsp.TSDelay.delay = 10;
1829 AddTSRsp.TSDelay.present = 1;
1830 }
1831 }
1832
1833 if ( pAddTS->wsmTspecPresent )
1834 {
1835 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1836 }
1837 else
1838 {
1839 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1840 }
1841
1842 if ( pAddTS->wsmTspecPresent )
1843 {
1844 AddTSRsp.num_WMMTCLAS = 0;
1845 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1846 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1847 {
1848 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1849 &AddTSRsp.TCLAS[i] );
1850 }
1851 }
1852 else
1853 {
1854 AddTSRsp.num_TCLAS = 0;
1855 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1856 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1857 {
1858 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1859 &AddTSRsp.WMMTCLAS[i] );
1860 }
1861 }
1862
1863 if ( pAddTS->tclasProcPresent )
1864 {
1865 if ( pAddTS->wsmTspecPresent )
1866 {
1867 AddTSRsp.WMMTCLASPROC.version = 1;
1868 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1869 AddTSRsp.WMMTCLASPROC.present = 1;
1870 }
1871 else
1872 {
1873 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1874 AddTSRsp.TCLASSPROC.present = 1;
1875 }
1876 }
1877
1878 // schedule element is included only if requested in the tspec and we are
1879 // using hcca (or both edca and hcca)
1880 // 11e-D8.0 is inconsistent on whether the schedule element is included
1881 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1882 // pg 46, line 17-18 says something else. So just include it and let the
1883 // sta figure it out
1884 if ((pSchedule != NULL) &&
1885 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1886 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1887 {
1888 if ( pAddTS->wsmTspecPresent )
1889 {
1890 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1891 }
1892 else
1893 {
1894 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1895 }
1896 }
1897
1898 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1899 if ( DOT11F_FAILED( nStatus ) )
1900 {
1901 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
1902 "ze for an Add TS Response (0x%08x).\n"),
1903 nStatus );
1904 // We'll fall back on the worst case scenario:
1905 nPayload = sizeof( tDot11fAddTSResponse );
1906 }
1907 else if ( DOT11F_WARNED( nStatus ) )
1908 {
1909 limLog( pMac, LOGW, FL("There were warnings while calcula"
1910 "tingthe packed size for an Add TS"
1911 " Response (0x%08x).\n"), nStatus );
1912 }
1913 }
1914 else
1915 {
1916 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ) );
1917
1918 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1919 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1920 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1921 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1922
1923 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1924
1925 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1926 if ( DOT11F_FAILED( nStatus ) )
1927 {
1928 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
1929 "ze for a WMM Add TS Response (0x%08x).\n"),
1930 nStatus );
1931 // We'll fall back on the worst case scenario:
1932 nPayload = sizeof( tDot11fWMMAddTSResponse );
1933 }
1934 else if ( DOT11F_WARNED( nStatus ) )
1935 {
1936 limLog( pMac, LOGW, FL("There were warnings while calcula"
1937 "tingthe packed size for a WMM Add"
1938 "TS Response (0x%08x).\n"), nStatus );
1939 }
1940 }
1941
1942 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1943
1944 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1945 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1946 {
1947 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
1948 "d TS Response.\n"), nBytes );
1949 return;
1950 }
1951
1952 // Paranoia:
1953 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1954
1955 // Next, we fill out the buffer descriptor:
1956 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1957 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1958 if ( eSIR_SUCCESS != nSirStatus )
1959 {
1960 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1961 "tor for an Add TS Response (%d).\n"),
1962 nSirStatus );
1963 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1964 return; // allocated!
1965 }
1966
1967 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1968
1969
1970 #if 0
1971 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1972 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1973 {
1974 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1975 "e sending an Add TS Response.\n") );
1976 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1977 return; // allocated!
1978 }
1979 #endif //TO SUPPORT BT-AMP
1980 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1981
1982 // That done, pack the struct:
1983 if ( ! pAddTS->wmeTspecPresent )
1984 {
1985 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1986 pFrame + sizeof( tSirMacMgmtHdr ),
1987 nPayload, &nPayload );
1988 if ( DOT11F_FAILED( nStatus ) )
1989 {
1990 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
1991 "(0x%08x).\n"),
1992 nStatus );
1993 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1994 return;
1995 }
1996 else if ( DOT11F_WARNED( nStatus ) )
1997 {
1998 limLog( pMac, LOGW, FL("There were warnings while packing"
1999 "an Add TS Response (0x%08x).\n") );
2000 }
2001 }
2002 else
2003 {
2004 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
2005 pFrame + sizeof( tSirMacMgmtHdr ),
2006 nPayload, &nPayload );
2007 if ( DOT11F_FAILED( nStatus ) )
2008 {
2009 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
2010 "(0x%08x).\n"),
2011 nStatus );
2012 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2013 return;
2014 }
2015 else if ( DOT11F_WARNED( nStatus ) )
2016 {
2017 limLog( pMac, LOGW, FL("There were warnings while packing"
2018 "a WMM Add TS Response (0x%08x).\n") );
2019 }
2020 }
2021
2022 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
2023 nStatusCode );
2024 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
2025
2026 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
2027#ifdef WLAN_FEATURE_P2P
2028 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2029 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
2030#endif
2031 )
2032 {
2033 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2034 }
2035
2036 // Queue the frame in high priority WQ:
2037 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2038 HAL_TXRX_FRM_802_11_MGMT,
2039 ANI_TXDIR_TODS,
2040 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2041 limTxComplete, pFrame, txFlag );
2042 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2043 {
2044 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!\n"),
2045 nSirStatus );
2046 //Pkt will be freed up by the callback
2047 }
2048
2049} // End limSendAddtsRspActionFrame.
2050
2051void
2052limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2053 tSirMacAddr peer,
2054 tANI_U8 wmmTspecPresent,
2055 tSirMacTSInfo *pTsinfo,
2056 tSirMacTspecIE *pTspecIe,
2057 tpPESession psessionEntry)
2058{
2059 tANI_U8 *pFrame;
2060 tpSirMacMgmtHdr pMacHdr;
2061 tDot11fDelTS DelTS;
2062 tDot11fWMMDelTS WMMDelTS;
2063 tSirRetStatus nSirStatus;
2064 tANI_U32 nBytes, nPayload, nStatus;
2065 void *pPacket;
2066 eHalStatus halstatus;
2067 tANI_U8 txFlag = 0;
2068
2069 if(NULL == psessionEntry)
2070 {
2071 return;
2072 }
2073
2074 if ( ! wmmTspecPresent )
2075 {
2076 palZeroMemory( pMac->hHdd, ( tANI_U8* )&DelTS, sizeof( DelTS ) );
2077
2078 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2079 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2080 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2081
2082 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2083 if ( DOT11F_FAILED( nStatus ) )
2084 {
2085 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
2086 "ze for a Del TS (0x%08x).\n"),
2087 nStatus );
2088 // We'll fall back on the worst case scenario:
2089 nPayload = sizeof( tDot11fDelTS );
2090 }
2091 else if ( DOT11F_WARNED( nStatus ) )
2092 {
2093 limLog( pMac, LOGW, FL("There were warnings while calcula"
2094 "ting the packed size for a Del TS"
2095 " (0x%08x).\n"), nStatus );
2096 }
2097 }
2098 else
2099 {
2100 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ) );
2101
2102 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2103 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2104 WMMDelTS.DialogToken.token = 0;
2105 WMMDelTS.StatusCode.statusCode = 0;
2106 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2107 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2108 if ( DOT11F_FAILED( nStatus ) )
2109 {
2110 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
2111 "ze for a WMM Del TS (0x%08x).\n"),
2112 nStatus );
2113 // We'll fall back on the worst case scenario:
2114 nPayload = sizeof( tDot11fDelTS );
2115 }
2116 else if ( DOT11F_WARNED( nStatus ) )
2117 {
2118 limLog( pMac, LOGW, FL("There were warnings while calcula"
2119 "ting the packed size for a WMM De"
2120 "l TS (0x%08x).\n"), nStatus );
2121 }
2122 }
2123
2124 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2125
2126 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2127 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2128 {
2129 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
2130 "d TS Response.\n"), nBytes );
2131 return;
2132 }
2133
2134 // Paranoia:
2135 palZeroMemory( pMac->hHdd, pFrame, nBytes );
2136
2137 // Next, we fill out the buffer descriptor:
2138 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2139 SIR_MAC_MGMT_ACTION, peer,
2140 psessionEntry->selfMacAddr);
2141 if ( eSIR_SUCCESS != nSirStatus )
2142 {
2143 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
2144 "tor for an Add TS Response (%d).\n"),
2145 nSirStatus );
2146 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2147 return; // allocated!
2148 }
2149
2150 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2151
2152 #if 0
2153
2154 cfgLen = SIR_MAC_ADDR_LENGTH;
2155 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2156 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2157 {
2158 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
2159 "e sending an Add TS Response.\n") );
2160 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2161 return; // allocated!
2162 }
2163 #endif //TO SUPPORT BT-AMP
2164 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2165
2166 // That done, pack the struct:
2167 if ( !wmmTspecPresent )
2168 {
2169 nStatus = dot11fPackDelTS( pMac, &DelTS,
2170 pFrame + sizeof( tSirMacMgmtHdr ),
2171 nPayload, &nPayload );
2172 if ( DOT11F_FAILED( nStatus ) )
2173 {
2174 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x).\n"),
2175 nStatus );
2176 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2177 return; // allocated!
2178 }
2179 else if ( DOT11F_WARNED( nStatus ) )
2180 {
2181 limLog( pMac, LOGW, FL("There were warnings while packing"
2182 "a Del TS frame (0x%08x).\n") );
2183 }
2184 }
2185 else
2186 {
2187 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2188 pFrame + sizeof( tSirMacMgmtHdr ),
2189 nPayload, &nPayload );
2190 if ( DOT11F_FAILED( nStatus ) )
2191 {
2192 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x).\n"),
2193 nStatus );
2194 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2195 return; // allocated!
2196 }
2197 else if ( DOT11F_WARNED( nStatus ) )
2198 {
2199 limLog( pMac, LOGW, FL("There were warnings while packing"
2200 "a WMM Del TS frame (0x%08x).\n") );
2201 }
2202 }
2203
2204 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2205 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
2206
2207 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
2208#ifdef WLAN_FEATURE_P2P
2209 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2210 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
2211#endif
2212 )
2213 {
2214 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2215 }
2216
2217 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2218 HAL_TXRX_FRM_802_11_MGMT,
2219 ANI_TXDIR_TODS,
2220 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2221 limTxComplete, pFrame, txFlag );
2222 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2223 {
2224 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!\n"),
2225 nSirStatus );
2226 //Pkt will be freed up by the callback
2227 }
2228
2229} // End limSendDeltsReqActionFrame.
2230
2231void
2232limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2233 tLimMlmAssocReq *pMlmAssocReq,
2234 tpPESession psessionEntry)
2235{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002236 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 tANI_U16 caps;
2238 tANI_U8 *pFrame;
2239 tSirRetStatus nSirStatus;
2240 tLimMlmAssocCnf mlmAssocCnf;
2241 tANI_U32 nBytes, nPayload, nStatus;
2242 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2243 void *pPacket;
2244 eHalStatus halstatus;
2245 tANI_U16 nAddIELen;
2246 tANI_U8 *pAddIE;
2247 tANI_U8 *wpsIe = NULL;
2248#if defined WLAN_FEATURE_VOWIFI
2249 tANI_U8 PowerCapsPopulated = FALSE;
2250#endif
2251 tANI_U8 txFlag = 0;
2252
2253 if(NULL == psessionEntry)
2254 {
2255 return;
2256 }
2257
2258 if(NULL == psessionEntry->pLimJoinReq)
2259 {
2260 return;
2261 }
2262
2263 /* check this early to avoid unncessary operation */
2264 if(NULL == psessionEntry->pLimJoinReq)
2265 {
2266 return;
2267 }
2268 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2269 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2270
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002271 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
2272 (void **)&pFrm, sizeof(tDot11fAssocRequest)))
2273 {
2274 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limSendAssocReqMgmtFrame\n") );
2275 return;
2276 }
2277
2278
2279 palZeroMemory( pMac->hHdd, ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002280
2281 caps = pMlmAssocReq->capabilityInfo;
2282 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2283 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2284#if defined(FEATURE_WLAN_WAPI)
2285 /* CR: 262463 :
2286 According to WAPI standard:
2287 7.3.1.4 Capability Information field
2288 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2289 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2290 Reassociation management frames. */
2291 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2292 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2293#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002294 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002295
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002296 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2297 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002299 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002300
2301 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2302 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2303
2304 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2305 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2306
2307 // We prefer .11e asociations:
2308 if ( fQosEnabled ) fWmeEnabled = false;
2309
2310 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2311 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2312
2313 if ( psessionEntry->lim11hEnable &&
2314 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2315 {
2316#if defined WLAN_FEATURE_VOWIFI
2317 PowerCapsPopulated = TRUE;
2318
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002319 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002320#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002321 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002322
2323 }
2324
2325#if defined WLAN_FEATURE_VOWIFI
2326 if( pMac->rrm.rrmPEContext.rrmEnable &&
2327 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2328 {
2329 if (PowerCapsPopulated == FALSE)
2330 {
2331 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002332 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002333 }
2334 }
2335#endif
2336
2337 if ( fQosEnabled &&
2338 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002339 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002340
2341 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002342 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002343
2344#if defined WLAN_FEATURE_VOWIFI
2345 if( pMac->rrm.rrmPEContext.rrmEnable &&
2346 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2347 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002348 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 }
2350#endif
2351 // The join request *should* contain zero or one of the WPA and RSN
2352 // IEs. The payload send along with the request is a
2353 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2354
2355 // typedef struct sSirRSNie
2356 // {
2357 // tANI_U16 length;
2358 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2359 // } tSirRSNie, *tpSirRSNie;
2360
2361 // So, we should be able to make the following two calls harmlessly,
2362 // since they do nothing if they don't find the given IE in the
2363 // bytestream with which they're provided.
2364
2365 // The net effect of this will be to faithfully transmit whatever
2366 // security IE is in the join request.
2367
2368 // *However*, if we're associating for the purpose of WPS
2369 // enrollment, and we've been configured to indicate that by
2370 // eliding the WPA or RSN IE, we just skip this:
2371 if( nAddIELen && pAddIE )
2372 {
2373 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2374 }
2375 if ( NULL == wpsIe )
2376 {
2377 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002378 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002380 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002381#if defined(FEATURE_WLAN_WAPI)
2382 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002383 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002384#endif // defined(FEATURE_WLAN_WAPI)
2385 }
2386
2387 // include WME EDCA IE as well
2388 if ( fWmeEnabled )
2389 {
2390 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2391 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002392 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 }
2394
2395 if ( fWsmEnabled &&
2396 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2397 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002398 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 }
2400 }
2401
2402 //Populate HT IEs, when operating in 11n or Taurus modes AND
2403 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002404 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 pMac->lim.htCapabilityPresentInBeacon)
2406 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002407 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002408#ifdef DISABLE_GF_FOR_INTEROP
2409
2410 /*
2411 * To resolve the interop problem with Broadcom AP,
2412 * where TQ STA could not pass traffic with GF enabled,
2413 * TQ STA will do Greenfield only with TQ AP, for
2414 * everybody else it will be turned off.
2415 */
2416
2417 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2418 {
2419 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002420 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 }
2422#endif
2423
2424 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002425#ifdef WLAN_FEATURE_11AC
2426 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002427 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002428 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002429 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002430 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2431 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002432 }
2433#endif
2434
Jeff Johnson295189b2012-06-20 16:38:30 -07002435
2436#if defined WLAN_FEATURE_VOWIFI_11R
2437 if (psessionEntry->pLimJoinReq->is11Rconnection)
2438 {
2439#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002440 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2442 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2443 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2444#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002445 PopulateMDIE( pMac, &pFrm->MobilityDomain, psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 }
2447 else
2448 {
2449 // No 11r IEs dont send any MDIE
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002450 limLog( pMac, LOG1, FL("mdie not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 }
2452#endif
2453
2454#ifdef FEATURE_WLAN_CCX
2455 // For CCX Associations fill the CCX IEs
2456 if (psessionEntry->isCCXconnection)
2457 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002458 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
2459 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 }
2461#endif
2462
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002463 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 if ( DOT11F_FAILED( nStatus ) )
2465 {
2466 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
2467 "or an Association Request (0x%08x).\n"),
2468 nStatus );
2469 // We'll fall back on the worst case scenario:
2470 nPayload = sizeof( tDot11fAssocRequest );
2471 }
2472 else if ( DOT11F_WARNED( nStatus ) )
2473 {
2474 limLog( pMac, LOGW, FL("There were warnings while calculating"
2475 "the packed size for an Association Re "
2476 "quest(0x%08x).\n"), nStatus );
2477 }
2478
2479 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2480
2481 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2482 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2483 ( void** ) &pPacket );
2484 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2485 {
2486 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
2487 "sociation Request.\n"), nBytes );
2488
2489 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002490 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002491
2492
2493 /* Update PE session id*/
2494 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2495
2496 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2497
2498 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2499 ( void* ) pFrame, ( void* ) pPacket );
2500
2501 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2502 ( tANI_U32* ) &mlmAssocCnf);
2503
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002504 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 return;
2506 }
2507
2508 // Paranoia:
2509 palZeroMemory( pMac->hHdd, pFrame, nBytes );
2510
2511 // Next, we fill out the buffer descriptor:
2512 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2513 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2514 if ( eSIR_SUCCESS != nSirStatus )
2515 {
2516 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
2517 "tor for an Association Request (%d).\n"),
2518 nSirStatus );
2519 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002520 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 return;
2522 }
2523
2524
2525 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002526 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002527 sizeof(tSirMacMgmtHdr),
2528 nPayload, &nPayload );
2529 if ( DOT11F_FAILED( nStatus ) )
2530 {
2531 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
2532 "8x).\n"),
2533 nStatus );
2534 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2535 ( void* ) pFrame, ( void* ) pPacket );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002536 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 return;
2538 }
2539 else if ( DOT11F_WARNED( nStatus ) )
2540 {
2541 limLog( pMac, LOGW, FL("There were warnings while packing a P"
2542 "robe Response (0x%08x).\n") );
2543 }
2544
2545 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
2546 "to \n"),
2547 nBytes );)
2548 // limPrintMacAddr( pMac, bssid, LOG1 );
2549
2550 if( psessionEntry->assocReq != NULL )
2551 {
2552 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2553 psessionEntry->assocReq = NULL;
2554 }
2555
2556 if( nAddIELen )
2557 {
2558 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2559 pAddIE,
2560 nAddIELen );
2561 nPayload += nAddIELen;
2562 }
2563
Jeff Johnson43971f52012-07-17 12:26:56 -07002564 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2565 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 {
2567 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2568 }
2569 else
2570 {
2571 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2572 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2573 psessionEntry->assocReqLen = nPayload;
2574 }
2575
2576 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
2577#ifdef WLAN_FEATURE_P2P
2578 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2579 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
2580#endif
2581 )
2582 {
2583 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2584 }
2585
2586 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2587 HAL_TXRX_FRM_802_11_MGMT,
2588 ANI_TXDIR_TODS,
2589 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2590 limTxComplete, pFrame, txFlag );
2591 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2592 {
2593 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!\n"),
2594 halstatus );
2595 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002596 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 return;
2598 }
2599
2600 // Free up buffer allocated for mlmAssocReq
2601 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmAssocReq );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002602 palFreeMemory(pMac->hHdd, pFrm);
2603 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002604} // End limSendAssocReqMgmtFrame
2605
2606
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002607#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002608/*------------------------------------------------------------------------------------
2609 *
2610 * Send Reassoc Req with FTIEs.
2611 *
2612 *-----------------------------------------------------------------------------------
2613 */
2614void
2615limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2616 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2617{
2618 static tDot11fReAssocRequest frm;
2619 tANI_U16 caps;
2620 tANI_U8 *pFrame;
2621 tSirRetStatus nSirStatus;
2622 tANI_U32 nBytes, nPayload, nStatus;
2623 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2624 void *pPacket;
2625 eHalStatus halstatus;
2626#if defined WLAN_FEATURE_VOWIFI
2627 tANI_U8 PowerCapsPopulated = FALSE;
2628#endif
2629 tANI_U16 ft_ies_length = 0;
2630 tANI_U8 *pBody;
2631 tANI_U16 nAddIELen;
2632 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002633#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 tANI_U8 *wpsIe = NULL;
2635#endif
2636 tANI_U8 txFlag = 0;
2637
2638 if (NULL == psessionEntry)
2639 {
2640 return;
2641 }
2642
2643#if defined WLAN_FEATURE_VOWIFI_11R
2644 if (psessionEntry->is11Rconnection)
2645 {
2646 if (pMac->ft.ftSmeContext.reassoc_ft_ies_length == 0)
2647 {
2648 return;
2649 }
2650 }
2651#endif
2652
2653 /* check this early to avoid unncessary operation */
2654 if(NULL == psessionEntry->pLimReAssocReq)
2655 {
2656 return;
2657 }
2658 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2659 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2660 limLog( pMac, LOGE, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2661 "state (%d).\n"), psessionEntry->limMlmState);
2662
2663 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
2664
2665 caps = pMlmReassocReq->capabilityInfo;
2666 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2667 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2668#if defined(FEATURE_WLAN_WAPI)
2669 /* CR: 262463 :
2670 According to WAPI standard:
2671 7.3.1.4 Capability Information field
2672 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2673 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2674 Reassociation management frames. */
2675 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2676 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2677#endif
2678 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2679
2680 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2681
2682 // Get the old bssid of the older AP.
2683 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
2684 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2685
2686 PopulateDot11fSSID2( pMac, &frm.SSID );
2687 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2688 &frm.SuppRates,psessionEntry);
2689
2690 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2691 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2692
2693 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2694 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2695
2696 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2697 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2698
2699 if ( psessionEntry->lim11hEnable &&
2700 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2701 {
2702#if defined WLAN_FEATURE_VOWIFI
2703 PowerCapsPopulated = TRUE;
2704
2705 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2706 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2707#endif
2708 }
2709
2710#if defined WLAN_FEATURE_VOWIFI
2711 if( pMac->rrm.rrmPEContext.rrmEnable &&
2712 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2713 {
2714 if (PowerCapsPopulated == FALSE)
2715 {
2716 PowerCapsPopulated = TRUE;
2717 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2718 }
2719 }
2720#endif
2721
2722 if ( fQosEnabled &&
2723 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2724 {
2725 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2726 }
2727
2728 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2729 &frm.ExtSuppRates, psessionEntry );
2730
2731#if defined WLAN_FEATURE_VOWIFI
2732 if( pMac->rrm.rrmPEContext.rrmEnable &&
2733 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2734 {
2735 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2736 }
2737#endif
2738
2739 // Ideally this should be enabled for 11r also. But 11r does
2740 // not follow the usual norm of using the Opaque object
2741 // for rsnie and fties. Instead we just add
2742 // the rsnie and fties at the end of the pack routine for 11r.
2743 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002744#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 //
2746 // The join request *should* contain zero or one of the WPA and RSN
2747 // IEs. The payload send along with the request is a
2748 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2749
2750 // typedef struct sSirRSNie
2751 // {
2752 // tANI_U16 length;
2753 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2754 // } tSirRSNie, *tpSirRSNie;
2755
2756 // So, we should be able to make the following two calls harmlessly,
2757 // since they do nothing if they don't find the given IE in the
2758 // bytestream with which they're provided.
2759
2760 // The net effect of this will be to faithfully transmit whatever
2761 // security IE is in the join request.
2762
2763 // *However*, if we're associating for the purpose of WPS
2764 // enrollment, and we've been configured to indicate that by
2765 // eliding the WPA or RSN IE, we just skip this:
2766 if (!psessionEntry->is11Rconnection)
2767 {
2768 if( nAddIELen && pAddIE )
2769 {
2770 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2771 }
2772 if ( NULL == wpsIe )
2773 {
2774 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2775 &frm.RSNOpaque );
2776 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2777 &frm.WPAOpaque );
2778 }
2779
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002780#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 if(psessionEntry->pLimReAssocReq->cckmIE.length)
2782 {
2783 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2784 &frm.CCXCckmOpaque );
2785 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002786#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 }
2788
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002789#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 // For CCX Associations fill the CCX IEs
2791 if (psessionEntry->isCCXconnection)
2792 {
2793 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
2794 PopulateDot11fCCXVersion(&frm.CCXVersion);
2795 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002796#endif //FEATURE_WLAN_CCX
2797#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002798
2799 // include WME EDCA IE as well
2800 if ( fWmeEnabled )
2801 {
2802 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2803 {
2804 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2805 }
2806
2807 if ( fWsmEnabled &&
2808 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2809 {
2810 PopulateDot11fWMMCaps( &frm.WMMCaps );
2811 }
2812#ifdef FEATURE_WLAN_CCX
2813 if (psessionEntry->isCCXconnection)
2814 {
2815 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2816
2817 // Populate the TSRS IE if TSPEC is included in the reassoc request
2818 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2819 {
2820 tANI_U32 phyMode;
2821 tSirMacCCXTSRSIE tsrsIE;
2822 limGetPhyMode(pMac, &phyMode, psessionEntry);
2823
2824 tsrsIE.tsid = 0;
2825 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2826 {
2827 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2828 }
2829 else
2830 {
2831 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2832 }
2833 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2834 }
2835 }
2836#endif
2837 }
2838
Jeff Johnsone7245742012-09-05 17:12:55 -07002839 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 pMac->lim.htCapabilityPresentInBeacon)
2841 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002842 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002843 }
2844
2845 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2846 if ( DOT11F_FAILED( nStatus ) )
2847 {
2848 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
2849 "or a Re-Association Request (0x%08x).\n"),
2850 nStatus );
2851 // We'll fall back on the worst case scenario:
2852 nPayload = sizeof( tDot11fReAssocRequest );
2853 }
2854 else if ( DOT11F_WARNED( nStatus ) )
2855 {
2856 limLog( pMac, LOGW, FL("There were warnings while calculating"
2857 "the packed size for a Re-Association Re "
2858 "quest(0x%08x).\n"), nStatus );
2859 }
2860
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002861 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002862
2863#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
2864 limLog( pMac, LOGE, FL("FT IE Reassoc Req (%d).\n"),
2865 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2866#endif
2867
2868#if defined WLAN_FEATURE_VOWIFI_11R
2869 if (psessionEntry->is11Rconnection)
2870 {
2871 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2872 }
2873#endif
2874
2875 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2876 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2877 ( void** ) &pPacket );
2878 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2879 {
2880 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002881 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
2883 "sociation Request.\n"), nBytes );
2884 goto end;
2885 }
2886
2887 // Paranoia:
2888 palZeroMemory( pMac->hHdd, pFrame, nBytes + ft_ies_length);
2889
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002890#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOGE);
2892#endif
2893 // Next, we fill out the buffer descriptor:
2894 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2895 SIR_MAC_MGMT_REASSOC_REQ,
2896 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2897 if ( eSIR_SUCCESS != nSirStatus )
2898 {
2899 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
2900 "tor for an Association Request (%d).\n"),
2901 nSirStatus );
2902 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2903 goto end;
2904 }
2905
2906
2907 // That done, pack the ReAssoc Request:
2908 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2909 sizeof(tSirMacMgmtHdr),
2910 nPayload, &nPayload );
2911 if ( DOT11F_FAILED( nStatus ) )
2912 {
2913 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
2914 "st (0x%08x).\n"),
2915 nStatus );
2916 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2917 goto end;
2918 }
2919 else if ( DOT11F_WARNED( nStatus ) )
2920 {
2921 limLog( pMac, LOGW, FL("There were warnings while packing a R"
2922 "e-Association Request (0x%08x).\n") );
2923 }
2924
2925 PELOG3(limLog( pMac, LOG3,
2926 FL("*** Sending Re-Association Request length %d %d to \n"),
2927 nBytes, nPayload );)
2928 if( psessionEntry->assocReq != NULL )
2929 {
2930 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2931 psessionEntry->assocReq = NULL;
2932 }
2933
2934 if( nAddIELen )
2935 {
2936 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2937 pAddIE,
2938 nAddIELen );
2939 nPayload += nAddIELen;
2940 }
2941
Jeff Johnson43971f52012-07-17 12:26:56 -07002942 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2943 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 {
2945 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002946 }
2947 else
2948 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2950 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2951 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002953
2954 if (psessionEntry->is11Rconnection)
2955 {
2956 {
2957 int i = 0;
2958
2959 pBody = pFrame + nBytes;
2960 for (i=0; i<ft_ies_length; i++)
2961 {
2962 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2963 pBody++;
2964 }
2965 }
2966 }
2967
2968#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
2969 PELOGE(limLog(pMac, LOGE, FL("Re-assoc Req Frame is: "));
2970 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
2971 (tANI_U8 *)pFrame,
2972 (nBytes + ft_ies_length));)
2973#endif
2974
2975
2976 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
2977#ifdef WLAN_FEATURE_P2P
2978 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2979 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
2980#endif
2981 )
2982 {
2983 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2984 }
2985
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002986 if( NULL != psessionEntry->assocReq )
2987 {
2988 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2989 psessionEntry->assocReq = NULL;
2990 }
2991
2992 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2993 (ft_ies_length))) != eHAL_STATUS_SUCCESS )
2994 {
2995 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2996 }
2997 else
2998 {
2999 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3000 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3001 (ft_ies_length));
3002 psessionEntry->assocReqLen = (ft_ies_length);
3003 }
3004
3005
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3007 HAL_TXRX_FRM_802_11_MGMT,
3008 ANI_TXDIR_TODS,
3009 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3010 limTxComplete, pFrame, txFlag );
3011 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3012 {
3013 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
3014 "(%X)!\n"),
3015 nSirStatus );
3016 //Pkt will be freed up by the callback
3017 goto end;
3018 }
3019
3020end:
3021 // Free up buffer allocated for mlmAssocReq
3022 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3023 psessionEntry->pLimMlmReassocReq = NULL;
3024
3025}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003026
3027void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3028 tLimMlmReassocReq *pMlmReassocReq,
3029 tpPESession psessionEntry)
3030{
3031 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3032 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3033 if(NULL == pTmpMlmReassocReq)
3034 {
3035 if ( !HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pTmpMlmReassocReq, sizeof(tLimMlmReassocReq))) ) goto end;
3036 palZeroMemory(pMac->hHdd, pTmpMlmReassocReq, sizeof(tLimMlmReassocReq));
3037 palCopyMemory( pMac->hHdd, pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
3038 }
3039
3040 // Prepare and send Reassociation request frame
3041 // start reassoc timer.
3042 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3043 // Start reassociation failure timer
3044 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0, eLIM_REASSOC_FAIL_TIMER));
3045 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3046 != TX_SUCCESS)
3047 {
3048 // Could not start reassoc failure timer.
3049 // Log error
3050 limLog(pMac, LOGP,
3051 FL("could not start Reassociation failure timer\n"));
3052 // Return Reassoc confirm with
3053 // Resources Unavailable
3054 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3055 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3056 goto end;
3057 }
3058
3059 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3060 return;
3061
3062end:
3063 // Free up buffer allocated for reassocReq
3064 if (pMlmReassocReq != NULL)
3065 {
3066 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
3067 pMlmReassocReq = NULL;
3068 }
3069 if (pTmpMlmReassocReq != NULL)
3070 {
3071 palFreeMemory( pMac->hHdd, (tANI_U8 *) pTmpMlmReassocReq);
3072 pTmpMlmReassocReq = NULL;
3073 }
3074 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3075 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3076 /* Update PE sessio Id*/
3077 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3078
3079 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3080}
3081
Jeff Johnson295189b2012-06-20 16:38:30 -07003082#endif /* WLAN_FEATURE_VOWIFI_11R */
3083
3084
3085void
3086limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3087 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3088{
3089 static tDot11fReAssocRequest frm;
3090 tANI_U16 caps;
3091 tANI_U8 *pFrame;
3092 tSirRetStatus nSirStatus;
3093 tANI_U32 nBytes, nPayload, nStatus;
3094 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3095 void *pPacket;
3096 eHalStatus halstatus;
3097 tANI_U16 nAddIELen;
3098 tANI_U8 *pAddIE;
3099 tANI_U8 *wpsIe = NULL;
3100 tANI_U8 txFlag = 0;
3101#if defined WLAN_FEATURE_VOWIFI
3102 tANI_U8 PowerCapsPopulated = FALSE;
3103#endif
3104
3105 if(NULL == psessionEntry)
3106 {
3107 return;
3108 }
3109
3110 /* check this early to avoid unncessary operation */
3111 if(NULL == psessionEntry->pLimReAssocReq)
3112 {
3113 return;
3114 }
3115 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3116 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3117
3118 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3119
3120 caps = pMlmReassocReq->capabilityInfo;
3121 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3122 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3123#if defined(FEATURE_WLAN_WAPI)
3124 /* CR: 262463 :
3125 According to WAPI standard:
3126 7.3.1.4 Capability Information field
3127 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3128 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3129 Reassociation management frames. */
3130 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3131 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3132#endif
3133 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3134
3135 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3136
3137 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
3138 ( tANI_U8* )psessionEntry->bssId, 6 );
3139
3140 PopulateDot11fSSID2( pMac, &frm.SSID );
3141 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3142 &frm.SuppRates,psessionEntry);
3143
3144 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3145 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3146
3147 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3148 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3149
3150 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3151 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3152
3153
3154 if ( psessionEntry->lim11hEnable &&
3155 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3156 {
3157#if defined WLAN_FEATURE_VOWIFI
3158 PowerCapsPopulated = TRUE;
3159 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3160 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3161#endif
3162 }
3163
3164#if defined WLAN_FEATURE_VOWIFI
3165 if( pMac->rrm.rrmPEContext.rrmEnable &&
3166 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3167 {
3168 if (PowerCapsPopulated == FALSE)
3169 {
3170 PowerCapsPopulated = TRUE;
3171 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3172 }
3173 }
3174#endif
3175
3176 if ( fQosEnabled &&
3177 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3178 {
3179 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3180 }
3181
3182 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3183 &frm.ExtSuppRates, psessionEntry );
3184
3185#if defined WLAN_FEATURE_VOWIFI
3186 if( pMac->rrm.rrmPEContext.rrmEnable &&
3187 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3188 {
3189 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3190 }
3191#endif
3192 // The join request *should* contain zero or one of the WPA and RSN
3193 // IEs. The payload send along with the request is a
3194 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3195
3196 // typedef struct sSirRSNie
3197 // {
3198 // tANI_U16 length;
3199 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3200 // } tSirRSNie, *tpSirRSNie;
3201
3202 // So, we should be able to make the following two calls harmlessly,
3203 // since they do nothing if they don't find the given IE in the
3204 // bytestream with which they're provided.
3205
3206 // The net effect of this will be to faithfully transmit whatever
3207 // security IE is in the join request.
3208
3209 // *However*, if we're associating for the purpose of WPS
3210 // enrollment, and we've been configured to indicate that by
3211 // eliding the WPA or RSN IE, we just skip this:
3212 if( nAddIELen && pAddIE )
3213 {
3214 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3215 }
3216 if ( NULL == wpsIe )
3217 {
3218 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3219 &frm.RSNOpaque );
3220 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3221 &frm.WPAOpaque );
3222#if defined(FEATURE_WLAN_WAPI)
3223 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3224 &frm.WAPIOpaque );
3225#endif // defined(FEATURE_WLAN_WAPI)
3226 }
3227
3228 // include WME EDCA IE as well
3229 if ( fWmeEnabled )
3230 {
3231 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3232 {
3233 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3234 }
3235
3236 if ( fWsmEnabled &&
3237 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3238 {
3239 PopulateDot11fWMMCaps( &frm.WMMCaps );
3240 }
3241 }
3242
Jeff Johnsone7245742012-09-05 17:12:55 -07003243 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 pMac->lim.htCapabilityPresentInBeacon)
3245 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003246 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003248#ifdef WLAN_FEATURE_11AC
3249 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003250 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003251 {
3252 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request\n"));
3253 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07003254 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003255 }
3256#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003257
3258 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3259 if ( DOT11F_FAILED( nStatus ) )
3260 {
3261 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3262 "or a Re-Association Request (0x%08x).\n"),
3263 nStatus );
3264 // We'll fall back on the worst case scenario:
3265 nPayload = sizeof( tDot11fReAssocRequest );
3266 }
3267 else if ( DOT11F_WARNED( nStatus ) )
3268 {
3269 limLog( pMac, LOGW, FL("There were warnings while calculating"
3270 "the packed size for a Re-Association Re "
3271 "quest(0x%08x).\n"), nStatus );
3272 }
3273
3274 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3275
3276 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3277 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3278 ( void** ) &pPacket );
3279 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3280 {
3281 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003282 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
3284 "sociation Request.\n"), nBytes );
3285 goto end;
3286 }
3287
3288 // Paranoia:
3289 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3290
3291 // Next, we fill out the buffer descriptor:
3292 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3293 SIR_MAC_MGMT_REASSOC_REQ,
3294 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3295 if ( eSIR_SUCCESS != nSirStatus )
3296 {
3297 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3298 "tor for an Association Request (%d).\n"),
3299 nSirStatus );
3300 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3301 goto end;
3302 }
3303
3304
3305 // That done, pack the Probe Request:
3306 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3307 sizeof(tSirMacMgmtHdr),
3308 nPayload, &nPayload );
3309 if ( DOT11F_FAILED( nStatus ) )
3310 {
3311 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
3312 "st (0x%08x).\n"),
3313 nStatus );
3314 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3315 goto end;
3316 }
3317 else if ( DOT11F_WARNED( nStatus ) )
3318 {
3319 limLog( pMac, LOGW, FL("There were warnings while packing a R"
3320 "e-Association Request (0x%08x).\n") );
3321 }
3322
3323 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
3324 "to \n"),
3325 nBytes );)
3326
3327 if( psessionEntry->assocReq != NULL )
3328 {
3329 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
3330 psessionEntry->assocReq = NULL;
3331 }
3332
3333 if( nAddIELen )
3334 {
3335 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3336 pAddIE,
3337 nAddIELen );
3338 nPayload += nAddIELen;
3339 }
3340
Jeff Johnson43971f52012-07-17 12:26:56 -07003341 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
3342 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 {
3344 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003345 }
3346 else
3347 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3349 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
3350 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003351 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003352
3353 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3354#ifdef WLAN_FEATURE_P2P
3355 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3356 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3357#endif
3358 )
3359 {
3360 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3361 }
3362
3363 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3364 HAL_TXRX_FRM_802_11_MGMT,
3365 ANI_TXDIR_TODS,
3366 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3367 limTxComplete, pFrame, txFlag );
3368 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3369 {
3370 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
3371 "(%X)!\n"),
3372 nSirStatus );
3373 //Pkt will be freed up by the callback
3374 goto end;
3375 }
3376
3377end:
3378 // Free up buffer allocated for mlmAssocReq
3379 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3380 psessionEntry->pLimMlmReassocReq = NULL;
3381
3382} // limSendReassocReqMgmtFrame
3383
3384/**
3385 * \brief Send an Authentication frame
3386 *
3387 *
3388 * \param pMac Pointer to Global MAC structure
3389 *
3390 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3391 * to be sent
3392 *
3393 * \param peerMacAddr MAC address of the peer entity to which Authentication
3394 * frame is destined
3395 *
3396 * \param wepBit Indicates whether wep bit to be set in FC while sending
3397 * Authentication frame3
3398 *
3399 *
3400 * This function is called by limProcessMlmMessages(). Authentication frame
3401 * is formatted and sent when this function is called.
3402 *
3403 *
3404 */
3405
3406void
3407limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3408 tpSirMacAuthFrameBody pAuthFrameBody,
3409 tSirMacAddr peerMacAddr,
3410 tANI_U8 wepBit,
3411 tpPESession psessionEntry
3412 )
3413{
3414 tANI_U8 *pFrame, *pBody;
3415 tANI_U32 frameLen = 0, bodyLen = 0;
3416 tpSirMacMgmtHdr pMacHdr;
3417 tANI_U16 i;
3418 void *pPacket;
3419 eHalStatus halstatus;
3420 tANI_U8 txFlag = 0;
3421
3422 if(NULL == psessionEntry)
3423 {
3424 return;
3425 }
3426
3427 if (wepBit == LIM_WEP_IN_FC)
3428 {
3429 /// Auth frame3 to be sent with encrypted framebody
3430 /**
3431 * Allocate buffer for Authenticaton frame of size equal
3432 * to management frame header length plus 2 bytes each for
3433 * auth algorithm number, transaction number, status code,
3434 * 128 bytes for challenge text and 4 bytes each for
3435 * IV & ICV.
3436 */
3437
3438 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3439
3440 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3441 } // if (wepBit == LIM_WEP_IN_FC)
3442 else
3443 {
3444 switch (pAuthFrameBody->authTransactionSeqNumber)
3445 {
3446 case SIR_MAC_AUTH_FRAME_1:
3447 /**
3448 * Allocate buffer for Authenticaton frame of size
3449 * equal to management frame header length plus 2 bytes
3450 * each for auth algorithm number, transaction number
3451 * and status code.
3452 */
3453
3454 frameLen = sizeof(tSirMacMgmtHdr) +
3455 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3456 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3457
3458#if defined WLAN_FEATURE_VOWIFI_11R
3459 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3460 {
3461 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies)
3462 {
3463 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
3464 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d\n"),
3465 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
3466 }
3467 else
3468 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!\n"));
3469 }
3470#endif
3471 break;
3472
3473 case SIR_MAC_AUTH_FRAME_2:
3474 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3475 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3476 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3477 {
3478 /**
3479 * Allocate buffer for Authenticaton frame of size
3480 * equal to management frame header length plus
3481 * 2 bytes each for auth algorithm number,
3482 * transaction number and status code.
3483 */
3484
3485 frameLen = sizeof(tSirMacMgmtHdr) +
3486 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3487 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3488 }
3489 else
3490 {
3491 // Shared Key algorithm with challenge text
3492 // to be sent
3493 /**
3494 * Allocate buffer for Authenticaton frame of size
3495 * equal to management frame header length plus
3496 * 2 bytes each for auth algorithm number,
3497 * transaction number, status code and 128 bytes
3498 * for challenge text.
3499 */
3500
3501 frameLen = sizeof(tSirMacMgmtHdr) +
3502 sizeof(tSirMacAuthFrame);
3503 bodyLen = sizeof(tSirMacAuthFrameBody);
3504 }
3505
3506 break;
3507
3508 case SIR_MAC_AUTH_FRAME_3:
3509 /// Auth frame3 to be sent without encrypted framebody
3510 /**
3511 * Allocate buffer for Authenticaton frame of size equal
3512 * to management frame header length plus 2 bytes each
3513 * for auth algorithm number, transaction number and
3514 * status code.
3515 */
3516
3517 frameLen = sizeof(tSirMacMgmtHdr) +
3518 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3519 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3520
3521 break;
3522
3523 case SIR_MAC_AUTH_FRAME_4:
3524 /**
3525 * Allocate buffer for Authenticaton frame of size equal
3526 * to management frame header length plus 2 bytes each
3527 * for auth algorithm number, transaction number and
3528 * status code.
3529 */
3530
3531 frameLen = sizeof(tSirMacMgmtHdr) +
3532 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3533 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3534
3535 break;
3536 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3537 } // end if (wepBit == LIM_WEP_IN_FC)
3538
3539
3540 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3541
3542 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3543 {
3544 // Log error
3545 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame\n"));
3546
3547 return;
3548 }
3549
3550 for (i = 0; i < frameLen; i++)
3551 pFrame[i] = 0;
3552
3553 // Prepare BD
3554 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3555 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3556 {
3557 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3558 return;
3559 }
3560
3561 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3562 pMacHdr->fc.wep = wepBit;
3563
3564 // Prepare BSSId
3565 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3566 {
3567 palCopyMemory( pMac->hHdd,(tANI_U8 *) pMacHdr->bssId,
3568 (tANI_U8 *) psessionEntry->bssId,
3569 sizeof( tSirMacAddr ));
3570 }
3571
3572 /// Prepare Authentication frame body
3573 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3574
3575 if (wepBit == LIM_WEP_IN_FC)
3576 {
3577 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
3578
3579 PELOG1(limLog(pMac, LOG1,
3580 FL("*** Sending Auth seq# 3 status %d (%d) to\n"),
3581 pAuthFrameBody->authStatusCode,
3582 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3583
3584 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3585 }
3586 else
3587 {
3588 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3589 pBody += sizeof(tANI_U16);
3590 bodyLen -= sizeof(tANI_U16);
3591
3592 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3593 pBody += sizeof(tANI_U16);
3594 bodyLen -= sizeof(tANI_U16);
3595
3596 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3597 pBody += sizeof(tANI_U16);
3598 bodyLen -= sizeof(tANI_U16);
3599
3600 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
3601
3602#if defined WLAN_FEATURE_VOWIFI_11R
3603 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3604 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3605 {
3606
3607 {
3608 int i = 0;
3609#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
3610 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3611 {
3612 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3613 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3614 (tANI_U8 *)pBody,
3615 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
3616 }
3617#endif
3618 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3619 {
3620 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3621 pBody++;
3622 }
3623 }
3624 }
3625#endif
3626
3627 PELOG1(limLog(pMac, LOG1,
3628 FL("*** Sending Auth seq# %d status %d (%d) to "),
3629 pAuthFrameBody->authTransactionSeqNumber,
3630 pAuthFrameBody->authStatusCode,
3631 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3632
3633 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3634 }
3635 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3636
3637 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3638#ifdef WLAN_FEATURE_P2P
3639 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3640 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3641#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003642#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
3643 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
3644 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3645#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 )
3647 {
3648 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3649 }
3650
3651 /// Queue Authentication frame in high priority WQ
3652 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3653 HAL_TXRX_FRM_802_11_MGMT,
3654 ANI_TXDIR_TODS,
3655 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3656 limTxComplete, pFrame, txFlag );
3657 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3658 {
3659 limLog(pMac, LOGE,
3660 FL("*** Could not send Auth frame, retCode=%X ***\n"),
3661 halstatus);
3662
3663 //Pkt will be freed up by the callback
3664 }
3665
3666 return;
3667} /*** end limSendAuthMgmtFrame() ***/
3668
3669/**
3670 * \brief This function is called to send Disassociate frame.
3671 *
3672 *
3673 * \param pMac Pointer to Global MAC structure
3674 *
3675 * \param nReason Indicates the reason that need to be sent in
3676 * Disassociation frame
3677 *
3678 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3679 * sent
3680 *
3681 *
3682 */
3683
3684void
3685limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3686 tANI_U16 nReason,
3687 tSirMacAddr peer,tpPESession psessionEntry)
3688{
3689 tDot11fDisassociation frm;
3690 tANI_U8 *pFrame;
3691 tSirRetStatus nSirStatus;
3692 tpSirMacMgmtHdr pMacHdr;
3693 tANI_U32 nBytes, nPayload, nStatus;
3694 void *pPacket;
3695 eHalStatus halstatus;
3696 tANI_U8 txFlag = 0;
3697
3698 if(NULL == psessionEntry)
3699 {
3700 return;
3701 }
3702
3703 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3704
3705 frm.Reason.code = nReason;
3706
3707 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3708 if ( DOT11F_FAILED( nStatus ) )
3709 {
3710 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3711 "or a Disassociation (0x%08x).\n"),
3712 nStatus );
3713 // We'll fall back on the worst case scenario:
3714 nPayload = sizeof( tDot11fDisassociation );
3715 }
3716 else if ( DOT11F_WARNED( nStatus ) )
3717 {
3718 limLog( pMac, LOGW, FL("There were warnings while calculating"
3719 "the packed size for a Disassociation "
3720 "(0x%08x).\n"), nStatus );
3721 }
3722
3723 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3724
3725 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3726 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3727 ( void** ) &pPacket );
3728 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3729 {
3730 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
3731 "association.\n"), nBytes );
3732 return;
3733 }
3734
3735 // Paranoia:
3736 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3737
3738 // Next, we fill out the buffer descriptor:
3739 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3740 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3741 if ( eSIR_SUCCESS != nSirStatus )
3742 {
3743 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3744 "tor for a Disassociation (%d).\n"),
3745 nSirStatus );
3746 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3747 ( void* ) pFrame, ( void* ) pPacket );
3748 return; // just allocated...
3749 }
3750
3751 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3752
3753 // Prepare the BSSID
3754 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3755
3756 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3757 sizeof(tSirMacMgmtHdr),
3758 nPayload, &nPayload );
3759 if ( DOT11F_FAILED( nStatus ) )
3760 {
3761 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x).\n"),
3762 nStatus );
3763 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3764 ( void* ) pFrame, ( void* ) pPacket );
3765 return; // allocated!
3766 }
3767 else if ( DOT11F_WARNED( nStatus ) )
3768 {
3769 limLog( pMac, LOGW, FL("There were warnings while packing a D"
3770 "isassociation (0x%08x).\n") );
3771 }
3772
3773 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
3774 "son %d to\n"), nReason );
3775 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3776
3777 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3778#ifdef WLAN_FEATURE_P2P
3779 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3780 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3781#endif
3782 )
3783 {
3784 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3785 }
3786
3787 // Queue Disassociation frame in high priority WQ
3788 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3789 HAL_TXRX_FRM_802_11_MGMT,
3790 ANI_TXDIR_TODS,
3791 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3792 limTxComplete, pFrame, txFlag );
3793 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3794 {
3795 limLog( pMac, LOGE, FL("Failed to send Disassociation "
3796 "(%X)!\n"),
3797 nSirStatus );
3798 //Pkt will be freed up by the callback
3799 return;
3800 }
3801
3802} // End limSendDisassocMgmtFrame.
3803
3804/**
3805 * \brief This function is called to send a Deauthenticate frame
3806 *
3807 *
3808 * \param pMac Pointer to global MAC structure
3809 *
3810 * \param nReason Indicates the reason that need to be sent in the
3811 * Deauthenticate frame
3812 *
3813 * \param peeer address of the STA to which the frame is to be sent
3814 *
3815 *
3816 */
3817
3818void
3819limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3820 tANI_U16 nReason,
3821 tSirMacAddr peer,tpPESession psessionEntry)
3822{
3823 tDot11fDeAuth frm;
3824 tANI_U8 *pFrame;
3825 tSirRetStatus nSirStatus;
3826 tpSirMacMgmtHdr pMacHdr;
3827 tANI_U32 nBytes, nPayload, nStatus;
3828 void *pPacket;
3829 eHalStatus halstatus;
3830 tANI_U8 txFlag = 0;
3831
3832 if(NULL == psessionEntry)
3833 {
3834 return;
3835 }
3836
3837 palZeroMemory( pMac->hHdd, ( tANI_U8* ) &frm, sizeof( frm ) );
3838
3839 frm.Reason.code = nReason;
3840
3841 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3842 if ( DOT11F_FAILED( nStatus ) )
3843 {
3844 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3845 "or a De-Authentication (0x%08x).\n"),
3846 nStatus );
3847 // We'll fall back on the worst case scenario:
3848 nPayload = sizeof( tDot11fDeAuth );
3849 }
3850 else if ( DOT11F_WARNED( nStatus ) )
3851 {
3852 limLog( pMac, LOGW, FL("There were warnings while calculating"
3853 "the packed size for a De-Authentication "
3854 "(0x%08x).\n"), nStatus );
3855 }
3856
3857 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3858
3859 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3860 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3861 ( void** ) &pPacket );
3862 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3863 {
3864 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
3865 "Authentication.\n"), nBytes );
3866 return;
3867 }
3868
3869 // Paranoia:
3870 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3871
3872 // Next, we fill out the buffer descriptor:
3873 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3874 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3875 if ( eSIR_SUCCESS != nSirStatus )
3876 {
3877 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3878 "tor for a De-Authentication (%d).\n"),
3879 nSirStatus );
3880 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3881 ( void* ) pFrame, ( void* ) pPacket );
3882 return; // just allocated...
3883 }
3884
3885 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3886
3887 // Prepare the BSSID
3888 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3889
3890 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3891 sizeof(tSirMacMgmtHdr),
3892 nPayload, &nPayload );
3893 if ( DOT11F_FAILED( nStatus ) )
3894 {
3895 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x).\n"),
3896 nStatus );
3897 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3898 ( void* ) pFrame, ( void* ) pPacket );
3899 return;
3900 }
3901 else if ( DOT11F_WARNED( nStatus ) )
3902 {
3903 limLog( pMac, LOGW, FL("There were warnings while packing a D"
3904 "e-Authentication (0x%08x).\n") );
3905 }
3906
3907 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
3908 "son %d to\n"), nReason );
3909 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3910
3911 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3912#ifdef WLAN_FEATURE_P2P
3913 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3914 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3915#endif
3916 )
3917 {
3918 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3919 }
3920
3921 // Queue Disassociation frame in high priority WQ
3922 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3923 HAL_TXRX_FRM_802_11_MGMT,
3924 ANI_TXDIR_TODS,
3925 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3926 limTxComplete, pFrame, txFlag );
3927 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3928 {
3929 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
3930 "(%X)!\n"),
3931 nSirStatus );
3932 //Pkt will be freed up by the callback
3933 return;
3934 }
3935
3936} // End limSendDeauthMgmtFrame.
3937
3938
3939#ifdef ANI_SUPPORT_11H
3940/**
3941 * \brief Send a Measurement Report Action frame
3942 *
3943 *
3944 * \param pMac Pointer to the global MAC structure
3945 *
3946 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3947 *
3948 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3949 *
3950 *
3951 */
3952
3953tSirRetStatus
3954limSendMeasReportFrame(tpAniSirGlobal pMac,
3955 tpSirMacMeasReqActionFrame pMeasReqFrame,
3956 tSirMacAddr peer)
3957{
3958 tDot11fMeasurementReport frm;
3959 tANI_U8 *pFrame;
3960 tSirRetStatus nSirStatus;
3961 tpSirMacMgmtHdr pMacHdr;
3962 tANI_U32 nBytes, nPayload, nStatus, nCfg;
3963 void *pPacket;
3964 eHalStatus halstatus;
3965
3966 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3967
3968 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3969 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3970 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3971
3972 switch ( pMeasReqFrame->measReqIE.measType )
3973 {
3974 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3975 nSirStatus =
3976 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
3977 &frm.MeasurementReport );
3978 break;
3979 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3980 nSirStatus =
3981 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
3982 &frm.MeasurementReport );
3983 break;
3984 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3985 nSirStatus =
3986 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
3987 &frm.MeasurementReport );
3988 break;
3989 default:
3990 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
3991 "dMeasReportFrame.\n"),
3992 pMeasReqFrame->measReqIE.measType );
3993 return eSIR_FAILURE;
3994 }
3995
3996 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
3997
3998 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
3999 if ( DOT11F_FAILED( nStatus ) )
4000 {
4001 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4002 "or a Measurement Report (0x%08x).\n"),
4003 nStatus );
4004 // We'll fall back on the worst case scenario:
4005 nPayload = sizeof( tDot11fMeasurementReport );
4006 }
4007 else if ( DOT11F_WARNED( nStatus ) )
4008 {
4009 limLog( pMac, LOGW, FL("There were warnings while calculating"
4010 "the packed size for a Measurement Rep"
4011 "ort (0x%08x).\n"), nStatus );
4012 }
4013
4014 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4015
4016 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4017 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4018 {
4019 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
4020 "Authentication.\n"), nBytes );
4021 return eSIR_FAILURE;
4022 }
4023
4024 // Paranoia:
4025 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4026
4027 // Next, we fill out the buffer descriptor:
4028 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4029 SIR_MAC_MGMT_ACTION, peer);
4030 if ( eSIR_SUCCESS != nSirStatus )
4031 {
4032 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4033 "tor for a Measurement Report (%d).\n"),
4034 nSirStatus );
4035 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4036 return eSIR_FAILURE; // just allocated...
4037 }
4038
4039 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4040
4041 nCfg = 6;
4042 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4043 if ( eSIR_SUCCESS != nSirStatus )
4044 {
4045 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4046 " CFG (%d).\n"),
4047 nSirStatus );
4048 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4049 return eSIR_FAILURE; // just allocated...
4050 }
4051
4052 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4053 sizeof(tSirMacMgmtHdr),
4054 nPayload, &nPayload );
4055 if ( DOT11F_FAILED( nStatus ) )
4056 {
4057 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x).\n"),
4058 nStatus );
4059 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4060 return eSIR_FAILURE; // allocated!
4061 }
4062 else if ( DOT11F_WARNED( nStatus ) )
4063 {
4064 limLog( pMac, LOGW, FL("There were warnings while packing a M"
4065 "easurement Report (0x%08x).\n") );
4066 }
4067
4068 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4069 HAL_TXRX_FRM_802_11_MGMT,
4070 ANI_TXDIR_TODS,
4071 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4072 limTxComplete, pFrame, 0 );
4073 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4074 {
4075 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
4076 "(%X)!\n"),
4077 nSirStatus );
4078 //Pkt will be freed up by the callback
4079 return eSIR_FAILURE; // just allocated...
4080 }
4081
4082 return eSIR_SUCCESS;
4083
4084} // End limSendMeasReportFrame.
4085
4086
4087/**
4088 * \brief Send a TPC Request Action frame
4089 *
4090 *
4091 * \param pMac Pointer to the global MAC datastructure
4092 *
4093 * \param peer MAC address to which the frame should be sent
4094 *
4095 *
4096 */
4097
4098void
4099limSendTpcRequestFrame(tpAniSirGlobal pMac,
4100 tSirMacAddr peer)
4101{
4102 tDot11fTPCRequest frm;
4103 tANI_U8 *pFrame;
4104 tSirRetStatus nSirStatus;
4105 tpSirMacMgmtHdr pMacHdr;
4106 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4107 void *pPacket;
4108 eHalStatus halstatus;
4109
4110 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4111
4112 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4113 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4114 frm.DialogToken.token = 1;
4115 frm.TPCRequest.present = 1;
4116
4117 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4118 if ( DOT11F_FAILED( nStatus ) )
4119 {
4120 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4121 "or a TPC Request (0x%08x).\n"),
4122 nStatus );
4123 // We'll fall back on the worst case scenario:
4124 nPayload = sizeof( tDot11fTPCRequest );
4125 }
4126 else if ( DOT11F_WARNED( nStatus ) )
4127 {
4128 limLog( pMac, LOGW, FL("There were warnings while calculating"
4129 "the packed size for a TPC Request (0x"
4130 "%08x).\n"), nStatus );
4131 }
4132
4133 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4134
4135 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4136 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4137 {
4138 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4139 " Request.\n"), nBytes );
4140 return;
4141 }
4142
4143 // Paranoia:
4144 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4145
4146 // Next, we fill out the buffer descriptor:
4147 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4148 SIR_MAC_MGMT_ACTION, peer);
4149 if ( eSIR_SUCCESS != nSirStatus )
4150 {
4151 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4152 "tor for a TPC Request (%d).\n"),
4153 nSirStatus );
4154 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4155 return; // just allocated...
4156 }
4157
4158 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4159
4160 nCfg = 6;
4161 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4162 if ( eSIR_SUCCESS != nSirStatus )
4163 {
4164 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4165 " CFG (%d).\n"),
4166 nSirStatus );
4167 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4168 return; // just allocated...
4169 }
4170
4171 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4172 sizeof(tSirMacMgmtHdr),
4173 nPayload, &nPayload );
4174 if ( DOT11F_FAILED( nStatus ) )
4175 {
4176 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x).\n"),
4177 nStatus );
4178 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4179 return; // allocated!
4180 }
4181 else if ( DOT11F_WARNED( nStatus ) )
4182 {
4183 limLog( pMac, LOGW, FL("There were warnings while packing a T"
4184 "PC Request (0x%08x).\n") );
4185 }
4186
4187 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4188 HAL_TXRX_FRM_802_11_MGMT,
4189 ANI_TXDIR_TODS,
4190 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4191 limTxComplete, pFrame, 0 );
4192 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4193 {
4194 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
4195 "(%X)!\n"),
4196 nSirStatus );
4197 //Pkt will be freed up by the callback
4198 return;
4199 }
4200
4201} // End limSendTpcRequestFrame.
4202
4203
4204/**
4205 * \brief Send a TPC Report Action frame
4206 *
4207 *
4208 * \param pMac Pointer to the global MAC datastructure
4209 *
4210 * \param pTpcReqFrame Pointer to the received TPC Request
4211 *
4212 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4213 *
4214 *
4215 */
4216
4217tSirRetStatus
4218limSendTpcReportFrame(tpAniSirGlobal pMac,
4219 tpSirMacTpcReqActionFrame pTpcReqFrame,
4220 tSirMacAddr peer)
4221{
4222 tDot11fTPCReport frm;
4223 tANI_U8 *pFrame;
4224 tSirRetStatus nSirStatus;
4225 tpSirMacMgmtHdr pMacHdr;
4226 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4227 void *pPacket;
4228 eHalStatus halstatus;
4229
4230 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4231
4232 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4233 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4234 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4235
4236 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4237 // "misplaced this function, need to replace:
4238 // txPower = halGetRateToPwrValue(pMac, staid,
4239 // pMac->lim.gLimCurrentChannelId, 0);
4240 frm.TPCReport.tx_power = 0;
4241 frm.TPCReport.link_margin = 0;
4242 frm.TPCReport.present = 1;
4243
4244 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4245 if ( DOT11F_FAILED( nStatus ) )
4246 {
4247 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4248 "or a TPC Report (0x%08x).\n"),
4249 nStatus );
4250 // We'll fall back on the worst case scenario:
4251 nPayload = sizeof( tDot11fTPCReport );
4252 }
4253 else if ( DOT11F_WARNED( nStatus ) )
4254 {
4255 limLog( pMac, LOGW, FL("There were warnings while calculating"
4256 "the packed size for a TPC Report (0x"
4257 "%08x).\n"), nStatus );
4258 }
4259
4260 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4261
4262 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4263 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4264 {
4265 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4266 " Report.\n"), nBytes );
4267 return eSIR_FAILURE;
4268 }
4269
4270 // Paranoia:
4271 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4272
4273 // Next, we fill out the buffer descriptor:
4274 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4275 SIR_MAC_MGMT_ACTION, peer);
4276 if ( eSIR_SUCCESS != nSirStatus )
4277 {
4278 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4279 "tor for a TPC Report (%d).\n"),
4280 nSirStatus );
4281 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4282 return eSIR_FAILURE; // just allocated...
4283 }
4284
4285 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4286
4287 nCfg = 6;
4288 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4289 if ( eSIR_SUCCESS != nSirStatus )
4290 {
4291 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4292 " CFG (%d).\n"),
4293 nSirStatus );
4294 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4295 return eSIR_FAILURE; // just allocated...
4296 }
4297
4298 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4299 sizeof(tSirMacMgmtHdr),
4300 nPayload, &nPayload );
4301 if ( DOT11F_FAILED( nStatus ) )
4302 {
4303 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x).\n"),
4304 nStatus );
4305 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4306 return eSIR_FAILURE; // allocated!
4307 }
4308 else if ( DOT11F_WARNED( nStatus ) )
4309 {
4310 limLog( pMac, LOGW, FL("There were warnings while packing a T"
4311 "PC Report (0x%08x).\n") );
4312 }
4313
4314
4315 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4316 HAL_TXRX_FRM_802_11_MGMT,
4317 ANI_TXDIR_TODS,
4318 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4319 limTxComplete, pFrame, 0 );
4320 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4321 {
4322 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
4323 "(%X)!\n"),
4324 nSirStatus );
4325 //Pkt will be freed up by the callback
4326 return eSIR_FAILURE; // just allocated...
4327 }
4328
4329 return eSIR_SUCCESS;
4330
4331} // End limSendTpcReportFrame.
4332#endif //ANI_SUPPORT_11H
4333
4334
Jeff Johnsone7245742012-09-05 17:12:55 -07004335#if 1//def ANI_PRODUCT_TYPE_AP
Jeff Johnson295189b2012-06-20 16:38:30 -07004336/**
4337 * \brief Send a Channel Switch Announcement
4338 *
4339 *
4340 * \param pMac Pointer to the global MAC datastructure
4341 *
4342 * \param peer MAC address to which this frame will be sent
4343 *
4344 * \param nMode
4345 *
4346 * \param nNewChannel
4347 *
4348 * \param nCount
4349 *
4350 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4351 *
4352 *
4353 */
4354
4355tSirRetStatus
4356limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4357 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004358 tANI_U8 nMode,
4359 tANI_U8 nNewChannel,
4360 tANI_U8 nCount,
4361 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004362{
4363 tDot11fChannelSwitch frm;
4364 tANI_U8 *pFrame;
4365 tSirRetStatus nSirStatus;
4366 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004367 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 void *pPacket;
4369 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004370 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004371
4372 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4373
4374 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4375 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4376 frm.ChanSwitchAnn.switchMode = nMode;
4377 frm.ChanSwitchAnn.newChannel = nNewChannel;
4378 frm.ChanSwitchAnn.switchCount = nCount;
4379 frm.ChanSwitchAnn.present = 1;
4380
4381 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4382 if ( DOT11F_FAILED( nStatus ) )
4383 {
4384 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4385 "or a Channel Switch (0x%08x).\n"),
4386 nStatus );
4387 // We'll fall back on the worst case scenario:
4388 nPayload = sizeof( tDot11fChannelSwitch );
4389 }
4390 else if ( DOT11F_WARNED( nStatus ) )
4391 {
4392 limLog( pMac, LOGW, FL("There were warnings while calculating"
4393 "the packed size for a Channel Switch (0x"
4394 "%08x).\n"), nStatus );
4395 }
4396
4397 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4398
4399 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4400 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4401 {
4402 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4403 " Report.\n"), nBytes );
4404 return eSIR_FAILURE;
4405 }
4406
4407 // Paranoia:
4408 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4409
4410 // Next, we fill out the buffer descriptor:
4411 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004412 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4413 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4414 palCopyMemory( pMac->hHdd,
4415 (tANI_U8 *) pMacHdr->bssId,
4416 (tANI_U8 *) psessionEntry->bssId,
4417 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 if ( eSIR_SUCCESS != nSirStatus )
4419 {
4420 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4421 "tor for a Channel Switch (%d).\n"),
4422 nSirStatus );
4423 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4424 return eSIR_FAILURE; // just allocated...
4425 }
4426
Jeff Johnsone7245742012-09-05 17:12:55 -07004427#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4429
4430 nCfg = 6;
4431 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4432 if ( eSIR_SUCCESS != nSirStatus )
4433 {
4434 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4435 " CFG (%d).\n"),
4436 nSirStatus );
4437 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4438 return eSIR_FAILURE; // just allocated...
4439 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004440#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4442 sizeof(tSirMacMgmtHdr),
4443 nPayload, &nPayload );
4444 if ( DOT11F_FAILED( nStatus ) )
4445 {
4446 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x).\n"),
4447 nStatus );
4448 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4449 return eSIR_FAILURE; // allocated!
4450 }
4451 else if ( DOT11F_WARNED( nStatus ) )
4452 {
4453 limLog( pMac, LOGW, FL("There were warnings while packing a C"
4454 "hannel Switch (0x%08x).\n") );
4455 }
4456
Jeff Johnsone7245742012-09-05 17:12:55 -07004457 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4458#ifdef WLAN_FEATURE_P2P
4459 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4460 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4461#endif
4462 )
4463 {
4464 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4467 HAL_TXRX_FRM_802_11_MGMT,
4468 ANI_TXDIR_TODS,
4469 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004470 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4472 {
4473 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4474 "(%X)!\n"),
4475 nSirStatus );
4476 //Pkt will be freed up by the callback
4477 return eSIR_FAILURE;
4478 }
4479
4480 return eSIR_SUCCESS;
4481
4482} // End limSendChannelSwitchMgmtFrame.
4483
4484#endif // (ANI_PRODUCT_TYPE_AP)
4485
4486
Mohit Khanna4a70d262012-09-11 16:30:12 -07004487#ifdef WLAN_FEATURE_11AC
4488tSirRetStatus
4489limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4490 tSirMacAddr peer,
4491 tANI_U8 nMode,
4492 tpPESession psessionEntry )
4493{
4494 tDot11fOperatingMode frm;
4495 tANI_U8 *pFrame;
4496 tSirRetStatus nSirStatus;
4497 tpSirMacMgmtHdr pMacHdr;
4498 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4499 void *pPacket;
4500 eHalStatus halstatus;
4501 tANI_U8 txFlag = 0;
4502
4503 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4504
4505 frm.Category.category = SIR_MAC_ACTION_VHT;
4506 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4507 frm.OperatingMode.chanWidth = nMode;
4508 frm.OperatingMode.rxNSS = 0;
4509 frm.OperatingMode.rxNSSType = 0;
4510
4511 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4512 if ( DOT11F_FAILED( nStatus ) )
4513 {
4514 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4515 "or a Operating Mode (0x%08x).\n"),
4516 nStatus );
4517 // We'll fall back on the worst case scenario:
4518 nPayload = sizeof( tDot11fOperatingMode);
4519 }
4520 else if ( DOT11F_WARNED( nStatus ) )
4521 {
4522 limLog( pMac, LOGW, FL("There were warnings while calculating"
4523 "the packed size for a Operating Mode (0x"
4524 "%08x).\n"), nStatus );
4525 }
4526
4527 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4528
4529 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4530 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4531 {
4532 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
4533 " Report.\n"), nBytes );
4534 return eSIR_FAILURE;
4535 }
4536
4537 // Paranoia:
4538 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4539
4540
4541 // Next, we fill out the buffer descriptor:
4542 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4543 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4544 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4545 } else
4546 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4547 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4548 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4549 palCopyMemory( pMac->hHdd,
4550 (tANI_U8 *) pMacHdr->bssId,
4551 (tANI_U8 *) psessionEntry->bssId,
4552 sizeof( tSirMacAddr ));
4553 if ( eSIR_SUCCESS != nSirStatus )
4554 {
4555 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4556 "tor for a Operating Mode (%d).\n"),
4557 nSirStatus );
4558 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4559 return eSIR_FAILURE; // just allocated...
4560 }
4561 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4562 sizeof(tSirMacMgmtHdr),
4563 nPayload, &nPayload );
4564 if ( DOT11F_FAILED( nStatus ) )
4565 {
4566 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x).\n"),
4567 nStatus );
4568 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4569 return eSIR_FAILURE; // allocated!
4570 }
4571 else if ( DOT11F_WARNED( nStatus ) )
4572 {
4573 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
4574 " (0x%08x).\n") );
4575 }
4576 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4577#ifdef WLAN_FEATURE_P2P
4578 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4579 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4580#endif
4581 )
4582 {
4583 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4584 }
4585 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4586 HAL_TXRX_FRM_802_11_MGMT,
4587 ANI_TXDIR_TODS,
4588 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4589 limTxComplete, pFrame, txFlag );
4590 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4591 {
4592 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4593 "(%X)!\n"),
4594 nSirStatus );
4595 //Pkt will be freed up by the callback
4596 return eSIR_FAILURE;
4597 }
4598
4599 return eSIR_SUCCESS;
4600}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004601
4602/**
4603 * \brief Send a VHT Channel Switch Announcement
4604 *
4605 *
4606 * \param pMac Pointer to the global MAC datastructure
4607 *
4608 * \param peer MAC address to which this frame will be sent
4609 *
4610 * \param nChanWidth
4611 *
4612 * \param nNewChannel
4613 *
4614 *
4615 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4616 *
4617 *
4618 */
4619
4620tSirRetStatus
4621limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4622 tSirMacAddr peer,
4623 tANI_U8 nChanWidth,
4624 tANI_U8 nNewChannel,
4625 tANI_U8 ncbMode,
4626 tpPESession psessionEntry )
4627{
4628 tDot11fChannelSwitch frm;
4629 tANI_U8 *pFrame;
4630 tSirRetStatus nSirStatus;
4631 tpSirMacMgmtHdr pMacHdr;
4632 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4633 void *pPacket;
4634 eHalStatus halstatus;
4635 tANI_U8 txFlag = 0;
4636
4637 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4638
4639
4640 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4641 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4642 frm.ChanSwitchAnn.switchMode = 1;
4643 frm.ChanSwitchAnn.newChannel = nNewChannel;
4644 frm.ChanSwitchAnn.switchCount = 1;
4645 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4646 frm.ExtChanSwitchAnn.present = 1;
4647 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4648 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4649 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4650 frm.ChanSwitchAnn.present = 1;
4651 frm.WiderBWChanSwitchAnn.present = 1;
4652
4653 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4654 if ( DOT11F_FAILED( nStatus ) )
4655 {
4656 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4657 "or a Channel Switch (0x%08x).\n"),
4658 nStatus );
4659 // We'll fall back on the worst case scenario:
4660 nPayload = sizeof( tDot11fChannelSwitch );
4661 }
4662 else if ( DOT11F_WARNED( nStatus ) )
4663 {
4664 limLog( pMac, LOGW, FL("There were warnings while calculating"
4665 "the packed size for a Channel Switch (0x"
4666 "%08x).\n"), nStatus );
4667 }
4668
4669 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4670
4671 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4672 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4673 {
4674 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4675 " Report.\n"), nBytes );
4676 return eSIR_FAILURE;
4677 }
4678 // Paranoia:
4679 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4680
4681 // Next, we fill out the buffer descriptor:
4682 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4683 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4684 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4685 palCopyMemory( pMac->hHdd,
4686 (tANI_U8 *) pMacHdr->bssId,
4687 (tANI_U8 *) psessionEntry->bssId,
4688 sizeof( tSirMacAddr ));
4689 if ( eSIR_SUCCESS != nSirStatus )
4690 {
4691 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4692 "tor for a Channel Switch (%d).\n"),
4693 nSirStatus );
4694 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4695 return eSIR_FAILURE; // just allocated...
4696 }
4697 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4698 sizeof(tSirMacMgmtHdr),
4699 nPayload, &nPayload );
4700 if ( DOT11F_FAILED( nStatus ) )
4701 {
4702 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x).\n"),
4703 nStatus );
4704 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4705 return eSIR_FAILURE; // allocated!
4706 }
4707 else if ( DOT11F_WARNED( nStatus ) )
4708 {
4709 limLog( pMac, LOGW, FL("There were warnings while packing a C"
4710 "hannel Switch (0x%08x).\n") );
4711 }
4712
4713 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4714#ifdef WLAN_FEATURE_P2P
4715 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4716 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4717#endif
4718 )
4719 {
4720 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4721 }
4722 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4723 HAL_TXRX_FRM_802_11_MGMT,
4724 ANI_TXDIR_TODS,
4725 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4726 limTxComplete, pFrame, txFlag );
4727 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4728 {
4729 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4730 "(%X)!\n"),
4731 nSirStatus );
4732 //Pkt will be freed up by the callback
4733 return eSIR_FAILURE;
4734 }
4735
4736 return eSIR_SUCCESS;
4737
4738} // End limSendVHTChannelSwitchMgmtFrame.
4739
4740
4741
Mohit Khanna4a70d262012-09-11 16:30:12 -07004742#endif
4743
Jeff Johnson295189b2012-06-20 16:38:30 -07004744/**
4745 * \brief Send an ADDBA Req Action Frame to peer
4746 *
4747 * \sa limSendAddBAReq
4748 *
4749 * \param pMac The global tpAniSirGlobal object
4750 *
4751 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4752 * the necessary parameters reqd by PE send the ADDBA Req Action
4753 * Frame to the peer
4754 *
4755 * \return eSIR_SUCCESS if setup completes successfully
4756 * eSIR_FAILURE is some problem is encountered
4757 */
4758tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
4759 tpLimMlmAddBAReq pMlmAddBAReq ,tpPESession psessionEntry)
4760{
4761 tDot11fAddBAReq frmAddBAReq;
4762 tANI_U8 *pAddBAReqBuffer = NULL;
4763 tpSirMacMgmtHdr pMacHdr;
4764 tANI_U32 frameLen = 0, nStatus, nPayload;
4765 tSirRetStatus statusCode;
4766 eHalStatus halStatus;
4767 void *pPacket;
4768 tANI_U8 txFlag = 0;
4769
4770 if(NULL == psessionEntry)
4771 {
4772 return eSIR_FAILURE;
4773 }
4774
4775 palZeroMemory( pMac->hHdd, (void *) &frmAddBAReq, sizeof( frmAddBAReq ));
4776
4777 // Category - 3 (BA)
4778 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4779
4780 // Action - 0 (ADDBA Req)
4781 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4782
4783 // FIXME - Dialog Token, generalize this...
4784 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4785
4786 // Fill the ADDBA Parameter Set
4787 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4788 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4789 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4790
4791 // BA timeout
4792 // 0 - indicates no BA timeout
4793 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4794
4795 // BA Starting Sequence Number
4796 // Fragment number will always be zero
4797 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4798 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4799 }
4800
4801 frmAddBAReq.BAStartingSequenceControl.ssn =
4802 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4803
4804 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4805
4806 if( DOT11F_FAILED( nStatus ))
4807 {
4808 limLog( pMac, LOGW,
4809 FL( "Failed to calculate the packed size for "
4810 "an ADDBA Request (0x%08x).\n"),
4811 nStatus );
4812
4813 // We'll fall back on the worst case scenario:
4814 nPayload = sizeof( tDot11fAddBAReq );
4815 }
4816 else if( DOT11F_WARNED( nStatus ))
4817 {
4818 limLog( pMac, LOGW,
4819 FL( "There were warnings while calculating"
4820 "the packed size for an ADDBA Req (0x%08x).\n"),
4821 nStatus );
4822 }
4823
4824 // Add the MGMT header to frame length
4825 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4826
4827 // Need to allocate a buffer for ADDBA AF
4828 if( eHAL_STATUS_SUCCESS !=
4829 (halStatus = palPktAlloc( pMac->hHdd,
4830 HAL_TXRX_FRM_802_11_MGMT,
4831 (tANI_U16) frameLen,
4832 (void **) &pAddBAReqBuffer,
4833 (void **) &pPacket )))
4834 {
4835 // Log error
4836 limLog( pMac, LOGP,
4837 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
4838 frameLen,
4839 halStatus );
4840
4841 statusCode = eSIR_MEM_ALLOC_FAILED;
4842 goto returnAfterError;
4843 }
4844
4845 palZeroMemory( pMac->hHdd, (void *) pAddBAReqBuffer, frameLen );
4846
4847 // Copy necessary info to BD
4848 if( eSIR_SUCCESS !=
4849 (statusCode = limPopulateMacHeader( pMac,
4850 pAddBAReqBuffer,
4851 SIR_MAC_MGMT_FRAME,
4852 SIR_MAC_MGMT_ACTION,
4853 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4854 goto returnAfterError;
4855
4856 // Update A3 with the BSSID
4857 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4858
4859 #if 0
4860 cfgLen = SIR_MAC_ADDR_LENGTH;
4861 if( eSIR_SUCCESS != cfgGetStr( pMac,
4862 WNI_CFG_BSSID,
4863 (tANI_U8 *) pMacHdr->bssId,
4864 &cfgLen ))
4865 {
4866 limLog( pMac, LOGP,
4867 FL( "Failed to retrieve WNI_CFG_BSSID while"
4868 "sending an ACTION Frame\n" ));
4869
4870 // FIXME - Need to convert to tSirRetStatus
4871 statusCode = eSIR_FAILURE;
4872 goto returnAfterError;
4873 }
4874 #endif//TO SUPPORT BT-AMP
4875 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4876
4877 // Now, we're ready to "pack" the frames
4878 nStatus = dot11fPackAddBAReq( pMac,
4879 &frmAddBAReq,
4880 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4881 nPayload,
4882 &nPayload );
4883
4884 if( DOT11F_FAILED( nStatus ))
4885 {
4886 limLog( pMac, LOGE,
4887 FL( "Failed to pack an ADDBA Req (0x%08x).\n" ),
4888 nStatus );
4889
4890 // FIXME - Need to convert to tSirRetStatus
4891 statusCode = eSIR_FAILURE;
4892 goto returnAfterError;
4893 }
4894 else if( DOT11F_WARNED( nStatus ))
4895 {
4896 limLog( pMac, LOGW,
4897 FL( "There were warnings while packing an ADDBA Req (0x%08x).\n" ));
4898 }
4899
4900 limLog( pMac, LOGW,
4901 FL( "Sending an ADDBA REQ to \n" ));
4902 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4903
4904 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4905#ifdef WLAN_FEATURE_P2P
4906 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4907 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4908#endif
4909 )
4910 {
4911 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4912 }
4913
4914 if( eHAL_STATUS_SUCCESS !=
4915 (halStatus = halTxFrame( pMac,
4916 pPacket,
4917 (tANI_U16) frameLen,
4918 HAL_TXRX_FRM_802_11_MGMT,
4919 ANI_TXDIR_TODS,
4920 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4921 limTxComplete,
4922 pAddBAReqBuffer, txFlag )))
4923 {
4924 limLog( pMac, LOGE,
4925 FL( "halTxFrame FAILED! Status [%d]\n"),
4926 halStatus );
4927
4928 // FIXME - Need to convert eHalStatus to tSirRetStatus
4929 statusCode = eSIR_FAILURE;
4930 //Pkt will be freed up by the callback
4931 return statusCode;
4932 }
4933 else
4934 return eSIR_SUCCESS;
4935
4936returnAfterError:
4937
4938 // Release buffer, if allocated
4939 if( NULL != pAddBAReqBuffer )
4940 palPktFree( pMac->hHdd,
4941 HAL_TXRX_FRM_802_11_MGMT,
4942 (void *) pAddBAReqBuffer,
4943 (void *) pPacket );
4944
4945 return statusCode;
4946}
4947
4948/**
4949 * \brief Send an ADDBA Rsp Action Frame to peer
4950 *
4951 * \sa limSendAddBARsp
4952 *
4953 * \param pMac The global tpAniSirGlobal object
4954 *
4955 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
4956 * the necessary parameters reqd by PE send the ADDBA Rsp Action
4957 * Frame to the peer
4958 *
4959 * \return eSIR_SUCCESS if setup completes successfully
4960 * eSIR_FAILURE is some problem is encountered
4961 */
4962tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
4963 tpLimMlmAddBARsp pMlmAddBARsp,
4964 tpPESession psessionEntry)
4965{
4966 tDot11fAddBARsp frmAddBARsp;
4967 tANI_U8 *pAddBARspBuffer = NULL;
4968 tpSirMacMgmtHdr pMacHdr;
4969 tANI_U32 frameLen = 0, nStatus, nPayload;
4970 tSirRetStatus statusCode;
4971 eHalStatus halStatus;
4972 void *pPacket;
4973 tANI_U8 txFlag = 0;
4974
4975 if(NULL == psessionEntry)
4976 {
4977 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!\n"));)
4978 return eSIR_FAILURE;
4979 }
4980
4981 palZeroMemory( pMac->hHdd, (void *) &frmAddBARsp, sizeof( frmAddBARsp ));
4982
4983 // Category - 3 (BA)
4984 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
4985 // Action - 1 (ADDBA Rsp)
4986 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
4987
4988 // Should be same as the one we received in the ADDBA Req
4989 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
4990
4991 // ADDBA Req status
4992 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
4993
4994 // Fill the ADDBA Parameter Set as provided by caller
4995 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
4996 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
4997 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
4998
4999 // BA timeout
5000 // 0 - indicates no BA timeout
5001 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5002
5003 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5004
5005 if( DOT11F_FAILED( nStatus ))
5006 {
5007 limLog( pMac, LOGW,
5008 FL( "Failed to calculate the packed size for "
5009 "an ADDBA Response (0x%08x).\n"),
5010 nStatus );
5011
5012 // We'll fall back on the worst case scenario:
5013 nPayload = sizeof( tDot11fAddBARsp );
5014 }
5015 else if( DOT11F_WARNED( nStatus ))
5016 {
5017 limLog( pMac, LOGW,
5018 FL( "There were warnings while calculating"
5019 "the packed size for an ADDBA Rsp (0x%08x).\n"),
5020 nStatus );
5021 }
5022
5023 // Need to allocate a buffer for ADDBA AF
5024 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5025
5026 // Allocate shared memory
5027 if( eHAL_STATUS_SUCCESS !=
5028 (halStatus = palPktAlloc( pMac->hHdd,
5029 HAL_TXRX_FRM_802_11_MGMT,
5030 (tANI_U16) frameLen,
5031 (void **) &pAddBARspBuffer,
5032 (void **) &pPacket )))
5033 {
5034 // Log error
5035 limLog( pMac, LOGP,
5036 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5037 frameLen,
5038 halStatus );
5039
5040 statusCode = eSIR_MEM_ALLOC_FAILED;
5041 goto returnAfterError;
5042 }
5043
5044 palZeroMemory( pMac->hHdd, (void *) pAddBARspBuffer, frameLen );
5045
5046 // Copy necessary info to BD
5047 if( eSIR_SUCCESS !=
5048 (statusCode = limPopulateMacHeader( pMac,
5049 pAddBARspBuffer,
5050 SIR_MAC_MGMT_FRAME,
5051 SIR_MAC_MGMT_ACTION,
5052 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5053 goto returnAfterError;
5054
5055 // Update A3 with the BSSID
5056
5057 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5058
5059 #if 0
5060 cfgLen = SIR_MAC_ADDR_LENGTH;
5061 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5062 WNI_CFG_BSSID,
5063 (tANI_U8 *) pMacHdr->bssId,
5064 &cfgLen ))
5065 {
5066 limLog( pMac, LOGP,
5067 FL( "Failed to retrieve WNI_CFG_BSSID while"
5068 "sending an ACTION Frame\n" ));
5069
5070 // FIXME - Need to convert to tSirRetStatus
5071 statusCode = eSIR_FAILURE;
5072 goto returnAfterError;
5073 }
5074 #endif // TO SUPPORT BT-AMP
5075 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5076
5077 // Now, we're ready to "pack" the frames
5078 nStatus = dot11fPackAddBARsp( pMac,
5079 &frmAddBARsp,
5080 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5081 nPayload,
5082 &nPayload );
5083
5084 if( DOT11F_FAILED( nStatus ))
5085 {
5086 limLog( pMac, LOGE,
5087 FL( "Failed to pack an ADDBA Rsp (0x%08x).\n" ),
5088 nStatus );
5089
5090 // FIXME - Need to convert to tSirRetStatus
5091 statusCode = eSIR_FAILURE;
5092 goto returnAfterError;
5093 }
5094 else if( DOT11F_WARNED( nStatus ))
5095 {
5096 limLog( pMac, LOGW,
5097 FL( "There were warnings while packing an ADDBA Rsp (0x%08x).\n" ));
5098 }
5099
5100 limLog( pMac, LOGW,
5101 FL( "Sending an ADDBA RSP to \n" ));
5102 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5103
5104 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5105#ifdef WLAN_FEATURE_P2P
5106 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5107 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5108#endif
5109 )
5110 {
5111 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5112 }
5113
5114 if( eHAL_STATUS_SUCCESS !=
5115 (halStatus = halTxFrame( pMac,
5116 pPacket,
5117 (tANI_U16) frameLen,
5118 HAL_TXRX_FRM_802_11_MGMT,
5119 ANI_TXDIR_TODS,
5120 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5121 limTxComplete,
5122 pAddBARspBuffer, txFlag )))
5123 {
5124 limLog( pMac, LOGE,
5125 FL( "halTxFrame FAILED! Status [%d]\n" ),
5126 halStatus );
5127
5128 // FIXME - HAL error codes are different from PE error
5129 // codes!! And, this routine is returning tSirRetStatus
5130 statusCode = eSIR_FAILURE;
5131 //Pkt will be freed up by the callback
5132 return statusCode;
5133 }
5134 else
5135 return eSIR_SUCCESS;
5136
5137 returnAfterError:
5138
5139 // Release buffer, if allocated
5140 if( NULL != pAddBARspBuffer )
5141 palPktFree( pMac->hHdd,
5142 HAL_TXRX_FRM_802_11_MGMT,
5143 (void *) pAddBARspBuffer,
5144 (void *) pPacket );
5145
5146 return statusCode;
5147}
5148
5149/**
5150 * \brief Send a DELBA Indication Action Frame to peer
5151 *
5152 * \sa limSendDelBAInd
5153 *
5154 * \param pMac The global tpAniSirGlobal object
5155 *
5156 * \param peerMacAddr MAC Address of peer
5157 *
5158 * \param reasonCode Reason for the DELBA notification
5159 *
5160 * \param pBAParameterSet The DELBA Parameter Set.
5161 * This identifies the TID for which the BA session is
5162 * being deleted.
5163 *
5164 * \return eSIR_SUCCESS if setup completes successfully
5165 * eSIR_FAILURE is some problem is encountered
5166 */
5167tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5168 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5169{
5170 tDot11fDelBAInd frmDelBAInd;
5171 tANI_U8 *pDelBAIndBuffer = NULL;
5172 //tANI_U32 val;
5173 tpSirMacMgmtHdr pMacHdr;
5174 tANI_U32 frameLen = 0, nStatus, nPayload;
5175 tSirRetStatus statusCode;
5176 eHalStatus halStatus;
5177 void *pPacket;
5178 tANI_U8 txFlag = 0;
5179
5180 if(NULL == psessionEntry)
5181 {
5182 return eSIR_FAILURE;
5183 }
5184
5185 palZeroMemory( pMac->hHdd, (void *) &frmDelBAInd, sizeof( frmDelBAInd ));
5186
5187 // Category - 3 (BA)
5188 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5189 // Action - 2 (DELBA)
5190 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5191
5192 // Fill the DELBA Parameter Set as provided by caller
5193 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5194 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5195
5196 // BA Starting Sequence Number
5197 // Fragment number will always be zero
5198 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5199
5200 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5201
5202 if( DOT11F_FAILED( nStatus ))
5203 {
5204 limLog( pMac, LOGW,
5205 FL( "Failed to calculate the packed size for "
5206 "an DELBA Indication (0x%08x).\n"),
5207 nStatus );
5208
5209 // We'll fall back on the worst case scenario:
5210 nPayload = sizeof( tDot11fDelBAInd );
5211 }
5212 else if( DOT11F_WARNED( nStatus ))
5213 {
5214 limLog( pMac, LOGW,
5215 FL( "There were warnings while calculating"
5216 "the packed size for an DELBA Ind (0x%08x).\n"),
5217 nStatus );
5218 }
5219
5220 // Add the MGMT header to frame length
5221 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5222
5223 // Allocate shared memory
5224 if( eHAL_STATUS_SUCCESS !=
5225 (halStatus = palPktAlloc( pMac->hHdd,
5226 HAL_TXRX_FRM_802_11_MGMT,
5227 (tANI_U16) frameLen,
5228 (void **) &pDelBAIndBuffer,
5229 (void **) &pPacket )))
5230 {
5231 // Log error
5232 limLog( pMac, LOGP,
5233 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5234 frameLen,
5235 halStatus );
5236
5237 statusCode = eSIR_MEM_ALLOC_FAILED;
5238 goto returnAfterError;
5239 }
5240
5241 palZeroMemory( pMac->hHdd, (void *) pDelBAIndBuffer, frameLen );
5242
5243 // Copy necessary info to BD
5244 if( eSIR_SUCCESS !=
5245 (statusCode = limPopulateMacHeader( pMac,
5246 pDelBAIndBuffer,
5247 SIR_MAC_MGMT_FRAME,
5248 SIR_MAC_MGMT_ACTION,
5249 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5250 goto returnAfterError;
5251
5252 // Update A3 with the BSSID
5253 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5254
5255 #if 0
5256 cfgLen = SIR_MAC_ADDR_LENGTH;
5257 if( eSIR_SUCCESS != cfgGetStr( pMac,
5258 WNI_CFG_BSSID,
5259 (tANI_U8 *) pMacHdr->bssId,
5260 &cfgLen ))
5261 {
5262 limLog( pMac, LOGP,
5263 FL( "Failed to retrieve WNI_CFG_BSSID while"
5264 "sending an ACTION Frame\n" ));
5265
5266 // FIXME - Need to convert to tSirRetStatus
5267 statusCode = eSIR_FAILURE;
5268 goto returnAfterError;
5269 }
5270 #endif //TO SUPPORT BT-AMP
5271 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5272
5273 // Now, we're ready to "pack" the frames
5274 nStatus = dot11fPackDelBAInd( pMac,
5275 &frmDelBAInd,
5276 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5277 nPayload,
5278 &nPayload );
5279
5280 if( DOT11F_FAILED( nStatus ))
5281 {
5282 limLog( pMac, LOGE,
5283 FL( "Failed to pack an DELBA Ind (0x%08x).\n" ),
5284 nStatus );
5285
5286 // FIXME - Need to convert to tSirRetStatus
5287 statusCode = eSIR_FAILURE;
5288 goto returnAfterError;
5289 }
5290 else if( DOT11F_WARNED( nStatus ))
5291 {
5292 limLog( pMac, LOGW,
5293 FL( "There were warnings while packing an DELBA Ind (0x%08x).\n" ));
5294 }
5295
5296 limLog( pMac, LOGW,
5297 FL( "Sending a DELBA IND to \n" ));
5298 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5299
5300 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5301#ifdef WLAN_FEATURE_P2P
5302 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5303 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5304#endif
5305 )
5306 {
5307 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5308 }
5309
5310 if( eHAL_STATUS_SUCCESS !=
5311 (halStatus = halTxFrame( pMac,
5312 pPacket,
5313 (tANI_U16) frameLen,
5314 HAL_TXRX_FRM_802_11_MGMT,
5315 ANI_TXDIR_TODS,
5316 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5317 limTxComplete,
5318 pDelBAIndBuffer, txFlag )))
5319 {
5320 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halStatus );)
5321 statusCode = eSIR_FAILURE;
5322 //Pkt will be freed up by the callback
5323 return statusCode;
5324 }
5325 else
5326 return eSIR_SUCCESS;
5327
5328 returnAfterError:
5329
5330 // Release buffer, if allocated
5331 if( NULL != pDelBAIndBuffer )
5332 palPktFree( pMac->hHdd,
5333 HAL_TXRX_FRM_802_11_MGMT,
5334 (void *) pDelBAIndBuffer,
5335 (void *) pPacket );
5336
5337 return statusCode;
5338}
5339
5340#if defined WLAN_FEATURE_VOWIFI
5341
5342/**
5343 * \brief Send a Neighbor Report Request Action frame
5344 *
5345 *
5346 * \param pMac Pointer to the global MAC structure
5347 *
5348 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5349 *
5350 * \param peer mac address of peer station.
5351 *
5352 * \param psessionEntry address of session entry.
5353 *
5354 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5355 *
5356 *
5357 */
5358
5359tSirRetStatus
5360limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5361 tpSirMacNeighborReportReq pNeighborReq,
5362 tSirMacAddr peer,
5363 tpPESession psessionEntry
5364 )
5365{
5366 tSirRetStatus statusCode = eSIR_SUCCESS;
5367 tDot11fNeighborReportRequest frm;
5368 tANI_U8 *pFrame;
5369 tpSirMacMgmtHdr pMacHdr;
5370 tANI_U32 nBytes, nPayload, nStatus;
5371 void *pPacket;
5372 eHalStatus halstatus;
5373 tANI_U8 txFlag = 0;
5374
5375 if ( psessionEntry == NULL )
5376 {
5377 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame\n") );
5378 return eSIR_FAILURE;
5379 }
5380 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5381
5382 frm.Category.category = SIR_MAC_ACTION_RRM;
5383 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5384 frm.DialogToken.token = pNeighborReq->dialogToken;
5385
5386
5387 if( pNeighborReq->ssid_present )
5388 {
5389 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5390 }
5391
5392 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5393 if ( DOT11F_FAILED( nStatus ) )
5394 {
5395 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5396 "or a Neighbor Report Request(0x%08x).\n"),
5397 nStatus );
5398 // We'll fall back on the worst case scenario:
5399 nPayload = sizeof( tDot11fNeighborReportRequest );
5400 }
5401 else if ( DOT11F_WARNED( nStatus ) )
5402 {
5403 limLog( pMac, LOGW, FL("There were warnings while calculating"
5404 "the packed size for a Neighbor Rep"
5405 "ort Request(0x%08x).\n"), nStatus );
5406 }
5407
5408 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5409
5410 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5411 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5412 {
5413 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
5414 "Report Request.\n"), nBytes );
5415 return eSIR_FAILURE;
5416 }
5417
5418 // Paranoia:
5419 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5420
5421 // Copy necessary info to BD
5422 if( eSIR_SUCCESS !=
5423 (statusCode = limPopulateMacHeader( pMac,
5424 pFrame,
5425 SIR_MAC_MGMT_FRAME,
5426 SIR_MAC_MGMT_ACTION,
5427 peer, psessionEntry->selfMacAddr)))
5428 goto returnAfterError;
5429
5430 // Update A3 with the BSSID
5431 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5432
5433 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5434
5435 // Now, we're ready to "pack" the frames
5436 nStatus = dot11fPackNeighborReportRequest( pMac,
5437 &frm,
5438 pFrame + sizeof( tSirMacMgmtHdr ),
5439 nPayload,
5440 &nPayload );
5441
5442 if( DOT11F_FAILED( nStatus ))
5443 {
5444 limLog( pMac, LOGE,
5445 FL( "Failed to pack an Neighbor Report Request (0x%08x).\n" ),
5446 nStatus );
5447
5448 // FIXME - Need to convert to tSirRetStatus
5449 statusCode = eSIR_FAILURE;
5450 goto returnAfterError;
5451 }
5452 else if( DOT11F_WARNED( nStatus ))
5453 {
5454 limLog( pMac, LOGW,
5455 FL( "There were warnings while packing Neighbor Report Request (0x%08x).\n" ));
5456 }
5457
5458 limLog( pMac, LOGW,
5459 FL( "Sending a Neighbor Report Request to \n" ));
5460 limPrintMacAddr( pMac, peer, LOGW );
5461
5462 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5463#ifdef WLAN_FEATURE_P2P
5464 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5465 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5466#endif
5467 )
5468 {
5469 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5470 }
5471
5472 if( eHAL_STATUS_SUCCESS !=
5473 (halstatus = halTxFrame( pMac,
5474 pPacket,
5475 (tANI_U16) nBytes,
5476 HAL_TXRX_FRM_802_11_MGMT,
5477 ANI_TXDIR_TODS,
5478 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5479 limTxComplete,
5480 pFrame, txFlag )))
5481 {
5482 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5483 statusCode = eSIR_FAILURE;
5484 //Pkt will be freed up by the callback
5485 return statusCode;
5486 }
5487 else
5488 return eSIR_SUCCESS;
5489
5490returnAfterError:
5491 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5492
5493 return statusCode;
5494} // End limSendNeighborReportRequestFrame.
5495
5496/**
5497 * \brief Send a Link Report Action frame
5498 *
5499 *
5500 * \param pMac Pointer to the global MAC structure
5501 *
5502 * \param pLinkReport Address of a tSirMacLinkReport
5503 *
5504 * \param peer mac address of peer station.
5505 *
5506 * \param psessionEntry address of session entry.
5507 *
5508 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5509 *
5510 *
5511 */
5512
5513tSirRetStatus
5514limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5515 tpSirMacLinkReport pLinkReport,
5516 tSirMacAddr peer,
5517 tpPESession psessionEntry
5518 )
5519{
5520 tSirRetStatus statusCode = eSIR_SUCCESS;
5521 tDot11fLinkMeasurementReport frm;
5522 tANI_U8 *pFrame;
5523 tpSirMacMgmtHdr pMacHdr;
5524 tANI_U32 nBytes, nPayload, nStatus;
5525 void *pPacket;
5526 eHalStatus halstatus;
5527 tANI_U8 txFlag = 0;
5528
5529
5530 if ( psessionEntry == NULL )
5531 {
5532 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame\n") );
5533 return eSIR_FAILURE;
5534 }
5535
5536 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5537
5538 frm.Category.category = SIR_MAC_ACTION_RRM;
5539 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5540 frm.DialogToken.token = pLinkReport->dialogToken;
5541
5542
5543 //IEEE Std. 802.11 7.3.2.18. for the report element.
5544 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5545 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5546 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5547 //such case this way than changing the frame parser.
5548 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5549 frm.TPCEleLen.TPCLen = 2;
5550 frm.TxPower.txPower = pLinkReport->txPower;
5551 frm.LinkMargin.linkMargin = 0;
5552
5553 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5554 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5555 frm.RCPI.rcpi = pLinkReport->rcpi;
5556 frm.RSNI.rsni = pLinkReport->rsni;
5557
5558 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5559 if ( DOT11F_FAILED( nStatus ) )
5560 {
5561 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5562 "or a Link Report (0x%08x).\n"),
5563 nStatus );
5564 // We'll fall back on the worst case scenario:
5565 nPayload = sizeof( tDot11fLinkMeasurementReport );
5566 }
5567 else if ( DOT11F_WARNED( nStatus ) )
5568 {
5569 limLog( pMac, LOGW, FL("There were warnings while calculating"
5570 "the packed size for a Link Rep"
5571 "ort (0x%08x).\n"), nStatus );
5572 }
5573
5574 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5575
5576 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5577 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5578 {
5579 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
5580 "Report.\n"), nBytes );
5581 return eSIR_FAILURE;
5582 }
5583
5584 // Paranoia:
5585 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5586
5587 // Copy necessary info to BD
5588 if( eSIR_SUCCESS !=
5589 (statusCode = limPopulateMacHeader( pMac,
5590 pFrame,
5591 SIR_MAC_MGMT_FRAME,
5592 SIR_MAC_MGMT_ACTION,
5593 peer, psessionEntry->selfMacAddr)))
5594 goto returnAfterError;
5595
5596 // Update A3 with the BSSID
5597 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5598
5599 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5600
5601 // Now, we're ready to "pack" the frames
5602 nStatus = dot11fPackLinkMeasurementReport( pMac,
5603 &frm,
5604 pFrame + sizeof( tSirMacMgmtHdr ),
5605 nPayload,
5606 &nPayload );
5607
5608 if( DOT11F_FAILED( nStatus ))
5609 {
5610 limLog( pMac, LOGE,
5611 FL( "Failed to pack an Link Report (0x%08x).\n" ),
5612 nStatus );
5613
5614 // FIXME - Need to convert to tSirRetStatus
5615 statusCode = eSIR_FAILURE;
5616 goto returnAfterError;
5617 }
5618 else if( DOT11F_WARNED( nStatus ))
5619 {
5620 limLog( pMac, LOGW,
5621 FL( "There were warnings while packing Link Report (0x%08x).\n" ));
5622 }
5623
5624 limLog( pMac, LOGW,
5625 FL( "Sending a Link Report to \n" ));
5626 limPrintMacAddr( pMac, peer, LOGW );
5627
5628 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5629#ifdef WLAN_FEATURE_P2P
5630 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5631 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5632#endif
5633 )
5634 {
5635 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5636 }
5637
5638 if( eHAL_STATUS_SUCCESS !=
5639 (halstatus = halTxFrame( pMac,
5640 pPacket,
5641 (tANI_U16) nBytes,
5642 HAL_TXRX_FRM_802_11_MGMT,
5643 ANI_TXDIR_TODS,
5644 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5645 limTxComplete,
5646 pFrame, txFlag )))
5647 {
5648 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5649 statusCode = eSIR_FAILURE;
5650 //Pkt will be freed up by the callback
5651 return statusCode;
5652 }
5653 else
5654 return eSIR_SUCCESS;
5655
5656returnAfterError:
5657 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5658
5659 return statusCode;
5660} // End limSendLinkReportActionFrame.
5661
5662/**
5663 * \brief Send a Beacon Report Action frame
5664 *
5665 *
5666 * \param pMac Pointer to the global MAC structure
5667 *
5668 * \param dialog_token dialog token to be used in the action frame.
5669 *
5670 * \param num_report number of reports in pRRMReport.
5671 *
5672 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5673 *
5674 * \param peer mac address of peer station.
5675 *
5676 * \param psessionEntry address of session entry.
5677 *
5678 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5679 *
5680 *
5681 */
5682
5683tSirRetStatus
5684limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5685 tANI_U8 dialog_token,
5686 tANI_U8 num_report,
5687 tpSirMacRadioMeasureReport pRRMReport,
5688 tSirMacAddr peer,
5689 tpPESession psessionEntry
5690 )
5691{
5692 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 tANI_U8 *pFrame;
5694 tpSirMacMgmtHdr pMacHdr;
5695 tANI_U32 nBytes, nPayload, nStatus;
5696 void *pPacket;
5697 eHalStatus halstatus;
5698 tANI_U8 i;
5699 tANI_U8 txFlag = 0;
5700
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005701 tDot11fRadioMeasurementReport *frm =
5702 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5703 if (!frm) {
5704 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport\n") );
5705 return eSIR_FAILURE;
5706 }
5707
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 if ( psessionEntry == NULL )
5709 {
5710 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame\n") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005711 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 return eSIR_FAILURE;
5713 }
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005714 palZeroMemory( pMac->hHdd, ( tANI_U8* )frm, sizeof( *frm ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005715
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005716 frm->Category.category = SIR_MAC_ACTION_RRM;
5717 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5718 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005719
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005720 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 -07005721
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005722 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005724 frm->MeasurementReport[i].type = pRRMReport[i].type;
5725 frm->MeasurementReport[i].token = pRRMReport[i].token;
5726 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 switch( pRRMReport[i].type )
5728 {
5729 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005730 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5731 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5732 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5733 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005734 break;
5735 default:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005736 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 break;
5738 }
5739 }
5740
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005741 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 if ( DOT11F_FAILED( nStatus ) )
5743 {
5744 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5745 "or a Radio Measure Report (0x%08x).\n"),
5746 nStatus );
5747 // We'll fall back on the worst case scenario:
5748 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005749 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 return eSIR_FAILURE;
5751 }
5752 else if ( DOT11F_WARNED( nStatus ) )
5753 {
5754 limLog( pMac, LOGW, FL("There were warnings while calculating"
5755 "the packed size for a Radio Measure Rep"
5756 "ort (0x%08x).\n"), nStatus );
5757 }
5758
5759 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5760
5761 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5762 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5763 {
5764 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
5765 "Report.\n"), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005766 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 return eSIR_FAILURE;
5768 }
5769
5770 // Paranoia:
5771 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5772
5773 // Copy necessary info to BD
5774 if( eSIR_SUCCESS !=
5775 (statusCode = limPopulateMacHeader( pMac,
5776 pFrame,
5777 SIR_MAC_MGMT_FRAME,
5778 SIR_MAC_MGMT_ACTION,
5779 peer, psessionEntry->selfMacAddr)))
5780 goto returnAfterError;
5781
5782 // Update A3 with the BSSID
5783 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5784
5785 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5786
5787 // Now, we're ready to "pack" the frames
5788 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005789 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 pFrame + sizeof( tSirMacMgmtHdr ),
5791 nPayload,
5792 &nPayload );
5793
5794 if( DOT11F_FAILED( nStatus ))
5795 {
5796 limLog( pMac, LOGE,
5797 FL( "Failed to pack an Radio Measure Report (0x%08x).\n" ),
5798 nStatus );
5799
5800 // FIXME - Need to convert to tSirRetStatus
5801 statusCode = eSIR_FAILURE;
5802 goto returnAfterError;
5803 }
5804 else if( DOT11F_WARNED( nStatus ))
5805 {
5806 limLog( pMac, LOGW,
5807 FL( "There were warnings while packing Radio Measure Report (0x%08x).\n" ));
5808 }
5809
5810 limLog( pMac, LOGW,
5811 FL( "Sending a Radio Measure Report to \n" ));
5812 limPrintMacAddr( pMac, peer, LOGW );
5813
5814 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5815#ifdef WLAN_FEATURE_P2P
5816 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5817 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5818#endif
5819 )
5820 {
5821 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5822 }
5823
5824 if( eHAL_STATUS_SUCCESS !=
5825 (halstatus = halTxFrame( pMac,
5826 pPacket,
5827 (tANI_U16) nBytes,
5828 HAL_TXRX_FRM_802_11_MGMT,
5829 ANI_TXDIR_TODS,
5830 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5831 limTxComplete,
5832 pFrame, txFlag )))
5833 {
5834 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5835 statusCode = eSIR_FAILURE;
5836 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005837 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 return statusCode;
5839 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005840 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005841 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005844
5845returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005846 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 return statusCode;
5849} // End limSendBeaconReportActionFrame.
5850
5851#endif
5852
5853#ifdef WLAN_FEATURE_11W
5854/**
5855 * \brief Send SA query response action frame to peer
5856 *
5857 * \sa limSendSaQueryResponseFrame
5858 *
5859 *
5860 * \param pMac The global tpAniSirGlobal object
5861 *
5862 * \param peer The Mac address of the AP to which this action frame is
5863addressed
5864 *
5865 * \param transId Transaction identifier received in SA query request action
5866frame
5867 *
5868 * \return eSIR_SUCCESS if setup completes successfully
5869 * eSIR_FAILURE is some problem is encountered
5870 */
5871
5872tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U16 transId,
5873tSirMacAddr peer,tpPESession psessionEntry)
5874{
5875
5876 tDot11wSaQueryRsp frm; // SA query reponse action frame
5877 tANI_U8 *pFrame;
5878 tSirRetStatus nSirStatus;
5879 tpSirMacMgmtHdr pMacHdr;
5880 tANI_U32 nBytes, nPayload;
5881 void *pPacket;
5882 eHalStatus halstatus;
5883 // Local variables used to dump prepared SA query response frame
5884 tANI_U8 *pDump;
5885 tANI_U16 dumpCount;
5886 tANI_U8 txFlag = 0;
5887 //tANI_U16 nBytes
5888
5889 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5890 frm.category = SIR_MAC_ACTION_SA_QUERY;
5891 /*11w action fiedl is :
5892 action: 0 --> SA query request action frame
5893 action: 1 --> SA query response action frame */
5894 frm.action = 1;
5895 /*11w Draft9.0 SA query response transId is same as
5896 SA query request transId*/
5897 frm.transId = transId;
5898
5899 nPayload = sizeof(tDot11wSaQueryRsp);
5900 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5901 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5902 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5903 {
5904 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
5905 " action frame\n"), nBytes );
5906 return eSIR_FAILURE;
5907 }
5908
5909 // Paranoia:
5910 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5911
5912 // Next, we fill out the buffer descriptor:
5913 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5914 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr );
5915 if ( eSIR_SUCCESS != nSirStatus )
5916 {
5917 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
5918 "tor for a TPC Report (%d).\n"),
5919 nSirStatus );
5920 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5921 return eSIR_FAILURE; // just allocated...
5922 }
5923
5924 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5925
5926 // Pack 11w SA query response frame
5927 DOT11F_MEMCPY(pMac, (tANI_U8 *)(pFrame + sizeof(tSirMacMgmtHdr)),(tANI_U8 *)&frm, nPayload);
5928 pDump = (tANI_U8 *) pFrame;
5929
5930 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5931 HAL_TXRX_FRM_802_11_MGMT,
5932 ANI_TXDIR_TODS,
5933 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5934 limTxComplete, pFrame,txFlag);
5935 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5936 {
5937 limLog( pMac, LOGE, FL("Failed to send a SA Query resp frame "
5938 "(%X)!\n"),halstatus );
5939 //Pkt will be freed up by the callback
5940 return eSIR_FAILURE; // just allocated...
5941 }
5942
5943 return eSIR_SUCCESS;
5944}
5945#endif