blob: b202bfe5482853fa1281b28954fa5b66b30b81cd [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
2881 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen; ;
2882
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
3006 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3007 HAL_TXRX_FRM_802_11_MGMT,
3008 ANI_TXDIR_TODS,
3009 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3010 limTxComplete, pFrame, txFlag );
3011 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3012 {
3013 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
3014 "(%X)!\n"),
3015 nSirStatus );
3016 //Pkt will be freed up by the callback
3017 goto end;
3018 }
3019
3020end:
3021 // Free up buffer allocated for mlmAssocReq
3022 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3023 psessionEntry->pLimMlmReassocReq = NULL;
3024
3025}
3026#endif /* WLAN_FEATURE_VOWIFI_11R */
3027
3028
3029void
3030limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3031 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3032{
3033 static tDot11fReAssocRequest frm;
3034 tANI_U16 caps;
3035 tANI_U8 *pFrame;
3036 tSirRetStatus nSirStatus;
3037 tANI_U32 nBytes, nPayload, nStatus;
3038 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3039 void *pPacket;
3040 eHalStatus halstatus;
3041 tANI_U16 nAddIELen;
3042 tANI_U8 *pAddIE;
3043 tANI_U8 *wpsIe = NULL;
3044 tANI_U8 txFlag = 0;
3045#if defined WLAN_FEATURE_VOWIFI
3046 tANI_U8 PowerCapsPopulated = FALSE;
3047#endif
3048
3049 if(NULL == psessionEntry)
3050 {
3051 return;
3052 }
3053
3054 /* check this early to avoid unncessary operation */
3055 if(NULL == psessionEntry->pLimReAssocReq)
3056 {
3057 return;
3058 }
3059 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3060 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3061
3062 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3063
3064 caps = pMlmReassocReq->capabilityInfo;
3065 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3066 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3067#if defined(FEATURE_WLAN_WAPI)
3068 /* CR: 262463 :
3069 According to WAPI standard:
3070 7.3.1.4 Capability Information field
3071 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3072 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3073 Reassociation management frames. */
3074 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3075 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3076#endif
3077 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3078
3079 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3080
3081 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
3082 ( tANI_U8* )psessionEntry->bssId, 6 );
3083
3084 PopulateDot11fSSID2( pMac, &frm.SSID );
3085 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3086 &frm.SuppRates,psessionEntry);
3087
3088 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3089 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3090
3091 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3092 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3093
3094 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3095 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3096
3097
3098 if ( psessionEntry->lim11hEnable &&
3099 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3100 {
3101#if defined WLAN_FEATURE_VOWIFI
3102 PowerCapsPopulated = TRUE;
3103 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3104 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3105#endif
3106 }
3107
3108#if defined WLAN_FEATURE_VOWIFI
3109 if( pMac->rrm.rrmPEContext.rrmEnable &&
3110 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3111 {
3112 if (PowerCapsPopulated == FALSE)
3113 {
3114 PowerCapsPopulated = TRUE;
3115 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3116 }
3117 }
3118#endif
3119
3120 if ( fQosEnabled &&
3121 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3122 {
3123 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3124 }
3125
3126 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3127 &frm.ExtSuppRates, psessionEntry );
3128
3129#if defined WLAN_FEATURE_VOWIFI
3130 if( pMac->rrm.rrmPEContext.rrmEnable &&
3131 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3132 {
3133 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3134 }
3135#endif
3136 // The join request *should* contain zero or one of the WPA and RSN
3137 // IEs. The payload send along with the request is a
3138 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3139
3140 // typedef struct sSirRSNie
3141 // {
3142 // tANI_U16 length;
3143 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3144 // } tSirRSNie, *tpSirRSNie;
3145
3146 // So, we should be able to make the following two calls harmlessly,
3147 // since they do nothing if they don't find the given IE in the
3148 // bytestream with which they're provided.
3149
3150 // The net effect of this will be to faithfully transmit whatever
3151 // security IE is in the join request.
3152
3153 // *However*, if we're associating for the purpose of WPS
3154 // enrollment, and we've been configured to indicate that by
3155 // eliding the WPA or RSN IE, we just skip this:
3156 if( nAddIELen && pAddIE )
3157 {
3158 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3159 }
3160 if ( NULL == wpsIe )
3161 {
3162 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3163 &frm.RSNOpaque );
3164 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3165 &frm.WPAOpaque );
3166#if defined(FEATURE_WLAN_WAPI)
3167 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3168 &frm.WAPIOpaque );
3169#endif // defined(FEATURE_WLAN_WAPI)
3170 }
3171
3172 // include WME EDCA IE as well
3173 if ( fWmeEnabled )
3174 {
3175 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3176 {
3177 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3178 }
3179
3180 if ( fWsmEnabled &&
3181 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3182 {
3183 PopulateDot11fWMMCaps( &frm.WMMCaps );
3184 }
3185 }
3186
Jeff Johnsone7245742012-09-05 17:12:55 -07003187 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 pMac->lim.htCapabilityPresentInBeacon)
3189 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003190 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003192#ifdef WLAN_FEATURE_11AC
3193 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003194 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003195 {
3196 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request\n"));
3197 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07003198 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003199 }
3200#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003201
3202 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3203 if ( DOT11F_FAILED( nStatus ) )
3204 {
3205 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3206 "or a Re-Association Request (0x%08x).\n"),
3207 nStatus );
3208 // We'll fall back on the worst case scenario:
3209 nPayload = sizeof( tDot11fReAssocRequest );
3210 }
3211 else if ( DOT11F_WARNED( nStatus ) )
3212 {
3213 limLog( pMac, LOGW, FL("There were warnings while calculating"
3214 "the packed size for a Re-Association Re "
3215 "quest(0x%08x).\n"), nStatus );
3216 }
3217
3218 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3219
3220 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3221 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3222 ( void** ) &pPacket );
3223 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3224 {
3225 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003226 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
3228 "sociation Request.\n"), nBytes );
3229 goto end;
3230 }
3231
3232 // Paranoia:
3233 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3234
3235 // Next, we fill out the buffer descriptor:
3236 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3237 SIR_MAC_MGMT_REASSOC_REQ,
3238 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3239 if ( eSIR_SUCCESS != nSirStatus )
3240 {
3241 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3242 "tor for an Association Request (%d).\n"),
3243 nSirStatus );
3244 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3245 goto end;
3246 }
3247
3248
3249 // That done, pack the Probe Request:
3250 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3251 sizeof(tSirMacMgmtHdr),
3252 nPayload, &nPayload );
3253 if ( DOT11F_FAILED( nStatus ) )
3254 {
3255 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
3256 "st (0x%08x).\n"),
3257 nStatus );
3258 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3259 goto end;
3260 }
3261 else if ( DOT11F_WARNED( nStatus ) )
3262 {
3263 limLog( pMac, LOGW, FL("There were warnings while packing a R"
3264 "e-Association Request (0x%08x).\n") );
3265 }
3266
3267 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
3268 "to \n"),
3269 nBytes );)
3270
3271 if( psessionEntry->assocReq != NULL )
3272 {
3273 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
3274 psessionEntry->assocReq = NULL;
3275 }
3276
3277 if( nAddIELen )
3278 {
3279 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3280 pAddIE,
3281 nAddIELen );
3282 nPayload += nAddIELen;
3283 }
3284
Jeff Johnson43971f52012-07-17 12:26:56 -07003285 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
3286 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 {
3288 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003289 }
3290 else
3291 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3293 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
3294 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003296
3297 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3298#ifdef WLAN_FEATURE_P2P
3299 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3300 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3301#endif
3302 )
3303 {
3304 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3305 }
3306
3307 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3308 HAL_TXRX_FRM_802_11_MGMT,
3309 ANI_TXDIR_TODS,
3310 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3311 limTxComplete, pFrame, txFlag );
3312 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3313 {
3314 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
3315 "(%X)!\n"),
3316 nSirStatus );
3317 //Pkt will be freed up by the callback
3318 goto end;
3319 }
3320
3321end:
3322 // Free up buffer allocated for mlmAssocReq
3323 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3324 psessionEntry->pLimMlmReassocReq = NULL;
3325
3326} // limSendReassocReqMgmtFrame
3327
3328/**
3329 * \brief Send an Authentication frame
3330 *
3331 *
3332 * \param pMac Pointer to Global MAC structure
3333 *
3334 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3335 * to be sent
3336 *
3337 * \param peerMacAddr MAC address of the peer entity to which Authentication
3338 * frame is destined
3339 *
3340 * \param wepBit Indicates whether wep bit to be set in FC while sending
3341 * Authentication frame3
3342 *
3343 *
3344 * This function is called by limProcessMlmMessages(). Authentication frame
3345 * is formatted and sent when this function is called.
3346 *
3347 *
3348 */
3349
3350void
3351limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3352 tpSirMacAuthFrameBody pAuthFrameBody,
3353 tSirMacAddr peerMacAddr,
3354 tANI_U8 wepBit,
3355 tpPESession psessionEntry
3356 )
3357{
3358 tANI_U8 *pFrame, *pBody;
3359 tANI_U32 frameLen = 0, bodyLen = 0;
3360 tpSirMacMgmtHdr pMacHdr;
3361 tANI_U16 i;
3362 void *pPacket;
3363 eHalStatus halstatus;
3364 tANI_U8 txFlag = 0;
3365
3366 if(NULL == psessionEntry)
3367 {
3368 return;
3369 }
3370
3371 if (wepBit == LIM_WEP_IN_FC)
3372 {
3373 /// Auth frame3 to be sent with encrypted framebody
3374 /**
3375 * Allocate buffer for Authenticaton frame of size equal
3376 * to management frame header length plus 2 bytes each for
3377 * auth algorithm number, transaction number, status code,
3378 * 128 bytes for challenge text and 4 bytes each for
3379 * IV & ICV.
3380 */
3381
3382 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3383
3384 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3385 } // if (wepBit == LIM_WEP_IN_FC)
3386 else
3387 {
3388 switch (pAuthFrameBody->authTransactionSeqNumber)
3389 {
3390 case SIR_MAC_AUTH_FRAME_1:
3391 /**
3392 * Allocate buffer for Authenticaton frame of size
3393 * equal to management frame header length plus 2 bytes
3394 * each for auth algorithm number, transaction number
3395 * and status code.
3396 */
3397
3398 frameLen = sizeof(tSirMacMgmtHdr) +
3399 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3400 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3401
3402#if defined WLAN_FEATURE_VOWIFI_11R
3403 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3404 {
3405 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies)
3406 {
3407 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
3408 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d\n"),
3409 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
3410 }
3411 else
3412 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!\n"));
3413 }
3414#endif
3415 break;
3416
3417 case SIR_MAC_AUTH_FRAME_2:
3418 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3419 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3420 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3421 {
3422 /**
3423 * Allocate buffer for Authenticaton frame of size
3424 * equal to management frame header length plus
3425 * 2 bytes each for auth algorithm number,
3426 * transaction number and status code.
3427 */
3428
3429 frameLen = sizeof(tSirMacMgmtHdr) +
3430 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3431 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3432 }
3433 else
3434 {
3435 // Shared Key algorithm with challenge text
3436 // to be sent
3437 /**
3438 * Allocate buffer for Authenticaton frame of size
3439 * equal to management frame header length plus
3440 * 2 bytes each for auth algorithm number,
3441 * transaction number, status code and 128 bytes
3442 * for challenge text.
3443 */
3444
3445 frameLen = sizeof(tSirMacMgmtHdr) +
3446 sizeof(tSirMacAuthFrame);
3447 bodyLen = sizeof(tSirMacAuthFrameBody);
3448 }
3449
3450 break;
3451
3452 case SIR_MAC_AUTH_FRAME_3:
3453 /// Auth frame3 to be sent without encrypted framebody
3454 /**
3455 * Allocate buffer for Authenticaton frame of size equal
3456 * to management frame header length plus 2 bytes each
3457 * for auth algorithm number, transaction number and
3458 * status code.
3459 */
3460
3461 frameLen = sizeof(tSirMacMgmtHdr) +
3462 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3463 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3464
3465 break;
3466
3467 case SIR_MAC_AUTH_FRAME_4:
3468 /**
3469 * Allocate buffer for Authenticaton frame of size equal
3470 * to management frame header length plus 2 bytes each
3471 * for auth algorithm number, transaction number and
3472 * status code.
3473 */
3474
3475 frameLen = sizeof(tSirMacMgmtHdr) +
3476 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3477 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3478
3479 break;
3480 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3481 } // end if (wepBit == LIM_WEP_IN_FC)
3482
3483
3484 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3485
3486 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3487 {
3488 // Log error
3489 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame\n"));
3490
3491 return;
3492 }
3493
3494 for (i = 0; i < frameLen; i++)
3495 pFrame[i] = 0;
3496
3497 // Prepare BD
3498 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3499 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3500 {
3501 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3502 return;
3503 }
3504
3505 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3506 pMacHdr->fc.wep = wepBit;
3507
3508 // Prepare BSSId
3509 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3510 {
3511 palCopyMemory( pMac->hHdd,(tANI_U8 *) pMacHdr->bssId,
3512 (tANI_U8 *) psessionEntry->bssId,
3513 sizeof( tSirMacAddr ));
3514 }
3515
3516 /// Prepare Authentication frame body
3517 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3518
3519 if (wepBit == LIM_WEP_IN_FC)
3520 {
3521 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
3522
3523 PELOG1(limLog(pMac, LOG1,
3524 FL("*** Sending Auth seq# 3 status %d (%d) to\n"),
3525 pAuthFrameBody->authStatusCode,
3526 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3527
3528 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3529 }
3530 else
3531 {
3532 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3533 pBody += sizeof(tANI_U16);
3534 bodyLen -= sizeof(tANI_U16);
3535
3536 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3537 pBody += sizeof(tANI_U16);
3538 bodyLen -= sizeof(tANI_U16);
3539
3540 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3541 pBody += sizeof(tANI_U16);
3542 bodyLen -= sizeof(tANI_U16);
3543
3544 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
3545
3546#if defined WLAN_FEATURE_VOWIFI_11R
3547 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3548 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3549 {
3550
3551 {
3552 int i = 0;
3553#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
3554 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3555 {
3556 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3557 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3558 (tANI_U8 *)pBody,
3559 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
3560 }
3561#endif
3562 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3563 {
3564 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3565 pBody++;
3566 }
3567 }
3568 }
3569#endif
3570
3571 PELOG1(limLog(pMac, LOG1,
3572 FL("*** Sending Auth seq# %d status %d (%d) to "),
3573 pAuthFrameBody->authTransactionSeqNumber,
3574 pAuthFrameBody->authStatusCode,
3575 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3576
3577 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3578 }
3579 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3580
3581 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3582#ifdef WLAN_FEATURE_P2P
3583 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3584 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3585#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003586#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
3587 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
3588 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3589#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 )
3591 {
3592 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3593 }
3594
3595 /// Queue Authentication frame in high priority WQ
3596 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3597 HAL_TXRX_FRM_802_11_MGMT,
3598 ANI_TXDIR_TODS,
3599 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3600 limTxComplete, pFrame, txFlag );
3601 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3602 {
3603 limLog(pMac, LOGE,
3604 FL("*** Could not send Auth frame, retCode=%X ***\n"),
3605 halstatus);
3606
3607 //Pkt will be freed up by the callback
3608 }
3609
3610 return;
3611} /*** end limSendAuthMgmtFrame() ***/
3612
3613/**
3614 * \brief This function is called to send Disassociate frame.
3615 *
3616 *
3617 * \param pMac Pointer to Global MAC structure
3618 *
3619 * \param nReason Indicates the reason that need to be sent in
3620 * Disassociation frame
3621 *
3622 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3623 * sent
3624 *
3625 *
3626 */
3627
3628void
3629limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3630 tANI_U16 nReason,
3631 tSirMacAddr peer,tpPESession psessionEntry)
3632{
3633 tDot11fDisassociation frm;
3634 tANI_U8 *pFrame;
3635 tSirRetStatus nSirStatus;
3636 tpSirMacMgmtHdr pMacHdr;
3637 tANI_U32 nBytes, nPayload, nStatus;
3638 void *pPacket;
3639 eHalStatus halstatus;
3640 tANI_U8 txFlag = 0;
3641
3642 if(NULL == psessionEntry)
3643 {
3644 return;
3645 }
3646
3647 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3648
3649 frm.Reason.code = nReason;
3650
3651 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3652 if ( DOT11F_FAILED( nStatus ) )
3653 {
3654 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3655 "or a Disassociation (0x%08x).\n"),
3656 nStatus );
3657 // We'll fall back on the worst case scenario:
3658 nPayload = sizeof( tDot11fDisassociation );
3659 }
3660 else if ( DOT11F_WARNED( nStatus ) )
3661 {
3662 limLog( pMac, LOGW, FL("There were warnings while calculating"
3663 "the packed size for a Disassociation "
3664 "(0x%08x).\n"), nStatus );
3665 }
3666
3667 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3668
3669 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3670 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3671 ( void** ) &pPacket );
3672 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3673 {
3674 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
3675 "association.\n"), nBytes );
3676 return;
3677 }
3678
3679 // Paranoia:
3680 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3681
3682 // Next, we fill out the buffer descriptor:
3683 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3684 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3685 if ( eSIR_SUCCESS != nSirStatus )
3686 {
3687 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3688 "tor for a Disassociation (%d).\n"),
3689 nSirStatus );
3690 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3691 ( void* ) pFrame, ( void* ) pPacket );
3692 return; // just allocated...
3693 }
3694
3695 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3696
3697 // Prepare the BSSID
3698 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3699
3700 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3701 sizeof(tSirMacMgmtHdr),
3702 nPayload, &nPayload );
3703 if ( DOT11F_FAILED( nStatus ) )
3704 {
3705 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x).\n"),
3706 nStatus );
3707 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3708 ( void* ) pFrame, ( void* ) pPacket );
3709 return; // allocated!
3710 }
3711 else if ( DOT11F_WARNED( nStatus ) )
3712 {
3713 limLog( pMac, LOGW, FL("There were warnings while packing a D"
3714 "isassociation (0x%08x).\n") );
3715 }
3716
3717 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
3718 "son %d to\n"), nReason );
3719 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3720
3721 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3722#ifdef WLAN_FEATURE_P2P
3723 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3724 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3725#endif
3726 )
3727 {
3728 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3729 }
3730
3731 // Queue Disassociation frame in high priority WQ
3732 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3733 HAL_TXRX_FRM_802_11_MGMT,
3734 ANI_TXDIR_TODS,
3735 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3736 limTxComplete, pFrame, txFlag );
3737 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3738 {
3739 limLog( pMac, LOGE, FL("Failed to send Disassociation "
3740 "(%X)!\n"),
3741 nSirStatus );
3742 //Pkt will be freed up by the callback
3743 return;
3744 }
3745
3746} // End limSendDisassocMgmtFrame.
3747
3748/**
3749 * \brief This function is called to send a Deauthenticate frame
3750 *
3751 *
3752 * \param pMac Pointer to global MAC structure
3753 *
3754 * \param nReason Indicates the reason that need to be sent in the
3755 * Deauthenticate frame
3756 *
3757 * \param peeer address of the STA to which the frame is to be sent
3758 *
3759 *
3760 */
3761
3762void
3763limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3764 tANI_U16 nReason,
3765 tSirMacAddr peer,tpPESession psessionEntry)
3766{
3767 tDot11fDeAuth frm;
3768 tANI_U8 *pFrame;
3769 tSirRetStatus nSirStatus;
3770 tpSirMacMgmtHdr pMacHdr;
3771 tANI_U32 nBytes, nPayload, nStatus;
3772 void *pPacket;
3773 eHalStatus halstatus;
3774 tANI_U8 txFlag = 0;
3775
3776 if(NULL == psessionEntry)
3777 {
3778 return;
3779 }
3780
3781 palZeroMemory( pMac->hHdd, ( tANI_U8* ) &frm, sizeof( frm ) );
3782
3783 frm.Reason.code = nReason;
3784
3785 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3786 if ( DOT11F_FAILED( nStatus ) )
3787 {
3788 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3789 "or a De-Authentication (0x%08x).\n"),
3790 nStatus );
3791 // We'll fall back on the worst case scenario:
3792 nPayload = sizeof( tDot11fDeAuth );
3793 }
3794 else if ( DOT11F_WARNED( nStatus ) )
3795 {
3796 limLog( pMac, LOGW, FL("There were warnings while calculating"
3797 "the packed size for a De-Authentication "
3798 "(0x%08x).\n"), nStatus );
3799 }
3800
3801 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3802
3803 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3804 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3805 ( void** ) &pPacket );
3806 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3807 {
3808 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
3809 "Authentication.\n"), nBytes );
3810 return;
3811 }
3812
3813 // Paranoia:
3814 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3815
3816 // Next, we fill out the buffer descriptor:
3817 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3818 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3819 if ( eSIR_SUCCESS != nSirStatus )
3820 {
3821 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3822 "tor for a De-Authentication (%d).\n"),
3823 nSirStatus );
3824 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3825 ( void* ) pFrame, ( void* ) pPacket );
3826 return; // just allocated...
3827 }
3828
3829 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3830
3831 // Prepare the BSSID
3832 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3833
3834 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3835 sizeof(tSirMacMgmtHdr),
3836 nPayload, &nPayload );
3837 if ( DOT11F_FAILED( nStatus ) )
3838 {
3839 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x).\n"),
3840 nStatus );
3841 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3842 ( void* ) pFrame, ( void* ) pPacket );
3843 return;
3844 }
3845 else if ( DOT11F_WARNED( nStatus ) )
3846 {
3847 limLog( pMac, LOGW, FL("There were warnings while packing a D"
3848 "e-Authentication (0x%08x).\n") );
3849 }
3850
3851 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
3852 "son %d to\n"), nReason );
3853 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3854
3855 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3856#ifdef WLAN_FEATURE_P2P
3857 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3858 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3859#endif
3860 )
3861 {
3862 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3863 }
3864
3865 // Queue Disassociation frame in high priority WQ
3866 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3867 HAL_TXRX_FRM_802_11_MGMT,
3868 ANI_TXDIR_TODS,
3869 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3870 limTxComplete, pFrame, txFlag );
3871 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3872 {
3873 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
3874 "(%X)!\n"),
3875 nSirStatus );
3876 //Pkt will be freed up by the callback
3877 return;
3878 }
3879
3880} // End limSendDeauthMgmtFrame.
3881
3882
3883#ifdef ANI_SUPPORT_11H
3884/**
3885 * \brief Send a Measurement Report Action frame
3886 *
3887 *
3888 * \param pMac Pointer to the global MAC structure
3889 *
3890 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3891 *
3892 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3893 *
3894 *
3895 */
3896
3897tSirRetStatus
3898limSendMeasReportFrame(tpAniSirGlobal pMac,
3899 tpSirMacMeasReqActionFrame pMeasReqFrame,
3900 tSirMacAddr peer)
3901{
3902 tDot11fMeasurementReport frm;
3903 tANI_U8 *pFrame;
3904 tSirRetStatus nSirStatus;
3905 tpSirMacMgmtHdr pMacHdr;
3906 tANI_U32 nBytes, nPayload, nStatus, nCfg;
3907 void *pPacket;
3908 eHalStatus halstatus;
3909
3910 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3911
3912 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3913 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3914 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3915
3916 switch ( pMeasReqFrame->measReqIE.measType )
3917 {
3918 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3919 nSirStatus =
3920 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
3921 &frm.MeasurementReport );
3922 break;
3923 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3924 nSirStatus =
3925 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
3926 &frm.MeasurementReport );
3927 break;
3928 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3929 nSirStatus =
3930 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
3931 &frm.MeasurementReport );
3932 break;
3933 default:
3934 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
3935 "dMeasReportFrame.\n"),
3936 pMeasReqFrame->measReqIE.measType );
3937 return eSIR_FAILURE;
3938 }
3939
3940 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
3941
3942 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
3943 if ( DOT11F_FAILED( nStatus ) )
3944 {
3945 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3946 "or a Measurement Report (0x%08x).\n"),
3947 nStatus );
3948 // We'll fall back on the worst case scenario:
3949 nPayload = sizeof( tDot11fMeasurementReport );
3950 }
3951 else if ( DOT11F_WARNED( nStatus ) )
3952 {
3953 limLog( pMac, LOGW, FL("There were warnings while calculating"
3954 "the packed size for a Measurement Rep"
3955 "ort (0x%08x).\n"), nStatus );
3956 }
3957
3958 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3959
3960 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
3961 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3962 {
3963 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
3964 "Authentication.\n"), nBytes );
3965 return eSIR_FAILURE;
3966 }
3967
3968 // Paranoia:
3969 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3970
3971 // Next, we fill out the buffer descriptor:
3972 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3973 SIR_MAC_MGMT_ACTION, peer);
3974 if ( eSIR_SUCCESS != nSirStatus )
3975 {
3976 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3977 "tor for a Measurement Report (%d).\n"),
3978 nSirStatus );
3979 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3980 return eSIR_FAILURE; // just allocated...
3981 }
3982
3983 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3984
3985 nCfg = 6;
3986 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
3987 if ( eSIR_SUCCESS != nSirStatus )
3988 {
3989 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
3990 " CFG (%d).\n"),
3991 nSirStatus );
3992 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3993 return eSIR_FAILURE; // just allocated...
3994 }
3995
3996 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
3997 sizeof(tSirMacMgmtHdr),
3998 nPayload, &nPayload );
3999 if ( DOT11F_FAILED( nStatus ) )
4000 {
4001 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x).\n"),
4002 nStatus );
4003 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4004 return eSIR_FAILURE; // allocated!
4005 }
4006 else if ( DOT11F_WARNED( nStatus ) )
4007 {
4008 limLog( pMac, LOGW, FL("There were warnings while packing a M"
4009 "easurement Report (0x%08x).\n") );
4010 }
4011
4012 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4013 HAL_TXRX_FRM_802_11_MGMT,
4014 ANI_TXDIR_TODS,
4015 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4016 limTxComplete, pFrame, 0 );
4017 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4018 {
4019 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
4020 "(%X)!\n"),
4021 nSirStatus );
4022 //Pkt will be freed up by the callback
4023 return eSIR_FAILURE; // just allocated...
4024 }
4025
4026 return eSIR_SUCCESS;
4027
4028} // End limSendMeasReportFrame.
4029
4030
4031/**
4032 * \brief Send a TPC Request Action frame
4033 *
4034 *
4035 * \param pMac Pointer to the global MAC datastructure
4036 *
4037 * \param peer MAC address to which the frame should be sent
4038 *
4039 *
4040 */
4041
4042void
4043limSendTpcRequestFrame(tpAniSirGlobal pMac,
4044 tSirMacAddr peer)
4045{
4046 tDot11fTPCRequest frm;
4047 tANI_U8 *pFrame;
4048 tSirRetStatus nSirStatus;
4049 tpSirMacMgmtHdr pMacHdr;
4050 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4051 void *pPacket;
4052 eHalStatus halstatus;
4053
4054 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4055
4056 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4057 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4058 frm.DialogToken.token = 1;
4059 frm.TPCRequest.present = 1;
4060
4061 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4062 if ( DOT11F_FAILED( nStatus ) )
4063 {
4064 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4065 "or a TPC Request (0x%08x).\n"),
4066 nStatus );
4067 // We'll fall back on the worst case scenario:
4068 nPayload = sizeof( tDot11fTPCRequest );
4069 }
4070 else if ( DOT11F_WARNED( nStatus ) )
4071 {
4072 limLog( pMac, LOGW, FL("There were warnings while calculating"
4073 "the packed size for a TPC Request (0x"
4074 "%08x).\n"), nStatus );
4075 }
4076
4077 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4078
4079 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4080 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4081 {
4082 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4083 " Request.\n"), nBytes );
4084 return;
4085 }
4086
4087 // Paranoia:
4088 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4089
4090 // Next, we fill out the buffer descriptor:
4091 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4092 SIR_MAC_MGMT_ACTION, peer);
4093 if ( eSIR_SUCCESS != nSirStatus )
4094 {
4095 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4096 "tor for a TPC Request (%d).\n"),
4097 nSirStatus );
4098 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4099 return; // just allocated...
4100 }
4101
4102 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4103
4104 nCfg = 6;
4105 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4106 if ( eSIR_SUCCESS != nSirStatus )
4107 {
4108 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4109 " CFG (%d).\n"),
4110 nSirStatus );
4111 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4112 return; // just allocated...
4113 }
4114
4115 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4116 sizeof(tSirMacMgmtHdr),
4117 nPayload, &nPayload );
4118 if ( DOT11F_FAILED( nStatus ) )
4119 {
4120 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x).\n"),
4121 nStatus );
4122 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4123 return; // allocated!
4124 }
4125 else if ( DOT11F_WARNED( nStatus ) )
4126 {
4127 limLog( pMac, LOGW, FL("There were warnings while packing a T"
4128 "PC Request (0x%08x).\n") );
4129 }
4130
4131 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4132 HAL_TXRX_FRM_802_11_MGMT,
4133 ANI_TXDIR_TODS,
4134 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4135 limTxComplete, pFrame, 0 );
4136 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4137 {
4138 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
4139 "(%X)!\n"),
4140 nSirStatus );
4141 //Pkt will be freed up by the callback
4142 return;
4143 }
4144
4145} // End limSendTpcRequestFrame.
4146
4147
4148/**
4149 * \brief Send a TPC Report Action frame
4150 *
4151 *
4152 * \param pMac Pointer to the global MAC datastructure
4153 *
4154 * \param pTpcReqFrame Pointer to the received TPC Request
4155 *
4156 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4157 *
4158 *
4159 */
4160
4161tSirRetStatus
4162limSendTpcReportFrame(tpAniSirGlobal pMac,
4163 tpSirMacTpcReqActionFrame pTpcReqFrame,
4164 tSirMacAddr peer)
4165{
4166 tDot11fTPCReport frm;
4167 tANI_U8 *pFrame;
4168 tSirRetStatus nSirStatus;
4169 tpSirMacMgmtHdr pMacHdr;
4170 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4171 void *pPacket;
4172 eHalStatus halstatus;
4173
4174 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4175
4176 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4177 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4178 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4179
4180 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4181 // "misplaced this function, need to replace:
4182 // txPower = halGetRateToPwrValue(pMac, staid,
4183 // pMac->lim.gLimCurrentChannelId, 0);
4184 frm.TPCReport.tx_power = 0;
4185 frm.TPCReport.link_margin = 0;
4186 frm.TPCReport.present = 1;
4187
4188 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4189 if ( DOT11F_FAILED( nStatus ) )
4190 {
4191 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4192 "or a TPC Report (0x%08x).\n"),
4193 nStatus );
4194 // We'll fall back on the worst case scenario:
4195 nPayload = sizeof( tDot11fTPCReport );
4196 }
4197 else if ( DOT11F_WARNED( nStatus ) )
4198 {
4199 limLog( pMac, LOGW, FL("There were warnings while calculating"
4200 "the packed size for a TPC Report (0x"
4201 "%08x).\n"), nStatus );
4202 }
4203
4204 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4205
4206 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4207 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4208 {
4209 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4210 " Report.\n"), nBytes );
4211 return eSIR_FAILURE;
4212 }
4213
4214 // Paranoia:
4215 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4216
4217 // Next, we fill out the buffer descriptor:
4218 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4219 SIR_MAC_MGMT_ACTION, peer);
4220 if ( eSIR_SUCCESS != nSirStatus )
4221 {
4222 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4223 "tor for a TPC Report (%d).\n"),
4224 nSirStatus );
4225 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4226 return eSIR_FAILURE; // just allocated...
4227 }
4228
4229 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4230
4231 nCfg = 6;
4232 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4233 if ( eSIR_SUCCESS != nSirStatus )
4234 {
4235 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4236 " CFG (%d).\n"),
4237 nSirStatus );
4238 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4239 return eSIR_FAILURE; // just allocated...
4240 }
4241
4242 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4243 sizeof(tSirMacMgmtHdr),
4244 nPayload, &nPayload );
4245 if ( DOT11F_FAILED( nStatus ) )
4246 {
4247 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x).\n"),
4248 nStatus );
4249 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4250 return eSIR_FAILURE; // allocated!
4251 }
4252 else if ( DOT11F_WARNED( nStatus ) )
4253 {
4254 limLog( pMac, LOGW, FL("There were warnings while packing a T"
4255 "PC Report (0x%08x).\n") );
4256 }
4257
4258
4259 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4260 HAL_TXRX_FRM_802_11_MGMT,
4261 ANI_TXDIR_TODS,
4262 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4263 limTxComplete, pFrame, 0 );
4264 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4265 {
4266 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
4267 "(%X)!\n"),
4268 nSirStatus );
4269 //Pkt will be freed up by the callback
4270 return eSIR_FAILURE; // just allocated...
4271 }
4272
4273 return eSIR_SUCCESS;
4274
4275} // End limSendTpcReportFrame.
4276#endif //ANI_SUPPORT_11H
4277
4278
Jeff Johnsone7245742012-09-05 17:12:55 -07004279#if 1//def ANI_PRODUCT_TYPE_AP
Jeff Johnson295189b2012-06-20 16:38:30 -07004280/**
4281 * \brief Send a Channel Switch Announcement
4282 *
4283 *
4284 * \param pMac Pointer to the global MAC datastructure
4285 *
4286 * \param peer MAC address to which this frame will be sent
4287 *
4288 * \param nMode
4289 *
4290 * \param nNewChannel
4291 *
4292 * \param nCount
4293 *
4294 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4295 *
4296 *
4297 */
4298
4299tSirRetStatus
4300limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4301 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004302 tANI_U8 nMode,
4303 tANI_U8 nNewChannel,
4304 tANI_U8 nCount,
4305 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004306{
4307 tDot11fChannelSwitch frm;
4308 tANI_U8 *pFrame;
4309 tSirRetStatus nSirStatus;
4310 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004311 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 void *pPacket;
4313 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004314 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004315
4316 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4317
4318 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4319 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4320 frm.ChanSwitchAnn.switchMode = nMode;
4321 frm.ChanSwitchAnn.newChannel = nNewChannel;
4322 frm.ChanSwitchAnn.switchCount = nCount;
4323 frm.ChanSwitchAnn.present = 1;
4324
4325 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4326 if ( DOT11F_FAILED( nStatus ) )
4327 {
4328 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4329 "or a Channel Switch (0x%08x).\n"),
4330 nStatus );
4331 // We'll fall back on the worst case scenario:
4332 nPayload = sizeof( tDot11fChannelSwitch );
4333 }
4334 else if ( DOT11F_WARNED( nStatus ) )
4335 {
4336 limLog( pMac, LOGW, FL("There were warnings while calculating"
4337 "the packed size for a Channel Switch (0x"
4338 "%08x).\n"), nStatus );
4339 }
4340
4341 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4342
4343 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4344 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4345 {
4346 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4347 " Report.\n"), nBytes );
4348 return eSIR_FAILURE;
4349 }
4350
4351 // Paranoia:
4352 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4353
4354 // Next, we fill out the buffer descriptor:
4355 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004356 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4357 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4358 palCopyMemory( pMac->hHdd,
4359 (tANI_U8 *) pMacHdr->bssId,
4360 (tANI_U8 *) psessionEntry->bssId,
4361 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 if ( eSIR_SUCCESS != nSirStatus )
4363 {
4364 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4365 "tor for a Channel Switch (%d).\n"),
4366 nSirStatus );
4367 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4368 return eSIR_FAILURE; // just allocated...
4369 }
4370
Jeff Johnsone7245742012-09-05 17:12:55 -07004371#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4373
4374 nCfg = 6;
4375 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4376 if ( eSIR_SUCCESS != nSirStatus )
4377 {
4378 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4379 " CFG (%d).\n"),
4380 nSirStatus );
4381 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4382 return eSIR_FAILURE; // just allocated...
4383 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004384#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4386 sizeof(tSirMacMgmtHdr),
4387 nPayload, &nPayload );
4388 if ( DOT11F_FAILED( nStatus ) )
4389 {
4390 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x).\n"),
4391 nStatus );
4392 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4393 return eSIR_FAILURE; // allocated!
4394 }
4395 else if ( DOT11F_WARNED( nStatus ) )
4396 {
4397 limLog( pMac, LOGW, FL("There were warnings while packing a C"
4398 "hannel Switch (0x%08x).\n") );
4399 }
4400
Jeff Johnsone7245742012-09-05 17:12:55 -07004401 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4402#ifdef WLAN_FEATURE_P2P
4403 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4404 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4405#endif
4406 )
4407 {
4408 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4411 HAL_TXRX_FRM_802_11_MGMT,
4412 ANI_TXDIR_TODS,
4413 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004414 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4416 {
4417 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4418 "(%X)!\n"),
4419 nSirStatus );
4420 //Pkt will be freed up by the callback
4421 return eSIR_FAILURE;
4422 }
4423
4424 return eSIR_SUCCESS;
4425
4426} // End limSendChannelSwitchMgmtFrame.
4427
4428#endif // (ANI_PRODUCT_TYPE_AP)
4429
4430
Mohit Khanna4a70d262012-09-11 16:30:12 -07004431#ifdef WLAN_FEATURE_11AC
4432tSirRetStatus
4433limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4434 tSirMacAddr peer,
4435 tANI_U8 nMode,
4436 tpPESession psessionEntry )
4437{
4438 tDot11fOperatingMode frm;
4439 tANI_U8 *pFrame;
4440 tSirRetStatus nSirStatus;
4441 tpSirMacMgmtHdr pMacHdr;
4442 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4443 void *pPacket;
4444 eHalStatus halstatus;
4445 tANI_U8 txFlag = 0;
4446
4447 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4448
4449 frm.Category.category = SIR_MAC_ACTION_VHT;
4450 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4451 frm.OperatingMode.chanWidth = nMode;
4452 frm.OperatingMode.rxNSS = 0;
4453 frm.OperatingMode.rxNSSType = 0;
4454
4455 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4456 if ( DOT11F_FAILED( nStatus ) )
4457 {
4458 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4459 "or a Operating Mode (0x%08x).\n"),
4460 nStatus );
4461 // We'll fall back on the worst case scenario:
4462 nPayload = sizeof( tDot11fOperatingMode);
4463 }
4464 else if ( DOT11F_WARNED( nStatus ) )
4465 {
4466 limLog( pMac, LOGW, FL("There were warnings while calculating"
4467 "the packed size for a Operating Mode (0x"
4468 "%08x).\n"), nStatus );
4469 }
4470
4471 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4472
4473 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4474 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4475 {
4476 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
4477 " Report.\n"), nBytes );
4478 return eSIR_FAILURE;
4479 }
4480
4481 // Paranoia:
4482 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4483
4484
4485 // Next, we fill out the buffer descriptor:
4486 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4487 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4488 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4489 } else
4490 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4491 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4492 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4493 palCopyMemory( pMac->hHdd,
4494 (tANI_U8 *) pMacHdr->bssId,
4495 (tANI_U8 *) psessionEntry->bssId,
4496 sizeof( tSirMacAddr ));
4497 if ( eSIR_SUCCESS != nSirStatus )
4498 {
4499 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4500 "tor for a Operating Mode (%d).\n"),
4501 nSirStatus );
4502 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4503 return eSIR_FAILURE; // just allocated...
4504 }
4505 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4506 sizeof(tSirMacMgmtHdr),
4507 nPayload, &nPayload );
4508 if ( DOT11F_FAILED( nStatus ) )
4509 {
4510 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x).\n"),
4511 nStatus );
4512 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4513 return eSIR_FAILURE; // allocated!
4514 }
4515 else if ( DOT11F_WARNED( nStatus ) )
4516 {
4517 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
4518 " (0x%08x).\n") );
4519 }
4520 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4521#ifdef WLAN_FEATURE_P2P
4522 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4523 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4524#endif
4525 )
4526 {
4527 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4528 }
4529 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4530 HAL_TXRX_FRM_802_11_MGMT,
4531 ANI_TXDIR_TODS,
4532 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4533 limTxComplete, pFrame, txFlag );
4534 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4535 {
4536 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4537 "(%X)!\n"),
4538 nSirStatus );
4539 //Pkt will be freed up by the callback
4540 return eSIR_FAILURE;
4541 }
4542
4543 return eSIR_SUCCESS;
4544}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004545
4546/**
4547 * \brief Send a VHT Channel Switch Announcement
4548 *
4549 *
4550 * \param pMac Pointer to the global MAC datastructure
4551 *
4552 * \param peer MAC address to which this frame will be sent
4553 *
4554 * \param nChanWidth
4555 *
4556 * \param nNewChannel
4557 *
4558 *
4559 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4560 *
4561 *
4562 */
4563
4564tSirRetStatus
4565limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4566 tSirMacAddr peer,
4567 tANI_U8 nChanWidth,
4568 tANI_U8 nNewChannel,
4569 tANI_U8 ncbMode,
4570 tpPESession psessionEntry )
4571{
4572 tDot11fChannelSwitch frm;
4573 tANI_U8 *pFrame;
4574 tSirRetStatus nSirStatus;
4575 tpSirMacMgmtHdr pMacHdr;
4576 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4577 void *pPacket;
4578 eHalStatus halstatus;
4579 tANI_U8 txFlag = 0;
4580
4581 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4582
4583
4584 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4585 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4586 frm.ChanSwitchAnn.switchMode = 1;
4587 frm.ChanSwitchAnn.newChannel = nNewChannel;
4588 frm.ChanSwitchAnn.switchCount = 1;
4589 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4590 frm.ExtChanSwitchAnn.present = 1;
4591 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4592 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4593 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4594 frm.ChanSwitchAnn.present = 1;
4595 frm.WiderBWChanSwitchAnn.present = 1;
4596
4597 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4598 if ( DOT11F_FAILED( nStatus ) )
4599 {
4600 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4601 "or a Channel Switch (0x%08x).\n"),
4602 nStatus );
4603 // We'll fall back on the worst case scenario:
4604 nPayload = sizeof( tDot11fChannelSwitch );
4605 }
4606 else if ( DOT11F_WARNED( nStatus ) )
4607 {
4608 limLog( pMac, LOGW, FL("There were warnings while calculating"
4609 "the packed size for a Channel Switch (0x"
4610 "%08x).\n"), nStatus );
4611 }
4612
4613 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4614
4615 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4616 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4617 {
4618 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4619 " Report.\n"), nBytes );
4620 return eSIR_FAILURE;
4621 }
4622 // Paranoia:
4623 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4624
4625 // Next, we fill out the buffer descriptor:
4626 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4627 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4628 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4629 palCopyMemory( pMac->hHdd,
4630 (tANI_U8 *) pMacHdr->bssId,
4631 (tANI_U8 *) psessionEntry->bssId,
4632 sizeof( tSirMacAddr ));
4633 if ( eSIR_SUCCESS != nSirStatus )
4634 {
4635 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4636 "tor for a Channel Switch (%d).\n"),
4637 nSirStatus );
4638 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4639 return eSIR_FAILURE; // just allocated...
4640 }
4641 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4642 sizeof(tSirMacMgmtHdr),
4643 nPayload, &nPayload );
4644 if ( DOT11F_FAILED( nStatus ) )
4645 {
4646 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x).\n"),
4647 nStatus );
4648 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4649 return eSIR_FAILURE; // allocated!
4650 }
4651 else if ( DOT11F_WARNED( nStatus ) )
4652 {
4653 limLog( pMac, LOGW, FL("There were warnings while packing a C"
4654 "hannel Switch (0x%08x).\n") );
4655 }
4656
4657 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4658#ifdef WLAN_FEATURE_P2P
4659 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4660 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4661#endif
4662 )
4663 {
4664 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4665 }
4666 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4667 HAL_TXRX_FRM_802_11_MGMT,
4668 ANI_TXDIR_TODS,
4669 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4670 limTxComplete, pFrame, txFlag );
4671 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4672 {
4673 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4674 "(%X)!\n"),
4675 nSirStatus );
4676 //Pkt will be freed up by the callback
4677 return eSIR_FAILURE;
4678 }
4679
4680 return eSIR_SUCCESS;
4681
4682} // End limSendVHTChannelSwitchMgmtFrame.
4683
4684
4685
Mohit Khanna4a70d262012-09-11 16:30:12 -07004686#endif
4687
Jeff Johnson295189b2012-06-20 16:38:30 -07004688/**
4689 * \brief Send an ADDBA Req Action Frame to peer
4690 *
4691 * \sa limSendAddBAReq
4692 *
4693 * \param pMac The global tpAniSirGlobal object
4694 *
4695 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4696 * the necessary parameters reqd by PE send the ADDBA Req Action
4697 * Frame to the peer
4698 *
4699 * \return eSIR_SUCCESS if setup completes successfully
4700 * eSIR_FAILURE is some problem is encountered
4701 */
4702tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
4703 tpLimMlmAddBAReq pMlmAddBAReq ,tpPESession psessionEntry)
4704{
4705 tDot11fAddBAReq frmAddBAReq;
4706 tANI_U8 *pAddBAReqBuffer = NULL;
4707 tpSirMacMgmtHdr pMacHdr;
4708 tANI_U32 frameLen = 0, nStatus, nPayload;
4709 tSirRetStatus statusCode;
4710 eHalStatus halStatus;
4711 void *pPacket;
4712 tANI_U8 txFlag = 0;
4713
4714 if(NULL == psessionEntry)
4715 {
4716 return eSIR_FAILURE;
4717 }
4718
4719 palZeroMemory( pMac->hHdd, (void *) &frmAddBAReq, sizeof( frmAddBAReq ));
4720
4721 // Category - 3 (BA)
4722 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4723
4724 // Action - 0 (ADDBA Req)
4725 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4726
4727 // FIXME - Dialog Token, generalize this...
4728 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4729
4730 // Fill the ADDBA Parameter Set
4731 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4732 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4733 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4734
4735 // BA timeout
4736 // 0 - indicates no BA timeout
4737 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4738
4739 // BA Starting Sequence Number
4740 // Fragment number will always be zero
4741 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4742 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4743 }
4744
4745 frmAddBAReq.BAStartingSequenceControl.ssn =
4746 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4747
4748 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4749
4750 if( DOT11F_FAILED( nStatus ))
4751 {
4752 limLog( pMac, LOGW,
4753 FL( "Failed to calculate the packed size for "
4754 "an ADDBA Request (0x%08x).\n"),
4755 nStatus );
4756
4757 // We'll fall back on the worst case scenario:
4758 nPayload = sizeof( tDot11fAddBAReq );
4759 }
4760 else if( DOT11F_WARNED( nStatus ))
4761 {
4762 limLog( pMac, LOGW,
4763 FL( "There were warnings while calculating"
4764 "the packed size for an ADDBA Req (0x%08x).\n"),
4765 nStatus );
4766 }
4767
4768 // Add the MGMT header to frame length
4769 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4770
4771 // Need to allocate a buffer for ADDBA AF
4772 if( eHAL_STATUS_SUCCESS !=
4773 (halStatus = palPktAlloc( pMac->hHdd,
4774 HAL_TXRX_FRM_802_11_MGMT,
4775 (tANI_U16) frameLen,
4776 (void **) &pAddBAReqBuffer,
4777 (void **) &pPacket )))
4778 {
4779 // Log error
4780 limLog( pMac, LOGP,
4781 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
4782 frameLen,
4783 halStatus );
4784
4785 statusCode = eSIR_MEM_ALLOC_FAILED;
4786 goto returnAfterError;
4787 }
4788
4789 palZeroMemory( pMac->hHdd, (void *) pAddBAReqBuffer, frameLen );
4790
4791 // Copy necessary info to BD
4792 if( eSIR_SUCCESS !=
4793 (statusCode = limPopulateMacHeader( pMac,
4794 pAddBAReqBuffer,
4795 SIR_MAC_MGMT_FRAME,
4796 SIR_MAC_MGMT_ACTION,
4797 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4798 goto returnAfterError;
4799
4800 // Update A3 with the BSSID
4801 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4802
4803 #if 0
4804 cfgLen = SIR_MAC_ADDR_LENGTH;
4805 if( eSIR_SUCCESS != cfgGetStr( pMac,
4806 WNI_CFG_BSSID,
4807 (tANI_U8 *) pMacHdr->bssId,
4808 &cfgLen ))
4809 {
4810 limLog( pMac, LOGP,
4811 FL( "Failed to retrieve WNI_CFG_BSSID while"
4812 "sending an ACTION Frame\n" ));
4813
4814 // FIXME - Need to convert to tSirRetStatus
4815 statusCode = eSIR_FAILURE;
4816 goto returnAfterError;
4817 }
4818 #endif//TO SUPPORT BT-AMP
4819 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4820
4821 // Now, we're ready to "pack" the frames
4822 nStatus = dot11fPackAddBAReq( pMac,
4823 &frmAddBAReq,
4824 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4825 nPayload,
4826 &nPayload );
4827
4828 if( DOT11F_FAILED( nStatus ))
4829 {
4830 limLog( pMac, LOGE,
4831 FL( "Failed to pack an ADDBA Req (0x%08x).\n" ),
4832 nStatus );
4833
4834 // FIXME - Need to convert to tSirRetStatus
4835 statusCode = eSIR_FAILURE;
4836 goto returnAfterError;
4837 }
4838 else if( DOT11F_WARNED( nStatus ))
4839 {
4840 limLog( pMac, LOGW,
4841 FL( "There were warnings while packing an ADDBA Req (0x%08x).\n" ));
4842 }
4843
4844 limLog( pMac, LOGW,
4845 FL( "Sending an ADDBA REQ to \n" ));
4846 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4847
4848 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4849#ifdef WLAN_FEATURE_P2P
4850 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4851 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4852#endif
4853 )
4854 {
4855 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4856 }
4857
4858 if( eHAL_STATUS_SUCCESS !=
4859 (halStatus = halTxFrame( pMac,
4860 pPacket,
4861 (tANI_U16) frameLen,
4862 HAL_TXRX_FRM_802_11_MGMT,
4863 ANI_TXDIR_TODS,
4864 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4865 limTxComplete,
4866 pAddBAReqBuffer, txFlag )))
4867 {
4868 limLog( pMac, LOGE,
4869 FL( "halTxFrame FAILED! Status [%d]\n"),
4870 halStatus );
4871
4872 // FIXME - Need to convert eHalStatus to tSirRetStatus
4873 statusCode = eSIR_FAILURE;
4874 //Pkt will be freed up by the callback
4875 return statusCode;
4876 }
4877 else
4878 return eSIR_SUCCESS;
4879
4880returnAfterError:
4881
4882 // Release buffer, if allocated
4883 if( NULL != pAddBAReqBuffer )
4884 palPktFree( pMac->hHdd,
4885 HAL_TXRX_FRM_802_11_MGMT,
4886 (void *) pAddBAReqBuffer,
4887 (void *) pPacket );
4888
4889 return statusCode;
4890}
4891
4892/**
4893 * \brief Send an ADDBA Rsp Action Frame to peer
4894 *
4895 * \sa limSendAddBARsp
4896 *
4897 * \param pMac The global tpAniSirGlobal object
4898 *
4899 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
4900 * the necessary parameters reqd by PE send the ADDBA Rsp Action
4901 * Frame to the peer
4902 *
4903 * \return eSIR_SUCCESS if setup completes successfully
4904 * eSIR_FAILURE is some problem is encountered
4905 */
4906tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
4907 tpLimMlmAddBARsp pMlmAddBARsp,
4908 tpPESession psessionEntry)
4909{
4910 tDot11fAddBARsp frmAddBARsp;
4911 tANI_U8 *pAddBARspBuffer = NULL;
4912 tpSirMacMgmtHdr pMacHdr;
4913 tANI_U32 frameLen = 0, nStatus, nPayload;
4914 tSirRetStatus statusCode;
4915 eHalStatus halStatus;
4916 void *pPacket;
4917 tANI_U8 txFlag = 0;
4918
4919 if(NULL == psessionEntry)
4920 {
4921 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!\n"));)
4922 return eSIR_FAILURE;
4923 }
4924
4925 palZeroMemory( pMac->hHdd, (void *) &frmAddBARsp, sizeof( frmAddBARsp ));
4926
4927 // Category - 3 (BA)
4928 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
4929 // Action - 1 (ADDBA Rsp)
4930 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
4931
4932 // Should be same as the one we received in the ADDBA Req
4933 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
4934
4935 // ADDBA Req status
4936 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
4937
4938 // Fill the ADDBA Parameter Set as provided by caller
4939 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
4940 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
4941 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
4942
4943 // BA timeout
4944 // 0 - indicates no BA timeout
4945 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
4946
4947 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
4948
4949 if( DOT11F_FAILED( nStatus ))
4950 {
4951 limLog( pMac, LOGW,
4952 FL( "Failed to calculate the packed size for "
4953 "an ADDBA Response (0x%08x).\n"),
4954 nStatus );
4955
4956 // We'll fall back on the worst case scenario:
4957 nPayload = sizeof( tDot11fAddBARsp );
4958 }
4959 else if( DOT11F_WARNED( nStatus ))
4960 {
4961 limLog( pMac, LOGW,
4962 FL( "There were warnings while calculating"
4963 "the packed size for an ADDBA Rsp (0x%08x).\n"),
4964 nStatus );
4965 }
4966
4967 // Need to allocate a buffer for ADDBA AF
4968 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4969
4970 // Allocate shared memory
4971 if( eHAL_STATUS_SUCCESS !=
4972 (halStatus = palPktAlloc( pMac->hHdd,
4973 HAL_TXRX_FRM_802_11_MGMT,
4974 (tANI_U16) frameLen,
4975 (void **) &pAddBARspBuffer,
4976 (void **) &pPacket )))
4977 {
4978 // Log error
4979 limLog( pMac, LOGP,
4980 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
4981 frameLen,
4982 halStatus );
4983
4984 statusCode = eSIR_MEM_ALLOC_FAILED;
4985 goto returnAfterError;
4986 }
4987
4988 palZeroMemory( pMac->hHdd, (void *) pAddBARspBuffer, frameLen );
4989
4990 // Copy necessary info to BD
4991 if( eSIR_SUCCESS !=
4992 (statusCode = limPopulateMacHeader( pMac,
4993 pAddBARspBuffer,
4994 SIR_MAC_MGMT_FRAME,
4995 SIR_MAC_MGMT_ACTION,
4996 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
4997 goto returnAfterError;
4998
4999 // Update A3 with the BSSID
5000
5001 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5002
5003 #if 0
5004 cfgLen = SIR_MAC_ADDR_LENGTH;
5005 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5006 WNI_CFG_BSSID,
5007 (tANI_U8 *) pMacHdr->bssId,
5008 &cfgLen ))
5009 {
5010 limLog( pMac, LOGP,
5011 FL( "Failed to retrieve WNI_CFG_BSSID while"
5012 "sending an ACTION Frame\n" ));
5013
5014 // FIXME - Need to convert to tSirRetStatus
5015 statusCode = eSIR_FAILURE;
5016 goto returnAfterError;
5017 }
5018 #endif // TO SUPPORT BT-AMP
5019 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5020
5021 // Now, we're ready to "pack" the frames
5022 nStatus = dot11fPackAddBARsp( pMac,
5023 &frmAddBARsp,
5024 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5025 nPayload,
5026 &nPayload );
5027
5028 if( DOT11F_FAILED( nStatus ))
5029 {
5030 limLog( pMac, LOGE,
5031 FL( "Failed to pack an ADDBA Rsp (0x%08x).\n" ),
5032 nStatus );
5033
5034 // FIXME - Need to convert to tSirRetStatus
5035 statusCode = eSIR_FAILURE;
5036 goto returnAfterError;
5037 }
5038 else if( DOT11F_WARNED( nStatus ))
5039 {
5040 limLog( pMac, LOGW,
5041 FL( "There were warnings while packing an ADDBA Rsp (0x%08x).\n" ));
5042 }
5043
5044 limLog( pMac, LOGW,
5045 FL( "Sending an ADDBA RSP to \n" ));
5046 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5047
5048 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5049#ifdef WLAN_FEATURE_P2P
5050 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5051 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5052#endif
5053 )
5054 {
5055 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5056 }
5057
5058 if( eHAL_STATUS_SUCCESS !=
5059 (halStatus = halTxFrame( pMac,
5060 pPacket,
5061 (tANI_U16) frameLen,
5062 HAL_TXRX_FRM_802_11_MGMT,
5063 ANI_TXDIR_TODS,
5064 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5065 limTxComplete,
5066 pAddBARspBuffer, txFlag )))
5067 {
5068 limLog( pMac, LOGE,
5069 FL( "halTxFrame FAILED! Status [%d]\n" ),
5070 halStatus );
5071
5072 // FIXME - HAL error codes are different from PE error
5073 // codes!! And, this routine is returning tSirRetStatus
5074 statusCode = eSIR_FAILURE;
5075 //Pkt will be freed up by the callback
5076 return statusCode;
5077 }
5078 else
5079 return eSIR_SUCCESS;
5080
5081 returnAfterError:
5082
5083 // Release buffer, if allocated
5084 if( NULL != pAddBARspBuffer )
5085 palPktFree( pMac->hHdd,
5086 HAL_TXRX_FRM_802_11_MGMT,
5087 (void *) pAddBARspBuffer,
5088 (void *) pPacket );
5089
5090 return statusCode;
5091}
5092
5093/**
5094 * \brief Send a DELBA Indication Action Frame to peer
5095 *
5096 * \sa limSendDelBAInd
5097 *
5098 * \param pMac The global tpAniSirGlobal object
5099 *
5100 * \param peerMacAddr MAC Address of peer
5101 *
5102 * \param reasonCode Reason for the DELBA notification
5103 *
5104 * \param pBAParameterSet The DELBA Parameter Set.
5105 * This identifies the TID for which the BA session is
5106 * being deleted.
5107 *
5108 * \return eSIR_SUCCESS if setup completes successfully
5109 * eSIR_FAILURE is some problem is encountered
5110 */
5111tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5112 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5113{
5114 tDot11fDelBAInd frmDelBAInd;
5115 tANI_U8 *pDelBAIndBuffer = NULL;
5116 //tANI_U32 val;
5117 tpSirMacMgmtHdr pMacHdr;
5118 tANI_U32 frameLen = 0, nStatus, nPayload;
5119 tSirRetStatus statusCode;
5120 eHalStatus halStatus;
5121 void *pPacket;
5122 tANI_U8 txFlag = 0;
5123
5124 if(NULL == psessionEntry)
5125 {
5126 return eSIR_FAILURE;
5127 }
5128
5129 palZeroMemory( pMac->hHdd, (void *) &frmDelBAInd, sizeof( frmDelBAInd ));
5130
5131 // Category - 3 (BA)
5132 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5133 // Action - 2 (DELBA)
5134 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5135
5136 // Fill the DELBA Parameter Set as provided by caller
5137 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5138 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5139
5140 // BA Starting Sequence Number
5141 // Fragment number will always be zero
5142 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5143
5144 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5145
5146 if( DOT11F_FAILED( nStatus ))
5147 {
5148 limLog( pMac, LOGW,
5149 FL( "Failed to calculate the packed size for "
5150 "an DELBA Indication (0x%08x).\n"),
5151 nStatus );
5152
5153 // We'll fall back on the worst case scenario:
5154 nPayload = sizeof( tDot11fDelBAInd );
5155 }
5156 else if( DOT11F_WARNED( nStatus ))
5157 {
5158 limLog( pMac, LOGW,
5159 FL( "There were warnings while calculating"
5160 "the packed size for an DELBA Ind (0x%08x).\n"),
5161 nStatus );
5162 }
5163
5164 // Add the MGMT header to frame length
5165 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5166
5167 // Allocate shared memory
5168 if( eHAL_STATUS_SUCCESS !=
5169 (halStatus = palPktAlloc( pMac->hHdd,
5170 HAL_TXRX_FRM_802_11_MGMT,
5171 (tANI_U16) frameLen,
5172 (void **) &pDelBAIndBuffer,
5173 (void **) &pPacket )))
5174 {
5175 // Log error
5176 limLog( pMac, LOGP,
5177 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5178 frameLen,
5179 halStatus );
5180
5181 statusCode = eSIR_MEM_ALLOC_FAILED;
5182 goto returnAfterError;
5183 }
5184
5185 palZeroMemory( pMac->hHdd, (void *) pDelBAIndBuffer, frameLen );
5186
5187 // Copy necessary info to BD
5188 if( eSIR_SUCCESS !=
5189 (statusCode = limPopulateMacHeader( pMac,
5190 pDelBAIndBuffer,
5191 SIR_MAC_MGMT_FRAME,
5192 SIR_MAC_MGMT_ACTION,
5193 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5194 goto returnAfterError;
5195
5196 // Update A3 with the BSSID
5197 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5198
5199 #if 0
5200 cfgLen = SIR_MAC_ADDR_LENGTH;
5201 if( eSIR_SUCCESS != cfgGetStr( pMac,
5202 WNI_CFG_BSSID,
5203 (tANI_U8 *) pMacHdr->bssId,
5204 &cfgLen ))
5205 {
5206 limLog( pMac, LOGP,
5207 FL( "Failed to retrieve WNI_CFG_BSSID while"
5208 "sending an ACTION Frame\n" ));
5209
5210 // FIXME - Need to convert to tSirRetStatus
5211 statusCode = eSIR_FAILURE;
5212 goto returnAfterError;
5213 }
5214 #endif //TO SUPPORT BT-AMP
5215 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5216
5217 // Now, we're ready to "pack" the frames
5218 nStatus = dot11fPackDelBAInd( pMac,
5219 &frmDelBAInd,
5220 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5221 nPayload,
5222 &nPayload );
5223
5224 if( DOT11F_FAILED( nStatus ))
5225 {
5226 limLog( pMac, LOGE,
5227 FL( "Failed to pack an DELBA Ind (0x%08x).\n" ),
5228 nStatus );
5229
5230 // FIXME - Need to convert to tSirRetStatus
5231 statusCode = eSIR_FAILURE;
5232 goto returnAfterError;
5233 }
5234 else if( DOT11F_WARNED( nStatus ))
5235 {
5236 limLog( pMac, LOGW,
5237 FL( "There were warnings while packing an DELBA Ind (0x%08x).\n" ));
5238 }
5239
5240 limLog( pMac, LOGW,
5241 FL( "Sending a DELBA IND to \n" ));
5242 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5243
5244 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5245#ifdef WLAN_FEATURE_P2P
5246 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5247 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5248#endif
5249 )
5250 {
5251 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5252 }
5253
5254 if( eHAL_STATUS_SUCCESS !=
5255 (halStatus = halTxFrame( pMac,
5256 pPacket,
5257 (tANI_U16) frameLen,
5258 HAL_TXRX_FRM_802_11_MGMT,
5259 ANI_TXDIR_TODS,
5260 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5261 limTxComplete,
5262 pDelBAIndBuffer, txFlag )))
5263 {
5264 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halStatus );)
5265 statusCode = eSIR_FAILURE;
5266 //Pkt will be freed up by the callback
5267 return statusCode;
5268 }
5269 else
5270 return eSIR_SUCCESS;
5271
5272 returnAfterError:
5273
5274 // Release buffer, if allocated
5275 if( NULL != pDelBAIndBuffer )
5276 palPktFree( pMac->hHdd,
5277 HAL_TXRX_FRM_802_11_MGMT,
5278 (void *) pDelBAIndBuffer,
5279 (void *) pPacket );
5280
5281 return statusCode;
5282}
5283
5284#if defined WLAN_FEATURE_VOWIFI
5285
5286/**
5287 * \brief Send a Neighbor Report Request Action frame
5288 *
5289 *
5290 * \param pMac Pointer to the global MAC structure
5291 *
5292 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5293 *
5294 * \param peer mac address of peer station.
5295 *
5296 * \param psessionEntry address of session entry.
5297 *
5298 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5299 *
5300 *
5301 */
5302
5303tSirRetStatus
5304limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5305 tpSirMacNeighborReportReq pNeighborReq,
5306 tSirMacAddr peer,
5307 tpPESession psessionEntry
5308 )
5309{
5310 tSirRetStatus statusCode = eSIR_SUCCESS;
5311 tDot11fNeighborReportRequest frm;
5312 tANI_U8 *pFrame;
5313 tpSirMacMgmtHdr pMacHdr;
5314 tANI_U32 nBytes, nPayload, nStatus;
5315 void *pPacket;
5316 eHalStatus halstatus;
5317 tANI_U8 txFlag = 0;
5318
5319 if ( psessionEntry == NULL )
5320 {
5321 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame\n") );
5322 return eSIR_FAILURE;
5323 }
5324 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5325
5326 frm.Category.category = SIR_MAC_ACTION_RRM;
5327 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5328 frm.DialogToken.token = pNeighborReq->dialogToken;
5329
5330
5331 if( pNeighborReq->ssid_present )
5332 {
5333 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5334 }
5335
5336 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5337 if ( DOT11F_FAILED( nStatus ) )
5338 {
5339 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5340 "or a Neighbor Report Request(0x%08x).\n"),
5341 nStatus );
5342 // We'll fall back on the worst case scenario:
5343 nPayload = sizeof( tDot11fNeighborReportRequest );
5344 }
5345 else if ( DOT11F_WARNED( nStatus ) )
5346 {
5347 limLog( pMac, LOGW, FL("There were warnings while calculating"
5348 "the packed size for a Neighbor Rep"
5349 "ort Request(0x%08x).\n"), nStatus );
5350 }
5351
5352 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5353
5354 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5355 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5356 {
5357 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
5358 "Report Request.\n"), nBytes );
5359 return eSIR_FAILURE;
5360 }
5361
5362 // Paranoia:
5363 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5364
5365 // Copy necessary info to BD
5366 if( eSIR_SUCCESS !=
5367 (statusCode = limPopulateMacHeader( pMac,
5368 pFrame,
5369 SIR_MAC_MGMT_FRAME,
5370 SIR_MAC_MGMT_ACTION,
5371 peer, psessionEntry->selfMacAddr)))
5372 goto returnAfterError;
5373
5374 // Update A3 with the BSSID
5375 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5376
5377 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5378
5379 // Now, we're ready to "pack" the frames
5380 nStatus = dot11fPackNeighborReportRequest( pMac,
5381 &frm,
5382 pFrame + sizeof( tSirMacMgmtHdr ),
5383 nPayload,
5384 &nPayload );
5385
5386 if( DOT11F_FAILED( nStatus ))
5387 {
5388 limLog( pMac, LOGE,
5389 FL( "Failed to pack an Neighbor Report Request (0x%08x).\n" ),
5390 nStatus );
5391
5392 // FIXME - Need to convert to tSirRetStatus
5393 statusCode = eSIR_FAILURE;
5394 goto returnAfterError;
5395 }
5396 else if( DOT11F_WARNED( nStatus ))
5397 {
5398 limLog( pMac, LOGW,
5399 FL( "There were warnings while packing Neighbor Report Request (0x%08x).\n" ));
5400 }
5401
5402 limLog( pMac, LOGW,
5403 FL( "Sending a Neighbor Report Request to \n" ));
5404 limPrintMacAddr( pMac, peer, LOGW );
5405
5406 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5407#ifdef WLAN_FEATURE_P2P
5408 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5409 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5410#endif
5411 )
5412 {
5413 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5414 }
5415
5416 if( eHAL_STATUS_SUCCESS !=
5417 (halstatus = halTxFrame( pMac,
5418 pPacket,
5419 (tANI_U16) nBytes,
5420 HAL_TXRX_FRM_802_11_MGMT,
5421 ANI_TXDIR_TODS,
5422 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5423 limTxComplete,
5424 pFrame, txFlag )))
5425 {
5426 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5427 statusCode = eSIR_FAILURE;
5428 //Pkt will be freed up by the callback
5429 return statusCode;
5430 }
5431 else
5432 return eSIR_SUCCESS;
5433
5434returnAfterError:
5435 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5436
5437 return statusCode;
5438} // End limSendNeighborReportRequestFrame.
5439
5440/**
5441 * \brief Send a Link Report Action frame
5442 *
5443 *
5444 * \param pMac Pointer to the global MAC structure
5445 *
5446 * \param pLinkReport Address of a tSirMacLinkReport
5447 *
5448 * \param peer mac address of peer station.
5449 *
5450 * \param psessionEntry address of session entry.
5451 *
5452 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5453 *
5454 *
5455 */
5456
5457tSirRetStatus
5458limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5459 tpSirMacLinkReport pLinkReport,
5460 tSirMacAddr peer,
5461 tpPESession psessionEntry
5462 )
5463{
5464 tSirRetStatus statusCode = eSIR_SUCCESS;
5465 tDot11fLinkMeasurementReport frm;
5466 tANI_U8 *pFrame;
5467 tpSirMacMgmtHdr pMacHdr;
5468 tANI_U32 nBytes, nPayload, nStatus;
5469 void *pPacket;
5470 eHalStatus halstatus;
5471 tANI_U8 txFlag = 0;
5472
5473
5474 if ( psessionEntry == NULL )
5475 {
5476 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame\n") );
5477 return eSIR_FAILURE;
5478 }
5479
5480 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5481
5482 frm.Category.category = SIR_MAC_ACTION_RRM;
5483 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5484 frm.DialogToken.token = pLinkReport->dialogToken;
5485
5486
5487 //IEEE Std. 802.11 7.3.2.18. for the report element.
5488 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5489 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5490 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5491 //such case this way than changing the frame parser.
5492 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5493 frm.TPCEleLen.TPCLen = 2;
5494 frm.TxPower.txPower = pLinkReport->txPower;
5495 frm.LinkMargin.linkMargin = 0;
5496
5497 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5498 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5499 frm.RCPI.rcpi = pLinkReport->rcpi;
5500 frm.RSNI.rsni = pLinkReport->rsni;
5501
5502 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5503 if ( DOT11F_FAILED( nStatus ) )
5504 {
5505 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5506 "or a Link Report (0x%08x).\n"),
5507 nStatus );
5508 // We'll fall back on the worst case scenario:
5509 nPayload = sizeof( tDot11fLinkMeasurementReport );
5510 }
5511 else if ( DOT11F_WARNED( nStatus ) )
5512 {
5513 limLog( pMac, LOGW, FL("There were warnings while calculating"
5514 "the packed size for a Link Rep"
5515 "ort (0x%08x).\n"), nStatus );
5516 }
5517
5518 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5519
5520 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5521 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5522 {
5523 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
5524 "Report.\n"), nBytes );
5525 return eSIR_FAILURE;
5526 }
5527
5528 // Paranoia:
5529 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5530
5531 // Copy necessary info to BD
5532 if( eSIR_SUCCESS !=
5533 (statusCode = limPopulateMacHeader( pMac,
5534 pFrame,
5535 SIR_MAC_MGMT_FRAME,
5536 SIR_MAC_MGMT_ACTION,
5537 peer, psessionEntry->selfMacAddr)))
5538 goto returnAfterError;
5539
5540 // Update A3 with the BSSID
5541 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5542
5543 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5544
5545 // Now, we're ready to "pack" the frames
5546 nStatus = dot11fPackLinkMeasurementReport( pMac,
5547 &frm,
5548 pFrame + sizeof( tSirMacMgmtHdr ),
5549 nPayload,
5550 &nPayload );
5551
5552 if( DOT11F_FAILED( nStatus ))
5553 {
5554 limLog( pMac, LOGE,
5555 FL( "Failed to pack an Link Report (0x%08x).\n" ),
5556 nStatus );
5557
5558 // FIXME - Need to convert to tSirRetStatus
5559 statusCode = eSIR_FAILURE;
5560 goto returnAfterError;
5561 }
5562 else if( DOT11F_WARNED( nStatus ))
5563 {
5564 limLog( pMac, LOGW,
5565 FL( "There were warnings while packing Link Report (0x%08x).\n" ));
5566 }
5567
5568 limLog( pMac, LOGW,
5569 FL( "Sending a Link Report to \n" ));
5570 limPrintMacAddr( pMac, peer, LOGW );
5571
5572 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5573#ifdef WLAN_FEATURE_P2P
5574 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5575 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5576#endif
5577 )
5578 {
5579 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5580 }
5581
5582 if( eHAL_STATUS_SUCCESS !=
5583 (halstatus = halTxFrame( pMac,
5584 pPacket,
5585 (tANI_U16) nBytes,
5586 HAL_TXRX_FRM_802_11_MGMT,
5587 ANI_TXDIR_TODS,
5588 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5589 limTxComplete,
5590 pFrame, txFlag )))
5591 {
5592 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5593 statusCode = eSIR_FAILURE;
5594 //Pkt will be freed up by the callback
5595 return statusCode;
5596 }
5597 else
5598 return eSIR_SUCCESS;
5599
5600returnAfterError:
5601 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5602
5603 return statusCode;
5604} // End limSendLinkReportActionFrame.
5605
5606/**
5607 * \brief Send a Beacon Report Action frame
5608 *
5609 *
5610 * \param pMac Pointer to the global MAC structure
5611 *
5612 * \param dialog_token dialog token to be used in the action frame.
5613 *
5614 * \param num_report number of reports in pRRMReport.
5615 *
5616 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5617 *
5618 * \param peer mac address of peer station.
5619 *
5620 * \param psessionEntry address of session entry.
5621 *
5622 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5623 *
5624 *
5625 */
5626
5627tSirRetStatus
5628limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5629 tANI_U8 dialog_token,
5630 tANI_U8 num_report,
5631 tpSirMacRadioMeasureReport pRRMReport,
5632 tSirMacAddr peer,
5633 tpPESession psessionEntry
5634 )
5635{
5636 tSirRetStatus statusCode = eSIR_SUCCESS;
5637 tDot11fRadioMeasurementReport frm;
5638 tANI_U8 *pFrame;
5639 tpSirMacMgmtHdr pMacHdr;
5640 tANI_U32 nBytes, nPayload, nStatus;
5641 void *pPacket;
5642 eHalStatus halstatus;
5643 tANI_U8 i;
5644 tANI_U8 txFlag = 0;
5645
5646 if ( psessionEntry == NULL )
5647 {
5648 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame\n") );
5649 return eSIR_FAILURE;
5650 }
5651 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5652
5653 frm.Category.category = SIR_MAC_ACTION_RRM;
5654 frm.Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5655 frm.DialogToken.token = dialog_token;
5656
5657 frm.num_MeasurementReport = (num_report > RADIO_REPORTS_MAX_IN_A_FRAME ) ? RADIO_REPORTS_MAX_IN_A_FRAME : num_report;
5658
5659 for( i = 0 ; i < frm.num_MeasurementReport ; i++ )
5660 {
5661 frm.MeasurementReport[i].type = pRRMReport[i].type;
5662 frm.MeasurementReport[i].token = pRRMReport[i].token;
5663 frm.MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
5664 switch( pRRMReport[i].type )
5665 {
5666 case SIR_MAC_RRM_BEACON_TYPE:
5667 PopulateDot11fBeaconReport( pMac, &frm.MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5668 frm.MeasurementReport[i].incapable = pRRMReport[i].incapable;
5669 frm.MeasurementReport[i].refused = pRRMReport[i].refused;
5670 frm.MeasurementReport[i].present = 1;
5671 break;
5672 default:
5673 frm.MeasurementReport[i].present = 1;
5674 break;
5675 }
5676 }
5677
5678 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, &frm, &nPayload );
5679 if ( DOT11F_FAILED( nStatus ) )
5680 {
5681 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5682 "or a Radio Measure Report (0x%08x).\n"),
5683 nStatus );
5684 // We'll fall back on the worst case scenario:
5685 nPayload = sizeof( tDot11fLinkMeasurementReport );
5686 return eSIR_FAILURE;
5687 }
5688 else if ( DOT11F_WARNED( nStatus ) )
5689 {
5690 limLog( pMac, LOGW, FL("There were warnings while calculating"
5691 "the packed size for a Radio Measure Rep"
5692 "ort (0x%08x).\n"), nStatus );
5693 }
5694
5695 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5696
5697 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5698 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5699 {
5700 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
5701 "Report.\n"), nBytes );
5702 return eSIR_FAILURE;
5703 }
5704
5705 // Paranoia:
5706 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5707
5708 // Copy necessary info to BD
5709 if( eSIR_SUCCESS !=
5710 (statusCode = limPopulateMacHeader( pMac,
5711 pFrame,
5712 SIR_MAC_MGMT_FRAME,
5713 SIR_MAC_MGMT_ACTION,
5714 peer, psessionEntry->selfMacAddr)))
5715 goto returnAfterError;
5716
5717 // Update A3 with the BSSID
5718 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5719
5720 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5721
5722 // Now, we're ready to "pack" the frames
5723 nStatus = dot11fPackRadioMeasurementReport( pMac,
5724 &frm,
5725 pFrame + sizeof( tSirMacMgmtHdr ),
5726 nPayload,
5727 &nPayload );
5728
5729 if( DOT11F_FAILED( nStatus ))
5730 {
5731 limLog( pMac, LOGE,
5732 FL( "Failed to pack an Radio Measure Report (0x%08x).\n" ),
5733 nStatus );
5734
5735 // FIXME - Need to convert to tSirRetStatus
5736 statusCode = eSIR_FAILURE;
5737 goto returnAfterError;
5738 }
5739 else if( DOT11F_WARNED( nStatus ))
5740 {
5741 limLog( pMac, LOGW,
5742 FL( "There were warnings while packing Radio Measure Report (0x%08x).\n" ));
5743 }
5744
5745 limLog( pMac, LOGW,
5746 FL( "Sending a Radio Measure Report to \n" ));
5747 limPrintMacAddr( pMac, peer, LOGW );
5748
5749 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5750#ifdef WLAN_FEATURE_P2P
5751 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5752 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5753#endif
5754 )
5755 {
5756 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5757 }
5758
5759 if( eHAL_STATUS_SUCCESS !=
5760 (halstatus = halTxFrame( pMac,
5761 pPacket,
5762 (tANI_U16) nBytes,
5763 HAL_TXRX_FRM_802_11_MGMT,
5764 ANI_TXDIR_TODS,
5765 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5766 limTxComplete,
5767 pFrame, txFlag )))
5768 {
5769 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5770 statusCode = eSIR_FAILURE;
5771 //Pkt will be freed up by the callback
5772 return statusCode;
5773 }
5774 else
5775 return eSIR_SUCCESS;
5776
5777returnAfterError:
5778 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5779
5780 return statusCode;
5781} // End limSendBeaconReportActionFrame.
5782
5783#endif
5784
5785#ifdef WLAN_FEATURE_11W
5786/**
5787 * \brief Send SA query response action frame to peer
5788 *
5789 * \sa limSendSaQueryResponseFrame
5790 *
5791 *
5792 * \param pMac The global tpAniSirGlobal object
5793 *
5794 * \param peer The Mac address of the AP to which this action frame is
5795addressed
5796 *
5797 * \param transId Transaction identifier received in SA query request action
5798frame
5799 *
5800 * \return eSIR_SUCCESS if setup completes successfully
5801 * eSIR_FAILURE is some problem is encountered
5802 */
5803
5804tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U16 transId,
5805tSirMacAddr peer,tpPESession psessionEntry)
5806{
5807
5808 tDot11wSaQueryRsp frm; // SA query reponse action frame
5809 tANI_U8 *pFrame;
5810 tSirRetStatus nSirStatus;
5811 tpSirMacMgmtHdr pMacHdr;
5812 tANI_U32 nBytes, nPayload;
5813 void *pPacket;
5814 eHalStatus halstatus;
5815 // Local variables used to dump prepared SA query response frame
5816 tANI_U8 *pDump;
5817 tANI_U16 dumpCount;
5818 tANI_U8 txFlag = 0;
5819 //tANI_U16 nBytes
5820
5821 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5822 frm.category = SIR_MAC_ACTION_SA_QUERY;
5823 /*11w action fiedl is :
5824 action: 0 --> SA query request action frame
5825 action: 1 --> SA query response action frame */
5826 frm.action = 1;
5827 /*11w Draft9.0 SA query response transId is same as
5828 SA query request transId*/
5829 frm.transId = transId;
5830
5831 nPayload = sizeof(tDot11wSaQueryRsp);
5832 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5833 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5834 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5835 {
5836 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
5837 " action frame\n"), nBytes );
5838 return eSIR_FAILURE;
5839 }
5840
5841 // Paranoia:
5842 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5843
5844 // Next, we fill out the buffer descriptor:
5845 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5846 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr );
5847 if ( eSIR_SUCCESS != nSirStatus )
5848 {
5849 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
5850 "tor for a TPC Report (%d).\n"),
5851 nSirStatus );
5852 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5853 return eSIR_FAILURE; // just allocated...
5854 }
5855
5856 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5857
5858 // Pack 11w SA query response frame
5859 DOT11F_MEMCPY(pMac, (tANI_U8 *)(pFrame + sizeof(tSirMacMgmtHdr)),(tANI_U8 *)&frm, nPayload);
5860 pDump = (tANI_U8 *) pFrame;
5861
5862 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5863 HAL_TXRX_FRM_802_11_MGMT,
5864 ANI_TXDIR_TODS,
5865 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5866 limTxComplete, pFrame,txFlag);
5867 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5868 {
5869 limLog( pMac, LOGE, FL("Failed to send a SA Query resp frame "
5870 "(%X)!\n"),halstatus );
5871 //Pkt will be freed up by the callback
5872 return eSIR_FAILURE; // just allocated...
5873 }
5874
5875 return eSIR_SUCCESS;
5876}
5877#endif