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