blob: 900565fc6012afc64c019eeb881d5eab532c5d48 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Satyanarayana Dash6f438272015-03-03 18:01:06 +05302 * Copyright (c) 2012-2015 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 Singh6d5d29c2014-07-03 14:25:22 +0530429 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700430 }
431 } else {
432 if (IS_DOT11_MODE_VHT(dot11mode))
433 {
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530434 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700435 }
436 }
437#endif
438
Jeff Johnson295189b2012-06-20 16:38:30 -0700439
440 // That's it-- now we pack it. First, how much space are we going to
441 // need?
442 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
443 if ( DOT11F_FAILED( nStatus ) )
444 {
445 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700446 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 // We'll fall back on the worst case scenario:
448 nPayload = sizeof( tDot11fProbeRequest );
449 }
450 else if ( DOT11F_WARNED( nStatus ) )
451 {
452 limLog( pMac, LOGW, FL("There were warnings while calculating"
453 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700454 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 }
456
457 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
458
459 // Ok-- try to allocate some memory:
460 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
461 ( tANI_U16 )nBytes, ( void** ) &pFrame,
462 ( void** ) &pPacket );
463 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
464 {
465 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700466 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 return eSIR_MEM_ALLOC_FAILED;
468 }
469
470 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530471 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700472
473 // Next, we fill out the buffer descriptor:
474 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530475 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 if ( eSIR_SUCCESS != nSirStatus )
477 {
478 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700479 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 nSirStatus );
481 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
482 ( void* ) pFrame, ( void* ) pPacket );
483 return nSirStatus; // allocated!
484 }
485
486 // That done, pack the Probe Request:
487 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
488 sizeof( tSirMacMgmtHdr ),
489 nPayload, &nPayload );
490 if ( DOT11F_FAILED( nStatus ) )
491 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700492 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 nStatus );
494 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
495 return eSIR_FAILURE; // allocated!
496 }
497 else if ( DOT11F_WARNED( nStatus ) )
498 {
499 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800500 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 }
502
503 // Append any AddIE if present.
504 if( nAdditionalIELen )
505 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530506 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 pAdditionalIE, nAdditionalIELen );
508 nPayload += nAdditionalIELen;
509 }
510
511 /* If this probe request is sent during P2P Search State, then we need
512 * to send it at OFDM rate.
513 */
514 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
516 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530517 /* For unicast probe req mgmt from Join function
518 we don't set above variables. So we need to add
519 one more check whether it is pePersona is P2P_CLIENT or not */
520 || ( ( psessionEntry != NULL ) &&
521 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 )
523 {
524 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
525 }
526
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +0530527 if( ( psessionEntry != NULL ) && ( psessionEntry->is11Gonly == true ) &&
528 ( !IS_BROADCAST_MAC(bssid) ) ){
529 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
530 }
531
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
533 HAL_TXRX_FRM_802_11_MGMT,
534 ANI_TXDIR_TODS,
535 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
536 limTxComplete, pFrame, txFlag );
537 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
538 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700539 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 //Pkt will be freed up by the callback
541 return eSIR_FAILURE;
542 }
543
544 return eSIR_SUCCESS;
545} // End limSendProbeReqMgmtFrame.
546
Jeff Johnson295189b2012-06-20 16:38:30 -0700547tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
548 tANI_U8* addIE, tANI_U16 *addnIELen,
549 tANI_U8 probeReqP2pIe)
550{
551 /* If Probe request doesn't have P2P IE, then take out P2P IE
552 from additional IE */
553 if(!probeReqP2pIe)
554 {
555 tANI_U8* tempbuf = NULL;
556 tANI_U16 tempLen = 0;
557 int left = *addnIELen;
558 v_U8_t *ptr = addIE;
559 v_U8_t elem_id, elem_len;
560
561 if(NULL == addIE)
562 {
563 PELOGE(limLog(pMac, LOGE,
564 FL(" NULL addIE pointer"));)
565 return eSIR_FAILURE;
566 }
567
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530568 tempbuf = vos_mem_malloc(left);
569 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 {
571 PELOGE(limLog(pMac, LOGE,
572 FL("Unable to allocate memory to store addn IE"));)
573 return eSIR_MEM_ALLOC_FAILED;
574 }
575
576 while(left >= 2)
577 {
578 elem_id = ptr[0];
579 elem_len = ptr[1];
580 left -= 2;
581 if(elem_len > left)
582 {
583 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700584 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530586 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 return eSIR_FAILURE;
588 }
589 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
590 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
591 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530592 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 tempLen += (elem_len + 2);
594 }
595 left -= elem_len;
596 ptr += (elem_len + 2);
597 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530598 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530600 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 }
602 return eSIR_SUCCESS;
603}
Jeff Johnson295189b2012-06-20 16:38:30 -0700604
605void
606limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
607 tSirMacAddr peerMacAddr,
608 tpAniSSID pSsid,
609 short nStaId,
610 tANI_U8 nKeepAlive,
611 tpPESession psessionEntry,
612 tANI_U8 probeReqP2pIe)
613{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700614 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530615 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530616 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530617 tpSirMacMgmtHdr pMacHdr;
618 tANI_U8 *pFrame;
619 void *pPacket;
620 eHalStatus halstatus;
621 tANI_U32 addnIEPresent;
622 tANI_U32 addnIE1Len=0;
623 tANI_U32 addnIE2Len=0;
624 tANI_U32 addnIE3Len=0;
625 tANI_U16 totalAddnIeLen = 0;
626 tANI_U32 wpsApEnable=0, tmp;
627 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530629 tANI_U8 *pP2pIe = NULL;
630 tANI_U8 noaLen = 0;
631 tANI_U8 total_noaLen = 0;
632 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530634 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700635 tDot11fIEExtCap extractedExtCap;
636 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530637 tANI_U32 nBytes = 0;
638
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
640 {
641 return; // in this case.
642 }
643
644 if(NULL == psessionEntry)
645 {
646 return;
647 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530648
649 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
650 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700651 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530652 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700653 return;
654 }
655
Girish Gowli0e826792014-05-17 17:56:44 +0530656 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
657
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 // Fill out 'frm', after which we'll just hand the struct off to
659 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530660 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700661
662 // Timestamp to be updated by TFP, below.
663
664 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
666 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700667 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 }
669 else
670 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800671 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
672 if (eSIR_SUCCESS != nSirStatus)
673 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700674 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800675 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530676 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800677 return;
678 }
679 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800680 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700681
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700682 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
683 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700685 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700686
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700687 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
688 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700689
Jeff Johnson295189b2012-06-20 16:38:30 -0700690
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
692 {
693 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
694 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700695 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 }
697 }
698 else
699 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800700 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700701 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700702
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800703 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700704
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800705 if (wpsApEnable)
706 {
707 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
708 }
709
710 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
711 {
712 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
713 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
714 }
715
716 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
717 {
718 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
719 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
720 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700722
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700723 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
724 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726
727 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700728 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700729
730
731 // N.B. In earlier implementations, the RSN IE would be placed in
732 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
733 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700734 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700735
736 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700737 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700738 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700739 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700740 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530742
743#ifdef WLAN_FEATURE_AP_HT40_24G
744 /* Populate Overlapping BSS Scan Parameters IEs,
745 * when operating in HT40 in 2.4GHz.
746 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +0530747 if ((pMac->roam.configParam.apHT40_24GEnabled)
748 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530749 {
750 PopulateDot11fOBSSScanParameters( pMac, &pFrm->OBSSScanParameters,
751 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530752 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
753 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
754 * Mode in 40 MHz bit in HT capablity.
755 */
756 pFrm->HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530757 }
758#endif
759
760 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
761
Jeff Johnsone7245742012-09-05 17:12:55 -0700762#ifdef WLAN_FEATURE_11AC
763 if(psessionEntry->vhtCapability)
764 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800765 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530766 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps, eSIR_TRUE );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700767 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700768 // we do not support multi users yet
769 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
770 }
771#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700772
Sandeep Puligilla60342762014-01-30 21:05:37 +0530773
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530774 if ( psessionEntry->pLimStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 {
776 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700777 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700778 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
779 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 }
781
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700782 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700783
784#if defined(FEATURE_WLAN_WAPI)
785 if( psessionEntry->pLimStartBssReq )
786 {
787 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700788 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 }
790
791#endif // defined(FEATURE_WLAN_WAPI)
792
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 if( pMac->lim.gpLimRemainOnChanReq )
795 {
796 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
797 }
798 //Only use CFG for non-listen mode. This CFG is not working for concurrency
799 //In listening mode, probe rsp IEs is passed in the message from SME to PE
800 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 {
802
803 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
804 &addnIEPresent) != eSIR_SUCCESS)
805 {
806 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530807 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 return;
809 }
810 }
811
812 if (addnIEPresent)
813 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530814
815 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
816 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 {
818 PELOGE(limLog(pMac, LOGE,
819 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530820 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 return;
822 }
823
824 //Probe rsp IE available
825 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
826 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
827 {
828 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530829 vos_mem_free(addIE);
830 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 return;
832 }
833 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
834 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
835 {
836 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
837 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
838 &addnIE1Len) )
839 {
840 limLog(pMac, LOGP,
841 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530842 vos_mem_free(addIE);
843 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 return;
845 }
846 }
847
848 //Probe rsp IE available
849 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
850 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
851 {
852 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530853 vos_mem_free(addIE);
854 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 return;
856 }
857 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
858 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
859 {
860 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
861 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
862 &addnIE2Len) )
863 {
864 limLog(pMac, LOGP,
865 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530866 vos_mem_free(addIE);
867 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 return;
869 }
870 }
871
872 //Probe rsp IE available
873 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
874 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
875 {
876 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530877 vos_mem_free(addIE);
878 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 return;
880 }
881 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
882 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
883 {
884 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
885 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
886 &addIE[addnIE1Len + addnIE2Len],
887 &addnIE3Len) )
888 {
889 limLog(pMac, LOGP,
890 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530891 vos_mem_free(addIE);
892 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 return;
894 }
895 }
896 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
897
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
899 {
900 limLog(pMac, LOGP,
901 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530902 vos_mem_free(addIE);
903 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 return;
905 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700906
Kalikinkar dhara205da782014-03-21 15:49:32 -0700907 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
908 addIE,
909 &totalAddnIeLen,
910 &extractedExtCap );
911 if(eSIR_SUCCESS != nSirStatus )
912 {
913 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
914 limLog(pMac, LOG1,
915 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
916 }
917
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 nBytes = nBytes + totalAddnIeLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530919 limLog(pMac, LOG1,
920 FL("probe rsp packet size is %d "), nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 if (probeReqP2pIe)
922 {
923 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
924 if (pP2pIe != NULL)
925 {
926 //get NoA attribute stream P2P IE
927 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
928 if (noaLen != 0)
929 {
930 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
931 &noaStream[0], noaLen);
932 nBytes = nBytes + total_noaLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530933 limLog(pMac, LOG1,
934 FL("p2p probe rsp packet size is %d, noalength is %d"),
935 nBytes, total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 }
937 }
938 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 }
940
c_hpothubcd78652014-04-28 22:31:08 +0530941 /*merge ExtCap IE*/
942 if (extractedExtCapFlag && extractedExtCap.present)
943 {
944 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
945 }
946
947 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
948 if ( DOT11F_FAILED( nStatus ) )
949 {
950 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
951 "or a Probe Response (0x%08x)."),
952 nStatus );
953 // We'll fall back on the worst case scenario:
954 nPayload = sizeof( tDot11fProbeResponse );
955 }
956 else if ( DOT11F_WARNED( nStatus ) )
957 {
958 limLog( pMac, LOGW, FL("There were warnings while calculating"
959 "the packed size for a Probe Response "
960 "(0x%08x)."), nStatus );
961 }
962
963 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
964
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
966 ( tANI_U16 )nBytes, ( void** ) &pFrame,
967 ( void** ) &pPacket );
968 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
969 {
970 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700971 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 if ( addIE != NULL )
973 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530974 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530976 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 return;
978 }
979
980 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530981 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700982
983 // Next, we fill out the buffer descriptor:
984 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
985 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
986 if ( eSIR_SUCCESS != nSirStatus )
987 {
988 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700989 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 nSirStatus );
991 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
992 ( void* ) pFrame, ( void* ) pPacket );
993 if ( addIE != NULL )
994 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530995 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530997 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 return;
999 }
1000
1001 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1002
1003 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1004
1005 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001006 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 nPayload, &nPayload );
1008 if ( DOT11F_FAILED( nStatus ) )
1009 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001010 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 nStatus );
1012 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1013 if ( addIE != NULL )
1014 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301015 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301017 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 return; // allocated!
1019 }
1020 else if ( DOT11F_WARNED( nStatus ) )
1021 {
1022 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001023 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 }
1025
1026 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1027 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1028
1029 pMac->sys.probeRespond++;
1030
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 if( pMac->lim.gpLimRemainOnChanReq )
1032 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301033 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001036
1037 if ( addnIEPresent )
1038 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301039 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 if (noaLen != 0)
1042 {
Krunal Soni81b24262013-05-15 17:46:41 -07001043 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 {
1045 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301046 FL("Not able to insert NoA because of length constraint."
1047 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301048 vos_mem_free(addIE);
1049 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001050 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1051 ( void* ) pFrame, ( void* ) pPacket );
1052 return;
1053 }
1054 else
1055 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301056 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001057 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 }
1059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001060
1061 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1063 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 )
1065 {
1066 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1067 }
1068
1069 // Queue Probe Response frame in high priority WQ
1070 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1071 ( tANI_U16 ) nBytes,
1072 HAL_TXRX_FRM_802_11_MGMT,
1073 ANI_TXDIR_TODS,
1074 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1075 limTxComplete, pFrame, txFlag );
1076 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1077 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001078 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 //Pkt will be freed up by the callback
1080 }
1081
1082 if ( addIE != NULL )
1083 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301084 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 }
1086
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301087 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001088 return;
1089
1090
Jeff Johnson295189b2012-06-20 16:38:30 -07001091} // End limSendProbeRspMgmtFrame.
1092
1093void
1094limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1095 tSirMacAddr peerMacAddr,
1096 tSirAddtsReqInfo *pAddTS,
1097 tpPESession psessionEntry)
1098{
1099 tANI_U16 i;
1100 tANI_U8 *pFrame;
1101 tSirRetStatus nSirStatus;
1102 tDot11fAddTSRequest AddTSReq;
1103 tDot11fWMMAddTSRequest WMMAddTSReq;
1104 tANI_U32 nPayload, nBytes, nStatus;
1105 tpSirMacMgmtHdr pMacHdr;
1106 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001107#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 tANI_U32 phyMode;
1109#endif
1110 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301111 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001112
1113 if(NULL == psessionEntry)
1114 {
1115 return;
1116 }
1117
1118 if ( ! pAddTS->wmeTspecPresent )
1119 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301120 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001121
1122 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1123 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1124 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1125 if ( pAddTS->lleTspecPresent )
1126 {
1127 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1128 }
1129 else
1130 {
1131 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1132 }
1133
1134 if ( pAddTS->lleTspecPresent )
1135 {
1136 AddTSReq.num_WMMTCLAS = 0;
1137 AddTSReq.num_TCLAS = pAddTS->numTclas;
1138 for ( i = 0; i < pAddTS->numTclas; ++i)
1139 {
1140 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1141 &AddTSReq.TCLAS[i] );
1142 }
1143 }
1144 else
1145 {
1146 AddTSReq.num_TCLAS = 0;
1147 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1148 for ( i = 0; i < pAddTS->numTclas; ++i)
1149 {
1150 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1151 &AddTSReq.WMMTCLAS[i] );
1152 }
1153 }
1154
1155 if ( pAddTS->tclasProcPresent )
1156 {
1157 if ( pAddTS->lleTspecPresent )
1158 {
1159 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1160 AddTSReq.TCLASSPROC.present = 1;
1161 }
1162 else
1163 {
1164 AddTSReq.WMMTCLASPROC.version = 1;
1165 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1166 AddTSReq.WMMTCLASPROC.present = 1;
1167 }
1168 }
1169
1170 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1171 if ( DOT11F_FAILED( nStatus ) )
1172 {
1173 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001174 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 nStatus );
1176 // We'll fall back on the worst case scenario:
1177 nPayload = sizeof( tDot11fAddTSRequest );
1178 }
1179 else if ( DOT11F_WARNED( nStatus ) )
1180 {
1181 limLog( pMac, LOGW, FL("There were warnings while calculating"
1182 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001183 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 }
1185 }
1186 else
1187 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301188 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001189
1190 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1191 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1192 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1193
1194 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1195 WMMAddTSReq.StatusCode.statusCode = 0;
1196
1197 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001198#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 limGetPhyMode(pMac, &phyMode, psessionEntry);
1200
1201 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1202 {
1203 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1204 }
1205 else
1206 {
1207 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1208 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001209 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001210#endif
1211 // fillWmeTspecIE
1212
1213 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1214 if ( DOT11F_FAILED( nStatus ) )
1215 {
1216 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001217 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 nStatus );
1219 // We'll fall back on the worst case scenario:
1220 nPayload = sizeof( tDot11fAddTSRequest );
1221 }
1222 else if ( DOT11F_WARNED( nStatus ) )
1223 {
1224 limLog( pMac, LOGW, FL("There were warnings while calculating"
1225 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001226 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 }
1228 }
1229
1230 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1231
1232 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1233 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1234 ( void** ) &pPacket );
1235 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1236 {
1237 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001238 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 return;
1240 }
1241
1242 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301243 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001244
1245 // Next, we fill out the buffer descriptor:
1246 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1247 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1248 if ( eSIR_SUCCESS != nSirStatus )
1249 {
1250 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001251 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 nSirStatus );
1253 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1254 ( void* ) pFrame, ( void* ) pPacket );
1255 return;
1256 }
1257
1258 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1259
1260 #if 0
1261 cfgLen = SIR_MAC_ADDR_LENGTH;
1262 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1263 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1264 {
1265 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001266 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1268 ( void* ) pFrame, ( void* ) pPacket );
1269 return;
1270 }
1271 #endif //TO SUPPORT BT-AMP
1272
1273 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1274
Chet Lanctot186b5732013-03-18 10:26:30 -07001275#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001276 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001277#endif
1278
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 // That done, pack the struct:
1280 if ( ! pAddTS->wmeTspecPresent )
1281 {
1282 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1283 pFrame + sizeof(tSirMacMgmtHdr),
1284 nPayload, &nPayload );
1285 if ( DOT11F_FAILED( nStatus ) )
1286 {
1287 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001288 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 nStatus );
1290 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1291 return; // allocated!
1292 }
1293 else if ( DOT11F_WARNED( nStatus ) )
1294 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001295 limLog( pMac, LOGW, FL("There were warnings while packing "
1296 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 }
1298 }
1299 else
1300 {
1301 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1302 pFrame + sizeof(tSirMacMgmtHdr),
1303 nPayload, &nPayload );
1304 if ( DOT11F_FAILED( nStatus ) )
1305 {
1306 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001307 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 nStatus );
1309 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1310 return; // allocated!
1311 }
1312 else if ( DOT11F_WARNED( nStatus ) )
1313 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001314 limLog( pMac, LOGW, FL("There were warnings while packing "
1315 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 }
1317 }
1318
Abhishek Singh127a8442014-12-15 17:31:27 +05301319 limLog( pMac, LOG1, FL("Sending an Add TS Request frame to ") );
1320 limPrintMacAddr( pMac, peerMacAddr, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001321
1322 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1324 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 )
1326 {
1327 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1328 }
1329
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301330 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1331 psessionEntry->peSessionId,
1332 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 // Queue Addts Response frame in high priority WQ
1334 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1335 HAL_TXRX_FRM_802_11_MGMT,
1336 ANI_TXDIR_TODS,
1337 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1338 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301339 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1340 psessionEntry->peSessionId,
1341 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1343 {
1344 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001345 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 //Pkt will be freed up by the callback
1347 }
1348
1349} // End limSendAddtsReqActionFrame.
1350
Jeff Johnson295189b2012-06-20 16:38:30 -07001351
1352
1353void
1354limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1355 tANI_U16 statusCode,
1356 tANI_U16 aid,
1357 tSirMacAddr peerMacAddr,
1358 tANI_U8 subType,
1359 tpDphHashNode pSta,tpPESession psessionEntry)
1360{
1361 static tDot11fAssocResponse frm;
1362 tANI_U8 *pFrame, *macAddr;
1363 tpSirMacMgmtHdr pMacHdr;
1364 tSirRetStatus nSirStatus;
1365 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1366 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301367 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 void *pPacket;
1369 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301370 tUpdateBeaconParams beaconParams;
1371 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 tANI_U32 addnIEPresent = false;
1373 tANI_U32 addnIELen=0;
1374 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1375 tpSirAssocReq pAssocReq = NULL;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301376 tANI_U16 addStripoffIELen = 0;
1377 tDot11fIEExtCap extractedExtCap;
1378 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301379 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001380
Chet Lanctot8cecea22014-02-11 19:09:36 -08001381#ifdef WLAN_FEATURE_11W
1382 tANI_U32 retryInterval;
1383 tANI_U32 maxRetries;
1384#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001385
1386 if(NULL == psessionEntry)
1387 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301388 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 return;
1390 }
1391
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301392 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
1394 limGetQosMode(psessionEntry, &qosMode);
1395 limGetWmeMode(psessionEntry, &wmeMode);
1396
1397 // An Add TS IE is added only if the AP supports it and the requesting
1398 // STA sent a traffic spec.
1399 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1400
1401 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1402
1403 frm.Status.status = statusCode;
1404
1405 frm.AID.associd = aid | LIM_AID_MASK;
1406
1407 if ( NULL == pSta )
1408 {
1409 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1410 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1411 }
1412 else
1413 {
1414 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1415 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1416 }
1417
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1419 {
1420 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1421 {
1422 pAssocReq =
1423 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1425 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1426 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 }
1429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001430
1431 if ( NULL != pSta )
1432 {
1433 if ( eHAL_SET == qosMode )
1434 {
1435 if ( pSta->lleEnabled )
1436 {
1437 lleMode = 1;
1438 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1439 {
1440 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1441
1442// FramesToDo:...
1443// if ( fAddTS )
1444// {
1445// tANI_U8 *pAf = pBody;
1446// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1447// tANI_U32 tlen;
1448// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1449// &tlen, bufLen - frameLen);
1450// } // End if on Add TS.
1451 }
1452 } // End if on .11e enabled in 'pSta'.
1453 } // End if on QOS Mode on.
1454
1455 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1456 {
1457 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1458 {
1459
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001461
1462 if ( pSta->wsmEnabled )
1463 {
1464 PopulateDot11fWMMCaps(&frm.WMMCaps );
1465 }
1466 }
1467 }
1468
1469 if ( pSta->aniPeer )
1470 {
1471 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1472 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1473 {
1474 edcaInclude = 1;
1475 }
1476
1477 } // End if on Airgo peer.
1478
1479 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001480 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001482 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301483 /*
1484 *Check the STA capability and update the HTCaps accordingly
1485 */
1486 frm.HTCaps.supportedChannelWidthSet =
1487 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1488 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1489
1490 if (!frm.HTCaps.supportedChannelWidthSet)
1491 frm.HTCaps.shortGI40MHz = 0;
1492
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001495
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301496#ifdef WLAN_FEATURE_AP_HT40_24G
1497 /* Populate Overlapping BSS Scan Parameters IEs,
1498 * when operating in HT40 in 2.4GHz.
1499 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +05301500 if ((pMac->roam.configParam.apHT40_24GEnabled)
1501 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301502 {
1503 PopulateDot11fOBSSScanParameters( pMac, &frm.OBSSScanParameters,
1504 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +05301505 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
1506 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
1507 * Mode in 40 MHz bit in HT capablity.
1508 */
1509 frm.HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301510 }
1511#endif
1512
1513 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001514#ifdef WLAN_FEATURE_11AC
1515 if( pSta->mlmStaContext.vhtCapability &&
1516 psessionEntry->vhtCapability )
1517 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001518 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301519 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07001520 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
1521 }
1522#endif
1523
Chet Lanctot8cecea22014-02-11 19:09:36 -08001524#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301525 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1526 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001527 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1528 &maxRetries ) != eSIR_SUCCESS )
1529 limLog( pMac, LOGE,
1530 FL("Could not retrieve PMF SA Query maximum retries value") );
1531 else
1532 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1533 &retryInterval ) != eSIR_SUCCESS)
1534 limLog( pMac, LOGE,
1535 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301536 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001537 PopulateDot11fTimeoutInterval(
1538 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1539 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301540 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001541#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301542 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001543
Chet Lanctot8cecea22014-02-11 19:09:36 -08001544 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1547 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1548 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001550
1551 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1552 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1553
1554 beaconParams.bssIdx = psessionEntry->bssIdx;
1555
1556 //Send message to HAL about beacon parameter change.
1557 if(beaconParams.paramChangeBitmap)
1558 {
1559 schSetFixedBeaconFields(pMac,psessionEntry);
1560 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1561 }
1562
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 if ( pAssocReq != NULL )
1564 {
1565 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1566 &addnIEPresent) != eSIR_SUCCESS)
1567 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301568 limLog(pMac, LOGP, FL("Unable to get "
1569 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 return;
1571 }
1572
1573 if (addnIEPresent)
1574 {
1575 //Assoc rsp IE available
1576 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1577 &addnIELen) != eSIR_SUCCESS)
1578 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301579 limLog(pMac, LOGP, FL("Unable to get "
1580 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 return;
1582 }
1583
1584 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1585 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1586 {
1587 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1588 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1589 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301590
1591 vos_mem_set(( tANI_U8* )&extractedExtCap,
1592 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301593 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301594 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1595 &addIE[0],
1596 &addStripoffIELen,
1597 &extractedExtCap );
1598 if(eSIR_SUCCESS != nSirStatus)
1599 {
1600 limLog(pMac, LOG1,
1601 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1602 }
1603 else
1604 {
1605 addnIELen = addStripoffIELen;
1606 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 nBytes = nBytes + addnIELen;
1609 }
1610 }
1611 }
1612 }
1613
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301614 /* merge the ExtCap struct*/
1615 if (extractedExtCapFlag && extractedExtCap.present)
1616 {
1617 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1618 }
1619
c_hpothubcd78652014-04-28 22:31:08 +05301620 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1621 if ( DOT11F_FAILED( nStatus ) )
1622 {
1623 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1624 "or an Association Response (0x%08x)."),
1625 nStatus );
1626 return;
1627 }
1628 else if ( DOT11F_WARNED( nStatus ) )
1629 {
1630 limLog( pMac, LOGW, FL("There were warnings while calculating "
1631 "the packed size for an Association Re"
1632 "sponse (0x%08x)."), nStatus );
1633 }
1634
1635 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1636
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1638 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1639 ( void** ) &pPacket );
1640 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1641 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001642 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 return;
1644 }
1645
1646 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301647 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001648
1649 // Next, we fill out the buffer descriptor:
1650 nSirStatus = limPopulateMacHeader( pMac,
1651 pFrame,
1652 SIR_MAC_MGMT_FRAME,
1653 ( LIM_ASSOC == subType ) ?
1654 SIR_MAC_MGMT_ASSOC_RSP :
1655 SIR_MAC_MGMT_REASSOC_RSP,
1656 peerMacAddr,psessionEntry->selfMacAddr);
1657 if ( eSIR_SUCCESS != nSirStatus )
1658 {
1659 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001660 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 nSirStatus );
1662 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1663 ( void* ) pFrame, ( void* ) pPacket );
1664 return;
1665 }
1666
1667 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1668
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1670
1671 nStatus = dot11fPackAssocResponse( pMac, &frm,
1672 pFrame + sizeof( tSirMacMgmtHdr ),
1673 nPayload, &nPayload );
1674 if ( DOT11F_FAILED( nStatus ) )
1675 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301676 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1677 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1679 ( void* ) pFrame, ( void* ) pPacket );
1680 return; // allocated!
1681 }
1682 else if ( DOT11F_WARNED( nStatus ) )
1683 {
1684 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001685 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 }
1687
1688 macAddr = pMacHdr->da;
1689
1690 if (subType == LIM_ASSOC)
1691 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301692 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 FL("*** Sending Assoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301694 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 }
1696 else{
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301697 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 FL("*** Sending ReAssoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301699 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301701 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001702
1703 if ( addnIEPresent )
1704 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301705 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 }
1707
1708 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1710 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 )
1712 {
1713 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1714 }
1715
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301716 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1717 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1718 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1719
1720 txFlag |= HAL_USE_FW_IN_TX_PATH;
1721
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301722 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1723 psessionEntry->peSessionId,
1724 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301725
1726 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
1727 {
1728 limLog(pMac, LOG1, FL("Re/AssocRsp - txBdToken %u"), pMac->lim.txBdToken);
1729 /// Queue Association Response frame in high priority WQ
1730 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1731 HAL_TXRX_FRM_802_11_MGMT,
1732 ANI_TXDIR_TODS,
1733 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1734 limTxComplete, pFrame, limTxBdComplete,
1735 txFlag, pMac->lim.txBdToken );
1736 pMac->lim.txBdToken++;
1737 }
1738 else
1739 {
1740 /// Queue Association Response frame in high priority WQ
1741 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1742 HAL_TXRX_FRM_802_11_MGMT,
1743 ANI_TXDIR_TODS,
1744 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1745 limTxComplete, pFrame, txFlag );
1746 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301747 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1748 psessionEntry->peSessionId,
1749 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1751 {
1752 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001753 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 nSirStatus);
1755
1756 //Pkt will be freed up by the callback
1757 }
1758
1759 // update the ANI peer station count
1760 //FIXME_PROTECTION : take care of different type of station
1761 // counter inside this function.
1762 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1763
1764} // End limSendAssocRspMgmtFrame.
1765
1766
1767
1768void
1769limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1770 tSirMacAddr peer,
1771 tANI_U16 nStatusCode,
1772 tSirAddtsReqInfo *pAddTS,
1773 tSirMacScheduleIE *pSchedule,
1774 tpPESession psessionEntry)
1775{
1776 tANI_U8 *pFrame;
1777 tpSirMacMgmtHdr pMacHdr;
1778 tDot11fAddTSResponse AddTSRsp;
1779 tDot11fWMMAddTSResponse WMMAddTSRsp;
1780 tSirRetStatus nSirStatus;
1781 tANI_U32 i, nBytes, nPayload, nStatus;
1782 void *pPacket;
1783 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301784 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785
1786 if(NULL == psessionEntry)
1787 {
1788 return;
1789 }
1790
1791 if ( ! pAddTS->wmeTspecPresent )
1792 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301793 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001794
1795 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1796 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1797 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1798 AddTSRsp.Status.status = nStatusCode;
1799
1800 // The TsDelay information element is only filled in for a specific
1801 // status code:
1802 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1803 {
1804 if ( pAddTS->wsmTspecPresent )
1805 {
1806 AddTSRsp.WMMTSDelay.version = 1;
1807 AddTSRsp.WMMTSDelay.delay = 10;
1808 AddTSRsp.WMMTSDelay.present = 1;
1809 }
1810 else
1811 {
1812 AddTSRsp.TSDelay.delay = 10;
1813 AddTSRsp.TSDelay.present = 1;
1814 }
1815 }
1816
1817 if ( pAddTS->wsmTspecPresent )
1818 {
1819 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1820 }
1821 else
1822 {
1823 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1824 }
1825
1826 if ( pAddTS->wsmTspecPresent )
1827 {
1828 AddTSRsp.num_WMMTCLAS = 0;
1829 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1830 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1831 {
1832 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1833 &AddTSRsp.TCLAS[i] );
1834 }
1835 }
1836 else
1837 {
1838 AddTSRsp.num_TCLAS = 0;
1839 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1840 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1841 {
1842 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1843 &AddTSRsp.WMMTCLAS[i] );
1844 }
1845 }
1846
1847 if ( pAddTS->tclasProcPresent )
1848 {
1849 if ( pAddTS->wsmTspecPresent )
1850 {
1851 AddTSRsp.WMMTCLASPROC.version = 1;
1852 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1853 AddTSRsp.WMMTCLASPROC.present = 1;
1854 }
1855 else
1856 {
1857 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1858 AddTSRsp.TCLASSPROC.present = 1;
1859 }
1860 }
1861
1862 // schedule element is included only if requested in the tspec and we are
1863 // using hcca (or both edca and hcca)
1864 // 11e-D8.0 is inconsistent on whether the schedule element is included
1865 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1866 // pg 46, line 17-18 says something else. So just include it and let the
1867 // sta figure it out
1868 if ((pSchedule != NULL) &&
1869 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1870 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1871 {
1872 if ( pAddTS->wsmTspecPresent )
1873 {
1874 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1875 }
1876 else
1877 {
1878 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1879 }
1880 }
1881
1882 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1883 if ( DOT11F_FAILED( nStatus ) )
1884 {
1885 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001886 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 nStatus );
1888 // We'll fall back on the worst case scenario:
1889 nPayload = sizeof( tDot11fAddTSResponse );
1890 }
1891 else if ( DOT11F_WARNED( nStatus ) )
1892 {
1893 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001894 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001895 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 }
1897 }
1898 else
1899 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301900 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001901
1902 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1903 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1904 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1905 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1906
1907 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1908
1909 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1910 if ( DOT11F_FAILED( nStatus ) )
1911 {
1912 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001913 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 nStatus );
1915 // We'll fall back on the worst case scenario:
1916 nPayload = sizeof( tDot11fWMMAddTSResponse );
1917 }
1918 else if ( DOT11F_WARNED( nStatus ) )
1919 {
1920 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001921 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001922 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 }
1924 }
1925
1926 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1927
1928 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1929 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1930 {
1931 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001932 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 return;
1934 }
1935
1936 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301937 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001938
1939 // Next, we fill out the buffer descriptor:
1940 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1941 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1942 if ( eSIR_SUCCESS != nSirStatus )
1943 {
1944 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001945 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 nSirStatus );
1947 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1948 return; // allocated!
1949 }
1950
1951 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1952
1953
1954 #if 0
1955 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1956 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1957 {
1958 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001959 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1961 return; // allocated!
1962 }
1963 #endif //TO SUPPORT BT-AMP
1964 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1965
Chet Lanctot186b5732013-03-18 10:26:30 -07001966#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001967 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001968#endif
1969
Jeff Johnson295189b2012-06-20 16:38:30 -07001970 // That done, pack the struct:
1971 if ( ! pAddTS->wmeTspecPresent )
1972 {
1973 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1974 pFrame + sizeof( tSirMacMgmtHdr ),
1975 nPayload, &nPayload );
1976 if ( DOT11F_FAILED( nStatus ) )
1977 {
1978 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001979 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 nStatus );
1981 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1982 return;
1983 }
1984 else if ( DOT11F_WARNED( nStatus ) )
1985 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001986 limLog( pMac, LOGW, FL("There were warnings while packing "
1987 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001988 }
1989 }
1990 else
1991 {
1992 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1993 pFrame + sizeof( tSirMacMgmtHdr ),
1994 nPayload, &nPayload );
1995 if ( DOT11F_FAILED( nStatus ) )
1996 {
1997 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001998 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 nStatus );
2000 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2001 return;
2002 }
2003 else if ( DOT11F_WARNED( nStatus ) )
2004 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002005 limLog( pMac, LOGW, FL("There were warnings while packing "
2006 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 }
2008 }
2009
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302010 limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 nStatusCode );
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302012 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002013
2014 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2016 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 )
2018 {
2019 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2020 }
2021
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302022 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2023 psessionEntry->peSessionId,
2024 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 // Queue the frame in high priority WQ:
2026 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2027 HAL_TXRX_FRM_802_11_MGMT,
2028 ANI_TXDIR_TODS,
2029 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2030 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302031 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2032 psessionEntry->peSessionId,
2033 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2035 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002036 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 nSirStatus );
2038 //Pkt will be freed up by the callback
2039 }
2040
2041} // End limSendAddtsRspActionFrame.
2042
2043void
2044limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2045 tSirMacAddr peer,
2046 tANI_U8 wmmTspecPresent,
2047 tSirMacTSInfo *pTsinfo,
2048 tSirMacTspecIE *pTspecIe,
2049 tpPESession psessionEntry)
2050{
2051 tANI_U8 *pFrame;
2052 tpSirMacMgmtHdr pMacHdr;
2053 tDot11fDelTS DelTS;
2054 tDot11fWMMDelTS WMMDelTS;
2055 tSirRetStatus nSirStatus;
2056 tANI_U32 nBytes, nPayload, nStatus;
2057 void *pPacket;
2058 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302059 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002060
2061 if(NULL == psessionEntry)
2062 {
2063 return;
2064 }
2065
2066 if ( ! wmmTspecPresent )
2067 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302068 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002069
2070 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2071 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2072 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2073
2074 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2075 if ( DOT11F_FAILED( nStatus ) )
2076 {
2077 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002078 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 nStatus );
2080 // We'll fall back on the worst case scenario:
2081 nPayload = sizeof( tDot11fDelTS );
2082 }
2083 else if ( DOT11F_WARNED( nStatus ) )
2084 {
2085 limLog( pMac, LOGW, FL("There were warnings while calcula"
2086 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002087 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 }
2089 }
2090 else
2091 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302092 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002093
2094 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2095 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2096 WMMDelTS.DialogToken.token = 0;
2097 WMMDelTS.StatusCode.statusCode = 0;
2098 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2099 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2100 if ( DOT11F_FAILED( nStatus ) )
2101 {
2102 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002103 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 nStatus );
2105 // We'll fall back on the worst case scenario:
2106 nPayload = sizeof( tDot11fDelTS );
2107 }
2108 else if ( DOT11F_WARNED( nStatus ) )
2109 {
2110 limLog( pMac, LOGW, FL("There were warnings while calcula"
2111 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002112 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002113 }
2114 }
2115
2116 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2117
2118 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2119 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2120 {
2121 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002122 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 return;
2124 }
2125
2126 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302127 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002128
2129 // Next, we fill out the buffer descriptor:
2130 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2131 SIR_MAC_MGMT_ACTION, peer,
2132 psessionEntry->selfMacAddr);
2133 if ( eSIR_SUCCESS != nSirStatus )
2134 {
2135 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002136 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 nSirStatus );
2138 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2139 return; // allocated!
2140 }
2141
2142 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2143
2144 #if 0
2145
2146 cfgLen = SIR_MAC_ADDR_LENGTH;
2147 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2148 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2149 {
2150 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002151 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2153 return; // allocated!
2154 }
2155 #endif //TO SUPPORT BT-AMP
2156 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2157
Chet Lanctot186b5732013-03-18 10:26:30 -07002158#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002159 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002160#endif
2161
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 // That done, pack the struct:
2163 if ( !wmmTspecPresent )
2164 {
2165 nStatus = dot11fPackDelTS( pMac, &DelTS,
2166 pFrame + sizeof( tSirMacMgmtHdr ),
2167 nPayload, &nPayload );
2168 if ( DOT11F_FAILED( nStatus ) )
2169 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002170 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 nStatus );
2172 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2173 return; // allocated!
2174 }
2175 else if ( DOT11F_WARNED( nStatus ) )
2176 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002177 limLog( pMac, LOGW, FL("There were warnings while packing "
2178 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 }
2180 }
2181 else
2182 {
2183 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2184 pFrame + sizeof( tSirMacMgmtHdr ),
2185 nPayload, &nPayload );
2186 if ( DOT11F_FAILED( nStatus ) )
2187 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002188 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 nStatus );
2190 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2191 return; // allocated!
2192 }
2193 else if ( DOT11F_WARNED( nStatus ) )
2194 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002195 limLog( pMac, LOGW, FL("There were warnings while packing "
2196 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 }
2198 }
2199
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302200 limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2201 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002202
2203 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2205 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 )
2207 {
2208 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2209 }
2210
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302211 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2212 psessionEntry->peSessionId,
2213 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2215 HAL_TXRX_FRM_802_11_MGMT,
2216 ANI_TXDIR_TODS,
2217 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2218 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302219 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2220 psessionEntry->peSessionId,
2221 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2223 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002224 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 nSirStatus );
2226 //Pkt will be freed up by the callback
2227 }
2228
2229} // End limSendDeltsReqActionFrame.
2230
2231void
2232limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2233 tLimMlmAssocReq *pMlmAssocReq,
2234 tpPESession psessionEntry)
2235{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002236 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 tANI_U16 caps;
2238 tANI_U8 *pFrame;
2239 tSirRetStatus nSirStatus;
2240 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302241 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2243 void *pPacket;
2244 eHalStatus halstatus;
2245 tANI_U16 nAddIELen;
2246 tANI_U8 *pAddIE;
2247 tANI_U8 *wpsIe = NULL;
2248#if defined WLAN_FEATURE_VOWIFI
2249 tANI_U8 PowerCapsPopulated = FALSE;
2250#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302251 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302252 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002253 tDot11fIEExtCap extractedExtCap;
2254 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302255 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002256
2257 if(NULL == psessionEntry)
2258 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302259 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 return;
2261 }
2262
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 /* check this early to avoid unncessary operation */
2264 if(NULL == psessionEntry->pLimJoinReq)
2265 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302266 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 return;
2268 }
2269 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2270 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2271
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302272 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2273 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002274 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302275 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002276 return;
2277 }
2278
2279
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302280 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002281
Kalikinkar dhara205da782014-03-21 15:49:32 -07002282 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2283 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2284 &nAddIELen,
2285 &extractedExtCap );
2286 if(eSIR_SUCCESS != nSirStatus )
2287 {
2288 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2289 limLog(pMac, LOG1,
2290 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2291 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002292 /* TODO:remove this code once driver provides the call back function
2293 * to supplicant for set_qos_map
2294 */
2295 else
2296 {
2297 if(extractedExtCap.interworkingService)
2298 {
2299 extractedExtCap.qosMap = 1;
2300 }
Abhishek Singh15d95602015-03-24 15:52:57 +05302301 /* No need to merge the EXT Cap from Supplicant
2302 * if interworkingService is not set, as currently
2303 * driver is only interested in interworkingService
2304 * capability from supplicant. if in
2305 * future any other EXT Cap info is required from
2306 * supplicant it needs to be handled here.
2307 */
2308 else
2309 {
2310 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2311 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002312 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002313
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 caps = pMlmAssocReq->capabilityInfo;
2315 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2316 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2317#if defined(FEATURE_WLAN_WAPI)
2318 /* CR: 262463 :
2319 According to WAPI standard:
2320 7.3.1.4 Capability Information field
2321 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2322 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2323 Reassociation management frames. */
2324 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2325 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2326#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002327 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002328
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002329 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2330 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002332 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002333
2334 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2335 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2336
2337 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2338 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2339
2340 // We prefer .11e asociations:
2341 if ( fQosEnabled ) fWmeEnabled = false;
2342
2343 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2344 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2345
2346 if ( psessionEntry->lim11hEnable &&
2347 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2348 {
2349#if defined WLAN_FEATURE_VOWIFI
2350 PowerCapsPopulated = TRUE;
2351
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002352 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002353#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002354 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002355
2356 }
2357
2358#if defined WLAN_FEATURE_VOWIFI
2359 if( pMac->rrm.rrmPEContext.rrmEnable &&
2360 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2361 {
2362 if (PowerCapsPopulated == FALSE)
2363 {
2364 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002365 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 }
2367 }
2368#endif
2369
2370 if ( fQosEnabled &&
2371 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002372 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002373
2374 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002375 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002376
2377#if defined WLAN_FEATURE_VOWIFI
2378 if( pMac->rrm.rrmPEContext.rrmEnable &&
2379 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2380 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002381 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 }
2383#endif
2384 // The join request *should* contain zero or one of the WPA and RSN
2385 // IEs. The payload send along with the request is a
2386 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2387
2388 // typedef struct sSirRSNie
2389 // {
2390 // tANI_U16 length;
2391 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2392 // } tSirRSNie, *tpSirRSNie;
2393
2394 // So, we should be able to make the following two calls harmlessly,
2395 // since they do nothing if they don't find the given IE in the
2396 // bytestream with which they're provided.
2397
2398 // The net effect of this will be to faithfully transmit whatever
2399 // security IE is in the join request.
2400
2401 // *However*, if we're associating for the purpose of WPS
2402 // enrollment, and we've been configured to indicate that by
2403 // eliding the WPA or RSN IE, we just skip this:
2404 if( nAddIELen && pAddIE )
2405 {
2406 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2407 }
2408 if ( NULL == wpsIe )
2409 {
2410 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002411 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002412 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002413 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002414#if defined(FEATURE_WLAN_WAPI)
2415 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002416 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002417#endif // defined(FEATURE_WLAN_WAPI)
2418 }
2419
2420 // include WME EDCA IE as well
2421 if ( fWmeEnabled )
2422 {
2423 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2424 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002425 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 }
2427
2428 if ( fWsmEnabled &&
2429 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2430 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002431 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 }
2433 }
2434
2435 //Populate HT IEs, when operating in 11n or Taurus modes AND
2436 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002437 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 pMac->lim.htCapabilityPresentInBeacon)
2439 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002440 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002441#ifdef DISABLE_GF_FOR_INTEROP
2442
2443 /*
2444 * To resolve the interop problem with Broadcom AP,
2445 * where TQ STA could not pass traffic with GF enabled,
2446 * TQ STA will do Greenfield only with TQ AP, for
2447 * everybody else it will be turned off.
2448 */
2449
2450 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2451 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302452 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2453 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002454 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 }
2456#endif
2457
2458 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002459#ifdef WLAN_FEATURE_11AC
2460 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002461 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002462 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002463 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302464 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002465 }
2466#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302467 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002468
2469#if defined WLAN_FEATURE_VOWIFI_11R
2470 if (psessionEntry->pLimJoinReq->is11Rconnection)
2471 {
2472#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002473 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2475 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2476 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2477#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302478 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2479 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302481 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 {
2483 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302484 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 }
2486#endif
2487
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002488#ifdef FEATURE_WLAN_ESE
2489 /* For ESE Associations fill the ESE IEs */
2490 if (psessionEntry->isESEconnection &&
2491 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002492 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002493#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002494 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002495#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002496 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 }
2498#endif
2499
c_hpothubcd78652014-04-28 22:31:08 +05302500 /* merge the ExtCap struct*/
2501 if (extractedExtCapFlag && extractedExtCap.present)
2502 {
2503 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2504 }
2505
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002506 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002507 if ( DOT11F_FAILED( nStatus ) )
2508 {
2509 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002510 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 nStatus );
2512 // We'll fall back on the worst case scenario:
2513 nPayload = sizeof( tDot11fAssocRequest );
2514 }
2515 else if ( DOT11F_WARNED( nStatus ) )
2516 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002517 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002519 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 }
2521
2522 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2523
2524 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2525 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2526 ( void** ) &pPacket );
2527 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2528 {
2529 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002530 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002531
2532 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002533 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002534
2535
2536 /* Update PE session id*/
2537 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2538
2539 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2540
2541 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2542 ( void* ) pFrame, ( void* ) pPacket );
2543
2544 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2545 ( tANI_U32* ) &mlmAssocCnf);
2546
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302547 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 return;
2549 }
2550
2551 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302552 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002553
2554 // Next, we fill out the buffer descriptor:
2555 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2556 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2557 if ( eSIR_SUCCESS != nSirStatus )
2558 {
2559 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002560 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 nSirStatus );
2562 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302563 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 return;
2565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002566
Abhishek Singh57aebef2014-02-03 18:47:44 +05302567 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002568 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 sizeof(tSirMacMgmtHdr),
2570 nPayload, &nPayload );
2571 if ( DOT11F_FAILED( nStatus ) )
2572 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302573 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002574 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 nStatus );
2576 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2577 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302578 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 return;
2580 }
2581 else if ( DOT11F_WARNED( nStatus ) )
2582 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302583 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2584 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 }
2586
2587 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002588 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 nBytes );)
2590 // limPrintMacAddr( pMac, bssid, LOG1 );
2591
2592 if( psessionEntry->assocReq != NULL )
2593 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302594 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 psessionEntry->assocReq = NULL;
2596 }
2597
2598 if( nAddIELen )
2599 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302600 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2601 pAddIE,
2602 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 nPayload += nAddIELen;
2604 }
2605
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302606 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2607 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302609 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2610 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 }
2612 else
2613 {
2614 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302615 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 psessionEntry->assocReqLen = nPayload;
2617 }
2618
2619 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2621 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 )
2623 {
2624 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2625 }
2626
Sushant Kaushike8681d22015-04-21 12:08:25 +05302627 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
2628 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08002629 {
2630 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2631 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302632
2633 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302634 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2635 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2636 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2637 txFlag |= HAL_USE_FW_IN_TX_PATH;
2638
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302639 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2640 psessionEntry->peSessionId,
2641 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302642
2643 // enable caching
2644 WLANTL_EnableCaching(psessionEntry->staId);
2645
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302646 if( ( psessionEntry->is11Gonly == true ) &&
2647 ( !IS_BROADCAST_MAC(pMlmAssocReq->peerMacAddr) ) ){
2648 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2649 }
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05302650 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
2651 {
2652 limLog(pMac, LOG1, FL("Assoc Req - txBdToken %u"), pMac->lim.txBdToken);
2653 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
2654 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2655 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2656 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2657 limTxComplete, pFrame, limTxBdComplete, txFlag,
2658 pMac->lim.txBdToken);
2659 pMac->lim.txBdToken++;
2660 }
2661 else
2662 {
2663 halstatus = halTxFrame( pMac, pPacket,
2664 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2665 HAL_TXRX_FRM_802_11_MGMT,
2666 ANI_TXDIR_TODS,
2667 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2668 limTxComplete, pFrame, txFlag );
2669 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302670
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302671 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2672 psessionEntry->peSessionId,
2673 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2675 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002676 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 halstatus );
2678 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302679 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 return;
2681 }
2682
2683 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302684 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002685 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302686 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002687 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002688} // End limSendAssocReqMgmtFrame
2689
2690
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002691#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002692/*------------------------------------------------------------------------------------
2693 *
2694 * Send Reassoc Req with FTIEs.
2695 *
2696 *-----------------------------------------------------------------------------------
2697 */
2698void
2699limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2700 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2701{
2702 static tDot11fReAssocRequest frm;
2703 tANI_U16 caps;
2704 tANI_U8 *pFrame;
2705 tSirRetStatus nSirStatus;
2706 tANI_U32 nBytes, nPayload, nStatus;
2707 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2708 void *pPacket;
2709 eHalStatus halstatus;
2710#if defined WLAN_FEATURE_VOWIFI
2711 tANI_U8 PowerCapsPopulated = FALSE;
2712#endif
2713 tANI_U16 ft_ies_length = 0;
2714 tANI_U8 *pBody;
2715 tANI_U16 nAddIELen;
2716 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002717#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 tANI_U8 *wpsIe = NULL;
2719#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302720 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302721 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002722
2723 if (NULL == psessionEntry)
2724 {
2725 return;
2726 }
2727
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 /* check this early to avoid unncessary operation */
2729 if(NULL == psessionEntry->pLimReAssocReq)
2730 {
2731 return;
2732 }
2733 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2734 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002735 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2736 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002737
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302738 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002739
2740 caps = pMlmReassocReq->capabilityInfo;
2741 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2742 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2743#if defined(FEATURE_WLAN_WAPI)
2744 /* CR: 262463 :
2745 According to WAPI standard:
2746 7.3.1.4 Capability Information field
2747 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2748 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2749 Reassociation management frames. */
2750 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2751 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2752#endif
2753 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2754
2755 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2756
2757 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302758 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2760
2761 PopulateDot11fSSID2( pMac, &frm.SSID );
2762 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2763 &frm.SuppRates,psessionEntry);
2764
2765 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2766 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2767
2768 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2769 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2770
2771 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2772 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2773
2774 if ( psessionEntry->lim11hEnable &&
2775 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2776 {
2777#if defined WLAN_FEATURE_VOWIFI
2778 PowerCapsPopulated = TRUE;
2779
2780 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2781 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2782#endif
2783 }
2784
2785#if defined WLAN_FEATURE_VOWIFI
2786 if( pMac->rrm.rrmPEContext.rrmEnable &&
2787 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2788 {
2789 if (PowerCapsPopulated == FALSE)
2790 {
2791 PowerCapsPopulated = TRUE;
2792 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2793 }
2794 }
2795#endif
2796
2797 if ( fQosEnabled &&
2798 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2799 {
2800 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2801 }
2802
2803 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2804 &frm.ExtSuppRates, psessionEntry );
2805
2806#if defined WLAN_FEATURE_VOWIFI
2807 if( pMac->rrm.rrmPEContext.rrmEnable &&
2808 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2809 {
2810 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2811 }
2812#endif
2813
2814 // Ideally this should be enabled for 11r also. But 11r does
2815 // not follow the usual norm of using the Opaque object
2816 // for rsnie and fties. Instead we just add
2817 // the rsnie and fties at the end of the pack routine for 11r.
2818 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002819#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 //
2821 // The join request *should* contain zero or one of the WPA and RSN
2822 // IEs. The payload send along with the request is a
2823 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2824
2825 // typedef struct sSirRSNie
2826 // {
2827 // tANI_U16 length;
2828 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2829 // } tSirRSNie, *tpSirRSNie;
2830
2831 // So, we should be able to make the following two calls harmlessly,
2832 // since they do nothing if they don't find the given IE in the
2833 // bytestream with which they're provided.
2834
2835 // The net effect of this will be to faithfully transmit whatever
2836 // security IE is in the join request.
2837
2838 // *However*, if we're associating for the purpose of WPS
2839 // enrollment, and we've been configured to indicate that by
2840 // eliding the WPA or RSN IE, we just skip this:
2841 if (!psessionEntry->is11Rconnection)
2842 {
2843 if( nAddIELen && pAddIE )
2844 {
2845 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2846 }
2847 if ( NULL == wpsIe )
2848 {
2849 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2850 &frm.RSNOpaque );
2851 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2852 &frm.WPAOpaque );
2853 }
2854
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002855#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302856 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002858 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2859 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002861#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 }
2863
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002864#ifdef FEATURE_WLAN_ESE
2865 // For ESE Associations fill the ESE IEs
2866 if (psessionEntry->isESEconnection &&
2867 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002869#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002870 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002871#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002872 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002874#endif //FEATURE_WLAN_ESE
2875#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002876
2877 // include WME EDCA IE as well
2878 if ( fWmeEnabled )
2879 {
2880 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2881 {
2882 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2883 }
2884
2885 if ( fWsmEnabled &&
2886 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2887 {
2888 PopulateDot11fWMMCaps( &frm.WMMCaps );
2889 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002890#ifdef FEATURE_WLAN_ESE
2891 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 {
2893 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2894
2895 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002896 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 {
2898 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002899 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 limGetPhyMode(pMac, &phyMode, psessionEntry);
2901
2902 tsrsIE.tsid = 0;
2903 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2904 {
2905 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2906 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302907 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 {
2909 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2910 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002911 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 }
2913 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302914#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 }
2916
Jeff Johnsone7245742012-09-05 17:12:55 -07002917 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 pMac->lim.htCapabilityPresentInBeacon)
2919 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002920 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 }
2922
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002923#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302924 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2925 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002926#if defined FEATURE_WLAN_ESE
2927 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302928#endif
2929 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002930 {
2931 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2932 }
2933#endif
2934
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002935#ifdef WLAN_FEATURE_11AC
2936 if ( psessionEntry->vhtCapability &&
2937 psessionEntry->vhtCapabilityPresentInBeacon)
2938 {
2939 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302940 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_FALSE );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002941 }
2942#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302943 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002944
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2946 if ( DOT11F_FAILED( nStatus ) )
2947 {
2948 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002949 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 nStatus );
2951 // We'll fall back on the worst case scenario:
2952 nPayload = sizeof( tDot11fReAssocRequest );
2953 }
2954 else if ( DOT11F_WARNED( nStatus ) )
2955 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002956 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002958 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 }
2960
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002961 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002962
2963#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002964 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2966#endif
2967
2968#if defined WLAN_FEATURE_VOWIFI_11R
2969 if (psessionEntry->is11Rconnection)
2970 {
2971 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2972 }
2973#endif
2974
2975 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2976 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2977 ( void** ) &pPacket );
2978 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2979 {
2980 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002981 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002983 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 goto end;
2985 }
2986
2987 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302988 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002989
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002990#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002991 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002992#endif
2993 // Next, we fill out the buffer descriptor:
2994 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2995 SIR_MAC_MGMT_REASSOC_REQ,
2996 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2997 if ( eSIR_SUCCESS != nSirStatus )
2998 {
2999 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003000 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 nSirStatus );
3002 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3003 goto end;
3004 }
3005
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303006 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 // That done, pack the ReAssoc Request:
3008 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3009 sizeof(tSirMacMgmtHdr),
3010 nPayload, &nPayload );
3011 if ( DOT11F_FAILED( nStatus ) )
3012 {
3013 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003014 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 nStatus );
3016 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3017 goto end;
3018 }
3019 else if ( DOT11F_WARNED( nStatus ) )
3020 {
3021 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003022 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 }
3024
3025 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003026 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 nBytes, nPayload );)
3028 if( psessionEntry->assocReq != NULL )
3029 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303030 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 psessionEntry->assocReq = NULL;
3032 }
3033
3034 if( nAddIELen )
3035 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303036 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3037 pAddIE,
3038 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 nPayload += nAddIELen;
3040 }
3041
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303042 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3043 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 {
3045 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003046 }
3047 else
3048 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303050 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003052 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003053
3054 if (psessionEntry->is11Rconnection)
3055 {
3056 {
3057 int i = 0;
3058
3059 pBody = pFrame + nBytes;
3060 for (i=0; i<ft_ies_length; i++)
3061 {
3062 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
3063 pBody++;
3064 }
3065 }
3066 }
3067
3068#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003069 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3070 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 (tANI_U8 *)pFrame,
3072 (nBytes + ft_ies_length));)
3073#endif
3074
3075
3076 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3078 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 )
3080 {
3081 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3082 }
3083
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003084 if( NULL != psessionEntry->assocReq )
3085 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303086 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003087 psessionEntry->assocReq = NULL;
3088 }
3089
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303090 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3091 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003092 {
3093 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003094 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003095 }
3096 else
3097 {
3098 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303099 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3100 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003101 psessionEntry->assocReqLen = (ft_ies_length);
3102 }
3103
3104
Mihir Shete63561c82014-08-23 16:58:07 +05303105 // Enable TL cahching in case of roaming
3106 WLANTL_EnableCaching(psessionEntry->staId);
3107
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303108 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3109 psessionEntry->peSessionId,
3110 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303111 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3112 {
3113 limLog( pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3114 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3115 ( tANI_U16 ) (nBytes + ft_ies_length),
3116 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3117 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3118 limTxComplete, pFrame, limTxBdComplete, txFlag,
3119 pMac->lim.txBdToken);
3120 pMac->lim.txBdToken++;
3121 }
3122 else
3123 {
3124 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3125 HAL_TXRX_FRM_802_11_MGMT,
3126 ANI_TXDIR_TODS,
3127 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3128 limTxComplete, pFrame, txFlag );
3129 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303130 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3131 psessionEntry->peSessionId,
3132 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3134 {
3135 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003136 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 nSirStatus );
3138 //Pkt will be freed up by the callback
3139 goto end;
3140 }
3141
3142end:
3143 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303144 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 psessionEntry->pLimMlmReassocReq = NULL;
3146
3147}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003148
3149void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3150 tLimMlmReassocReq *pMlmReassocReq,
3151 tpPESession psessionEntry)
3152{
3153 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3154 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
Sachin Ahuja07a43012015-01-30 17:04:38 +05303155#ifdef FEATURE_WLAN_ESE
3156 tANI_U32 val=0;
3157#endif
3158 if (pMlmReassocReq == NULL)
3159 {
3160 limLog(pMac, LOGE,
3161 FL("Invalid pMlmReassocReq"));
3162 goto end;
3163 }
Hema Aparna Medicharla43d0f7b2015-02-12 17:07:59 +05303164
3165 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3166 if ( NULL == pTmpMlmReassocReq ) goto end;
3167 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3168 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003169
3170 // Prepare and send Reassociation request frame
3171 // start reassoc timer.
Sachin Ahuja07a43012015-01-30 17:04:38 +05303172#ifdef FEATURE_WLAN_ESE
3173 /*
3174 * In case of Ese Reassociation, change the reassoc timer
3175 * value.
3176 */
3177 val = pMlmReassocReq->reassocFailureTimeout;
3178 if (psessionEntry->isESEconnection)
3179 {
3180 val = val/LIM_MAX_REASSOC_RETRY_LIMIT;
3181 }
3182 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer) !=
3183 TX_SUCCESS)
3184 {
3185 limLog(pMac, LOGP,
3186 FL("unable to deactivate Reassoc failure timer"));
3187 }
3188 val = SYS_MS_TO_TICKS(val);
3189 if (tx_timer_change(&pMac->lim.limTimers.gLimReassocFailureTimer,
3190 val, 0) != TX_SUCCESS)
3191 {
3192 limLog(pMac, LOGP,
3193 FL("unable to change Reassociation failure timer"));
3194 }
3195#endif
3196
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003197 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3198 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003199 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003200 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3201 != TX_SUCCESS)
3202 {
3203 // Could not start reassoc failure timer.
3204 // Log error
3205 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003206 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003207 // Return Reassoc confirm with
3208 // Resources Unavailable
3209 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3210 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3211 goto end;
3212 }
3213
3214 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3215 return;
3216
3217end:
3218 // Free up buffer allocated for reassocReq
3219 if (pMlmReassocReq != NULL)
3220 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303221 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003222 pMlmReassocReq = NULL;
3223 }
3224 if (pTmpMlmReassocReq != NULL)
3225 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303226 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003227 pTmpMlmReassocReq = NULL;
3228 }
3229 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3230 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3231 /* Update PE sessio Id*/
3232 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3233
3234 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3235}
3236
Jeff Johnson295189b2012-06-20 16:38:30 -07003237#endif /* WLAN_FEATURE_VOWIFI_11R */
3238
3239
3240void
3241limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3242 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3243{
3244 static tDot11fReAssocRequest frm;
3245 tANI_U16 caps;
3246 tANI_U8 *pFrame;
3247 tSirRetStatus nSirStatus;
3248 tANI_U32 nBytes, nPayload, nStatus;
3249 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3250 void *pPacket;
3251 eHalStatus halstatus;
3252 tANI_U16 nAddIELen;
3253 tANI_U8 *pAddIE;
3254 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303255 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003256#if defined WLAN_FEATURE_VOWIFI
3257 tANI_U8 PowerCapsPopulated = FALSE;
3258#endif
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303259 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003260
3261 if(NULL == psessionEntry)
3262 {
3263 return;
3264 }
3265
3266 /* check this early to avoid unncessary operation */
3267 if(NULL == psessionEntry->pLimReAssocReq)
3268 {
3269 return;
3270 }
3271 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3272 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3273
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303274 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003275
3276 caps = pMlmReassocReq->capabilityInfo;
3277 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3278 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3279#if defined(FEATURE_WLAN_WAPI)
3280 /* CR: 262463 :
3281 According to WAPI standard:
3282 7.3.1.4 Capability Information field
3283 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3284 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3285 Reassociation management frames. */
3286 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3287 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3288#endif
3289 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3290
3291 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3292
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303293 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3294 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003295
3296 PopulateDot11fSSID2( pMac, &frm.SSID );
3297 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3298 &frm.SuppRates,psessionEntry);
3299
3300 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3301 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3302
3303 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3304 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3305
3306 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3307 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3308
3309
3310 if ( psessionEntry->lim11hEnable &&
3311 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3312 {
3313#if defined WLAN_FEATURE_VOWIFI
3314 PowerCapsPopulated = TRUE;
3315 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3316 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3317#endif
3318 }
3319
3320#if defined WLAN_FEATURE_VOWIFI
3321 if( pMac->rrm.rrmPEContext.rrmEnable &&
3322 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3323 {
3324 if (PowerCapsPopulated == FALSE)
3325 {
3326 PowerCapsPopulated = TRUE;
3327 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3328 }
3329 }
3330#endif
3331
3332 if ( fQosEnabled &&
3333 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3334 {
3335 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3336 }
3337
3338 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3339 &frm.ExtSuppRates, psessionEntry );
3340
3341#if defined WLAN_FEATURE_VOWIFI
3342 if( pMac->rrm.rrmPEContext.rrmEnable &&
3343 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3344 {
3345 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3346 }
3347#endif
3348 // The join request *should* contain zero or one of the WPA and RSN
3349 // IEs. The payload send along with the request is a
3350 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3351
3352 // typedef struct sSirRSNie
3353 // {
3354 // tANI_U16 length;
3355 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3356 // } tSirRSNie, *tpSirRSNie;
3357
3358 // So, we should be able to make the following two calls harmlessly,
3359 // since they do nothing if they don't find the given IE in the
3360 // bytestream with which they're provided.
3361
3362 // The net effect of this will be to faithfully transmit whatever
3363 // security IE is in the join request.
3364
3365 // *However*, if we're associating for the purpose of WPS
3366 // enrollment, and we've been configured to indicate that by
3367 // eliding the WPA or RSN IE, we just skip this:
3368 if( nAddIELen && pAddIE )
3369 {
3370 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3371 }
3372 if ( NULL == wpsIe )
3373 {
3374 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3375 &frm.RSNOpaque );
3376 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3377 &frm.WPAOpaque );
3378#if defined(FEATURE_WLAN_WAPI)
3379 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3380 &frm.WAPIOpaque );
3381#endif // defined(FEATURE_WLAN_WAPI)
3382 }
3383
3384 // include WME EDCA IE as well
3385 if ( fWmeEnabled )
3386 {
3387 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3388 {
3389 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3390 }
3391
3392 if ( fWsmEnabled &&
3393 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3394 {
3395 PopulateDot11fWMMCaps( &frm.WMMCaps );
3396 }
3397 }
3398
Jeff Johnsone7245742012-09-05 17:12:55 -07003399 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 pMac->lim.htCapabilityPresentInBeacon)
3401 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003402 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003404#ifdef WLAN_FEATURE_11AC
3405 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003406 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003407 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003408 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05303409 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_FALSE );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303410 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003411 }
3412#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003413
3414 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3415 if ( DOT11F_FAILED( nStatus ) )
3416 {
3417 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003418 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 nStatus );
3420 // We'll fall back on the worst case scenario:
3421 nPayload = sizeof( tDot11fReAssocRequest );
3422 }
3423 else if ( DOT11F_WARNED( nStatus ) )
3424 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003425 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003427 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 }
3429
3430 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3431
3432 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3433 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3434 ( void** ) &pPacket );
3435 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3436 {
3437 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003438 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003440 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 goto end;
3442 }
3443
3444 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303445 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003446
3447 // Next, we fill out the buffer descriptor:
3448 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3449 SIR_MAC_MGMT_REASSOC_REQ,
3450 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3451 if ( eSIR_SUCCESS != nSirStatus )
3452 {
3453 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003454 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 nSirStatus );
3456 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3457 goto end;
3458 }
3459
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303460 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 // That done, pack the Probe Request:
3462 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3463 sizeof(tSirMacMgmtHdr),
3464 nPayload, &nPayload );
3465 if ( DOT11F_FAILED( nStatus ) )
3466 {
3467 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003468 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 nStatus );
3470 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3471 goto end;
3472 }
3473 else if ( DOT11F_WARNED( nStatus ) )
3474 {
3475 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003476 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 }
3478
3479 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003480 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 nBytes );)
3482
3483 if( psessionEntry->assocReq != NULL )
3484 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303485 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 psessionEntry->assocReq = NULL;
3487 }
3488
3489 if( nAddIELen )
3490 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303491 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3492 pAddIE,
3493 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 nPayload += nAddIELen;
3495 }
3496
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303497 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3498 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 {
3500 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003501 }
3502 else
3503 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303505 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003508
3509 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3511 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 )
3513 {
3514 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3515 }
3516
Sushant Kaushike8681d22015-04-21 12:08:25 +05303517 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3518 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003519 {
3520 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3521 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003522
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303523 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3524 psessionEntry->peSessionId,
3525 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303526
3527 // enable caching
3528 WLANTL_EnableCaching(psessionEntry->staId);
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303529 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3530 {
3531 limLog(pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3532 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3533 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3534 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3535 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3536 limTxComplete, pFrame, limTxBdComplete,
3537 txFlag, pMac->lim.txBdToken );
3538 pMac->lim.txBdToken++;
3539 }
3540 else
3541 {
3542 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3543 HAL_TXRX_FRM_802_11_MGMT,
3544 ANI_TXDIR_TODS,
3545 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3546 limTxComplete, pFrame, txFlag );
3547 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303548 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3549 psessionEntry->peSessionId,
3550 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3552 {
3553 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003554 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 nSirStatus );
3556 //Pkt will be freed up by the callback
3557 goto end;
3558 }
3559
3560end:
3561 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303562 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 psessionEntry->pLimMlmReassocReq = NULL;
3564
3565} // limSendReassocReqMgmtFrame
3566
Sushant Kaushik9e923872015-04-02 17:09:31 +05303567eHalStatus limAuthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303568{
Sushant Kaushik9e923872015-04-02 17:09:31 +05303569 tANI_U32 txCompleteSuccess;
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303570 tpSirTxBdStatus pTxBdStatus;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303571
3572 if (!pData)
3573 {
3574 limLog(pMac, LOG1,
3575 FL(" pData is NULL"));
3576 return eHAL_STATUS_FAILURE;
3577 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303578
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303579 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3580 {
3581 pTxBdStatus = (tpSirTxBdStatus) pData;
3582 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
3583 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
3584 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
3585 }
3586 else
3587 {
3588 txCompleteSuccess = *((tANI_U32*) pData);
3589 limLog(pMac, LOG1,
3590 FL("txCompleteSuccess= %d"), txCompleteSuccess);
3591 }
3592
Sushant Kaushik9e923872015-04-02 17:09:31 +05303593 if(txCompleteSuccess)
3594 {
3595 pMac->authAckStatus = LIM_AUTH_ACK_RCD_SUCCESS;
3596 // 'Change' timer for future activations
3597 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
3598 }
3599 else
3600 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
3601 return eHAL_STATUS_SUCCESS;
3602}
3603
Jeff Johnson295189b2012-06-20 16:38:30 -07003604/**
3605 * \brief Send an Authentication frame
3606 *
3607 *
3608 * \param pMac Pointer to Global MAC structure
3609 *
3610 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3611 * to be sent
3612 *
3613 * \param peerMacAddr MAC address of the peer entity to which Authentication
3614 * frame is destined
3615 *
3616 * \param wepBit Indicates whether wep bit to be set in FC while sending
3617 * Authentication frame3
3618 *
3619 *
3620 * This function is called by limProcessMlmMessages(). Authentication frame
3621 * is formatted and sent when this function is called.
3622 *
3623 *
3624 */
3625
3626void
3627limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3628 tpSirMacAuthFrameBody pAuthFrameBody,
3629 tSirMacAddr peerMacAddr,
3630 tANI_U8 wepBit,
Sushant Kaushik9e923872015-04-02 17:09:31 +05303631 tpPESession psessionEntry,
3632 tAniBool waitForAck
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 )
3634{
3635 tANI_U8 *pFrame, *pBody;
3636 tANI_U32 frameLen = 0, bodyLen = 0;
3637 tpSirMacMgmtHdr pMacHdr;
3638 tANI_U16 i;
3639 void *pPacket;
3640 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303641 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003642
3643 if(NULL == psessionEntry)
3644 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303645 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 return;
3647 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303648
3649 limLog(pMac, LOG1,
3650 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3651 pAuthFrameBody->authTransactionSeqNumber,
3652 pAuthFrameBody->authStatusCode,
3653 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3654 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 if (wepBit == LIM_WEP_IN_FC)
3656 {
3657 /// Auth frame3 to be sent with encrypted framebody
3658 /**
3659 * Allocate buffer for Authenticaton frame of size equal
3660 * to management frame header length plus 2 bytes each for
3661 * auth algorithm number, transaction number, status code,
3662 * 128 bytes for challenge text and 4 bytes each for
3663 * IV & ICV.
3664 */
3665
3666 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3667
3668 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3669 } // if (wepBit == LIM_WEP_IN_FC)
3670 else
3671 {
3672 switch (pAuthFrameBody->authTransactionSeqNumber)
3673 {
3674 case SIR_MAC_AUTH_FRAME_1:
3675 /**
3676 * Allocate buffer for Authenticaton frame of size
3677 * equal to management frame header length plus 2 bytes
3678 * each for auth algorithm number, transaction number
3679 * and status code.
3680 */
3681
3682 frameLen = sizeof(tSirMacMgmtHdr) +
3683 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3684 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3685
3686#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003687 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3688 {
3689 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003691 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003692 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003693 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003695 else
3696 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303697 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3698 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003699 frameLen += (2+SIR_MDIE_SIZE);
3700 }
3701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003702#endif
3703 break;
3704
3705 case SIR_MAC_AUTH_FRAME_2:
3706 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3707 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3708 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3709 {
3710 /**
3711 * Allocate buffer for Authenticaton frame of size
3712 * equal to management frame header length plus
3713 * 2 bytes each for auth algorithm number,
3714 * transaction number and status code.
3715 */
3716
3717 frameLen = sizeof(tSirMacMgmtHdr) +
3718 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3719 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3720 }
3721 else
3722 {
3723 // Shared Key algorithm with challenge text
3724 // to be sent
3725 /**
3726 * Allocate buffer for Authenticaton frame of size
3727 * equal to management frame header length plus
3728 * 2 bytes each for auth algorithm number,
3729 * transaction number, status code and 128 bytes
3730 * for challenge text.
3731 */
3732
3733 frameLen = sizeof(tSirMacMgmtHdr) +
3734 sizeof(tSirMacAuthFrame);
3735 bodyLen = sizeof(tSirMacAuthFrameBody);
3736 }
3737
3738 break;
3739
3740 case SIR_MAC_AUTH_FRAME_3:
3741 /// Auth frame3 to be sent without encrypted framebody
3742 /**
3743 * Allocate buffer for Authenticaton frame of size equal
3744 * to management frame header length plus 2 bytes each
3745 * for auth algorithm number, transaction number and
3746 * status code.
3747 */
3748
3749 frameLen = sizeof(tSirMacMgmtHdr) +
3750 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3751 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3752
3753 break;
3754
3755 case SIR_MAC_AUTH_FRAME_4:
3756 /**
3757 * Allocate buffer for Authenticaton frame of size equal
3758 * to management frame header length plus 2 bytes each
3759 * for auth algorithm number, transaction number and
3760 * status code.
3761 */
3762
3763 frameLen = sizeof(tSirMacMgmtHdr) +
3764 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3765 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3766
3767 break;
3768 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3769 } // end if (wepBit == LIM_WEP_IN_FC)
3770
3771
3772 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3773
3774 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3775 {
3776 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003777 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003778
3779 return;
3780 }
3781
3782 for (i = 0; i < frameLen; i++)
3783 pFrame[i] = 0;
3784
3785 // Prepare BD
3786 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3787 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3788 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303789 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3790 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3792 return;
3793 }
3794
3795 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3796 pMacHdr->fc.wep = wepBit;
3797
3798 // Prepare BSSId
3799 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3800 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303801 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3802 (tANI_U8 *) psessionEntry->bssId,
3803 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 }
3805
3806 /// Prepare Authentication frame body
3807 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3808
3809 if (wepBit == LIM_WEP_IN_FC)
3810 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303811 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003812
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303813 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303814 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303816 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303817 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003818
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 }
3820 else
3821 {
3822 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3823 pBody += sizeof(tANI_U16);
3824 bodyLen -= sizeof(tANI_U16);
3825
3826 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3827 pBody += sizeof(tANI_U16);
3828 bodyLen -= sizeof(tANI_U16);
3829
3830 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3831 pBody += sizeof(tANI_U16);
3832 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003833 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3834 sizeof (pAuthFrameBody->length) +
3835 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303836 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003837
3838#if defined WLAN_FEATURE_VOWIFI_11R
3839 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3840 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3841 {
3842
3843 {
3844 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3846 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003847#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003848 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3849 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 (tANI_U8 *)pBody,
3851 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003852#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003853 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3854 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003855 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3856 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003857 }
3858 }
3859 else
3860 {
3861 /* MDID attr is 54*/
3862 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003864 *pBody = SIR_MDIE_SIZE;
3865 pBody++;
3866 for(i=0;i<SIR_MDIE_SIZE;i++)
3867 {
3868 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3869 pBody++;
3870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 }
3872 }
3873 }
3874#endif
3875
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303876 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303877 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 pAuthFrameBody->authTransactionSeqNumber,
3879 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303880 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303881 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 }
3883 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3884
3885 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3887 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003888#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303889 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003890 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3891#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 )
3893 {
3894 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3895 }
3896
Sushant Kaushike8681d22015-04-21 12:08:25 +05303897 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3898 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003899 {
3900 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3901 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003902
Sushant Kaushik9e923872015-04-02 17:09:31 +05303903 limLog( pMac, LOG1,
3904 FL("Sending Auth Frame over WQ5 with waitForAck %d to "MAC_ADDRESS_STR
3905 " From " MAC_ADDRESS_STR), waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303906 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3907
3908 txFlag |= HAL_USE_FW_IN_TX_PATH;
3909
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303910 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3911 psessionEntry->peSessionId,
3912 pMacHdr->fc.subType));
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303913
3914 if( ( psessionEntry->is11Gonly == true ) &&
3915 ( !IS_BROADCAST_MAC(peerMacAddr) ) ){
3916 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3917 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303918 if(eSIR_TRUE == waitForAck)
3919 {
3920 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303921 limLog(pMac, LOGE, FL("Auth frame - txBdToken %u"),
3922 pMac->lim.txBdToken);
Sushant Kaushik9e923872015-04-02 17:09:31 +05303923 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3924 ( tANI_U16 ) frameLen,
3925 HAL_TXRX_FRM_802_11_MGMT,
3926 ANI_TXDIR_TODS,
3927 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303928 limTxComplete, pFrame, limAuthTxCompleteCnf, txFlag,
3929 pMac->lim.txBdToken);
3930 pMac->lim.txBdToken++;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303931 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3932 psessionEntry->peSessionId,
3933 halstatus));
3934 if (!HAL_STATUS_SUCCESS(halstatus))
3935 {
3936 limLog( pMac, LOGE,
3937 FL("Could not send Auth frame, retCode=%X "),
3938 halstatus );
3939 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
3940 //Pkt will be freed up by the callback
3941 }
3942 }
3943 else
3944 {
3945 /// Queue Authentication frame in high priority WQ
3946 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 HAL_TXRX_FRM_802_11_MGMT,
3948 ANI_TXDIR_TODS,
3949 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3950 limTxComplete, pFrame, txFlag );
Sushant Kaushik9e923872015-04-02 17:09:31 +05303951 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303952 psessionEntry->peSessionId,
3953 halstatus));
Sushant Kaushik9e923872015-04-02 17:09:31 +05303954 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3955 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003957 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 halstatus);
3959
3960 //Pkt will be freed up by the callback
Sushant Kaushik9e923872015-04-02 17:09:31 +05303961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 }
3963
3964 return;
3965} /*** end limSendAuthMgmtFrame() ***/
3966
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003967eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3968{
3969 tANI_U16 aid;
3970 tpDphHashNode pStaDs;
3971 tLimMlmDeauthReq *pMlmDeauthReq;
3972 tLimMlmDeauthCnf mlmDeauthCnf;
3973 tpPESession psessionEntry;
3974
3975 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3976 if (pMlmDeauthReq)
3977 {
3978 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3979 {
3980 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3981 }
3982
3983 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3984 {
3985
3986 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003987 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003988 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3989 goto end;
3990 }
3991
3992 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3993 if (pStaDs == NULL)
3994 {
3995 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3996 goto end;
3997 }
3998
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003999 /// Receive path cleanup with dummy packet
4000 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304001
4002#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304003 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304004 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304005 PELOGE(limLog(pMac, LOG1,
4006 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304007#ifdef FEATURE_WLAN_ESE
4008 " isESE %d"
4009#endif
4010#ifdef FEATURE_WLAN_LFR
4011 " isLFR %d"
4012#endif
4013 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304014 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304015#ifdef FEATURE_WLAN_ESE
4016 psessionEntry->isESEconnection,
4017#endif
4018#ifdef FEATURE_WLAN_LFR
4019 psessionEntry->isFastRoamIniFeatureEnabled,
4020#endif
4021 psessionEntry->is11Rconnection,
4022 pMlmDeauthReq->reasonCode,
4023 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304024
4025 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304026 }
4027#endif
4028
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004029 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304030 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004031 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
4032 }
4033 return eHAL_STATUS_SUCCESS;
4034end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304035 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004036 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
4037 sizeof(tSirMacAddr));
4038 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
4039 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
4040 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
4041
4042 // Free up buffer allocated
4043 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304044 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004045
4046 limPostSmeMessage(pMac,
4047 LIM_MLM_DEAUTH_CNF,
4048 (tANI_U32 *) &mlmDeauthCnf);
4049 return eHAL_STATUS_SUCCESS;
4050}
4051
4052eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
4053{
4054 tANI_U16 aid;
4055 tpDphHashNode pStaDs;
4056 tLimMlmDisassocCnf mlmDisassocCnf;
4057 tpPESession psessionEntry;
4058 tLimMlmDisassocReq *pMlmDisassocReq;
4059
4060 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
4061 if (pMlmDisassocReq)
4062 {
4063 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
4064 {
4065 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4066 }
4067
4068 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
4069 {
4070
4071 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004072 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004073 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4074 goto end;
4075 }
4076
4077 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4078 if (pStaDs == NULL)
4079 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304080 limLog(pMac, LOGE,
4081 FL("StaDs Null"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004082 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4083 goto end;
4084 }
4085
4086 /// Receive path cleanup with dummy packet
4087 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
4088 {
4089 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304090 limLog(pMac, LOGE,
4091 FL("CleanupRxPath error"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004092 goto end;
4093 }
4094
4095#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004096 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05304097 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004098 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004099 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304100 PELOGE(limLog(pMac, LOG1,
4101 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004102#ifdef FEATURE_WLAN_ESE
4103 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004104#endif
4105#ifdef FEATURE_WLAN_LFR
4106 " isLFR %d"
4107#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004108 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304109 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004110#ifdef FEATURE_WLAN_ESE
4111 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004112#endif
4113#ifdef FEATURE_WLAN_LFR
4114 psessionEntry->isFastRoamIniFeatureEnabled,
4115#endif
4116 psessionEntry->is11Rconnection,
4117 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304118 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004119 }
4120#endif
4121
4122 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304123 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004124 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4125 return eHAL_STATUS_SUCCESS;
4126 }
4127 else
4128 {
4129 return eHAL_STATUS_SUCCESS;
4130 }
4131end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304132 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004133 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
4134 sizeof(tSirMacAddr));
4135 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
4136 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
4137
4138 /* Update PE session ID*/
4139 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
4140
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004141 if(pMlmDisassocReq != NULL)
4142 {
4143 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304144 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004145 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4146 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004147
4148 limPostSmeMessage(pMac,
4149 LIM_MLM_DISASSOC_CNF,
4150 (tANI_U32 *) &mlmDisassocCnf);
4151 return eHAL_STATUS_SUCCESS;
4152}
4153
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304154eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004155{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304156 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4157 {
4158 tpSirTxBdStatus pTxBdStatus;
4159 pTxBdStatus = (tpSirTxBdStatus) pData;
4160 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4161 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4162 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004163 return limSendDisassocCnf(pMac);
4164}
4165
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304166eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004167{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304168 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4169 {
4170 tpSirTxBdStatus pTxBdStatus;
4171 pTxBdStatus = (tpSirTxBdStatus) pData;
4172 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4173 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4174 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004175 return limSendDeauthCnf(pMac);
4176}
4177
Jeff Johnson295189b2012-06-20 16:38:30 -07004178/**
4179 * \brief This function is called to send Disassociate frame.
4180 *
4181 *
4182 * \param pMac Pointer to Global MAC structure
4183 *
4184 * \param nReason Indicates the reason that need to be sent in
4185 * Disassociation frame
4186 *
4187 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
4188 * sent
4189 *
4190 *
4191 */
4192
4193void
4194limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4195 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004196 tSirMacAddr peer,
4197 tpPESession psessionEntry,
4198 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004199{
4200 tDot11fDisassociation frm;
4201 tANI_U8 *pFrame;
4202 tSirRetStatus nSirStatus;
4203 tpSirMacMgmtHdr pMacHdr;
4204 tANI_U32 nBytes, nPayload, nStatus;
4205 void *pPacket;
4206 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304207 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004208 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 if(NULL == psessionEntry)
4210 {
4211 return;
4212 }
4213
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304214 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004215
4216 frm.Reason.code = nReason;
4217
4218 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4219 if ( DOT11F_FAILED( nStatus ) )
4220 {
4221 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004222 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 nStatus );
4224 // We'll fall back on the worst case scenario:
4225 nPayload = sizeof( tDot11fDisassociation );
4226 }
4227 else if ( DOT11F_WARNED( nStatus ) )
4228 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004229 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004230 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004231 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 }
4233
4234 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4235
4236 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4237 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4238 ( void** ) &pPacket );
4239 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4240 {
4241 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004242 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 return;
4244 }
4245
4246 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304247 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004248
4249 // Next, we fill out the buffer descriptor:
4250 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4251 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4252 if ( eSIR_SUCCESS != nSirStatus )
4253 {
4254 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004255 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 nSirStatus );
4257 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4258 ( void* ) pFrame, ( void* ) pPacket );
4259 return; // just allocated...
4260 }
4261
4262 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4263
4264 // Prepare the BSSID
4265 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4266
Chet Lanctot186b5732013-03-18 10:26:30 -07004267#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004268 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004269#endif
4270
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4272 sizeof(tSirMacMgmtHdr),
4273 nPayload, &nPayload );
4274 if ( DOT11F_FAILED( nStatus ) )
4275 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004276 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 nStatus );
4278 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4279 ( void* ) pFrame, ( void* ) pPacket );
4280 return; // allocated!
4281 }
4282 else if ( DOT11F_WARNED( nStatus ) )
4283 {
4284 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004285 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 }
4287
Abhishek Singhcd09b562013-12-24 16:02:20 +05304288 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4289 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4290 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4291 MAC_ADDR_ARRAY(pMacHdr->da),
4292 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004293
4294 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4296 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 )
4298 {
4299 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4300 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004301
Sushant Kaushike8681d22015-04-21 12:08:25 +05304302 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004303
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304304 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4305 {
4306 /* This frame will be sent on air by firmware,
4307 which will ensure that this frame goes out
4308 even though DEL_STA is sent immediately */
4309 /* Without this for DEL_STA command there is
4310 risk of flushing frame in BTQM queue without
4311 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304312 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4313 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4314 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304315 txFlag |= HAL_USE_FW_IN_TX_PATH;
4316 }
4317
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004318 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304320 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4321 psessionEntry->peSessionId,
4322 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004323 // Queue Disassociation frame in high priority WQ
4324 /* get the duration from the request */
4325 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4326 HAL_TXRX_FRM_802_11_MGMT,
4327 ANI_TXDIR_TODS,
4328 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4329 limTxComplete, pFrame, limDisassocTxCompleteCnf,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304330 txFlag,
4331 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304332 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4333 psessionEntry->peSessionId,
4334 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004335 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004336
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004337 if (tx_timer_change(
4338 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4339 != TX_SUCCESS)
4340 {
4341 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004342 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004343 return;
4344 }
4345 else if(TX_SUCCESS != tx_timer_activate(
4346 &pMac->lim.limTimers.gLimDisassocAckTimer))
4347 {
4348 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004349 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004350 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4351 return;
4352 }
4353 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004354 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004355 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304356 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4357 psessionEntry->peSessionId,
4358 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004359 // Queue Disassociation frame in high priority WQ
4360 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4361 HAL_TXRX_FRM_802_11_MGMT,
4362 ANI_TXDIR_TODS,
4363 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4364 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304365 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4366 psessionEntry->peSessionId,
4367 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004368 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4369 {
4370 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004371 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004372 nSirStatus );
4373 //Pkt will be freed up by the callback
4374 return;
4375 }
4376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004377} // End limSendDisassocMgmtFrame.
4378
4379/**
4380 * \brief This function is called to send a Deauthenticate frame
4381 *
4382 *
4383 * \param pMac Pointer to global MAC structure
4384 *
4385 * \param nReason Indicates the reason that need to be sent in the
4386 * Deauthenticate frame
4387 *
4388 * \param peeer address of the STA to which the frame is to be sent
4389 *
4390 *
4391 */
4392
4393void
4394limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4395 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004396 tSirMacAddr peer,
4397 tpPESession psessionEntry,
4398 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004399{
4400 tDot11fDeAuth frm;
4401 tANI_U8 *pFrame;
4402 tSirRetStatus nSirStatus;
4403 tpSirMacMgmtHdr pMacHdr;
4404 tANI_U32 nBytes, nPayload, nStatus;
4405 void *pPacket;
4406 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304407 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004408 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004409#ifdef FEATURE_WLAN_TDLS
4410 tANI_U16 aid;
4411 tpDphHashNode pStaDs;
4412#endif
4413
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 if(NULL == psessionEntry)
4415 {
4416 return;
4417 }
4418
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304419 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004420
4421 frm.Reason.code = nReason;
4422
4423 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4424 if ( DOT11F_FAILED( nStatus ) )
4425 {
4426 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004427 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 nStatus );
4429 // We'll fall back on the worst case scenario:
4430 nPayload = sizeof( tDot11fDeAuth );
4431 }
4432 else if ( DOT11F_WARNED( nStatus ) )
4433 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004434 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004436 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 }
4438
4439 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4440
4441 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4442 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4443 ( void** ) &pPacket );
4444 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4445 {
4446 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004447 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 return;
4449 }
4450
4451 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304452 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004453
4454 // Next, we fill out the buffer descriptor:
4455 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4456 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4457 if ( eSIR_SUCCESS != nSirStatus )
4458 {
4459 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004460 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 nSirStatus );
4462 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4463 ( void* ) pFrame, ( void* ) pPacket );
4464 return; // just allocated...
4465 }
4466
4467 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4468
4469 // Prepare the BSSID
4470 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4471
Chet Lanctot186b5732013-03-18 10:26:30 -07004472#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004473 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004474#endif
4475
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4477 sizeof(tSirMacMgmtHdr),
4478 nPayload, &nPayload );
4479 if ( DOT11F_FAILED( nStatus ) )
4480 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004481 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 nStatus );
4483 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4484 ( void* ) pFrame, ( void* ) pPacket );
4485 return;
4486 }
4487 else if ( DOT11F_WARNED( nStatus ) )
4488 {
4489 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004490 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304492 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4493 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4494 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4495 MAC_ADDR_ARRAY(pMacHdr->da),
4496 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004497
4498 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4500 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 )
4502 {
4503 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4504 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004505
Sushant Kaushike8681d22015-04-21 12:08:25 +05304506 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004507
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304508 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4509 {
4510 /* This frame will be sent on air by firmware,
4511 which will ensure that this frame goes out
4512 even though DEL_STA is sent immediately */
4513 /* Without this for DEL_STA command there is
4514 risk of flushing frame in BTQM queue without
4515 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304516 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4517 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4518 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304519 txFlag |= HAL_USE_FW_IN_TX_PATH;
4520 }
4521
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004522#ifdef FEATURE_WLAN_TDLS
4523 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4524#endif
4525
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004526 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304528 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4529 psessionEntry->peSessionId,
4530 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004531 // Queue Disassociation frame in high priority WQ
4532 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4533 HAL_TXRX_FRM_802_11_MGMT,
4534 ANI_TXDIR_TODS,
4535 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304536 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag,
4537 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304538 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4539 psessionEntry->peSessionId,
4540 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304541 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004542 {
4543 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304544 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004545 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004546 //Pkt will be freed up by the callback limTxComplete
4547
4548 /*Call limProcessDeauthAckTimeout which will send
4549 * DeauthCnf for this frame
4550 */
4551 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004552 return;
4553 }
4554
4555 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4556
4557 if (tx_timer_change(
4558 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4559 != TX_SUCCESS)
4560 {
4561 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004562 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004563 return;
4564 }
4565 else if(TX_SUCCESS != tx_timer_activate(
4566 &pMac->lim.limTimers.gLimDeauthAckTimer))
4567 {
4568 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004569 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004570 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4571 return;
4572 }
4573 }
4574 else
4575 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304576 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4577 psessionEntry->peSessionId,
4578 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004579#ifdef FEATURE_WLAN_TDLS
4580 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4581 {
4582 // Queue Disassociation frame in high priority WQ
4583 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004584 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004585 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004586 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4587 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004588 }
4589 else
4590 {
4591#endif
4592 // Queue Disassociation frame in high priority WQ
4593 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4594 HAL_TXRX_FRM_802_11_MGMT,
4595 ANI_TXDIR_TODS,
4596 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4597 limTxComplete, pFrame, txFlag );
4598#ifdef FEATURE_WLAN_TDLS
4599 }
4600#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304601 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4602 psessionEntry->peSessionId,
4603 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004604 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4605 {
4606 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004607 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004608 nSirStatus );
4609 //Pkt will be freed up by the callback
4610 return;
4611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 }
4613
4614} // End limSendDeauthMgmtFrame.
4615
4616
4617#ifdef ANI_SUPPORT_11H
4618/**
4619 * \brief Send a Measurement Report Action frame
4620 *
4621 *
4622 * \param pMac Pointer to the global MAC structure
4623 *
4624 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4625 *
4626 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4627 *
4628 *
4629 */
4630
4631tSirRetStatus
4632limSendMeasReportFrame(tpAniSirGlobal pMac,
4633 tpSirMacMeasReqActionFrame pMeasReqFrame,
4634 tSirMacAddr peer)
4635{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304636 tDot11fMeasurementReport frm;
4637 tANI_U8 *pFrame;
4638 tSirRetStatus nSirStatus;
4639 tpSirMacMgmtHdr pMacHdr;
4640 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4641 void *pPacket;
4642 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004643
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304644 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004645
4646 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4647 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4648 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4649
4650 switch ( pMeasReqFrame->measReqIE.measType )
4651 {
4652 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4653 nSirStatus =
4654 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4655 &frm.MeasurementReport );
4656 break;
4657 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4658 nSirStatus =
4659 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4660 &frm.MeasurementReport );
4661 break;
4662 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4663 nSirStatus =
4664 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4665 &frm.MeasurementReport );
4666 break;
4667 default:
4668 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004669 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 pMeasReqFrame->measReqIE.measType );
4671 return eSIR_FAILURE;
4672 }
4673
4674 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4675
4676 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4677 if ( DOT11F_FAILED( nStatus ) )
4678 {
4679 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004680 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 nStatus );
4682 // We'll fall back on the worst case scenario:
4683 nPayload = sizeof( tDot11fMeasurementReport );
4684 }
4685 else if ( DOT11F_WARNED( nStatus ) )
4686 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004687 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004689 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004690 }
4691
4692 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4693
4694 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4695 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4696 {
4697 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004698 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004699 return eSIR_FAILURE;
4700 }
4701
4702 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304703 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004704
4705 // Next, we fill out the buffer descriptor:
4706 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4707 SIR_MAC_MGMT_ACTION, peer);
4708 if ( eSIR_SUCCESS != nSirStatus )
4709 {
4710 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004711 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 nSirStatus );
4713 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4714 return eSIR_FAILURE; // just allocated...
4715 }
4716
4717 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4718
4719 nCfg = 6;
4720 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4721 if ( eSIR_SUCCESS != nSirStatus )
4722 {
4723 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004724 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 nSirStatus );
4726 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4727 return eSIR_FAILURE; // just allocated...
4728 }
4729
Chet Lanctot186b5732013-03-18 10:26:30 -07004730#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004731 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004732#endif
4733
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4735 sizeof(tSirMacMgmtHdr),
4736 nPayload, &nPayload );
4737 if ( DOT11F_FAILED( nStatus ) )
4738 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004739 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 nStatus );
4741 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4742 return eSIR_FAILURE; // allocated!
4743 }
4744 else if ( DOT11F_WARNED( nStatus ) )
4745 {
4746 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004747 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 }
4749
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304750 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4751 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4752 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4754 HAL_TXRX_FRM_802_11_MGMT,
4755 ANI_TXDIR_TODS,
4756 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4757 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304758 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4759 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4760 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4762 {
4763 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004764 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 nSirStatus );
4766 //Pkt will be freed up by the callback
4767 return eSIR_FAILURE; // just allocated...
4768 }
4769
4770 return eSIR_SUCCESS;
4771
4772} // End limSendMeasReportFrame.
4773
4774
4775/**
4776 * \brief Send a TPC Request Action frame
4777 *
4778 *
4779 * \param pMac Pointer to the global MAC datastructure
4780 *
4781 * \param peer MAC address to which the frame should be sent
4782 *
4783 *
4784 */
4785
4786void
4787limSendTpcRequestFrame(tpAniSirGlobal pMac,
4788 tSirMacAddr peer)
4789{
4790 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304791 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 tSirRetStatus nSirStatus;
4793 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304794 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4795 void *pPacket;
4796 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004797
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304798 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004799
4800 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4801 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4802 frm.DialogToken.token = 1;
4803 frm.TPCRequest.present = 1;
4804
4805 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4806 if ( DOT11F_FAILED( nStatus ) )
4807 {
4808 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004809 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 nStatus );
4811 // We'll fall back on the worst case scenario:
4812 nPayload = sizeof( tDot11fTPCRequest );
4813 }
4814 else if ( DOT11F_WARNED( nStatus ) )
4815 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004816 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004818 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 }
4820
4821 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4822
4823 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4824 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4825 {
4826 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004827 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 return;
4829 }
4830
4831 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304832 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004833
4834 // Next, we fill out the buffer descriptor:
4835 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4836 SIR_MAC_MGMT_ACTION, peer);
4837 if ( eSIR_SUCCESS != nSirStatus )
4838 {
4839 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004840 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 nSirStatus );
4842 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4843 return; // just allocated...
4844 }
4845
4846 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4847
4848 nCfg = 6;
4849 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4850 if ( eSIR_SUCCESS != nSirStatus )
4851 {
4852 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004853 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 nSirStatus );
4855 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4856 return; // just allocated...
4857 }
4858
Chet Lanctot186b5732013-03-18 10:26:30 -07004859#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004860 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004861#endif
4862
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4864 sizeof(tSirMacMgmtHdr),
4865 nPayload, &nPayload );
4866 if ( DOT11F_FAILED( nStatus ) )
4867 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004868 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 nStatus );
4870 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4871 return; // allocated!
4872 }
4873 else if ( DOT11F_WARNED( nStatus ) )
4874 {
4875 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004876 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 }
4878
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304879 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4880 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4881 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4883 HAL_TXRX_FRM_802_11_MGMT,
4884 ANI_TXDIR_TODS,
4885 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4886 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304887 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4888 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4889 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4891 {
4892 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004893 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 nSirStatus );
4895 //Pkt will be freed up by the callback
4896 return;
4897 }
4898
4899} // End limSendTpcRequestFrame.
4900
4901
4902/**
4903 * \brief Send a TPC Report Action frame
4904 *
4905 *
4906 * \param pMac Pointer to the global MAC datastructure
4907 *
4908 * \param pTpcReqFrame Pointer to the received TPC Request
4909 *
4910 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4911 *
4912 *
4913 */
4914
4915tSirRetStatus
4916limSendTpcReportFrame(tpAniSirGlobal pMac,
4917 tpSirMacTpcReqActionFrame pTpcReqFrame,
4918 tSirMacAddr peer)
4919{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304920 tDot11fTPCReport frm;
4921 tANI_U8 *pFrame;
4922 tSirRetStatus nSirStatus;
4923 tpSirMacMgmtHdr pMacHdr;
4924 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4925 void *pPacket;
4926 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004927
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304928 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004929
4930 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4931 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4932 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4933
4934 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4935 // "misplaced this function, need to replace:
4936 // txPower = halGetRateToPwrValue(pMac, staid,
4937 // pMac->lim.gLimCurrentChannelId, 0);
4938 frm.TPCReport.tx_power = 0;
4939 frm.TPCReport.link_margin = 0;
4940 frm.TPCReport.present = 1;
4941
4942 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4943 if ( DOT11F_FAILED( nStatus ) )
4944 {
4945 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004946 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 nStatus );
4948 // We'll fall back on the worst case scenario:
4949 nPayload = sizeof( tDot11fTPCReport );
4950 }
4951 else if ( DOT11F_WARNED( nStatus ) )
4952 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004953 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004955 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 }
4957
4958 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4959
4960 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4961 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4962 {
4963 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004964 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 return eSIR_FAILURE;
4966 }
4967
4968 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304969 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004970
4971 // Next, we fill out the buffer descriptor:
4972 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4973 SIR_MAC_MGMT_ACTION, peer);
4974 if ( eSIR_SUCCESS != nSirStatus )
4975 {
4976 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004977 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 nSirStatus );
4979 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4980 return eSIR_FAILURE; // just allocated...
4981 }
4982
4983 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4984
4985 nCfg = 6;
4986 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4987 if ( eSIR_SUCCESS != nSirStatus )
4988 {
4989 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004990 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 nSirStatus );
4992 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4993 return eSIR_FAILURE; // just allocated...
4994 }
4995
Chet Lanctot186b5732013-03-18 10:26:30 -07004996#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004997 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004998#endif
4999
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
5001 sizeof(tSirMacMgmtHdr),
5002 nPayload, &nPayload );
5003 if ( DOT11F_FAILED( nStatus ) )
5004 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005005 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 nStatus );
5007 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5008 return eSIR_FAILURE; // allocated!
5009 }
5010 else if ( DOT11F_WARNED( nStatus ) )
5011 {
5012 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005013 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 }
5015
5016
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305017 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5018 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5019 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5021 HAL_TXRX_FRM_802_11_MGMT,
5022 ANI_TXDIR_TODS,
5023 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5024 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305025 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5026 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5027 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5029 {
5030 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005031 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 nSirStatus );
5033 //Pkt will be freed up by the callback
5034 return eSIR_FAILURE; // just allocated...
5035 }
5036
5037 return eSIR_SUCCESS;
5038
5039} // End limSendTpcReportFrame.
5040#endif //ANI_SUPPORT_11H
5041
5042
Jeff Johnson295189b2012-06-20 16:38:30 -07005043/**
5044 * \brief Send a Channel Switch Announcement
5045 *
5046 *
5047 * \param pMac Pointer to the global MAC datastructure
5048 *
5049 * \param peer MAC address to which this frame will be sent
5050 *
5051 * \param nMode
5052 *
5053 * \param nNewChannel
5054 *
5055 * \param nCount
5056 *
5057 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5058 *
5059 *
5060 */
5061
5062tSirRetStatus
5063limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5064 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07005065 tANI_U8 nMode,
5066 tANI_U8 nNewChannel,
5067 tANI_U8 nCount,
5068 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07005069{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305070 tDot11fChannelSwitch frm;
5071 tANI_U8 *pFrame;
5072 tSirRetStatus nSirStatus;
5073 tpSirMacMgmtHdr pMacHdr;
5074 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5075 void *pPacket;
5076 eHalStatus halstatus;
5077 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005078
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305079 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005080
5081 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5082 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5083 frm.ChanSwitchAnn.switchMode = nMode;
5084 frm.ChanSwitchAnn.newChannel = nNewChannel;
5085 frm.ChanSwitchAnn.switchCount = nCount;
5086 frm.ChanSwitchAnn.present = 1;
5087
5088 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5089 if ( DOT11F_FAILED( nStatus ) )
5090 {
5091 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005092 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 nStatus );
5094 // We'll fall back on the worst case scenario:
5095 nPayload = sizeof( tDot11fChannelSwitch );
5096 }
5097 else if ( DOT11F_WARNED( nStatus ) )
5098 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005099 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005101 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005102 }
5103
5104 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5105
5106 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5107 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5108 {
5109 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005110 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005111 return eSIR_FAILURE;
5112 }
5113
5114 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305115 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005116
5117 // Next, we fill out the buffer descriptor:
5118 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07005119 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5120 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305121 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5122 (tANI_U8 *) psessionEntry->bssId,
5123 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 if ( eSIR_SUCCESS != nSirStatus )
5125 {
5126 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005127 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 nSirStatus );
5129 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5130 return eSIR_FAILURE; // just allocated...
5131 }
5132
Jeff Johnsone7245742012-09-05 17:12:55 -07005133#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5135
5136 nCfg = 6;
5137 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5138 if ( eSIR_SUCCESS != nSirStatus )
5139 {
5140 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005141 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 nSirStatus );
5143 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5144 return eSIR_FAILURE; // just allocated...
5145 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005146#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005147
5148#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005149 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005150#endif
5151
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5153 sizeof(tSirMacMgmtHdr),
5154 nPayload, &nPayload );
5155 if ( DOT11F_FAILED( nStatus ) )
5156 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005157 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 nStatus );
5159 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5160 return eSIR_FAILURE; // allocated!
5161 }
5162 else if ( DOT11F_WARNED( nStatus ) )
5163 {
5164 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005165 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 }
5167
Jeff Johnsone7245742012-09-05 17:12:55 -07005168 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07005169 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5170 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07005171 )
5172 {
5173 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5174 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305175
5176 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5177 psessionEntry->peSessionId,
5178 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5180 HAL_TXRX_FRM_802_11_MGMT,
5181 ANI_TXDIR_TODS,
5182 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07005183 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305184 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5185 psessionEntry->peSessionId,
5186 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005187 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5188 {
5189 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005190 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 nSirStatus );
5192 //Pkt will be freed up by the callback
5193 return eSIR_FAILURE;
5194 }
5195
5196 return eSIR_SUCCESS;
5197
5198} // End limSendChannelSwitchMgmtFrame.
5199
Jeff Johnson295189b2012-06-20 16:38:30 -07005200
5201
Mohit Khanna4a70d262012-09-11 16:30:12 -07005202#ifdef WLAN_FEATURE_11AC
5203tSirRetStatus
5204limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5205 tSirMacAddr peer,
5206 tANI_U8 nMode,
5207 tpPESession psessionEntry )
5208{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305209 tDot11fOperatingMode frm;
5210 tANI_U8 *pFrame;
5211 tSirRetStatus nSirStatus;
5212 tpSirMacMgmtHdr pMacHdr;
5213 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5214 void *pPacket;
5215 eHalStatus halstatus;
5216 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005217
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305218 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005219
5220 frm.Category.category = SIR_MAC_ACTION_VHT;
5221 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5222 frm.OperatingMode.chanWidth = nMode;
5223 frm.OperatingMode.rxNSS = 0;
5224 frm.OperatingMode.rxNSSType = 0;
5225
5226 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5227 if ( DOT11F_FAILED( nStatus ) )
5228 {
5229 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005230 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005231 nStatus );
5232 // We'll fall back on the worst case scenario:
5233 nPayload = sizeof( tDot11fOperatingMode);
5234 }
5235 else if ( DOT11F_WARNED( nStatus ) )
5236 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005237 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005238 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005239 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005240 }
5241
5242 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5243
5244 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5245 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5246 {
5247 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005248 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005249 return eSIR_FAILURE;
5250 }
5251
5252 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305253 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005254
5255
5256 // Next, we fill out the buffer descriptor:
5257 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5258 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5259 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5260 } else
5261 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5262 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5263 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305264 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5265 (tANI_U8 *) psessionEntry->bssId,
5266 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005267 if ( eSIR_SUCCESS != nSirStatus )
5268 {
5269 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005270 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005271 nSirStatus );
5272 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5273 return eSIR_FAILURE; // just allocated...
5274 }
5275 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5276 sizeof(tSirMacMgmtHdr),
5277 nPayload, &nPayload );
5278 if ( DOT11F_FAILED( nStatus ) )
5279 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005280 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005281 nStatus );
5282 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5283 return eSIR_FAILURE; // allocated!
5284 }
5285 else if ( DOT11F_WARNED( nStatus ) )
5286 {
5287 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005288 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005289 }
5290 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005291 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5292 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005293 )
5294 {
5295 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5296 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305297
5298 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5299 psessionEntry->peSessionId,
5300 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005301 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5302 HAL_TXRX_FRM_802_11_MGMT,
5303 ANI_TXDIR_TODS,
5304 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5305 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305306 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5307 psessionEntry->peSessionId,
5308 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005309 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5310 {
5311 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005312 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005313 nSirStatus );
5314 //Pkt will be freed up by the callback
5315 return eSIR_FAILURE;
5316 }
5317
5318 return eSIR_SUCCESS;
5319}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005320
5321/**
5322 * \brief Send a VHT Channel Switch Announcement
5323 *
5324 *
5325 * \param pMac Pointer to the global MAC datastructure
5326 *
5327 * \param peer MAC address to which this frame will be sent
5328 *
5329 * \param nChanWidth
5330 *
5331 * \param nNewChannel
5332 *
5333 *
5334 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5335 *
5336 *
5337 */
5338
5339tSirRetStatus
5340limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5341 tSirMacAddr peer,
5342 tANI_U8 nChanWidth,
5343 tANI_U8 nNewChannel,
5344 tANI_U8 ncbMode,
5345 tpPESession psessionEntry )
5346{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305347 tDot11fChannelSwitch frm;
5348 tANI_U8 *pFrame;
5349 tSirRetStatus nSirStatus;
5350 tpSirMacMgmtHdr pMacHdr;
5351 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5352 void *pPacket;
5353 eHalStatus halstatus;
5354 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005355
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305356 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005357
5358
5359 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5360 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5361 frm.ChanSwitchAnn.switchMode = 1;
5362 frm.ChanSwitchAnn.newChannel = nNewChannel;
5363 frm.ChanSwitchAnn.switchCount = 1;
5364 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5365 frm.ExtChanSwitchAnn.present = 1;
5366 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5367 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5368 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5369 frm.ChanSwitchAnn.present = 1;
5370 frm.WiderBWChanSwitchAnn.present = 1;
5371
5372 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5373 if ( DOT11F_FAILED( nStatus ) )
5374 {
5375 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005376 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005377 nStatus );
5378 // We'll fall back on the worst case scenario:
5379 nPayload = sizeof( tDot11fChannelSwitch );
5380 }
5381 else if ( DOT11F_WARNED( nStatus ) )
5382 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005383 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005384 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005385 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005386 }
5387
5388 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5389
5390 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5391 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5392 {
5393 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005394 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005395 return eSIR_FAILURE;
5396 }
5397 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305398 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005399
5400 // Next, we fill out the buffer descriptor:
5401 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5402 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5403 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305404 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5405 (tANI_U8 *) psessionEntry->bssId,
5406 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005407 if ( eSIR_SUCCESS != nSirStatus )
5408 {
5409 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005410 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005411 nSirStatus );
5412 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5413 return eSIR_FAILURE; // just allocated...
5414 }
5415 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5416 sizeof(tSirMacMgmtHdr),
5417 nPayload, &nPayload );
5418 if ( DOT11F_FAILED( nStatus ) )
5419 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005420 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005421 nStatus );
5422 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5423 return eSIR_FAILURE; // allocated!
5424 }
5425 else if ( DOT11F_WARNED( nStatus ) )
5426 {
5427 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005428 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005429 }
5430
5431 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005432 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5433 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005434 )
5435 {
5436 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5437 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305438
5439 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5440 psessionEntry->peSessionId,
5441 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005442 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5443 HAL_TXRX_FRM_802_11_MGMT,
5444 ANI_TXDIR_TODS,
5445 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5446 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305447 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5448 psessionEntry->peSessionId,
5449 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005450 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5451 {
5452 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005453 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005454 nSirStatus );
5455 //Pkt will be freed up by the callback
5456 return eSIR_FAILURE;
5457 }
5458
5459 return eSIR_SUCCESS;
5460
5461} // End limSendVHTChannelSwitchMgmtFrame.
5462
5463
5464
Mohit Khanna4a70d262012-09-11 16:30:12 -07005465#endif
5466
Jeff Johnson295189b2012-06-20 16:38:30 -07005467/**
5468 * \brief Send an ADDBA Req Action Frame to peer
5469 *
5470 * \sa limSendAddBAReq
5471 *
5472 * \param pMac The global tpAniSirGlobal object
5473 *
5474 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5475 * the necessary parameters reqd by PE send the ADDBA Req Action
5476 * Frame to the peer
5477 *
5478 * \return eSIR_SUCCESS if setup completes successfully
5479 * eSIR_FAILURE is some problem is encountered
5480 */
5481tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305482 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005483{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305484 tDot11fAddBAReq frmAddBAReq;
5485 tANI_U8 *pAddBAReqBuffer = NULL;
5486 tpSirMacMgmtHdr pMacHdr;
5487 tANI_U32 frameLen = 0, nStatus, nPayload;
5488 tSirRetStatus statusCode;
5489 eHalStatus halStatus;
5490 void *pPacket;
5491 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005492
5493 if(NULL == psessionEntry)
5494 {
5495 return eSIR_FAILURE;
5496 }
5497
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305498 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005499
5500 // Category - 3 (BA)
5501 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5502
5503 // Action - 0 (ADDBA Req)
5504 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5505
5506 // FIXME - Dialog Token, generalize this...
5507 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5508
5509 // Fill the ADDBA Parameter Set
5510 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5511 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5512 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5513
5514 // BA timeout
5515 // 0 - indicates no BA timeout
5516 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5517
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305518 /* Send SSN whatever we get from FW.
5519 */
5520 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005521
5522 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5523
5524 if( DOT11F_FAILED( nStatus ))
5525 {
5526 limLog( pMac, LOGW,
5527 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005528 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 nStatus );
5530
5531 // We'll fall back on the worst case scenario:
5532 nPayload = sizeof( tDot11fAddBAReq );
5533 }
5534 else if( DOT11F_WARNED( nStatus ))
5535 {
5536 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005537 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005538 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 nStatus );
5540 }
5541
5542 // Add the MGMT header to frame length
5543 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5544
5545 // Need to allocate a buffer for ADDBA AF
5546 if( eHAL_STATUS_SUCCESS !=
5547 (halStatus = palPktAlloc( pMac->hHdd,
5548 HAL_TXRX_FRM_802_11_MGMT,
5549 (tANI_U16) frameLen,
5550 (void **) &pAddBAReqBuffer,
5551 (void **) &pPacket )))
5552 {
5553 // Log error
5554 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005555 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 frameLen,
5557 halStatus );
5558
5559 statusCode = eSIR_MEM_ALLOC_FAILED;
5560 goto returnAfterError;
5561 }
5562
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305563 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005564
5565 // Copy necessary info to BD
5566 if( eSIR_SUCCESS !=
5567 (statusCode = limPopulateMacHeader( pMac,
5568 pAddBAReqBuffer,
5569 SIR_MAC_MGMT_FRAME,
5570 SIR_MAC_MGMT_ACTION,
5571 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5572 goto returnAfterError;
5573
5574 // Update A3 with the BSSID
5575 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5576
5577 #if 0
5578 cfgLen = SIR_MAC_ADDR_LENGTH;
5579 if( eSIR_SUCCESS != cfgGetStr( pMac,
5580 WNI_CFG_BSSID,
5581 (tANI_U8 *) pMacHdr->bssId,
5582 &cfgLen ))
5583 {
5584 limLog( pMac, LOGP,
5585 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005586 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005587
5588 // FIXME - Need to convert to tSirRetStatus
5589 statusCode = eSIR_FAILURE;
5590 goto returnAfterError;
5591 }
5592 #endif//TO SUPPORT BT-AMP
5593 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5594
Chet Lanctot186b5732013-03-18 10:26:30 -07005595#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005596 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005597#endif
5598
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 // Now, we're ready to "pack" the frames
5600 nStatus = dot11fPackAddBAReq( pMac,
5601 &frmAddBAReq,
5602 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5603 nPayload,
5604 &nPayload );
5605
5606 if( DOT11F_FAILED( nStatus ))
5607 {
5608 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005609 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 nStatus );
5611
5612 // FIXME - Need to convert to tSirRetStatus
5613 statusCode = eSIR_FAILURE;
5614 goto returnAfterError;
5615 }
5616 else if( DOT11F_WARNED( nStatus ))
5617 {
5618 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005619 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5620 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 }
5622
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305623 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5624 " tid = %d policy = %d buffsize = %d "
5625 " amsduSupported = %d"),
5626 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5627 frmAddBAReq.AddBAParameterSet.tid,
5628 frmAddBAReq.AddBAParameterSet.policy,
5629 frmAddBAReq.AddBAParameterSet.bufferSize,
5630 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005631
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305632 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5633 frmAddBAReq.BAStartingSequenceControl.ssn,
5634 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5635
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5638 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 )
5640 {
5641 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5642 }
5643
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305644 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5645 psessionEntry->peSessionId,
5646 pMacHdr->fc.subType));
5647 halStatus = halTxFrame( pMac,
5648 pPacket,
5649 (tANI_U16) frameLen,
5650 HAL_TXRX_FRM_802_11_MGMT,
5651 ANI_TXDIR_TODS,
5652 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5653 limTxComplete,
5654 pAddBAReqBuffer, txFlag );
5655 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5656 psessionEntry->peSessionId,
5657 halStatus));
5658 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 {
5660 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005661 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 halStatus );
5663
5664 // FIXME - Need to convert eHalStatus to tSirRetStatus
5665 statusCode = eSIR_FAILURE;
5666 //Pkt will be freed up by the callback
5667 return statusCode;
5668 }
5669 else
5670 return eSIR_SUCCESS;
5671
5672returnAfterError:
5673
5674 // Release buffer, if allocated
5675 if( NULL != pAddBAReqBuffer )
5676 palPktFree( pMac->hHdd,
5677 HAL_TXRX_FRM_802_11_MGMT,
5678 (void *) pAddBAReqBuffer,
5679 (void *) pPacket );
5680
5681 return statusCode;
5682}
5683
5684/**
5685 * \brief Send an ADDBA Rsp Action Frame to peer
5686 *
5687 * \sa limSendAddBARsp
5688 *
5689 * \param pMac The global tpAniSirGlobal object
5690 *
5691 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5692 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5693 * Frame to the peer
5694 *
5695 * \return eSIR_SUCCESS if setup completes successfully
5696 * eSIR_FAILURE is some problem is encountered
5697 */
5698tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5699 tpLimMlmAddBARsp pMlmAddBARsp,
5700 tpPESession psessionEntry)
5701{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305702 tDot11fAddBARsp frmAddBARsp;
5703 tANI_U8 *pAddBARspBuffer = NULL;
5704 tpSirMacMgmtHdr pMacHdr;
5705 tANI_U32 frameLen = 0, nStatus, nPayload;
5706 tSirRetStatus statusCode;
5707 eHalStatus halStatus;
5708 void *pPacket;
5709 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005710
5711 if(NULL == psessionEntry)
5712 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005713 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 return eSIR_FAILURE;
5715 }
5716
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305717 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005718
5719 // Category - 3 (BA)
5720 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5721 // Action - 1 (ADDBA Rsp)
5722 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5723
5724 // Should be same as the one we received in the ADDBA Req
5725 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5726
5727 // ADDBA Req status
5728 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5729
5730 // Fill the ADDBA Parameter Set as provided by caller
5731 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5732 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5733 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005734
5735 if(psessionEntry->isAmsduSupportInAMPDU)
5736 {
5737 frmAddBARsp.AddBAParameterSet.amsduSupported =
5738 psessionEntry->amsduSupportedInBA;
5739 }
5740 else
5741 {
5742 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005744
5745 // BA timeout
5746 // 0 - indicates no BA timeout
5747 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5748
5749 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5750
5751 if( DOT11F_FAILED( nStatus ))
5752 {
5753 limLog( pMac, LOGW,
5754 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005755 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 nStatus );
5757
5758 // We'll fall back on the worst case scenario:
5759 nPayload = sizeof( tDot11fAddBARsp );
5760 }
5761 else if( DOT11F_WARNED( nStatus ))
5762 {
5763 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005764 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005765 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 nStatus );
5767 }
5768
5769 // Need to allocate a buffer for ADDBA AF
5770 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5771
5772 // Allocate shared memory
5773 if( eHAL_STATUS_SUCCESS !=
5774 (halStatus = palPktAlloc( pMac->hHdd,
5775 HAL_TXRX_FRM_802_11_MGMT,
5776 (tANI_U16) frameLen,
5777 (void **) &pAddBARspBuffer,
5778 (void **) &pPacket )))
5779 {
5780 // Log error
5781 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005782 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 frameLen,
5784 halStatus );
5785
5786 statusCode = eSIR_MEM_ALLOC_FAILED;
5787 goto returnAfterError;
5788 }
5789
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305790 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005791
5792 // Copy necessary info to BD
5793 if( eSIR_SUCCESS !=
5794 (statusCode = limPopulateMacHeader( pMac,
5795 pAddBARspBuffer,
5796 SIR_MAC_MGMT_FRAME,
5797 SIR_MAC_MGMT_ACTION,
5798 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5799 goto returnAfterError;
5800
5801 // Update A3 with the BSSID
5802
5803 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5804
5805 #if 0
5806 cfgLen = SIR_MAC_ADDR_LENGTH;
5807 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5808 WNI_CFG_BSSID,
5809 (tANI_U8 *) pMacHdr->bssId,
5810 &cfgLen ))
5811 {
5812 limLog( pMac, LOGP,
5813 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005814 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005815
5816 // FIXME - Need to convert to tSirRetStatus
5817 statusCode = eSIR_FAILURE;
5818 goto returnAfterError;
5819 }
5820 #endif // TO SUPPORT BT-AMP
5821 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5822
Chet Lanctot186b5732013-03-18 10:26:30 -07005823#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005824 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005825#endif
5826
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 // Now, we're ready to "pack" the frames
5828 nStatus = dot11fPackAddBARsp( pMac,
5829 &frmAddBARsp,
5830 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5831 nPayload,
5832 &nPayload );
5833
5834 if( DOT11F_FAILED( nStatus ))
5835 {
5836 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005837 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 nStatus );
5839
5840 // FIXME - Need to convert to tSirRetStatus
5841 statusCode = eSIR_FAILURE;
5842 goto returnAfterError;
5843 }
5844 else if( DOT11F_WARNED( nStatus ))
5845 {
5846 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005847 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5848 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 }
5850
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305851 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5852 " tid = %d policy = %d buffsize = %d"
5853 " amsduSupported = %d status %d"),
5854 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5855 frmAddBARsp.AddBAParameterSet.tid,
5856 frmAddBARsp.AddBAParameterSet.policy,
5857 frmAddBARsp.AddBAParameterSet.bufferSize,
5858 frmAddBARsp.AddBAParameterSet.amsduSupported,
5859 frmAddBARsp.Status.status);
5860
Jeff Johnson295189b2012-06-20 16:38:30 -07005861
5862 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5864 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 )
5866 {
5867 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5868 }
5869
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305870 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5871 psessionEntry->peSessionId,
5872 pMacHdr->fc.subType));
5873 halStatus = halTxFrame( pMac,
5874 pPacket,
5875 (tANI_U16) frameLen,
5876 HAL_TXRX_FRM_802_11_MGMT,
5877 ANI_TXDIR_TODS,
5878 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5879 limTxComplete,
5880 pAddBARspBuffer, txFlag );
5881 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5882 psessionEntry->peSessionId,
5883 halStatus));
5884 if( eHAL_STATUS_SUCCESS != halStatus )
5885 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005887 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005888 halStatus );
5889
5890 // FIXME - HAL error codes are different from PE error
5891 // codes!! And, this routine is returning tSirRetStatus
5892 statusCode = eSIR_FAILURE;
5893 //Pkt will be freed up by the callback
5894 return statusCode;
5895 }
5896 else
5897 return eSIR_SUCCESS;
5898
5899 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 // Release buffer, if allocated
5901 if( NULL != pAddBARspBuffer )
5902 palPktFree( pMac->hHdd,
5903 HAL_TXRX_FRM_802_11_MGMT,
5904 (void *) pAddBARspBuffer,
5905 (void *) pPacket );
5906
5907 return statusCode;
5908}
5909
5910/**
5911 * \brief Send a DELBA Indication Action Frame to peer
5912 *
5913 * \sa limSendDelBAInd
5914 *
5915 * \param pMac The global tpAniSirGlobal object
5916 *
5917 * \param peerMacAddr MAC Address of peer
5918 *
5919 * \param reasonCode Reason for the DELBA notification
5920 *
5921 * \param pBAParameterSet The DELBA Parameter Set.
5922 * This identifies the TID for which the BA session is
5923 * being deleted.
5924 *
5925 * \return eSIR_SUCCESS if setup completes successfully
5926 * eSIR_FAILURE is some problem is encountered
5927 */
5928tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5929 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5930{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305931 tDot11fDelBAInd frmDelBAInd;
5932 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305934 tpSirMacMgmtHdr pMacHdr;
5935 tANI_U32 frameLen = 0, nStatus, nPayload;
5936 tSirRetStatus statusCode;
5937 eHalStatus halStatus;
5938 void *pPacket;
5939 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005940
5941 if(NULL == psessionEntry)
5942 {
5943 return eSIR_FAILURE;
5944 }
5945
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305946 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005947
5948 // Category - 3 (BA)
5949 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5950 // Action - 2 (DELBA)
5951 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5952
5953 // Fill the DELBA Parameter Set as provided by caller
5954 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5955 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5956
5957 // BA Starting Sequence Number
5958 // Fragment number will always be zero
5959 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5960
5961 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5962
5963 if( DOT11F_FAILED( nStatus ))
5964 {
5965 limLog( pMac, LOGW,
5966 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005967 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 nStatus );
5969
5970 // We'll fall back on the worst case scenario:
5971 nPayload = sizeof( tDot11fDelBAInd );
5972 }
5973 else if( DOT11F_WARNED( nStatus ))
5974 {
5975 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005976 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005977 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 nStatus );
5979 }
5980
5981 // Add the MGMT header to frame length
5982 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5983
5984 // Allocate shared memory
5985 if( eHAL_STATUS_SUCCESS !=
5986 (halStatus = palPktAlloc( pMac->hHdd,
5987 HAL_TXRX_FRM_802_11_MGMT,
5988 (tANI_U16) frameLen,
5989 (void **) &pDelBAIndBuffer,
5990 (void **) &pPacket )))
5991 {
5992 // Log error
5993 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005994 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 frameLen,
5996 halStatus );
5997
5998 statusCode = eSIR_MEM_ALLOC_FAILED;
5999 goto returnAfterError;
6000 }
6001
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306002 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006003
6004 // Copy necessary info to BD
6005 if( eSIR_SUCCESS !=
6006 (statusCode = limPopulateMacHeader( pMac,
6007 pDelBAIndBuffer,
6008 SIR_MAC_MGMT_FRAME,
6009 SIR_MAC_MGMT_ACTION,
6010 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
6011 goto returnAfterError;
6012
6013 // Update A3 with the BSSID
6014 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
6015
6016 #if 0
6017 cfgLen = SIR_MAC_ADDR_LENGTH;
6018 if( eSIR_SUCCESS != cfgGetStr( pMac,
6019 WNI_CFG_BSSID,
6020 (tANI_U8 *) pMacHdr->bssId,
6021 &cfgLen ))
6022 {
6023 limLog( pMac, LOGP,
6024 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006025 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006026
6027 // FIXME - Need to convert to tSirRetStatus
6028 statusCode = eSIR_FAILURE;
6029 goto returnAfterError;
6030 }
6031 #endif //TO SUPPORT BT-AMP
6032 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
6033
Chet Lanctot186b5732013-03-18 10:26:30 -07006034#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006035 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006036#endif
6037
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 // Now, we're ready to "pack" the frames
6039 nStatus = dot11fPackDelBAInd( pMac,
6040 &frmDelBAInd,
6041 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
6042 nPayload,
6043 &nPayload );
6044
6045 if( DOT11F_FAILED( nStatus ))
6046 {
6047 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006048 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 nStatus );
6050
6051 // FIXME - Need to convert to tSirRetStatus
6052 statusCode = eSIR_FAILURE;
6053 goto returnAfterError;
6054 }
6055 else if( DOT11F_WARNED( nStatus ))
6056 {
6057 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006058 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
6059 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 }
6061
Abhishek Singh1f6e6532014-06-05 17:35:08 +05306062 limLog( pMac, LOG1,
6063 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
6064 " initiator = %d reason = %d" ),
6065 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
6066 frmDelBAInd.DelBAParameterSet.tid,
6067 frmDelBAInd.DelBAParameterSet.initiator,
6068 frmDelBAInd.Reason.code);
6069
Jeff Johnson295189b2012-06-20 16:38:30 -07006070
6071 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6073 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 )
6075 {
6076 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6077 }
6078
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306079 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6080 psessionEntry->peSessionId,
6081 pMacHdr->fc.subType));
6082 halStatus = halTxFrame( pMac,
6083 pPacket,
6084 (tANI_U16) frameLen,
6085 HAL_TXRX_FRM_802_11_MGMT,
6086 ANI_TXDIR_TODS,
6087 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6088 limTxComplete,
6089 pDelBAIndBuffer, txFlag );
6090 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6091 psessionEntry->peSessionId,
6092 halStatus));
6093 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006095 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 statusCode = eSIR_FAILURE;
6097 //Pkt will be freed up by the callback
6098 return statusCode;
6099 }
6100 else
6101 return eSIR_SUCCESS;
6102
6103 returnAfterError:
6104
6105 // Release buffer, if allocated
6106 if( NULL != pDelBAIndBuffer )
6107 palPktFree( pMac->hHdd,
6108 HAL_TXRX_FRM_802_11_MGMT,
6109 (void *) pDelBAIndBuffer,
6110 (void *) pPacket );
6111
6112 return statusCode;
6113}
6114
6115#if defined WLAN_FEATURE_VOWIFI
6116
6117/**
6118 * \brief Send a Neighbor Report Request Action frame
6119 *
6120 *
6121 * \param pMac Pointer to the global MAC structure
6122 *
6123 * \param pNeighborReq Address of a tSirMacNeighborReportReq
6124 *
6125 * \param peer mac address of peer station.
6126 *
6127 * \param psessionEntry address of session entry.
6128 *
6129 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6130 *
6131 *
6132 */
6133
6134tSirRetStatus
6135limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
6136 tpSirMacNeighborReportReq pNeighborReq,
6137 tSirMacAddr peer,
6138 tpPESession psessionEntry
6139 )
6140{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306141 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 tDot11fNeighborReportRequest frm;
6143 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306144 tpSirMacMgmtHdr pMacHdr;
6145 tANI_U32 nBytes, nPayload, nStatus;
6146 void *pPacket;
6147 eHalStatus halstatus;
6148 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006149
6150 if ( psessionEntry == NULL )
6151 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006152 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 return eSIR_FAILURE;
6154 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306155 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006156
6157 frm.Category.category = SIR_MAC_ACTION_RRM;
6158 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
6159 frm.DialogToken.token = pNeighborReq->dialogToken;
6160
6161
6162 if( pNeighborReq->ssid_present )
6163 {
6164 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
6165 }
6166
6167 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
6168 if ( DOT11F_FAILED( nStatus ) )
6169 {
6170 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006171 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 nStatus );
6173 // We'll fall back on the worst case scenario:
6174 nPayload = sizeof( tDot11fNeighborReportRequest );
6175 }
6176 else if ( DOT11F_WARNED( nStatus ) )
6177 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006178 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006180 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 }
6182
6183 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6184
6185 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6186 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6187 {
6188 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006189 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 return eSIR_FAILURE;
6191 }
6192
6193 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306194 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006195
6196 // Copy necessary info to BD
6197 if( eSIR_SUCCESS !=
6198 (statusCode = limPopulateMacHeader( pMac,
6199 pFrame,
6200 SIR_MAC_MGMT_FRAME,
6201 SIR_MAC_MGMT_ACTION,
6202 peer, psessionEntry->selfMacAddr)))
6203 goto returnAfterError;
6204
6205 // Update A3 with the BSSID
6206 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6207
6208 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6209
Chet Lanctot186b5732013-03-18 10:26:30 -07006210#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006211 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006212#endif
6213
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 // Now, we're ready to "pack" the frames
6215 nStatus = dot11fPackNeighborReportRequest( pMac,
6216 &frm,
6217 pFrame + sizeof( tSirMacMgmtHdr ),
6218 nPayload,
6219 &nPayload );
6220
6221 if( DOT11F_FAILED( nStatus ))
6222 {
6223 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006224 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 nStatus );
6226
6227 // FIXME - Need to convert to tSirRetStatus
6228 statusCode = eSIR_FAILURE;
6229 goto returnAfterError;
6230 }
6231 else if( DOT11F_WARNED( nStatus ))
6232 {
6233 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006234 FL( "There were warnings while packing Neighbor Report "
6235 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 }
6237
6238 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006239 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 limPrintMacAddr( pMac, peer, LOGW );
6241
6242 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6244 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 )
6246 {
6247 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6248 }
6249
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306250 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6251 psessionEntry->peSessionId,
6252 pMacHdr->fc.subType));
6253 halstatus = halTxFrame( pMac,
6254 pPacket,
6255 (tANI_U16) nBytes,
6256 HAL_TXRX_FRM_802_11_MGMT,
6257 ANI_TXDIR_TODS,
6258 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6259 limTxComplete,
6260 pFrame, txFlag );
6261 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6262 psessionEntry->peSessionId,
6263 halstatus));
6264 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006266 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 statusCode = eSIR_FAILURE;
6268 //Pkt will be freed up by the callback
6269 return statusCode;
6270 }
6271 else
6272 return eSIR_SUCCESS;
6273
6274returnAfterError:
6275 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6276
6277 return statusCode;
6278} // End limSendNeighborReportRequestFrame.
6279
6280/**
6281 * \brief Send a Link Report Action frame
6282 *
6283 *
6284 * \param pMac Pointer to the global MAC structure
6285 *
6286 * \param pLinkReport Address of a tSirMacLinkReport
6287 *
6288 * \param peer mac address of peer station.
6289 *
6290 * \param psessionEntry address of session entry.
6291 *
6292 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6293 *
6294 *
6295 */
6296
6297tSirRetStatus
6298limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6299 tpSirMacLinkReport pLinkReport,
6300 tSirMacAddr peer,
6301 tpPESession psessionEntry
6302 )
6303{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306304 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006305 tDot11fLinkMeasurementReport frm;
6306 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306307 tpSirMacMgmtHdr pMacHdr;
6308 tANI_U32 nBytes, nPayload, nStatus;
6309 void *pPacket;
6310 eHalStatus halstatus;
6311 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006312
6313
6314 if ( psessionEntry == NULL )
6315 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006316 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006317 return eSIR_FAILURE;
6318 }
6319
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306320 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006321
6322 frm.Category.category = SIR_MAC_ACTION_RRM;
6323 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6324 frm.DialogToken.token = pLinkReport->dialogToken;
6325
6326
6327 //IEEE Std. 802.11 7.3.2.18. for the report element.
6328 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6329 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6330 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6331 //such case this way than changing the frame parser.
6332 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6333 frm.TPCEleLen.TPCLen = 2;
6334 frm.TxPower.txPower = pLinkReport->txPower;
6335 frm.LinkMargin.linkMargin = 0;
6336
6337 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6338 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6339 frm.RCPI.rcpi = pLinkReport->rcpi;
6340 frm.RSNI.rsni = pLinkReport->rsni;
6341
6342 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6343 if ( DOT11F_FAILED( nStatus ) )
6344 {
6345 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006346 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 nStatus );
6348 // We'll fall back on the worst case scenario:
6349 nPayload = sizeof( tDot11fLinkMeasurementReport );
6350 }
6351 else if ( DOT11F_WARNED( nStatus ) )
6352 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006353 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006355 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 }
6357
6358 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6359
6360 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6361 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6362 {
6363 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006364 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 return eSIR_FAILURE;
6366 }
6367
6368 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306369 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006370
6371 // Copy necessary info to BD
6372 if( eSIR_SUCCESS !=
6373 (statusCode = limPopulateMacHeader( pMac,
6374 pFrame,
6375 SIR_MAC_MGMT_FRAME,
6376 SIR_MAC_MGMT_ACTION,
6377 peer, psessionEntry->selfMacAddr)))
6378 goto returnAfterError;
6379
6380 // Update A3 with the BSSID
6381 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6382
6383 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6384
Chet Lanctot186b5732013-03-18 10:26:30 -07006385#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006386 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006387#endif
6388
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 // Now, we're ready to "pack" the frames
6390 nStatus = dot11fPackLinkMeasurementReport( pMac,
6391 &frm,
6392 pFrame + sizeof( tSirMacMgmtHdr ),
6393 nPayload,
6394 &nPayload );
6395
6396 if( DOT11F_FAILED( nStatus ))
6397 {
6398 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006399 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 nStatus );
6401
6402 // FIXME - Need to convert to tSirRetStatus
6403 statusCode = eSIR_FAILURE;
6404 goto returnAfterError;
6405 }
6406 else if( DOT11F_WARNED( nStatus ))
6407 {
6408 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006409 FL( "There were warnings while packing Link Report (0x%08x)." ),
6410 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 }
6412
6413 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006414 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 limPrintMacAddr( pMac, peer, LOGW );
6416
6417 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6419 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 )
6421 {
6422 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6423 }
6424
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306425 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6426 psessionEntry->peSessionId,
6427 pMacHdr->fc.subType));
6428 halstatus = halTxFrame( pMac,
6429 pPacket,
6430 (tANI_U16) nBytes,
6431 HAL_TXRX_FRM_802_11_MGMT,
6432 ANI_TXDIR_TODS,
6433 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6434 limTxComplete,
6435 pFrame, txFlag );
6436 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6437 psessionEntry->peSessionId,
6438 halstatus));
6439 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006441 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006442 statusCode = eSIR_FAILURE;
6443 //Pkt will be freed up by the callback
6444 return statusCode;
6445 }
6446 else
6447 return eSIR_SUCCESS;
6448
6449returnAfterError:
6450 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6451
6452 return statusCode;
6453} // End limSendLinkReportActionFrame.
6454
6455/**
6456 * \brief Send a Beacon Report Action frame
6457 *
6458 *
6459 * \param pMac Pointer to the global MAC structure
6460 *
6461 * \param dialog_token dialog token to be used in the action frame.
6462 *
6463 * \param num_report number of reports in pRRMReport.
6464 *
6465 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6466 *
6467 * \param peer mac address of peer station.
6468 *
6469 * \param psessionEntry address of session entry.
6470 *
6471 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6472 *
6473 *
6474 */
6475
6476tSirRetStatus
6477limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6478 tANI_U8 dialog_token,
6479 tANI_U8 num_report,
6480 tpSirMacRadioMeasureReport pRRMReport,
6481 tSirMacAddr peer,
6482 tpPESession psessionEntry
6483 )
6484{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306485 tSirRetStatus statusCode = eSIR_SUCCESS;
6486 tANI_U8 *pFrame;
6487 tpSirMacMgmtHdr pMacHdr;
6488 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306490 eHalStatus halstatus;
6491 tANI_U8 i;
6492 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006493
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006494 tDot11fRadioMeasurementReport *frm =
6495 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6496 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006497 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006498 return eSIR_FAILURE;
6499 }
6500
Jeff Johnson295189b2012-06-20 16:38:30 -07006501 if ( psessionEntry == NULL )
6502 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006503 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006504 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006505 return eSIR_FAILURE;
6506 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306507 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006508
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006509 frm->Category.category = SIR_MAC_ACTION_RRM;
6510 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6511 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006512
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006513 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 -07006514
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006515 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006516 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006517 frm->MeasurementReport[i].type = pRRMReport[i].type;
6518 frm->MeasurementReport[i].token = pRRMReport[i].token;
6519 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 switch( pRRMReport[i].type )
6521 {
6522 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006523 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6524 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6525 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6526 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 break;
6528 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306529 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6530 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006531 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 break;
6533 }
6534 }
6535
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006536 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006537 if ( DOT11F_FAILED( nStatus ) )
6538 {
6539 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006540 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006541 nStatus );
6542 // We'll fall back on the worst case scenario:
6543 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006544 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 return eSIR_FAILURE;
6546 }
6547 else if ( DOT11F_WARNED( nStatus ) )
6548 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006549 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006551 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006552 }
6553
6554 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6555
6556 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6557 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6558 {
6559 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006560 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006561 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006562 return eSIR_FAILURE;
6563 }
6564
6565 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306566 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006567
6568 // Copy necessary info to BD
6569 if( eSIR_SUCCESS !=
6570 (statusCode = limPopulateMacHeader( pMac,
6571 pFrame,
6572 SIR_MAC_MGMT_FRAME,
6573 SIR_MAC_MGMT_ACTION,
6574 peer, psessionEntry->selfMacAddr)))
6575 goto returnAfterError;
6576
6577 // Update A3 with the BSSID
6578 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6579
6580 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6581
Chet Lanctot186b5732013-03-18 10:26:30 -07006582#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006583 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006584#endif
6585
Jeff Johnson295189b2012-06-20 16:38:30 -07006586 // Now, we're ready to "pack" the frames
6587 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006588 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 pFrame + sizeof( tSirMacMgmtHdr ),
6590 nPayload,
6591 &nPayload );
6592
6593 if( DOT11F_FAILED( nStatus ))
6594 {
6595 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006596 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 nStatus );
6598
6599 // FIXME - Need to convert to tSirRetStatus
6600 statusCode = eSIR_FAILURE;
6601 goto returnAfterError;
6602 }
6603 else if( DOT11F_WARNED( nStatus ))
6604 {
6605 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006606 FL( "There were warnings while packing Radio "
6607 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 }
6609
6610 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006611 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006612 limPrintMacAddr( pMac, peer, LOGW );
6613
6614 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6616 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 )
6618 {
6619 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6620 }
6621
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306622 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6623 psessionEntry->peSessionId,
6624 pMacHdr->fc.subType));
6625 halstatus = halTxFrame( pMac,
6626 pPacket,
6627 (tANI_U16) nBytes,
6628 HAL_TXRX_FRM_802_11_MGMT,
6629 ANI_TXDIR_TODS,
6630 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6631 limTxComplete,
6632 pFrame, txFlag );
6633 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6634 psessionEntry->peSessionId,
6635 halstatus));
6636 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006638 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 statusCode = eSIR_FAILURE;
6640 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006641 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 return statusCode;
6643 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006644 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006645 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006648
6649returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006650 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 return statusCode;
6653} // End limSendBeaconReportActionFrame.
6654
6655#endif
6656
6657#ifdef WLAN_FEATURE_11W
6658/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006659 * \brief Send SA query request action frame to peer
6660 *
6661 * \sa limSendSaQueryRequestFrame
6662 *
6663 *
6664 * \param pMac The global tpAniSirGlobal object
6665 *
6666 * \param transId Transaction identifier
6667 *
6668 * \param peer The Mac address of the station to which this action frame is addressed
6669 *
6670 * \param psessionEntry The PE session entry
6671 *
6672 * \return eSIR_SUCCESS if setup completes successfully
6673 * eSIR_FAILURE is some problem is encountered
6674 */
6675
6676tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6677 tSirMacAddr peer, tpPESession psessionEntry )
6678{
6679
6680 tDot11fSaQueryReq frm; // SA query request action frame
6681 tANI_U8 *pFrame;
6682 tSirRetStatus nSirStatus;
6683 tpSirMacMgmtHdr pMacHdr;
6684 tANI_U32 nBytes, nPayload, nStatus;
6685 void *pPacket;
6686 eHalStatus halstatus;
6687 tANI_U8 txFlag = 0;
6688
6689 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6690 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6691 /* 11w action field is :
6692 action: 0 --> SA Query Request action frame
6693 action: 1 --> SA Query Response action frame */
6694 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6695 /* 11w SA Query Request transId */
6696 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6697
6698 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6699 if ( DOT11F_FAILED( nStatus ) )
6700 {
6701 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6702 "for an SA Query Request (0x%08x)."),
6703 nStatus );
6704 // We'll fall back on the worst case scenario:
6705 nPayload = sizeof( tDot11fSaQueryReq );
6706 }
6707 else if ( DOT11F_WARNED( nStatus ) )
6708 {
6709 limLog( pMac, LOGW, FL("There were warnings while calculating "
6710 "the packed size for an SA Query Request"
6711 " (0x%08x)."), nStatus );
6712 }
6713
6714 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6715 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6716 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6717 {
6718 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6719 "action frame"), nBytes );
6720 return eSIR_FAILURE;
6721 }
6722
6723 // Paranoia:
6724 vos_mem_set( pFrame, nBytes, 0 );
6725
6726 // Copy necessary info to BD
6727 nSirStatus = limPopulateMacHeader( pMac,
6728 pFrame,
6729 SIR_MAC_MGMT_FRAME,
6730 SIR_MAC_MGMT_ACTION,
6731 peer, psessionEntry->selfMacAddr );
6732 if ( eSIR_SUCCESS != nSirStatus )
6733 goto returnAfterError;
6734
6735 // Update A3 with the BSSID
6736 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6737
6738 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6739
6740 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6741 // in the FC
6742 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6743
6744 // Pack 11w SA Query Request frame
6745 nStatus = dot11fPackSaQueryReq( pMac,
6746 &frm,
6747 pFrame + sizeof( tSirMacMgmtHdr ),
6748 nPayload,
6749 &nPayload );
6750
6751 if ( DOT11F_FAILED( nStatus ))
6752 {
6753 limLog( pMac, LOGE,
6754 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6755 nStatus );
6756 // FIXME - Need to convert to tSirRetStatus
6757 nSirStatus = eSIR_FAILURE;
6758 goto returnAfterError;
6759 }
6760 else if ( DOT11F_WARNED( nStatus ))
6761 {
6762 limLog( pMac, LOGW,
6763 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6764 nStatus);
6765 }
6766
6767 limLog( pMac, LOG1,
6768 FL( "Sending an SA Query Request to " ));
6769 limPrintMacAddr( pMac, peer, LOG1 );
6770 limPrintMacAddr( pMac, peer, LOGE );
6771 limLog( pMac, LOGE,
6772 FL( "Sending an SA Query Request from " ));
6773 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6774
6775 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6776#ifdef WLAN_FEATURE_P2P
6777 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6778 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6779#endif
6780 )
6781 {
6782 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6783 }
6784
6785 halstatus = halTxFrame( pMac,
6786 pPacket,
6787 (tANI_U16) nBytes,
6788 HAL_TXRX_FRM_802_11_MGMT,
6789 ANI_TXDIR_TODS,
6790 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6791 limTxComplete,
6792 pFrame, txFlag );
6793 if ( eHAL_STATUS_SUCCESS != halstatus )
6794 {
6795 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6796 nSirStatus = eSIR_FAILURE;
6797 //Pkt will be freed up by the callback
6798 return nSirStatus;
6799 }
6800 else {
6801 return eSIR_SUCCESS;
6802 }
6803
6804returnAfterError:
6805 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6806 return nSirStatus;
6807} // End limSendSaQueryRequestFrame
6808
6809/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 * \brief Send SA query response action frame to peer
6811 *
6812 * \sa limSendSaQueryResponseFrame
6813 *
6814 *
6815 * \param pMac The global tpAniSirGlobal object
6816 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006817 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006818 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006819 * \param peer The Mac address of the AP to which this action frame is addressed
6820 *
6821 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 *
6823 * \return eSIR_SUCCESS if setup completes successfully
6824 * eSIR_FAILURE is some problem is encountered
6825 */
6826
Chet Lanctot186b5732013-03-18 10:26:30 -07006827tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006828tSirMacAddr peer,tpPESession psessionEntry)
6829{
6830
Chet Lanctot186b5732013-03-18 10:26:30 -07006831 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006832 tANI_U8 *pFrame;
6833 tSirRetStatus nSirStatus;
6834 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006835 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 void *pPacket;
6837 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306838 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006839
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306840 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006841 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6842 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 action: 0 --> SA query request action frame
6844 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006845 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6846 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006848 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006849
Chet Lanctot186b5732013-03-18 10:26:30 -07006850 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6851 if ( DOT11F_FAILED( nStatus ) )
6852 {
6853 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6854 "or a SA Query Response (0x%08x)."),
6855 nStatus );
6856 // We'll fall back on the worst case scenario:
6857 nPayload = sizeof( tDot11fSaQueryRsp );
6858 }
6859 else if ( DOT11F_WARNED( nStatus ) )
6860 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006861 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006862 "the packed size for an SA Query Response"
6863 " (0x%08x)."), nStatus );
6864 }
6865
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6867 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6868 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6869 {
6870 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006871 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 return eSIR_FAILURE;
6873 }
6874
6875 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306876 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006877
Chet Lanctot186b5732013-03-18 10:26:30 -07006878 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006879 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006880 pFrame,
6881 SIR_MAC_MGMT_FRAME,
6882 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006883 peer, psessionEntry->selfMacAddr );
6884 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006885 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006886
Chet Lanctot186b5732013-03-18 10:26:30 -07006887 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6889
Chet Lanctot186b5732013-03-18 10:26:30 -07006890 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006891
Chet Lanctot186b5732013-03-18 10:26:30 -07006892 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6893 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006894 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006895
Chet Lanctot186b5732013-03-18 10:26:30 -07006896 // Pack 11w SA query response frame
6897 nStatus = dot11fPackSaQueryRsp( pMac,
6898 &frm,
6899 pFrame + sizeof( tSirMacMgmtHdr ),
6900 nPayload,
6901 &nPayload );
6902
6903 if ( DOT11F_FAILED( nStatus ))
6904 {
6905 limLog( pMac, LOGE,
6906 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6907 nStatus );
6908 // FIXME - Need to convert to tSirRetStatus
6909 nSirStatus = eSIR_FAILURE;
6910 goto returnAfterError;
6911 }
6912 else if ( DOT11F_WARNED( nStatus ))
6913 {
6914 limLog( pMac, LOGW,
6915 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6916 nStatus);
6917 }
6918
6919 limLog( pMac, LOG1,
6920 FL( "Sending a SA Query Response to " ));
6921 limPrintMacAddr( pMac, peer, LOGW );
6922
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006923 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006924#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006925 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6926 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006927#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006928 )
6929 {
6930 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6931 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006932
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306933 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6934 psessionEntry->peSessionId,
6935 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006936 halstatus = halTxFrame( pMac,
6937 pPacket,
6938 (tANI_U16) nBytes,
6939 HAL_TXRX_FRM_802_11_MGMT,
6940 ANI_TXDIR_TODS,
6941 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6942 limTxComplete,
6943 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306944 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6945 psessionEntry->peSessionId,
6946 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006947 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006948 {
6949 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6950 nSirStatus = eSIR_FAILURE;
6951 //Pkt will be freed up by the callback
6952 return nSirStatus;
6953 }
6954 else {
6955 return eSIR_SUCCESS;
6956 }
6957
6958returnAfterError:
6959 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6960 return nSirStatus;
6961} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006962#endif