blob: 4305dc05dec5a4e71ce650e61bbb0e1936d1ffaf [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -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/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * \file lim_send_management_frames.c
30 *
31 * \brief Code for preparing and sending 802.11 Management frames
32 *
33 *
34 */
35
36#include "sir_api.h"
37#include "ani_global.h"
38#include "sir_mac_prot_def.h"
39#include "cfg_api.h"
40#include "utils_api.h"
41#include "lim_types.h"
42#include "lim_utils.h"
43#include "lim_security_utils.h"
44#include "lim_prop_exts_utils.h"
45#include "dot11f.h"
46#include "lim_sta_hash_api.h"
47#include "sch_api.h"
48#include "lim_send_messages.h"
49#include "lim_assoc_utils.h"
50#include "lim_ft.h"
51#ifdef WLAN_FEATURE_11W
52#include "wni_cfg.h"
53#endif
54
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053057#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053058#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059#include "cds_utils.h"
60#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061#include "rrm_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053062#include "qdf_crypto.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
64#include "wma_types.h"
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -080065#include <cdp_txrx_cmn.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070066#include <cdp_txrx_peer_ops.h>
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053067#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070068#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069
70/**
71 *
72 * \brief This function is called to add the sequence number to the
73 * management frames
74 *
75 * \param pMac Pointer to Global MAC structure
76 *
77 * \param pMacHdr Pointer to MAC management header
78 *
79 * The pMacHdr argument points to the MAC management header. The
80 * sequence number stored in the pMac structure will be incremented
81 * and updated to the MAC management header. The start sequence
82 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
83 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
84 * number will roll over.
85 *
86 */
Jeff Johnson38112a32016-10-07 07:30:50 -070087static void lim_add_mgmt_seq_num(tpAniSirGlobal pMac, tpSirMacMgmtHdr pMacHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088{
89 if (pMac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
90 pMac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
91 }
92
93 pMac->mgmtSeqNum++;
94
95 pMacHdr->seqControl.seqNumLo = (pMac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
96 pMacHdr->seqControl.seqNumHi =
97 ((pMac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
98}
99
100/**
101 *
102 * \brief This function is called before sending a p2p action frame
103 * inorder to add sequence numbers to action packets
104 *
105 * \param pMac Pointer to Global MAC structure
106 *
107 * \param pBD Pointer to the frame buffer that needs to be populate
108 *
109 * The pMacHdr argument points to the MAC management header. The
110 * sequence number stored in the pMac structure will be incremented
111 * and updated to the MAC management header. The start sequence
112 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
113 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
114 * number will roll over.
115 *
116 */
117void lim_populate_p2p_mac_header(tpAniSirGlobal pMac, uint8_t *pBD)
118{
119 tpSirMacMgmtHdr pMacHdr;
120
121 /* / Prepare MAC management header */
122 pMacHdr = (tpSirMacMgmtHdr) (pBD);
123
124 /* Prepare sequence number */
125 lim_add_mgmt_seq_num(pMac, pMacHdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700126 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127 pMacHdr->seqControl.seqNumLo,
128 pMacHdr->seqControl.seqNumHi, pMac->mgmtSeqNum);
129}
130
131/**
132 * lim_populate_mac_header() - Fill in 802.11 header of frame
133 *
134 * @mac_ctx: Pointer to Global MAC structure
135 * @buf: Pointer to the frame buffer that needs to be populate
136 * @type: 802.11 Type of the frame
137 * @sub_type: 802.11 Subtype of the frame
138 * @peer_addr: dst address
139 * @self_mac_addr: local mac address
140 *
141 * This function is called by various LIM modules to prepare the
142 * 802.11 frame MAC header
143 *
144 * The buf argument points to the beginning of the frame buffer to
145 * which - a) The 802.11 MAC header is set b) Following this MAC header
146 * will be the MGMT frame payload The payload itself is populated by the
147 * caller API
148 *
149 * Return: None
150 */
151
152void lim_populate_mac_header(tpAniSirGlobal mac_ctx, uint8_t *buf,
153 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
154 tSirMacAddr self_mac_addr)
155{
156 tpSirMacMgmtHdr mac_hdr;
157
158 /* Prepare MAC management header */
159 mac_hdr = (tpSirMacMgmtHdr) (buf);
160
161 /* Prepare FC */
162 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
163 mac_hdr->fc.type = type;
164 mac_hdr->fc.subType = sub_type;
165
166 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530167 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
169
170 /* Prepare Address 2 */
171 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
172
173 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530174 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
176
177 /* Prepare sequence number */
178 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700179 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 mac_hdr->seqControl.seqNumLo,
181 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
182}
183
184/**
185 * lim_send_probe_req_mgmt_frame() - send probe request management frame
186 * @mac_ctx: Pointer to Global MAC structure
187 * @ssid: SSID to be sent in Probe Request frame
188 * @bssid: BSSID to be sent in Probe Request frame
189 * @channel: Channel # on which the Probe Request is going out
190 * @self_macaddr: self MAC address
191 * @dot11mode: self dotllmode
192 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
193 * frame
194 * @additional_ie: if additional_ielen is non zero, include this field in the
195 * Probe Request frame
196 *
197 * This function is called by various LIM modules to send Probe Request frame
198 * during active scan/learn phase.
199 * Probe request is sent out in the following scenarios:
200 * --heartbeat failure: session needed
201 * --join req: session needed
202 * --foreground scan: no session
203 * --background scan: no session
204 * --sch_beacon_processing: to get EDCA parameters: session needed
205 *
206 * Return: tSirRetStatus (eSIR_SUCCESS on success and error codes otherwise)
207 */
208tSirRetStatus
209lim_send_probe_req_mgmt_frame(tpAniSirGlobal mac_ctx,
210 tSirMacSSid *ssid,
211 tSirMacAddr bssid,
212 uint8_t channel,
213 tSirMacAddr self_macaddr,
214 uint32_t dot11mode,
215 uint32_t additional_ielen, uint8_t *additional_ie)
216{
217 tDot11fProbeRequest pr;
218 uint32_t status, bytes, payload;
219 uint8_t *frame;
220 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530221 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 tpPESession pesession;
223 uint8_t sessionid;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700224 const uint8_t *p2pie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 uint8_t txflag = 0;
226 uint8_t sme_sessionid = 0;
227 bool is_vht_enabled = false;
228 uint8_t txPower;
229 uint16_t addn_ielen = additional_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530230 bool extracted_ext_cap_flag = false;
231 tDot11fIEExtCap extracted_ext_cap;
232 tSirRetStatus sir_status;
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530233 const uint8_t *qcn_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234
235 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
236 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
237 * is false and dot11mode is 11ac set it to 11n.
238 */
239 if (channel <= SIR_11B_CHANNEL_END &&
240 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
241 (WNI_CFG_DOT11_MODE_11AC == dot11mode ||
242 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode))
243 dot11mode = WNI_CFG_DOT11_MODE_11N;
244 /*
245 * session context may or may not be present, when probe request needs
246 * to be sent out. Following cases exist:
247 * --heartbeat failure: session needed
248 * --join req: session needed
249 * --foreground scan: no session
250 * --background scan: no session
251 * --sch_beacon_processing: to get EDCA parameters: session needed
252 * If session context does not exist, some IEs will be populated from
253 * CFGs, e.g. Supported and Extended rate set IEs
254 */
255 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
256
257 if (pesession != NULL)
258 sme_sessionid = pesession->smeSessionId;
259
260 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
261 /* and then hand it off to 'dot11f_pack_probe_request' (for */
262 /* serialization). We start by zero-initializing the structure: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530263 qdf_mem_set((uint8_t *) &pr, sizeof(pr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264
265 /* & delegating to assorted helpers: */
266 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
267
268 if (addn_ielen && additional_ie)
269 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
270
271 /*
272 * Don't include 11b rate if it is a P2P serach or probe request is
273 * sent by P2P Client
274 */
275 if ((WNI_CFG_DOT11_MODE_11B != dot11mode) && (p2pie != NULL) &&
276 (((mac_ctx->lim.gpLimMlmScanReq != NULL) &&
277 mac_ctx->lim.gpLimMlmScanReq->p2pSearch) ||
278 ((pesession != NULL) &&
Anurag Chouhan6d760662016-02-20 16:05:43 +0530279 (QDF_P2P_CLIENT_MODE == pesession->pePersona))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800280 )
281 ) {
282 /*
283 * In the below API pass channel number > 14, do that it fills
284 * only 11a rates in supported rates
285 */
286 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
287 pesession);
288 } else {
289 populate_dot11f_supp_rates(mac_ctx, channel,
290 &pr.SuppRates, pesession);
291
292 if (WNI_CFG_DOT11_MODE_11B != dot11mode) {
293 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
294 &pr.ExtSuppRates);
295 }
296 }
297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 /*
299 * Table 7-14 in IEEE Std. 802.11k-2008 says
300 * DS params "can" be present in RRM is disabled and "is" present if
301 * RRM is enabled. It should be ok even if we add it into probe req when
302 * RRM is not enabled.
303 */
304 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
305 /* Call RRM module to get the tx power for management used. */
306 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
307 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
308
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309
310 if (pesession != NULL) {
311 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
312 /* Include HT Capability IE */
313 if (pesession->htCapability)
314 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
315 } else { /* pesession == NULL */
316 if (IS_DOT11_MODE_HT(dot11mode))
317 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
318 }
319
320 /*
321 * Set channelbonding information as "disabled" when tunned to a
322 * 2.4 GHz channel
323 */
324 if (channel <= SIR_11B_CHANNEL_END) {
325 if (mac_ctx->roam.configParam.channelBondingMode24GHz
326 == PHY_SINGLE_CHANNEL_CENTERED) {
327 pr.HTCaps.supportedChannelWidthSet =
328 eHT_CHANNEL_WIDTH_20MHZ;
329 pr.HTCaps.shortGI40MHz = 0;
330 } else {
331 pr.HTCaps.supportedChannelWidthSet =
332 eHT_CHANNEL_WIDTH_40MHZ;
333 }
334 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 if (pesession != NULL) {
336 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
337 /* Include VHT Capability IE */
338 if (pesession->vhtCapability) {
339 populate_dot11f_vht_caps(mac_ctx, pesession,
340 &pr.VHTCaps);
341 is_vht_enabled = true;
342 }
343 } else {
344 if (IS_DOT11_MODE_VHT(dot11mode)) {
345 populate_dot11f_vht_caps(mac_ctx, pesession,
346 &pr.VHTCaps);
347 is_vht_enabled = true;
348 }
349 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350 if (pesession != NULL)
351 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
352 pesession);
353
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800354 if (IS_DOT11_MODE_HE(dot11mode) && NULL != pesession)
355 lim_update_session_he_capable(mac_ctx, pesession);
356
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700357 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700358 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 if (addn_ielen) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530361 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
362 sizeof(tDot11fIEExtCap));
363 sir_status = lim_strip_extcap_update_struct(mac_ctx,
364 additional_ie,
365 &addn_ielen,
366 &extracted_ext_cap);
367 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700368 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530369 } else {
370 struct s_ext_cap *p_ext_cap =
371 (struct s_ext_cap *)
372 extracted_ext_cap.bytes;
373 if (p_ext_cap->interworking_service)
374 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800375 extracted_ext_cap.num_bytes =
376 lim_compute_ext_cap_ie_length
377 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530378 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800379 (extracted_ext_cap.num_bytes > 0);
Kapil Guptac03eb072016-08-09 14:01:36 +0530380 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530381 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
382 SIR_MAC_QCN_OUI_TYPE_SIZE,
383 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530385 /* Add qcn_ie only if qcn ie is not present in additional_ie */
386 if (mac_ctx->roam.configParam.qcn_ie_support && !qcn_ie)
387 populate_dot11f_qcn_ie(&pr.QCN_IE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388
Hu Wang411e0cc2016-10-28 14:56:01 +0800389 /*
390 * Extcap IE now support variable length, merge Extcap IE from addn_ie
391 * may change the frame size. Therefore, MUST merge ExtCap IE before
392 * dot11f get packed payload size.
393 */
394 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800395 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800396
397 /* That's it-- now we pack it. First, how much space are we going to */
398 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
399 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700400 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800401 status);
402 /* We'll fall back on the worst case scenario: */
403 payload = sizeof(tDot11fProbeRequest);
404 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700405 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800406 status);
407 }
408
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
410
411 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530412 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800413 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530414 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700415 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 return eSIR_MEM_ALLOC_FAILED;
417 }
418 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530419 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420
421 /* Next, we fill out the buffer descriptor: */
422 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
423 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
424
425 /* That done, pack the Probe Request: */
426 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
427 sizeof(tSirMacMgmtHdr),
428 payload, &payload);
429 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700430 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 cds_packet_free((void *)packet);
432 return eSIR_FAILURE; /* allocated! */
433 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700434 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 }
436 /* Append any AddIE if present. */
437 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530438 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 additional_ie, addn_ielen);
440 payload += addn_ielen;
441 }
442
443 /* If this probe request is sent during P2P Search State, then we need
444 * to send it at OFDM rate.
445 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800446 if ((BAND_5G == lim_get_rf_band(channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447 || ((mac_ctx->lim.gpLimMlmScanReq != NULL) &&
448 mac_ctx->lim.gpLimMlmScanReq->p2pSearch)
449 /*
450 * For unicast probe req mgmt from Join function we don't set
451 * above variables. So we need to add one more check whether it
452 * is pePersona is P2P_CLIENT or not
453 */
454 || ((pesession != NULL) &&
Anurag Chouhan6d760662016-02-20 16:05:43 +0530455 (QDF_P2P_CLIENT_MODE == pesession->pePersona))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456 ) {
457 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
458 }
459
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530460 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 wma_tx_frame(mac_ctx, packet,
462 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
463 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
464 lim_tx_complete, frame, txflag, sme_sessionid,
Naveen Rawat296a5182017-09-25 14:02:48 -0700465 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530466 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700467 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468 /* Pkt will be freed up by the callback */
469 return eSIR_FAILURE;
470 }
471
472 return eSIR_SUCCESS;
473} /* End lim_send_probe_req_mgmt_frame. */
474
Jeff Johnson38112a32016-10-07 07:30:50 -0700475static tSirRetStatus lim_get_addn_ie_for_probe_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 uint8_t *addIE, uint16_t *addnIELen,
477 uint8_t probeReqP2pIe)
478{
479 /* If Probe request doesn't have P2P IE, then take out P2P IE
480 from additional IE */
481 if (!probeReqP2pIe) {
482 uint8_t *tempbuf = NULL;
483 uint16_t tempLen = 0;
484 int left = *addnIELen;
485 uint8_t *ptr = addIE;
486 uint8_t elem_id, elem_len;
487
488 if (NULL == addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700489 pe_err("NULL addIE pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490 return eSIR_FAILURE;
491 }
492
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530493 tempbuf = qdf_mem_malloc(left);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 if (NULL == tempbuf) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700495 pe_err("Unable to allocate memory to store addn IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800496 return eSIR_MEM_ALLOC_FAILED;
497 }
498
499 while (left >= 2) {
500 elem_id = ptr[0];
501 elem_len = ptr[1];
502 left -= 2;
503 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700504 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530506 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 return eSIR_FAILURE;
508 }
509 if (!((SIR_MAC_EID_VENDOR == elem_id) &&
510 (memcmp
511 (&ptr[2], SIR_MAC_P2P_OUI,
512 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530513 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514 elem_len + 2);
515 tempLen += (elem_len + 2);
516 }
517 left -= elem_len;
518 ptr += (elem_len + 2);
519 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530520 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530522 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523 }
524 return eSIR_SUCCESS;
525}
526
527/**
528 * lim_send_probe_rsp_mgmt_frame() - Send probe response
529 *
530 * @mac_ctx: Handle for mac context
531 * @peer_macaddr: Mac address of requesting peer
532 * @ssid: SSID for response
533 * @n_staid: Station ID, currently unused.
534 * @pe_session: PE session id
535 * @keepalive: Keep alive flag. Currently unused.
536 * @preq_p2pie: P2P IE in incoming probe request
537 *
538 * Builds and sends probe response frame to the requesting peer
539 *
540 * Return: void
541 */
542
543void
544lim_send_probe_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
545 tSirMacAddr peer_macaddr,
546 tpAniSSID ssid,
547 short n_staid,
548 uint8_t keepalive,
549 tpPESession pe_session, uint8_t preq_p2pie)
550{
551 tDot11fProbeResponse *frm;
552 tSirRetStatus sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800553 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800554 tpSirMacMgmtHdr mac_hdr;
555 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700556 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530557 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 uint32_t addn_ie_present = false;
559
560 uint16_t addn_ie_len = 0;
561 uint32_t wps_ap = 0, tmp;
562 uint8_t tx_flag = 0;
563 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700564 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 uint8_t noalen = 0;
566 uint8_t total_noalen = 0;
567 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
568 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
569 uint8_t sme_sessionid = 0;
570 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530571 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530572 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573
574 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700575 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 return;
577
578 if (NULL == pe_session)
579 return;
580
581 /*
582 * In case when cac timer is running for this SAP session then
583 * avoid sending probe rsp out. It is violation of dfs specification.
584 */
Anurag Chouhan6d760662016-02-20 16:05:43 +0530585 if (((pe_session->pePersona == QDF_SAP_MODE) ||
586 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800587 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530588 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589 FL("CAC timer is running, probe response dropped"));
590 return;
591 }
592 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530593 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700595 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 return;
597 }
598
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 /*
600 * Fill out 'frm', after which we'll just hand the struct off to
601 * 'dot11f_pack_probe_response'.
602 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530603 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fProbeResponse), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604
605 /*
606 * Timestamp to be updated by TFP, below.
607 *
608 * Beacon Interval:
609 */
610 if (LIM_IS_AP_ROLE(pe_session)) {
611 frm->BeaconInterval.interval =
612 mac_ctx->sch.schObject.gSchBeaconInterval;
613 } else {
614 sir_status = wlan_cfg_get_int(mac_ctx,
615 WNI_CFG_BEACON_INTERVAL, &cfg);
616 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700617 pe_err("Failed to get WNI_CFG_BEACON_INTERVAL (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 sir_status);
619 goto err_ret;
620 }
621 frm->BeaconInterval.interval = (uint16_t) cfg;
622 }
623
624 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
625 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
626 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
627 &frm->SuppRates, pe_session);
628
629 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
630 pe_session->currentOperChannel);
631 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
632
633 if (LIM_IS_AP_ROLE(pe_session)) {
634 if (pe_session->wps_state != SAP_WPS_DISABLED)
635 populate_dot11f_probe_res_wpsi_es(mac_ctx,
636 &frm->WscProbeRes,
637 pe_session);
638 } else {
639 if (wlan_cfg_get_int(mac_ctx, (uint16_t) WNI_CFG_WPS_ENABLE,
640 &tmp) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700641 pe_err("Failed to cfg get id %d", WNI_CFG_WPS_ENABLE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642
643 wps_ap = tmp & WNI_CFG_WPS_ENABLE_AP;
644
645 if (wps_ap)
646 populate_dot11f_wsc_in_probe_res(mac_ctx,
647 &frm->WscProbeRes);
648
649 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
650 eLIM_WSC_ENROLL_BEGIN) {
651 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
652 &frm->WscProbeRes);
653 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
654 eLIM_WSC_ENROLL_IN_PROGRESS;
655 }
656
657 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
658 eLIM_WSC_ENROLL_END) {
659 de_populate_dot11f_wsc_registrar_info_in_probe_res(
660 mac_ctx, &frm->WscProbeRes);
661 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
662 eLIM_WSC_ENROLL_NOOP;
663 }
664 }
665
666 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
667 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
668
669 if (pe_session->dot11mode != WNI_CFG_DOT11_MODE_11B)
670 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
671
672 populate_dot11f_ext_supp_rates(mac_ctx,
673 POPULATE_DOT11F_RATES_OPERATIONAL,
674 &frm->ExtSuppRates, pe_session);
675
676 /* Populate HT IEs, when operating in 11n */
677 if (pe_session->htCapability) {
678 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
679 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
680 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700682 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
684 populate_dot11f_vht_operation(mac_ctx, pe_session,
685 &frm->VHTOperation);
686 /*
687 * we do not support multi users yet.
688 * populate_dot11f_vht_ext_bss_load( mac_ctx,
689 * &frm.VHTExtBssLoad );
690 */
691 is_vht_enabled = true;
692 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800693
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800694 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700695 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800696 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700697 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800698 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700699 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800700 }
701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
703 pe_session);
704
705 if (pe_session->pLimStartBssReq) {
706 populate_dot11f_wpa(mac_ctx,
707 &(pe_session->pLimStartBssReq->rsnIE),
708 &frm->WPA);
709 populate_dot11f_rsn_opaque(mac_ctx,
710 &(pe_session->pLimStartBssReq->rsnIE),
711 &frm->RSNOpaque);
712 }
713
714 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
715 &frm->WMMCaps, pe_session);
716
717#if defined(FEATURE_WLAN_WAPI)
718 if (pe_session->pLimStartBssReq)
719 populate_dot11f_wapi(mac_ctx,
720 &(pe_session->pLimStartBssReq->rsnIE),
721 &frm->WAPI);
722#endif /* defined(FEATURE_WLAN_WAPI) */
723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724 if (mac_ctx->lim.gpLimRemainOnChanReq)
725 bytes += (mac_ctx->lim.gpLimRemainOnChanReq->length -
726 sizeof(tSirRemainOnChnReq));
727 else
728 /*
729 * Only use CFG for non-listen mode. This CFG is not working for
730 * concurrency. In listening mode, probe rsp IEs is passed in
731 * the message from SME to PE.
732 */
733 addn_ie_present =
734 (pe_session->addIeParams.probeRespDataLen != 0);
735
736 if (addn_ie_present) {
737
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530738 add_ie = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 pe_session->addIeParams.probeRespDataLen);
740 if (NULL == add_ie) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700741 pe_err("add_ie allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742 goto err_ret;
743 }
744
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530745 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 pe_session->addIeParams.probeRespData_buff,
747 pe_session->addIeParams.probeRespDataLen);
748 addn_ie_len = pe_session->addIeParams.probeRespDataLen;
749
750 if (eSIR_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
751 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700752 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753 goto err_ret;
754 }
755
756 sir_status = lim_strip_extcap_update_struct(mac_ctx,
757 add_ie, &addn_ie_len,
758 &extracted_ext_cap);
759 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700760 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530761 } else {
762 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763 }
764
765 bytes = bytes + addn_ie_len;
766
767 if (preq_p2pie)
768 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
769 addn_ie_len);
770
771 if (p2p_ie != NULL) {
772 /* get NoA attribute stream P2P IE */
773 noalen = lim_get_noa_attr_stream(mac_ctx,
774 noa_stream, pe_session);
775 if (noalen != 0) {
776 total_noalen =
777 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
778 &noa_stream[0], noalen);
779 bytes = bytes + total_noalen;
780 }
781 }
782 }
783
Hu Wang411e0cc2016-10-28 14:56:01 +0800784 /*
785 * Extcap IE now support variable length, merge Extcap IE from addn_ie
786 * may change the frame size. Therefore, MUST merge ExtCap IE before
787 * dot11f get packed payload size.
788 */
789 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800790 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
791 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800792
793 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
794 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700795 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800796 status);
797 /* We'll fall back on the worst case scenario: */
798 payload = sizeof(tDot11fProbeResponse);
799 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700800 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800801 status);
802 }
803
804 bytes += payload + sizeof(tSirMacMgmtHdr);
805
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530806 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530808 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700809 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 goto err_ret;
811 }
812 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530813 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814
815 /* Next, we fill out the buffer descriptor: */
816 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
817 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
818 pe_session->selfMacAddr);
819
820 mac_hdr = (tpSirMacMgmtHdr) frame;
821
822 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 /* That done, pack the Probe Response: */
825 status =
826 dot11f_pack_probe_response(mac_ctx, frm,
827 frame + sizeof(tSirMacMgmtHdr),
828 payload, &payload);
829 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700830 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 status);
832 goto err_ret;
833 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700834 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 }
836
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700837 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530838 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840 if (mac_ctx->lim.gpLimRemainOnChanReq)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530841 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 mac_ctx->lim.gpLimRemainOnChanReq->probeRspIe,
843 (mac_ctx->lim.gpLimRemainOnChanReq->length -
844 sizeof(tSirRemainOnChnReq)));
845
846 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530847 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 &add_ie[0], addn_ie_len);
849
850 if (noalen != 0) {
851 if (total_noalen >
852 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700853 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 total_noalen);
855 goto err_ret;
856 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530857 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 &noa_ie[0], total_noalen);
859 }
860 }
861
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800862 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530863 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
864 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 )
866 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
867
868 /* Queue Probe Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530869 qdf_status = wma_tx_frame((tHalHandle) mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 (uint16_t) bytes,
871 TXRX_FRM_802_11_MGMT,
872 ANI_TXDIR_TODS,
873 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -0700874 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875
876 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530877 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700878 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879
880 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530881 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530883 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 return;
885
886err_ret:
887 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530888 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889 if (frm != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530890 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 if (packet != NULL)
892 cds_packet_free((void *)packet);
893 return;
894
895} /* End lim_send_probe_rsp_mgmt_frame. */
896
897void
898lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
899 tSirMacAddr peerMacAddr,
900 tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry)
901{
902 uint16_t i;
903 uint8_t *pFrame;
904 tDot11fAddTSRequest AddTSReq;
905 tDot11fWMMAddTSRequest WMMAddTSReq;
906 uint32_t nPayload, nBytes, nStatus;
907 tpSirMacMgmtHdr pMacHdr;
908 void *pPacket;
909#ifdef FEATURE_WLAN_ESE
910 uint32_t phyMode;
911#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530912 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 uint8_t txFlag = 0;
914 uint8_t smeSessionId = 0;
915
916 if (NULL == psessionEntry) {
917 return;
918 }
919
920 smeSessionId = psessionEntry->smeSessionId;
921
922 if (!pAddTS->wmeTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530923 qdf_mem_set((uint8_t *) &AddTSReq, sizeof(AddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924
925 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
926 AddTSReq.DialogToken.token = pAddTS->dialogToken;
927 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
928 if (pAddTS->lleTspecPresent) {
929 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
930 } else {
931 populate_dot11f_wmmtspec(&pAddTS->tspec,
932 &AddTSReq.WMMTSPEC);
933 }
934
935 if (pAddTS->lleTspecPresent) {
936 AddTSReq.num_WMMTCLAS = 0;
937 AddTSReq.num_TCLAS = pAddTS->numTclas;
938 for (i = 0; i < pAddTS->numTclas; ++i) {
939 populate_dot11f_tclas(pMac, &pAddTS->tclasInfo[i],
940 &AddTSReq.TCLAS[i]);
941 }
942 } else {
943 AddTSReq.num_TCLAS = 0;
944 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
945 for (i = 0; i < pAddTS->numTclas; ++i) {
946 populate_dot11f_wmmtclas(pMac,
947 &pAddTS->tclasInfo[i],
948 &AddTSReq.WMMTCLAS[i]);
949 }
950 }
951
952 if (pAddTS->tclasProcPresent) {
953 if (pAddTS->lleTspecPresent) {
954 AddTSReq.TCLASSPROC.processing =
955 pAddTS->tclasProc;
956 AddTSReq.TCLASSPROC.present = 1;
957 } else {
958 AddTSReq.WMMTCLASPROC.version = 1;
959 AddTSReq.WMMTCLASPROC.processing =
960 pAddTS->tclasProc;
961 AddTSReq.WMMTCLASPROC.present = 1;
962 }
963 }
964
965 nStatus =
966 dot11f_get_packed_add_ts_request_size(pMac, &AddTSReq, &nPayload);
967 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700968 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
969 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 /* We'll fall back on the worst case scenario: */
971 nPayload = sizeof(tDot11fAddTSRequest);
972 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700973 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
974 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 }
976 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530977 qdf_mem_set((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978
979 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
980 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
981 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
982
983 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
984 WMMAddTSReq.StatusCode.statusCode = 0;
985
986 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
987#ifdef FEATURE_WLAN_ESE
988 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
989
990 if (phyMode == WNI_CFG_PHY_MODE_11G
991 || phyMode == WNI_CFG_PHY_MODE_11A) {
992 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
993 } else {
994 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
995 }
996 populate_dot11_tsrsie(pMac, &pAddTS->tsrsIE,
997 &WMMAddTSReq.ESETrafStrmRateSet,
998 sizeof(uint8_t));
999#endif
1000 /* fillWmeTspecIE */
1001
1002 nStatus =
1003 dot11f_get_packed_wmm_add_ts_request_size(pMac, &WMMAddTSReq,
1004 &nPayload);
1005 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001006 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007 nStatus);
1008 /* We'll fall back on the worst case scenario: */
1009 nPayload = sizeof(tDot11fAddTSRequest);
1010 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001011 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
1012 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 }
1014 }
1015
1016 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1017
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301018 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301020 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001021 pe_err("Failed to allocate %d bytes for an Add TS Request",
1022 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 return;
1024 }
1025 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301026 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027
1028 /* Next, we fill out the buffer descriptor: */
1029 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1030 SIR_MAC_MGMT_ACTION, peerMacAddr, psessionEntry->selfMacAddr);
1031 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1032
1033 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1034
1035#ifdef WLAN_FEATURE_11W
1036 lim_set_protected_bit(pMac, psessionEntry, peerMacAddr, pMacHdr);
1037#endif
1038
1039 /* That done, pack the struct: */
1040 if (!pAddTS->wmeTspecPresent) {
1041 nStatus = dot11f_pack_add_ts_request(pMac, &AddTSReq,
1042 pFrame +
1043 sizeof(tSirMacMgmtHdr),
1044 nPayload, &nPayload);
1045 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001046 pe_err("Failed to pack an Add TS Request "
1047 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 cds_packet_free((void *)pPacket);
1049 return; /* allocated! */
1050 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001051 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1052 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 }
1054 } else {
1055 nStatus = dot11f_pack_wmm_add_ts_request(pMac, &WMMAddTSReq,
1056 pFrame +
1057 sizeof(tSirMacMgmtHdr),
1058 nPayload, &nPayload);
1059 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001060 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1061 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 cds_packet_free((void *)pPacket);
1063 return; /* allocated! */
1064 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001065 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1066 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 }
1068 }
1069
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001070 pe_debug("Sending an Add TS Request frame to");
1071 lim_print_mac_addr(pMac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001073 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301075 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1076 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 ) {
1078 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1079 }
1080
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301081 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082 psessionEntry->peSessionId, pMacHdr->fc.subType));
1083
1084 /* Queue Addts Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301085 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 TXRX_FRM_802_11_MGMT,
1087 ANI_TXDIR_TODS,
1088 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001089 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301090 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301091 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001093 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1094 pe_err("Could not send an Add TS Request (%X",
1095 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096} /* End lim_send_addts_req_action_frame. */
1097
1098/**
1099 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1100 * @mac_ctx: Handle for mac context
1101 * @status_code: Status code for assoc response frame
1102 * @aid: Association ID
1103 * @peer_addr: Mac address of requesting peer
1104 * @subtype: Assoc/Reassoc
1105 * @sta: Pointer to station node
1106 * @pe_session: PE session id.
1107 *
1108 * Builds and sends association response frame to the requesting peer.
1109 *
1110 * Return: void
1111 */
1112
1113void
1114lim_send_assoc_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
1115 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
1116 uint8_t subtype, tpDphHashNode sta, tpPESession pe_session)
1117{
1118 static tDot11fAssocResponse frm;
1119 uint8_t *frame;
1120 tpSirMacMgmtHdr mac_hdr;
1121 tSirRetStatus sir_status;
1122 uint8_t lle_mode = 0, addts;
1123 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001124 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001125 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301126 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001127 tUpdateBeaconParams beacon_params;
1128 uint8_t tx_flag = 0;
1129 uint32_t addn_ie_len = 0;
1130 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1131 tpSirAssocReq assoc_req = NULL;
1132 uint8_t sme_session = 0;
1133 bool is_vht = false;
1134 uint16_t stripoff_len = 0;
1135 tDot11fIEExtCap extracted_ext_cap;
1136 bool extracted_flag = false;
1137#ifdef WLAN_FEATURE_11W
1138 uint32_t retry_int;
1139 uint32_t max_retries;
1140#endif
1141
1142 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001143 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144 return;
1145 }
1146
1147 sme_session = pe_session->smeSessionId;
1148
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301149 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150
1151 limGetQosMode(pe_session, &qos_mode);
1152 limGetWmeMode(pe_session, &wme_mode);
1153
1154 /*
1155 * An Add TS IE is added only if the AP supports it and
1156 * the requesting STA sent a traffic spec.
1157 */
1158 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1159
1160 frm.Status.status = status_code;
1161
1162 frm.AID.associd = aid | LIM_AID_MASK;
1163
1164 if (NULL == sta) {
1165 populate_dot11f_supp_rates(mac_ctx,
1166 POPULATE_DOT11F_RATES_OPERATIONAL,
1167 &frm.SuppRates, pe_session);
1168 populate_dot11f_ext_supp_rates(mac_ctx,
1169 POPULATE_DOT11F_RATES_OPERATIONAL,
1170 &frm.ExtSuppRates, pe_session);
1171 } else {
1172 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1173 &frm.ExtSuppRates,
1174 sta->supportedRates.llbRates,
1175 sta->supportedRates.llaRates);
1176 }
1177
1178 if (LIM_IS_AP_ROLE(pe_session) && sta != NULL &&
1179 eSIR_SUCCESS == status_code) {
1180 assoc_req = (tpSirAssocReq)
1181 pe_session->parsedAssocReq[sta->assocId];
1182 /*
1183 * populate P2P IE in AssocRsp when assocReq from the peer
1184 * includes P2P IE
1185 */
1186 if (assoc_req != NULL && assoc_req->addIEPresent)
1187 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1188 &frm.P2PAssocRes,
1189 assoc_req);
1190 }
1191
1192 if (NULL != sta) {
1193 if (eHAL_SET == qos_mode) {
1194 if (sta->lleEnabled) {
1195 lle_mode = 1;
1196 populate_dot11f_edca_param_set(mac_ctx,
1197 &frm.EDCAParamSet, pe_session);
1198 }
1199 }
1200
1201 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1202 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1203 pe_session);
1204
1205 if (sta->wsmEnabled)
1206 populate_dot11f_wmm_caps(&frm.WMMCaps);
1207 }
1208
1209 if (sta->mlmStaContext.htCapability &&
1210 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001211 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 populate_dot11f_ht_caps(mac_ctx, pe_session,
1213 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001214 /*
1215 * Check the STA capability and
1216 * update the HTCaps accordingly
1217 */
1218 frm.HTCaps.supportedChannelWidthSet = (
1219 sta->htSupportedChannelWidthSet <
1220 pe_session->htSupportedChannelWidthSet) ?
1221 sta->htSupportedChannelWidthSet :
1222 pe_session->htSupportedChannelWidthSet;
1223 if (!frm.HTCaps.supportedChannelWidthSet)
1224 frm.HTCaps.shortGI40MHz = 0;
1225
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
1227 pe_session);
1228 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001229 pe_debug("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, short GI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x",
Agrawal Ashishc38e58d2015-09-16 17:17:29 +05301230 frm.HTCaps.supportedChannelWidthSet,
1231 frm.HTCaps.mimoPowerSave,
1232 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1233 frm.HTCaps.shortGI40MHz,
1234 frm.HTCaps.dsssCckMode40MHz,
1235 frm.HTCaps.maxRxAMPDUFactor);
1236
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 if (sta->mlmStaContext.vhtCapability &&
1238 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001239 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 populate_dot11f_vht_caps(mac_ctx, pe_session,
1241 &frm.VHTCaps);
1242 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301243 &frm.VHTOperation);
1244 is_vht = true;
1245 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001246
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301247 if (pe_session->vhtCapability &&
1248 pe_session->vendor_vht_sap &&
1249 (assoc_req != NULL) &&
1250 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001251 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301252 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001253 frm.vendor_vht_ie.sub_type =
1254 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301255 frm.vendor_vht_ie.VHTCaps.present = 1;
1256 populate_dot11f_vht_caps(mac_ctx, pe_session,
1257 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001258 populate_dot11f_vht_operation(mac_ctx, pe_session,
1259 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 is_vht = true;
1261 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1263 pe_session);
1264
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001265 if (lim_is_sta_he_capable(sta) &&
1266 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001267 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001268 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001269 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001270 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001271 &frm.he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001272 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273#ifdef WLAN_FEATURE_11W
1274 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
1275 if (wlan_cfg_get_int
1276 (mac_ctx, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1277 &max_retries) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001278 pe_err("get WNI_CFG_PMF_SA_QUERY_MAX_RETRIES failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001279 else if (wlan_cfg_get_int
1280 (mac_ctx,
1281 WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1282 &retry_int) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001283 pe_err("get WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 else
1285 populate_dot11f_timeout_interval(mac_ctx,
1286 &frm.TimeoutInterval,
1287 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1288 (max_retries -
1289 sta->pmfSaQueryRetryCount)
1290 * retry_int);
1291 }
1292#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001293
1294 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1295 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 }
1297
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301298 qdf_mem_set((uint8_t *) &beacon_params, sizeof(beacon_params), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299
1300 if (LIM_IS_AP_ROLE(pe_session) &&
1301 (pe_session->gLimProtectionControl !=
1302 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE))
1303 lim_decide_ap_protection(mac_ctx, peer_addr,
1304 &beacon_params, pe_session);
1305
1306 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1307 pe_session);
1308 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1309 pe_session);
1310
1311 /*
1312 * Populate Do11capabilities after updating session with
1313 * Assos req details
1314 */
1315 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1316
1317 beacon_params.bssIdx = pe_session->bssIdx;
1318
1319 /* Send message to HAL about beacon parameter change. */
1320 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1321 && beacon_params.paramChangeBitmap) {
1322 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1323 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1324 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325
1326 if (assoc_req != NULL) {
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001327 addn_ie_len = pe_session->addIeParams.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328
1329 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001330 if (addn_ie_len > 0 &&
1331 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1332 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301333 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 pe_session->addIeParams.assocRespData_buff,
1335 pe_session->addIeParams.assocRespDataLen);
1336
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301337 qdf_mem_set((uint8_t *) &extracted_ext_cap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 sizeof(extracted_ext_cap), 0);
1339
1340 stripoff_len = addn_ie_len;
1341 sir_status =
1342 lim_strip_extcap_update_struct
1343 (mac_ctx, &add_ie[0], &stripoff_len,
1344 &extracted_ext_cap);
1345 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001346 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 } else {
1348 addn_ie_len = stripoff_len;
1349 extracted_flag = true;
1350 }
1351 bytes = bytes + addn_ie_len;
1352 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001353 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354 addn_ie_len, assoc_req->addIEPresent);
1355 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001356
1357 /*
1358 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1359 * may change the frame size. Therefore, MUST merge ExtCap IE before
1360 * dot11f get packed payload size.
1361 */
1362 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001363 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1364 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001365
1366 /* Allocate a buffer for this frame: */
1367 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1368 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001369 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001370 status);
1371 return;
1372 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001373 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001374 status);
1375 }
1376
1377 bytes += sizeof(tSirMacMgmtHdr) + payload;
1378
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301379 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301381 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001382 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383 return;
1384 }
1385 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301386 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387
1388 /* Next, we fill out the buffer descriptor: */
1389 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1390 (LIM_ASSOC == subtype) ?
1391 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1392 peer_addr,
1393 pe_session->selfMacAddr);
1394 mac_hdr = (tpSirMacMgmtHdr) frame;
1395
1396 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1397
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1399 frame + sizeof(tSirMacMgmtHdr),
1400 payload, &payload);
1401 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001402 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403 status);
1404 cds_packet_free((void *)packet);
1405 return;
1406 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001407 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 status);
1409 }
1410
1411 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001412 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413 status_code, aid);
1414 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001415 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416 status_code, aid);
1417
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301418 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419
1420 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301421 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 &add_ie[0], addn_ie_len);
1423
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001424 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301426 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1427 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1429
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301430 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 pe_session->peSessionId, mac_hdr->fc.subType));
1432 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301433 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 TXRX_FRM_802_11_MGMT,
1435 ANI_TXDIR_TODS,
1436 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001437 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301438 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301439 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440
1441 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301442 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001443 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301444 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445
1446 /*
1447 * update the ANI peer station count.
1448 * FIXME_PROTECTION : take care of different type of station
1449 * counter inside this function.
1450 */
1451 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1452
1453}
1454
1455void
1456lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
1457 tSirMacAddr peer,
1458 uint8_t wmmTspecPresent,
1459 tSirMacTSInfo *pTsinfo,
1460 tSirMacTspecIE *pTspecIe, tpPESession psessionEntry)
1461{
1462 uint8_t *pFrame;
1463 tpSirMacMgmtHdr pMacHdr;
1464 tDot11fDelTS DelTS;
1465 tDot11fWMMDelTS WMMDelTS;
1466 uint32_t nBytes, nPayload, nStatus;
1467 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301468 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 uint8_t txFlag = 0;
1470 uint8_t smeSessionId = 0;
1471
1472 if (NULL == psessionEntry) {
1473 return;
1474 }
1475
1476 smeSessionId = psessionEntry->smeSessionId;
1477
1478 if (!wmmTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301479 qdf_mem_set((uint8_t *) &DelTS, sizeof(DelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480
1481 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1482 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1483 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1484
1485 nStatus = dot11f_get_packed_del_ts_size(pMac, &DelTS, &nPayload);
1486 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001487 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 /* We'll fall back on the worst case scenario: */
1489 nPayload = sizeof(tDot11fDelTS);
1490 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001491 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1492 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493 }
1494 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301495 qdf_mem_set((uint8_t *) &WMMDelTS, sizeof(WMMDelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496
1497 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1498 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1499 WMMDelTS.DialogToken.token = 0;
1500 WMMDelTS.StatusCode.statusCode = 0;
1501 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1502 nStatus =
1503 dot11f_get_packed_wmm_del_ts_size(pMac, &WMMDelTS, &nPayload);
1504 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001505 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 /* We'll fall back on the worst case scenario: */
1507 nPayload = sizeof(tDot11fDelTS);
1508 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001509 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1510 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511 }
1512 }
1513
1514 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1515
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301516 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1518 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301519 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001520 pe_err("Failed to allocate %d bytes for an Add TS Response",
1521 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 return;
1523 }
1524 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301525 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526
1527 /* Next, we fill out the buffer descriptor: */
1528 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1529 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
1530 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1531
1532 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1533
1534#ifdef WLAN_FEATURE_11W
1535 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
1536#endif
1537
1538 /* That done, pack the struct: */
1539 if (!wmmTspecPresent) {
1540 nStatus = dot11f_pack_del_ts(pMac, &DelTS,
1541 pFrame + sizeof(tSirMacMgmtHdr),
1542 nPayload, &nPayload);
1543 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001544 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 nStatus);
1546 cds_packet_free((void *)pPacket);
1547 return; /* allocated! */
1548 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001549 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1550 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 }
1552 } else {
1553 nStatus = dot11f_pack_wmm_del_ts(pMac, &WMMDelTS,
1554 pFrame + sizeof(tSirMacMgmtHdr),
1555 nPayload, &nPayload);
1556 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001557 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 nStatus);
1559 cds_packet_free((void *)pPacket);
1560 return; /* allocated! */
1561 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001562 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1563 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 }
1565 }
1566
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001567 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
1568 lim_print_mac_addr(pMac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001570 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301572 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1573 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 ) {
1575 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1576 }
1577
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301578 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301580 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 TXRX_FRM_802_11_MGMT,
1582 ANI_TXDIR_TODS,
1583 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001584 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301585 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301586 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301588 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001589 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590
1591} /* End lim_send_delts_req_action_frame. */
1592
1593/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301594 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1595 * @context: pointer to global mac
1596 * @buf: buffer
1597 * @tx_complete : Sent status
1598 * @params; tx completion params
1599 *
1600 * Return: This returns QDF_STATUS
1601 */
1602
1603static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1604 qdf_nbuf_t buf,
1605 uint32_t tx_complete,
1606 void *params)
1607{
1608 uint16_t assoc_ack_status;
1609 uint16_t reason_code;
1610 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
1611
1612 pe_debug("tx_complete= %d", tx_complete);
1613 if (tx_complete) {
1614 assoc_ack_status = ACKED;
1615 reason_code = eSIR_SUCCESS;
1616 } else {
1617 assoc_ack_status = NOT_ACKED;
1618 reason_code = eSIR_FAILURE;
1619 }
1620 if (buf)
1621 qdf_nbuf_free(buf);
1622
1623 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1624 NULL, assoc_ack_status, reason_code);
1625 return QDF_STATUS_SUCCESS;
1626}
1627
1628/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 * lim_send_assoc_req_mgmt_frame() - Send association request
1630 * @mac_ctx: Handle to MAC context
1631 * @mlm_assoc_req: Association request information
1632 * @pe_session: PE session information
1633 *
1634 * Builds and transmits association request frame to AP.
1635 *
1636 * Return: Void
1637 */
1638
1639void
1640lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
1641 tLimMlmAssocReq *mlm_assoc_req,
1642 tpPESession pe_session)
1643{
1644 tDot11fAssocRequest *frm;
1645 uint16_t caps;
1646 uint8_t *frame;
1647 tSirRetStatus sir_status;
1648 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001649 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1651 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301652 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 uint16_t add_ie_len;
1654 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001655 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 uint8_t tx_flag = 0;
1658 uint8_t sme_sessionid = 0;
1659 bool vht_enabled = false;
1660 tDot11fIEExtCap extr_ext_cap;
1661 bool extr_ext_flag = true;
1662 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001663 uint32_t ie_offset = 0;
1664 uint8_t *p_ext_cap = NULL;
1665 tDot11fIEExtCap bcn_ext_cap;
1666 uint8_t *bcn_ie = NULL;
1667 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301668 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001669 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670
1671 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001672 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301673 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674 return;
1675 }
1676
1677 sme_sessionid = pe_session->smeSessionId;
1678
1679 /* check this early to avoid unncessary operation */
1680 if (NULL == pe_session->pLimJoinReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001681 pe_err("pe_session->pLimJoinReq is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301682 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 return;
1684 }
1685 add_ie_len = pe_session->pLimJoinReq->addIEAssoc.length;
1686 add_ie = pe_session->pLimJoinReq->addIEAssoc.addIEdata;
1687
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301688 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001690 pe_err("Unable to allocate memory");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301691 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 return;
1693 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001694 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fAssocRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301696 if (add_ie_len && pe_session->is_ext_caps_present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301697 qdf_mem_set((uint8_t *) &extr_ext_cap, sizeof(tDot11fIEExtCap),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 0);
1699 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1700 add_ie, &add_ie_len, &extr_ext_cap);
1701 if (eSIR_SUCCESS != sir_status) {
1702 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001703 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 } else {
1705 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1706 extr_ext_cap.bytes;
1707
1708 if (p_ext_cap->interworking_service)
1709 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001710 extr_ext_cap.num_bytes =
1711 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1712 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 }
1714 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001715 pe_debug("No addn IE or peer dosen't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 extr_ext_flag = false;
1717 }
1718
1719 caps = mlm_assoc_req->capabilityInfo;
1720#if defined(FEATURE_WLAN_WAPI)
1721 /*
1722 * According to WAPI standard:
1723 * 7.3.1.4 Capability Information field
1724 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1725 * in transmitted Association or Reassociation management frames.
1726 * APs ignore the Privacy subfield within received Association and
1727 * Reassociation management frames.
1728 */
1729 if (pe_session->encryptType == eSIR_ED_WPI)
1730 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1731#endif
1732 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1733
1734 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1735 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1736 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1737 &frm->SuppRates, pe_session);
1738
1739 qos_enabled = (pe_session->limQosEnabled) &&
1740 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1741
1742 wme_enabled = (pe_session->limWmeEnabled) &&
1743 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1744
1745 /* We prefer .11e asociations: */
1746 if (qos_enabled)
1747 wme_enabled = false;
1748
1749 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1750 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1751
1752 if (pe_session->lim11hEnable &&
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001753 pe_session->pLimJoinReq->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754 power_caps = true;
1755
1756 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1757 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1759 LIM_ASSOC, pe_session);
1760
1761 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1763 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1764 if (power_caps == false) {
1765 power_caps = true;
1766 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1767 LIM_ASSOC, pe_session);
1768 }
1769 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001771 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1772 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773
1774 populate_dot11f_ext_supp_rates(mac_ctx,
1775 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1776 pe_session);
1777
Gupta, Kapil54a16992016-01-13 19:34:02 +05301778 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1779 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1781 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 /*
1784 * The join request *should* contain zero or one of the WPA and RSN
1785 * IEs. The payload send along with the request is a
1786 * 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
1787 * typedef struct sSirRSNie
1788 * {
1789 * uint16_t length;
1790 * uint8_t rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
1791 * } tSirRSNie, *tpSirRSNie;
1792 * So, we should be able to make the following two calls harmlessly,
1793 * since they do nothing if they don't find the given IE in the
1794 * bytestream with which they're provided.
1795 * The net effect of this will be to faithfully transmit whatever
1796 * security IE is in the join request.
1797 * However, if we're associating for the purpose of WPS
1798 * enrollment, and we've been configured to indicate that by
1799 * eliding the WPA or RSN IE, we just skip this:
1800 */
1801 if (add_ie_len && add_ie)
1802 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1803
1804 if (NULL == wps_ie) {
1805 populate_dot11f_rsn_opaque(mac_ctx,
1806 &(pe_session->pLimJoinReq->rsnIE),
1807 &frm->RSNOpaque);
1808 populate_dot11f_wpa_opaque(mac_ctx,
1809 &(pe_session->pLimJoinReq->rsnIE),
1810 &frm->WPAOpaque);
1811#if defined(FEATURE_WLAN_WAPI)
1812 populate_dot11f_wapi_opaque(mac_ctx,
1813 &(pe_session->pLimJoinReq->rsnIE),
1814 &frm->WAPIOpaque);
1815#endif /* defined(FEATURE_WLAN_WAPI) */
1816 }
1817 /* include WME EDCA IE as well */
1818 if (wme_enabled) {
1819 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1820 pe_session, &frm->WMMInfoStation);
1821
1822 if (wsm_enabled)
1823 populate_dot11f_wmm_caps(&frm->WMMCaps);
1824 }
1825
1826 /*
1827 * Populate HT IEs, when operating in 11n and
1828 * when AP is also operating in 11n mode
1829 */
1830 if (pe_session->htCapability &&
1831 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001832 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001834 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1835 &frm->HTCaps, sizeof(frm->HTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001837 pe_debug("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, short GI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x",
Agrawal Ashishc38e58d2015-09-16 17:17:29 +05301838 frm->HTCaps.supportedChannelWidthSet,
1839 frm->HTCaps.mimoPowerSave,
1840 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1841 frm->HTCaps.shortGI40MHz,
1842 frm->HTCaps.dsssCckMode40MHz,
1843 frm->HTCaps.maxRxAMPDUFactor);
1844
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 if (pe_session->vhtCapability &&
1846 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001847 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001849 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1850 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001852 if (pe_session->enableHtSmps &&
1853 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001854 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001855 populate_dot11f_operating_mode(mac_ctx,
1856 &frm->OperatingMode, pe_session);
1857 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 }
1859 if (!vht_enabled &&
1860 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001861 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301862 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001863 frm->vendor_vht_ie.sub_type =
1864 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301865 frm->vendor_vht_ie.VHTCaps.present = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301867 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 vht_enabled = true;
1869 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301870 if (pe_session->is_ext_caps_present)
1871 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1872 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301874 if (mac_ctx->roam.configParam.qcn_ie_support)
1875 populate_dot11f_qcn_ie(&frm->QCN_IE);
1876
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001877 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001878 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001879 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001880 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001881 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301882
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 tSirBssDescription *bssdescr;
1885
1886 bssdescr = &pe_session->pLimJoinReq->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001887 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 (unsigned int) bssdescr->mdie[0],
1889 (unsigned int) bssdescr->mdie[1],
1890 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 populate_mdie(mac_ctx, &frm->MobilityDomain,
1892 pe_session->pLimJoinReq->bssDescription.mdie);
1893 } else {
1894 /* No 11r IEs dont send any MDIE */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001895 pe_debug("MDIE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897
1898#ifdef FEATURE_WLAN_ESE
1899 /*
1900 * ESE Version IE will be included in association request
1901 * when ESE is enabled on DUT through ini and it is also
1902 * advertised by the peer AP to which we are trying to
1903 * associate to.
1904 */
1905 if (pe_session->is_ese_version_ie_present &&
1906 mac_ctx->roam.configParam.isEseIniFeatureEnabled)
1907 populate_dot11f_ese_version(&frm->ESEVersion);
1908 /* For ESE Associations fill the ESE IEs */
1909 if (pe_session->isESEconnection &&
1910 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1911#ifndef FEATURE_DISABLE_RM
1912 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1913#endif
1914 }
1915#endif
1916
Hu Wang411e0cc2016-10-28 14:56:01 +08001917 /*
1918 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1919 * may change the frame size. Therefore, MUST merge ExtCap IE before
1920 * dot11f get packed payload size.
1921 */
1922 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001923 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1924
1925 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1926 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1927 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1928 DOT11F_FF_BEACONINTERVAL_LEN +
1929 DOT11F_FF_CAPABILITIES_LEN;
1930
1931 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1932 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1933 bcn_ie = pe_session->beacon + ie_offset;
1934 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001935 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001936 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001937 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001938 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1939 &bcn_ext_cap);
1940 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1941 false);
1942 }
1943 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001944
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001945 if (eSIR_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
1946 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001947 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001948
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301949 if (lim_is_fils_connection(pe_session)) {
1950 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
1951 aes_block_size_len = AES_BLOCK_SIZE;
1952 }
1953
1954 /*
1955 * Do unpack to populate the add_ie buffer to frm structure
1956 * before packing the frm structure. In this way, the IE ordering
1957 * which the latest 802.11 spec mandates is maintained.
1958 */
1959 if (add_ie_len)
1960 dot11f_unpack_assoc_request(mac_ctx, add_ie,
1961 add_ie_len, frm, true);
1962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
1964 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001965 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 status);
1967 /* We'll fall back on the worst case scenario: */
1968 payload = sizeof(tDot11fAssocRequest);
1969 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001970 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 status);
1972 }
1973
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301974 bytes = payload + sizeof(tSirMacMgmtHdr) +
1975 aes_block_size_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301977 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301979 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001980 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981
1982 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301983 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984 pe_session->peSessionId,
1985 pe_session->limMlmState));
1986
1987 /* Update PE session id */
1988 assoc_cnf.sessionId = pe_session->peSessionId;
1989
1990 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1991
1992 cds_packet_free((void *)packet);
1993
1994 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
1995 (uint32_t *) &assoc_cnf);
1996
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301997 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 }
1999 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302000 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001
2002 /* Next, we fill out the buffer descriptor: */
2003 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2004 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
2005 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 /* That done, pack the Assoc Request: */
2007 status = dot11f_pack_assoc_request(mac_ctx, frm,
2008 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2009 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002010 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302012 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002014 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 }
2016
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 if (pe_session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302018 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002020 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 }
2022
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302023 if (lim_is_fils_connection(pe_session)) {
2024 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2025 frame, &payload);
2026 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2027 cds_packet_free((void *)packet);
2028 qdf_mem_free(frm);
2029 return;
2030 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 }
2032
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302033 pe_session->assocReq = qdf_mem_malloc(payload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 if (NULL == pe_session->assocReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002035 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002036 } else {
2037 /*
2038 * Store the Assoc request. This is sent to csr/hdd in
2039 * join cnf response.
2040 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302041 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 frame + sizeof(tSirMacMgmtHdr), payload);
2043 pe_session->assocReqLen = payload;
2044 }
2045
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002046 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302047 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
2048 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 )
2050 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2051
Anurag Chouhan6d760662016-02-20 16:05:43 +05302052 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
2053 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2055
2056#ifdef FEATURE_WLAN_DIAG_SUPPORT
2057 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
2058 pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
2059#endif
2060 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302061 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302063
2064 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002065 min_rid = lim_get_min_session_txrate(pe_session);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302066 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302067 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2069 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302070 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002071 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302072 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302073 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302074 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002075
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302076 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002077 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302078 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302079 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
2080 pe_session, SENT_FAIL, eSIR_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002081 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 }
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302083end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302085 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302087 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 return;
2089}
2090
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302092 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302093 * @context: pointer to global mac
2094 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302095 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302096 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302097 *
2098 * Return: This returns QDF_STATUS
2099 */
2100
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302101static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2102 qdf_nbuf_t buf,
2103 uint32_t tx_complete,
2104 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302105{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302106 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302107 uint16_t auth_ack_status;
2108 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302109
Naveen Rawat684e8b12017-09-20 15:54:44 -07002110 pe_debug("tx_complete = %d %s", tx_complete,
2111 (tx_complete ? "success":"fail"));
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302112 if (tx_complete) {
2113 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302114 auth_ack_status = ACKED;
2115 reason_code = eSIR_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302116 /* 'Change' timer for future activations */
2117 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2118 } else {
2119 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302120 auth_ack_status = NOT_ACKED;
2121 reason_code = eSIR_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302122 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302123
2124 if (buf)
2125 qdf_nbuf_free(buf);
2126
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302127 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2128 NULL, auth_ack_status, reason_code);
2129
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302130 return QDF_STATUS_SUCCESS;
2131}
2132
2133/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2135 *
2136 * @mac_ctx: Pointer to Global MAC structure
2137 * @auth_frame: Pointer to Authentication frame structure
2138 * @peer_addr: MAC address of destination peer
2139 * @wep_bit: wep bit in frame control for Authentication frame3
2140 * @session: PE session information
2141 *
2142 * This function is called by lim_process_mlm_messages(). Authentication frame
2143 * is formatted and sent when this function is called.
2144 *
2145 * Return: void
2146 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147void
2148lim_send_auth_mgmt_frame(tpAniSirGlobal mac_ctx,
2149 tpSirMacAuthFrameBody auth_frame,
2150 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302151 uint8_t wep_challenge_len,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302152 tpPESession session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153{
2154 uint8_t *frame, *body;
2155 uint32_t frame_len = 0, body_len = 0;
2156 tpSirMacMgmtHdr mac_hdr;
2157 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302158 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 uint8_t tx_flag = 0;
2160 uint8_t sme_sessionid = 0;
2161 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002162 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002163 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164
2165 if (NULL == session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002166 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167 return;
2168 }
2169
2170 sme_sessionid = session->smeSessionId;
2171
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302172 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002173 /*
2174 * Auth frame3 to be sent with encrypted framebody
2175 *
2176 * Allocate buffer for Authenticaton frame of size
2177 * equal to management frame header length plus 2 bytes
2178 * each for auth algorithm number, transaction number,
2179 * status code, 128 bytes for challenge text and
2180 * 4 bytes each for IV & ICV.
2181 */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002182 pe_debug("Sending encrypted auth frame to " MAC_ADDRESS_STR,
2183 MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002184
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302185 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002186 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002187
2188 goto alloc_packet;
2189 }
2190
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302191 pe_info("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002192 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 auth_frame->authTransactionSeqNumber,
2194 auth_frame->authStatusCode,
2195 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
2196 MAC_ADDR_ARRAY(peer_addr));
2197
2198 switch (auth_frame->authTransactionSeqNumber) {
2199 case SIR_MAC_AUTH_FRAME_1:
2200 /*
2201 * Allocate buffer for Authenticaton frame of size
2202 * equal to management frame header length plus 2 bytes
2203 * each for auth algorithm number, transaction number
2204 * and status code.
2205 */
2206
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002207 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2208 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302210 frame_len += lim_create_fils_auth_data(mac_ctx,
2211 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
2213 if (NULL != session->ftPEContext.pFTPreAuthReq &&
2214 0 != session->ftPEContext.pFTPreAuthReq->
2215 ft_ies_length) {
2216 ft_ies_length = session->ftPEContext.
2217 pFTPreAuthReq->ft_ies_length;
2218 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002219 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 ft_ies_length);
2221 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002222 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 frame_len += (2 + SIR_MDIE_SIZE);
2224 }
2225 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 break;
2227
2228 case SIR_MAC_AUTH_FRAME_2:
2229 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2230 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2231 (auth_frame->authStatusCode !=
2232 eSIR_MAC_SUCCESS_STATUS))) {
2233 /*
2234 * Allocate buffer for Authenticaton frame of size
2235 * equal to management frame header length plus
2236 * 2 bytes each for auth algorithm number,
2237 * transaction number and status code.
2238 */
2239
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002240 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2241 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 } else {
2243 /*
2244 * Shared Key algorithm with challenge text
2245 * to be sent.
2246 *
2247 * Allocate buffer for Authenticaton frame of size
2248 * equal to management frame header length plus
2249 * 2 bytes each for auth algorithm number,
2250 * transaction number, status code and 128 bytes
2251 * for challenge text.
2252 */
2253
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002254 challenge_req = true;
2255 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302256 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2257 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002258 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 }
2260 break;
2261
2262 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002263 /*
2264 * Auth frame3 to be sent without encrypted framebody
2265 *
2266 * Allocate buffer for Authenticaton frame of size equal
2267 * to management frame header length plus 2 bytes each
2268 * for auth algorithm number, transaction number and
2269 * status code.
2270 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002272 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2273 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274 break;
2275
2276 case SIR_MAC_AUTH_FRAME_4:
2277 /*
2278 * Allocate buffer for Authenticaton frame of size equal
2279 * to management frame header length plus 2 bytes each
2280 * for auth algorithm number, transaction number and
2281 * status code.
2282 */
2283
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002284 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2285 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286
2287 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002288 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002289 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002290 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 } /* switch (auth_frame->authTransactionSeqNumber) */
2292
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002293alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302294 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 (void **)&packet);
2296
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302297 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002298 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 return;
2300 }
2301
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302302 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303
2304 /* Prepare BD */
2305 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2306 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2307 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302308 if (wep_challenge_len)
2309 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2310 else
2311 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312
2313 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002314 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302315 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 (uint8_t *) session->bssId,
2317 sizeof(tSirMacAddr));
2318
2319 /* Prepare Authentication frame body */
2320 body = frame + sizeof(tSirMacMgmtHdr);
2321
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302322 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302323 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002325 pe_debug("Sending Auth seq# 3 to " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 MAC_ADDR_ARRAY(mac_hdr->da));
2327
2328 } else {
2329 *((uint16_t *) (body)) =
2330 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2331 body += sizeof(uint16_t);
2332 body_len -= sizeof(uint16_t);
2333
2334 *((uint16_t *) (body)) =
2335 sir_swap_u16if_needed(
2336 auth_frame->authTransactionSeqNumber);
2337 body += sizeof(uint16_t);
2338 body_len -= sizeof(uint16_t);
2339
2340 *((uint16_t *) (body)) =
2341 sir_swap_u16if_needed(auth_frame->authStatusCode);
2342 body += sizeof(uint16_t);
2343 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002344
2345 if (challenge_req) {
2346 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302347 /* copy challenge IE id, len, challenge text */
2348 *body = auth_frame->type;
2349 body++;
2350 body_len -= sizeof(uint8_t);
2351 *body = auth_frame->length;
2352 body++;
2353 body_len -= sizeof(uint8_t);
2354 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002355 body_len);
2356 pe_err("Incomplete challenge info: length: %d, expected: %d",
2357 body_len,
2358 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2359 body += body_len;
2360 body_len = 0;
2361 } else {
2362 /* copy challenge IE id, len, challenge text */
2363 *body = auth_frame->type;
2364 body++;
2365 *body = auth_frame->length;
2366 body++;
2367 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302368 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2369 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002370
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302371 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2372 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002373 }
2374 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2377 (auth_frame->authTransactionSeqNumber ==
2378 SIR_MAC_AUTH_FRAME_1) &&
2379 (session->ftPEContext.pFTPreAuthReq != NULL)) {
2380
2381 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302382 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 session->ftPEContext.
2384 pFTPreAuthReq->ft_ies,
2385 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002386 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002387 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2388 QDF_TRACE_LEVEL_DEBUG,
2389 (uint8_t *) body,
2390 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 } else if (NULL != session->ftPEContext.
2392 pFTPreAuthReq->pbssDescription) {
2393 /* MDID attr is 54 */
2394 *body = SIR_MDIE_ELEMENT_ID;
2395 body++;
2396 *body = SIR_MDIE_SIZE;
2397 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302398 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 &session->ftPEContext.pFTPreAuthReq->
2400 pbssDescription->mdie[0],
2401 SIR_MDIE_SIZE);
2402 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302403 } else if (auth_frame->authAlgoNumber ==
Varun Reddy Yeturu5faa1772017-10-23 11:22:01 -07002404 SIR_FILS_SK_WITHOUT_PFS) {
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302405 /* TODO MDIE */
2406 pe_debug("appending fils Auth data");
2407 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002410 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
2411 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412 auth_frame->authTransactionSeqNumber,
2413 auth_frame->authStatusCode,
2414 (auth_frame->authStatusCode ==
2415 eSIR_MAC_SUCCESS_STATUS),
2416 MAC_ADDR_ARRAY(mac_hdr->da));
2417 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002418 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2419 QDF_TRACE_LEVEL_DEBUG,
2420 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302422 if ((NULL != session->ftPEContext.pFTPreAuthReq) &&
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002423 (BAND_5G == lim_get_rf_band(
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302424 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002426 else if ((BAND_5G ==
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302427 lim_get_rf_band(session->currentOperChannel))
2428 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2429 || (session->pePersona == QDF_P2P_GO_MODE))
2430 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431
Anurag Chouhan6d760662016-02-20 16:05:43 +05302432 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2433 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2435
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302436 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302439 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002440 min_rid = lim_get_min_session_txrate(session);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302441 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2442 (uint16_t)frame_len,
2443 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2444 7, lim_tx_complete, frame,
2445 lim_auth_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002446 tx_flag, sme_sessionid, false, 0, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302447 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2448 session->peSessionId, qdf_status));
2449 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2450 pe_err("*** Could not send Auth frame, retCode=%X ***",
2451 qdf_status);
2452 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2453 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2454 session, SENT_FAIL, eSIR_FAILURE);
2455 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302456 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457 return;
2458}
2459
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002460QDF_STATUS lim_send_deauth_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461{
2462 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002463 tpDphHashNode sta_ds;
2464 tLimMlmDeauthReq *deauth_req;
2465 tLimMlmDeauthCnf deauth_cnf;
2466 tpPESession session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002468 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2469 if (deauth_req) {
2470 if (tx_timer_running(
2471 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2472 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002475 session_entry = pe_find_session_by_session_id(mac_ctx,
2476 deauth_req->sessionId);
2477 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002478 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002479 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 eSIR_SME_INVALID_PARAMETERS;
2481 goto end;
2482 }
2483
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002484 sta_ds =
2485 dph_lookup_hash_entry(mac_ctx,
2486 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002487 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002488 &session_entry->dph.dphHashTable);
2489 if (sta_ds == NULL) {
2490 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 goto end;
2492 }
2493
2494 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002495 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2496 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2497 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2498 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302499#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002500 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302501#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002502 (session_entry->isFastRoamIniFeatureEnabled) ||
2503 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002504 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002505 session_entry,
2506 session_entry->peSessionId,
2507 deauth_req->reasonCode,
2508 deauth_req->deauthTrigger);
2509 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002510 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002511 pe_debug("No FT Preauth Session Cleanup in role %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002512#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002513 " isESE %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002514#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002515 " isLFR %d"
2516 " is11r %d, Deauth reason %d Trigger = %d",
2517 session_entry->limSystemRole,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002518#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002519 session_entry->isESEconnection,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002520#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002521 session_entry->isFastRoamIniFeatureEnabled,
2522 session_entry->is11Rconnection,
2523 deauth_req->reasonCode,
2524 deauth_req->deauthTrigger);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002525 }
2526 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002527 qdf_mem_free(deauth_req);
2528 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302530 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002532 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2533 &deauth_req->peer_macaddr);
2534 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2535 deauth_cnf.aid = deauth_req->aid;
2536 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537
2538 /* Free up buffer allocated */
2539 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002540 qdf_mem_free(deauth_req);
2541 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002543 lim_post_sme_message(mac_ctx,
2544 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302545 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546}
2547
2548/**
2549 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2550 *
2551 * @mac_ctx: Handle to MAC context
2552 *
2553 * Sends disassoc confirmation to SME. Removes disassoc request stored
2554 * in lim.
2555 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302556 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557 */
2558
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302559QDF_STATUS lim_send_disassoc_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560{
2561 uint16_t aid;
2562 tpDphHashNode sta_ds;
2563 tLimMlmDisassocCnf disassoc_cnf;
2564 tpPESession pe_session;
2565 tLimMlmDisassocReq *disassoc_req;
2566
2567 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2568 if (disassoc_req) {
2569 if (tx_timer_running(
2570 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2571 lim_deactivate_and_change_timer(mac_ctx,
2572 eLIM_DISASSOC_ACK_TIMER);
2573
2574 pe_session = pe_find_session_by_session_id(
2575 mac_ctx, disassoc_req->sessionId);
2576 if (pe_session == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002577 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 disassoc_cnf.resultCode =
2579 eSIR_SME_INVALID_PARAMETERS;
2580 goto end;
2581 }
2582
2583 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002584 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 &pe_session->dph.dphHashTable);
2586 if (sta_ds == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002587 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2589 goto end;
2590 }
2591 /* Receive path cleanup with dummy packet */
2592 if (eSIR_SUCCESS !=
2593 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2594 disassoc_cnf.resultCode =
2595 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002596 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 goto end;
2598 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002599 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002600 (disassoc_req->reasonCode !=
2601 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002602 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002603 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 /* Delete FT session if there exists one */
2606 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302609 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302611 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302613 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614 }
2615end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302616 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002617 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302618 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 disassoc_cnf.aid = disassoc_req->aid;
2620 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2621
2622 /* Update PE session ID */
2623 disassoc_cnf.sessionId = disassoc_req->sessionId;
2624
2625 if (disassoc_req != NULL) {
2626 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302627 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2629 }
2630
2631 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2632 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302633 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634}
2635
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302636QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002637 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302638 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002640 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302641
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002642 pe_debug("tx_success: %d", tx_success);
2643
2644 return lim_send_disassoc_cnf(max_ctx);
2645}
2646
2647static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2648 qdf_nbuf_t buf,
2649 uint32_t tx_success,
2650 void *params)
2651{
2652 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
2653 QDF_STATUS status_code;
2654 struct scheduler_msg msg = {0};
2655
2656 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302657
2658 if (buf)
2659 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002660 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2661 msg.bodyptr = params;
2662 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302663
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002664 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2665 if (status_code != QDF_STATUS_SUCCESS)
2666 pe_err("posting message: %X to LIM failed, reason: %d",
2667 msg.type, status_code);
2668 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669}
2670
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302671QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002672 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302673 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002675 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302676
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002677 pe_debug("tx_success: %d", tx_success);
2678
2679 return lim_send_deauth_cnf(mac_ctx);
2680}
2681
2682static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2683 qdf_nbuf_t buf,
2684 uint32_t tx_success,
2685 void *params)
2686{
2687 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2688 QDF_STATUS status_code;
2689 struct scheduler_msg msg = {0};
2690
2691 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302692
2693 if (buf)
2694 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002695 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2696 msg.bodyptr = params;
2697 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302698
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002699 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2700 if (status_code != QDF_STATUS_SUCCESS)
2701 pe_err("posting message: %X to LIM failed, reason: %d",
2702 msg.type, status_code);
2703 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704}
2705
2706/**
2707 * \brief This function is called to send Disassociate frame.
2708 *
2709 *
2710 * \param pMac Pointer to Global MAC structure
2711 *
2712 * \param nReason Indicates the reason that need to be sent in
2713 * Disassociation frame
2714 *
2715 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2716 * sent
2717 *
2718 *
2719 */
2720
2721void
2722lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
2723 uint16_t nReason,
2724 tSirMacAddr peer,
2725 tpPESession psessionEntry, bool waitForAck)
2726{
2727 tDot11fDisassociation frm;
2728 uint8_t *pFrame;
2729 tpSirMacMgmtHdr pMacHdr;
2730 uint32_t nBytes, nPayload, nStatus;
2731 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302732 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733 uint8_t txFlag = 0;
2734 uint32_t val = 0;
2735 uint8_t smeSessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 if (NULL == psessionEntry) {
2738 return;
2739 }
2740
2741 /*
2742 * In case when cac timer is running for this SAP session then
2743 * avoid sending disassoc out. It is violation of dfs specification.
2744 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302745 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2746 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302748 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 FL
2750 ("CAC timer is running, drop disassoc from going out"));
2751 return;
2752 }
2753 smeSessionId = psessionEntry->smeSessionId;
2754
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302755 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756
2757 frm.Reason.code = nReason;
2758
2759 nStatus = dot11f_get_packed_disassociation_size(pMac, &frm, &nPayload);
2760 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002761 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 nStatus);
2763 /* We'll fall back on the worst case scenario: */
2764 nPayload = sizeof(tDot11fDisassociation);
2765 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002766 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2767 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 }
2769
2770 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2771
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302772 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302774 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002775 pe_err("Failed to allocate %d bytes for a Disassociation",
2776 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777 return;
2778 }
2779 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302780 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781
2782 /* Next, we fill out the buffer descriptor: */
2783 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2784 SIR_MAC_MGMT_DISASSOC, peer, psessionEntry->selfMacAddr);
2785 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2786
2787 /* Prepare the BSSID */
2788 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2789
2790#ifdef WLAN_FEATURE_11W
2791 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2792#endif
2793
2794 nStatus = dot11f_pack_disassociation(pMac, &frm, pFrame +
2795 sizeof(tSirMacMgmtHdr),
2796 nPayload, &nPayload);
2797 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002798 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 nStatus);
2800 cds_packet_free((void *)pPacket);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002801 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002803 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
2804 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805 }
2806
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002807 pe_debug("***Sessionid %d Sending Disassociation frame with "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002809 MAC_ADDRESS_STR, psessionEntry->peSessionId, nReason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810 waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
2811 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2812
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002813 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302814 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2815 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002816 ) {
2817 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2818 }
2819
Sushant Kaushik46556062015-12-02 16:57:47 +05302820 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821
2822 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302823 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 psessionEntry->peSessionId,
2825 pMacHdr->fc.subType));
2826 /* Queue Disassociation frame in high priority WQ */
2827 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302828 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2830 TXRX_FRM_802_11_MGMT,
2831 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002832 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07002833 txFlag, smeSessionId, false, 0,
2834 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302835 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302836 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302837 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002838
2839 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2840
2841 if (tx_timer_change
2842 (&pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
2843 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002844 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 return;
2846 } else if (TX_SUCCESS !=
2847 tx_timer_activate(&pMac->lim.limTimers.
2848 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002849 pe_err("Unable to activate Disassoc ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 lim_deactivate_and_change_timer(pMac,
2851 eLIM_DISASSOC_ACK_TIMER);
2852 return;
2853 }
2854 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302855 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 psessionEntry->peSessionId,
2857 pMacHdr->fc.subType));
2858 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302859 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 TXRX_FRM_802_11_MGMT,
2861 ANI_TXDIR_TODS,
2862 7,
2863 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07002864 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302865 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302866 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302867 psessionEntry->peSessionId, qdf_status));
2868 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002869 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302870 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 /* Pkt will be freed up by the callback */
2872 }
2873 }
2874} /* End lim_send_disassoc_mgmt_frame. */
2875
2876/**
2877 * \brief This function is called to send a Deauthenticate frame
2878 *
2879 *
2880 * \param pMac Pointer to global MAC structure
2881 *
2882 * \param nReason Indicates the reason that need to be sent in the
2883 * Deauthenticate frame
2884 *
2885 * \param peeer address of the STA to which the frame is to be sent
2886 *
2887 *
2888 */
2889
2890void
2891lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
2892 uint16_t nReason,
2893 tSirMacAddr peer,
2894 tpPESession psessionEntry, bool waitForAck)
2895{
2896 tDot11fDeAuth frm;
2897 uint8_t *pFrame;
2898 tpSirMacMgmtHdr pMacHdr;
2899 uint32_t nBytes, nPayload, nStatus;
2900 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302901 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 uint8_t txFlag = 0;
2903 uint32_t val = 0;
2904#ifdef FEATURE_WLAN_TDLS
2905 uint16_t aid;
2906 tpDphHashNode pStaDs;
2907#endif
2908 uint8_t smeSessionId = 0;
2909
2910 if (NULL == psessionEntry) {
2911 return;
2912 }
2913
2914 /*
2915 * In case when cac timer is running for this SAP session then
2916 * avoid deauth frame out. It is violation of dfs specification.
2917 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302918 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2919 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302921 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 FL
2923 ("CAC timer is running, drop the deauth from going out"));
2924 return;
2925 }
2926 smeSessionId = psessionEntry->smeSessionId;
2927
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302928 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929
2930 frm.Reason.code = nReason;
2931
2932 nStatus = dot11f_get_packed_de_auth_size(pMac, &frm, &nPayload);
2933 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002934 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 nStatus);
2936 /* We'll fall back on the worst case scenario: */
2937 nPayload = sizeof(tDot11fDeAuth);
2938 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002939 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
2940 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941 }
2942
2943 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2944
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302945 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302947 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002948 pe_err("Failed to allocate %d bytes for a De-Authentication",
2949 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950 return;
2951 }
2952 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302953 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954
2955 /* Next, we fill out the buffer descriptor: */
2956 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2957 SIR_MAC_MGMT_DEAUTH, peer, psessionEntry->selfMacAddr);
2958 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2959
2960 /* Prepare the BSSID */
2961 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2962
2963#ifdef WLAN_FEATURE_11W
2964 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2965#endif
2966
2967 nStatus = dot11f_pack_de_auth(pMac, &frm, pFrame +
2968 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
2969 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002970 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971 nStatus);
2972 cds_packet_free((void *)pPacket);
2973 return;
2974 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002975 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
2976 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002978 pe_debug("***Sessionid %d Sending Deauth frame with "
2979 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
2980 " ,From " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 psessionEntry->peSessionId, nReason, waitForAck,
2982 MAC_ADDR_ARRAY(pMacHdr->da),
2983 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2984
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002985 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302986 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2987 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 ) {
2989 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2990 }
2991
Sushant Kaushik46556062015-12-02 16:57:47 +05302992 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993#ifdef FEATURE_WLAN_TDLS
2994 pStaDs =
2995 dph_lookup_hash_entry(pMac, peer, &aid,
2996 &psessionEntry->dph.dphHashTable);
2997#endif
2998
2999 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303000 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 psessionEntry->peSessionId,
3002 pMacHdr->fc.subType));
3003 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303004 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
3006 TXRX_FRM_802_11_MGMT,
3007 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003008 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003009 txFlag, smeSessionId, false, 0,
3010 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303011 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303012 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303013 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303015 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003016 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303017 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018
3019 /* Call lim_process_deauth_ack_timeout which will send
3020 * DeauthCnf for this frame
3021 */
3022 lim_process_deauth_ack_timeout(pMac);
3023 return;
3024 }
3025
3026 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3027
3028 if (tx_timer_change
3029 (&pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3030 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003031 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 return;
3033 } else if (TX_SUCCESS !=
3034 tx_timer_activate(&pMac->lim.limTimers.
3035 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003036 pe_err("Unable to activate Deauth ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 lim_deactivate_and_change_timer(pMac,
3038 eLIM_DEAUTH_ACK_TIMER);
3039 return;
3040 }
3041 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303042 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 psessionEntry->peSessionId,
3044 pMacHdr->fc.subType));
3045#ifdef FEATURE_WLAN_TDLS
3046 if ((NULL != pStaDs)
3047 && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
3048 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303049 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3051 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3052 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003053 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 } else {
3055#endif
3056 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303057 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3059 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3060 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003061 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062#ifdef FEATURE_WLAN_TDLS
3063 }
3064#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303065 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303066 psessionEntry->peSessionId, qdf_status));
3067 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003068 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303069 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070 /* Pkt will be freed up by the callback */
3071 }
3072 }
3073
3074} /* End lim_send_deauth_mgmt_frame. */
3075
3076#ifdef ANI_SUPPORT_11H
3077/**
3078 * \brief Send a Measurement Report Action frame
3079 *
3080 *
3081 * \param pMac Pointer to the global MAC structure
3082 *
3083 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3084 *
3085 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3086 *
3087 *
3088 */
3089
3090tSirRetStatus
3091lim_send_meas_report_frame(tpAniSirGlobal pMac,
3092 tpSirMacMeasReqActionFrame pMeasReqFrame,
3093 tSirMacAddr peer, tpPESession psessionEntry)
3094{
3095 tDot11fMeasurementReport frm;
3096 uint8_t *pFrame;
3097 tSirRetStatus nSirStatus;
3098 tpSirMacMgmtHdr pMacHdr;
3099 uint32_t nBytes, nPayload, nStatus;
3100 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303101 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303103 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104
3105 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3106 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3107 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3108
3109 switch (pMeasReqFrame->measReqIE.measType) {
3110 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3111 nSirStatus =
3112 populate_dot11f_measurement_report0(pMac, pMeasReqFrame,
3113 &frm.MeasurementReport);
3114 break;
3115 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3116 nSirStatus =
3117 populate_dot11f_measurement_report1(pMac, pMeasReqFrame,
3118 &frm.MeasurementReport);
3119 break;
3120 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3121 nSirStatus =
3122 populate_dot11f_measurement_report2(pMac, pMeasReqFrame,
3123 &frm.MeasurementReport);
3124 break;
3125 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003126 pe_err("Unknown measurement type %d in limSen"
3127 "dMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 pMeasReqFrame->measReqIE.measType);
3129 return eSIR_FAILURE;
3130 }
3131
3132 if (eSIR_SUCCESS != nSirStatus)
3133 return eSIR_FAILURE;
3134
3135 nStatus = dot11f_get_packed_measurement_report_size(pMac, &frm, &nPayload);
3136 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003137 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138 nStatus);
3139 /* We'll fall back on the worst case scenario: */
3140 nPayload = sizeof(tDot11fMeasurementReport);
3141 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003142 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3143 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 }
3145
3146 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3147
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303148 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3150 (uint16_t) nBytes, (void **)&pFrame,
3151 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303152 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003153 pe_err("Failed to allocate %d bytes for a "
3154 "De-Authentication", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 return eSIR_FAILURE;
3156 }
3157 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303158 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159
3160 /* Next, we fill out the buffer descriptor: */
3161 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3162 SIR_MAC_MGMT_ACTION, peer);
3163 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3164
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303165 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166
3167#ifdef WLAN_FEATURE_11W
3168 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3169#endif
3170
3171 nStatus = dot11f_pack_measurement_report(pMac, &frm, pFrame +
3172 sizeof(tSirMacMgmtHdr),
3173 nPayload, &nPayload);
3174 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003175 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 nStatus);
3177 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3178 (void *)pFrame, (void *)pPacket);
3179 return eSIR_FAILURE; /* allocated! */
3180 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003181 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3182 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183 }
3184
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303185 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 ((psessionEntry) ? psessionEntry->
3187 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303188 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3190 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003191 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303192 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303193 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303195 qdf_status));
3196 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003197 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303198 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 /* Pkt will be freed up by the callback */
3200 return eSIR_FAILURE; /* just allocated... */
3201 }
3202
3203 return eSIR_SUCCESS;
3204
3205} /* End lim_send_meas_report_frame. */
3206
3207/**
3208 * \brief Send a TPC Request Action frame
3209 *
3210 *
3211 * \param pMac Pointer to the global MAC datastructure
3212 *
3213 * \param peer MAC address to which the frame should be sent
3214 *
3215 *
3216 */
3217
3218void
3219lim_send_tpc_request_frame(tpAniSirGlobal pMac,
3220 tSirMacAddr peer, tpPESession psessionEntry)
3221{
3222 tDot11fTPCRequest frm;
3223 uint8_t *pFrame;
3224 tpSirMacMgmtHdr pMacHdr;
3225 uint32_t nBytes, nPayload, nStatus;
3226 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303227 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303229 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230
3231 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3232 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
3233 frm.DialogToken.token = 1;
3234 frm.TPCRequest.present = 1;
3235
3236 nStatus = dot11f_get_packed_tpc_request_size(pMac, &frm, &nPayload);
3237 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003238 pe_err("Failed to calculate the packed size for a TPC Request (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 /* We'll fall back on the worst case scenario: */
3240 nPayload = sizeof(tDot11fTPCRequest);
3241 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003242 pe_warn("There were warnings while calculating the packed size for a TPC Request (0x%08x)",
3243 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 }
3245
3246 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3247
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303248 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3250 (uint16_t) nBytes, (void **)&pFrame,
3251 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303252 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003253 pe_err("Failed to allocate %d bytes for a TPC"
3254 " Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 return;
3256 }
3257 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303258 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259
3260 /* Next, we fill out the buffer descriptor: */
3261 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3262 SIR_MAC_MGMT_ACTION, peer);
3263 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3264
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303265 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266
3267#ifdef WLAN_FEATURE_11W
3268 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3269#endif
3270
3271 nStatus = dot11f_pack_tpc_request(pMac, &frm, pFrame +
3272 sizeof(tSirMacMgmtHdr),
3273 nPayload, &nPayload);
3274 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003275 pe_err("Failed to pack a TPC Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276 nStatus);
3277 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3278 (void *)pFrame, (void *)pPacket);
3279 return; /* allocated! */
3280 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003281 pe_warn("There were warnings while packing a TPC Request (0x%08x)",
3282 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 }
3284
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303285 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 ((psessionEntry) ? psessionEntry->
3287 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303288 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3290 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003291 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303292 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303293 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303295 qdf_status));
3296 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003297 pe_err("Failed to send a TPC Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303298 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 /* Pkt will be freed up by the callback */
3300 }
3301
3302} /* End lim_send_tpc_request_frame. */
3303
3304/**
3305 * \brief Send a TPC Report Action frame
3306 *
3307 *
3308 * \param pMac Pointer to the global MAC datastructure
3309 *
3310 * \param pTpcReqFrame Pointer to the received TPC Request
3311 *
3312 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3313 *
3314 *
3315 */
3316
3317tSirRetStatus
3318lim_send_tpc_report_frame(tpAniSirGlobal pMac,
3319 tpSirMacTpcReqActionFrame pTpcReqFrame,
3320 tSirMacAddr peer, tpPESession psessionEntry)
3321{
3322 tDot11fTPCReport frm;
3323 uint8_t *pFrame;
3324 tpSirMacMgmtHdr pMacHdr;
3325 uint32_t nBytes, nPayload, nStatus;
3326 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303327 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303329 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330
3331 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3332 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3333 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3334
3335 frm.TPCReport.tx_power = 0;
3336 frm.TPCReport.link_margin = 0;
3337 frm.TPCReport.present = 1;
3338
3339 nStatus = dot11f_get_packed_tpc_report_size(pMac, &frm, &nPayload);
3340 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003341 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 /* We'll fall back on the worst case scenario: */
3343 nPayload = sizeof(tDot11fTPCReport);
3344 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003345 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3346 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 }
3348
3349 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3350
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303351 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3353 (uint16_t) nBytes, (void **)&pFrame,
3354 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303355 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003356 pe_err("Failed to allocate %d bytes for a TPC"
3357 " Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 return eSIR_FAILURE;
3359 }
3360 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303361 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362
3363 /* Next, we fill out the buffer descriptor: */
3364 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3365 SIR_MAC_MGMT_ACTION, peer);
3366
3367 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3368
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303369 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370
3371#ifdef WLAN_FEATURE_11W
3372 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3373#endif
3374
3375 nStatus = dot11f_pack_tpc_report(pMac, &frm, pFrame +
3376 sizeof(tSirMacMgmtHdr),
3377 nPayload, &nPayload);
3378 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003379 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 nStatus);
3381 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3382 (void *)pFrame, (void *)pPacket);
3383 return eSIR_FAILURE; /* allocated! */
3384 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003385 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3386 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303388 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 ((psessionEntry) ? psessionEntry->
3390 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303391 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3393 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003394 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303395 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003396 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3397 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
3398 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303399 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003400 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303401 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 /* Pkt will be freed up by the callback */
3403 return eSIR_FAILURE; /* just allocated... */
3404 }
3405
3406 return eSIR_SUCCESS;
3407
3408} /* End lim_send_tpc_report_frame. */
3409#endif /* ANI_SUPPORT_11H */
3410
3411/**
3412 * \brief Send a Channel Switch Announcement
3413 *
3414 *
3415 * \param pMac Pointer to the global MAC datastructure
3416 *
3417 * \param peer MAC address to which this frame will be sent
3418 *
3419 * \param nMode
3420 *
3421 * \param nNewChannel
3422 *
3423 * \param nCount
3424 *
3425 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3426 *
3427 *
3428 */
3429
3430tSirRetStatus
3431lim_send_channel_switch_mgmt_frame(tpAniSirGlobal pMac,
3432 tSirMacAddr peer,
3433 uint8_t nMode,
3434 uint8_t nNewChannel,
3435 uint8_t nCount, tpPESession psessionEntry)
3436{
3437 tDot11fChannelSwitch frm;
3438 uint8_t *pFrame;
3439 tpSirMacMgmtHdr pMacHdr;
3440 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3441 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303442 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 uint8_t txFlag = 0;
3444
3445 uint8_t smeSessionId = 0;
3446
3447 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003448 pe_err("Session entry is NULL!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449 return eSIR_FAILURE;
3450 }
3451 smeSessionId = psessionEntry->smeSessionId;
3452
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303453 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454
3455 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3456 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3457 frm.ChanSwitchAnn.switchMode = nMode;
3458 frm.ChanSwitchAnn.newChannel = nNewChannel;
3459 frm.ChanSwitchAnn.switchCount = nCount;
3460 frm.ChanSwitchAnn.present = 1;
3461
3462 nStatus = dot11f_get_packed_channel_switch_size(pMac, &frm, &nPayload);
3463 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003464 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 nStatus);
3466 /* We'll fall back on the worst case scenario: */
3467 nPayload = sizeof(tDot11fChannelSwitch);
3468 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003469 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3470 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 }
3472
3473 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3474
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303475 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3477 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303478 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003479 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 return eSIR_FAILURE;
3481 }
3482 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303483 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484
3485 /* Next, we fill out the buffer descriptor: */
3486 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3487 SIR_MAC_MGMT_ACTION, peer,
3488 psessionEntry->selfMacAddr);
3489 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303490 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3492
3493#ifdef WLAN_FEATURE_11W
3494 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3495#endif
3496
3497 nStatus = dot11f_pack_channel_switch(pMac, &frm, pFrame +
3498 sizeof(tSirMacMgmtHdr),
3499 nPayload, &nPayload);
3500 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003501 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502 nStatus);
3503 cds_packet_free((void *)pPacket);
3504 return eSIR_FAILURE; /* allocated! */
3505 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003506 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3507 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 }
3509
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003510 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303511 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3512 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 ) {
3514 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3515 }
3516
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303517 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303519 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 TXRX_FRM_802_11_MGMT,
3521 ANI_TXDIR_TODS,
3522 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003523 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303524 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303525 psessionEntry->peSessionId, qdf_status));
3526 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003527 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303528 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 /* Pkt will be freed up by the callback */
3530 return eSIR_FAILURE;
3531 }
3532
3533 return eSIR_SUCCESS;
3534
3535} /* End lim_send_channel_switch_mgmt_frame. */
3536
Abhishek Singh518323d2015-10-19 17:42:01 +05303537/**
3538 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3539 * action frame over the air .
3540 * @mac_ctx: pointer to global mac structure
3541 * @peer: Destination mac.
3542 * @mode: channel switch mode
3543 * @new_op_class: new op class
3544 * @new_channel: new channel to switch
3545 * @count: channel switch count
3546 *
3547 * This function is called to send ECSA frame.
3548 *
3549 * Return: success if frame is sent else return failure
3550 */
3551
3552tSirRetStatus
3553lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
3554 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
3555 uint8_t new_channel, uint8_t count, tpPESession session_entry)
3556{
3557 tDot11fext_channel_switch_action_frame frm;
3558 uint8_t *frame;
3559 tpSirMacMgmtHdr mac_hdr;
3560 uint32_t num_bytes, n_payload, status;
3561 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303562 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303563 uint8_t txFlag = 0;
3564 uint8_t sme_session_id = 0;
3565
3566 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003567 pe_err("Session entry is NULL!!!");
Abhishek Singh518323d2015-10-19 17:42:01 +05303568 return eSIR_FAILURE;
3569 }
3570
3571 sme_session_id = session_entry->smeSessionId;
3572
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303573 qdf_mem_set(&frm, sizeof(frm), 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303574
3575 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3576 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3577
3578 frm.ext_chan_switch_ann_action.switch_mode = mode;
3579 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3580 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3581 frm.ext_chan_switch_ann_action.switch_count = count;
3582
3583
3584 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3585 &frm, &n_payload);
3586 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003587 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303588 status);
3589 /* We'll fall back on the worst case scenario*/
3590 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3591 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003592 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303593 status);
3594 }
3595
3596 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3597
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303598 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303599 (void **) &frame, (void **) &packet);
3600
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303601 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003602 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303603 num_bytes);
3604 return eSIR_FAILURE;
3605 }
3606
3607 /* Paranoia*/
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303608 qdf_mem_set(frame, num_bytes, 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303609
3610 /* Next, we fill out the buffer descriptor */
3611 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3612 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3613 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303614 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303615 (uint8_t *) session_entry->bssId,
3616 sizeof(tSirMacAddr));
3617
3618 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3619 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3620 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003621 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303622 cds_packet_free((void *)packet);
3623 return eSIR_FAILURE;
3624 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003625 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303626 status);
3627 }
3628
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003629 if ((BAND_5G ==
Abhishek Singh518323d2015-10-19 17:42:01 +05303630 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303631 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3632 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303633 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3634 }
3635
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003636 pe_debug("Send Ext channel Switch to :"MAC_ADDRESS_STR" with swcount %d, swmode %d , newchannel %d newops %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05303637 MAC_ADDR_ARRAY(mac_hdr->da),
3638 frm.ext_chan_switch_ann_action.switch_count,
3639 frm.ext_chan_switch_ann_action.switch_mode,
3640 frm.ext_chan_switch_ann_action.new_channel,
3641 frm.ext_chan_switch_ann_action.op_class);
3642
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303643 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303644 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303645 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303646 TXRX_FRM_802_11_MGMT,
3647 ANI_TXDIR_TODS,
3648 7,
3649 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003650 txFlag, sme_session_id, 0,
3651 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303652 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303653 session_entry->peSessionId, qdf_status));
3654 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003655 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303656 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303657 /* Pkt will be freed up by the callback */
3658 return eSIR_FAILURE;
3659 }
3660 return eSIR_SUCCESS;
3661} /* End lim_send_extended_chan_switch_action_frame */
3662
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303663
3664/**
3665 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3666 * sent over the air
3667 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303668 * @context: pointer to global mac
3669 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303670 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303671 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303672 *
3673 * Return: This returns QDF_STATUS
3674 */
3675
3676static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303677 void *context,
3678 qdf_nbuf_t buf,
3679 uint32_t tx_complete,
3680 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303681{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003682 pe_debug("tx_complete: %d", tx_complete);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303683 return QDF_STATUS_SUCCESS;
3684}
3685
3686/**
3687 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3688 * p2p oper chan change confirm action frame
3689 * @mac_ctx: pointer to global mac structure
3690 * @peer: Destination mac.
3691 * @session_entry: session entry
3692 *
3693 * This function is called to send p2p oper chan change confirm action frame.
3694 *
3695 * Return: success if frame is sent else return failure
3696 */
3697
3698tSirRetStatus
3699lim_p2p_oper_chan_change_confirm_action_frame(tpAniSirGlobal mac_ctx,
3700 tSirMacAddr peer, tpPESession session_entry)
3701{
3702 tDot11fp2p_oper_chan_change_confirm frm;
3703 uint8_t *frame;
3704 tpSirMacMgmtHdr mac_hdr;
3705 uint32_t num_bytes, n_payload, status;
3706 void *packet;
3707 QDF_STATUS qdf_status;
3708 uint8_t tx_flag = 0;
3709 uint8_t sme_session_id = 0;
3710
3711 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003712 pe_err("Session entry is NULL!!!");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303713 return eSIR_FAILURE;
3714 }
3715
3716 sme_session_id = session_entry->smeSessionId;
3717
3718 qdf_mem_set(&frm, sizeof(frm), 0);
3719
3720 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3721
3722 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3723 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3724 frm.p2p_action_subtype.subtype = 0x04;
3725 frm.DialogToken.token = 0x0;
3726
3727 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003728 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303729 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3730 }
3731
3732 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003733 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303734 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3735 populate_dot11f_operating_mode(mac_ctx,
3736 &frm.OperatingMode, session_entry);
3737 }
3738
3739 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3740 &frm, &n_payload);
3741 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003742 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303743 /* We'll fall back on the worst case scenario*/
3744 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3745 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003746 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3747 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303748 }
3749
3750 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3751
3752 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3753 (void **) &frame, (void **) &packet);
3754
3755 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003756 pe_err("Failed to allocate %d bytes", num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303757 return eSIR_FAILURE;
3758 }
3759
3760 qdf_mem_set(frame, num_bytes, 0);
3761
3762 /* Next, fill out the buffer descriptor */
3763 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3764 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3765 mac_hdr = (tpSirMacMgmtHdr) frame;
3766 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3767 (uint8_t *) session_entry->bssId,
3768 sizeof(tSirMacAddr));
3769
3770 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3771 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3772 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003773 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303774 cds_packet_free((void *)packet);
3775 return eSIR_FAILURE;
3776 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003777 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303778 status);
3779 }
3780
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003781 if ((BAND_5G ==
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303782 lim_get_rf_band(session_entry->currentOperChannel)) ||
3783 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3784 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
3785 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3786 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003787 pe_debug("Send frame on channel %d to mac "
3788 MAC_ADDRESS_STR, session_entry->currentOperChannel,
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303789 MAC_ADDR_ARRAY(peer));
3790
3791 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3792 session_entry->peSessionId, mac_hdr->fc.subType));
3793
3794 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3795 (uint16_t)num_bytes,
3796 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3797 7, lim_tx_complete, frame,
3798 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07003799 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303800
3801 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3802 session_entry->peSessionId, qdf_status));
3803 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003804 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303805 /* Pkt will be freed up by the callback */
3806 return eSIR_FAILURE;
3807 }
3808 return eSIR_SUCCESS;
3809}
3810
3811
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812tSirRetStatus
3813lim_send_vht_opmode_notification_frame(tpAniSirGlobal pMac,
3814 tSirMacAddr peer,
3815 uint8_t nMode, tpPESession psessionEntry)
3816{
3817 tDot11fOperatingMode frm;
3818 uint8_t *pFrame;
3819 tpSirMacMgmtHdr pMacHdr;
3820 uint32_t nBytes, nPayload = 0, nStatus; /* , nCfg; */
3821 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303822 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823 uint8_t txFlag = 0;
3824
3825 uint8_t smeSessionId = 0;
3826
3827 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003828 pe_err("Session entry is NULL!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003829 return eSIR_FAILURE;
3830 }
3831 smeSessionId = psessionEntry->smeSessionId;
3832
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303833 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003834
3835 frm.Category.category = SIR_MAC_ACTION_VHT;
3836 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
3837 frm.OperatingMode.chanWidth = nMode;
3838 frm.OperatingMode.rxNSS = 0;
3839 frm.OperatingMode.rxNSSType = 0;
3840
3841 nStatus = dot11f_get_packed_operating_mode_size(pMac, &frm, &nPayload);
3842 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003843 pe_err("Failed to calculate the packed size for a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003844 nStatus);
3845 /* We'll fall back on the worst case scenario: */
3846 nPayload = sizeof(tDot11fOperatingMode);
3847 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003848 pe_warn("There were warnings while calculating the packed size for a Operating Mode (0x%08x)",
3849 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850 }
3851
3852 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3853
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303854 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3856 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303857 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003858 pe_err("Failed to allocate %d bytes for a Operating Mode Report",
3859 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003860 return eSIR_FAILURE;
3861 }
3862 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303863 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003864
3865 /* Next, we fill out the buffer descriptor: */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303866 if (psessionEntry->pePersona == QDF_SAP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3868 SIR_MAC_MGMT_ACTION, peer,
3869 psessionEntry->selfMacAddr);
3870 else
3871 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3872 SIR_MAC_MGMT_ACTION, psessionEntry->bssId,
3873 psessionEntry->selfMacAddr);
3874 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303875 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3877 nStatus = dot11f_pack_operating_mode(pMac, &frm, pFrame +
3878 sizeof(tSirMacMgmtHdr),
3879 nPayload, &nPayload);
3880 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003881 pe_err("Failed to pack a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882 nStatus);
3883 cds_packet_free((void *)pPacket);
3884 return eSIR_FAILURE; /* allocated! */
3885 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003886 pe_warn("There were warnings while packing a Operating Mode (0x%08x)",
3887 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003889 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303890 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3891 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 ) {
3893 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3894 }
3895
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303896 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303898 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899 TXRX_FRM_802_11_MGMT,
3900 ANI_TXDIR_TODS,
3901 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003902 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303903 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303904 psessionEntry->peSessionId, qdf_status));
3905 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003906 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303907 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 /* Pkt will be freed up by the callback */
3909 return eSIR_FAILURE;
3910 }
3911
3912 return eSIR_SUCCESS;
3913}
3914
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915/**
3916 * \brief Send a Neighbor Report Request Action frame
3917 *
3918 *
3919 * \param pMac Pointer to the global MAC structure
3920 *
3921 * \param pNeighborReq Address of a tSirMacNeighborReportReq
3922 *
3923 * \param peer mac address of peer station.
3924 *
3925 * \param psessionEntry address of session entry.
3926 *
3927 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3928 *
3929 *
3930 */
3931
3932tSirRetStatus
3933lim_send_neighbor_report_request_frame(tpAniSirGlobal pMac,
3934 tpSirMacNeighborReportReq pNeighborReq,
3935 tSirMacAddr peer, tpPESession psessionEntry)
3936{
3937 tSirRetStatus statusCode = eSIR_SUCCESS;
3938 tDot11fNeighborReportRequest frm;
3939 uint8_t *pFrame;
3940 tpSirMacMgmtHdr pMacHdr;
3941 uint32_t nBytes, nPayload, nStatus;
3942 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303943 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 uint8_t txFlag = 0;
3945 uint8_t smeSessionId = 0;
3946
3947 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003948 pe_err("(psession == NULL) in Request to send Neighbor Report request action frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 return eSIR_FAILURE;
3950 }
3951 smeSessionId = psessionEntry->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303952 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953
3954 frm.Category.category = SIR_MAC_ACTION_RRM;
3955 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
3956 frm.DialogToken.token = pNeighborReq->dialogToken;
3957
3958 if (pNeighborReq->ssid_present) {
3959 populate_dot11f_ssid(pMac, &pNeighborReq->ssid, &frm.SSID);
3960 }
3961
3962 nStatus =
3963 dot11f_get_packed_neighbor_report_request_size(pMac, &frm, &nPayload);
3964 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003965 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003966 nStatus);
3967 /* We'll fall back on the worst case scenario: */
3968 nPayload = sizeof(tDot11fNeighborReportRequest);
3969 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003970 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
3971 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003972 }
3973
3974 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3975
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303976 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3978 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303979 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003980 pe_err("Failed to allocate %d bytes for a Neighbor "
3981 "Report Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982 return eSIR_FAILURE;
3983 }
3984 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303985 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986
3987 /* Copy necessary info to BD */
3988 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3989 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
3990
3991 /* Update A3 with the BSSID */
3992 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3993
3994 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
3995
3996#ifdef WLAN_FEATURE_11W
3997 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3998#endif
3999
4000 /* Now, we're ready to "pack" the frames */
4001 nStatus = dot11f_pack_neighbor_report_request(pMac,
4002 &frm,
4003 pFrame +
4004 sizeof(tSirMacMgmtHdr),
4005 nPayload, &nPayload);
4006
4007 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004008 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009 nStatus);
4010
4011 /* FIXME - Need to convert to tSirRetStatus */
4012 statusCode = eSIR_FAILURE;
4013 goto returnAfterError;
4014 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004015 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4016 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 }
4018
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004019 pe_debug("Sending a Neighbor Report Request to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +05304020 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004022 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304023 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4024 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 ) {
4026 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4027 }
4028
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304029 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304031 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 pPacket,
4033 (uint16_t) nBytes,
4034 TXRX_FRM_802_11_MGMT,
4035 ANI_TXDIR_TODS,
4036 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004037 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304038 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304039 psessionEntry->peSessionId, qdf_status));
4040 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004041 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 statusCode = eSIR_FAILURE;
4043 /* Pkt will be freed up by the callback */
4044 return statusCode;
4045 } else
4046 return eSIR_SUCCESS;
4047
4048returnAfterError:
4049 cds_packet_free((void *)pPacket);
4050
4051 return statusCode;
4052} /* End lim_send_neighbor_report_request_frame. */
4053
4054/**
4055 * \brief Send a Link Report Action frame
4056 *
4057 *
4058 * \param pMac Pointer to the global MAC structure
4059 *
4060 * \param pLinkReport Address of a tSirMacLinkReport
4061 *
4062 * \param peer mac address of peer station.
4063 *
4064 * \param psessionEntry address of session entry.
4065 *
4066 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4067 *
4068 *
4069 */
4070
4071tSirRetStatus
4072lim_send_link_report_action_frame(tpAniSirGlobal pMac,
4073 tpSirMacLinkReport pLinkReport,
4074 tSirMacAddr peer, tpPESession psessionEntry)
4075{
4076 tSirRetStatus statusCode = eSIR_SUCCESS;
4077 tDot11fLinkMeasurementReport frm;
4078 uint8_t *pFrame;
4079 tpSirMacMgmtHdr pMacHdr;
4080 uint32_t nBytes, nPayload, nStatus;
4081 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304082 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083 uint8_t txFlag = 0;
4084 uint8_t smeSessionId = 0;
4085
4086 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004087 pe_err("(psession == NULL) in Request to send Link Report action frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 return eSIR_FAILURE;
4089 }
4090
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304091 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092
4093 frm.Category.category = SIR_MAC_ACTION_RRM;
4094 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
4095 frm.DialogToken.token = pLinkReport->dialogToken;
4096
4097 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4098 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4099 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4100 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4101 /* such case this way than changing the frame parser. */
4102 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
4103 frm.TPCEleLen.TPCLen = 2;
4104 frm.TxPower.txPower = pLinkReport->txPower;
4105 frm.LinkMargin.linkMargin = 0;
4106
4107 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4108 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4109 frm.RCPI.rcpi = pLinkReport->rcpi;
4110 frm.RSNI.rsni = pLinkReport->rsni;
4111
4112 nStatus =
4113 dot11f_get_packed_link_measurement_report_size(pMac, &frm, &nPayload);
4114 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004115 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 /* We'll fall back on the worst case scenario: */
4117 nPayload = sizeof(tDot11fLinkMeasurementReport);
4118 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004119 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4120 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 }
4122
4123 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4124
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304125 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4127 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304128 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004129 pe_err("Failed to allocate %d bytes for a Link "
4130 "Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 return eSIR_FAILURE;
4132 }
4133 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304134 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135
4136 /* Copy necessary info to BD */
4137 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4138 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4139
4140 /* Update A3 with the BSSID */
4141 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4142
4143 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4144
4145#ifdef WLAN_FEATURE_11W
4146 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4147#endif
4148
4149 /* Now, we're ready to "pack" the frames */
4150 nStatus = dot11f_pack_link_measurement_report(pMac,
4151 &frm,
4152 pFrame +
4153 sizeof(tSirMacMgmtHdr),
4154 nPayload, &nPayload);
4155
4156 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004157 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158
4159 /* FIXME - Need to convert to tSirRetStatus */
4160 statusCode = eSIR_FAILURE;
4161 goto returnAfterError;
4162 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004163 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 nStatus);
4165 }
4166
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004167 pe_warn("Sending a Link Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 lim_print_mac_addr(pMac, peer, LOGW);
4169
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004170 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304171 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4172 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4174 }
4175
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304176 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004177 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304178 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179 pPacket,
4180 (uint16_t) nBytes,
4181 TXRX_FRM_802_11_MGMT,
4182 ANI_TXDIR_TODS,
4183 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004184 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304185 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304186 psessionEntry->peSessionId, qdf_status));
4187 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004188 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 statusCode = eSIR_FAILURE;
4190 /* Pkt will be freed up by the callback */
4191 return statusCode;
4192 } else
4193 return eSIR_SUCCESS;
4194
4195returnAfterError:
4196 cds_packet_free((void *)pPacket);
4197
4198 return statusCode;
4199} /* End lim_send_link_report_action_frame. */
4200
4201/**
4202 * \brief Send a Beacon Report Action frame
4203 *
4204 *
4205 * \param pMac Pointer to the global MAC structure
4206 *
4207 * \param dialog_token dialog token to be used in the action frame.
4208 *
4209 * \param num_report number of reports in pRRMReport.
4210 *
4211 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
4212 *
4213 * \param peer mac address of peer station.
4214 *
4215 * \param psessionEntry address of session entry.
4216 *
4217 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4218 *
4219 *
4220 */
4221
4222tSirRetStatus
4223lim_send_radio_measure_report_action_frame(tpAniSirGlobal pMac,
4224 uint8_t dialog_token,
4225 uint8_t num_report,
4226 tpSirMacRadioMeasureReport pRRMReport,
4227 tSirMacAddr peer,
4228 tpPESession psessionEntry)
4229{
4230 tSirRetStatus statusCode = eSIR_SUCCESS;
4231 uint8_t *pFrame;
4232 tpSirMacMgmtHdr pMacHdr;
4233 uint32_t nBytes, nPayload, nStatus;
4234 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304235 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236 uint8_t i;
4237 uint8_t txFlag = 0;
4238 uint8_t smeSessionId = 0;
4239
4240 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304241 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004242 if (!frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004243 pe_err("Not enough memory to allocate tDot11fRadioMeasurementReport");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 return eSIR_MEM_ALLOC_FAILED;
4245 }
4246
4247 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004248 pe_err("(psession == NULL) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304249 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250 return eSIR_FAILURE;
4251 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004253 smeSessionId = psessionEntry->smeSessionId;
4254
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004255 pe_debug("dialog_token %d num_report %d",
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304256 dialog_token, num_report);
4257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 frm->Category.category = SIR_MAC_ACTION_RRM;
4259 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4260 frm->DialogToken.token = dialog_token;
4261
4262 frm->num_MeasurementReport =
4263 (num_report >
4264 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4265 num_report;
4266
4267 for (i = 0; i < frm->num_MeasurementReport; i++) {
4268 frm->MeasurementReport[i].type = pRRMReport[i].type;
4269 frm->MeasurementReport[i].token = pRRMReport[i].token;
4270 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4271 switch (pRRMReport[i].type) {
4272 case SIR_MAC_RRM_BEACON_TYPE:
4273 populate_dot11f_beacon_report(pMac,
4274 &frm->MeasurementReport[i],
4275 &pRRMReport[i].report.
4276 beaconReport);
4277 frm->MeasurementReport[i].incapable =
4278 pRRMReport[i].incapable;
4279 frm->MeasurementReport[i].refused =
4280 pRRMReport[i].refused;
4281 frm->MeasurementReport[i].present = 1;
4282 break;
4283 default:
4284 frm->MeasurementReport[i].incapable =
4285 pRRMReport[i].incapable;
4286 frm->MeasurementReport[i].refused =
4287 pRRMReport[i].refused;
4288 frm->MeasurementReport[i].present = 1;
4289 break;
4290 }
4291 }
4292
4293 nStatus =
4294 dot11f_get_packed_radio_measurement_report_size(pMac, frm, &nPayload);
4295 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004296 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004297 nStatus);
4298 /* We'll fall back on the worst case scenario: */
4299 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304300 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301 return eSIR_FAILURE;
4302 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004303 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4304 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 }
4306
4307 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4308
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304309 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4311 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304312 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004313 pe_err("Failed to allocate %d bytes for a Radio Measure "
4314 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304315 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316 return eSIR_FAILURE;
4317 }
4318 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304319 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320
4321 /* Copy necessary info to BD */
4322 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4323 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4324
4325 /* Update A3 with the BSSID */
4326 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4327
4328 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4329
4330#ifdef WLAN_FEATURE_11W
4331 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4332#endif
4333
4334 /* Now, we're ready to "pack" the frames */
4335 nStatus = dot11f_pack_radio_measurement_report(pMac,
4336 frm,
4337 pFrame +
4338 sizeof(tSirMacMgmtHdr),
4339 nPayload, &nPayload);
4340
4341 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004342 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343 nStatus);
4344
4345 /* FIXME - Need to convert to tSirRetStatus */
4346 statusCode = eSIR_FAILURE;
4347 goto returnAfterError;
4348 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004349 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4350 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004351 }
4352
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004353 pe_warn("Sending a Radio Measure Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354 lim_print_mac_addr(pMac, peer, LOGW);
4355
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004356 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304357 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4358 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359 ) {
4360 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4361 }
4362
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304363 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304365 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366 pPacket,
4367 (uint16_t) nBytes,
4368 TXRX_FRM_802_11_MGMT,
4369 ANI_TXDIR_TODS,
4370 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004371 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304372 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304373 psessionEntry->peSessionId, qdf_status));
4374 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004375 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376 statusCode = eSIR_FAILURE;
4377 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304378 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379 return statusCode;
4380 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304381 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004382 return eSIR_SUCCESS;
4383 }
4384
4385returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304386 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387 cds_packet_free((void *)pPacket);
4388 return statusCode;
4389}
4390
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391#ifdef WLAN_FEATURE_11W
4392/**
4393 * \brief Send SA query request action frame to peer
4394 *
4395 * \sa lim_send_sa_query_request_frame
4396 *
4397 *
4398 * \param pMac The global tpAniSirGlobal object
4399 *
4400 * \param transId Transaction identifier
4401 *
4402 * \param peer The Mac address of the station to which this action frame is addressed
4403 *
4404 * \param psessionEntry The PE session entry
4405 *
4406 * \return eSIR_SUCCESS if setup completes successfully
4407 * eSIR_FAILURE is some problem is encountered
4408 */
4409
4410tSirRetStatus lim_send_sa_query_request_frame(tpAniSirGlobal pMac, uint8_t *transId,
4411 tSirMacAddr peer,
4412 tpPESession psessionEntry)
4413{
4414
4415 tDot11fSaQueryReq frm; /* SA query request action frame */
4416 uint8_t *pFrame;
4417 tSirRetStatus nSirStatus;
4418 tpSirMacMgmtHdr pMacHdr;
4419 uint32_t nBytes, nPayload, nStatus;
4420 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304421 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 uint8_t txFlag = 0;
4423 uint8_t smeSessionId = 0;
4424
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304425 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4427 /* 11w action field is :
4428 action: 0 --> SA Query Request action frame
4429 action: 1 --> SA Query Response action frame */
4430 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4431 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304432 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433
4434 nStatus = dot11f_get_packed_sa_query_req_size(pMac, &frm, &nPayload);
4435 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004436 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 nStatus);
4438 /* We'll fall back on the worst case scenario: */
4439 nPayload = sizeof(tDot11fSaQueryReq);
4440 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004441 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4442 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443 }
4444
4445 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304446 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304448 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004449 pe_err("Failed to allocate %d bytes for a SA Query Request "
4450 "action frame", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 return eSIR_FAILURE;
4452 }
4453 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304454 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455
4456 /* Copy necessary info to BD */
4457 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4458 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4459
4460 /* Update A3 with the BSSID */
4461 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4462
4463 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4464
4465 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4466 /* in the FC */
4467 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4468
4469 /* Pack 11w SA Query Request frame */
4470 nStatus = dot11f_pack_sa_query_req(pMac,
4471 &frm,
4472 pFrame + sizeof(tSirMacMgmtHdr),
4473 nPayload, &nPayload);
4474
4475 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004476 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 nStatus);
4478 /* FIXME - Need to convert to tSirRetStatus */
4479 nSirStatus = eSIR_FAILURE;
4480 goto returnAfterError;
4481 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004482 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 nStatus);
4484 }
4485
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004486 pe_debug("Sending an SA Query Request to");
4487 lim_print_mac_addr(pMac, peer, LOGD);
4488 pe_debug("Sending an SA Query Request from ");
4489 lim_print_mac_addr(pMac, psessionEntry->selfMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004491 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304493 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4494 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495#endif
4496 ) {
4497 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4498 }
4499 smeSessionId = psessionEntry->smeSessionId;
4500
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304501 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 pPacket,
4503 (uint16_t) nBytes,
4504 TXRX_FRM_802_11_MGMT,
4505 ANI_TXDIR_TODS,
4506 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004507 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304508 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004509 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510 nSirStatus = eSIR_FAILURE;
4511 /* Pkt will be freed up by the callback */
4512 return nSirStatus;
4513 } else {
4514 return eSIR_SUCCESS;
4515 }
4516
4517returnAfterError:
4518 cds_packet_free((void *)pPacket);
4519 return nSirStatus;
4520} /* End lim_send_sa_query_request_frame */
4521
4522/**
4523 * \brief Send SA query response action frame to peer
4524 *
4525 * \sa lim_send_sa_query_response_frame
4526 *
4527 *
4528 * \param pMac The global tpAniSirGlobal object
4529 *
4530 * \param transId Transaction identifier received in SA query request action frame
4531 *
4532 * \param peer The Mac address of the AP to which this action frame is addressed
4533 *
4534 * \param psessionEntry The PE session entry
4535 *
4536 * \return eSIR_SUCCESS if setup completes successfully
4537 * eSIR_FAILURE is some problem is encountered
4538 */
4539
4540tSirRetStatus lim_send_sa_query_response_frame(tpAniSirGlobal pMac,
4541 uint8_t *transId, tSirMacAddr peer,
4542 tpPESession psessionEntry)
4543{
4544
4545 tDot11fSaQueryRsp frm; /* SA query reponse action frame */
4546 uint8_t *pFrame;
4547 tSirRetStatus nSirStatus;
4548 tpSirMacMgmtHdr pMacHdr;
4549 uint32_t nBytes, nPayload, nStatus;
4550 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304551 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004552 uint8_t txFlag = 0;
4553 uint8_t smeSessionId = 0;
4554
4555 smeSessionId = psessionEntry->smeSessionId;
4556
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304557 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4559 /*11w action field is :
4560 action: 0 --> SA query request action frame
4561 action: 1 --> SA query response action frame */
4562 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4563 /*11w SA query response transId is same as
4564 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304565 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566
4567 nStatus = dot11f_get_packed_sa_query_rsp_size(pMac, &frm, &nPayload);
4568 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004569 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570 nStatus);
4571 /* We'll fall back on the worst case scenario: */
4572 nPayload = sizeof(tDot11fSaQueryRsp);
4573 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004574 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4575 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 }
4577
4578 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304579 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304581 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004582 pe_err("Failed to allocate %d bytes for a SA query response"
4583 " action frame", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 return eSIR_FAILURE;
4585 }
4586 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304587 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588
4589 /* Copy necessary info to BD */
4590 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4591 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4592
4593 /* Update A3 with the BSSID */
4594 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4595
4596 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4597
4598 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4599 /* in the FC */
4600 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4601
4602 /* Pack 11w SA query response frame */
4603 nStatus = dot11f_pack_sa_query_rsp(pMac,
4604 &frm,
4605 pFrame + sizeof(tSirMacMgmtHdr),
4606 nPayload, &nPayload);
4607
4608 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004609 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610 nStatus);
4611 /* FIXME - Need to convert to tSirRetStatus */
4612 nSirStatus = eSIR_FAILURE;
4613 goto returnAfterError;
4614 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004615 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616 nStatus);
4617 }
4618
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004619 pe_debug("Sending a SA Query Response to");
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07004620 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004622 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304624 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4625 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626#endif
4627 ) {
4628 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4629 }
4630
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304631 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304633 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 pPacket,
4635 (uint16_t) nBytes,
4636 TXRX_FRM_802_11_MGMT,
4637 ANI_TXDIR_TODS,
4638 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004639 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304640 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304641 psessionEntry->peSessionId, qdf_status));
4642 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004643 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 nSirStatus = eSIR_FAILURE;
4645 /* Pkt will be freed up by the callback */
4646 return nSirStatus;
4647 } else {
4648 return eSIR_SUCCESS;
4649 }
4650
4651returnAfterError:
4652 cds_packet_free((void *)pPacket);
4653 return nSirStatus;
4654} /* End lim_send_sa_query_response_frame */
4655#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004656
4657/**
4658 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4659 * @mac_ctx: mac context
4660 * @peer_mac: Peer MAC address
4661 * @tid: TID for which addba response is being sent
4662 * @session: PE session entry
4663 *
4664 * This function is called when ADDBA request is successful. ADDBA response is
4665 * setup by calling addba_response_setup API and frame is then sent out OTA.
4666 *
4667 * Return: QDF_STATUS
4668 */
4669QDF_STATUS lim_send_addba_response_frame(tpAniSirGlobal mac_ctx,
4670 tSirMacAddr peer_mac, uint16_t tid, tpPESession session)
4671{
4672
4673 tDot11faddba_rsp frm;
4674 uint8_t *frame_ptr;
4675 tpSirMacMgmtHdr mgmt_hdr;
4676 uint32_t num_bytes, payload_size, status;
4677 void *pkt_ptr;
4678 QDF_STATUS qdf_status;
4679 uint8_t tx_flag = 0;
4680 uint8_t sme_sessionid = 0;
4681 uint16_t buff_size, status_code, batimeout;
4682 uint8_t peer_id, dialog_token;
4683 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4684 void *peer, *pdev;
4685
4686 sme_sessionid = session->smeSessionId;
4687
4688 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4689 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004690 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004691 return QDF_STATUS_E_FAILURE;
4692 }
4693
4694 peer = cdp_peer_find_by_addr(soc, pdev, peer_mac, &peer_id);
4695 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004696 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004697 return QDF_STATUS_E_FAILURE;
4698 }
4699
4700 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4701 &status_code, &buff_size, &batimeout);
4702
4703 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
4704 frm.Category.category = SIR_MAC_ACTION_BLKACK;
4705 frm.Action.action = SIR_MAC_ADDBA_RSP;
4706
4707 frm.DialogToken.token = dialog_token;
4708 frm.Status.status = status_code;
4709 frm.addba_param_set.tid = tid;
4710 frm.addba_param_set.buff_size = buff_size;
4711 frm.addba_param_set.amsdu_supp = SIR_MAC_BA_POLICY_IMMEDIATE;
4712 frm.addba_param_set.policy = SIR_MAC_BA_AMSDU_SUPPORTED;
4713 frm.ba_timeout.timeout = batimeout;
4714
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004715 pe_debug("Sending a ADDBA Response from %pM to %pM",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004716 session->selfMacAddr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004717 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004718 tid, frm.DialogToken.token, frm.Status.status,
4719 frm.addba_param_set.buff_size);
4720
4721 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4722 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004723 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004724 status);
4725 /* We'll fall back on the worst case scenario: */
4726 payload_size = sizeof(tDot11faddba_rsp);
4727 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004728 pe_warn("There were warnings while calculating the packed size for a ADDBA Response (0x%08x).", status);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004729 }
4730
4731 num_bytes = payload_size + sizeof(*mgmt_hdr);
4732 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4733 (void **)&pkt_ptr);
4734 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004735 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4736 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004737 return QDF_STATUS_E_FAILURE;
4738 }
4739 qdf_mem_set(frame_ptr, num_bytes, 0);
4740
4741 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
4742 SIR_MAC_MGMT_ACTION, peer_mac, session->selfMacAddr);
4743
4744 /* Update A3 with the BSSID */
4745 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4746 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4747
4748 /* ADDBA Response is a robust mgmt action frame,
4749 * set the "protect" (aka WEP) bit in the FC
4750 */
4751 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4752
4753 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4754 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4755 &payload_size);
4756
4757 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004758 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004759 status);
4760 qdf_status = QDF_STATUS_E_FAILURE;
4761 goto error_addba_rsp;
4762 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004763 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004764 status);
4765 }
4766
4767
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004768 if ((BAND_5G == lim_get_rf_band(session->currentOperChannel))
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004769#ifdef WLAN_FEATURE_P2P
4770 || (session->pePersona == QDF_P2P_CLIENT_MODE) ||
4771 (session->pePersona == QDF_P2P_GO_MODE)
4772#endif
4773 ) {
4774 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4775 }
4776
4777 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4778 session->peSessionId, mgmt_hdr->fc.subType));
4779 qdf_status = wma_tx_frame(mac_ctx, pkt_ptr, (uint16_t) num_bytes,
4780 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07004781 lim_tx_complete, frame_ptr, tx_flag, sme_sessionid, 0,
4782 RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004783 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4784 session->peSessionId, qdf_status));
4785 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004786 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004787 qdf_status);
4788 qdf_status = QDF_STATUS_E_FAILURE;
4789 /*
4790 * wma_tx_frame free memory in certain cases, free pkt_ptr
4791 * only if not freed already.
4792 */
4793 if (pkt_ptr)
4794 cds_packet_free((void *)pkt_ptr);
4795 return qdf_status;
4796 } else {
4797 return eSIR_SUCCESS;
4798 }
4799
4800error_addba_rsp:
4801 cds_packet_free((void *)pkt_ptr);
4802 return qdf_status;
4803}