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