blob: ab8e86c84fb79550e4b7fd665974ceee9aa7eeff [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhc601a472016-01-20 11:08:32 +05302 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Jeff Johnson295189b2012-06-20 16:38:30 -070026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/**
32 * \file limSendManagementFrames.c
33 *
34 * \brief Code for preparing and sending 802.11 Management frames
35 *
Kiet Lam842dad02014-02-18 18:44:02 -080036
Jeff Johnson295189b2012-06-20 16:38:30 -070037 *
38 */
39
40#include "sirApi.h"
41#include "aniGlobal.h"
42#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043#include "cfgApi.h"
44#include "utilsApi.h"
45#include "limTypes.h"
46#include "limUtils.h"
47#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070048#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070049#include "dot11f.h"
50#include "limStaHashApi.h"
51#include "schApi.h"
52#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080053#include "limAssocUtils.h"
54#include "limFT.h"
Chet Lanctot8cecea22014-02-11 19:09:36 -080055#ifdef WLAN_FEATURE_11W
Satyanarayana Dash6f438272015-03-03 18:01:06 +053056#include "wniCfg.h"
Chet Lanctot8cecea22014-02-11 19:09:36 -080057#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080058
Jeff Johnson295189b2012-06-20 16:38:30 -070059#if defined WLAN_FEATURE_VOWIFI
60#include "rrmApi.h"
61#endif
62
Jeff Johnson295189b2012-06-20 16:38:30 -070063#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070064
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053065#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070066////////////////////////////////////////////////////////////////////////
67
Kalikinkar dhara205da782014-03-21 15:49:32 -070068tSirRetStatus limStripOffExtCapIE(tpAniSirGlobal pMac,
69 tANI_U8 *addIE,
70 tANI_U16 *addnIELen,
71 tANI_U8 *pExtractedExtCapIEBuf )
72{
73 tANI_U8* tempbuf = NULL;
74 tANI_U16 tempLen = 0;
75 int left = *addnIELen;
76 tANI_U8 *ptr = addIE;
77 tANI_U8 elem_id, elem_len;
78
79 if (NULL == addIE)
80 {
81 PELOGE(limLog(pMac, LOG1, FL("NULL addIE pointer"));)
82 return eSIR_IGNORE_IE ;
83 }
84
85 tempbuf = vos_mem_malloc(left);
86 if ( NULL == tempbuf )
87 {
88 PELOGE(limLog(pMac, LOGE,
89 FL("Unable to allocate memory to store addn IE"));)
90 return eSIR_MEM_ALLOC_FAILED;
91 }
92
93 while(left >= 2)
94 {
95 elem_id = ptr[0];
96 elem_len = ptr[1];
97 left -= 2;
98 if (elem_len > left)
99 {
100 limLog( pMac, LOGE,
101 FL("Invalid IEs eid = %d elem_len=%d left=%d"),
102 elem_id,elem_len,left);
103 vos_mem_free(tempbuf);
104 return eSIR_FAILURE;
105 }
106 if ( !(DOT11F_EID_EXTCAP == elem_id) )
107 {
108 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
109 tempLen += (elem_len + 2);
110 }
111 else
112 { /*Est Cap present size is 8 + 2 byte at present*/
113 if ( NULL != pExtractedExtCapIEBuf )
114 {
115 vos_mem_set(pExtractedExtCapIEBuf,
116 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
117 if (elem_len <= DOT11F_IE_EXTCAP_MAX_LEN )
118 {
119 vos_mem_copy (pExtractedExtCapIEBuf, &ptr[0],
120 elem_len + 2);
121 }
122 }
123 }
124 left -= elem_len;
125 ptr += (elem_len + 2);
126 }
127 vos_mem_copy (addIE, tempbuf, tempLen);
128 *addnIELen = tempLen;
129 vos_mem_free(tempbuf);
130 return eSIR_SUCCESS;
131}
132
133void limUpdateExtCapIEtoStruct(tpAniSirGlobal pMac,
134 tANI_U8 *pBuf,
135 tDot11fIEExtCap *pDst)
136{
137 tANI_U8 pOut[DOT11F_IE_EXTCAP_MAX_LEN];
138
139 if ( NULL == pBuf )
140 {
141 limLog( pMac, LOGE,
142 FL("Invalid Buffer Address"));
143 return;
144 }
145 if(NULL == pDst)
146 {
147 PELOGE(limLog(pMac, LOGE,
148 FL("NULL pDst pointer"));)
149 return ;
150 }
151
152 if ( DOT11F_EID_EXTCAP != pBuf[0] ||
153 pBuf[1] > DOT11F_IE_EXTCAP_MAX_LEN )
154 {
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +0530155 limLog( pMac, LOG1,
Kalikinkar dhara205da782014-03-21 15:49:32 -0700156 FL("Invalid IEs eid = %d elem_len=%d "),
157 pBuf[0],pBuf[1]);
158 return;
159 }
160 vos_mem_set(( tANI_U8* )&pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, 0);
161 /* conversion should follow 4, 2, 2 byte order */
162 limUtilsframeshtonl(pMac, &pOut[0],*((tANI_U32*)&pBuf[2]),0);
163 limUtilsframeshtons(pMac, &pOut[4],*((tANI_U16*)&pBuf[6]),0);
164 limUtilsframeshtons(pMac, &pOut[6],*((tANI_U16*)&pBuf[8]),0);
165
166 if ( DOT11F_PARSE_SUCCESS != dot11fUnpackIeExtCap( pMac,
167 &pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, pDst) )
168 {
169 limLog( pMac, LOGE,
170 FL("dot11fUnpackIeExtCap Parse Error "));
171 }
172}
173
174tSirRetStatus limStripOffExtCapIEAndUpdateStruct(tpAniSirGlobal pMac,
175 tANI_U8* addIE,
176 tANI_U16 *addnIELen,
177 tDot11fIEExtCap * pDst )
178{
179 tANI_U8 pExtractedExtCapIEBuf[DOT11F_IE_EXTCAP_MAX_LEN + 2];
180 tSirRetStatus nSirStatus;
181
182 vos_mem_set(( tANI_U8* )&pExtractedExtCapIEBuf[0],
183 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
184 nSirStatus = limStripOffExtCapIE(pMac, addIE, addnIELen,
185 pExtractedExtCapIEBuf);
186 if ( eSIR_SUCCESS != nSirStatus )
187 {
188 limLog( pMac, LOG1, FL("Failed to strip off in"
189 "limStripOffExtCapIE status = (%d)."),
190 nSirStatus );
191 return nSirStatus;
192 }
193 /* update the extracted ExtCap to struct*/
194 limUpdateExtCapIEtoStruct(pMac, pExtractedExtCapIEBuf, pDst);
195 return nSirStatus;
196}
197
198void limMergeExtCapIEStruct(tDot11fIEExtCap *pDst,
199 tDot11fIEExtCap *pSrc)
200{
201 tANI_U8 *tempDst = (tANI_U8 *)pDst;
202 tANI_U8 *tempSrc = (tANI_U8 *)pSrc;
203 tANI_U8 structlen = sizeof(tDot11fIEExtCap);
204
205 while(tempDst && tempSrc && structlen--)
206 {
207 *tempDst |= *tempSrc;
208 tempDst++;
209 tempSrc++;
210 }
211}
Jeff Johnson295189b2012-06-20 16:38:30 -0700212
213/**
214 *
215 * \brief This function is called by various LIM modules to prepare the
216 * 802.11 frame MAC header
217 *
218 *
219 * \param pMac Pointer to Global MAC structure
220 *
221 * \param pBD Pointer to the frame buffer that needs to be populate
222 *
223 * \param type Type of the frame
224 *
225 * \param subType Subtype of the frame
226 *
227 * \return eHalStatus
228 *
229 *
230 * The pFrameBuf argument points to the beginning of the frame buffer to
231 * which - a) The 802.11 MAC header is set b) Following this MAC header
232 * will be the MGMT frame payload The payload itself is populated by the
233 * caller API
234 *
235 *
236 */
237
238tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
239 tANI_U8* pBD,
240 tANI_U8 type,
241 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530242 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700243{
244 tSirRetStatus statusCode = eSIR_SUCCESS;
245 tpSirMacMgmtHdr pMacHdr;
246
247 /// Prepare MAC management header
248 pMacHdr = (tpSirMacMgmtHdr) (pBD);
249
250 // Prepare FC
251 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
252 pMacHdr->fc.type = type;
253 pMacHdr->fc.subType = subType;
254
255 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530256 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 (tANI_U8 *) peerAddr,
258 sizeof( tSirMacAddr ));
259
260 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
262
263 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530264 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700265 (tANI_U8 *) peerAddr,
266 sizeof( tSirMacAddr ));
267 return statusCode;
268} /*** end limPopulateMacHeader() ***/
269
270/**
271 * \brief limSendProbeReqMgmtFrame
272 *
273 *
274 * \param pMac Pointer to Global MAC structure
275 *
276 * \param pSsid SSID to be sent in Probe Request frame
277 *
278 * \param bssid BSSID to be sent in Probe Request frame
279 *
280 * \param nProbeDelay probe delay to be used before sending Probe Request
281 * frame
282 *
283 * \param nChannelNum Channel # on which the Probe Request is going out
284 *
285 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
286 *
287 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
288 *
289 * This function is called by various LIM modules to send Probe Request frame
290 * during active scan/learn phase.
291 * Probe request is sent out in the following scenarios:
292 * --heartbeat failure: session needed
293 * --join req: session needed
294 * --foreground scan: no session
295 * --background scan: no session
296 * --schBeaconProcessing: to get EDCA parameters: session needed
297 *
298 *
299 */
300tSirRetStatus
301limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
302 tSirMacSSid *pSsid,
303 tSirMacAddr bssid,
304 tANI_U8 nChannelNum,
305 tSirMacAddr SelfMacAddr,
306 tANI_U32 dot11mode,
307 tANI_U32 nAdditionalIELen,
308 tANI_U8 *pAdditionalIE)
309{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530310 tDot11fProbeRequest pr;
311 tANI_U32 nStatus, nBytes, nPayload;
312 tSirRetStatus nSirStatus;
313 tANI_U8 *pFrame;
314 void *pPacket;
315 eHalStatus halstatus;
316 tpPESession psessionEntry;
317 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530319 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700320
321#ifndef GEN4_SCAN
322 return eSIR_FAILURE;
323#endif
324
325#if defined ( ANI_DVT_DEBUG )
326 return eSIR_FAILURE;
327#endif
328
Abhishek Singh4beed422014-02-03 16:47:17 +0530329 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
330 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
331 * is false and dot11mode is 11ac set it to 11n.
332 */
333 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
334 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
335 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
336 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
337 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 /*
339 * session context may or may not be present, when probe request needs to be sent out.
340 * following cases exist:
341 * --heartbeat failure: session needed
342 * --join req: session needed
343 * --foreground scan: no session
344 * --background scan: no session
345 * --schBeaconProcessing: to get EDCA parameters: session needed
346 * If session context does not exist, some IEs will be populated from CFGs,
347 * e.g. Supported and Extended rate set IEs
348 */
349 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
350
351 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
352 // and then hand it off to 'dot11fPackProbeRequest' (for
353 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530354 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355
356 // & delegating to assorted helpers:
357 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 if( nAdditionalIELen && pAdditionalIE )
360 {
361 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
362 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700363 /* Don't include 11b rate only when device is doing P2P Search */
364 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
365 ( p2pIe != NULL ) &&
366 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
367 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
368 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
369 ( ( psessionEntry != NULL ) &&
370 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
371 )
372 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 {
374 /* In the below API pass channel number > 14, do that it fills only
375 * 11a rates in supported rates */
376 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
377 }
378 else
379 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 PopulateDot11fSuppRates( pMac, nChannelNum,
381 &pr.SuppRates,psessionEntry);
382
383 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
384 {
385 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
386 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700388
389#if defined WLAN_FEATURE_VOWIFI
390 //Table 7-14 in IEEE Std. 802.11k-2008 says
391 //DS params "can" be present in RRM is disabled and "is" present if
392 //RRM is enabled. It should be ok even if we add it into probe req when
393 //RRM is not enabled.
394 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
395 //Call RRM module to get the tx power for management used.
396 {
397 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
398 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
399 }
400#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700401
402 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700403 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700405 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700407 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700409 } else { //psessionEntry == NULL
410 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700412 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 }
414 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800415
Hardik Kantilal Patelbca5b002015-01-19 15:30:18 +0530416 if((nChannelNum <= SIR_11B_CHANNEL_END)
417 && (!IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
418 && (!pMac->roam.configParam.channelBondingMode24GHz))
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800419 {
420 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
421 pr.HTCaps.shortGI40MHz = 0;
422 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700423#ifdef WLAN_FEATURE_11AC
424 if (psessionEntry != NULL ) {
425 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
426 //Include HT Capability IE
427 if (psessionEntry->vhtCapability)
428 {
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530429 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps,
430 psessionEntry->currentOperChannel , eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700431 }
432 } else {
433 if (IS_DOT11_MODE_VHT(dot11mode))
434 {
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530435 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, nChannelNum, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700436 }
437 }
438#endif
439
Jeff Johnson295189b2012-06-20 16:38:30 -0700440
441 // That's it-- now we pack it. First, how much space are we going to
442 // need?
443 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
444 if ( DOT11F_FAILED( nStatus ) )
445 {
446 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700447 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 // We'll fall back on the worst case scenario:
449 nPayload = sizeof( tDot11fProbeRequest );
450 }
451 else if ( DOT11F_WARNED( nStatus ) )
452 {
453 limLog( pMac, LOGW, FL("There were warnings while calculating"
454 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700455 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 }
457
458 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
459
460 // Ok-- try to allocate some memory:
461 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
462 ( tANI_U16 )nBytes, ( void** ) &pFrame,
463 ( void** ) &pPacket );
464 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
465 {
466 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700467 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 return eSIR_MEM_ALLOC_FAILED;
469 }
470
471 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530472 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700473
474 // Next, we fill out the buffer descriptor:
475 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530476 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 if ( eSIR_SUCCESS != nSirStatus )
478 {
479 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700480 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 nSirStatus );
482 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
483 ( void* ) pFrame, ( void* ) pPacket );
484 return nSirStatus; // allocated!
485 }
486
487 // That done, pack the Probe Request:
488 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
489 sizeof( tSirMacMgmtHdr ),
490 nPayload, &nPayload );
491 if ( DOT11F_FAILED( nStatus ) )
492 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700493 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 nStatus );
495 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
496 return eSIR_FAILURE; // allocated!
497 }
498 else if ( DOT11F_WARNED( nStatus ) )
499 {
500 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800501 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 }
503
504 // Append any AddIE if present.
505 if( nAdditionalIELen )
506 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530507 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 pAdditionalIE, nAdditionalIELen );
509 nPayload += nAdditionalIELen;
510 }
511
512 /* If this probe request is sent during P2P Search State, then we need
513 * to send it at OFDM rate.
514 */
515 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
517 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530518 /* For unicast probe req mgmt from Join function
519 we don't set above variables. So we need to add
520 one more check whether it is pePersona is P2P_CLIENT or not */
521 || ( ( psessionEntry != NULL ) &&
522 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 )
524 {
525 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
526 }
527
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +0530528 if( ( psessionEntry != NULL ) && ( psessionEntry->is11Gonly == true ) &&
529 ( !IS_BROADCAST_MAC(bssid) ) ){
530 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
531 }
532
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
534 HAL_TXRX_FRM_802_11_MGMT,
535 ANI_TXDIR_TODS,
536 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
537 limTxComplete, pFrame, txFlag );
538 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
539 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700540 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 //Pkt will be freed up by the callback
542 return eSIR_FAILURE;
543 }
544
545 return eSIR_SUCCESS;
546} // End limSendProbeReqMgmtFrame.
547
Jeff Johnson295189b2012-06-20 16:38:30 -0700548tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
549 tANI_U8* addIE, tANI_U16 *addnIELen,
550 tANI_U8 probeReqP2pIe)
551{
552 /* If Probe request doesn't have P2P IE, then take out P2P IE
553 from additional IE */
554 if(!probeReqP2pIe)
555 {
556 tANI_U8* tempbuf = NULL;
557 tANI_U16 tempLen = 0;
558 int left = *addnIELen;
559 v_U8_t *ptr = addIE;
560 v_U8_t elem_id, elem_len;
561
562 if(NULL == addIE)
563 {
564 PELOGE(limLog(pMac, LOGE,
565 FL(" NULL addIE pointer"));)
566 return eSIR_FAILURE;
567 }
568
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530569 tempbuf = vos_mem_malloc(left);
570 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 {
572 PELOGE(limLog(pMac, LOGE,
573 FL("Unable to allocate memory to store addn IE"));)
574 return eSIR_MEM_ALLOC_FAILED;
575 }
576
577 while(left >= 2)
578 {
579 elem_id = ptr[0];
580 elem_len = ptr[1];
581 left -= 2;
582 if(elem_len > left)
583 {
584 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700585 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530587 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 return eSIR_FAILURE;
589 }
590 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
591 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
592 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530593 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 tempLen += (elem_len + 2);
595 }
596 left -= elem_len;
597 ptr += (elem_len + 2);
598 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530599 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530601 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 }
603 return eSIR_SUCCESS;
604}
Jeff Johnson295189b2012-06-20 16:38:30 -0700605
606void
607limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
608 tSirMacAddr peerMacAddr,
609 tpAniSSID pSsid,
610 short nStaId,
611 tANI_U8 nKeepAlive,
612 tpPESession psessionEntry,
613 tANI_U8 probeReqP2pIe)
614{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700615 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530616 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530617 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530618 tpSirMacMgmtHdr pMacHdr;
619 tANI_U8 *pFrame;
620 void *pPacket;
621 eHalStatus halstatus;
622 tANI_U32 addnIEPresent;
623 tANI_U32 addnIE1Len=0;
624 tANI_U32 addnIE2Len=0;
625 tANI_U32 addnIE3Len=0;
626 tANI_U16 totalAddnIeLen = 0;
627 tANI_U32 wpsApEnable=0, tmp;
628 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530630 tANI_U8 *pP2pIe = NULL;
631 tANI_U8 noaLen = 0;
632 tANI_U8 total_noaLen = 0;
633 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530635 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700636 tDot11fIEExtCap extractedExtCap;
637 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530638 tANI_U32 nBytes = 0;
639
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
641 {
642 return; // in this case.
643 }
644
645 if(NULL == psessionEntry)
646 {
647 return;
648 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530649
650 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
651 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700652 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530653 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700654 return;
655 }
656
Girish Gowli0e826792014-05-17 17:56:44 +0530657 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
658
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 // Fill out 'frm', after which we'll just hand the struct off to
660 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530661 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700662
663 // Timestamp to be updated by TFP, below.
664
665 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
667 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700668 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 }
670 else
671 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800672 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
673 if (eSIR_SUCCESS != nSirStatus)
674 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700675 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800676 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530677 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800678 return;
679 }
680 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800681 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700682
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700683 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
684 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700686 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700687
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700688 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
689 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700690
Jeff Johnson295189b2012-06-20 16:38:30 -0700691
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
693 {
694 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
695 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700696 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 }
698 }
699 else
700 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800701 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700702 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700703
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800704 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700705
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800706 if (wpsApEnable)
707 {
708 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
709 }
710
711 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
712 {
713 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
714 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
715 }
716
717 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
718 {
719 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
720 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
721 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700723
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700724 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
725 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700726
Jeff Johnson295189b2012-06-20 16:38:30 -0700727
728 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700729 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700730
731
732 // N.B. In earlier implementations, the RSN IE would be placed in
733 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
734 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700735 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700736
737 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700738 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700740 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700741 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530743
744#ifdef WLAN_FEATURE_AP_HT40_24G
745 /* Populate Overlapping BSS Scan Parameters IEs,
746 * when operating in HT40 in 2.4GHz.
747 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +0530748 if ((pMac->roam.configParam.apHT40_24GEnabled)
749 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530750 {
751 PopulateDot11fOBSSScanParameters( pMac, &pFrm->OBSSScanParameters,
752 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530753 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
754 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
755 * Mode in 40 MHz bit in HT capablity.
756 */
757 pFrm->HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530758 }
759#endif
760
761 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
762
Jeff Johnsone7245742012-09-05 17:12:55 -0700763#ifdef WLAN_FEATURE_11AC
764 if(psessionEntry->vhtCapability)
765 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800766 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530767 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
768 psessionEntry->currentOperChannel, eSIR_TRUE );
769 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation ,
770 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700771 // we do not support multi users yet
772 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
773 }
774#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700775
Sandeep Puligilla60342762014-01-30 21:05:37 +0530776
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530777 if ( psessionEntry->pLimStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 {
779 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700780 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700781 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
782 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 }
784
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700785 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700786
787#if defined(FEATURE_WLAN_WAPI)
788 if( psessionEntry->pLimStartBssReq )
789 {
790 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700791 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 }
793
794#endif // defined(FEATURE_WLAN_WAPI)
795
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 if( pMac->lim.gpLimRemainOnChanReq )
798 {
799 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
800 }
801 //Only use CFG for non-listen mode. This CFG is not working for concurrency
802 //In listening mode, probe rsp IEs is passed in the message from SME to PE
803 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 {
805
806 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
807 &addnIEPresent) != eSIR_SUCCESS)
808 {
809 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530810 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 return;
812 }
813 }
814
815 if (addnIEPresent)
816 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530817
818 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
819 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 {
821 PELOGE(limLog(pMac, LOGE,
822 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530823 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 return;
825 }
826
827 //Probe rsp IE available
828 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
829 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
830 {
831 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530832 vos_mem_free(addIE);
833 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 return;
835 }
836 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
837 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
838 {
839 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
840 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
841 &addnIE1Len) )
842 {
843 limLog(pMac, LOGP,
844 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530845 vos_mem_free(addIE);
846 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 return;
848 }
849 }
850
851 //Probe rsp IE available
852 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
853 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
854 {
855 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530856 vos_mem_free(addIE);
857 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 return;
859 }
860 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
861 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
862 {
863 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
864 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
865 &addnIE2Len) )
866 {
867 limLog(pMac, LOGP,
868 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530869 vos_mem_free(addIE);
870 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 return;
872 }
873 }
874
875 //Probe rsp IE available
876 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
877 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
878 {
879 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530880 vos_mem_free(addIE);
881 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 return;
883 }
884 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
885 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
886 {
887 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
888 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
889 &addIE[addnIE1Len + addnIE2Len],
890 &addnIE3Len) )
891 {
892 limLog(pMac, LOGP,
893 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530894 vos_mem_free(addIE);
895 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 return;
897 }
898 }
899 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
900
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
902 {
903 limLog(pMac, LOGP,
904 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530905 vos_mem_free(addIE);
906 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 return;
908 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700909
Kalikinkar dhara205da782014-03-21 15:49:32 -0700910 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
911 addIE,
912 &totalAddnIeLen,
913 &extractedExtCap );
914 if(eSIR_SUCCESS != nSirStatus )
915 {
916 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
917 limLog(pMac, LOG1,
918 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
919 }
920
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 nBytes = nBytes + totalAddnIeLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530922 limLog(pMac, LOG1,
923 FL("probe rsp packet size is %d "), nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 if (probeReqP2pIe)
925 {
926 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
927 if (pP2pIe != NULL)
928 {
929 //get NoA attribute stream P2P IE
930 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
931 if (noaLen != 0)
932 {
933 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
934 &noaStream[0], noaLen);
935 nBytes = nBytes + total_noaLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530936 limLog(pMac, LOG1,
937 FL("p2p probe rsp packet size is %d, noalength is %d"),
938 nBytes, total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 }
940 }
941 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 }
943
c_hpothubcd78652014-04-28 22:31:08 +0530944 /*merge ExtCap IE*/
945 if (extractedExtCapFlag && extractedExtCap.present)
946 {
947 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
948 }
949
950 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
951 if ( DOT11F_FAILED( nStatus ) )
952 {
953 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
954 "or a Probe Response (0x%08x)."),
955 nStatus );
956 // We'll fall back on the worst case scenario:
957 nPayload = sizeof( tDot11fProbeResponse );
958 }
959 else if ( DOT11F_WARNED( nStatus ) )
960 {
961 limLog( pMac, LOGW, FL("There were warnings while calculating"
962 "the packed size for a Probe Response "
963 "(0x%08x)."), nStatus );
964 }
965
966 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
967
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
969 ( tANI_U16 )nBytes, ( void** ) &pFrame,
970 ( void** ) &pPacket );
971 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
972 {
973 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700974 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 if ( addIE != NULL )
976 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530977 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530979 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 return;
981 }
982
983 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530984 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700985
986 // Next, we fill out the buffer descriptor:
987 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
988 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
989 if ( eSIR_SUCCESS != nSirStatus )
990 {
991 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700992 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700993 nSirStatus );
994 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
995 ( void* ) pFrame, ( void* ) pPacket );
996 if ( addIE != NULL )
997 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530998 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301000 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 return;
1002 }
1003
1004 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1005
1006 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1007
1008 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001009 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 nPayload, &nPayload );
1011 if ( DOT11F_FAILED( nStatus ) )
1012 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001013 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 nStatus );
1015 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1016 if ( addIE != NULL )
1017 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301018 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301020 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 return; // allocated!
1022 }
1023 else if ( DOT11F_WARNED( nStatus ) )
1024 {
1025 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001026 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 }
1028
1029 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1030 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1031
1032 pMac->sys.probeRespond++;
1033
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 if( pMac->lim.gpLimRemainOnChanReq )
1035 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301036 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001039
1040 if ( addnIEPresent )
1041 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301042 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if (noaLen != 0)
1045 {
Krunal Soni81b24262013-05-15 17:46:41 -07001046 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 {
1048 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301049 FL("Not able to insert NoA because of length constraint."
1050 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301051 vos_mem_free(addIE);
1052 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001053 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1054 ( void* ) pFrame, ( void* ) pPacket );
1055 return;
1056 }
1057 else
1058 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301059 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001060 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001061 }
1062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001063
1064 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1066 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 )
1068 {
1069 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1070 }
1071
1072 // Queue Probe Response frame in high priority WQ
1073 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1074 ( tANI_U16 ) nBytes,
1075 HAL_TXRX_FRM_802_11_MGMT,
1076 ANI_TXDIR_TODS,
1077 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1078 limTxComplete, pFrame, txFlag );
1079 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1080 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001081 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 //Pkt will be freed up by the callback
1083 }
1084
1085 if ( addIE != NULL )
1086 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301087 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 }
1089
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301090 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001091 return;
1092
1093
Jeff Johnson295189b2012-06-20 16:38:30 -07001094} // End limSendProbeRspMgmtFrame.
1095
1096void
1097limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1098 tSirMacAddr peerMacAddr,
1099 tSirAddtsReqInfo *pAddTS,
1100 tpPESession psessionEntry)
1101{
1102 tANI_U16 i;
1103 tANI_U8 *pFrame;
1104 tSirRetStatus nSirStatus;
1105 tDot11fAddTSRequest AddTSReq;
1106 tDot11fWMMAddTSRequest WMMAddTSReq;
1107 tANI_U32 nPayload, nBytes, nStatus;
1108 tpSirMacMgmtHdr pMacHdr;
1109 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001110#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 tANI_U32 phyMode;
1112#endif
1113 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301114 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115
1116 if(NULL == psessionEntry)
1117 {
1118 return;
1119 }
1120
1121 if ( ! pAddTS->wmeTspecPresent )
1122 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301123 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001124
1125 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1126 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1127 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1128 if ( pAddTS->lleTspecPresent )
1129 {
1130 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1131 }
1132 else
1133 {
1134 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1135 }
1136
1137 if ( pAddTS->lleTspecPresent )
1138 {
1139 AddTSReq.num_WMMTCLAS = 0;
1140 AddTSReq.num_TCLAS = pAddTS->numTclas;
1141 for ( i = 0; i < pAddTS->numTclas; ++i)
1142 {
1143 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1144 &AddTSReq.TCLAS[i] );
1145 }
1146 }
1147 else
1148 {
1149 AddTSReq.num_TCLAS = 0;
1150 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1151 for ( i = 0; i < pAddTS->numTclas; ++i)
1152 {
1153 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1154 &AddTSReq.WMMTCLAS[i] );
1155 }
1156 }
1157
1158 if ( pAddTS->tclasProcPresent )
1159 {
1160 if ( pAddTS->lleTspecPresent )
1161 {
1162 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1163 AddTSReq.TCLASSPROC.present = 1;
1164 }
1165 else
1166 {
1167 AddTSReq.WMMTCLASPROC.version = 1;
1168 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1169 AddTSReq.WMMTCLASPROC.present = 1;
1170 }
1171 }
1172
1173 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1174 if ( DOT11F_FAILED( nStatus ) )
1175 {
1176 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001177 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 nStatus );
1179 // We'll fall back on the worst case scenario:
1180 nPayload = sizeof( tDot11fAddTSRequest );
1181 }
1182 else if ( DOT11F_WARNED( nStatus ) )
1183 {
1184 limLog( pMac, LOGW, FL("There were warnings while calculating"
1185 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001186 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 }
1188 }
1189 else
1190 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301191 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001192
1193 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1194 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1195 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1196
1197 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1198 WMMAddTSReq.StatusCode.statusCode = 0;
1199
1200 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001201#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 limGetPhyMode(pMac, &phyMode, psessionEntry);
1203
1204 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1205 {
1206 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1207 }
1208 else
1209 {
1210 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1211 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001212 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001213#endif
1214 // fillWmeTspecIE
1215
1216 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1217 if ( DOT11F_FAILED( nStatus ) )
1218 {
1219 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001220 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 nStatus );
1222 // We'll fall back on the worst case scenario:
1223 nPayload = sizeof( tDot11fAddTSRequest );
1224 }
1225 else if ( DOT11F_WARNED( nStatus ) )
1226 {
1227 limLog( pMac, LOGW, FL("There were warnings while calculating"
1228 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001229 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 }
1231 }
1232
1233 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1234
1235 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1236 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1237 ( void** ) &pPacket );
1238 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1239 {
1240 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001241 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 return;
1243 }
1244
1245 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301246 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001247
1248 // Next, we fill out the buffer descriptor:
1249 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1250 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1251 if ( eSIR_SUCCESS != nSirStatus )
1252 {
1253 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001254 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 nSirStatus );
1256 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1257 ( void* ) pFrame, ( void* ) pPacket );
1258 return;
1259 }
1260
1261 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1262
1263 #if 0
1264 cfgLen = SIR_MAC_ADDR_LENGTH;
1265 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1266 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1267 {
1268 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001269 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1271 ( void* ) pFrame, ( void* ) pPacket );
1272 return;
1273 }
1274 #endif //TO SUPPORT BT-AMP
1275
1276 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1277
Chet Lanctot186b5732013-03-18 10:26:30 -07001278#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001279 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001280#endif
1281
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 // That done, pack the struct:
1283 if ( ! pAddTS->wmeTspecPresent )
1284 {
1285 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1286 pFrame + sizeof(tSirMacMgmtHdr),
1287 nPayload, &nPayload );
1288 if ( DOT11F_FAILED( nStatus ) )
1289 {
1290 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001291 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 nStatus );
1293 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1294 return; // allocated!
1295 }
1296 else if ( DOT11F_WARNED( nStatus ) )
1297 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001298 limLog( pMac, LOGW, FL("There were warnings while packing "
1299 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 }
1301 }
1302 else
1303 {
1304 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1305 pFrame + sizeof(tSirMacMgmtHdr),
1306 nPayload, &nPayload );
1307 if ( DOT11F_FAILED( nStatus ) )
1308 {
1309 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001310 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 nStatus );
1312 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1313 return; // allocated!
1314 }
1315 else if ( DOT11F_WARNED( nStatus ) )
1316 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001317 limLog( pMac, LOGW, FL("There were warnings while packing "
1318 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 }
1320 }
1321
Abhishek Singh127a8442014-12-15 17:31:27 +05301322 limLog( pMac, LOG1, FL("Sending an Add TS Request frame to ") );
1323 limPrintMacAddr( pMac, peerMacAddr, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001324
1325 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1327 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 )
1329 {
1330 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1331 }
1332
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301333 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1334 psessionEntry->peSessionId,
1335 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 // Queue Addts Response frame in high priority WQ
1337 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1338 HAL_TXRX_FRM_802_11_MGMT,
1339 ANI_TXDIR_TODS,
1340 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1341 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301342 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1343 psessionEntry->peSessionId,
1344 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1346 {
1347 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001348 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 //Pkt will be freed up by the callback
1350 }
1351
1352} // End limSendAddtsReqActionFrame.
1353
Jeff Johnson295189b2012-06-20 16:38:30 -07001354
1355
1356void
1357limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1358 tANI_U16 statusCode,
1359 tANI_U16 aid,
1360 tSirMacAddr peerMacAddr,
1361 tANI_U8 subType,
1362 tpDphHashNode pSta,tpPESession psessionEntry)
1363{
1364 static tDot11fAssocResponse frm;
1365 tANI_U8 *pFrame, *macAddr;
1366 tpSirMacMgmtHdr pMacHdr;
1367 tSirRetStatus nSirStatus;
1368 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1369 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301370 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 void *pPacket;
1372 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301373 tUpdateBeaconParams beaconParams;
1374 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 tANI_U32 addnIEPresent = false;
1376 tANI_U32 addnIELen=0;
1377 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1378 tpSirAssocReq pAssocReq = NULL;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301379 tANI_U16 addStripoffIELen = 0;
1380 tDot11fIEExtCap extractedExtCap;
1381 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301382 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001383
Chet Lanctot8cecea22014-02-11 19:09:36 -08001384#ifdef WLAN_FEATURE_11W
1385 tANI_U32 retryInterval;
1386 tANI_U32 maxRetries;
1387#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001388
1389 if(NULL == psessionEntry)
1390 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301391 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 return;
1393 }
1394
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301395 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001396
1397 limGetQosMode(psessionEntry, &qosMode);
1398 limGetWmeMode(psessionEntry, &wmeMode);
1399
1400 // An Add TS IE is added only if the AP supports it and the requesting
1401 // STA sent a traffic spec.
1402 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1403
1404 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1405
1406 frm.Status.status = statusCode;
1407
1408 frm.AID.associd = aid | LIM_AID_MASK;
1409
1410 if ( NULL == pSta )
1411 {
1412 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1413 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1414 }
1415 else
1416 {
1417 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1418 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1419 }
1420
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1422 {
1423 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1424 {
1425 pAssocReq =
1426 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1428 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1429 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 }
1432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001433
1434 if ( NULL != pSta )
1435 {
1436 if ( eHAL_SET == qosMode )
1437 {
1438 if ( pSta->lleEnabled )
1439 {
1440 lleMode = 1;
1441 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1442 {
1443 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1444
1445// FramesToDo:...
1446// if ( fAddTS )
1447// {
1448// tANI_U8 *pAf = pBody;
1449// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1450// tANI_U32 tlen;
1451// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1452// &tlen, bufLen - frameLen);
1453// } // End if on Add TS.
1454 }
1455 } // End if on .11e enabled in 'pSta'.
1456 } // End if on QOS Mode on.
1457
1458 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1459 {
1460 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1461 {
1462
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001464
1465 if ( pSta->wsmEnabled )
1466 {
1467 PopulateDot11fWMMCaps(&frm.WMMCaps );
1468 }
1469 }
1470 }
1471
1472 if ( pSta->aniPeer )
1473 {
1474 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1475 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1476 {
1477 edcaInclude = 1;
1478 }
1479
1480 } // End if on Airgo peer.
1481
1482 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001483 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05301485 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001486 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301487 /*
1488 *Check the STA capability and update the HTCaps accordingly
1489 */
1490 frm.HTCaps.supportedChannelWidthSet =
1491 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1492 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1493
1494 if (!frm.HTCaps.supportedChannelWidthSet)
1495 frm.HTCaps.shortGI40MHz = 0;
1496
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05301499 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
1500 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
1501 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
1502 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
1503 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
1504
1505
Jeff Johnsone7245742012-09-05 17:12:55 -07001506
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301507#ifdef WLAN_FEATURE_AP_HT40_24G
1508 /* Populate Overlapping BSS Scan Parameters IEs,
1509 * when operating in HT40 in 2.4GHz.
1510 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +05301511 if ((pMac->roam.configParam.apHT40_24GEnabled)
1512 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301513 {
1514 PopulateDot11fOBSSScanParameters( pMac, &frm.OBSSScanParameters,
1515 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +05301516 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
1517 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
1518 * Mode in 40 MHz bit in HT capablity.
1519 */
1520 frm.HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301521 }
1522#endif
1523
1524 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001525#ifdef WLAN_FEATURE_11AC
1526 if( pSta->mlmStaContext.vhtCapability &&
1527 psessionEntry->vhtCapability )
1528 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001529 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05301530 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
1531 psessionEntry->currentOperChannel, eSIR_TRUE );
1532 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation,
1533 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07001534 }
1535#endif
1536
Chet Lanctot8cecea22014-02-11 19:09:36 -08001537#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301538 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1539 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001540 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1541 &maxRetries ) != eSIR_SUCCESS )
1542 limLog( pMac, LOGE,
1543 FL("Could not retrieve PMF SA Query maximum retries value") );
1544 else
1545 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1546 &retryInterval ) != eSIR_SUCCESS)
1547 limLog( pMac, LOGE,
1548 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301549 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001550 PopulateDot11fTimeoutInterval(
1551 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1552 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301553 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001554#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301555 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001556
Chet Lanctot8cecea22014-02-11 19:09:36 -08001557 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001558
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1560 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1561 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001563
1564 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1565 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1566
1567 beaconParams.bssIdx = psessionEntry->bssIdx;
1568
1569 //Send message to HAL about beacon parameter change.
1570 if(beaconParams.paramChangeBitmap)
1571 {
1572 schSetFixedBeaconFields(pMac,psessionEntry);
1573 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1574 }
1575
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 if ( pAssocReq != NULL )
1577 {
1578 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1579 &addnIEPresent) != eSIR_SUCCESS)
1580 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301581 limLog(pMac, LOGP, FL("Unable to get "
1582 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 return;
1584 }
1585
1586 if (addnIEPresent)
1587 {
1588 //Assoc rsp IE available
1589 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1590 &addnIELen) != eSIR_SUCCESS)
1591 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301592 limLog(pMac, LOGP, FL("Unable to get "
1593 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 return;
1595 }
1596
1597 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1598 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1599 {
1600 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1601 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1602 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301603
1604 vos_mem_set(( tANI_U8* )&extractedExtCap,
1605 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301606 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301607 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1608 &addIE[0],
1609 &addStripoffIELen,
1610 &extractedExtCap );
1611 if(eSIR_SUCCESS != nSirStatus)
1612 {
1613 limLog(pMac, LOG1,
1614 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1615 }
1616 else
1617 {
1618 addnIELen = addStripoffIELen;
1619 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 nBytes = nBytes + addnIELen;
1622 }
1623 }
1624 }
1625 }
1626
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301627 /* merge the ExtCap struct*/
1628 if (extractedExtCapFlag && extractedExtCap.present)
1629 {
1630 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1631 }
1632
c_hpothubcd78652014-04-28 22:31:08 +05301633 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1634 if ( DOT11F_FAILED( nStatus ) )
1635 {
1636 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1637 "or an Association Response (0x%08x)."),
1638 nStatus );
1639 return;
1640 }
1641 else if ( DOT11F_WARNED( nStatus ) )
1642 {
1643 limLog( pMac, LOGW, FL("There were warnings while calculating "
1644 "the packed size for an Association Re"
1645 "sponse (0x%08x)."), nStatus );
1646 }
1647
1648 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1649
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1651 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1652 ( void** ) &pPacket );
1653 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1654 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001655 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 return;
1657 }
1658
1659 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301660 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001661
1662 // Next, we fill out the buffer descriptor:
1663 nSirStatus = limPopulateMacHeader( pMac,
1664 pFrame,
1665 SIR_MAC_MGMT_FRAME,
1666 ( LIM_ASSOC == subType ) ?
1667 SIR_MAC_MGMT_ASSOC_RSP :
1668 SIR_MAC_MGMT_REASSOC_RSP,
1669 peerMacAddr,psessionEntry->selfMacAddr);
1670 if ( eSIR_SUCCESS != nSirStatus )
1671 {
1672 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001673 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 nSirStatus );
1675 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1676 ( void* ) pFrame, ( void* ) pPacket );
1677 return;
1678 }
1679
1680 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1681
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1683
1684 nStatus = dot11fPackAssocResponse( pMac, &frm,
1685 pFrame + sizeof( tSirMacMgmtHdr ),
1686 nPayload, &nPayload );
1687 if ( DOT11F_FAILED( nStatus ) )
1688 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301689 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1690 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1692 ( void* ) pFrame, ( void* ) pPacket );
1693 return; // allocated!
1694 }
1695 else if ( DOT11F_WARNED( nStatus ) )
1696 {
1697 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001698 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 }
1700
1701 macAddr = pMacHdr->da;
1702
1703 if (subType == LIM_ASSOC)
1704 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301705 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 FL("*** Sending Assoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301707 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 }
1709 else{
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301710 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 FL("*** Sending ReAssoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301712 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301714 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001715
1716 if ( addnIEPresent )
1717 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301718 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 }
1720
1721 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1723 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 )
1725 {
1726 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1727 }
1728
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301729 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1730 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1731 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1732
1733 txFlag |= HAL_USE_FW_IN_TX_PATH;
1734
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301735 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1736 psessionEntry->peSessionId,
1737 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301738
1739 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
1740 {
1741 limLog(pMac, LOG1, FL("Re/AssocRsp - txBdToken %u"), pMac->lim.txBdToken);
1742 /// Queue Association Response frame in high priority WQ
1743 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1744 HAL_TXRX_FRM_802_11_MGMT,
1745 ANI_TXDIR_TODS,
1746 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1747 limTxComplete, pFrame, limTxBdComplete,
1748 txFlag, pMac->lim.txBdToken );
1749 pMac->lim.txBdToken++;
1750 }
1751 else
1752 {
1753 /// Queue Association Response frame in high priority WQ
1754 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1755 HAL_TXRX_FRM_802_11_MGMT,
1756 ANI_TXDIR_TODS,
1757 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1758 limTxComplete, pFrame, txFlag );
1759 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301760 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1761 psessionEntry->peSessionId,
1762 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1764 {
1765 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001766 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 nSirStatus);
1768
1769 //Pkt will be freed up by the callback
1770 }
1771
1772 // update the ANI peer station count
1773 //FIXME_PROTECTION : take care of different type of station
1774 // counter inside this function.
1775 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1776
1777} // End limSendAssocRspMgmtFrame.
1778
1779
1780
1781void
1782limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1783 tSirMacAddr peer,
1784 tANI_U16 nStatusCode,
1785 tSirAddtsReqInfo *pAddTS,
1786 tSirMacScheduleIE *pSchedule,
1787 tpPESession psessionEntry)
1788{
1789 tANI_U8 *pFrame;
1790 tpSirMacMgmtHdr pMacHdr;
1791 tDot11fAddTSResponse AddTSRsp;
1792 tDot11fWMMAddTSResponse WMMAddTSRsp;
1793 tSirRetStatus nSirStatus;
1794 tANI_U32 i, nBytes, nPayload, nStatus;
1795 void *pPacket;
1796 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301797 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001798
1799 if(NULL == psessionEntry)
1800 {
1801 return;
1802 }
1803
1804 if ( ! pAddTS->wmeTspecPresent )
1805 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301806 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001807
1808 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1809 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1810 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1811 AddTSRsp.Status.status = nStatusCode;
1812
1813 // The TsDelay information element is only filled in for a specific
1814 // status code:
1815 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1816 {
1817 if ( pAddTS->wsmTspecPresent )
1818 {
1819 AddTSRsp.WMMTSDelay.version = 1;
1820 AddTSRsp.WMMTSDelay.delay = 10;
1821 AddTSRsp.WMMTSDelay.present = 1;
1822 }
1823 else
1824 {
1825 AddTSRsp.TSDelay.delay = 10;
1826 AddTSRsp.TSDelay.present = 1;
1827 }
1828 }
1829
1830 if ( pAddTS->wsmTspecPresent )
1831 {
1832 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1833 }
1834 else
1835 {
1836 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1837 }
1838
1839 if ( pAddTS->wsmTspecPresent )
1840 {
1841 AddTSRsp.num_WMMTCLAS = 0;
1842 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1843 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1844 {
1845 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1846 &AddTSRsp.TCLAS[i] );
1847 }
1848 }
1849 else
1850 {
1851 AddTSRsp.num_TCLAS = 0;
1852 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1853 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1854 {
1855 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1856 &AddTSRsp.WMMTCLAS[i] );
1857 }
1858 }
1859
1860 if ( pAddTS->tclasProcPresent )
1861 {
1862 if ( pAddTS->wsmTspecPresent )
1863 {
1864 AddTSRsp.WMMTCLASPROC.version = 1;
1865 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1866 AddTSRsp.WMMTCLASPROC.present = 1;
1867 }
1868 else
1869 {
1870 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1871 AddTSRsp.TCLASSPROC.present = 1;
1872 }
1873 }
1874
1875 // schedule element is included only if requested in the tspec and we are
1876 // using hcca (or both edca and hcca)
1877 // 11e-D8.0 is inconsistent on whether the schedule element is included
1878 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1879 // pg 46, line 17-18 says something else. So just include it and let the
1880 // sta figure it out
1881 if ((pSchedule != NULL) &&
1882 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1883 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1884 {
1885 if ( pAddTS->wsmTspecPresent )
1886 {
1887 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1888 }
1889 else
1890 {
1891 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1892 }
1893 }
1894
1895 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1896 if ( DOT11F_FAILED( nStatus ) )
1897 {
1898 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001899 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 nStatus );
1901 // We'll fall back on the worst case scenario:
1902 nPayload = sizeof( tDot11fAddTSResponse );
1903 }
1904 else if ( DOT11F_WARNED( nStatus ) )
1905 {
1906 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001907 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001908 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 }
1910 }
1911 else
1912 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301913 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001914
1915 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1916 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1917 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1918 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1919
1920 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1921
1922 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1923 if ( DOT11F_FAILED( nStatus ) )
1924 {
1925 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001926 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 nStatus );
1928 // We'll fall back on the worst case scenario:
1929 nPayload = sizeof( tDot11fWMMAddTSResponse );
1930 }
1931 else if ( DOT11F_WARNED( nStatus ) )
1932 {
1933 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001934 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001935 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001936 }
1937 }
1938
1939 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1940
1941 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1942 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1943 {
1944 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001945 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 return;
1947 }
1948
1949 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301950 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001951
1952 // Next, we fill out the buffer descriptor:
1953 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1954 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1955 if ( eSIR_SUCCESS != nSirStatus )
1956 {
1957 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001958 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 nSirStatus );
1960 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1961 return; // allocated!
1962 }
1963
1964 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1965
1966
1967 #if 0
1968 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1969 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1970 {
1971 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001972 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001973 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1974 return; // allocated!
1975 }
1976 #endif //TO SUPPORT BT-AMP
1977 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1978
Chet Lanctot186b5732013-03-18 10:26:30 -07001979#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001980 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001981#endif
1982
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 // That done, pack the struct:
1984 if ( ! pAddTS->wmeTspecPresent )
1985 {
1986 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1987 pFrame + sizeof( tSirMacMgmtHdr ),
1988 nPayload, &nPayload );
1989 if ( DOT11F_FAILED( nStatus ) )
1990 {
1991 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001992 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 nStatus );
1994 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1995 return;
1996 }
1997 else if ( DOT11F_WARNED( nStatus ) )
1998 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001999 limLog( pMac, LOGW, FL("There were warnings while packing "
2000 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 }
2002 }
2003 else
2004 {
2005 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
2006 pFrame + sizeof( tSirMacMgmtHdr ),
2007 nPayload, &nPayload );
2008 if ( DOT11F_FAILED( nStatus ) )
2009 {
2010 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002011 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 nStatus );
2013 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2014 return;
2015 }
2016 else if ( DOT11F_WARNED( nStatus ) )
2017 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002018 limLog( pMac, LOGW, FL("There were warnings while packing "
2019 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 }
2021 }
2022
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302023 limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 nStatusCode );
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302025 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002026
2027 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2029 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 )
2031 {
2032 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2033 }
2034
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302035 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2036 psessionEntry->peSessionId,
2037 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 // Queue the frame in high priority WQ:
2039 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2040 HAL_TXRX_FRM_802_11_MGMT,
2041 ANI_TXDIR_TODS,
2042 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2043 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302044 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2045 psessionEntry->peSessionId,
2046 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2048 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002049 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 nSirStatus );
2051 //Pkt will be freed up by the callback
2052 }
2053
2054} // End limSendAddtsRspActionFrame.
2055
2056void
2057limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2058 tSirMacAddr peer,
2059 tANI_U8 wmmTspecPresent,
2060 tSirMacTSInfo *pTsinfo,
2061 tSirMacTspecIE *pTspecIe,
2062 tpPESession psessionEntry)
2063{
2064 tANI_U8 *pFrame;
2065 tpSirMacMgmtHdr pMacHdr;
2066 tDot11fDelTS DelTS;
2067 tDot11fWMMDelTS WMMDelTS;
2068 tSirRetStatus nSirStatus;
2069 tANI_U32 nBytes, nPayload, nStatus;
2070 void *pPacket;
2071 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302072 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002073
2074 if(NULL == psessionEntry)
2075 {
2076 return;
2077 }
2078
2079 if ( ! wmmTspecPresent )
2080 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302081 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002082
2083 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2084 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2085 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2086
2087 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2088 if ( DOT11F_FAILED( nStatus ) )
2089 {
2090 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002091 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 nStatus );
2093 // We'll fall back on the worst case scenario:
2094 nPayload = sizeof( tDot11fDelTS );
2095 }
2096 else if ( DOT11F_WARNED( nStatus ) )
2097 {
2098 limLog( pMac, LOGW, FL("There were warnings while calcula"
2099 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002100 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 }
2102 }
2103 else
2104 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302105 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002106
2107 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2108 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2109 WMMDelTS.DialogToken.token = 0;
2110 WMMDelTS.StatusCode.statusCode = 0;
2111 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2112 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2113 if ( DOT11F_FAILED( nStatus ) )
2114 {
2115 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002116 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 nStatus );
2118 // We'll fall back on the worst case scenario:
2119 nPayload = sizeof( tDot11fDelTS );
2120 }
2121 else if ( DOT11F_WARNED( nStatus ) )
2122 {
2123 limLog( pMac, LOGW, FL("There were warnings while calcula"
2124 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002125 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 }
2127 }
2128
2129 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2130
2131 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2132 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2133 {
2134 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002135 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 return;
2137 }
2138
2139 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302140 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002141
2142 // Next, we fill out the buffer descriptor:
2143 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2144 SIR_MAC_MGMT_ACTION, peer,
2145 psessionEntry->selfMacAddr);
2146 if ( eSIR_SUCCESS != nSirStatus )
2147 {
2148 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002149 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 nSirStatus );
2151 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2152 return; // allocated!
2153 }
2154
2155 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2156
2157 #if 0
2158
2159 cfgLen = SIR_MAC_ADDR_LENGTH;
2160 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2161 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2162 {
2163 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002164 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2166 return; // allocated!
2167 }
2168 #endif //TO SUPPORT BT-AMP
2169 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2170
Chet Lanctot186b5732013-03-18 10:26:30 -07002171#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002172 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002173#endif
2174
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 // That done, pack the struct:
2176 if ( !wmmTspecPresent )
2177 {
2178 nStatus = dot11fPackDelTS( pMac, &DelTS,
2179 pFrame + sizeof( tSirMacMgmtHdr ),
2180 nPayload, &nPayload );
2181 if ( DOT11F_FAILED( nStatus ) )
2182 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002183 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 nStatus );
2185 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2186 return; // allocated!
2187 }
2188 else if ( DOT11F_WARNED( nStatus ) )
2189 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002190 limLog( pMac, LOGW, FL("There were warnings while packing "
2191 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 }
2193 }
2194 else
2195 {
2196 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2197 pFrame + sizeof( tSirMacMgmtHdr ),
2198 nPayload, &nPayload );
2199 if ( DOT11F_FAILED( nStatus ) )
2200 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002201 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 nStatus );
2203 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2204 return; // allocated!
2205 }
2206 else if ( DOT11F_WARNED( nStatus ) )
2207 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002208 limLog( pMac, LOGW, FL("There were warnings while packing "
2209 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 }
2211 }
2212
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302213 limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2214 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002215
2216 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2218 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 )
2220 {
2221 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2222 }
2223
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302224 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2225 psessionEntry->peSessionId,
2226 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2228 HAL_TXRX_FRM_802_11_MGMT,
2229 ANI_TXDIR_TODS,
2230 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2231 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302232 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2233 psessionEntry->peSessionId,
2234 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2236 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002237 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 nSirStatus );
2239 //Pkt will be freed up by the callback
2240 }
2241
2242} // End limSendDeltsReqActionFrame.
2243
2244void
2245limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2246 tLimMlmAssocReq *pMlmAssocReq,
2247 tpPESession psessionEntry)
2248{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002249 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 tANI_U16 caps;
2251 tANI_U8 *pFrame;
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302252 tSirRetStatus nSirStatus = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302254 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2256 void *pPacket;
2257 eHalStatus halstatus;
2258 tANI_U16 nAddIELen;
2259 tANI_U8 *pAddIE;
2260 tANI_U8 *wpsIe = NULL;
2261#if defined WLAN_FEATURE_VOWIFI
2262 tANI_U8 PowerCapsPopulated = FALSE;
2263#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302264 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302265 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002266 tDot11fIEExtCap extractedExtCap;
2267 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302268 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002269
2270 if(NULL == psessionEntry)
2271 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302272 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 return;
2274 }
2275
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 /* check this early to avoid unncessary operation */
2277 if(NULL == psessionEntry->pLimJoinReq)
2278 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302279 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 return;
2281 }
2282 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2283 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2284
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302285 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2286 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002287 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302288 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002289 return;
2290 }
2291
2292
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302293 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002294
Kalikinkar dhara205da782014-03-21 15:49:32 -07002295 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302296 if (psessionEntry->is_ext_caps_present)
2297 {
2298 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
Kalikinkar dhara205da782014-03-21 15:49:32 -07002299 &nAddIELen,
2300 &extractedExtCap );
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302301 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002302 if(eSIR_SUCCESS != nSirStatus )
2303 {
2304 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2305 limLog(pMac, LOG1,
2306 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2307 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002308 /* TODO:remove this code once driver provides the call back function
2309 * to supplicant for set_qos_map
2310 */
2311 else
2312 {
Abhishek Singhc601a472016-01-20 11:08:32 +05302313 if (extractedExtCap.interworkingService ||
2314 extractedExtCap.bssTransition)
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002315 {
2316 extractedExtCap.qosMap = 1;
2317 }
Abhishek Singh15d95602015-03-24 15:52:57 +05302318 /* No need to merge the EXT Cap from Supplicant
Abhishek Singhc601a472016-01-20 11:08:32 +05302319 * if interworkingService or bsstransition is not set,
2320 * as currently driver is only interested in interworkingService
2321 * and bsstransition capability from supplicant. if in
Abhishek Singh15d95602015-03-24 15:52:57 +05302322 * future any other EXT Cap info is required from
2323 * supplicant it needs to be handled here.
2324 */
2325 else
2326 {
2327 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2328 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002329 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002330
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 caps = pMlmAssocReq->capabilityInfo;
2332 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2333 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2334#if defined(FEATURE_WLAN_WAPI)
2335 /* CR: 262463 :
2336 According to WAPI standard:
2337 7.3.1.4 Capability Information field
2338 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2339 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2340 Reassociation management frames. */
2341 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2342 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2343#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002344 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002345
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002346 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2347 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002349 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002350
2351 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2352 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2353
2354 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2355 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2356
2357 // We prefer .11e asociations:
2358 if ( fQosEnabled ) fWmeEnabled = false;
2359
2360 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2361 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2362
2363 if ( psessionEntry->lim11hEnable &&
2364 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2365 {
2366#if defined WLAN_FEATURE_VOWIFI
2367 PowerCapsPopulated = TRUE;
2368
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002369 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002370#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002371 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002372
2373 }
2374
2375#if defined WLAN_FEATURE_VOWIFI
2376 if( pMac->rrm.rrmPEContext.rrmEnable &&
2377 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2378 {
2379 if (PowerCapsPopulated == FALSE)
2380 {
2381 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002382 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 }
2384 }
2385#endif
2386
2387 if ( fQosEnabled &&
2388 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002389 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002390
2391 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002392 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002393
2394#if defined WLAN_FEATURE_VOWIFI
2395 if( pMac->rrm.rrmPEContext.rrmEnable &&
2396 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2397 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002398 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 }
2400#endif
2401 // The join request *should* contain zero or one of the WPA and RSN
2402 // IEs. The payload send along with the request is a
2403 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2404
2405 // typedef struct sSirRSNie
2406 // {
2407 // tANI_U16 length;
2408 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2409 // } tSirRSNie, *tpSirRSNie;
2410
2411 // So, we should be able to make the following two calls harmlessly,
2412 // since they do nothing if they don't find the given IE in the
2413 // bytestream with which they're provided.
2414
2415 // The net effect of this will be to faithfully transmit whatever
2416 // security IE is in the join request.
2417
2418 // *However*, if we're associating for the purpose of WPS
2419 // enrollment, and we've been configured to indicate that by
2420 // eliding the WPA or RSN IE, we just skip this:
2421 if( nAddIELen && pAddIE )
2422 {
2423 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2424 }
2425 if ( NULL == wpsIe )
2426 {
2427 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002428 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002430 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002431#if defined(FEATURE_WLAN_WAPI)
2432 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002433 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002434#endif // defined(FEATURE_WLAN_WAPI)
2435 }
2436
2437 // include WME EDCA IE as well
2438 if ( fWmeEnabled )
2439 {
2440 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2441 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002442 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 }
2444
2445 if ( fWsmEnabled &&
2446 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2447 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002448 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 }
2450 }
2451
2452 //Populate HT IEs, when operating in 11n or Taurus modes AND
2453 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002454 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 pMac->lim.htCapabilityPresentInBeacon)
2456 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302457 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002458 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002459#ifdef DISABLE_GF_FOR_INTEROP
2460
2461 /*
2462 * To resolve the interop problem with Broadcom AP,
2463 * where TQ STA could not pass traffic with GF enabled,
2464 * TQ STA will do Greenfield only with TQ AP, for
2465 * everybody else it will be turned off.
2466 */
2467
2468 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2469 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302470 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2471 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002472 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 }
2474#endif
2475
2476 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302477
2478 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2479 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2480 pFrm->HTCaps.supportedChannelWidthSet, pFrm->HTCaps.mimoPowerSave,
2481 pFrm->HTCaps.greenField, pFrm->HTCaps.shortGI20MHz, pFrm->HTCaps.shortGI40MHz,
2482 pFrm->HTCaps.dsssCckMode40MHz, pFrm->HTCaps.maxRxAMPDUFactor);
2483
2484
Jeff Johnsone7245742012-09-05 17:12:55 -07002485#ifdef WLAN_FEATURE_11AC
2486 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002487 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002488 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002489 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302490 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
2491 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302492
Jeff Johnsone7245742012-09-05 17:12:55 -07002493 }
2494#endif
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302495 if (psessionEntry->is_ext_caps_present)
2496 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002497
2498#if defined WLAN_FEATURE_VOWIFI_11R
2499 if (psessionEntry->pLimJoinReq->is11Rconnection)
2500 {
2501#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002502 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2504 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2505 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2506#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302507 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2508 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302510 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 {
2512 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302513 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 }
2515#endif
2516
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002517#ifdef FEATURE_WLAN_ESE
2518 /* For ESE Associations fill the ESE IEs */
2519 if (psessionEntry->isESEconnection &&
2520 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002522#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002523 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002524#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002525 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 }
2527#endif
2528
c_hpothubcd78652014-04-28 22:31:08 +05302529 /* merge the ExtCap struct*/
2530 if (extractedExtCapFlag && extractedExtCap.present)
2531 {
2532 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2533 }
2534
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002535 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 if ( DOT11F_FAILED( nStatus ) )
2537 {
2538 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002539 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 nStatus );
2541 // We'll fall back on the worst case scenario:
2542 nPayload = sizeof( tDot11fAssocRequest );
2543 }
2544 else if ( DOT11F_WARNED( nStatus ) )
2545 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002546 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002548 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 }
2550
2551 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2552
2553 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2554 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2555 ( void** ) &pPacket );
2556 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2557 {
2558 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002559 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002560
2561 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002562 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002563
2564
2565 /* Update PE session id*/
2566 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2567
2568 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2569
2570 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2571 ( void* ) pFrame, ( void* ) pPacket );
2572
2573 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2574 ( tANI_U32* ) &mlmAssocCnf);
2575
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302576 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 return;
2578 }
2579
2580 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302581 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002582
2583 // Next, we fill out the buffer descriptor:
2584 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2585 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2586 if ( eSIR_SUCCESS != nSirStatus )
2587 {
2588 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002589 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 nSirStatus );
2591 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302592 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 return;
2594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002595
Abhishek Singh57aebef2014-02-03 18:47:44 +05302596 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002597 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 sizeof(tSirMacMgmtHdr),
2599 nPayload, &nPayload );
2600 if ( DOT11F_FAILED( nStatus ) )
2601 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302602 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002603 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 nStatus );
2605 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2606 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302607 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 return;
2609 }
2610 else if ( DOT11F_WARNED( nStatus ) )
2611 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302612 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2613 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 }
2615
2616 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002617 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 nBytes );)
2619 // limPrintMacAddr( pMac, bssid, LOG1 );
2620
2621 if( psessionEntry->assocReq != NULL )
2622 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302623 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 psessionEntry->assocReq = NULL;
2625 }
2626
2627 if( nAddIELen )
2628 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302629 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2630 pAddIE,
2631 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 nPayload += nAddIELen;
2633 }
2634
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302635 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2636 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302638 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2639 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 }
2641 else
2642 {
2643 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302644 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 psessionEntry->assocReqLen = nPayload;
2646 }
2647
2648 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2650 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 )
2652 {
2653 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2654 }
2655
Sushant Kaushike8681d22015-04-21 12:08:25 +05302656 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
2657 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08002658 {
2659 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2660 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05302661#ifdef FEATURE_WLAN_DIAG_SUPPORT
2662 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_START_EVENT, psessionEntry,
2663 eSIR_SUCCESS, eSIR_SUCCESS);
2664#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302665 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302666 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2667 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2668 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2669 txFlag |= HAL_USE_FW_IN_TX_PATH;
2670
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302671 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2672 psessionEntry->peSessionId,
2673 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302674
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302675 if( ( psessionEntry->is11Gonly == true ) &&
2676 ( !IS_BROADCAST_MAC(pMlmAssocReq->peerMacAddr) ) ){
2677 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2678 }
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05302679 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
2680 {
2681 limLog(pMac, LOG1, FL("Assoc Req - txBdToken %u"), pMac->lim.txBdToken);
2682 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
2683 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2684 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2685 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2686 limTxComplete, pFrame, limTxBdComplete, txFlag,
2687 pMac->lim.txBdToken);
2688 pMac->lim.txBdToken++;
2689 }
2690 else
2691 {
2692 halstatus = halTxFrame( pMac, pPacket,
2693 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2694 HAL_TXRX_FRM_802_11_MGMT,
2695 ANI_TXDIR_TODS,
2696 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2697 limTxComplete, pFrame, txFlag );
2698 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302699 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2700 psessionEntry->peSessionId,
2701 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2703 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002704 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 halstatus );
2706 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302707 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 return;
2709 }
2710
Katya Nigamccaeda72015-04-20 18:51:22 +05302711 //Enable caching only if Assoc Request is successfully submitted to the h/w
2712 WLANTL_EnableCaching(psessionEntry->staId);
2713
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302715 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002716 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302717 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002718 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002719} // End limSendAssocReqMgmtFrame
2720
2721
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002722#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002723/*------------------------------------------------------------------------------------
2724 *
2725 * Send Reassoc Req with FTIEs.
2726 *
2727 *-----------------------------------------------------------------------------------
2728 */
2729void
2730limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2731 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2732{
2733 static tDot11fReAssocRequest frm;
2734 tANI_U16 caps;
2735 tANI_U8 *pFrame;
2736 tSirRetStatus nSirStatus;
2737 tANI_U32 nBytes, nPayload, nStatus;
2738 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2739 void *pPacket;
2740 eHalStatus halstatus;
2741#if defined WLAN_FEATURE_VOWIFI
2742 tANI_U8 PowerCapsPopulated = FALSE;
2743#endif
2744 tANI_U16 ft_ies_length = 0;
2745 tANI_U8 *pBody;
2746 tANI_U16 nAddIELen;
2747 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002748#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 tANI_U8 *wpsIe = NULL;
2750#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302751 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302752 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002753
2754 if (NULL == psessionEntry)
2755 {
2756 return;
2757 }
2758
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 /* check this early to avoid unncessary operation */
2760 if(NULL == psessionEntry->pLimReAssocReq)
2761 {
2762 return;
2763 }
2764 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2765 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002766 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2767 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002768
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302769 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002770
2771 caps = pMlmReassocReq->capabilityInfo;
2772 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2773 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2774#if defined(FEATURE_WLAN_WAPI)
2775 /* CR: 262463 :
2776 According to WAPI standard:
2777 7.3.1.4 Capability Information field
2778 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2779 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2780 Reassociation management frames. */
2781 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2782 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2783#endif
2784 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2785
2786 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2787
2788 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302789 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2791
2792 PopulateDot11fSSID2( pMac, &frm.SSID );
2793 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2794 &frm.SuppRates,psessionEntry);
2795
2796 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2797 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2798
2799 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2800 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2801
2802 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2803 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2804
2805 if ( psessionEntry->lim11hEnable &&
2806 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2807 {
2808#if defined WLAN_FEATURE_VOWIFI
2809 PowerCapsPopulated = TRUE;
2810
2811 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2812 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2813#endif
2814 }
2815
2816#if defined WLAN_FEATURE_VOWIFI
2817 if( pMac->rrm.rrmPEContext.rrmEnable &&
2818 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2819 {
2820 if (PowerCapsPopulated == FALSE)
2821 {
2822 PowerCapsPopulated = TRUE;
2823 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2824 }
2825 }
2826#endif
2827
2828 if ( fQosEnabled &&
2829 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2830 {
2831 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2832 }
2833
2834 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2835 &frm.ExtSuppRates, psessionEntry );
2836
2837#if defined WLAN_FEATURE_VOWIFI
2838 if( pMac->rrm.rrmPEContext.rrmEnable &&
2839 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2840 {
2841 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2842 }
2843#endif
2844
2845 // Ideally this should be enabled for 11r also. But 11r does
2846 // not follow the usual norm of using the Opaque object
2847 // for rsnie and fties. Instead we just add
2848 // the rsnie and fties at the end of the pack routine for 11r.
2849 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002850#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 //
2852 // The join request *should* contain zero or one of the WPA and RSN
2853 // IEs. The payload send along with the request is a
2854 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2855
2856 // typedef struct sSirRSNie
2857 // {
2858 // tANI_U16 length;
2859 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2860 // } tSirRSNie, *tpSirRSNie;
2861
2862 // So, we should be able to make the following two calls harmlessly,
2863 // since they do nothing if they don't find the given IE in the
2864 // bytestream with which they're provided.
2865
2866 // The net effect of this will be to faithfully transmit whatever
2867 // security IE is in the join request.
2868
2869 // *However*, if we're associating for the purpose of WPS
2870 // enrollment, and we've been configured to indicate that by
2871 // eliding the WPA or RSN IE, we just skip this:
2872 if (!psessionEntry->is11Rconnection)
2873 {
2874 if( nAddIELen && pAddIE )
2875 {
2876 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2877 }
2878 if ( NULL == wpsIe )
2879 {
2880 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2881 &frm.RSNOpaque );
2882 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2883 &frm.WPAOpaque );
2884 }
2885
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002886#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302887 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002889 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2890 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002892#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 }
2894
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002895#ifdef FEATURE_WLAN_ESE
2896 // For ESE Associations fill the ESE IEs
2897 if (psessionEntry->isESEconnection &&
2898 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002900#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002901 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002902#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002903 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002905#endif //FEATURE_WLAN_ESE
2906#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002907
2908 // include WME EDCA IE as well
2909 if ( fWmeEnabled )
2910 {
2911 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2912 {
2913 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2914 }
2915
2916 if ( fWsmEnabled &&
2917 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2918 {
2919 PopulateDot11fWMMCaps( &frm.WMMCaps );
2920 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002921#ifdef FEATURE_WLAN_ESE
2922 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 {
2924 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2925
2926 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002927 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 {
2929 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002930 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 limGetPhyMode(pMac, &phyMode, psessionEntry);
2932
2933 tsrsIE.tsid = 0;
2934 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2935 {
2936 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2937 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302938 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 {
2940 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2941 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002942 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 }
2944 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302945#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 }
2947
Jeff Johnsone7245742012-09-05 17:12:55 -07002948 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 pMac->lim.htCapabilityPresentInBeacon)
2950 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002951 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302953 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2954 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2955 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
2956 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
2957 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002958#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302959 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2960 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002961#if defined FEATURE_WLAN_ESE
2962 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302963#endif
2964 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002965 {
2966 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2967 }
2968#endif
2969
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002970#ifdef WLAN_FEATURE_11AC
2971 if ( psessionEntry->vhtCapability &&
2972 psessionEntry->vhtCapabilityPresentInBeacon)
2973 {
2974 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302975 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
2976 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302977
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002978 }
2979#endif
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302980 if (psessionEntry->is_ext_caps_present)
2981 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002982
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2984 if ( DOT11F_FAILED( nStatus ) )
2985 {
2986 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002987 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 nStatus );
2989 // We'll fall back on the worst case scenario:
2990 nPayload = sizeof( tDot11fReAssocRequest );
2991 }
2992 else if ( DOT11F_WARNED( nStatus ) )
2993 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002994 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002996 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 }
2998
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002999 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003000
3001#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003002 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
3004#endif
3005
3006#if defined WLAN_FEATURE_VOWIFI_11R
3007 if (psessionEntry->is11Rconnection)
3008 {
3009 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
3010 }
3011#endif
3012
3013 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3014 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
3015 ( void** ) &pPacket );
3016 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3017 {
3018 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003019 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003021 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 goto end;
3023 }
3024
3025 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303026 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003027
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003028#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003029 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003030#endif
3031 // Next, we fill out the buffer descriptor:
3032 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3033 SIR_MAC_MGMT_REASSOC_REQ,
3034 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3035 if ( eSIR_SUCCESS != nSirStatus )
3036 {
3037 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003038 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 nSirStatus );
3040 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3041 goto end;
3042 }
3043
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303044 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 // That done, pack the ReAssoc Request:
3046 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3047 sizeof(tSirMacMgmtHdr),
3048 nPayload, &nPayload );
3049 if ( DOT11F_FAILED( nStatus ) )
3050 {
3051 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003052 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 nStatus );
3054 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3055 goto end;
3056 }
3057 else if ( DOT11F_WARNED( nStatus ) )
3058 {
3059 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003060 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 }
3062
3063 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003064 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 nBytes, nPayload );)
3066 if( psessionEntry->assocReq != NULL )
3067 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303068 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 psessionEntry->assocReq = NULL;
3070 }
3071
3072 if( nAddIELen )
3073 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303074 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3075 pAddIE,
3076 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 nPayload += nAddIELen;
3078 }
3079
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303080 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3081 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 {
3083 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003084 }
3085 else
3086 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303088 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003091
3092 if (psessionEntry->is11Rconnection)
3093 {
3094 {
3095 int i = 0;
3096
3097 pBody = pFrame + nBytes;
3098 for (i=0; i<ft_ies_length; i++)
3099 {
3100 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
3101 pBody++;
3102 }
3103 }
3104 }
3105
3106#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003107 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3108 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 (tANI_U8 *)pFrame,
3110 (nBytes + ft_ies_length));)
3111#endif
3112
3113
3114 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3116 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 )
3118 {
3119 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3120 }
3121
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003122 if( NULL != psessionEntry->assocReq )
3123 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303124 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003125 psessionEntry->assocReq = NULL;
3126 }
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303127 if (ft_ies_length)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003128 {
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303129 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3130 if (NULL == psessionEntry->assocReq)
3131 {
3132 limLog(pMac, LOGE,
3133 FL("Unable to allocate memory for FT IEs"));
3134 psessionEntry->assocReqLen = 0;
3135 }
3136 else
3137 {
3138 /* Store the FT IEs. This is sent to csr/hdd in join cnf response.*/
3139 vos_mem_copy(psessionEntry->assocReq,
3140 pMac->ft.ftSmeContext.reassoc_ft_ies,
3141 (ft_ies_length));
3142 psessionEntry->assocReqLen = ft_ies_length;
3143 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003144 }
3145 else
3146 {
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303147 limLog(pMac, LOG1, FL("FT IEs not present"));
3148 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003149 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303150#ifdef FEATURE_WLAN_DIAG_SUPPORT
3151 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3152 eSIR_SUCCESS, eSIR_SUCCESS);
3153#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303154 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3155 psessionEntry->peSessionId,
3156 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303157 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3158 {
3159 limLog( pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3160 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3161 ( tANI_U16 ) (nBytes + ft_ies_length),
3162 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3163 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3164 limTxComplete, pFrame, limTxBdComplete, txFlag,
3165 pMac->lim.txBdToken);
3166 pMac->lim.txBdToken++;
3167 }
3168 else
3169 {
3170 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3171 HAL_TXRX_FRM_802_11_MGMT,
3172 ANI_TXDIR_TODS,
3173 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3174 limTxComplete, pFrame, txFlag );
3175 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303176 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3177 psessionEntry->peSessionId,
3178 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3180 {
3181 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003182 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003183 nSirStatus );
3184 //Pkt will be freed up by the callback
3185 goto end;
3186 }
3187
Katya Nigamccaeda72015-04-20 18:51:22 +05303188 // Enable TL cahching in case of roaming
3189 WLANTL_EnableCaching(psessionEntry->staId);
3190
Jeff Johnson295189b2012-06-20 16:38:30 -07003191end:
3192 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303193 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 psessionEntry->pLimMlmReassocReq = NULL;
3195
3196}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003197
3198void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3199 tLimMlmReassocReq *pMlmReassocReq,
3200 tpPESession psessionEntry)
3201{
3202 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3203 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
Sachin Ahuja07a43012015-01-30 17:04:38 +05303204#ifdef FEATURE_WLAN_ESE
3205 tANI_U32 val=0;
3206#endif
3207 if (pMlmReassocReq == NULL)
3208 {
3209 limLog(pMac, LOGE,
3210 FL("Invalid pMlmReassocReq"));
3211 goto end;
3212 }
Hema Aparna Medicharla43d0f7b2015-02-12 17:07:59 +05303213
3214 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3215 if ( NULL == pTmpMlmReassocReq ) goto end;
3216 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3217 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003218
3219 // Prepare and send Reassociation request frame
3220 // start reassoc timer.
Sachin Ahuja07a43012015-01-30 17:04:38 +05303221#ifdef FEATURE_WLAN_ESE
3222 /*
3223 * In case of Ese Reassociation, change the reassoc timer
3224 * value.
3225 */
3226 val = pMlmReassocReq->reassocFailureTimeout;
3227 if (psessionEntry->isESEconnection)
3228 {
3229 val = val/LIM_MAX_REASSOC_RETRY_LIMIT;
3230 }
3231 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer) !=
3232 TX_SUCCESS)
3233 {
3234 limLog(pMac, LOGP,
3235 FL("unable to deactivate Reassoc failure timer"));
3236 }
3237 val = SYS_MS_TO_TICKS(val);
3238 if (tx_timer_change(&pMac->lim.limTimers.gLimReassocFailureTimer,
3239 val, 0) != TX_SUCCESS)
3240 {
3241 limLog(pMac, LOGP,
3242 FL("unable to change Reassociation failure timer"));
3243 }
3244#endif
3245
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003246 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3247 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003248 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003249 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3250 != TX_SUCCESS)
3251 {
3252 // Could not start reassoc failure timer.
3253 // Log error
3254 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003255 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003256 // Return Reassoc confirm with
3257 // Resources Unavailable
3258 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3259 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3260 goto end;
3261 }
3262
3263 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3264 return;
3265
3266end:
3267 // Free up buffer allocated for reassocReq
3268 if (pMlmReassocReq != NULL)
3269 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303270 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003271 pMlmReassocReq = NULL;
3272 }
3273 if (pTmpMlmReassocReq != NULL)
3274 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303275 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003276 pTmpMlmReassocReq = NULL;
3277 }
3278 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3279 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3280 /* Update PE sessio Id*/
3281 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3282
3283 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3284}
3285
Jeff Johnson295189b2012-06-20 16:38:30 -07003286#endif /* WLAN_FEATURE_VOWIFI_11R */
3287
3288
3289void
3290limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3291 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3292{
3293 static tDot11fReAssocRequest frm;
3294 tANI_U16 caps;
3295 tANI_U8 *pFrame;
3296 tSirRetStatus nSirStatus;
3297 tANI_U32 nBytes, nPayload, nStatus;
3298 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3299 void *pPacket;
3300 eHalStatus halstatus;
3301 tANI_U16 nAddIELen;
3302 tANI_U8 *pAddIE;
3303 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303304 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003305#if defined WLAN_FEATURE_VOWIFI
3306 tANI_U8 PowerCapsPopulated = FALSE;
3307#endif
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303308 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003309
3310 if(NULL == psessionEntry)
3311 {
3312 return;
3313 }
3314
3315 /* check this early to avoid unncessary operation */
3316 if(NULL == psessionEntry->pLimReAssocReq)
3317 {
3318 return;
3319 }
3320 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3321 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3322
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303323 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003324
3325 caps = pMlmReassocReq->capabilityInfo;
3326 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3327 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3328#if defined(FEATURE_WLAN_WAPI)
3329 /* CR: 262463 :
3330 According to WAPI standard:
3331 7.3.1.4 Capability Information field
3332 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3333 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3334 Reassociation management frames. */
3335 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3336 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3337#endif
3338 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3339
3340 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3341
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303342 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3343 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003344
3345 PopulateDot11fSSID2( pMac, &frm.SSID );
3346 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3347 &frm.SuppRates,psessionEntry);
3348
3349 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3350 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3351
3352 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3353 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3354
3355 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3356 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3357
3358
3359 if ( psessionEntry->lim11hEnable &&
3360 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3361 {
3362#if defined WLAN_FEATURE_VOWIFI
3363 PowerCapsPopulated = TRUE;
3364 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3365 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3366#endif
3367 }
3368
3369#if defined WLAN_FEATURE_VOWIFI
3370 if( pMac->rrm.rrmPEContext.rrmEnable &&
3371 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3372 {
3373 if (PowerCapsPopulated == FALSE)
3374 {
3375 PowerCapsPopulated = TRUE;
3376 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3377 }
3378 }
3379#endif
3380
3381 if ( fQosEnabled &&
3382 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3383 {
3384 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3385 }
3386
3387 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3388 &frm.ExtSuppRates, psessionEntry );
3389
3390#if defined WLAN_FEATURE_VOWIFI
3391 if( pMac->rrm.rrmPEContext.rrmEnable &&
3392 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3393 {
3394 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3395 }
3396#endif
3397 // The join request *should* contain zero or one of the WPA and RSN
3398 // IEs. The payload send along with the request is a
3399 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3400
3401 // typedef struct sSirRSNie
3402 // {
3403 // tANI_U16 length;
3404 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3405 // } tSirRSNie, *tpSirRSNie;
3406
3407 // So, we should be able to make the following two calls harmlessly,
3408 // since they do nothing if they don't find the given IE in the
3409 // bytestream with which they're provided.
3410
3411 // The net effect of this will be to faithfully transmit whatever
3412 // security IE is in the join request.
3413
3414 // *However*, if we're associating for the purpose of WPS
3415 // enrollment, and we've been configured to indicate that by
3416 // eliding the WPA or RSN IE, we just skip this:
3417 if( nAddIELen && pAddIE )
3418 {
3419 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3420 }
3421 if ( NULL == wpsIe )
3422 {
3423 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3424 &frm.RSNOpaque );
3425 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3426 &frm.WPAOpaque );
3427#if defined(FEATURE_WLAN_WAPI)
3428 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3429 &frm.WAPIOpaque );
3430#endif // defined(FEATURE_WLAN_WAPI)
3431 }
3432
3433 // include WME EDCA IE as well
3434 if ( fWmeEnabled )
3435 {
3436 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3437 {
3438 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3439 }
3440
3441 if ( fWsmEnabled &&
3442 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3443 {
3444 PopulateDot11fWMMCaps( &frm.WMMCaps );
3445 }
3446 }
3447
Jeff Johnsone7245742012-09-05 17:12:55 -07003448 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 pMac->lim.htCapabilityPresentInBeacon)
3450 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003451 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05303453 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
3454 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
3455 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
3456 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
3457 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Jeff Johnsone7245742012-09-05 17:12:55 -07003458#ifdef WLAN_FEATURE_11AC
3459 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003460 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003461 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003462 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05303463 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
3464 psessionEntry->currentOperChannel, eSIR_FALSE );
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05303465 if (psessionEntry->is_ext_caps_present)
3466 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003467 }
3468#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003469
3470 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3471 if ( DOT11F_FAILED( nStatus ) )
3472 {
3473 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003474 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 nStatus );
3476 // We'll fall back on the worst case scenario:
3477 nPayload = sizeof( tDot11fReAssocRequest );
3478 }
3479 else if ( DOT11F_WARNED( nStatus ) )
3480 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003481 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003483 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 }
3485
3486 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3487
3488 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3489 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3490 ( void** ) &pPacket );
3491 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3492 {
3493 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003494 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003496 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 goto end;
3498 }
3499
3500 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303501 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003502
3503 // Next, we fill out the buffer descriptor:
3504 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3505 SIR_MAC_MGMT_REASSOC_REQ,
3506 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3507 if ( eSIR_SUCCESS != nSirStatus )
3508 {
3509 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003510 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 nSirStatus );
3512 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3513 goto end;
3514 }
3515
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303516 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 // That done, pack the Probe Request:
3518 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3519 sizeof(tSirMacMgmtHdr),
3520 nPayload, &nPayload );
3521 if ( DOT11F_FAILED( nStatus ) )
3522 {
3523 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003524 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 nStatus );
3526 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3527 goto end;
3528 }
3529 else if ( DOT11F_WARNED( nStatus ) )
3530 {
3531 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003532 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 }
3534
3535 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003536 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003537 nBytes );)
3538
3539 if( psessionEntry->assocReq != NULL )
3540 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303541 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 psessionEntry->assocReq = NULL;
3543 }
3544
3545 if( nAddIELen )
3546 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303547 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3548 pAddIE,
3549 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 nPayload += nAddIELen;
3551 }
3552
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303553 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3554 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 {
3556 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003557 }
3558 else
3559 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303561 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003564
3565 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3567 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 )
3569 {
3570 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3571 }
3572
Sushant Kaushike8681d22015-04-21 12:08:25 +05303573 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3574 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003575 {
3576 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3577 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303578#ifdef FEATURE_WLAN_DIAG_SUPPORT
3579 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3580 eSIR_SUCCESS, eSIR_SUCCESS);
3581#endif
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003582
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303583 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3584 psessionEntry->peSessionId,
3585 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303586
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303587 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3588 {
3589 limLog(pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3590 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3591 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3592 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3593 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3594 limTxComplete, pFrame, limTxBdComplete,
3595 txFlag, pMac->lim.txBdToken );
3596 pMac->lim.txBdToken++;
3597 }
3598 else
3599 {
3600 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3601 HAL_TXRX_FRM_802_11_MGMT,
3602 ANI_TXDIR_TODS,
3603 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3604 limTxComplete, pFrame, txFlag );
3605 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303606 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3607 psessionEntry->peSessionId,
3608 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3610 {
3611 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003612 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 nSirStatus );
3614 //Pkt will be freed up by the callback
3615 goto end;
3616 }
3617
Katya Nigamccaeda72015-04-20 18:51:22 +05303618 // enable caching
3619 WLANTL_EnableCaching(psessionEntry->staId);
3620
Jeff Johnson295189b2012-06-20 16:38:30 -07003621end:
3622 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303623 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 psessionEntry->pLimMlmReassocReq = NULL;
3625
3626} // limSendReassocReqMgmtFrame
3627
Sushant Kaushik9e923872015-04-02 17:09:31 +05303628eHalStatus limAuthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303629{
Sushant Kaushik9e923872015-04-02 17:09:31 +05303630 tANI_U32 txCompleteSuccess;
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303631 tpSirTxBdStatus pTxBdStatus;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303632
3633 if (!pData)
3634 {
3635 limLog(pMac, LOG1,
3636 FL(" pData is NULL"));
3637 return eHAL_STATUS_FAILURE;
3638 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303639
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303640 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3641 {
3642 pTxBdStatus = (tpSirTxBdStatus) pData;
3643 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
3644 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
3645 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
3646 }
3647 else
3648 {
3649 txCompleteSuccess = *((tANI_U32*) pData);
3650 limLog(pMac, LOG1,
3651 FL("txCompleteSuccess= %d"), txCompleteSuccess);
3652 }
3653
Sushant Kaushik9e923872015-04-02 17:09:31 +05303654 if(txCompleteSuccess)
3655 {
3656 pMac->authAckStatus = LIM_AUTH_ACK_RCD_SUCCESS;
3657 // 'Change' timer for future activations
3658 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
3659 }
3660 else
3661 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303662#ifdef FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05303663 limDiagEventReport(pMac, WLAN_PE_DIAG_AUTH_START_EVENT, NULL,
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303664 pMac->authAckStatus, eSIR_SUCCESS);
3665#endif
3666
Sushant Kaushik9e923872015-04-02 17:09:31 +05303667 return eHAL_STATUS_SUCCESS;
3668}
3669
Jeff Johnson295189b2012-06-20 16:38:30 -07003670/**
3671 * \brief Send an Authentication frame
3672 *
3673 *
3674 * \param pMac Pointer to Global MAC structure
3675 *
3676 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3677 * to be sent
3678 *
3679 * \param peerMacAddr MAC address of the peer entity to which Authentication
3680 * frame is destined
3681 *
3682 * \param wepBit Indicates whether wep bit to be set in FC while sending
3683 * Authentication frame3
3684 *
3685 *
3686 * This function is called by limProcessMlmMessages(). Authentication frame
3687 * is formatted and sent when this function is called.
3688 *
3689 *
3690 */
3691
3692void
3693limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3694 tpSirMacAuthFrameBody pAuthFrameBody,
3695 tSirMacAddr peerMacAddr,
3696 tANI_U8 wepBit,
Sushant Kaushik9e923872015-04-02 17:09:31 +05303697 tpPESession psessionEntry,
3698 tAniBool waitForAck
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 )
3700{
3701 tANI_U8 *pFrame, *pBody;
3702 tANI_U32 frameLen = 0, bodyLen = 0;
3703 tpSirMacMgmtHdr pMacHdr;
3704 tANI_U16 i;
3705 void *pPacket;
3706 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303707 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003708
3709 if(NULL == psessionEntry)
3710 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303711 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 return;
3713 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303714
3715 limLog(pMac, LOG1,
3716 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3717 pAuthFrameBody->authTransactionSeqNumber,
3718 pAuthFrameBody->authStatusCode,
3719 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3720 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 if (wepBit == LIM_WEP_IN_FC)
3722 {
3723 /// Auth frame3 to be sent with encrypted framebody
3724 /**
3725 * Allocate buffer for Authenticaton frame of size equal
3726 * to management frame header length plus 2 bytes each for
3727 * auth algorithm number, transaction number, status code,
3728 * 128 bytes for challenge text and 4 bytes each for
3729 * IV & ICV.
3730 */
3731
3732 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3733
3734 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3735 } // if (wepBit == LIM_WEP_IN_FC)
3736 else
3737 {
3738 switch (pAuthFrameBody->authTransactionSeqNumber)
3739 {
3740 case SIR_MAC_AUTH_FRAME_1:
3741 /**
3742 * Allocate buffer for Authenticaton frame of size
3743 * equal to management frame header length plus 2 bytes
3744 * each for auth algorithm number, transaction number
3745 * and status code.
3746 */
3747
3748 frameLen = sizeof(tSirMacMgmtHdr) +
3749 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3750 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3751
3752#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003753 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3754 {
3755 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003757 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003758 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003759 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003761 else
3762 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303763 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3764 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003765 frameLen += (2+SIR_MDIE_SIZE);
3766 }
3767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003768#endif
3769 break;
3770
3771 case SIR_MAC_AUTH_FRAME_2:
3772 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3773 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3774 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3775 {
3776 /**
3777 * Allocate buffer for Authenticaton frame of size
3778 * equal to management frame header length plus
3779 * 2 bytes each for auth algorithm number,
3780 * transaction number and status code.
3781 */
3782
3783 frameLen = sizeof(tSirMacMgmtHdr) +
3784 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3785 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3786 }
3787 else
3788 {
3789 // Shared Key algorithm with challenge text
3790 // to be sent
3791 /**
3792 * Allocate buffer for Authenticaton frame of size
3793 * equal to management frame header length plus
3794 * 2 bytes each for auth algorithm number,
3795 * transaction number, status code and 128 bytes
3796 * for challenge text.
3797 */
3798
3799 frameLen = sizeof(tSirMacMgmtHdr) +
3800 sizeof(tSirMacAuthFrame);
3801 bodyLen = sizeof(tSirMacAuthFrameBody);
3802 }
3803
3804 break;
3805
3806 case SIR_MAC_AUTH_FRAME_3:
3807 /// Auth frame3 to be sent without encrypted framebody
3808 /**
3809 * Allocate buffer for Authenticaton frame of size equal
3810 * to management frame header length plus 2 bytes each
3811 * for auth algorithm number, transaction number and
3812 * status code.
3813 */
3814
3815 frameLen = sizeof(tSirMacMgmtHdr) +
3816 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3817 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3818
3819 break;
3820
3821 case SIR_MAC_AUTH_FRAME_4:
3822 /**
3823 * Allocate buffer for Authenticaton frame of size equal
3824 * to management frame header length plus 2 bytes each
3825 * for auth algorithm number, transaction number and
3826 * status code.
3827 */
3828
3829 frameLen = sizeof(tSirMacMgmtHdr) +
3830 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3831 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3832
3833 break;
3834 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3835 } // end if (wepBit == LIM_WEP_IN_FC)
3836
3837
3838 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3839
3840 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3841 {
3842 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003843 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003844
3845 return;
3846 }
3847
3848 for (i = 0; i < frameLen; i++)
3849 pFrame[i] = 0;
3850
3851 // Prepare BD
3852 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3853 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3854 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303855 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3856 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3858 return;
3859 }
3860
3861 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3862 pMacHdr->fc.wep = wepBit;
3863
3864 // Prepare BSSId
3865 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3866 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303867 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3868 (tANI_U8 *) psessionEntry->bssId,
3869 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 }
3871
3872 /// Prepare Authentication frame body
3873 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3874
3875 if (wepBit == LIM_WEP_IN_FC)
3876 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303877 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003878
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303879 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303880 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303882 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303883 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003884
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 }
3886 else
3887 {
3888 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3889 pBody += sizeof(tANI_U16);
3890 bodyLen -= sizeof(tANI_U16);
3891
3892 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3893 pBody += sizeof(tANI_U16);
3894 bodyLen -= sizeof(tANI_U16);
3895
3896 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3897 pBody += sizeof(tANI_U16);
3898 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003899 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3900 sizeof (pAuthFrameBody->length) +
3901 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303902 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003903
3904#if defined WLAN_FEATURE_VOWIFI_11R
3905 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3906 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3907 {
3908
3909 {
3910 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3912 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003913#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003914 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3915 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 (tANI_U8 *)pBody,
3917 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003918#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003919 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3920 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003921 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3922 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003923 }
3924 }
3925 else
3926 {
3927 /* MDID attr is 54*/
3928 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003930 *pBody = SIR_MDIE_SIZE;
3931 pBody++;
3932 for(i=0;i<SIR_MDIE_SIZE;i++)
3933 {
3934 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3935 pBody++;
3936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 }
3938 }
3939 }
3940#endif
3941
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303942 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303943 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 pAuthFrameBody->authTransactionSeqNumber,
3945 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303946 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303947 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 }
3949 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3950
3951 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3953 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003954#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303955 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003956 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3957#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 )
3959 {
3960 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3961 }
3962
Sushant Kaushike8681d22015-04-21 12:08:25 +05303963 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3964 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003965 {
3966 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3967 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003968
Sushant Kaushik9e923872015-04-02 17:09:31 +05303969 limLog( pMac, LOG1,
3970 FL("Sending Auth Frame over WQ5 with waitForAck %d to "MAC_ADDRESS_STR
3971 " From " MAC_ADDRESS_STR), waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303972 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3973
3974 txFlag |= HAL_USE_FW_IN_TX_PATH;
3975
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303976 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3977 psessionEntry->peSessionId,
3978 pMacHdr->fc.subType));
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303979
3980 if( ( psessionEntry->is11Gonly == true ) &&
3981 ( !IS_BROADCAST_MAC(peerMacAddr) ) ){
3982 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3983 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303984 if(eSIR_TRUE == waitForAck)
3985 {
3986 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
Sushant Kaushik0b343422015-05-25 17:15:55 +05303987 limLog(pMac, LOG1, FL("Auth frame - txBdToken %u"),
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303988 pMac->lim.txBdToken);
Sushant Kaushik9e923872015-04-02 17:09:31 +05303989 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3990 ( tANI_U16 ) frameLen,
3991 HAL_TXRX_FRM_802_11_MGMT,
3992 ANI_TXDIR_TODS,
3993 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303994 limTxComplete, pFrame, limAuthTxCompleteCnf, txFlag,
3995 pMac->lim.txBdToken);
3996 pMac->lim.txBdToken++;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303997 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3998 psessionEntry->peSessionId,
3999 halstatus));
4000 if (!HAL_STATUS_SUCCESS(halstatus))
4001 {
4002 limLog( pMac, LOGE,
4003 FL("Could not send Auth frame, retCode=%X "),
4004 halstatus );
4005 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
4006 //Pkt will be freed up by the callback
4007 }
4008 }
4009 else
4010 {
4011 /// Queue Authentication frame in high priority WQ
4012 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 HAL_TXRX_FRM_802_11_MGMT,
4014 ANI_TXDIR_TODS,
4015 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4016 limTxComplete, pFrame, txFlag );
Sushant Kaushik9e923872015-04-02 17:09:31 +05304017 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304018 psessionEntry->peSessionId,
4019 halstatus));
Sushant Kaushik9e923872015-04-02 17:09:31 +05304020 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4021 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004023 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 halstatus);
4025
4026 //Pkt will be freed up by the callback
Sushant Kaushik9e923872015-04-02 17:09:31 +05304027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 }
4029
4030 return;
4031} /*** end limSendAuthMgmtFrame() ***/
4032
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004033eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
4034{
4035 tANI_U16 aid;
4036 tpDphHashNode pStaDs;
4037 tLimMlmDeauthReq *pMlmDeauthReq;
4038 tLimMlmDeauthCnf mlmDeauthCnf;
4039 tpPESession psessionEntry;
4040
4041 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
4042 if (pMlmDeauthReq)
4043 {
4044 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
4045 {
4046 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4047 }
4048
4049 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
4050 {
4051
4052 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004053 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004054 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4055 goto end;
4056 }
4057
4058 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4059 if (pStaDs == NULL)
4060 {
4061 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4062 goto end;
4063 }
4064
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004065 /// Receive path cleanup with dummy packet
4066 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304067
4068#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304069 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304070 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304071 PELOGE(limLog(pMac, LOG1,
4072 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304073#ifdef FEATURE_WLAN_ESE
4074 " isESE %d"
4075#endif
4076#ifdef FEATURE_WLAN_LFR
4077 " isLFR %d"
4078#endif
4079 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304080 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304081#ifdef FEATURE_WLAN_ESE
4082 psessionEntry->isESEconnection,
4083#endif
4084#ifdef FEATURE_WLAN_LFR
4085 psessionEntry->isFastRoamIniFeatureEnabled,
4086#endif
4087 psessionEntry->is11Rconnection,
4088 pMlmDeauthReq->reasonCode,
4089 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304090
4091 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304092 }
4093#endif
4094
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004095 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304096 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004097 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
4098 }
4099 return eHAL_STATUS_SUCCESS;
4100end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304101 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004102 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
4103 sizeof(tSirMacAddr));
4104 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
4105 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
4106 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
4107
4108 // Free up buffer allocated
4109 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304110 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004111
4112 limPostSmeMessage(pMac,
4113 LIM_MLM_DEAUTH_CNF,
4114 (tANI_U32 *) &mlmDeauthCnf);
4115 return eHAL_STATUS_SUCCESS;
4116}
4117
4118eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
4119{
4120 tANI_U16 aid;
4121 tpDphHashNode pStaDs;
4122 tLimMlmDisassocCnf mlmDisassocCnf;
4123 tpPESession psessionEntry;
4124 tLimMlmDisassocReq *pMlmDisassocReq;
4125
4126 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
4127 if (pMlmDisassocReq)
4128 {
4129 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
4130 {
4131 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4132 }
4133
4134 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
4135 {
4136
4137 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004138 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004139 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4140 goto end;
4141 }
4142
4143 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4144 if (pStaDs == NULL)
4145 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304146 limLog(pMac, LOGE,
4147 FL("StaDs Null"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004148 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4149 goto end;
4150 }
4151
4152 /// Receive path cleanup with dummy packet
4153 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
4154 {
4155 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304156 limLog(pMac, LOGE,
4157 FL("CleanupRxPath error"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004158 goto end;
4159 }
4160
4161#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004162 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05304163 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004164 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004165 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304166 PELOGE(limLog(pMac, LOG1,
4167 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004168#ifdef FEATURE_WLAN_ESE
4169 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004170#endif
4171#ifdef FEATURE_WLAN_LFR
4172 " isLFR %d"
4173#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004174 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304175 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004176#ifdef FEATURE_WLAN_ESE
4177 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004178#endif
4179#ifdef FEATURE_WLAN_LFR
4180 psessionEntry->isFastRoamIniFeatureEnabled,
4181#endif
4182 psessionEntry->is11Rconnection,
4183 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304184 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004185 }
4186#endif
4187
4188 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304189 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004190 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4191 return eHAL_STATUS_SUCCESS;
4192 }
4193 else
4194 {
4195 return eHAL_STATUS_SUCCESS;
4196 }
4197end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304198 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004199 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
4200 sizeof(tSirMacAddr));
4201 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
4202 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
4203
4204 /* Update PE session ID*/
4205 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
4206
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004207 if(pMlmDisassocReq != NULL)
4208 {
4209 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304210 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004211 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4212 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004213
4214 limPostSmeMessage(pMac,
4215 LIM_MLM_DISASSOC_CNF,
4216 (tANI_U32 *) &mlmDisassocCnf);
4217 return eHAL_STATUS_SUCCESS;
4218}
4219
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304220eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004221{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304222 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4223 {
4224 tpSirTxBdStatus pTxBdStatus;
4225 pTxBdStatus = (tpSirTxBdStatus) pData;
4226 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4227 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4228 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004229 return limSendDisassocCnf(pMac);
4230}
4231
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304232eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004233{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304234 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4235 {
4236 tpSirTxBdStatus pTxBdStatus;
4237 pTxBdStatus = (tpSirTxBdStatus) pData;
4238 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4239 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4240 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004241 return limSendDeauthCnf(pMac);
4242}
4243
Jeff Johnson295189b2012-06-20 16:38:30 -07004244/**
4245 * \brief This function is called to send Disassociate frame.
4246 *
4247 *
4248 * \param pMac Pointer to Global MAC structure
4249 *
4250 * \param nReason Indicates the reason that need to be sent in
4251 * Disassociation frame
4252 *
4253 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
4254 * sent
4255 *
4256 *
4257 */
4258
4259void
4260limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4261 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004262 tSirMacAddr peer,
4263 tpPESession psessionEntry,
4264 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004265{
4266 tDot11fDisassociation frm;
4267 tANI_U8 *pFrame;
4268 tSirRetStatus nSirStatus;
4269 tpSirMacMgmtHdr pMacHdr;
4270 tANI_U32 nBytes, nPayload, nStatus;
4271 void *pPacket;
4272 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304273 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004274 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 if(NULL == psessionEntry)
4276 {
4277 return;
4278 }
4279
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304280 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004281
4282 frm.Reason.code = nReason;
4283
4284 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4285 if ( DOT11F_FAILED( nStatus ) )
4286 {
4287 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004288 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 nStatus );
4290 // We'll fall back on the worst case scenario:
4291 nPayload = sizeof( tDot11fDisassociation );
4292 }
4293 else if ( DOT11F_WARNED( nStatus ) )
4294 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004295 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004297 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 }
4299
4300 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4301
4302 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4303 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4304 ( void** ) &pPacket );
4305 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4306 {
4307 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004308 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 return;
4310 }
4311
4312 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304313 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004314
4315 // Next, we fill out the buffer descriptor:
4316 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4317 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4318 if ( eSIR_SUCCESS != nSirStatus )
4319 {
4320 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004321 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 nSirStatus );
4323 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4324 ( void* ) pFrame, ( void* ) pPacket );
4325 return; // just allocated...
4326 }
4327
4328 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4329
4330 // Prepare the BSSID
4331 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4332
Chet Lanctot186b5732013-03-18 10:26:30 -07004333#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004334 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004335#endif
4336
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4338 sizeof(tSirMacMgmtHdr),
4339 nPayload, &nPayload );
4340 if ( DOT11F_FAILED( nStatus ) )
4341 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004342 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 nStatus );
4344 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4345 ( void* ) pFrame, ( void* ) pPacket );
4346 return; // allocated!
4347 }
4348 else if ( DOT11F_WARNED( nStatus ) )
4349 {
4350 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004351 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 }
4353
Abhishek Singhcd09b562013-12-24 16:02:20 +05304354 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4355 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4356 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4357 MAC_ADDR_ARRAY(pMacHdr->da),
4358 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004359
4360 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4362 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 )
4364 {
4365 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4366 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004367
Sushant Kaushike8681d22015-04-21 12:08:25 +05304368 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004369
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304370 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4371 {
4372 /* This frame will be sent on air by firmware,
4373 which will ensure that this frame goes out
4374 even though DEL_STA is sent immediately */
4375 /* Without this for DEL_STA command there is
4376 risk of flushing frame in BTQM queue without
4377 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304378 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4379 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4380 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304381 txFlag |= HAL_USE_FW_IN_TX_PATH;
4382 }
4383
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004384 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304386 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4387 psessionEntry->peSessionId,
4388 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004389 // Queue Disassociation frame in high priority WQ
4390 /* get the duration from the request */
4391 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4392 HAL_TXRX_FRM_802_11_MGMT,
4393 ANI_TXDIR_TODS,
4394 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4395 limTxComplete, pFrame, limDisassocTxCompleteCnf,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304396 txFlag,
4397 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304398 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4399 psessionEntry->peSessionId,
4400 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004401 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004402
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004403 if (tx_timer_change(
4404 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4405 != TX_SUCCESS)
4406 {
4407 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004408 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004409 return;
4410 }
4411 else if(TX_SUCCESS != tx_timer_activate(
4412 &pMac->lim.limTimers.gLimDisassocAckTimer))
4413 {
4414 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004415 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004416 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4417 return;
4418 }
4419 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004420 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004421 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304422 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4423 psessionEntry->peSessionId,
4424 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004425 // Queue Disassociation frame in high priority WQ
4426 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4427 HAL_TXRX_FRM_802_11_MGMT,
4428 ANI_TXDIR_TODS,
4429 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4430 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304431 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4432 psessionEntry->peSessionId,
4433 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004434 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4435 {
4436 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004437 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004438 nSirStatus );
4439 //Pkt will be freed up by the callback
4440 return;
4441 }
4442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004443} // End limSendDisassocMgmtFrame.
4444
4445/**
4446 * \brief This function is called to send a Deauthenticate frame
4447 *
4448 *
4449 * \param pMac Pointer to global MAC structure
4450 *
4451 * \param nReason Indicates the reason that need to be sent in the
4452 * Deauthenticate frame
4453 *
4454 * \param peeer address of the STA to which the frame is to be sent
4455 *
4456 *
4457 */
4458
4459void
4460limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4461 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004462 tSirMacAddr peer,
4463 tpPESession psessionEntry,
4464 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004465{
4466 tDot11fDeAuth frm;
4467 tANI_U8 *pFrame;
4468 tSirRetStatus nSirStatus;
4469 tpSirMacMgmtHdr pMacHdr;
4470 tANI_U32 nBytes, nPayload, nStatus;
4471 void *pPacket;
4472 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304473 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004474 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004475#ifdef FEATURE_WLAN_TDLS
4476 tANI_U16 aid;
4477 tpDphHashNode pStaDs;
4478#endif
4479
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 if(NULL == psessionEntry)
4481 {
4482 return;
4483 }
4484
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304485 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004486
4487 frm.Reason.code = nReason;
4488
4489 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4490 if ( DOT11F_FAILED( nStatus ) )
4491 {
4492 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004493 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 nStatus );
4495 // We'll fall back on the worst case scenario:
4496 nPayload = sizeof( tDot11fDeAuth );
4497 }
4498 else if ( DOT11F_WARNED( nStatus ) )
4499 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004500 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004502 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 }
4504
4505 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4506
4507 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4508 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4509 ( void** ) &pPacket );
4510 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4511 {
4512 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004513 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 return;
4515 }
4516
4517 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304518 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004519
4520 // Next, we fill out the buffer descriptor:
4521 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4522 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4523 if ( eSIR_SUCCESS != nSirStatus )
4524 {
4525 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004526 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 nSirStatus );
4528 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4529 ( void* ) pFrame, ( void* ) pPacket );
4530 return; // just allocated...
4531 }
4532
4533 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4534
4535 // Prepare the BSSID
4536 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4537
Chet Lanctot186b5732013-03-18 10:26:30 -07004538#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004539 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004540#endif
4541
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4543 sizeof(tSirMacMgmtHdr),
4544 nPayload, &nPayload );
4545 if ( DOT11F_FAILED( nStatus ) )
4546 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004547 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 nStatus );
4549 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4550 ( void* ) pFrame, ( void* ) pPacket );
4551 return;
4552 }
4553 else if ( DOT11F_WARNED( nStatus ) )
4554 {
4555 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004556 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304558 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4559 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4560 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4561 MAC_ADDR_ARRAY(pMacHdr->da),
4562 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004563
4564 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4566 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 )
4568 {
4569 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4570 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004571
Sushant Kaushike8681d22015-04-21 12:08:25 +05304572 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004573
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304574 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4575 {
4576 /* This frame will be sent on air by firmware,
4577 which will ensure that this frame goes out
4578 even though DEL_STA is sent immediately */
4579 /* Without this for DEL_STA command there is
4580 risk of flushing frame in BTQM queue without
4581 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304582 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4583 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4584 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304585 txFlag |= HAL_USE_FW_IN_TX_PATH;
4586 }
4587
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004588#ifdef FEATURE_WLAN_TDLS
4589 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4590#endif
4591
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004592 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304594 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4595 psessionEntry->peSessionId,
4596 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004597 // Queue Disassociation frame in high priority WQ
4598 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4599 HAL_TXRX_FRM_802_11_MGMT,
4600 ANI_TXDIR_TODS,
4601 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304602 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag,
4603 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304604 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4605 psessionEntry->peSessionId,
4606 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304607 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004608 {
4609 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304610 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004611 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004612 //Pkt will be freed up by the callback limTxComplete
4613
4614 /*Call limProcessDeauthAckTimeout which will send
4615 * DeauthCnf for this frame
4616 */
4617 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004618 return;
4619 }
4620
4621 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4622
4623 if (tx_timer_change(
4624 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4625 != TX_SUCCESS)
4626 {
4627 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004628 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004629 return;
4630 }
4631 else if(TX_SUCCESS != tx_timer_activate(
4632 &pMac->lim.limTimers.gLimDeauthAckTimer))
4633 {
4634 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004635 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004636 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4637 return;
4638 }
4639 }
4640 else
4641 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304642 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4643 psessionEntry->peSessionId,
4644 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004645#ifdef FEATURE_WLAN_TDLS
4646 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4647 {
4648 // Queue Disassociation frame in high priority WQ
4649 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004650 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004651 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004652 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4653 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004654 }
4655 else
4656 {
4657#endif
4658 // Queue Disassociation frame in high priority WQ
4659 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4660 HAL_TXRX_FRM_802_11_MGMT,
4661 ANI_TXDIR_TODS,
4662 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4663 limTxComplete, pFrame, txFlag );
4664#ifdef FEATURE_WLAN_TDLS
4665 }
4666#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304667 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4668 psessionEntry->peSessionId,
4669 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004670 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4671 {
4672 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004673 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004674 nSirStatus );
4675 //Pkt will be freed up by the callback
4676 return;
4677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 }
4679
4680} // End limSendDeauthMgmtFrame.
4681
4682
4683#ifdef ANI_SUPPORT_11H
4684/**
4685 * \brief Send a Measurement Report Action frame
4686 *
4687 *
4688 * \param pMac Pointer to the global MAC structure
4689 *
4690 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4691 *
4692 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4693 *
4694 *
4695 */
4696
4697tSirRetStatus
4698limSendMeasReportFrame(tpAniSirGlobal pMac,
4699 tpSirMacMeasReqActionFrame pMeasReqFrame,
4700 tSirMacAddr peer)
4701{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304702 tDot11fMeasurementReport frm;
4703 tANI_U8 *pFrame;
4704 tSirRetStatus nSirStatus;
4705 tpSirMacMgmtHdr pMacHdr;
4706 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4707 void *pPacket;
4708 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004709
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304710 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004711
4712 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4713 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4714 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4715
4716 switch ( pMeasReqFrame->measReqIE.measType )
4717 {
4718 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4719 nSirStatus =
4720 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4721 &frm.MeasurementReport );
4722 break;
4723 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4724 nSirStatus =
4725 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4726 &frm.MeasurementReport );
4727 break;
4728 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4729 nSirStatus =
4730 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4731 &frm.MeasurementReport );
4732 break;
4733 default:
4734 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004735 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 pMeasReqFrame->measReqIE.measType );
4737 return eSIR_FAILURE;
4738 }
4739
4740 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4741
4742 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4743 if ( DOT11F_FAILED( nStatus ) )
4744 {
4745 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004746 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 nStatus );
4748 // We'll fall back on the worst case scenario:
4749 nPayload = sizeof( tDot11fMeasurementReport );
4750 }
4751 else if ( DOT11F_WARNED( nStatus ) )
4752 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004753 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004755 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 }
4757
4758 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4759
4760 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4761 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4762 {
4763 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004764 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 return eSIR_FAILURE;
4766 }
4767
4768 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304769 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004770
4771 // Next, we fill out the buffer descriptor:
4772 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4773 SIR_MAC_MGMT_ACTION, peer);
4774 if ( eSIR_SUCCESS != nSirStatus )
4775 {
4776 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004777 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 nSirStatus );
4779 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4780 return eSIR_FAILURE; // just allocated...
4781 }
4782
4783 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4784
4785 nCfg = 6;
4786 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4787 if ( eSIR_SUCCESS != nSirStatus )
4788 {
4789 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004790 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 nSirStatus );
4792 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4793 return eSIR_FAILURE; // just allocated...
4794 }
4795
Chet Lanctot186b5732013-03-18 10:26:30 -07004796#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004797 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004798#endif
4799
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4801 sizeof(tSirMacMgmtHdr),
4802 nPayload, &nPayload );
4803 if ( DOT11F_FAILED( nStatus ) )
4804 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004805 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 nStatus );
4807 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4808 return eSIR_FAILURE; // allocated!
4809 }
4810 else if ( DOT11F_WARNED( nStatus ) )
4811 {
4812 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004813 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 }
4815
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304816 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4817 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4818 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4820 HAL_TXRX_FRM_802_11_MGMT,
4821 ANI_TXDIR_TODS,
4822 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4823 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304824 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4825 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4826 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4828 {
4829 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004830 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 nSirStatus );
4832 //Pkt will be freed up by the callback
4833 return eSIR_FAILURE; // just allocated...
4834 }
4835
4836 return eSIR_SUCCESS;
4837
4838} // End limSendMeasReportFrame.
4839
4840
4841/**
4842 * \brief Send a TPC Request Action frame
4843 *
4844 *
4845 * \param pMac Pointer to the global MAC datastructure
4846 *
4847 * \param peer MAC address to which the frame should be sent
4848 *
4849 *
4850 */
4851
4852void
4853limSendTpcRequestFrame(tpAniSirGlobal pMac,
4854 tSirMacAddr peer)
4855{
4856 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304857 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 tSirRetStatus nSirStatus;
4859 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304860 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4861 void *pPacket;
4862 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004863
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304864 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004865
4866 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4867 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4868 frm.DialogToken.token = 1;
4869 frm.TPCRequest.present = 1;
4870
4871 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4872 if ( DOT11F_FAILED( nStatus ) )
4873 {
4874 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004875 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 nStatus );
4877 // We'll fall back on the worst case scenario:
4878 nPayload = sizeof( tDot11fTPCRequest );
4879 }
4880 else if ( DOT11F_WARNED( nStatus ) )
4881 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004882 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004884 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 }
4886
4887 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4888
4889 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4890 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4891 {
4892 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004893 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 return;
4895 }
4896
4897 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304898 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004899
4900 // Next, we fill out the buffer descriptor:
4901 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4902 SIR_MAC_MGMT_ACTION, peer);
4903 if ( eSIR_SUCCESS != nSirStatus )
4904 {
4905 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004906 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 nSirStatus );
4908 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4909 return; // just allocated...
4910 }
4911
4912 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4913
4914 nCfg = 6;
4915 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4916 if ( eSIR_SUCCESS != nSirStatus )
4917 {
4918 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004919 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 nSirStatus );
4921 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4922 return; // just allocated...
4923 }
4924
Chet Lanctot186b5732013-03-18 10:26:30 -07004925#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004926 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004927#endif
4928
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4930 sizeof(tSirMacMgmtHdr),
4931 nPayload, &nPayload );
4932 if ( DOT11F_FAILED( nStatus ) )
4933 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004934 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 nStatus );
4936 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4937 return; // allocated!
4938 }
4939 else if ( DOT11F_WARNED( nStatus ) )
4940 {
4941 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004942 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 }
4944
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304945 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4946 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4947 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4949 HAL_TXRX_FRM_802_11_MGMT,
4950 ANI_TXDIR_TODS,
4951 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4952 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304953 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4954 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4955 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4957 {
4958 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004959 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 nSirStatus );
4961 //Pkt will be freed up by the callback
4962 return;
4963 }
4964
4965} // End limSendTpcRequestFrame.
4966
4967
4968/**
4969 * \brief Send a TPC Report Action frame
4970 *
4971 *
4972 * \param pMac Pointer to the global MAC datastructure
4973 *
4974 * \param pTpcReqFrame Pointer to the received TPC Request
4975 *
4976 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4977 *
4978 *
4979 */
4980
4981tSirRetStatus
4982limSendTpcReportFrame(tpAniSirGlobal pMac,
4983 tpSirMacTpcReqActionFrame pTpcReqFrame,
4984 tSirMacAddr peer)
4985{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304986 tDot11fTPCReport frm;
4987 tANI_U8 *pFrame;
4988 tSirRetStatus nSirStatus;
4989 tpSirMacMgmtHdr pMacHdr;
4990 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4991 void *pPacket;
4992 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004993
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304994 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004995
4996 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4997 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4998 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4999
5000 // FramesToDo: On the Gen4_TVM branch, there was a comment:
5001 // "misplaced this function, need to replace:
5002 // txPower = halGetRateToPwrValue(pMac, staid,
5003 // pMac->lim.gLimCurrentChannelId, 0);
5004 frm.TPCReport.tx_power = 0;
5005 frm.TPCReport.link_margin = 0;
5006 frm.TPCReport.present = 1;
5007
5008 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
5009 if ( DOT11F_FAILED( nStatus ) )
5010 {
5011 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005012 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 nStatus );
5014 // We'll fall back on the worst case scenario:
5015 nPayload = sizeof( tDot11fTPCReport );
5016 }
5017 else if ( DOT11F_WARNED( nStatus ) )
5018 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005019 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005021 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 }
5023
5024 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5025
5026 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5027 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5028 {
5029 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005030 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 return eSIR_FAILURE;
5032 }
5033
5034 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305035 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005036
5037 // Next, we fill out the buffer descriptor:
5038 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5039 SIR_MAC_MGMT_ACTION, peer);
5040 if ( eSIR_SUCCESS != nSirStatus )
5041 {
5042 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005043 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 nSirStatus );
5045 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5046 return eSIR_FAILURE; // just allocated...
5047 }
5048
5049 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5050
5051 nCfg = 6;
5052 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5053 if ( eSIR_SUCCESS != nSirStatus )
5054 {
5055 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005056 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 nSirStatus );
5058 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5059 return eSIR_FAILURE; // just allocated...
5060 }
5061
Chet Lanctot186b5732013-03-18 10:26:30 -07005062#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005063 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005064#endif
5065
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
5067 sizeof(tSirMacMgmtHdr),
5068 nPayload, &nPayload );
5069 if ( DOT11F_FAILED( nStatus ) )
5070 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005071 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 nStatus );
5073 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5074 return eSIR_FAILURE; // allocated!
5075 }
5076 else if ( DOT11F_WARNED( nStatus ) )
5077 {
5078 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005079 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 }
5081
5082
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305083 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5084 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5085 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5087 HAL_TXRX_FRM_802_11_MGMT,
5088 ANI_TXDIR_TODS,
5089 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5090 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305091 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5092 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5093 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5095 {
5096 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005097 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 nSirStatus );
5099 //Pkt will be freed up by the callback
5100 return eSIR_FAILURE; // just allocated...
5101 }
5102
5103 return eSIR_SUCCESS;
5104
5105} // End limSendTpcReportFrame.
5106#endif //ANI_SUPPORT_11H
5107
5108
Jeff Johnson295189b2012-06-20 16:38:30 -07005109/**
5110 * \brief Send a Channel Switch Announcement
5111 *
5112 *
5113 * \param pMac Pointer to the global MAC datastructure
5114 *
5115 * \param peer MAC address to which this frame will be sent
5116 *
5117 * \param nMode
5118 *
5119 * \param nNewChannel
5120 *
5121 * \param nCount
5122 *
5123 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5124 *
5125 *
5126 */
5127
5128tSirRetStatus
5129limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5130 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07005131 tANI_U8 nMode,
5132 tANI_U8 nNewChannel,
5133 tANI_U8 nCount,
5134 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07005135{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305136 tDot11fChannelSwitch frm;
5137 tANI_U8 *pFrame;
5138 tSirRetStatus nSirStatus;
5139 tpSirMacMgmtHdr pMacHdr;
5140 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5141 void *pPacket;
5142 eHalStatus halstatus;
5143 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005144
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305145 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005146
5147 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5148 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5149 frm.ChanSwitchAnn.switchMode = nMode;
5150 frm.ChanSwitchAnn.newChannel = nNewChannel;
5151 frm.ChanSwitchAnn.switchCount = nCount;
5152 frm.ChanSwitchAnn.present = 1;
5153
5154 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5155 if ( DOT11F_FAILED( nStatus ) )
5156 {
5157 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005158 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 nStatus );
5160 // We'll fall back on the worst case scenario:
5161 nPayload = sizeof( tDot11fChannelSwitch );
5162 }
5163 else if ( DOT11F_WARNED( nStatus ) )
5164 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005165 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005167 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005168 }
5169
5170 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5171
5172 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5173 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5174 {
5175 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005176 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005177 return eSIR_FAILURE;
5178 }
5179
5180 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305181 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005182
5183 // Next, we fill out the buffer descriptor:
5184 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07005185 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5186 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305187 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5188 (tANI_U8 *) psessionEntry->bssId,
5189 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 if ( eSIR_SUCCESS != nSirStatus )
5191 {
5192 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005193 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005194 nSirStatus );
5195 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5196 return eSIR_FAILURE; // just allocated...
5197 }
5198
Jeff Johnsone7245742012-09-05 17:12:55 -07005199#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5201
5202 nCfg = 6;
5203 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5204 if ( eSIR_SUCCESS != nSirStatus )
5205 {
5206 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005207 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 nSirStatus );
5209 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5210 return eSIR_FAILURE; // just allocated...
5211 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005212#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005213
5214#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005215 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005216#endif
5217
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5219 sizeof(tSirMacMgmtHdr),
5220 nPayload, &nPayload );
5221 if ( DOT11F_FAILED( nStatus ) )
5222 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005223 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 nStatus );
5225 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5226 return eSIR_FAILURE; // allocated!
5227 }
5228 else if ( DOT11F_WARNED( nStatus ) )
5229 {
5230 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005231 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005232 }
5233
Jeff Johnsone7245742012-09-05 17:12:55 -07005234 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07005235 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5236 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07005237 )
5238 {
5239 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5240 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305241
5242 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5243 psessionEntry->peSessionId,
5244 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5246 HAL_TXRX_FRM_802_11_MGMT,
5247 ANI_TXDIR_TODS,
5248 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07005249 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305250 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5251 psessionEntry->peSessionId,
5252 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005253 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5254 {
5255 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005256 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 nSirStatus );
5258 //Pkt will be freed up by the callback
5259 return eSIR_FAILURE;
5260 }
5261
5262 return eSIR_SUCCESS;
5263
5264} // End limSendChannelSwitchMgmtFrame.
5265
Jeff Johnson295189b2012-06-20 16:38:30 -07005266
5267
Mohit Khanna4a70d262012-09-11 16:30:12 -07005268#ifdef WLAN_FEATURE_11AC
5269tSirRetStatus
5270limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5271 tSirMacAddr peer,
5272 tANI_U8 nMode,
5273 tpPESession psessionEntry )
5274{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305275 tDot11fOperatingMode frm;
5276 tANI_U8 *pFrame;
5277 tSirRetStatus nSirStatus;
5278 tpSirMacMgmtHdr pMacHdr;
5279 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5280 void *pPacket;
5281 eHalStatus halstatus;
5282 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005283
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305284 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005285
5286 frm.Category.category = SIR_MAC_ACTION_VHT;
5287 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5288 frm.OperatingMode.chanWidth = nMode;
5289 frm.OperatingMode.rxNSS = 0;
5290 frm.OperatingMode.rxNSSType = 0;
5291
5292 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5293 if ( DOT11F_FAILED( nStatus ) )
5294 {
5295 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005296 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005297 nStatus );
5298 // We'll fall back on the worst case scenario:
5299 nPayload = sizeof( tDot11fOperatingMode);
5300 }
5301 else if ( DOT11F_WARNED( nStatus ) )
5302 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005303 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005304 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005305 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005306 }
5307
5308 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5309
5310 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5311 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5312 {
5313 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005314 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005315 return eSIR_FAILURE;
5316 }
5317
5318 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305319 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005320
5321
5322 // Next, we fill out the buffer descriptor:
5323 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5324 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5325 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5326 } else
5327 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5328 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5329 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305330 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5331 (tANI_U8 *) psessionEntry->bssId,
5332 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005333 if ( eSIR_SUCCESS != nSirStatus )
5334 {
5335 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005336 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005337 nSirStatus );
5338 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5339 return eSIR_FAILURE; // just allocated...
5340 }
5341 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5342 sizeof(tSirMacMgmtHdr),
5343 nPayload, &nPayload );
5344 if ( DOT11F_FAILED( nStatus ) )
5345 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005346 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005347 nStatus );
5348 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5349 return eSIR_FAILURE; // allocated!
5350 }
5351 else if ( DOT11F_WARNED( nStatus ) )
5352 {
5353 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005354 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005355 }
5356 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005357 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5358 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005359 )
5360 {
5361 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5362 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305363
5364 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5365 psessionEntry->peSessionId,
5366 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005367 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5368 HAL_TXRX_FRM_802_11_MGMT,
5369 ANI_TXDIR_TODS,
5370 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5371 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305372 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5373 psessionEntry->peSessionId,
5374 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005375 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5376 {
5377 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005378 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005379 nSirStatus );
5380 //Pkt will be freed up by the callback
5381 return eSIR_FAILURE;
5382 }
5383
5384 return eSIR_SUCCESS;
5385}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005386
5387/**
5388 * \brief Send a VHT Channel Switch Announcement
5389 *
5390 *
5391 * \param pMac Pointer to the global MAC datastructure
5392 *
5393 * \param peer MAC address to which this frame will be sent
5394 *
5395 * \param nChanWidth
5396 *
5397 * \param nNewChannel
5398 *
5399 *
5400 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5401 *
5402 *
5403 */
5404
5405tSirRetStatus
5406limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5407 tSirMacAddr peer,
5408 tANI_U8 nChanWidth,
5409 tANI_U8 nNewChannel,
5410 tANI_U8 ncbMode,
5411 tpPESession psessionEntry )
5412{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305413 tDot11fChannelSwitch frm;
5414 tANI_U8 *pFrame;
5415 tSirRetStatus nSirStatus;
5416 tpSirMacMgmtHdr pMacHdr;
5417 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5418 void *pPacket;
5419 eHalStatus halstatus;
5420 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005421
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305422 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005423
5424
5425 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5426 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5427 frm.ChanSwitchAnn.switchMode = 1;
5428 frm.ChanSwitchAnn.newChannel = nNewChannel;
5429 frm.ChanSwitchAnn.switchCount = 1;
5430 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5431 frm.ExtChanSwitchAnn.present = 1;
5432 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5433 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5434 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5435 frm.ChanSwitchAnn.present = 1;
5436 frm.WiderBWChanSwitchAnn.present = 1;
5437
5438 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5439 if ( DOT11F_FAILED( nStatus ) )
5440 {
5441 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005442 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005443 nStatus );
5444 // We'll fall back on the worst case scenario:
5445 nPayload = sizeof( tDot11fChannelSwitch );
5446 }
5447 else if ( DOT11F_WARNED( nStatus ) )
5448 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005449 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005450 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005451 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005452 }
5453
5454 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5455
5456 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5457 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5458 {
5459 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005460 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005461 return eSIR_FAILURE;
5462 }
5463 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305464 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005465
5466 // Next, we fill out the buffer descriptor:
5467 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5468 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5469 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305470 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5471 (tANI_U8 *) psessionEntry->bssId,
5472 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005473 if ( eSIR_SUCCESS != nSirStatus )
5474 {
5475 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005476 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005477 nSirStatus );
5478 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5479 return eSIR_FAILURE; // just allocated...
5480 }
5481 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5482 sizeof(tSirMacMgmtHdr),
5483 nPayload, &nPayload );
5484 if ( DOT11F_FAILED( nStatus ) )
5485 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005486 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005487 nStatus );
5488 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5489 return eSIR_FAILURE; // allocated!
5490 }
5491 else if ( DOT11F_WARNED( nStatus ) )
5492 {
5493 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005494 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005495 }
5496
5497 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005498 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5499 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005500 )
5501 {
5502 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5503 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305504
5505 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5506 psessionEntry->peSessionId,
5507 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005508 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5509 HAL_TXRX_FRM_802_11_MGMT,
5510 ANI_TXDIR_TODS,
5511 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5512 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305513 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5514 psessionEntry->peSessionId,
5515 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005516 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5517 {
5518 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005519 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005520 nSirStatus );
5521 //Pkt will be freed up by the callback
5522 return eSIR_FAILURE;
5523 }
5524
5525 return eSIR_SUCCESS;
5526
5527} // End limSendVHTChannelSwitchMgmtFrame.
5528
5529
5530
Mohit Khanna4a70d262012-09-11 16:30:12 -07005531#endif
5532
Jeff Johnson295189b2012-06-20 16:38:30 -07005533/**
5534 * \brief Send an ADDBA Req Action Frame to peer
5535 *
5536 * \sa limSendAddBAReq
5537 *
5538 * \param pMac The global tpAniSirGlobal object
5539 *
5540 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5541 * the necessary parameters reqd by PE send the ADDBA Req Action
5542 * Frame to the peer
5543 *
5544 * \return eSIR_SUCCESS if setup completes successfully
5545 * eSIR_FAILURE is some problem is encountered
5546 */
5547tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305548 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005549{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305550 tDot11fAddBAReq frmAddBAReq;
5551 tANI_U8 *pAddBAReqBuffer = NULL;
5552 tpSirMacMgmtHdr pMacHdr;
5553 tANI_U32 frameLen = 0, nStatus, nPayload;
5554 tSirRetStatus statusCode;
5555 eHalStatus halStatus;
5556 void *pPacket;
5557 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005558
5559 if(NULL == psessionEntry)
5560 {
5561 return eSIR_FAILURE;
5562 }
5563
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305564 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005565
5566 // Category - 3 (BA)
5567 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5568
5569 // Action - 0 (ADDBA Req)
5570 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5571
5572 // FIXME - Dialog Token, generalize this...
5573 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5574
5575 // Fill the ADDBA Parameter Set
5576 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5577 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5578 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5579
5580 // BA timeout
5581 // 0 - indicates no BA timeout
5582 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5583
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305584 /* Send SSN whatever we get from FW.
5585 */
5586 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005587
5588 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5589
5590 if( DOT11F_FAILED( nStatus ))
5591 {
5592 limLog( pMac, LOGW,
5593 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005594 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 nStatus );
5596
5597 // We'll fall back on the worst case scenario:
5598 nPayload = sizeof( tDot11fAddBAReq );
5599 }
5600 else if( DOT11F_WARNED( nStatus ))
5601 {
5602 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005603 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005604 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005605 nStatus );
5606 }
5607
5608 // Add the MGMT header to frame length
5609 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5610
5611 // Need to allocate a buffer for ADDBA AF
5612 if( eHAL_STATUS_SUCCESS !=
5613 (halStatus = palPktAlloc( pMac->hHdd,
5614 HAL_TXRX_FRM_802_11_MGMT,
5615 (tANI_U16) frameLen,
5616 (void **) &pAddBAReqBuffer,
5617 (void **) &pPacket )))
5618 {
5619 // Log error
5620 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005621 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 frameLen,
5623 halStatus );
5624
5625 statusCode = eSIR_MEM_ALLOC_FAILED;
5626 goto returnAfterError;
5627 }
5628
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305629 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005630
5631 // Copy necessary info to BD
5632 if( eSIR_SUCCESS !=
5633 (statusCode = limPopulateMacHeader( pMac,
5634 pAddBAReqBuffer,
5635 SIR_MAC_MGMT_FRAME,
5636 SIR_MAC_MGMT_ACTION,
5637 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5638 goto returnAfterError;
5639
5640 // Update A3 with the BSSID
5641 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5642
5643 #if 0
5644 cfgLen = SIR_MAC_ADDR_LENGTH;
5645 if( eSIR_SUCCESS != cfgGetStr( pMac,
5646 WNI_CFG_BSSID,
5647 (tANI_U8 *) pMacHdr->bssId,
5648 &cfgLen ))
5649 {
5650 limLog( pMac, LOGP,
5651 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005652 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005653
5654 // FIXME - Need to convert to tSirRetStatus
5655 statusCode = eSIR_FAILURE;
5656 goto returnAfterError;
5657 }
5658 #endif//TO SUPPORT BT-AMP
5659 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5660
Chet Lanctot186b5732013-03-18 10:26:30 -07005661#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005662 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005663#endif
5664
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 // Now, we're ready to "pack" the frames
5666 nStatus = dot11fPackAddBAReq( pMac,
5667 &frmAddBAReq,
5668 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5669 nPayload,
5670 &nPayload );
5671
5672 if( DOT11F_FAILED( nStatus ))
5673 {
5674 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005675 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 nStatus );
5677
5678 // FIXME - Need to convert to tSirRetStatus
5679 statusCode = eSIR_FAILURE;
5680 goto returnAfterError;
5681 }
5682 else if( DOT11F_WARNED( nStatus ))
5683 {
5684 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005685 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5686 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 }
5688
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305689 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5690 " tid = %d policy = %d buffsize = %d "
5691 " amsduSupported = %d"),
5692 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5693 frmAddBAReq.AddBAParameterSet.tid,
5694 frmAddBAReq.AddBAParameterSet.policy,
5695 frmAddBAReq.AddBAParameterSet.bufferSize,
5696 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005697
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305698 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5699 frmAddBAReq.BAStartingSequenceControl.ssn,
5700 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5701
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5704 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 )
5706 {
5707 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5708 }
5709
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305710 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5711 psessionEntry->peSessionId,
5712 pMacHdr->fc.subType));
5713 halStatus = halTxFrame( pMac,
5714 pPacket,
5715 (tANI_U16) frameLen,
5716 HAL_TXRX_FRM_802_11_MGMT,
5717 ANI_TXDIR_TODS,
5718 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5719 limTxComplete,
5720 pAddBAReqBuffer, txFlag );
5721 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5722 psessionEntry->peSessionId,
5723 halStatus));
5724 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 {
5726 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005727 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 halStatus );
5729
5730 // FIXME - Need to convert eHalStatus to tSirRetStatus
5731 statusCode = eSIR_FAILURE;
5732 //Pkt will be freed up by the callback
5733 return statusCode;
5734 }
5735 else
5736 return eSIR_SUCCESS;
5737
5738returnAfterError:
5739
5740 // Release buffer, if allocated
5741 if( NULL != pAddBAReqBuffer )
5742 palPktFree( pMac->hHdd,
5743 HAL_TXRX_FRM_802_11_MGMT,
5744 (void *) pAddBAReqBuffer,
5745 (void *) pPacket );
5746
5747 return statusCode;
5748}
5749
5750/**
5751 * \brief Send an ADDBA Rsp Action Frame to peer
5752 *
5753 * \sa limSendAddBARsp
5754 *
5755 * \param pMac The global tpAniSirGlobal object
5756 *
5757 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5758 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5759 * Frame to the peer
5760 *
5761 * \return eSIR_SUCCESS if setup completes successfully
5762 * eSIR_FAILURE is some problem is encountered
5763 */
5764tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5765 tpLimMlmAddBARsp pMlmAddBARsp,
5766 tpPESession psessionEntry)
5767{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305768 tDot11fAddBARsp frmAddBARsp;
5769 tANI_U8 *pAddBARspBuffer = NULL;
5770 tpSirMacMgmtHdr pMacHdr;
5771 tANI_U32 frameLen = 0, nStatus, nPayload;
5772 tSirRetStatus statusCode;
5773 eHalStatus halStatus;
5774 void *pPacket;
5775 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005776
5777 if(NULL == psessionEntry)
5778 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005779 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 return eSIR_FAILURE;
5781 }
5782
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305783 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005784
5785 // Category - 3 (BA)
5786 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5787 // Action - 1 (ADDBA Rsp)
5788 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5789
5790 // Should be same as the one we received in the ADDBA Req
5791 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5792
5793 // ADDBA Req status
5794 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5795
5796 // Fill the ADDBA Parameter Set as provided by caller
5797 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5798 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5799 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005800
5801 if(psessionEntry->isAmsduSupportInAMPDU)
5802 {
5803 frmAddBARsp.AddBAParameterSet.amsduSupported =
5804 psessionEntry->amsduSupportedInBA;
5805 }
5806 else
5807 {
5808 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005810
5811 // BA timeout
5812 // 0 - indicates no BA timeout
5813 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5814
5815 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5816
5817 if( DOT11F_FAILED( nStatus ))
5818 {
5819 limLog( pMac, LOGW,
5820 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005821 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 nStatus );
5823
5824 // We'll fall back on the worst case scenario:
5825 nPayload = sizeof( tDot11fAddBARsp );
5826 }
5827 else if( DOT11F_WARNED( nStatus ))
5828 {
5829 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005830 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005831 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 nStatus );
5833 }
5834
5835 // Need to allocate a buffer for ADDBA AF
5836 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5837
5838 // Allocate shared memory
5839 if( eHAL_STATUS_SUCCESS !=
5840 (halStatus = palPktAlloc( pMac->hHdd,
5841 HAL_TXRX_FRM_802_11_MGMT,
5842 (tANI_U16) frameLen,
5843 (void **) &pAddBARspBuffer,
5844 (void **) &pPacket )))
5845 {
5846 // Log error
5847 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005848 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 frameLen,
5850 halStatus );
5851
5852 statusCode = eSIR_MEM_ALLOC_FAILED;
5853 goto returnAfterError;
5854 }
5855
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305856 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005857
5858 // Copy necessary info to BD
5859 if( eSIR_SUCCESS !=
5860 (statusCode = limPopulateMacHeader( pMac,
5861 pAddBARspBuffer,
5862 SIR_MAC_MGMT_FRAME,
5863 SIR_MAC_MGMT_ACTION,
5864 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5865 goto returnAfterError;
5866
5867 // Update A3 with the BSSID
5868
5869 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5870
5871 #if 0
5872 cfgLen = SIR_MAC_ADDR_LENGTH;
5873 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5874 WNI_CFG_BSSID,
5875 (tANI_U8 *) pMacHdr->bssId,
5876 &cfgLen ))
5877 {
5878 limLog( pMac, LOGP,
5879 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005880 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005881
5882 // FIXME - Need to convert to tSirRetStatus
5883 statusCode = eSIR_FAILURE;
5884 goto returnAfterError;
5885 }
5886 #endif // TO SUPPORT BT-AMP
5887 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5888
Chet Lanctot186b5732013-03-18 10:26:30 -07005889#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005890 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005891#endif
5892
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 // Now, we're ready to "pack" the frames
5894 nStatus = dot11fPackAddBARsp( pMac,
5895 &frmAddBARsp,
5896 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5897 nPayload,
5898 &nPayload );
5899
5900 if( DOT11F_FAILED( nStatus ))
5901 {
5902 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005903 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005904 nStatus );
5905
5906 // FIXME - Need to convert to tSirRetStatus
5907 statusCode = eSIR_FAILURE;
5908 goto returnAfterError;
5909 }
5910 else if( DOT11F_WARNED( nStatus ))
5911 {
5912 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005913 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5914 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 }
5916
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305917 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5918 " tid = %d policy = %d buffsize = %d"
5919 " amsduSupported = %d status %d"),
5920 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5921 frmAddBARsp.AddBAParameterSet.tid,
5922 frmAddBARsp.AddBAParameterSet.policy,
5923 frmAddBARsp.AddBAParameterSet.bufferSize,
5924 frmAddBARsp.AddBAParameterSet.amsduSupported,
5925 frmAddBARsp.Status.status);
5926
Jeff Johnson295189b2012-06-20 16:38:30 -07005927
5928 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5930 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 )
5932 {
5933 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5934 }
5935
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305936 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5937 psessionEntry->peSessionId,
5938 pMacHdr->fc.subType));
5939 halStatus = halTxFrame( pMac,
5940 pPacket,
5941 (tANI_U16) frameLen,
5942 HAL_TXRX_FRM_802_11_MGMT,
5943 ANI_TXDIR_TODS,
5944 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5945 limTxComplete,
5946 pAddBARspBuffer, txFlag );
5947 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5948 psessionEntry->peSessionId,
5949 halStatus));
5950 if( eHAL_STATUS_SUCCESS != halStatus )
5951 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005953 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 halStatus );
5955
5956 // FIXME - HAL error codes are different from PE error
5957 // codes!! And, this routine is returning tSirRetStatus
5958 statusCode = eSIR_FAILURE;
5959 //Pkt will be freed up by the callback
5960 return statusCode;
5961 }
5962 else
5963 return eSIR_SUCCESS;
5964
5965 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 // Release buffer, if allocated
5967 if( NULL != pAddBARspBuffer )
5968 palPktFree( pMac->hHdd,
5969 HAL_TXRX_FRM_802_11_MGMT,
5970 (void *) pAddBARspBuffer,
5971 (void *) pPacket );
5972
5973 return statusCode;
5974}
5975
5976/**
5977 * \brief Send a DELBA Indication Action Frame to peer
5978 *
5979 * \sa limSendDelBAInd
5980 *
5981 * \param pMac The global tpAniSirGlobal object
5982 *
5983 * \param peerMacAddr MAC Address of peer
5984 *
5985 * \param reasonCode Reason for the DELBA notification
5986 *
5987 * \param pBAParameterSet The DELBA Parameter Set.
5988 * This identifies the TID for which the BA session is
5989 * being deleted.
5990 *
5991 * \return eSIR_SUCCESS if setup completes successfully
5992 * eSIR_FAILURE is some problem is encountered
5993 */
5994tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5995 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5996{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305997 tDot11fDelBAInd frmDelBAInd;
5998 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306000 tpSirMacMgmtHdr pMacHdr;
6001 tANI_U32 frameLen = 0, nStatus, nPayload;
6002 tSirRetStatus statusCode;
6003 eHalStatus halStatus;
6004 void *pPacket;
6005 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006006
6007 if(NULL == psessionEntry)
6008 {
6009 return eSIR_FAILURE;
6010 }
6011
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306012 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006013
6014 // Category - 3 (BA)
6015 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
6016 // Action - 2 (DELBA)
6017 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
6018
6019 // Fill the DELBA Parameter Set as provided by caller
6020 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
6021 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
6022
6023 // BA Starting Sequence Number
6024 // Fragment number will always be zero
6025 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
6026
6027 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
6028
6029 if( DOT11F_FAILED( nStatus ))
6030 {
6031 limLog( pMac, LOGW,
6032 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006033 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 nStatus );
6035
6036 // We'll fall back on the worst case scenario:
6037 nPayload = sizeof( tDot11fDelBAInd );
6038 }
6039 else if( DOT11F_WARNED( nStatus ))
6040 {
6041 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006042 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006043 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 nStatus );
6045 }
6046
6047 // Add the MGMT header to frame length
6048 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
6049
6050 // Allocate shared memory
6051 if( eHAL_STATUS_SUCCESS !=
6052 (halStatus = palPktAlloc( pMac->hHdd,
6053 HAL_TXRX_FRM_802_11_MGMT,
6054 (tANI_U16) frameLen,
6055 (void **) &pDelBAIndBuffer,
6056 (void **) &pPacket )))
6057 {
6058 // Log error
6059 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006060 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 frameLen,
6062 halStatus );
6063
6064 statusCode = eSIR_MEM_ALLOC_FAILED;
6065 goto returnAfterError;
6066 }
6067
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306068 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006069
6070 // Copy necessary info to BD
6071 if( eSIR_SUCCESS !=
6072 (statusCode = limPopulateMacHeader( pMac,
6073 pDelBAIndBuffer,
6074 SIR_MAC_MGMT_FRAME,
6075 SIR_MAC_MGMT_ACTION,
6076 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
6077 goto returnAfterError;
6078
6079 // Update A3 with the BSSID
6080 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
6081
6082 #if 0
6083 cfgLen = SIR_MAC_ADDR_LENGTH;
6084 if( eSIR_SUCCESS != cfgGetStr( pMac,
6085 WNI_CFG_BSSID,
6086 (tANI_U8 *) pMacHdr->bssId,
6087 &cfgLen ))
6088 {
6089 limLog( pMac, LOGP,
6090 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006091 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006092
6093 // FIXME - Need to convert to tSirRetStatus
6094 statusCode = eSIR_FAILURE;
6095 goto returnAfterError;
6096 }
6097 #endif //TO SUPPORT BT-AMP
6098 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
6099
Chet Lanctot186b5732013-03-18 10:26:30 -07006100#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006101 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006102#endif
6103
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 // Now, we're ready to "pack" the frames
6105 nStatus = dot11fPackDelBAInd( pMac,
6106 &frmDelBAInd,
6107 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
6108 nPayload,
6109 &nPayload );
6110
6111 if( DOT11F_FAILED( nStatus ))
6112 {
6113 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006114 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 nStatus );
6116
6117 // FIXME - Need to convert to tSirRetStatus
6118 statusCode = eSIR_FAILURE;
6119 goto returnAfterError;
6120 }
6121 else if( DOT11F_WARNED( nStatus ))
6122 {
6123 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006124 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
6125 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 }
6127
Abhishek Singh1f6e6532014-06-05 17:35:08 +05306128 limLog( pMac, LOG1,
6129 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
6130 " initiator = %d reason = %d" ),
6131 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
6132 frmDelBAInd.DelBAParameterSet.tid,
6133 frmDelBAInd.DelBAParameterSet.initiator,
6134 frmDelBAInd.Reason.code);
6135
Jeff Johnson295189b2012-06-20 16:38:30 -07006136
6137 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6139 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 )
6141 {
6142 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6143 }
6144
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306145 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6146 psessionEntry->peSessionId,
6147 pMacHdr->fc.subType));
6148 halStatus = halTxFrame( pMac,
6149 pPacket,
6150 (tANI_U16) frameLen,
6151 HAL_TXRX_FRM_802_11_MGMT,
6152 ANI_TXDIR_TODS,
6153 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6154 limTxComplete,
6155 pDelBAIndBuffer, txFlag );
6156 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6157 psessionEntry->peSessionId,
6158 halStatus));
6159 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006161 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 statusCode = eSIR_FAILURE;
6163 //Pkt will be freed up by the callback
6164 return statusCode;
6165 }
6166 else
6167 return eSIR_SUCCESS;
6168
6169 returnAfterError:
6170
6171 // Release buffer, if allocated
6172 if( NULL != pDelBAIndBuffer )
6173 palPktFree( pMac->hHdd,
6174 HAL_TXRX_FRM_802_11_MGMT,
6175 (void *) pDelBAIndBuffer,
6176 (void *) pPacket );
6177
6178 return statusCode;
6179}
6180
6181#if defined WLAN_FEATURE_VOWIFI
6182
6183/**
6184 * \brief Send a Neighbor Report Request Action frame
6185 *
6186 *
6187 * \param pMac Pointer to the global MAC structure
6188 *
6189 * \param pNeighborReq Address of a tSirMacNeighborReportReq
6190 *
6191 * \param peer mac address of peer station.
6192 *
6193 * \param psessionEntry address of session entry.
6194 *
6195 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6196 *
6197 *
6198 */
6199
6200tSirRetStatus
6201limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
6202 tpSirMacNeighborReportReq pNeighborReq,
6203 tSirMacAddr peer,
6204 tpPESession psessionEntry
6205 )
6206{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306207 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 tDot11fNeighborReportRequest frm;
6209 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306210 tpSirMacMgmtHdr pMacHdr;
6211 tANI_U32 nBytes, nPayload, nStatus;
6212 void *pPacket;
6213 eHalStatus halstatus;
6214 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006215
6216 if ( psessionEntry == NULL )
6217 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006218 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 return eSIR_FAILURE;
6220 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306221 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006222
6223 frm.Category.category = SIR_MAC_ACTION_RRM;
6224 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
6225 frm.DialogToken.token = pNeighborReq->dialogToken;
6226
6227
6228 if( pNeighborReq->ssid_present )
6229 {
6230 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
6231 }
6232
6233 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
6234 if ( DOT11F_FAILED( nStatus ) )
6235 {
6236 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006237 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 nStatus );
6239 // We'll fall back on the worst case scenario:
6240 nPayload = sizeof( tDot11fNeighborReportRequest );
6241 }
6242 else if ( DOT11F_WARNED( nStatus ) )
6243 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006244 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006246 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 }
6248
6249 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6250
6251 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6252 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6253 {
6254 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006255 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 return eSIR_FAILURE;
6257 }
6258
6259 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306260 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006261
6262 // Copy necessary info to BD
6263 if( eSIR_SUCCESS !=
6264 (statusCode = limPopulateMacHeader( pMac,
6265 pFrame,
6266 SIR_MAC_MGMT_FRAME,
6267 SIR_MAC_MGMT_ACTION,
6268 peer, psessionEntry->selfMacAddr)))
6269 goto returnAfterError;
6270
6271 // Update A3 with the BSSID
6272 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6273
6274 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6275
Chet Lanctot186b5732013-03-18 10:26:30 -07006276#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006277 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006278#endif
6279
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 // Now, we're ready to "pack" the frames
6281 nStatus = dot11fPackNeighborReportRequest( pMac,
6282 &frm,
6283 pFrame + sizeof( tSirMacMgmtHdr ),
6284 nPayload,
6285 &nPayload );
6286
6287 if( DOT11F_FAILED( nStatus ))
6288 {
6289 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006290 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 nStatus );
6292
6293 // FIXME - Need to convert to tSirRetStatus
6294 statusCode = eSIR_FAILURE;
6295 goto returnAfterError;
6296 }
6297 else if( DOT11F_WARNED( nStatus ))
6298 {
6299 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006300 FL( "There were warnings while packing Neighbor Report "
6301 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 }
6303
6304 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006305 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 limPrintMacAddr( pMac, peer, LOGW );
6307
6308 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6310 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 )
6312 {
6313 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6314 }
6315
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306316 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6317 psessionEntry->peSessionId,
6318 pMacHdr->fc.subType));
6319 halstatus = halTxFrame( pMac,
6320 pPacket,
6321 (tANI_U16) nBytes,
6322 HAL_TXRX_FRM_802_11_MGMT,
6323 ANI_TXDIR_TODS,
6324 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6325 limTxComplete,
6326 pFrame, txFlag );
6327 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6328 psessionEntry->peSessionId,
6329 halstatus));
6330 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006332 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 statusCode = eSIR_FAILURE;
6334 //Pkt will be freed up by the callback
6335 return statusCode;
6336 }
6337 else
6338 return eSIR_SUCCESS;
6339
6340returnAfterError:
6341 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6342
6343 return statusCode;
6344} // End limSendNeighborReportRequestFrame.
6345
6346/**
6347 * \brief Send a Link Report Action frame
6348 *
6349 *
6350 * \param pMac Pointer to the global MAC structure
6351 *
6352 * \param pLinkReport Address of a tSirMacLinkReport
6353 *
6354 * \param peer mac address of peer station.
6355 *
6356 * \param psessionEntry address of session entry.
6357 *
6358 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6359 *
6360 *
6361 */
6362
6363tSirRetStatus
6364limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6365 tpSirMacLinkReport pLinkReport,
6366 tSirMacAddr peer,
6367 tpPESession psessionEntry
6368 )
6369{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306370 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 tDot11fLinkMeasurementReport frm;
6372 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306373 tpSirMacMgmtHdr pMacHdr;
6374 tANI_U32 nBytes, nPayload, nStatus;
6375 void *pPacket;
6376 eHalStatus halstatus;
6377 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006378
6379
6380 if ( psessionEntry == NULL )
6381 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006382 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 return eSIR_FAILURE;
6384 }
6385
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306386 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006387
6388 frm.Category.category = SIR_MAC_ACTION_RRM;
6389 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6390 frm.DialogToken.token = pLinkReport->dialogToken;
6391
6392
6393 //IEEE Std. 802.11 7.3.2.18. for the report element.
6394 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6395 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6396 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6397 //such case this way than changing the frame parser.
6398 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6399 frm.TPCEleLen.TPCLen = 2;
6400 frm.TxPower.txPower = pLinkReport->txPower;
6401 frm.LinkMargin.linkMargin = 0;
6402
6403 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6404 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6405 frm.RCPI.rcpi = pLinkReport->rcpi;
6406 frm.RSNI.rsni = pLinkReport->rsni;
6407
6408 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6409 if ( DOT11F_FAILED( nStatus ) )
6410 {
6411 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006412 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 nStatus );
6414 // We'll fall back on the worst case scenario:
6415 nPayload = sizeof( tDot11fLinkMeasurementReport );
6416 }
6417 else if ( DOT11F_WARNED( nStatus ) )
6418 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006419 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006421 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 }
6423
6424 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6425
6426 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6427 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6428 {
6429 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006430 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 return eSIR_FAILURE;
6432 }
6433
6434 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306435 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006436
6437 // Copy necessary info to BD
6438 if( eSIR_SUCCESS !=
6439 (statusCode = limPopulateMacHeader( pMac,
6440 pFrame,
6441 SIR_MAC_MGMT_FRAME,
6442 SIR_MAC_MGMT_ACTION,
6443 peer, psessionEntry->selfMacAddr)))
6444 goto returnAfterError;
6445
6446 // Update A3 with the BSSID
6447 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6448
6449 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6450
Chet Lanctot186b5732013-03-18 10:26:30 -07006451#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006452 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006453#endif
6454
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 // Now, we're ready to "pack" the frames
6456 nStatus = dot11fPackLinkMeasurementReport( pMac,
6457 &frm,
6458 pFrame + sizeof( tSirMacMgmtHdr ),
6459 nPayload,
6460 &nPayload );
6461
6462 if( DOT11F_FAILED( nStatus ))
6463 {
6464 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006465 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 nStatus );
6467
6468 // FIXME - Need to convert to tSirRetStatus
6469 statusCode = eSIR_FAILURE;
6470 goto returnAfterError;
6471 }
6472 else if( DOT11F_WARNED( nStatus ))
6473 {
6474 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006475 FL( "There were warnings while packing Link Report (0x%08x)." ),
6476 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 }
6478
6479 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006480 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 limPrintMacAddr( pMac, peer, LOGW );
6482
6483 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6485 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 )
6487 {
6488 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6489 }
6490
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306491 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6492 psessionEntry->peSessionId,
6493 pMacHdr->fc.subType));
6494 halstatus = halTxFrame( pMac,
6495 pPacket,
6496 (tANI_U16) nBytes,
6497 HAL_TXRX_FRM_802_11_MGMT,
6498 ANI_TXDIR_TODS,
6499 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6500 limTxComplete,
6501 pFrame, txFlag );
6502 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6503 psessionEntry->peSessionId,
6504 halstatus));
6505 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006507 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 statusCode = eSIR_FAILURE;
6509 //Pkt will be freed up by the callback
6510 return statusCode;
6511 }
6512 else
6513 return eSIR_SUCCESS;
6514
6515returnAfterError:
6516 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6517
6518 return statusCode;
6519} // End limSendLinkReportActionFrame.
6520
6521/**
6522 * \brief Send a Beacon Report Action frame
6523 *
6524 *
6525 * \param pMac Pointer to the global MAC structure
6526 *
6527 * \param dialog_token dialog token to be used in the action frame.
6528 *
6529 * \param num_report number of reports in pRRMReport.
6530 *
6531 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6532 *
6533 * \param peer mac address of peer station.
6534 *
6535 * \param psessionEntry address of session entry.
6536 *
6537 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6538 *
6539 *
6540 */
6541
6542tSirRetStatus
6543limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6544 tANI_U8 dialog_token,
6545 tANI_U8 num_report,
6546 tpSirMacRadioMeasureReport pRRMReport,
6547 tSirMacAddr peer,
6548 tpPESession psessionEntry
6549 )
6550{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306551 tSirRetStatus statusCode = eSIR_SUCCESS;
6552 tANI_U8 *pFrame;
6553 tpSirMacMgmtHdr pMacHdr;
6554 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006555 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306556 eHalStatus halstatus;
6557 tANI_U8 i;
6558 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006559
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006560 tDot11fRadioMeasurementReport *frm =
6561 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6562 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006563 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006564 return eSIR_FAILURE;
6565 }
6566
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 if ( psessionEntry == NULL )
6568 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006569 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006570 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 return eSIR_FAILURE;
6572 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306573 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006574
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006575 frm->Category.category = SIR_MAC_ACTION_RRM;
6576 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6577 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006578
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006579 frm->num_MeasurementReport = (num_report > RADIO_REPORTS_MAX_IN_A_FRAME ) ? RADIO_REPORTS_MAX_IN_A_FRAME : num_report;
Jeff Johnson295189b2012-06-20 16:38:30 -07006580
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006581 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006583 frm->MeasurementReport[i].type = pRRMReport[i].type;
6584 frm->MeasurementReport[i].token = pRRMReport[i].token;
6585 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006586 switch( pRRMReport[i].type )
6587 {
6588 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006589 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6590 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6591 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6592 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 break;
6594 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306595 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6596 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006597 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 break;
6599 }
6600 }
6601
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006602 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 if ( DOT11F_FAILED( nStatus ) )
6604 {
6605 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006606 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 nStatus );
6608 // We'll fall back on the worst case scenario:
6609 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006610 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 return eSIR_FAILURE;
6612 }
6613 else if ( DOT11F_WARNED( nStatus ) )
6614 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006615 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006617 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 }
6619
6620 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6621
6622 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6623 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6624 {
6625 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006626 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006627 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 return eSIR_FAILURE;
6629 }
6630
6631 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306632 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006633
6634 // Copy necessary info to BD
6635 if( eSIR_SUCCESS !=
6636 (statusCode = limPopulateMacHeader( pMac,
6637 pFrame,
6638 SIR_MAC_MGMT_FRAME,
6639 SIR_MAC_MGMT_ACTION,
6640 peer, psessionEntry->selfMacAddr)))
6641 goto returnAfterError;
6642
6643 // Update A3 with the BSSID
6644 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6645
6646 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6647
Chet Lanctot186b5732013-03-18 10:26:30 -07006648#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006649 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006650#endif
6651
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 // Now, we're ready to "pack" the frames
6653 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006654 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 pFrame + sizeof( tSirMacMgmtHdr ),
6656 nPayload,
6657 &nPayload );
6658
6659 if( DOT11F_FAILED( nStatus ))
6660 {
6661 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006662 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 nStatus );
6664
6665 // FIXME - Need to convert to tSirRetStatus
6666 statusCode = eSIR_FAILURE;
6667 goto returnAfterError;
6668 }
6669 else if( DOT11F_WARNED( nStatus ))
6670 {
6671 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006672 FL( "There were warnings while packing Radio "
6673 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 }
6675
6676 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006677 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006678 limPrintMacAddr( pMac, peer, LOGW );
6679
6680 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6682 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 )
6684 {
6685 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6686 }
6687
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306688 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6689 psessionEntry->peSessionId,
6690 pMacHdr->fc.subType));
6691 halstatus = halTxFrame( pMac,
6692 pPacket,
6693 (tANI_U16) nBytes,
6694 HAL_TXRX_FRM_802_11_MGMT,
6695 ANI_TXDIR_TODS,
6696 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6697 limTxComplete,
6698 pFrame, txFlag );
6699 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6700 psessionEntry->peSessionId,
6701 halstatus));
6702 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006704 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 statusCode = eSIR_FAILURE;
6706 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006707 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 return statusCode;
6709 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006710 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006711 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006712 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006714
6715returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006716 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 return statusCode;
6719} // End limSendBeaconReportActionFrame.
6720
6721#endif
6722
6723#ifdef WLAN_FEATURE_11W
6724/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006725 * \brief Send SA query request action frame to peer
6726 *
6727 * \sa limSendSaQueryRequestFrame
6728 *
6729 *
6730 * \param pMac The global tpAniSirGlobal object
6731 *
6732 * \param transId Transaction identifier
6733 *
6734 * \param peer The Mac address of the station to which this action frame is addressed
6735 *
6736 * \param psessionEntry The PE session entry
6737 *
6738 * \return eSIR_SUCCESS if setup completes successfully
6739 * eSIR_FAILURE is some problem is encountered
6740 */
6741
6742tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6743 tSirMacAddr peer, tpPESession psessionEntry )
6744{
6745
6746 tDot11fSaQueryReq frm; // SA query request action frame
6747 tANI_U8 *pFrame;
6748 tSirRetStatus nSirStatus;
6749 tpSirMacMgmtHdr pMacHdr;
6750 tANI_U32 nBytes, nPayload, nStatus;
6751 void *pPacket;
6752 eHalStatus halstatus;
6753 tANI_U8 txFlag = 0;
6754
6755 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6756 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6757 /* 11w action field is :
6758 action: 0 --> SA Query Request action frame
6759 action: 1 --> SA Query Response action frame */
6760 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6761 /* 11w SA Query Request transId */
6762 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6763
6764 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6765 if ( DOT11F_FAILED( nStatus ) )
6766 {
6767 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6768 "for an SA Query Request (0x%08x)."),
6769 nStatus );
6770 // We'll fall back on the worst case scenario:
6771 nPayload = sizeof( tDot11fSaQueryReq );
6772 }
6773 else if ( DOT11F_WARNED( nStatus ) )
6774 {
6775 limLog( pMac, LOGW, FL("There were warnings while calculating "
6776 "the packed size for an SA Query Request"
6777 " (0x%08x)."), nStatus );
6778 }
6779
6780 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6781 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6782 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6783 {
6784 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6785 "action frame"), nBytes );
6786 return eSIR_FAILURE;
6787 }
6788
6789 // Paranoia:
6790 vos_mem_set( pFrame, nBytes, 0 );
6791
6792 // Copy necessary info to BD
6793 nSirStatus = limPopulateMacHeader( pMac,
6794 pFrame,
6795 SIR_MAC_MGMT_FRAME,
6796 SIR_MAC_MGMT_ACTION,
6797 peer, psessionEntry->selfMacAddr );
6798 if ( eSIR_SUCCESS != nSirStatus )
6799 goto returnAfterError;
6800
6801 // Update A3 with the BSSID
6802 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6803
6804 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6805
6806 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6807 // in the FC
6808 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6809
6810 // Pack 11w SA Query Request frame
6811 nStatus = dot11fPackSaQueryReq( pMac,
6812 &frm,
6813 pFrame + sizeof( tSirMacMgmtHdr ),
6814 nPayload,
6815 &nPayload );
6816
6817 if ( DOT11F_FAILED( nStatus ))
6818 {
6819 limLog( pMac, LOGE,
6820 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6821 nStatus );
6822 // FIXME - Need to convert to tSirRetStatus
6823 nSirStatus = eSIR_FAILURE;
6824 goto returnAfterError;
6825 }
6826 else if ( DOT11F_WARNED( nStatus ))
6827 {
6828 limLog( pMac, LOGW,
6829 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6830 nStatus);
6831 }
6832
6833 limLog( pMac, LOG1,
6834 FL( "Sending an SA Query Request to " ));
6835 limPrintMacAddr( pMac, peer, LOG1 );
6836 limPrintMacAddr( pMac, peer, LOGE );
6837 limLog( pMac, LOGE,
6838 FL( "Sending an SA Query Request from " ));
6839 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6840
6841 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6842#ifdef WLAN_FEATURE_P2P
6843 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6844 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6845#endif
6846 )
6847 {
6848 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6849 }
6850
6851 halstatus = halTxFrame( pMac,
6852 pPacket,
6853 (tANI_U16) nBytes,
6854 HAL_TXRX_FRM_802_11_MGMT,
6855 ANI_TXDIR_TODS,
6856 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6857 limTxComplete,
6858 pFrame, txFlag );
6859 if ( eHAL_STATUS_SUCCESS != halstatus )
6860 {
6861 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6862 nSirStatus = eSIR_FAILURE;
6863 //Pkt will be freed up by the callback
6864 return nSirStatus;
6865 }
6866 else {
6867 return eSIR_SUCCESS;
6868 }
6869
6870returnAfterError:
6871 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6872 return nSirStatus;
6873} // End limSendSaQueryRequestFrame
6874
6875/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006876 * \brief Send SA query response action frame to peer
6877 *
6878 * \sa limSendSaQueryResponseFrame
6879 *
6880 *
6881 * \param pMac The global tpAniSirGlobal object
6882 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006883 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006884 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006885 * \param peer The Mac address of the AP to which this action frame is addressed
6886 *
6887 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 *
6889 * \return eSIR_SUCCESS if setup completes successfully
6890 * eSIR_FAILURE is some problem is encountered
6891 */
6892
Chet Lanctot186b5732013-03-18 10:26:30 -07006893tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006894tSirMacAddr peer,tpPESession psessionEntry)
6895{
6896
Chet Lanctot186b5732013-03-18 10:26:30 -07006897 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006898 tANI_U8 *pFrame;
6899 tSirRetStatus nSirStatus;
6900 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006901 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 void *pPacket;
6903 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306904 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006905
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306906 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006907 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6908 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 action: 0 --> SA query request action frame
6910 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006911 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6912 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006914 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006915
Chet Lanctot186b5732013-03-18 10:26:30 -07006916 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6917 if ( DOT11F_FAILED( nStatus ) )
6918 {
6919 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6920 "or a SA Query Response (0x%08x)."),
6921 nStatus );
6922 // We'll fall back on the worst case scenario:
6923 nPayload = sizeof( tDot11fSaQueryRsp );
6924 }
6925 else if ( DOT11F_WARNED( nStatus ) )
6926 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006927 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006928 "the packed size for an SA Query Response"
6929 " (0x%08x)."), nStatus );
6930 }
6931
Jeff Johnson295189b2012-06-20 16:38:30 -07006932 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6933 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6934 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6935 {
6936 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006937 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 return eSIR_FAILURE;
6939 }
6940
6941 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306942 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006943
Chet Lanctot186b5732013-03-18 10:26:30 -07006944 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006945 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006946 pFrame,
6947 SIR_MAC_MGMT_FRAME,
6948 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006949 peer, psessionEntry->selfMacAddr );
6950 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006951 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006952
Chet Lanctot186b5732013-03-18 10:26:30 -07006953 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6955
Chet Lanctot186b5732013-03-18 10:26:30 -07006956 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006957
Chet Lanctot186b5732013-03-18 10:26:30 -07006958 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6959 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006960 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006961
Chet Lanctot186b5732013-03-18 10:26:30 -07006962 // Pack 11w SA query response frame
6963 nStatus = dot11fPackSaQueryRsp( pMac,
6964 &frm,
6965 pFrame + sizeof( tSirMacMgmtHdr ),
6966 nPayload,
6967 &nPayload );
6968
6969 if ( DOT11F_FAILED( nStatus ))
6970 {
6971 limLog( pMac, LOGE,
6972 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6973 nStatus );
6974 // FIXME - Need to convert to tSirRetStatus
6975 nSirStatus = eSIR_FAILURE;
6976 goto returnAfterError;
6977 }
6978 else if ( DOT11F_WARNED( nStatus ))
6979 {
6980 limLog( pMac, LOGW,
6981 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6982 nStatus);
6983 }
6984
6985 limLog( pMac, LOG1,
6986 FL( "Sending a SA Query Response to " ));
6987 limPrintMacAddr( pMac, peer, LOGW );
6988
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006989 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006990#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006991 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6992 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006993#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006994 )
6995 {
6996 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6997 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006998
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306999 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
7000 psessionEntry->peSessionId,
7001 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007002 halstatus = halTxFrame( pMac,
7003 pPacket,
7004 (tANI_U16) nBytes,
7005 HAL_TXRX_FRM_802_11_MGMT,
7006 ANI_TXDIR_TODS,
7007 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
7008 limTxComplete,
7009 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05307010 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
7011 psessionEntry->peSessionId,
7012 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007013 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07007014 {
7015 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
7016 nSirStatus = eSIR_FAILURE;
7017 //Pkt will be freed up by the callback
7018 return nSirStatus;
7019 }
7020 else {
7021 return eSIR_SUCCESS;
7022 }
7023
7024returnAfterError:
7025 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
7026 return nSirStatus;
7027} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07007028#endif
Abhishek Singh00b71972016-01-07 10:51:04 +05307029
7030#ifdef WLAN_FEATURE_RMC
7031tSirRetStatus
7032limSendRMCActionFrame(tpAniSirGlobal pMac,
7033 tSirMacAddr peerMacAddr,
7034 tSirRMCInfo *pRMC,
7035 tpPESession psessionEntry)
7036{
7037 tSirRetStatus nSirStatus;
7038 tANI_U8 *pFrame;
7039 tDot11fRMC RMC;
7040 tANI_U32 nPayload, nBytes, nStatus;
7041 tpSirMacMgmtHdr pMacHdr;
7042 void *pPacket;
7043 eHalStatus halstatus;
7044 tANI_U8 txFlag = 0;
7045 tANI_U8 MagicCode[] = { 0x4f, 0x58, 0x59, 0x47, 0x45, 0x4e };
7046
7047 if (NULL == psessionEntry)
7048 {
7049 return eSIR_FAILURE;
7050 }
7051
7052 vos_mem_set(( tANI_U8* )&RMC, sizeof( RMC ), 0);
7053
7054 RMC.Action.action = pRMC->action;
7055 RMC.RMCDialogToken.token = pRMC->dialogToken;
7056 RMC.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
7057 RMC.RMCVersion.version = SIR_MAC_RMC_VER;
7058
7059 vos_mem_copy(&RMC.RMCOUI.oui, SIR_MAC_RMC_OUI, SIR_MAC_RMC_OUI_SIZE);
7060 vos_mem_copy(&RMC.MagicCode.magic, MagicCode, sizeof(MagicCode));
7061
7062 vos_mem_copy(&RMC.Ruler.mac, pRMC->mcastRuler, sizeof(tSirMacAddr));
7063
7064 nStatus = dot11fGetPackedRMCSize( pMac, &RMC, &nPayload );
7065 if ( DOT11F_FAILED( nStatus ) )
7066 {
7067 limLog( pMac, LOGE, FL("Failed to calculate the packed size for "
7068 "an RMC (0x%08x)."),
7069 nStatus );
7070 // We'll fall back on the worst case scenario:
7071 nPayload = sizeof( tDot11fRMC );
7072 }
7073 else if ( DOT11F_WARNED( nStatus ) )
7074 {
7075 limLog( pMac, LOGW, FL("There were warnings while calculating "
7076 "the packed size for an RMC Action Frame"
7077 " (0x%08x)."), nStatus );
7078 }
7079
7080 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
7081
7082 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
7083 ( tANI_U16 )nBytes, ( void** ) &pFrame,
7084 ( void** ) &pPacket );
7085 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
7086 {
7087 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an RMC "
7088 "Action Frame."), nBytes );
7089 return eSIR_FAILURE;
7090 }
7091
7092 // Paranoia:
7093 vos_mem_set( pFrame, nBytes, 0 );
7094
7095 // Next, we fill out the buffer descriptor:
7096 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
7097 SIR_MAC_MGMT_ACTION, peerMacAddr,
7098 psessionEntry->selfMacAddr);
7099 if ( eSIR_SUCCESS != nSirStatus )
7100 {
7101 limLog( pMac, LOGE, FL("Failed to populate the buffer descriptor "
7102 "for an RMC Action Frame (%d)."),
7103 nSirStatus );
7104 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
7105 ( void* ) pFrame, ( void* ) pPacket );
7106 return nSirStatus;
7107 }
7108
7109 // Update A3 with the BSSID
7110 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
7111 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
7112
7113 // That done, pack the struct:
7114 nStatus = dot11fPackRMC( pMac, &RMC,
7115 pFrame + sizeof(tSirMacMgmtHdr),
7116 nPayload, &nPayload );
7117 if ( DOT11F_FAILED( nStatus ) )
7118 {
7119 limLog( pMac, LOGE, FL("Failed to pack an RMC "
7120 "(0x%08x)."),
7121 nStatus );
7122 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame,
7123 ( void* ) pPacket );
7124 return eSIR_FAILURE;
7125 }
7126 else if ( DOT11F_WARNED( nStatus ) )
7127 {
7128 limLog( pMac, LOGW, FL("There were warnings while packing "
7129 "an RMC (0x%08x)."), nStatus );
7130 }
7131
7132 limLog( pMac, LOG1, FL("Sending an RMC Action frame to "
7133 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMacAddr));
7134
7135 /*
7136 * With this masking, RMC action frames will be sent
7137 * at self-sta rates for both 2G and 5G bands.
7138 */
7139 txFlag |= HAL_USE_SELF_STA_REQUESTED_MASK;
7140
7141 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
7142 psessionEntry->peSessionId,
7143 pMacHdr->fc.subType));
7144 // Queue RMC Action frame in high priority WQ
7145 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
7146 HAL_TXRX_FRM_802_11_MGMT,
7147 ANI_TXDIR_TODS,
7148 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
7149 limTxComplete, pFrame, txFlag );
7150 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
7151 psessionEntry->peSessionId,
7152 halstatus));
7153 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
7154 {
7155 limLog( pMac, LOGE, FL( "*** Could not send an RMC Action frame"
7156 " (%X) ***" ), halstatus );
7157 //Pkt will be freed up by the callback
7158 return eSIR_FAILURE;
7159 }
7160
7161 return eSIR_SUCCESS;
7162
7163} // End limSendRMCActionFrame.
7164
7165#endif /* WLAN_FEATURE_RMC */