blob: 3a376a3865f82b0a1a82dd8dd0c40ab527e92535 [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
2589 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2590 HAL_TXRX_FRM_802_11_MGMT,
2591 ANI_TXDIR_TODS,
2592 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2593 limTxComplete, pFrame, txFlag );
2594 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2595 {
2596 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!\n"),
2597 halstatus );
2598 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002599 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 return;
2601 }
2602
2603 // Free up buffer allocated for mlmAssocReq
2604 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmAssocReq );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002605 palFreeMemory(pMac->hHdd, pFrm);
2606 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002607} // End limSendAssocReqMgmtFrame
2608
2609
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002610#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002611/*------------------------------------------------------------------------------------
2612 *
2613 * Send Reassoc Req with FTIEs.
2614 *
2615 *-----------------------------------------------------------------------------------
2616 */
2617void
2618limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2619 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2620{
2621 static tDot11fReAssocRequest frm;
2622 tANI_U16 caps;
2623 tANI_U8 *pFrame;
2624 tSirRetStatus nSirStatus;
2625 tANI_U32 nBytes, nPayload, nStatus;
2626 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2627 void *pPacket;
2628 eHalStatus halstatus;
2629#if defined WLAN_FEATURE_VOWIFI
2630 tANI_U8 PowerCapsPopulated = FALSE;
2631#endif
2632 tANI_U16 ft_ies_length = 0;
2633 tANI_U8 *pBody;
2634 tANI_U16 nAddIELen;
2635 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002636#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 tANI_U8 *wpsIe = NULL;
2638#endif
2639 tANI_U8 txFlag = 0;
2640
2641 if (NULL == psessionEntry)
2642 {
2643 return;
2644 }
2645
2646#if defined WLAN_FEATURE_VOWIFI_11R
2647 if (psessionEntry->is11Rconnection)
2648 {
2649 if (pMac->ft.ftSmeContext.reassoc_ft_ies_length == 0)
2650 {
2651 return;
2652 }
2653 }
2654#endif
2655
2656 /* check this early to avoid unncessary operation */
2657 if(NULL == psessionEntry->pLimReAssocReq)
2658 {
2659 return;
2660 }
2661 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2662 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2663 limLog( pMac, LOGE, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2664 "state (%d).\n"), psessionEntry->limMlmState);
2665
2666 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
2667
2668 caps = pMlmReassocReq->capabilityInfo;
2669 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2670 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2671#if defined(FEATURE_WLAN_WAPI)
2672 /* CR: 262463 :
2673 According to WAPI standard:
2674 7.3.1.4 Capability Information field
2675 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2676 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2677 Reassociation management frames. */
2678 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2679 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2680#endif
2681 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2682
2683 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2684
2685 // Get the old bssid of the older AP.
2686 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
2687 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2688
2689 PopulateDot11fSSID2( pMac, &frm.SSID );
2690 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2691 &frm.SuppRates,psessionEntry);
2692
2693 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2694 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2695
2696 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2697 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2698
2699 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2700 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2701
2702 if ( psessionEntry->lim11hEnable &&
2703 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2704 {
2705#if defined WLAN_FEATURE_VOWIFI
2706 PowerCapsPopulated = TRUE;
2707
2708 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2709 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2710#endif
2711 }
2712
2713#if defined WLAN_FEATURE_VOWIFI
2714 if( pMac->rrm.rrmPEContext.rrmEnable &&
2715 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2716 {
2717 if (PowerCapsPopulated == FALSE)
2718 {
2719 PowerCapsPopulated = TRUE;
2720 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2721 }
2722 }
2723#endif
2724
2725 if ( fQosEnabled &&
2726 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2727 {
2728 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2729 }
2730
2731 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2732 &frm.ExtSuppRates, psessionEntry );
2733
2734#if defined WLAN_FEATURE_VOWIFI
2735 if( pMac->rrm.rrmPEContext.rrmEnable &&
2736 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2737 {
2738 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2739 }
2740#endif
2741
2742 // Ideally this should be enabled for 11r also. But 11r does
2743 // not follow the usual norm of using the Opaque object
2744 // for rsnie and fties. Instead we just add
2745 // the rsnie and fties at the end of the pack routine for 11r.
2746 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002747#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 //
2749 // The join request *should* contain zero or one of the WPA and RSN
2750 // IEs. The payload send along with the request is a
2751 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2752
2753 // typedef struct sSirRSNie
2754 // {
2755 // tANI_U16 length;
2756 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2757 // } tSirRSNie, *tpSirRSNie;
2758
2759 // So, we should be able to make the following two calls harmlessly,
2760 // since they do nothing if they don't find the given IE in the
2761 // bytestream with which they're provided.
2762
2763 // The net effect of this will be to faithfully transmit whatever
2764 // security IE is in the join request.
2765
2766 // *However*, if we're associating for the purpose of WPS
2767 // enrollment, and we've been configured to indicate that by
2768 // eliding the WPA or RSN IE, we just skip this:
2769 if (!psessionEntry->is11Rconnection)
2770 {
2771 if( nAddIELen && pAddIE )
2772 {
2773 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2774 }
2775 if ( NULL == wpsIe )
2776 {
2777 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2778 &frm.RSNOpaque );
2779 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2780 &frm.WPAOpaque );
2781 }
2782
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002783#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 if(psessionEntry->pLimReAssocReq->cckmIE.length)
2785 {
2786 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2787 &frm.CCXCckmOpaque );
2788 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002789#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 }
2791
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002792#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 // For CCX Associations fill the CCX IEs
2794 if (psessionEntry->isCCXconnection)
2795 {
2796 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
2797 PopulateDot11fCCXVersion(&frm.CCXVersion);
2798 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002799#endif //FEATURE_WLAN_CCX
2800#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002801
2802 // include WME EDCA IE as well
2803 if ( fWmeEnabled )
2804 {
2805 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2806 {
2807 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2808 }
2809
2810 if ( fWsmEnabled &&
2811 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2812 {
2813 PopulateDot11fWMMCaps( &frm.WMMCaps );
2814 }
2815#ifdef FEATURE_WLAN_CCX
2816 if (psessionEntry->isCCXconnection)
2817 {
2818 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2819
2820 // Populate the TSRS IE if TSPEC is included in the reassoc request
2821 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2822 {
2823 tANI_U32 phyMode;
2824 tSirMacCCXTSRSIE tsrsIE;
2825 limGetPhyMode(pMac, &phyMode, psessionEntry);
2826
2827 tsrsIE.tsid = 0;
2828 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2829 {
2830 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2831 }
2832 else
2833 {
2834 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2835 }
2836 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2837 }
2838 }
2839#endif
2840 }
2841
Jeff Johnsone7245742012-09-05 17:12:55 -07002842 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002843 pMac->lim.htCapabilityPresentInBeacon)
2844 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002845 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 }
2847
2848 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2849 if ( DOT11F_FAILED( nStatus ) )
2850 {
2851 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
2852 "or a Re-Association Request (0x%08x).\n"),
2853 nStatus );
2854 // We'll fall back on the worst case scenario:
2855 nPayload = sizeof( tDot11fReAssocRequest );
2856 }
2857 else if ( DOT11F_WARNED( nStatus ) )
2858 {
2859 limLog( pMac, LOGW, FL("There were warnings while calculating"
2860 "the packed size for a Re-Association Re "
2861 "quest(0x%08x).\n"), nStatus );
2862 }
2863
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002864 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002865
2866#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
2867 limLog( pMac, LOGE, FL("FT IE Reassoc Req (%d).\n"),
2868 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2869#endif
2870
2871#if defined WLAN_FEATURE_VOWIFI_11R
2872 if (psessionEntry->is11Rconnection)
2873 {
2874 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2875 }
2876#endif
2877
2878 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2879 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2880 ( void** ) &pPacket );
2881 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2882 {
2883 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002884 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
2886 "sociation Request.\n"), nBytes );
2887 goto end;
2888 }
2889
2890 // Paranoia:
2891 palZeroMemory( pMac->hHdd, pFrame, nBytes + ft_ies_length);
2892
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002893#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOGE);
2895#endif
2896 // Next, we fill out the buffer descriptor:
2897 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2898 SIR_MAC_MGMT_REASSOC_REQ,
2899 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2900 if ( eSIR_SUCCESS != nSirStatus )
2901 {
2902 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
2903 "tor for an Association Request (%d).\n"),
2904 nSirStatus );
2905 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2906 goto end;
2907 }
2908
2909
2910 // That done, pack the ReAssoc Request:
2911 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2912 sizeof(tSirMacMgmtHdr),
2913 nPayload, &nPayload );
2914 if ( DOT11F_FAILED( nStatus ) )
2915 {
2916 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
2917 "st (0x%08x).\n"),
2918 nStatus );
2919 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2920 goto end;
2921 }
2922 else if ( DOT11F_WARNED( nStatus ) )
2923 {
2924 limLog( pMac, LOGW, FL("There were warnings while packing a R"
2925 "e-Association Request (0x%08x).\n") );
2926 }
2927
2928 PELOG3(limLog( pMac, LOG3,
2929 FL("*** Sending Re-Association Request length %d %d to \n"),
2930 nBytes, nPayload );)
2931 if( psessionEntry->assocReq != NULL )
2932 {
2933 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2934 psessionEntry->assocReq = NULL;
2935 }
2936
2937 if( nAddIELen )
2938 {
2939 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2940 pAddIE,
2941 nAddIELen );
2942 nPayload += nAddIELen;
2943 }
2944
Jeff Johnson43971f52012-07-17 12:26:56 -07002945 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2946 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 {
2948 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002949 }
2950 else
2951 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2953 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2954 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002956
2957 if (psessionEntry->is11Rconnection)
2958 {
2959 {
2960 int i = 0;
2961
2962 pBody = pFrame + nBytes;
2963 for (i=0; i<ft_ies_length; i++)
2964 {
2965 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2966 pBody++;
2967 }
2968 }
2969 }
2970
2971#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
2972 PELOGE(limLog(pMac, LOGE, FL("Re-assoc Req Frame is: "));
2973 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
2974 (tANI_U8 *)pFrame,
2975 (nBytes + ft_ies_length));)
2976#endif
2977
2978
2979 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
2980#ifdef WLAN_FEATURE_P2P
2981 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2982 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
2983#endif
2984 )
2985 {
2986 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2987 }
2988
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002989 if( NULL != psessionEntry->assocReq )
2990 {
2991 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2992 psessionEntry->assocReq = NULL;
2993 }
2994
2995 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2996 (ft_ies_length))) != eHAL_STATUS_SUCCESS )
2997 {
2998 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2999 }
3000 else
3001 {
3002 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3003 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3004 (ft_ies_length));
3005 psessionEntry->assocReqLen = (ft_ies_length);
3006 }
3007
3008
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3010 HAL_TXRX_FRM_802_11_MGMT,
3011 ANI_TXDIR_TODS,
3012 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3013 limTxComplete, pFrame, txFlag );
3014 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3015 {
3016 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
3017 "(%X)!\n"),
3018 nSirStatus );
3019 //Pkt will be freed up by the callback
3020 goto end;
3021 }
3022
3023end:
3024 // Free up buffer allocated for mlmAssocReq
3025 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3026 psessionEntry->pLimMlmReassocReq = NULL;
3027
3028}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003029
3030void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3031 tLimMlmReassocReq *pMlmReassocReq,
3032 tpPESession psessionEntry)
3033{
3034 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3035 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3036 if(NULL == pTmpMlmReassocReq)
3037 {
3038 if ( !HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pTmpMlmReassocReq, sizeof(tLimMlmReassocReq))) ) goto end;
3039 palZeroMemory(pMac->hHdd, pTmpMlmReassocReq, sizeof(tLimMlmReassocReq));
3040 palCopyMemory( pMac->hHdd, pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
3041 }
3042
3043 // Prepare and send Reassociation request frame
3044 // start reassoc timer.
3045 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3046 // Start reassociation failure timer
3047 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0, eLIM_REASSOC_FAIL_TIMER));
3048 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3049 != TX_SUCCESS)
3050 {
3051 // Could not start reassoc failure timer.
3052 // Log error
3053 limLog(pMac, LOGP,
3054 FL("could not start Reassociation failure timer\n"));
3055 // Return Reassoc confirm with
3056 // Resources Unavailable
3057 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3058 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3059 goto end;
3060 }
3061
3062 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3063 return;
3064
3065end:
3066 // Free up buffer allocated for reassocReq
3067 if (pMlmReassocReq != NULL)
3068 {
3069 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
3070 pMlmReassocReq = NULL;
3071 }
3072 if (pTmpMlmReassocReq != NULL)
3073 {
3074 palFreeMemory( pMac->hHdd, (tANI_U8 *) pTmpMlmReassocReq);
3075 pTmpMlmReassocReq = NULL;
3076 }
3077 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3078 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3079 /* Update PE sessio Id*/
3080 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3081
3082 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3083}
3084
Jeff Johnson295189b2012-06-20 16:38:30 -07003085#endif /* WLAN_FEATURE_VOWIFI_11R */
3086
3087
3088void
3089limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3090 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3091{
3092 static tDot11fReAssocRequest frm;
3093 tANI_U16 caps;
3094 tANI_U8 *pFrame;
3095 tSirRetStatus nSirStatus;
3096 tANI_U32 nBytes, nPayload, nStatus;
3097 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3098 void *pPacket;
3099 eHalStatus halstatus;
3100 tANI_U16 nAddIELen;
3101 tANI_U8 *pAddIE;
3102 tANI_U8 *wpsIe = NULL;
3103 tANI_U8 txFlag = 0;
3104#if defined WLAN_FEATURE_VOWIFI
3105 tANI_U8 PowerCapsPopulated = FALSE;
3106#endif
3107
3108 if(NULL == psessionEntry)
3109 {
3110 return;
3111 }
3112
3113 /* check this early to avoid unncessary operation */
3114 if(NULL == psessionEntry->pLimReAssocReq)
3115 {
3116 return;
3117 }
3118 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3119 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3120
3121 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3122
3123 caps = pMlmReassocReq->capabilityInfo;
3124 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3125 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3126#if defined(FEATURE_WLAN_WAPI)
3127 /* CR: 262463 :
3128 According to WAPI standard:
3129 7.3.1.4 Capability Information field
3130 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3131 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3132 Reassociation management frames. */
3133 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3134 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3135#endif
3136 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3137
3138 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3139
3140 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
3141 ( tANI_U8* )psessionEntry->bssId, 6 );
3142
3143 PopulateDot11fSSID2( pMac, &frm.SSID );
3144 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3145 &frm.SuppRates,psessionEntry);
3146
3147 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3148 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3149
3150 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3151 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3152
3153 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3154 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3155
3156
3157 if ( psessionEntry->lim11hEnable &&
3158 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3159 {
3160#if defined WLAN_FEATURE_VOWIFI
3161 PowerCapsPopulated = TRUE;
3162 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3163 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3164#endif
3165 }
3166
3167#if defined WLAN_FEATURE_VOWIFI
3168 if( pMac->rrm.rrmPEContext.rrmEnable &&
3169 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3170 {
3171 if (PowerCapsPopulated == FALSE)
3172 {
3173 PowerCapsPopulated = TRUE;
3174 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3175 }
3176 }
3177#endif
3178
3179 if ( fQosEnabled &&
3180 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3181 {
3182 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3183 }
3184
3185 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3186 &frm.ExtSuppRates, psessionEntry );
3187
3188#if defined WLAN_FEATURE_VOWIFI
3189 if( pMac->rrm.rrmPEContext.rrmEnable &&
3190 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3191 {
3192 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3193 }
3194#endif
3195 // The join request *should* contain zero or one of the WPA and RSN
3196 // IEs. The payload send along with the request is a
3197 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3198
3199 // typedef struct sSirRSNie
3200 // {
3201 // tANI_U16 length;
3202 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3203 // } tSirRSNie, *tpSirRSNie;
3204
3205 // So, we should be able to make the following two calls harmlessly,
3206 // since they do nothing if they don't find the given IE in the
3207 // bytestream with which they're provided.
3208
3209 // The net effect of this will be to faithfully transmit whatever
3210 // security IE is in the join request.
3211
3212 // *However*, if we're associating for the purpose of WPS
3213 // enrollment, and we've been configured to indicate that by
3214 // eliding the WPA or RSN IE, we just skip this:
3215 if( nAddIELen && pAddIE )
3216 {
3217 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3218 }
3219 if ( NULL == wpsIe )
3220 {
3221 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3222 &frm.RSNOpaque );
3223 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3224 &frm.WPAOpaque );
3225#if defined(FEATURE_WLAN_WAPI)
3226 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3227 &frm.WAPIOpaque );
3228#endif // defined(FEATURE_WLAN_WAPI)
3229 }
3230
3231 // include WME EDCA IE as well
3232 if ( fWmeEnabled )
3233 {
3234 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3235 {
3236 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3237 }
3238
3239 if ( fWsmEnabled &&
3240 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3241 {
3242 PopulateDot11fWMMCaps( &frm.WMMCaps );
3243 }
3244 }
3245
Jeff Johnsone7245742012-09-05 17:12:55 -07003246 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 pMac->lim.htCapabilityPresentInBeacon)
3248 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003249 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003251#ifdef WLAN_FEATURE_11AC
3252 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003253 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003254 {
3255 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request\n"));
3256 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07003257 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003258 }
3259#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003260
3261 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3262 if ( DOT11F_FAILED( nStatus ) )
3263 {
3264 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3265 "or a Re-Association Request (0x%08x).\n"),
3266 nStatus );
3267 // We'll fall back on the worst case scenario:
3268 nPayload = sizeof( tDot11fReAssocRequest );
3269 }
3270 else if ( DOT11F_WARNED( nStatus ) )
3271 {
3272 limLog( pMac, LOGW, FL("There were warnings while calculating"
3273 "the packed size for a Re-Association Re "
3274 "quest(0x%08x).\n"), nStatus );
3275 }
3276
3277 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3278
3279 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3280 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3281 ( void** ) &pPacket );
3282 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3283 {
3284 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003285 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
3287 "sociation Request.\n"), nBytes );
3288 goto end;
3289 }
3290
3291 // Paranoia:
3292 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3293
3294 // Next, we fill out the buffer descriptor:
3295 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3296 SIR_MAC_MGMT_REASSOC_REQ,
3297 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3298 if ( eSIR_SUCCESS != nSirStatus )
3299 {
3300 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3301 "tor for an Association Request (%d).\n"),
3302 nSirStatus );
3303 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3304 goto end;
3305 }
3306
3307
3308 // That done, pack the Probe Request:
3309 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3310 sizeof(tSirMacMgmtHdr),
3311 nPayload, &nPayload );
3312 if ( DOT11F_FAILED( nStatus ) )
3313 {
3314 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
3315 "st (0x%08x).\n"),
3316 nStatus );
3317 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3318 goto end;
3319 }
3320 else if ( DOT11F_WARNED( nStatus ) )
3321 {
3322 limLog( pMac, LOGW, FL("There were warnings while packing a R"
3323 "e-Association Request (0x%08x).\n") );
3324 }
3325
3326 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
3327 "to \n"),
3328 nBytes );)
3329
3330 if( psessionEntry->assocReq != NULL )
3331 {
3332 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
3333 psessionEntry->assocReq = NULL;
3334 }
3335
3336 if( nAddIELen )
3337 {
3338 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3339 pAddIE,
3340 nAddIELen );
3341 nPayload += nAddIELen;
3342 }
3343
Jeff Johnson43971f52012-07-17 12:26:56 -07003344 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
3345 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 {
3347 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003348 }
3349 else
3350 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3352 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
3353 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003355
3356 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3357#ifdef WLAN_FEATURE_P2P
3358 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3359 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3360#endif
3361 )
3362 {
3363 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3364 }
3365
3366 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3367 HAL_TXRX_FRM_802_11_MGMT,
3368 ANI_TXDIR_TODS,
3369 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3370 limTxComplete, pFrame, txFlag );
3371 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3372 {
3373 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
3374 "(%X)!\n"),
3375 nSirStatus );
3376 //Pkt will be freed up by the callback
3377 goto end;
3378 }
3379
3380end:
3381 // Free up buffer allocated for mlmAssocReq
3382 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3383 psessionEntry->pLimMlmReassocReq = NULL;
3384
3385} // limSendReassocReqMgmtFrame
3386
3387/**
3388 * \brief Send an Authentication frame
3389 *
3390 *
3391 * \param pMac Pointer to Global MAC structure
3392 *
3393 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3394 * to be sent
3395 *
3396 * \param peerMacAddr MAC address of the peer entity to which Authentication
3397 * frame is destined
3398 *
3399 * \param wepBit Indicates whether wep bit to be set in FC while sending
3400 * Authentication frame3
3401 *
3402 *
3403 * This function is called by limProcessMlmMessages(). Authentication frame
3404 * is formatted and sent when this function is called.
3405 *
3406 *
3407 */
3408
3409void
3410limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3411 tpSirMacAuthFrameBody pAuthFrameBody,
3412 tSirMacAddr peerMacAddr,
3413 tANI_U8 wepBit,
3414 tpPESession psessionEntry
3415 )
3416{
3417 tANI_U8 *pFrame, *pBody;
3418 tANI_U32 frameLen = 0, bodyLen = 0;
3419 tpSirMacMgmtHdr pMacHdr;
3420 tANI_U16 i;
3421 void *pPacket;
3422 eHalStatus halstatus;
3423 tANI_U8 txFlag = 0;
3424
3425 if(NULL == psessionEntry)
3426 {
3427 return;
3428 }
3429
3430 if (wepBit == LIM_WEP_IN_FC)
3431 {
3432 /// Auth frame3 to be sent with encrypted framebody
3433 /**
3434 * Allocate buffer for Authenticaton frame of size equal
3435 * to management frame header length plus 2 bytes each for
3436 * auth algorithm number, transaction number, status code,
3437 * 128 bytes for challenge text and 4 bytes each for
3438 * IV & ICV.
3439 */
3440
3441 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3442
3443 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3444 } // if (wepBit == LIM_WEP_IN_FC)
3445 else
3446 {
3447 switch (pAuthFrameBody->authTransactionSeqNumber)
3448 {
3449 case SIR_MAC_AUTH_FRAME_1:
3450 /**
3451 * Allocate buffer for Authenticaton frame of size
3452 * equal to management frame header length plus 2 bytes
3453 * each for auth algorithm number, transaction number
3454 * and status code.
3455 */
3456
3457 frameLen = sizeof(tSirMacMgmtHdr) +
3458 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3459 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3460
3461#if defined WLAN_FEATURE_VOWIFI_11R
3462 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3463 {
3464 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies)
3465 {
3466 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
3467 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d\n"),
3468 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
3469 }
3470 else
3471 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!\n"));
3472 }
3473#endif
3474 break;
3475
3476 case SIR_MAC_AUTH_FRAME_2:
3477 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3478 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3479 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3480 {
3481 /**
3482 * Allocate buffer for Authenticaton frame of size
3483 * equal to management frame header length plus
3484 * 2 bytes each for auth algorithm number,
3485 * transaction number and status code.
3486 */
3487
3488 frameLen = sizeof(tSirMacMgmtHdr) +
3489 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3490 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3491 }
3492 else
3493 {
3494 // Shared Key algorithm with challenge text
3495 // to be sent
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, status code and 128 bytes
3501 * for challenge text.
3502 */
3503
3504 frameLen = sizeof(tSirMacMgmtHdr) +
3505 sizeof(tSirMacAuthFrame);
3506 bodyLen = sizeof(tSirMacAuthFrameBody);
3507 }
3508
3509 break;
3510
3511 case SIR_MAC_AUTH_FRAME_3:
3512 /// Auth frame3 to be sent without encrypted framebody
3513 /**
3514 * Allocate buffer for Authenticaton frame of size equal
3515 * to management frame header length plus 2 bytes each
3516 * for auth algorithm number, transaction number and
3517 * status code.
3518 */
3519
3520 frameLen = sizeof(tSirMacMgmtHdr) +
3521 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3522 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3523
3524 break;
3525
3526 case SIR_MAC_AUTH_FRAME_4:
3527 /**
3528 * Allocate buffer for Authenticaton frame of size equal
3529 * to management frame header length plus 2 bytes each
3530 * for auth algorithm number, transaction number and
3531 * status code.
3532 */
3533
3534 frameLen = sizeof(tSirMacMgmtHdr) +
3535 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3536 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3537
3538 break;
3539 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3540 } // end if (wepBit == LIM_WEP_IN_FC)
3541
3542
3543 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3544
3545 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3546 {
3547 // Log error
3548 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame\n"));
3549
3550 return;
3551 }
3552
3553 for (i = 0; i < frameLen; i++)
3554 pFrame[i] = 0;
3555
3556 // Prepare BD
3557 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3558 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3559 {
3560 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3561 return;
3562 }
3563
3564 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3565 pMacHdr->fc.wep = wepBit;
3566
3567 // Prepare BSSId
3568 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3569 {
3570 palCopyMemory( pMac->hHdd,(tANI_U8 *) pMacHdr->bssId,
3571 (tANI_U8 *) psessionEntry->bssId,
3572 sizeof( tSirMacAddr ));
3573 }
3574
3575 /// Prepare Authentication frame body
3576 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3577
3578 if (wepBit == LIM_WEP_IN_FC)
3579 {
3580 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
3581
3582 PELOG1(limLog(pMac, LOG1,
3583 FL("*** Sending Auth seq# 3 status %d (%d) to\n"),
3584 pAuthFrameBody->authStatusCode,
3585 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3586
3587 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3588 }
3589 else
3590 {
3591 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3592 pBody += sizeof(tANI_U16);
3593 bodyLen -= sizeof(tANI_U16);
3594
3595 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3596 pBody += sizeof(tANI_U16);
3597 bodyLen -= sizeof(tANI_U16);
3598
3599 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3600 pBody += sizeof(tANI_U16);
3601 bodyLen -= sizeof(tANI_U16);
3602
3603 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
3604
3605#if defined WLAN_FEATURE_VOWIFI_11R
3606 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3607 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3608 {
3609
3610 {
3611 int i = 0;
3612#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
3613 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3614 {
3615 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3616 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3617 (tANI_U8 *)pBody,
3618 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
3619 }
3620#endif
3621 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3622 {
3623 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3624 pBody++;
3625 }
3626 }
3627 }
3628#endif
3629
3630 PELOG1(limLog(pMac, LOG1,
3631 FL("*** Sending Auth seq# %d status %d (%d) to "),
3632 pAuthFrameBody->authTransactionSeqNumber,
3633 pAuthFrameBody->authStatusCode,
3634 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3635
3636 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3637 }
3638 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3639
3640 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3641#ifdef WLAN_FEATURE_P2P
3642 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3643 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3644#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003645#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
3646 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
3647 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3648#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 )
3650 {
3651 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3652 }
3653
3654 /// Queue Authentication frame in high priority WQ
3655 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3656 HAL_TXRX_FRM_802_11_MGMT,
3657 ANI_TXDIR_TODS,
3658 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3659 limTxComplete, pFrame, txFlag );
3660 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3661 {
3662 limLog(pMac, LOGE,
3663 FL("*** Could not send Auth frame, retCode=%X ***\n"),
3664 halstatus);
3665
3666 //Pkt will be freed up by the callback
3667 }
3668
3669 return;
3670} /*** end limSendAuthMgmtFrame() ***/
3671
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003672eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3673{
3674 tANI_U16 aid;
3675 tpDphHashNode pStaDs;
3676 tLimMlmDeauthReq *pMlmDeauthReq;
3677 tLimMlmDeauthCnf mlmDeauthCnf;
3678 tpPESession psessionEntry;
3679
3680 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3681 if (pMlmDeauthReq)
3682 {
3683 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3684 {
3685 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3686 }
3687
3688 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3689 {
3690
3691 PELOGE(limLog(pMac, LOGE,
3692 FL("session does not exist for given sessionId\n"));)
3693 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3694 goto end;
3695 }
3696
3697 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3698 if (pStaDs == NULL)
3699 {
3700 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3701 goto end;
3702 }
3703
3704
3705 /// Receive path cleanup with dummy packet
3706 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3707 /// Free up buffer allocated for mlmDeauthReq
3708 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3709 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3710 }
3711 return eHAL_STATUS_SUCCESS;
3712end:
3713 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3714 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3715 sizeof(tSirMacAddr));
3716 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3717 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3718 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3719
3720 // Free up buffer allocated
3721 // for mlmDeauthReq
3722 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3723
3724 limPostSmeMessage(pMac,
3725 LIM_MLM_DEAUTH_CNF,
3726 (tANI_U32 *) &mlmDeauthCnf);
3727 return eHAL_STATUS_SUCCESS;
3728}
3729
3730eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3731{
3732 tANI_U16 aid;
3733 tpDphHashNode pStaDs;
3734 tLimMlmDisassocCnf mlmDisassocCnf;
3735 tpPESession psessionEntry;
3736 tLimMlmDisassocReq *pMlmDisassocReq;
3737
3738 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3739 if (pMlmDisassocReq)
3740 {
3741 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3742 {
3743 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3744 }
3745
3746 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3747 {
3748
3749 PELOGE(limLog(pMac, LOGE,
3750 FL("session does not exist for given sessionId\n"));)
3751 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3752 goto end;
3753 }
3754
3755 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3756 if (pStaDs == NULL)
3757 {
3758 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3759 goto end;
3760 }
3761
3762 /// Receive path cleanup with dummy packet
3763 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3764 {
3765 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3766 goto end;
3767 }
3768
3769#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003770 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3771 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003772#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003773 (psessionEntry->isCCXconnection ) ||
3774#endif
3775#ifdef FEATURE_WLAN_LFR
3776 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003777#endif
3778 (psessionEntry->is11Rconnection )) &&
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003779 (pMlmDisassocReq->reasonCode !=
3780 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003781 {
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003782 PELOGE(limLog(pMac, LOGE,
3783 FL("FT Preauth Session (%p,%d) Cleanup\n"),
3784 psessionEntry, psessionEntry->peSessionId););
3785 limFTCleanup(pMac);
3786 }
3787 else
3788 {
3789 PELOGE(limLog(pMac, LOGE,
3790 FL("No FT Preauth Session Cleanup in role %d"
3791#ifdef FEATURE_WLAN_CCX
3792 " isCCX %d"
3793#endif
3794#ifdef FEATURE_WLAN_LFR
3795 " isLFR %d"
3796#endif
3797 " is11r %d reason %d\n"),
3798 psessionEntry->limSystemRole,
3799#ifdef FEATURE_WLAN_CCX
3800 psessionEntry->isCCXconnection,
3801#endif
3802#ifdef FEATURE_WLAN_LFR
3803 psessionEntry->isFastRoamIniFeatureEnabled,
3804#endif
3805 psessionEntry->is11Rconnection,
3806 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003807 }
3808#endif
3809
3810 /// Free up buffer allocated for mlmDisassocReq
3811 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3812 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3813 return eHAL_STATUS_SUCCESS;
3814 }
3815 else
3816 {
3817 return eHAL_STATUS_SUCCESS;
3818 }
3819end:
3820 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
3821 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3822 sizeof(tSirMacAddr));
3823 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3824 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3825
3826 /* Update PE session ID*/
3827 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3828
3829 /// Free up buffer allocated for mlmDisassocReq
3830 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3831
3832 limPostSmeMessage(pMac,
3833 LIM_MLM_DISASSOC_CNF,
3834 (tANI_U32 *) &mlmDisassocCnf);
3835 return eHAL_STATUS_SUCCESS;
3836}
3837
3838eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3839{
3840 return limSendDisassocCnf(pMac);
3841}
3842
3843eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3844{
3845 return limSendDeauthCnf(pMac);
3846}
3847
Jeff Johnson295189b2012-06-20 16:38:30 -07003848/**
3849 * \brief This function is called to send Disassociate frame.
3850 *
3851 *
3852 * \param pMac Pointer to Global MAC structure
3853 *
3854 * \param nReason Indicates the reason that need to be sent in
3855 * Disassociation frame
3856 *
3857 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3858 * sent
3859 *
3860 *
3861 */
3862
3863void
3864limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3865 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003866 tSirMacAddr peer,
3867 tpPESession psessionEntry,
3868 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003869{
3870 tDot11fDisassociation frm;
3871 tANI_U8 *pFrame;
3872 tSirRetStatus nSirStatus;
3873 tpSirMacMgmtHdr pMacHdr;
3874 tANI_U32 nBytes, nPayload, nStatus;
3875 void *pPacket;
3876 eHalStatus halstatus;
3877 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003878 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 if(NULL == psessionEntry)
3880 {
3881 return;
3882 }
3883
3884 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3885
3886 frm.Reason.code = nReason;
3887
3888 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3889 if ( DOT11F_FAILED( nStatus ) )
3890 {
3891 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3892 "or a Disassociation (0x%08x).\n"),
3893 nStatus );
3894 // We'll fall back on the worst case scenario:
3895 nPayload = sizeof( tDot11fDisassociation );
3896 }
3897 else if ( DOT11F_WARNED( nStatus ) )
3898 {
3899 limLog( pMac, LOGW, FL("There were warnings while calculating"
3900 "the packed size for a Disassociation "
3901 "(0x%08x).\n"), nStatus );
3902 }
3903
3904 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3905
3906 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3907 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3908 ( void** ) &pPacket );
3909 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3910 {
3911 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
3912 "association.\n"), nBytes );
3913 return;
3914 }
3915
3916 // Paranoia:
3917 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3918
3919 // Next, we fill out the buffer descriptor:
3920 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3921 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3922 if ( eSIR_SUCCESS != nSirStatus )
3923 {
3924 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3925 "tor for a Disassociation (%d).\n"),
3926 nSirStatus );
3927 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3928 ( void* ) pFrame, ( void* ) pPacket );
3929 return; // just allocated...
3930 }
3931
3932 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3933
3934 // Prepare the BSSID
3935 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3936
3937 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3938 sizeof(tSirMacMgmtHdr),
3939 nPayload, &nPayload );
3940 if ( DOT11F_FAILED( nStatus ) )
3941 {
3942 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x).\n"),
3943 nStatus );
3944 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3945 ( void* ) pFrame, ( void* ) pPacket );
3946 return; // allocated!
3947 }
3948 else if ( DOT11F_WARNED( nStatus ) )
3949 {
3950 limLog( pMac, LOGW, FL("There were warnings while packing a D"
3951 "isassociation (0x%08x).\n") );
3952 }
3953
3954 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
3955 "son %d to\n"), nReason );
3956 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3957
3958 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3959#ifdef WLAN_FEATURE_P2P
3960 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3961 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3962#endif
3963 )
3964 {
3965 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3966 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003967
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003968 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003970 // Queue Disassociation frame in high priority WQ
3971 /* get the duration from the request */
3972 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3973 HAL_TXRX_FRM_802_11_MGMT,
3974 ANI_TXDIR_TODS,
3975 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3976 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3977 txFlag );
3978 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003980 if (tx_timer_change(
3981 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3982 != TX_SUCCESS)
3983 {
3984 limLog(pMac, LOGP,
3985 FL("Unable to change Disassoc ack Timer val\n"));
3986 return;
3987 }
3988 else if(TX_SUCCESS != tx_timer_activate(
3989 &pMac->lim.limTimers.gLimDisassocAckTimer))
3990 {
3991 limLog(pMac, LOGP,
3992 FL("Unable to activate Disassoc ack Timer\n"));
3993 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3994 return;
3995 }
3996 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003997 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003998 {
3999 // Queue Disassociation frame in high priority WQ
4000 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4001 HAL_TXRX_FRM_802_11_MGMT,
4002 ANI_TXDIR_TODS,
4003 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4004 limTxComplete, pFrame, txFlag );
4005 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4006 {
4007 limLog( pMac, LOGE, FL("Failed to send Disassociation "
4008 "(%X)!\n"),
4009 nSirStatus );
4010 //Pkt will be freed up by the callback
4011 return;
4012 }
4013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004014} // End limSendDisassocMgmtFrame.
4015
4016/**
4017 * \brief This function is called to send a Deauthenticate frame
4018 *
4019 *
4020 * \param pMac Pointer to global MAC structure
4021 *
4022 * \param nReason Indicates the reason that need to be sent in the
4023 * Deauthenticate frame
4024 *
4025 * \param peeer address of the STA to which the frame is to be sent
4026 *
4027 *
4028 */
4029
4030void
4031limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4032 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004033 tSirMacAddr peer,
4034 tpPESession psessionEntry,
4035 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004036{
4037 tDot11fDeAuth frm;
4038 tANI_U8 *pFrame;
4039 tSirRetStatus nSirStatus;
4040 tpSirMacMgmtHdr pMacHdr;
4041 tANI_U32 nBytes, nPayload, nStatus;
4042 void *pPacket;
4043 eHalStatus halstatus;
4044 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004045 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 if(NULL == psessionEntry)
4047 {
4048 return;
4049 }
4050
4051 palZeroMemory( pMac->hHdd, ( tANI_U8* ) &frm, sizeof( frm ) );
4052
4053 frm.Reason.code = nReason;
4054
4055 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4056 if ( DOT11F_FAILED( nStatus ) )
4057 {
4058 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4059 "or a De-Authentication (0x%08x).\n"),
4060 nStatus );
4061 // We'll fall back on the worst case scenario:
4062 nPayload = sizeof( tDot11fDeAuth );
4063 }
4064 else if ( DOT11F_WARNED( nStatus ) )
4065 {
4066 limLog( pMac, LOGW, FL("There were warnings while calculating"
4067 "the packed size for a De-Authentication "
4068 "(0x%08x).\n"), nStatus );
4069 }
4070
4071 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4072
4073 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4074 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4075 ( void** ) &pPacket );
4076 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4077 {
4078 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
4079 "Authentication.\n"), nBytes );
4080 return;
4081 }
4082
4083 // Paranoia:
4084 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4085
4086 // Next, we fill out the buffer descriptor:
4087 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4088 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4089 if ( eSIR_SUCCESS != nSirStatus )
4090 {
4091 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4092 "tor for a De-Authentication (%d).\n"),
4093 nSirStatus );
4094 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4095 ( void* ) pFrame, ( void* ) pPacket );
4096 return; // just allocated...
4097 }
4098
4099 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4100
4101 // Prepare the BSSID
4102 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4103
4104 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4105 sizeof(tSirMacMgmtHdr),
4106 nPayload, &nPayload );
4107 if ( DOT11F_FAILED( nStatus ) )
4108 {
4109 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x).\n"),
4110 nStatus );
4111 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4112 ( void* ) pFrame, ( void* ) pPacket );
4113 return;
4114 }
4115 else if ( DOT11F_WARNED( nStatus ) )
4116 {
4117 limLog( pMac, LOGW, FL("There were warnings while packing a D"
4118 "e-Authentication (0x%08x).\n") );
4119 }
4120
4121 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
4122 "son %d to\n"), nReason );
4123 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
4124
4125 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4126#ifdef WLAN_FEATURE_P2P
4127 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4128 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4129#endif
4130 )
4131 {
4132 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4133 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004134
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004135 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004137 // Queue Disassociation frame in high priority WQ
4138 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4139 HAL_TXRX_FRM_802_11_MGMT,
4140 ANI_TXDIR_TODS,
4141 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4142 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
4143 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4144 {
4145 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
4146 "(%X)!\n"),
4147 nSirStatus );
4148 //Pkt will be freed up by the callback
4149 return;
4150 }
4151
4152 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4153
4154 if (tx_timer_change(
4155 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4156 != TX_SUCCESS)
4157 {
4158 limLog(pMac, LOGP,
4159 FL("Unable to change Deauth ack Timer val\n"));
4160 return;
4161 }
4162 else if(TX_SUCCESS != tx_timer_activate(
4163 &pMac->lim.limTimers.gLimDeauthAckTimer))
4164 {
4165 limLog(pMac, LOGP,
4166 FL("Unable to activate Deauth ack Timer\n"));
4167 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4168 return;
4169 }
4170 }
4171 else
4172 {
4173 // Queue Disassociation frame in high priority WQ
4174 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4175 HAL_TXRX_FRM_802_11_MGMT,
4176 ANI_TXDIR_TODS,
4177 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4178 limTxComplete, pFrame, txFlag );
4179 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4180 {
4181 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
4182 "(%X)!\n"),
4183 nSirStatus );
4184 //Pkt will be freed up by the callback
4185 return;
4186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 }
4188
4189} // End limSendDeauthMgmtFrame.
4190
4191
4192#ifdef ANI_SUPPORT_11H
4193/**
4194 * \brief Send a Measurement Report Action frame
4195 *
4196 *
4197 * \param pMac Pointer to the global MAC structure
4198 *
4199 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4200 *
4201 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4202 *
4203 *
4204 */
4205
4206tSirRetStatus
4207limSendMeasReportFrame(tpAniSirGlobal pMac,
4208 tpSirMacMeasReqActionFrame pMeasReqFrame,
4209 tSirMacAddr peer)
4210{
4211 tDot11fMeasurementReport frm;
4212 tANI_U8 *pFrame;
4213 tSirRetStatus nSirStatus;
4214 tpSirMacMgmtHdr pMacHdr;
4215 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4216 void *pPacket;
4217 eHalStatus halstatus;
4218
4219 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4220
4221 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4222 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4223 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4224
4225 switch ( pMeasReqFrame->measReqIE.measType )
4226 {
4227 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4228 nSirStatus =
4229 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4230 &frm.MeasurementReport );
4231 break;
4232 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4233 nSirStatus =
4234 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4235 &frm.MeasurementReport );
4236 break;
4237 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4238 nSirStatus =
4239 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4240 &frm.MeasurementReport );
4241 break;
4242 default:
4243 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
4244 "dMeasReportFrame.\n"),
4245 pMeasReqFrame->measReqIE.measType );
4246 return eSIR_FAILURE;
4247 }
4248
4249 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4250
4251 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4252 if ( DOT11F_FAILED( nStatus ) )
4253 {
4254 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4255 "or a Measurement Report (0x%08x).\n"),
4256 nStatus );
4257 // We'll fall back on the worst case scenario:
4258 nPayload = sizeof( tDot11fMeasurementReport );
4259 }
4260 else if ( DOT11F_WARNED( nStatus ) )
4261 {
4262 limLog( pMac, LOGW, FL("There were warnings while calculating"
4263 "the packed size for a Measurement Rep"
4264 "ort (0x%08x).\n"), nStatus );
4265 }
4266
4267 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4268
4269 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4270 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4271 {
4272 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
4273 "Authentication.\n"), nBytes );
4274 return eSIR_FAILURE;
4275 }
4276
4277 // Paranoia:
4278 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4279
4280 // Next, we fill out the buffer descriptor:
4281 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4282 SIR_MAC_MGMT_ACTION, peer);
4283 if ( eSIR_SUCCESS != nSirStatus )
4284 {
4285 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4286 "tor for a Measurement Report (%d).\n"),
4287 nSirStatus );
4288 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4289 return eSIR_FAILURE; // just allocated...
4290 }
4291
4292 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4293
4294 nCfg = 6;
4295 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4296 if ( eSIR_SUCCESS != nSirStatus )
4297 {
4298 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4299 " CFG (%d).\n"),
4300 nSirStatus );
4301 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4302 return eSIR_FAILURE; // just allocated...
4303 }
4304
4305 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4306 sizeof(tSirMacMgmtHdr),
4307 nPayload, &nPayload );
4308 if ( DOT11F_FAILED( nStatus ) )
4309 {
4310 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x).\n"),
4311 nStatus );
4312 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4313 return eSIR_FAILURE; // allocated!
4314 }
4315 else if ( DOT11F_WARNED( nStatus ) )
4316 {
4317 limLog( pMac, LOGW, FL("There were warnings while packing a M"
4318 "easurement Report (0x%08x).\n") );
4319 }
4320
4321 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4322 HAL_TXRX_FRM_802_11_MGMT,
4323 ANI_TXDIR_TODS,
4324 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4325 limTxComplete, pFrame, 0 );
4326 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4327 {
4328 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
4329 "(%X)!\n"),
4330 nSirStatus );
4331 //Pkt will be freed up by the callback
4332 return eSIR_FAILURE; // just allocated...
4333 }
4334
4335 return eSIR_SUCCESS;
4336
4337} // End limSendMeasReportFrame.
4338
4339
4340/**
4341 * \brief Send a TPC Request Action frame
4342 *
4343 *
4344 * \param pMac Pointer to the global MAC datastructure
4345 *
4346 * \param peer MAC address to which the frame should be sent
4347 *
4348 *
4349 */
4350
4351void
4352limSendTpcRequestFrame(tpAniSirGlobal pMac,
4353 tSirMacAddr peer)
4354{
4355 tDot11fTPCRequest frm;
4356 tANI_U8 *pFrame;
4357 tSirRetStatus nSirStatus;
4358 tpSirMacMgmtHdr pMacHdr;
4359 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4360 void *pPacket;
4361 eHalStatus halstatus;
4362
4363 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4364
4365 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4366 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4367 frm.DialogToken.token = 1;
4368 frm.TPCRequest.present = 1;
4369
4370 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4371 if ( DOT11F_FAILED( nStatus ) )
4372 {
4373 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4374 "or a TPC Request (0x%08x).\n"),
4375 nStatus );
4376 // We'll fall back on the worst case scenario:
4377 nPayload = sizeof( tDot11fTPCRequest );
4378 }
4379 else if ( DOT11F_WARNED( nStatus ) )
4380 {
4381 limLog( pMac, LOGW, FL("There were warnings while calculating"
4382 "the packed size for a TPC Request (0x"
4383 "%08x).\n"), nStatus );
4384 }
4385
4386 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4387
4388 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4389 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4390 {
4391 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4392 " Request.\n"), nBytes );
4393 return;
4394 }
4395
4396 // Paranoia:
4397 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4398
4399 // Next, we fill out the buffer descriptor:
4400 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4401 SIR_MAC_MGMT_ACTION, peer);
4402 if ( eSIR_SUCCESS != nSirStatus )
4403 {
4404 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4405 "tor for a TPC Request (%d).\n"),
4406 nSirStatus );
4407 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4408 return; // just allocated...
4409 }
4410
4411 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4412
4413 nCfg = 6;
4414 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4415 if ( eSIR_SUCCESS != nSirStatus )
4416 {
4417 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4418 " CFG (%d).\n"),
4419 nSirStatus );
4420 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4421 return; // just allocated...
4422 }
4423
4424 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4425 sizeof(tSirMacMgmtHdr),
4426 nPayload, &nPayload );
4427 if ( DOT11F_FAILED( nStatus ) )
4428 {
4429 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x).\n"),
4430 nStatus );
4431 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4432 return; // allocated!
4433 }
4434 else if ( DOT11F_WARNED( nStatus ) )
4435 {
4436 limLog( pMac, LOGW, FL("There were warnings while packing a T"
4437 "PC Request (0x%08x).\n") );
4438 }
4439
4440 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4441 HAL_TXRX_FRM_802_11_MGMT,
4442 ANI_TXDIR_TODS,
4443 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4444 limTxComplete, pFrame, 0 );
4445 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4446 {
4447 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
4448 "(%X)!\n"),
4449 nSirStatus );
4450 //Pkt will be freed up by the callback
4451 return;
4452 }
4453
4454} // End limSendTpcRequestFrame.
4455
4456
4457/**
4458 * \brief Send a TPC Report Action frame
4459 *
4460 *
4461 * \param pMac Pointer to the global MAC datastructure
4462 *
4463 * \param pTpcReqFrame Pointer to the received TPC Request
4464 *
4465 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4466 *
4467 *
4468 */
4469
4470tSirRetStatus
4471limSendTpcReportFrame(tpAniSirGlobal pMac,
4472 tpSirMacTpcReqActionFrame pTpcReqFrame,
4473 tSirMacAddr peer)
4474{
4475 tDot11fTPCReport frm;
4476 tANI_U8 *pFrame;
4477 tSirRetStatus nSirStatus;
4478 tpSirMacMgmtHdr pMacHdr;
4479 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4480 void *pPacket;
4481 eHalStatus halstatus;
4482
4483 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4484
4485 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4486 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4487 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4488
4489 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4490 // "misplaced this function, need to replace:
4491 // txPower = halGetRateToPwrValue(pMac, staid,
4492 // pMac->lim.gLimCurrentChannelId, 0);
4493 frm.TPCReport.tx_power = 0;
4494 frm.TPCReport.link_margin = 0;
4495 frm.TPCReport.present = 1;
4496
4497 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4498 if ( DOT11F_FAILED( nStatus ) )
4499 {
4500 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4501 "or a TPC Report (0x%08x).\n"),
4502 nStatus );
4503 // We'll fall back on the worst case scenario:
4504 nPayload = sizeof( tDot11fTPCReport );
4505 }
4506 else if ( DOT11F_WARNED( nStatus ) )
4507 {
4508 limLog( pMac, LOGW, FL("There were warnings while calculating"
4509 "the packed size for a TPC Report (0x"
4510 "%08x).\n"), nStatus );
4511 }
4512
4513 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4514
4515 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4516 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4517 {
4518 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4519 " Report.\n"), nBytes );
4520 return eSIR_FAILURE;
4521 }
4522
4523 // Paranoia:
4524 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4525
4526 // Next, we fill out the buffer descriptor:
4527 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4528 SIR_MAC_MGMT_ACTION, peer);
4529 if ( eSIR_SUCCESS != nSirStatus )
4530 {
4531 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4532 "tor for a TPC Report (%d).\n"),
4533 nSirStatus );
4534 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4535 return eSIR_FAILURE; // just allocated...
4536 }
4537
4538 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4539
4540 nCfg = 6;
4541 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4542 if ( eSIR_SUCCESS != nSirStatus )
4543 {
4544 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4545 " CFG (%d).\n"),
4546 nSirStatus );
4547 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4548 return eSIR_FAILURE; // just allocated...
4549 }
4550
4551 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4552 sizeof(tSirMacMgmtHdr),
4553 nPayload, &nPayload );
4554 if ( DOT11F_FAILED( nStatus ) )
4555 {
4556 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x).\n"),
4557 nStatus );
4558 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4559 return eSIR_FAILURE; // allocated!
4560 }
4561 else if ( DOT11F_WARNED( nStatus ) )
4562 {
4563 limLog( pMac, LOGW, FL("There were warnings while packing a T"
4564 "PC Report (0x%08x).\n") );
4565 }
4566
4567
4568 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4569 HAL_TXRX_FRM_802_11_MGMT,
4570 ANI_TXDIR_TODS,
4571 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4572 limTxComplete, pFrame, 0 );
4573 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4574 {
4575 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
4576 "(%X)!\n"),
4577 nSirStatus );
4578 //Pkt will be freed up by the callback
4579 return eSIR_FAILURE; // just allocated...
4580 }
4581
4582 return eSIR_SUCCESS;
4583
4584} // End limSendTpcReportFrame.
4585#endif //ANI_SUPPORT_11H
4586
4587
Jeff Johnsone7245742012-09-05 17:12:55 -07004588#if 1//def ANI_PRODUCT_TYPE_AP
Jeff Johnson295189b2012-06-20 16:38:30 -07004589/**
4590 * \brief Send a Channel Switch Announcement
4591 *
4592 *
4593 * \param pMac Pointer to the global MAC datastructure
4594 *
4595 * \param peer MAC address to which this frame will be sent
4596 *
4597 * \param nMode
4598 *
4599 * \param nNewChannel
4600 *
4601 * \param nCount
4602 *
4603 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4604 *
4605 *
4606 */
4607
4608tSirRetStatus
4609limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4610 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004611 tANI_U8 nMode,
4612 tANI_U8 nNewChannel,
4613 tANI_U8 nCount,
4614 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004615{
4616 tDot11fChannelSwitch frm;
4617 tANI_U8 *pFrame;
4618 tSirRetStatus nSirStatus;
4619 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004620 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 void *pPacket;
4622 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004623 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004624
4625 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4626
4627 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4628 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4629 frm.ChanSwitchAnn.switchMode = nMode;
4630 frm.ChanSwitchAnn.newChannel = nNewChannel;
4631 frm.ChanSwitchAnn.switchCount = nCount;
4632 frm.ChanSwitchAnn.present = 1;
4633
4634 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4635 if ( DOT11F_FAILED( nStatus ) )
4636 {
4637 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4638 "or a Channel Switch (0x%08x).\n"),
4639 nStatus );
4640 // We'll fall back on the worst case scenario:
4641 nPayload = sizeof( tDot11fChannelSwitch );
4642 }
4643 else if ( DOT11F_WARNED( nStatus ) )
4644 {
4645 limLog( pMac, LOGW, FL("There were warnings while calculating"
4646 "the packed size for a Channel Switch (0x"
4647 "%08x).\n"), nStatus );
4648 }
4649
4650 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4651
4652 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4653 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4654 {
4655 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4656 " Report.\n"), nBytes );
4657 return eSIR_FAILURE;
4658 }
4659
4660 // Paranoia:
4661 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4662
4663 // Next, we fill out the buffer descriptor:
4664 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004665 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4666 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4667 palCopyMemory( pMac->hHdd,
4668 (tANI_U8 *) pMacHdr->bssId,
4669 (tANI_U8 *) psessionEntry->bssId,
4670 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 if ( eSIR_SUCCESS != nSirStatus )
4672 {
4673 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4674 "tor for a Channel Switch (%d).\n"),
4675 nSirStatus );
4676 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4677 return eSIR_FAILURE; // just allocated...
4678 }
4679
Jeff Johnsone7245742012-09-05 17:12:55 -07004680#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4682
4683 nCfg = 6;
4684 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4685 if ( eSIR_SUCCESS != nSirStatus )
4686 {
4687 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4688 " CFG (%d).\n"),
4689 nSirStatus );
4690 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4691 return eSIR_FAILURE; // just allocated...
4692 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004693#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4695 sizeof(tSirMacMgmtHdr),
4696 nPayload, &nPayload );
4697 if ( DOT11F_FAILED( nStatus ) )
4698 {
4699 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x).\n"),
4700 nStatus );
4701 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4702 return eSIR_FAILURE; // allocated!
4703 }
4704 else if ( DOT11F_WARNED( nStatus ) )
4705 {
4706 limLog( pMac, LOGW, FL("There were warnings while packing a C"
4707 "hannel Switch (0x%08x).\n") );
4708 }
4709
Jeff Johnsone7245742012-09-05 17:12:55 -07004710 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4711#ifdef WLAN_FEATURE_P2P
4712 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4713 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4714#endif
4715 )
4716 {
4717 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4718 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004719 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4720 HAL_TXRX_FRM_802_11_MGMT,
4721 ANI_TXDIR_TODS,
4722 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004723 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4725 {
4726 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4727 "(%X)!\n"),
4728 nSirStatus );
4729 //Pkt will be freed up by the callback
4730 return eSIR_FAILURE;
4731 }
4732
4733 return eSIR_SUCCESS;
4734
4735} // End limSendChannelSwitchMgmtFrame.
4736
4737#endif // (ANI_PRODUCT_TYPE_AP)
4738
4739
Mohit Khanna4a70d262012-09-11 16:30:12 -07004740#ifdef WLAN_FEATURE_11AC
4741tSirRetStatus
4742limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4743 tSirMacAddr peer,
4744 tANI_U8 nMode,
4745 tpPESession psessionEntry )
4746{
4747 tDot11fOperatingMode frm;
4748 tANI_U8 *pFrame;
4749 tSirRetStatus nSirStatus;
4750 tpSirMacMgmtHdr pMacHdr;
4751 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4752 void *pPacket;
4753 eHalStatus halstatus;
4754 tANI_U8 txFlag = 0;
4755
4756 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4757
4758 frm.Category.category = SIR_MAC_ACTION_VHT;
4759 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4760 frm.OperatingMode.chanWidth = nMode;
4761 frm.OperatingMode.rxNSS = 0;
4762 frm.OperatingMode.rxNSSType = 0;
4763
4764 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4765 if ( DOT11F_FAILED( nStatus ) )
4766 {
4767 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4768 "or a Operating Mode (0x%08x).\n"),
4769 nStatus );
4770 // We'll fall back on the worst case scenario:
4771 nPayload = sizeof( tDot11fOperatingMode);
4772 }
4773 else if ( DOT11F_WARNED( nStatus ) )
4774 {
4775 limLog( pMac, LOGW, FL("There were warnings while calculating"
4776 "the packed size for a Operating Mode (0x"
4777 "%08x).\n"), nStatus );
4778 }
4779
4780 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4781
4782 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4783 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4784 {
4785 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
4786 " Report.\n"), nBytes );
4787 return eSIR_FAILURE;
4788 }
4789
4790 // Paranoia:
4791 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4792
4793
4794 // Next, we fill out the buffer descriptor:
4795 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4796 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4797 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4798 } else
4799 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4800 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4801 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4802 palCopyMemory( pMac->hHdd,
4803 (tANI_U8 *) pMacHdr->bssId,
4804 (tANI_U8 *) psessionEntry->bssId,
4805 sizeof( tSirMacAddr ));
4806 if ( eSIR_SUCCESS != nSirStatus )
4807 {
4808 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4809 "tor for a Operating Mode (%d).\n"),
4810 nSirStatus );
4811 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4812 return eSIR_FAILURE; // just allocated...
4813 }
4814 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4815 sizeof(tSirMacMgmtHdr),
4816 nPayload, &nPayload );
4817 if ( DOT11F_FAILED( nStatus ) )
4818 {
4819 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x).\n"),
4820 nStatus );
4821 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4822 return eSIR_FAILURE; // allocated!
4823 }
4824 else if ( DOT11F_WARNED( nStatus ) )
4825 {
4826 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
4827 " (0x%08x).\n") );
4828 }
4829 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4830#ifdef WLAN_FEATURE_P2P
4831 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4832 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4833#endif
4834 )
4835 {
4836 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4837 }
4838 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4839 HAL_TXRX_FRM_802_11_MGMT,
4840 ANI_TXDIR_TODS,
4841 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4842 limTxComplete, pFrame, txFlag );
4843 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4844 {
4845 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4846 "(%X)!\n"),
4847 nSirStatus );
4848 //Pkt will be freed up by the callback
4849 return eSIR_FAILURE;
4850 }
4851
4852 return eSIR_SUCCESS;
4853}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004854
4855/**
4856 * \brief Send a VHT Channel Switch Announcement
4857 *
4858 *
4859 * \param pMac Pointer to the global MAC datastructure
4860 *
4861 * \param peer MAC address to which this frame will be sent
4862 *
4863 * \param nChanWidth
4864 *
4865 * \param nNewChannel
4866 *
4867 *
4868 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4869 *
4870 *
4871 */
4872
4873tSirRetStatus
4874limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4875 tSirMacAddr peer,
4876 tANI_U8 nChanWidth,
4877 tANI_U8 nNewChannel,
4878 tANI_U8 ncbMode,
4879 tpPESession psessionEntry )
4880{
4881 tDot11fChannelSwitch frm;
4882 tANI_U8 *pFrame;
4883 tSirRetStatus nSirStatus;
4884 tpSirMacMgmtHdr pMacHdr;
4885 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4886 void *pPacket;
4887 eHalStatus halstatus;
4888 tANI_U8 txFlag = 0;
4889
4890 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4891
4892
4893 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4894 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4895 frm.ChanSwitchAnn.switchMode = 1;
4896 frm.ChanSwitchAnn.newChannel = nNewChannel;
4897 frm.ChanSwitchAnn.switchCount = 1;
4898 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4899 frm.ExtChanSwitchAnn.present = 1;
4900 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4901 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4902 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4903 frm.ChanSwitchAnn.present = 1;
4904 frm.WiderBWChanSwitchAnn.present = 1;
4905
4906 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4907 if ( DOT11F_FAILED( nStatus ) )
4908 {
4909 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4910 "or a Channel Switch (0x%08x).\n"),
4911 nStatus );
4912 // We'll fall back on the worst case scenario:
4913 nPayload = sizeof( tDot11fChannelSwitch );
4914 }
4915 else if ( DOT11F_WARNED( nStatus ) )
4916 {
4917 limLog( pMac, LOGW, FL("There were warnings while calculating"
4918 "the packed size for a Channel Switch (0x"
4919 "%08x).\n"), nStatus );
4920 }
4921
4922 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4923
4924 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4925 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4926 {
4927 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4928 " Report.\n"), nBytes );
4929 return eSIR_FAILURE;
4930 }
4931 // Paranoia:
4932 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4933
4934 // Next, we fill out the buffer descriptor:
4935 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4936 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4937 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4938 palCopyMemory( pMac->hHdd,
4939 (tANI_U8 *) pMacHdr->bssId,
4940 (tANI_U8 *) psessionEntry->bssId,
4941 sizeof( tSirMacAddr ));
4942 if ( eSIR_SUCCESS != nSirStatus )
4943 {
4944 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4945 "tor for a Channel Switch (%d).\n"),
4946 nSirStatus );
4947 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4948 return eSIR_FAILURE; // just allocated...
4949 }
4950 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4951 sizeof(tSirMacMgmtHdr),
4952 nPayload, &nPayload );
4953 if ( DOT11F_FAILED( nStatus ) )
4954 {
4955 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x).\n"),
4956 nStatus );
4957 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4958 return eSIR_FAILURE; // allocated!
4959 }
4960 else if ( DOT11F_WARNED( nStatus ) )
4961 {
4962 limLog( pMac, LOGW, FL("There were warnings while packing a C"
4963 "hannel Switch (0x%08x).\n") );
4964 }
4965
4966 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4967#ifdef WLAN_FEATURE_P2P
4968 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4969 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4970#endif
4971 )
4972 {
4973 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4974 }
4975 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4976 HAL_TXRX_FRM_802_11_MGMT,
4977 ANI_TXDIR_TODS,
4978 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4979 limTxComplete, pFrame, txFlag );
4980 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4981 {
4982 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4983 "(%X)!\n"),
4984 nSirStatus );
4985 //Pkt will be freed up by the callback
4986 return eSIR_FAILURE;
4987 }
4988
4989 return eSIR_SUCCESS;
4990
4991} // End limSendVHTChannelSwitchMgmtFrame.
4992
4993
4994
Mohit Khanna4a70d262012-09-11 16:30:12 -07004995#endif
4996
Jeff Johnson295189b2012-06-20 16:38:30 -07004997/**
4998 * \brief Send an ADDBA Req Action Frame to peer
4999 *
5000 * \sa limSendAddBAReq
5001 *
5002 * \param pMac The global tpAniSirGlobal object
5003 *
5004 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5005 * the necessary parameters reqd by PE send the ADDBA Req Action
5006 * Frame to the peer
5007 *
5008 * \return eSIR_SUCCESS if setup completes successfully
5009 * eSIR_FAILURE is some problem is encountered
5010 */
5011tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
5012 tpLimMlmAddBAReq pMlmAddBAReq ,tpPESession psessionEntry)
5013{
5014 tDot11fAddBAReq frmAddBAReq;
5015 tANI_U8 *pAddBAReqBuffer = NULL;
5016 tpSirMacMgmtHdr pMacHdr;
5017 tANI_U32 frameLen = 0, nStatus, nPayload;
5018 tSirRetStatus statusCode;
5019 eHalStatus halStatus;
5020 void *pPacket;
5021 tANI_U8 txFlag = 0;
5022
5023 if(NULL == psessionEntry)
5024 {
5025 return eSIR_FAILURE;
5026 }
5027
5028 palZeroMemory( pMac->hHdd, (void *) &frmAddBAReq, sizeof( frmAddBAReq ));
5029
5030 // Category - 3 (BA)
5031 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5032
5033 // Action - 0 (ADDBA Req)
5034 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5035
5036 // FIXME - Dialog Token, generalize this...
5037 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5038
5039 // Fill the ADDBA Parameter Set
5040 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5041 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5042 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5043
5044 // BA timeout
5045 // 0 - indicates no BA timeout
5046 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5047
5048 // BA Starting Sequence Number
5049 // Fragment number will always be zero
5050 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5051 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5052 }
5053
5054 frmAddBAReq.BAStartingSequenceControl.ssn =
5055 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5056
5057 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5058
5059 if( DOT11F_FAILED( nStatus ))
5060 {
5061 limLog( pMac, LOGW,
5062 FL( "Failed to calculate the packed size for "
5063 "an ADDBA Request (0x%08x).\n"),
5064 nStatus );
5065
5066 // We'll fall back on the worst case scenario:
5067 nPayload = sizeof( tDot11fAddBAReq );
5068 }
5069 else if( DOT11F_WARNED( nStatus ))
5070 {
5071 limLog( pMac, LOGW,
5072 FL( "There were warnings while calculating"
5073 "the packed size for an ADDBA Req (0x%08x).\n"),
5074 nStatus );
5075 }
5076
5077 // Add the MGMT header to frame length
5078 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5079
5080 // Need to allocate a buffer for ADDBA AF
5081 if( eHAL_STATUS_SUCCESS !=
5082 (halStatus = palPktAlloc( pMac->hHdd,
5083 HAL_TXRX_FRM_802_11_MGMT,
5084 (tANI_U16) frameLen,
5085 (void **) &pAddBAReqBuffer,
5086 (void **) &pPacket )))
5087 {
5088 // Log error
5089 limLog( pMac, LOGP,
5090 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5091 frameLen,
5092 halStatus );
5093
5094 statusCode = eSIR_MEM_ALLOC_FAILED;
5095 goto returnAfterError;
5096 }
5097
5098 palZeroMemory( pMac->hHdd, (void *) pAddBAReqBuffer, frameLen );
5099
5100 // Copy necessary info to BD
5101 if( eSIR_SUCCESS !=
5102 (statusCode = limPopulateMacHeader( pMac,
5103 pAddBAReqBuffer,
5104 SIR_MAC_MGMT_FRAME,
5105 SIR_MAC_MGMT_ACTION,
5106 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5107 goto returnAfterError;
5108
5109 // Update A3 with the BSSID
5110 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5111
5112 #if 0
5113 cfgLen = SIR_MAC_ADDR_LENGTH;
5114 if( eSIR_SUCCESS != cfgGetStr( pMac,
5115 WNI_CFG_BSSID,
5116 (tANI_U8 *) pMacHdr->bssId,
5117 &cfgLen ))
5118 {
5119 limLog( pMac, LOGP,
5120 FL( "Failed to retrieve WNI_CFG_BSSID while"
5121 "sending an ACTION Frame\n" ));
5122
5123 // FIXME - Need to convert to tSirRetStatus
5124 statusCode = eSIR_FAILURE;
5125 goto returnAfterError;
5126 }
5127 #endif//TO SUPPORT BT-AMP
5128 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5129
5130 // Now, we're ready to "pack" the frames
5131 nStatus = dot11fPackAddBAReq( pMac,
5132 &frmAddBAReq,
5133 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5134 nPayload,
5135 &nPayload );
5136
5137 if( DOT11F_FAILED( nStatus ))
5138 {
5139 limLog( pMac, LOGE,
5140 FL( "Failed to pack an ADDBA Req (0x%08x).\n" ),
5141 nStatus );
5142
5143 // FIXME - Need to convert to tSirRetStatus
5144 statusCode = eSIR_FAILURE;
5145 goto returnAfterError;
5146 }
5147 else if( DOT11F_WARNED( nStatus ))
5148 {
5149 limLog( pMac, LOGW,
5150 FL( "There were warnings while packing an ADDBA Req (0x%08x).\n" ));
5151 }
5152
5153 limLog( pMac, LOGW,
5154 FL( "Sending an ADDBA REQ to \n" ));
5155 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5156
5157 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5158#ifdef WLAN_FEATURE_P2P
5159 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5160 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5161#endif
5162 )
5163 {
5164 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5165 }
5166
5167 if( eHAL_STATUS_SUCCESS !=
5168 (halStatus = halTxFrame( pMac,
5169 pPacket,
5170 (tANI_U16) frameLen,
5171 HAL_TXRX_FRM_802_11_MGMT,
5172 ANI_TXDIR_TODS,
5173 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5174 limTxComplete,
5175 pAddBAReqBuffer, txFlag )))
5176 {
5177 limLog( pMac, LOGE,
5178 FL( "halTxFrame FAILED! Status [%d]\n"),
5179 halStatus );
5180
5181 // FIXME - Need to convert eHalStatus to tSirRetStatus
5182 statusCode = eSIR_FAILURE;
5183 //Pkt will be freed up by the callback
5184 return statusCode;
5185 }
5186 else
5187 return eSIR_SUCCESS;
5188
5189returnAfterError:
5190
5191 // Release buffer, if allocated
5192 if( NULL != pAddBAReqBuffer )
5193 palPktFree( pMac->hHdd,
5194 HAL_TXRX_FRM_802_11_MGMT,
5195 (void *) pAddBAReqBuffer,
5196 (void *) pPacket );
5197
5198 return statusCode;
5199}
5200
5201/**
5202 * \brief Send an ADDBA Rsp Action Frame to peer
5203 *
5204 * \sa limSendAddBARsp
5205 *
5206 * \param pMac The global tpAniSirGlobal object
5207 *
5208 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5209 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5210 * Frame to the peer
5211 *
5212 * \return eSIR_SUCCESS if setup completes successfully
5213 * eSIR_FAILURE is some problem is encountered
5214 */
5215tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5216 tpLimMlmAddBARsp pMlmAddBARsp,
5217 tpPESession psessionEntry)
5218{
5219 tDot11fAddBARsp frmAddBARsp;
5220 tANI_U8 *pAddBARspBuffer = NULL;
5221 tpSirMacMgmtHdr pMacHdr;
5222 tANI_U32 frameLen = 0, nStatus, nPayload;
5223 tSirRetStatus statusCode;
5224 eHalStatus halStatus;
5225 void *pPacket;
5226 tANI_U8 txFlag = 0;
5227
5228 if(NULL == psessionEntry)
5229 {
5230 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!\n"));)
5231 return eSIR_FAILURE;
5232 }
5233
5234 palZeroMemory( pMac->hHdd, (void *) &frmAddBARsp, sizeof( frmAddBARsp ));
5235
5236 // Category - 3 (BA)
5237 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5238 // Action - 1 (ADDBA Rsp)
5239 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5240
5241 // Should be same as the one we received in the ADDBA Req
5242 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5243
5244 // ADDBA Req status
5245 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5246
5247 // Fill the ADDBA Parameter Set as provided by caller
5248 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5249 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5250 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
5251
5252 // BA timeout
5253 // 0 - indicates no BA timeout
5254 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5255
5256 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5257
5258 if( DOT11F_FAILED( nStatus ))
5259 {
5260 limLog( pMac, LOGW,
5261 FL( "Failed to calculate the packed size for "
5262 "an ADDBA Response (0x%08x).\n"),
5263 nStatus );
5264
5265 // We'll fall back on the worst case scenario:
5266 nPayload = sizeof( tDot11fAddBARsp );
5267 }
5268 else if( DOT11F_WARNED( nStatus ))
5269 {
5270 limLog( pMac, LOGW,
5271 FL( "There were warnings while calculating"
5272 "the packed size for an ADDBA Rsp (0x%08x).\n"),
5273 nStatus );
5274 }
5275
5276 // Need to allocate a buffer for ADDBA AF
5277 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5278
5279 // Allocate shared memory
5280 if( eHAL_STATUS_SUCCESS !=
5281 (halStatus = palPktAlloc( pMac->hHdd,
5282 HAL_TXRX_FRM_802_11_MGMT,
5283 (tANI_U16) frameLen,
5284 (void **) &pAddBARspBuffer,
5285 (void **) &pPacket )))
5286 {
5287 // Log error
5288 limLog( pMac, LOGP,
5289 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5290 frameLen,
5291 halStatus );
5292
5293 statusCode = eSIR_MEM_ALLOC_FAILED;
5294 goto returnAfterError;
5295 }
5296
5297 palZeroMemory( pMac->hHdd, (void *) pAddBARspBuffer, frameLen );
5298
5299 // Copy necessary info to BD
5300 if( eSIR_SUCCESS !=
5301 (statusCode = limPopulateMacHeader( pMac,
5302 pAddBARspBuffer,
5303 SIR_MAC_MGMT_FRAME,
5304 SIR_MAC_MGMT_ACTION,
5305 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5306 goto returnAfterError;
5307
5308 // Update A3 with the BSSID
5309
5310 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5311
5312 #if 0
5313 cfgLen = SIR_MAC_ADDR_LENGTH;
5314 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5315 WNI_CFG_BSSID,
5316 (tANI_U8 *) pMacHdr->bssId,
5317 &cfgLen ))
5318 {
5319 limLog( pMac, LOGP,
5320 FL( "Failed to retrieve WNI_CFG_BSSID while"
5321 "sending an ACTION Frame\n" ));
5322
5323 // FIXME - Need to convert to tSirRetStatus
5324 statusCode = eSIR_FAILURE;
5325 goto returnAfterError;
5326 }
5327 #endif // TO SUPPORT BT-AMP
5328 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5329
5330 // Now, we're ready to "pack" the frames
5331 nStatus = dot11fPackAddBARsp( pMac,
5332 &frmAddBARsp,
5333 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5334 nPayload,
5335 &nPayload );
5336
5337 if( DOT11F_FAILED( nStatus ))
5338 {
5339 limLog( pMac, LOGE,
5340 FL( "Failed to pack an ADDBA Rsp (0x%08x).\n" ),
5341 nStatus );
5342
5343 // FIXME - Need to convert to tSirRetStatus
5344 statusCode = eSIR_FAILURE;
5345 goto returnAfterError;
5346 }
5347 else if( DOT11F_WARNED( nStatus ))
5348 {
5349 limLog( pMac, LOGW,
5350 FL( "There were warnings while packing an ADDBA Rsp (0x%08x).\n" ));
5351 }
5352
5353 limLog( pMac, LOGW,
5354 FL( "Sending an ADDBA RSP to \n" ));
5355 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5356
5357 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5358#ifdef WLAN_FEATURE_P2P
5359 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5360 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5361#endif
5362 )
5363 {
5364 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5365 }
5366
5367 if( eHAL_STATUS_SUCCESS !=
5368 (halStatus = halTxFrame( pMac,
5369 pPacket,
5370 (tANI_U16) frameLen,
5371 HAL_TXRX_FRM_802_11_MGMT,
5372 ANI_TXDIR_TODS,
5373 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5374 limTxComplete,
5375 pAddBARspBuffer, txFlag )))
5376 {
5377 limLog( pMac, LOGE,
5378 FL( "halTxFrame FAILED! Status [%d]\n" ),
5379 halStatus );
5380
5381 // FIXME - HAL error codes are different from PE error
5382 // codes!! And, this routine is returning tSirRetStatus
5383 statusCode = eSIR_FAILURE;
5384 //Pkt will be freed up by the callback
5385 return statusCode;
5386 }
5387 else
5388 return eSIR_SUCCESS;
5389
5390 returnAfterError:
5391
5392 // Release buffer, if allocated
5393 if( NULL != pAddBARspBuffer )
5394 palPktFree( pMac->hHdd,
5395 HAL_TXRX_FRM_802_11_MGMT,
5396 (void *) pAddBARspBuffer,
5397 (void *) pPacket );
5398
5399 return statusCode;
5400}
5401
5402/**
5403 * \brief Send a DELBA Indication Action Frame to peer
5404 *
5405 * \sa limSendDelBAInd
5406 *
5407 * \param pMac The global tpAniSirGlobal object
5408 *
5409 * \param peerMacAddr MAC Address of peer
5410 *
5411 * \param reasonCode Reason for the DELBA notification
5412 *
5413 * \param pBAParameterSet The DELBA Parameter Set.
5414 * This identifies the TID for which the BA session is
5415 * being deleted.
5416 *
5417 * \return eSIR_SUCCESS if setup completes successfully
5418 * eSIR_FAILURE is some problem is encountered
5419 */
5420tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5421 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5422{
5423 tDot11fDelBAInd frmDelBAInd;
5424 tANI_U8 *pDelBAIndBuffer = NULL;
5425 //tANI_U32 val;
5426 tpSirMacMgmtHdr pMacHdr;
5427 tANI_U32 frameLen = 0, nStatus, nPayload;
5428 tSirRetStatus statusCode;
5429 eHalStatus halStatus;
5430 void *pPacket;
5431 tANI_U8 txFlag = 0;
5432
5433 if(NULL == psessionEntry)
5434 {
5435 return eSIR_FAILURE;
5436 }
5437
5438 palZeroMemory( pMac->hHdd, (void *) &frmDelBAInd, sizeof( frmDelBAInd ));
5439
5440 // Category - 3 (BA)
5441 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5442 // Action - 2 (DELBA)
5443 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5444
5445 // Fill the DELBA Parameter Set as provided by caller
5446 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5447 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5448
5449 // BA Starting Sequence Number
5450 // Fragment number will always be zero
5451 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5452
5453 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5454
5455 if( DOT11F_FAILED( nStatus ))
5456 {
5457 limLog( pMac, LOGW,
5458 FL( "Failed to calculate the packed size for "
5459 "an DELBA Indication (0x%08x).\n"),
5460 nStatus );
5461
5462 // We'll fall back on the worst case scenario:
5463 nPayload = sizeof( tDot11fDelBAInd );
5464 }
5465 else if( DOT11F_WARNED( nStatus ))
5466 {
5467 limLog( pMac, LOGW,
5468 FL( "There were warnings while calculating"
5469 "the packed size for an DELBA Ind (0x%08x).\n"),
5470 nStatus );
5471 }
5472
5473 // Add the MGMT header to frame length
5474 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5475
5476 // Allocate shared memory
5477 if( eHAL_STATUS_SUCCESS !=
5478 (halStatus = palPktAlloc( pMac->hHdd,
5479 HAL_TXRX_FRM_802_11_MGMT,
5480 (tANI_U16) frameLen,
5481 (void **) &pDelBAIndBuffer,
5482 (void **) &pPacket )))
5483 {
5484 // Log error
5485 limLog( pMac, LOGP,
5486 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5487 frameLen,
5488 halStatus );
5489
5490 statusCode = eSIR_MEM_ALLOC_FAILED;
5491 goto returnAfterError;
5492 }
5493
5494 palZeroMemory( pMac->hHdd, (void *) pDelBAIndBuffer, frameLen );
5495
5496 // Copy necessary info to BD
5497 if( eSIR_SUCCESS !=
5498 (statusCode = limPopulateMacHeader( pMac,
5499 pDelBAIndBuffer,
5500 SIR_MAC_MGMT_FRAME,
5501 SIR_MAC_MGMT_ACTION,
5502 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5503 goto returnAfterError;
5504
5505 // Update A3 with the BSSID
5506 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5507
5508 #if 0
5509 cfgLen = SIR_MAC_ADDR_LENGTH;
5510 if( eSIR_SUCCESS != cfgGetStr( pMac,
5511 WNI_CFG_BSSID,
5512 (tANI_U8 *) pMacHdr->bssId,
5513 &cfgLen ))
5514 {
5515 limLog( pMac, LOGP,
5516 FL( "Failed to retrieve WNI_CFG_BSSID while"
5517 "sending an ACTION Frame\n" ));
5518
5519 // FIXME - Need to convert to tSirRetStatus
5520 statusCode = eSIR_FAILURE;
5521 goto returnAfterError;
5522 }
5523 #endif //TO SUPPORT BT-AMP
5524 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5525
5526 // Now, we're ready to "pack" the frames
5527 nStatus = dot11fPackDelBAInd( pMac,
5528 &frmDelBAInd,
5529 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5530 nPayload,
5531 &nPayload );
5532
5533 if( DOT11F_FAILED( nStatus ))
5534 {
5535 limLog( pMac, LOGE,
5536 FL( "Failed to pack an DELBA Ind (0x%08x).\n" ),
5537 nStatus );
5538
5539 // FIXME - Need to convert to tSirRetStatus
5540 statusCode = eSIR_FAILURE;
5541 goto returnAfterError;
5542 }
5543 else if( DOT11F_WARNED( nStatus ))
5544 {
5545 limLog( pMac, LOGW,
5546 FL( "There were warnings while packing an DELBA Ind (0x%08x).\n" ));
5547 }
5548
5549 limLog( pMac, LOGW,
5550 FL( "Sending a DELBA IND to \n" ));
5551 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5552
5553 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5554#ifdef WLAN_FEATURE_P2P
5555 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5556 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5557#endif
5558 )
5559 {
5560 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5561 }
5562
5563 if( eHAL_STATUS_SUCCESS !=
5564 (halStatus = halTxFrame( pMac,
5565 pPacket,
5566 (tANI_U16) frameLen,
5567 HAL_TXRX_FRM_802_11_MGMT,
5568 ANI_TXDIR_TODS,
5569 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5570 limTxComplete,
5571 pDelBAIndBuffer, txFlag )))
5572 {
5573 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halStatus );)
5574 statusCode = eSIR_FAILURE;
5575 //Pkt will be freed up by the callback
5576 return statusCode;
5577 }
5578 else
5579 return eSIR_SUCCESS;
5580
5581 returnAfterError:
5582
5583 // Release buffer, if allocated
5584 if( NULL != pDelBAIndBuffer )
5585 palPktFree( pMac->hHdd,
5586 HAL_TXRX_FRM_802_11_MGMT,
5587 (void *) pDelBAIndBuffer,
5588 (void *) pPacket );
5589
5590 return statusCode;
5591}
5592
5593#if defined WLAN_FEATURE_VOWIFI
5594
5595/**
5596 * \brief Send a Neighbor Report Request Action frame
5597 *
5598 *
5599 * \param pMac Pointer to the global MAC structure
5600 *
5601 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5602 *
5603 * \param peer mac address of peer station.
5604 *
5605 * \param psessionEntry address of session entry.
5606 *
5607 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5608 *
5609 *
5610 */
5611
5612tSirRetStatus
5613limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5614 tpSirMacNeighborReportReq pNeighborReq,
5615 tSirMacAddr peer,
5616 tpPESession psessionEntry
5617 )
5618{
5619 tSirRetStatus statusCode = eSIR_SUCCESS;
5620 tDot11fNeighborReportRequest frm;
5621 tANI_U8 *pFrame;
5622 tpSirMacMgmtHdr pMacHdr;
5623 tANI_U32 nBytes, nPayload, nStatus;
5624 void *pPacket;
5625 eHalStatus halstatus;
5626 tANI_U8 txFlag = 0;
5627
5628 if ( psessionEntry == NULL )
5629 {
5630 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame\n") );
5631 return eSIR_FAILURE;
5632 }
5633 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5634
5635 frm.Category.category = SIR_MAC_ACTION_RRM;
5636 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5637 frm.DialogToken.token = pNeighborReq->dialogToken;
5638
5639
5640 if( pNeighborReq->ssid_present )
5641 {
5642 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5643 }
5644
5645 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5646 if ( DOT11F_FAILED( nStatus ) )
5647 {
5648 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5649 "or a Neighbor Report Request(0x%08x).\n"),
5650 nStatus );
5651 // We'll fall back on the worst case scenario:
5652 nPayload = sizeof( tDot11fNeighborReportRequest );
5653 }
5654 else if ( DOT11F_WARNED( nStatus ) )
5655 {
5656 limLog( pMac, LOGW, FL("There were warnings while calculating"
5657 "the packed size for a Neighbor Rep"
5658 "ort Request(0x%08x).\n"), nStatus );
5659 }
5660
5661 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5662
5663 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5664 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5665 {
5666 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
5667 "Report Request.\n"), nBytes );
5668 return eSIR_FAILURE;
5669 }
5670
5671 // Paranoia:
5672 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5673
5674 // Copy necessary info to BD
5675 if( eSIR_SUCCESS !=
5676 (statusCode = limPopulateMacHeader( pMac,
5677 pFrame,
5678 SIR_MAC_MGMT_FRAME,
5679 SIR_MAC_MGMT_ACTION,
5680 peer, psessionEntry->selfMacAddr)))
5681 goto returnAfterError;
5682
5683 // Update A3 with the BSSID
5684 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5685
5686 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5687
5688 // Now, we're ready to "pack" the frames
5689 nStatus = dot11fPackNeighborReportRequest( pMac,
5690 &frm,
5691 pFrame + sizeof( tSirMacMgmtHdr ),
5692 nPayload,
5693 &nPayload );
5694
5695 if( DOT11F_FAILED( nStatus ))
5696 {
5697 limLog( pMac, LOGE,
5698 FL( "Failed to pack an Neighbor Report Request (0x%08x).\n" ),
5699 nStatus );
5700
5701 // FIXME - Need to convert to tSirRetStatus
5702 statusCode = eSIR_FAILURE;
5703 goto returnAfterError;
5704 }
5705 else if( DOT11F_WARNED( nStatus ))
5706 {
5707 limLog( pMac, LOGW,
5708 FL( "There were warnings while packing Neighbor Report Request (0x%08x).\n" ));
5709 }
5710
5711 limLog( pMac, LOGW,
5712 FL( "Sending a Neighbor Report Request to \n" ));
5713 limPrintMacAddr( pMac, peer, LOGW );
5714
5715 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5716#ifdef WLAN_FEATURE_P2P
5717 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5718 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5719#endif
5720 )
5721 {
5722 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5723 }
5724
5725 if( eHAL_STATUS_SUCCESS !=
5726 (halstatus = halTxFrame( pMac,
5727 pPacket,
5728 (tANI_U16) nBytes,
5729 HAL_TXRX_FRM_802_11_MGMT,
5730 ANI_TXDIR_TODS,
5731 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5732 limTxComplete,
5733 pFrame, txFlag )))
5734 {
5735 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5736 statusCode = eSIR_FAILURE;
5737 //Pkt will be freed up by the callback
5738 return statusCode;
5739 }
5740 else
5741 return eSIR_SUCCESS;
5742
5743returnAfterError:
5744 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5745
5746 return statusCode;
5747} // End limSendNeighborReportRequestFrame.
5748
5749/**
5750 * \brief Send a Link Report Action frame
5751 *
5752 *
5753 * \param pMac Pointer to the global MAC structure
5754 *
5755 * \param pLinkReport Address of a tSirMacLinkReport
5756 *
5757 * \param peer mac address of peer station.
5758 *
5759 * \param psessionEntry address of session entry.
5760 *
5761 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5762 *
5763 *
5764 */
5765
5766tSirRetStatus
5767limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5768 tpSirMacLinkReport pLinkReport,
5769 tSirMacAddr peer,
5770 tpPESession psessionEntry
5771 )
5772{
5773 tSirRetStatus statusCode = eSIR_SUCCESS;
5774 tDot11fLinkMeasurementReport frm;
5775 tANI_U8 *pFrame;
5776 tpSirMacMgmtHdr pMacHdr;
5777 tANI_U32 nBytes, nPayload, nStatus;
5778 void *pPacket;
5779 eHalStatus halstatus;
5780 tANI_U8 txFlag = 0;
5781
5782
5783 if ( psessionEntry == NULL )
5784 {
5785 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame\n") );
5786 return eSIR_FAILURE;
5787 }
5788
5789 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5790
5791 frm.Category.category = SIR_MAC_ACTION_RRM;
5792 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5793 frm.DialogToken.token = pLinkReport->dialogToken;
5794
5795
5796 //IEEE Std. 802.11 7.3.2.18. for the report element.
5797 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5798 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5799 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5800 //such case this way than changing the frame parser.
5801 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5802 frm.TPCEleLen.TPCLen = 2;
5803 frm.TxPower.txPower = pLinkReport->txPower;
5804 frm.LinkMargin.linkMargin = 0;
5805
5806 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5807 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5808 frm.RCPI.rcpi = pLinkReport->rcpi;
5809 frm.RSNI.rsni = pLinkReport->rsni;
5810
5811 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5812 if ( DOT11F_FAILED( nStatus ) )
5813 {
5814 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5815 "or a Link Report (0x%08x).\n"),
5816 nStatus );
5817 // We'll fall back on the worst case scenario:
5818 nPayload = sizeof( tDot11fLinkMeasurementReport );
5819 }
5820 else if ( DOT11F_WARNED( nStatus ) )
5821 {
5822 limLog( pMac, LOGW, FL("There were warnings while calculating"
5823 "the packed size for a Link Rep"
5824 "ort (0x%08x).\n"), nStatus );
5825 }
5826
5827 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5828
5829 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5830 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5831 {
5832 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
5833 "Report.\n"), nBytes );
5834 return eSIR_FAILURE;
5835 }
5836
5837 // Paranoia:
5838 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5839
5840 // Copy necessary info to BD
5841 if( eSIR_SUCCESS !=
5842 (statusCode = limPopulateMacHeader( pMac,
5843 pFrame,
5844 SIR_MAC_MGMT_FRAME,
5845 SIR_MAC_MGMT_ACTION,
5846 peer, psessionEntry->selfMacAddr)))
5847 goto returnAfterError;
5848
5849 // Update A3 with the BSSID
5850 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5851
5852 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5853
5854 // Now, we're ready to "pack" the frames
5855 nStatus = dot11fPackLinkMeasurementReport( pMac,
5856 &frm,
5857 pFrame + sizeof( tSirMacMgmtHdr ),
5858 nPayload,
5859 &nPayload );
5860
5861 if( DOT11F_FAILED( nStatus ))
5862 {
5863 limLog( pMac, LOGE,
5864 FL( "Failed to pack an Link Report (0x%08x).\n" ),
5865 nStatus );
5866
5867 // FIXME - Need to convert to tSirRetStatus
5868 statusCode = eSIR_FAILURE;
5869 goto returnAfterError;
5870 }
5871 else if( DOT11F_WARNED( nStatus ))
5872 {
5873 limLog( pMac, LOGW,
5874 FL( "There were warnings while packing Link Report (0x%08x).\n" ));
5875 }
5876
5877 limLog( pMac, LOGW,
5878 FL( "Sending a Link Report to \n" ));
5879 limPrintMacAddr( pMac, peer, LOGW );
5880
5881 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5882#ifdef WLAN_FEATURE_P2P
5883 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5884 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5885#endif
5886 )
5887 {
5888 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5889 }
5890
5891 if( eHAL_STATUS_SUCCESS !=
5892 (halstatus = halTxFrame( pMac,
5893 pPacket,
5894 (tANI_U16) nBytes,
5895 HAL_TXRX_FRM_802_11_MGMT,
5896 ANI_TXDIR_TODS,
5897 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5898 limTxComplete,
5899 pFrame, txFlag )))
5900 {
5901 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5902 statusCode = eSIR_FAILURE;
5903 //Pkt will be freed up by the callback
5904 return statusCode;
5905 }
5906 else
5907 return eSIR_SUCCESS;
5908
5909returnAfterError:
5910 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5911
5912 return statusCode;
5913} // End limSendLinkReportActionFrame.
5914
5915/**
5916 * \brief Send a Beacon Report Action frame
5917 *
5918 *
5919 * \param pMac Pointer to the global MAC structure
5920 *
5921 * \param dialog_token dialog token to be used in the action frame.
5922 *
5923 * \param num_report number of reports in pRRMReport.
5924 *
5925 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5926 *
5927 * \param peer mac address of peer station.
5928 *
5929 * \param psessionEntry address of session entry.
5930 *
5931 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5932 *
5933 *
5934 */
5935
5936tSirRetStatus
5937limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5938 tANI_U8 dialog_token,
5939 tANI_U8 num_report,
5940 tpSirMacRadioMeasureReport pRRMReport,
5941 tSirMacAddr peer,
5942 tpPESession psessionEntry
5943 )
5944{
5945 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 tANI_U8 *pFrame;
5947 tpSirMacMgmtHdr pMacHdr;
5948 tANI_U32 nBytes, nPayload, nStatus;
5949 void *pPacket;
5950 eHalStatus halstatus;
5951 tANI_U8 i;
5952 tANI_U8 txFlag = 0;
5953
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005954 tDot11fRadioMeasurementReport *frm =
5955 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5956 if (!frm) {
5957 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport\n") );
5958 return eSIR_FAILURE;
5959 }
5960
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 if ( psessionEntry == NULL )
5962 {
5963 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame\n") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005964 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 return eSIR_FAILURE;
5966 }
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005967 palZeroMemory( pMac->hHdd, ( tANI_U8* )frm, sizeof( *frm ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005968
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005969 frm->Category.category = SIR_MAC_ACTION_RRM;
5970 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5971 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005972
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005973 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 -07005974
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005975 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005977 frm->MeasurementReport[i].type = pRRMReport[i].type;
5978 frm->MeasurementReport[i].token = pRRMReport[i].token;
5979 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 switch( pRRMReport[i].type )
5981 {
5982 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005983 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5984 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5985 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5986 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 break;
5988 default:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005989 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 break;
5991 }
5992 }
5993
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005994 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 if ( DOT11F_FAILED( nStatus ) )
5996 {
5997 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5998 "or a Radio Measure Report (0x%08x).\n"),
5999 nStatus );
6000 // We'll fall back on the worst case scenario:
6001 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006002 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 return eSIR_FAILURE;
6004 }
6005 else if ( DOT11F_WARNED( nStatus ) )
6006 {
6007 limLog( pMac, LOGW, FL("There were warnings while calculating"
6008 "the packed size for a Radio Measure Rep"
6009 "ort (0x%08x).\n"), nStatus );
6010 }
6011
6012 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6013
6014 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6015 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6016 {
6017 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
6018 "Report.\n"), nBytes );
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 }
6022
6023 // Paranoia:
6024 palZeroMemory( pMac->hHdd, pFrame, nBytes );
6025
6026 // Copy necessary info to BD
6027 if( eSIR_SUCCESS !=
6028 (statusCode = limPopulateMacHeader( pMac,
6029 pFrame,
6030 SIR_MAC_MGMT_FRAME,
6031 SIR_MAC_MGMT_ACTION,
6032 peer, psessionEntry->selfMacAddr)))
6033 goto returnAfterError;
6034
6035 // Update A3 with the BSSID
6036 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6037
6038 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6039
6040 // Now, we're ready to "pack" the frames
6041 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006042 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006043 pFrame + sizeof( tSirMacMgmtHdr ),
6044 nPayload,
6045 &nPayload );
6046
6047 if( DOT11F_FAILED( nStatus ))
6048 {
6049 limLog( pMac, LOGE,
6050 FL( "Failed to pack an Radio Measure Report (0x%08x).\n" ),
6051 nStatus );
6052
6053 // FIXME - Need to convert to tSirRetStatus
6054 statusCode = eSIR_FAILURE;
6055 goto returnAfterError;
6056 }
6057 else if( DOT11F_WARNED( nStatus ))
6058 {
6059 limLog( pMac, LOGW,
6060 FL( "There were warnings while packing Radio Measure Report (0x%08x).\n" ));
6061 }
6062
6063 limLog( pMac, LOGW,
6064 FL( "Sending a Radio Measure Report to \n" ));
6065 limPrintMacAddr( pMac, peer, LOGW );
6066
6067 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
6068#ifdef WLAN_FEATURE_P2P
6069 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6070 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
6071#endif
6072 )
6073 {
6074 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6075 }
6076
6077 if( eHAL_STATUS_SUCCESS !=
6078 (halstatus = halTxFrame( pMac,
6079 pPacket,
6080 (tANI_U16) nBytes,
6081 HAL_TXRX_FRM_802_11_MGMT,
6082 ANI_TXDIR_TODS,
6083 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6084 limTxComplete,
6085 pFrame, txFlag )))
6086 {
6087 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
6088 statusCode = eSIR_FAILURE;
6089 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006090 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 return statusCode;
6092 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006093 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006094 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006097
6098returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006099 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 return statusCode;
6102} // End limSendBeaconReportActionFrame.
6103
6104#endif
6105
6106#ifdef WLAN_FEATURE_11W
6107/**
6108 * \brief Send SA query response action frame to peer
6109 *
6110 * \sa limSendSaQueryResponseFrame
6111 *
6112 *
6113 * \param pMac The global tpAniSirGlobal object
6114 *
6115 * \param peer The Mac address of the AP to which this action frame is
6116addressed
6117 *
6118 * \param transId Transaction identifier received in SA query request action
6119frame
6120 *
6121 * \return eSIR_SUCCESS if setup completes successfully
6122 * eSIR_FAILURE is some problem is encountered
6123 */
6124
6125tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U16 transId,
6126tSirMacAddr peer,tpPESession psessionEntry)
6127{
6128
6129 tDot11wSaQueryRsp frm; // SA query reponse action frame
6130 tANI_U8 *pFrame;
6131 tSirRetStatus nSirStatus;
6132 tpSirMacMgmtHdr pMacHdr;
6133 tANI_U32 nBytes, nPayload;
6134 void *pPacket;
6135 eHalStatus halstatus;
6136 // Local variables used to dump prepared SA query response frame
6137 tANI_U8 *pDump;
6138 tANI_U16 dumpCount;
6139 tANI_U8 txFlag = 0;
6140 //tANI_U16 nBytes
6141
6142 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
6143 frm.category = SIR_MAC_ACTION_SA_QUERY;
6144 /*11w action fiedl is :
6145 action: 0 --> SA query request action frame
6146 action: 1 --> SA query response action frame */
6147 frm.action = 1;
6148 /*11w Draft9.0 SA query response transId is same as
6149 SA query request transId*/
6150 frm.transId = transId;
6151
6152 nPayload = sizeof(tDot11wSaQueryRsp);
6153 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6154 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6155 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6156 {
6157 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
6158 " action frame\n"), nBytes );
6159 return eSIR_FAILURE;
6160 }
6161
6162 // Paranoia:
6163 palZeroMemory( pMac->hHdd, pFrame, nBytes );
6164
6165 // Next, we fill out the buffer descriptor:
6166 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
6167 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr );
6168 if ( eSIR_SUCCESS != nSirStatus )
6169 {
6170 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
6171 "tor for a TPC Report (%d).\n"),
6172 nSirStatus );
6173 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6174 return eSIR_FAILURE; // just allocated...
6175 }
6176
6177 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6178
6179 // Pack 11w SA query response frame
6180 DOT11F_MEMCPY(pMac, (tANI_U8 *)(pFrame + sizeof(tSirMacMgmtHdr)),(tANI_U8 *)&frm, nPayload);
6181 pDump = (tANI_U8 *) pFrame;
6182
6183 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
6184 HAL_TXRX_FRM_802_11_MGMT,
6185 ANI_TXDIR_TODS,
6186 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6187 limTxComplete, pFrame,txFlag);
6188 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6189 {
6190 limLog( pMac, LOGE, FL("Failed to send a SA Query resp frame "
6191 "(%X)!\n"),halstatus );
6192 //Pkt will be freed up by the callback
6193 return eSIR_FAILURE; // just allocated...
6194 }
6195
6196 return eSIR_SUCCESS;
6197}
6198#endif