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