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