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