blob: 0a51399f8c8a5e1b9337808dac909123cfeb4f44 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**
20 * \file lim_send_management_frames.c
21 *
22 * \brief Code for preparing and sending 802.11 Management frames
23 *
24 *
25 */
26
27#include "sir_api.h"
28#include "ani_global.h"
29#include "sir_mac_prot_def.h"
30#include "cfg_api.h"
31#include "utils_api.h"
32#include "lim_types.h"
33#include "lim_utils.h"
34#include "lim_security_utils.h"
35#include "lim_prop_exts_utils.h"
36#include "dot11f.h"
37#include "lim_sta_hash_api.h"
38#include "sch_api.h"
39#include "lim_send_messages.h"
40#include "lim_assoc_utils.h"
41#include "lim_ft.h"
42#ifdef WLAN_FEATURE_11W
43#include "wni_cfg.h"
44#endif
45
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053048#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053049#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "cds_utils.h"
51#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052#include "rrm_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053053#include "qdf_crypto.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080054
55#include "wma_types.h"
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -080056#include <cdp_txrx_cmn.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070057#include <cdp_txrx_peer_ops.h>
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053058#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070059#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61/**
62 *
63 * \brief This function is called to add the sequence number to the
64 * management frames
65 *
66 * \param pMac Pointer to Global MAC structure
67 *
68 * \param pMacHdr Pointer to MAC management header
69 *
70 * The pMacHdr argument points to the MAC management header. The
71 * sequence number stored in the pMac structure will be incremented
72 * and updated to the MAC management header. The start sequence
73 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
74 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
75 * number will roll over.
76 *
77 */
Jeff Johnson38112a32016-10-07 07:30:50 -070078static void lim_add_mgmt_seq_num(tpAniSirGlobal pMac, tpSirMacMgmtHdr pMacHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079{
80 if (pMac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
81 pMac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
82 }
83
84 pMac->mgmtSeqNum++;
85
86 pMacHdr->seqControl.seqNumLo = (pMac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
87 pMacHdr->seqControl.seqNumHi =
88 ((pMac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
89}
90
91/**
92 *
93 * \brief This function is called before sending a p2p action frame
94 * inorder to add sequence numbers to action packets
95 *
96 * \param pMac Pointer to Global MAC structure
97 *
98 * \param pBD Pointer to the frame buffer that needs to be populate
99 *
100 * The pMacHdr argument points to the MAC management header. The
101 * sequence number stored in the pMac structure will be incremented
102 * and updated to the MAC management header. The start sequence
103 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
104 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
105 * number will roll over.
106 *
107 */
108void lim_populate_p2p_mac_header(tpAniSirGlobal pMac, uint8_t *pBD)
109{
110 tpSirMacMgmtHdr pMacHdr;
111
112 /* / Prepare MAC management header */
113 pMacHdr = (tpSirMacMgmtHdr) (pBD);
114
115 /* Prepare sequence number */
116 lim_add_mgmt_seq_num(pMac, pMacHdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700117 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118 pMacHdr->seqControl.seqNumLo,
119 pMacHdr->seqControl.seqNumHi, pMac->mgmtSeqNum);
120}
121
122/**
123 * lim_populate_mac_header() - Fill in 802.11 header of frame
124 *
125 * @mac_ctx: Pointer to Global MAC structure
126 * @buf: Pointer to the frame buffer that needs to be populate
127 * @type: 802.11 Type of the frame
128 * @sub_type: 802.11 Subtype of the frame
129 * @peer_addr: dst address
130 * @self_mac_addr: local mac address
131 *
132 * This function is called by various LIM modules to prepare the
133 * 802.11 frame MAC header
134 *
135 * The buf argument points to the beginning of the frame buffer to
136 * which - a) The 802.11 MAC header is set b) Following this MAC header
137 * will be the MGMT frame payload The payload itself is populated by the
138 * caller API
139 *
140 * Return: None
141 */
142
143void lim_populate_mac_header(tpAniSirGlobal mac_ctx, uint8_t *buf,
144 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
145 tSirMacAddr self_mac_addr)
146{
147 tpSirMacMgmtHdr mac_hdr;
148
149 /* Prepare MAC management header */
150 mac_hdr = (tpSirMacMgmtHdr) (buf);
151
152 /* Prepare FC */
153 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
154 mac_hdr->fc.type = type;
155 mac_hdr->fc.subType = sub_type;
156
157 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530158 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
160
161 /* Prepare Address 2 */
162 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
163
164 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530165 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
167
168 /* Prepare sequence number */
169 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700170 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 mac_hdr->seqControl.seqNumLo,
172 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
173}
174
175/**
176 * lim_send_probe_req_mgmt_frame() - send probe request management frame
177 * @mac_ctx: Pointer to Global MAC structure
178 * @ssid: SSID to be sent in Probe Request frame
179 * @bssid: BSSID to be sent in Probe Request frame
180 * @channel: Channel # on which the Probe Request is going out
181 * @self_macaddr: self MAC address
182 * @dot11mode: self dotllmode
183 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
184 * frame
185 * @additional_ie: if additional_ielen is non zero, include this field in the
186 * Probe Request frame
187 *
188 * This function is called by various LIM modules to send Probe Request frame
189 * during active scan/learn phase.
190 * Probe request is sent out in the following scenarios:
191 * --heartbeat failure: session needed
192 * --join req: session needed
193 * --foreground scan: no session
194 * --background scan: no session
195 * --sch_beacon_processing: to get EDCA parameters: session needed
196 *
197 * Return: tSirRetStatus (eSIR_SUCCESS on success and error codes otherwise)
198 */
199tSirRetStatus
200lim_send_probe_req_mgmt_frame(tpAniSirGlobal mac_ctx,
201 tSirMacSSid *ssid,
202 tSirMacAddr bssid,
203 uint8_t channel,
204 tSirMacAddr self_macaddr,
205 uint32_t dot11mode,
Sandeep Puligilla06ae8902018-04-16 19:02:47 -0700206 uint16_t *additional_ielen, uint8_t *additional_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207{
208 tDot11fProbeRequest pr;
209 uint32_t status, bytes, payload;
210 uint8_t *frame;
211 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530212 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 tpPESession pesession;
214 uint8_t sessionid;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700215 const uint8_t *p2pie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800216 uint8_t txflag = 0;
217 uint8_t sme_sessionid = 0;
218 bool is_vht_enabled = false;
219 uint8_t txPower;
Arif Hussain4c265132018-04-23 18:55:26 -0700220 uint16_t addn_ielen = 0;
Kapil Guptac03eb072016-08-09 14:01:36 +0530221 bool extracted_ext_cap_flag = false;
222 tDot11fIEExtCap extracted_ext_cap;
223 tSirRetStatus sir_status;
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530224 const uint8_t *qcn_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225
Arif Hussain4c265132018-04-23 18:55:26 -0700226 if (additional_ielen)
227 addn_ielen = *additional_ielen;
228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
230 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
231 * is false and dot11mode is 11ac set it to 11n.
232 */
233 if (channel <= SIR_11B_CHANNEL_END &&
234 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
235 (WNI_CFG_DOT11_MODE_11AC == dot11mode ||
236 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode))
237 dot11mode = WNI_CFG_DOT11_MODE_11N;
238 /*
239 * session context may or may not be present, when probe request needs
240 * to be sent out. Following cases exist:
241 * --heartbeat failure: session needed
242 * --join req: session needed
243 * --foreground scan: no session
244 * --background scan: no session
245 * --sch_beacon_processing: to get EDCA parameters: session needed
246 * If session context does not exist, some IEs will be populated from
247 * CFGs, e.g. Supported and Extended rate set IEs
248 */
249 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
250
251 if (pesession != NULL)
252 sme_sessionid = pesession->smeSessionId;
253
254 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
255 /* and then hand it off to 'dot11f_pack_probe_request' (for */
256 /* serialization). We start by zero-initializing the structure: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530257 qdf_mem_set((uint8_t *) &pr, sizeof(pr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258
259 /* & delegating to assorted helpers: */
260 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
261
262 if (addn_ielen && additional_ie)
263 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
264
265 /*
266 * Don't include 11b rate if it is a P2P serach or probe request is
267 * sent by P2P Client
268 */
269 if ((WNI_CFG_DOT11_MODE_11B != dot11mode) && (p2pie != NULL) &&
Abhishek Singh221cf992018-02-22 13:44:53 +0530270 ((pesession != NULL) &&
271 (QDF_P2P_CLIENT_MODE == pesession->pePersona))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 /*
273 * In the below API pass channel number > 14, do that it fills
274 * only 11a rates in supported rates
275 */
276 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
277 pesession);
278 } else {
279 populate_dot11f_supp_rates(mac_ctx, channel,
280 &pr.SuppRates, pesession);
281
282 if (WNI_CFG_DOT11_MODE_11B != dot11mode) {
283 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
284 &pr.ExtSuppRates);
285 }
286 }
287
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 /*
289 * Table 7-14 in IEEE Std. 802.11k-2008 says
290 * DS params "can" be present in RRM is disabled and "is" present if
291 * RRM is enabled. It should be ok even if we add it into probe req when
292 * RRM is not enabled.
293 */
294 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
295 /* Call RRM module to get the tx power for management used. */
296 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
297 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
298
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299
300 if (pesession != NULL) {
301 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
302 /* Include HT Capability IE */
303 if (pesession->htCapability)
304 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
305 } else { /* pesession == NULL */
306 if (IS_DOT11_MODE_HT(dot11mode))
307 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
308 }
309
310 /*
311 * Set channelbonding information as "disabled" when tunned to a
312 * 2.4 GHz channel
313 */
314 if (channel <= SIR_11B_CHANNEL_END) {
315 if (mac_ctx->roam.configParam.channelBondingMode24GHz
316 == PHY_SINGLE_CHANNEL_CENTERED) {
317 pr.HTCaps.supportedChannelWidthSet =
318 eHT_CHANNEL_WIDTH_20MHZ;
319 pr.HTCaps.shortGI40MHz = 0;
320 } else {
321 pr.HTCaps.supportedChannelWidthSet =
322 eHT_CHANNEL_WIDTH_40MHZ;
323 }
324 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 if (pesession != NULL) {
326 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
327 /* Include VHT Capability IE */
328 if (pesession->vhtCapability) {
329 populate_dot11f_vht_caps(mac_ctx, pesession,
330 &pr.VHTCaps);
331 is_vht_enabled = true;
332 }
333 } else {
334 if (IS_DOT11_MODE_VHT(dot11mode)) {
335 populate_dot11f_vht_caps(mac_ctx, pesession,
336 &pr.VHTCaps);
337 is_vht_enabled = true;
338 }
339 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 if (pesession != NULL)
341 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
342 pesession);
343
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800344 if (IS_DOT11_MODE_HE(dot11mode) && NULL != pesession)
345 lim_update_session_he_capable(mac_ctx, pesession);
346
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700347 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700348 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800349
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700350 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530351 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
352 sizeof(tDot11fIEExtCap));
353 sir_status = lim_strip_extcap_update_struct(mac_ctx,
354 additional_ie,
355 &addn_ielen,
356 &extracted_ext_cap);
357 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700358 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530359 } else {
360 struct s_ext_cap *p_ext_cap =
361 (struct s_ext_cap *)
362 extracted_ext_cap.bytes;
363 if (p_ext_cap->interworking_service)
364 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800365 extracted_ext_cap.num_bytes =
366 lim_compute_ext_cap_ie_length
367 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530368 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800369 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700370 if (additional_ielen)
371 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530372 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530373 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
374 SIR_MAC_QCN_OUI_TYPE_SIZE,
375 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530377 /* Add qcn_ie only if qcn ie is not present in additional_ie */
378 if (mac_ctx->roam.configParam.qcn_ie_support && !qcn_ie)
379 populate_dot11f_qcn_ie(&pr.QCN_IE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380
Hu Wang411e0cc2016-10-28 14:56:01 +0800381 /*
382 * Extcap IE now support variable length, merge Extcap IE from addn_ie
383 * may change the frame size. Therefore, MUST merge ExtCap IE before
384 * dot11f get packed payload size.
385 */
386 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800387 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800388
389 /* That's it-- now we pack it. First, how much space are we going to */
390 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
391 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700392 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800393 status);
394 /* We'll fall back on the worst case scenario: */
395 payload = sizeof(tDot11fProbeRequest);
396 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700397 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800398 status);
399 }
400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
402
403 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530404 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530406 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700407 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 return eSIR_MEM_ALLOC_FAILED;
409 }
410 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530411 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412
413 /* Next, we fill out the buffer descriptor: */
414 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
415 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
416
417 /* That done, pack the Probe Request: */
418 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
419 sizeof(tSirMacMgmtHdr),
420 payload, &payload);
421 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700422 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 cds_packet_free((void *)packet);
424 return eSIR_FAILURE; /* allocated! */
425 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700426 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 }
428 /* Append any AddIE if present. */
429 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530430 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 additional_ie, addn_ielen);
432 payload += addn_ielen;
433 }
434
435 /* If this probe request is sent during P2P Search State, then we need
436 * to send it at OFDM rate.
437 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530438 if ((BAND_5G == lim_get_rf_band(channel)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 /*
440 * For unicast probe req mgmt from Join function we don't set
441 * above variables. So we need to add one more check whether it
442 * is pePersona is P2P_CLIENT or not
443 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530444 ((pesession != NULL) &&
445 (QDF_P2P_CLIENT_MODE == pesession->pePersona))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
447 }
448
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530449 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 wma_tx_frame(mac_ctx, packet,
451 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
452 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
453 lim_tx_complete, frame, txflag, sme_sessionid,
Naveen Rawat296a5182017-09-25 14:02:48 -0700454 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530455 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700456 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 /* Pkt will be freed up by the callback */
458 return eSIR_FAILURE;
459 }
460
461 return eSIR_SUCCESS;
462} /* End lim_send_probe_req_mgmt_frame. */
463
Jeff Johnson38112a32016-10-07 07:30:50 -0700464static tSirRetStatus lim_get_addn_ie_for_probe_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 uint8_t *addIE, uint16_t *addnIELen,
466 uint8_t probeReqP2pIe)
467{
468 /* If Probe request doesn't have P2P IE, then take out P2P IE
469 from additional IE */
470 if (!probeReqP2pIe) {
471 uint8_t *tempbuf = NULL;
472 uint16_t tempLen = 0;
473 int left = *addnIELen;
474 uint8_t *ptr = addIE;
475 uint8_t elem_id, elem_len;
476
477 if (NULL == addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700478 pe_err("NULL addIE pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 return eSIR_FAILURE;
480 }
481
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530482 tempbuf = qdf_mem_malloc(left);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 if (NULL == tempbuf) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700484 pe_err("Unable to allocate memory to store addn IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485 return eSIR_MEM_ALLOC_FAILED;
486 }
487
488 while (left >= 2) {
489 elem_id = ptr[0];
490 elem_len = ptr[1];
491 left -= 2;
492 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700493 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530495 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800496 return eSIR_FAILURE;
497 }
498 if (!((SIR_MAC_EID_VENDOR == elem_id) &&
499 (memcmp
500 (&ptr[2], SIR_MAC_P2P_OUI,
501 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530502 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 elem_len + 2);
504 tempLen += (elem_len + 2);
505 }
506 left -= elem_len;
507 ptr += (elem_len + 2);
508 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530509 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530511 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512 }
513 return eSIR_SUCCESS;
514}
515
516/**
517 * lim_send_probe_rsp_mgmt_frame() - Send probe response
518 *
519 * @mac_ctx: Handle for mac context
520 * @peer_macaddr: Mac address of requesting peer
521 * @ssid: SSID for response
522 * @n_staid: Station ID, currently unused.
523 * @pe_session: PE session id
524 * @keepalive: Keep alive flag. Currently unused.
525 * @preq_p2pie: P2P IE in incoming probe request
526 *
527 * Builds and sends probe response frame to the requesting peer
528 *
529 * Return: void
530 */
531
532void
533lim_send_probe_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
534 tSirMacAddr peer_macaddr,
535 tpAniSSID ssid,
536 short n_staid,
537 uint8_t keepalive,
538 tpPESession pe_session, uint8_t preq_p2pie)
539{
540 tDot11fProbeResponse *frm;
541 tSirRetStatus sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800542 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800543 tpSirMacMgmtHdr mac_hdr;
544 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700545 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530546 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547 uint32_t addn_ie_present = false;
548
549 uint16_t addn_ie_len = 0;
550 uint32_t wps_ap = 0, tmp;
551 uint8_t tx_flag = 0;
552 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700553 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800554 uint8_t noalen = 0;
555 uint8_t total_noalen = 0;
556 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
557 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
558 uint8_t sme_sessionid = 0;
559 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530560 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530561 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562
563 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700564 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 return;
566
567 if (NULL == pe_session)
568 return;
569
570 /*
571 * In case when cac timer is running for this SAP session then
572 * avoid sending probe rsp out. It is violation of dfs specification.
573 */
Anurag Chouhan6d760662016-02-20 16:05:43 +0530574 if (((pe_session->pePersona == QDF_SAP_MODE) ||
575 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530577 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 FL("CAC timer is running, probe response dropped"));
579 return;
580 }
581 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530582 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700584 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 return;
586 }
587
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588 /*
589 * Fill out 'frm', after which we'll just hand the struct off to
590 * 'dot11f_pack_probe_response'.
591 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530592 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fProbeResponse), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593
594 /*
595 * Timestamp to be updated by TFP, below.
596 *
597 * Beacon Interval:
598 */
599 if (LIM_IS_AP_ROLE(pe_session)) {
600 frm->BeaconInterval.interval =
601 mac_ctx->sch.schObject.gSchBeaconInterval;
602 } else {
603 sir_status = wlan_cfg_get_int(mac_ctx,
604 WNI_CFG_BEACON_INTERVAL, &cfg);
605 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700606 pe_err("Failed to get WNI_CFG_BEACON_INTERVAL (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 sir_status);
608 goto err_ret;
609 }
610 frm->BeaconInterval.interval = (uint16_t) cfg;
611 }
612
613 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
614 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
615 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
616 &frm->SuppRates, pe_session);
617
618 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
619 pe_session->currentOperChannel);
620 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
621
622 if (LIM_IS_AP_ROLE(pe_session)) {
623 if (pe_session->wps_state != SAP_WPS_DISABLED)
624 populate_dot11f_probe_res_wpsi_es(mac_ctx,
625 &frm->WscProbeRes,
626 pe_session);
627 } else {
628 if (wlan_cfg_get_int(mac_ctx, (uint16_t) WNI_CFG_WPS_ENABLE,
629 &tmp) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700630 pe_err("Failed to cfg get id %d", WNI_CFG_WPS_ENABLE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631
632 wps_ap = tmp & WNI_CFG_WPS_ENABLE_AP;
633
634 if (wps_ap)
635 populate_dot11f_wsc_in_probe_res(mac_ctx,
636 &frm->WscProbeRes);
637
638 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
639 eLIM_WSC_ENROLL_BEGIN) {
640 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
641 &frm->WscProbeRes);
642 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
643 eLIM_WSC_ENROLL_IN_PROGRESS;
644 }
645
646 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
647 eLIM_WSC_ENROLL_END) {
648 de_populate_dot11f_wsc_registrar_info_in_probe_res(
649 mac_ctx, &frm->WscProbeRes);
650 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
651 eLIM_WSC_ENROLL_NOOP;
652 }
653 }
654
655 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
656 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
657
658 if (pe_session->dot11mode != WNI_CFG_DOT11_MODE_11B)
659 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
660
661 populate_dot11f_ext_supp_rates(mac_ctx,
662 POPULATE_DOT11F_RATES_OPERATIONAL,
663 &frm->ExtSuppRates, pe_session);
664
665 /* Populate HT IEs, when operating in 11n */
666 if (pe_session->htCapability) {
667 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
668 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
669 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700671 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
673 populate_dot11f_vht_operation(mac_ctx, pe_session,
674 &frm->VHTOperation);
675 /*
676 * we do not support multi users yet.
677 * populate_dot11f_vht_ext_bss_load( mac_ctx,
678 * &frm.VHTExtBssLoad );
679 */
680 is_vht_enabled = true;
681 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800683 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700684 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800685 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700686 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800687 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700688 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800689 }
690
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
692 pe_session);
693
694 if (pe_session->pLimStartBssReq) {
695 populate_dot11f_wpa(mac_ctx,
696 &(pe_session->pLimStartBssReq->rsnIE),
697 &frm->WPA);
698 populate_dot11f_rsn_opaque(mac_ctx,
699 &(pe_session->pLimStartBssReq->rsnIE),
700 &frm->RSNOpaque);
701 }
702
703 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
704 &frm->WMMCaps, pe_session);
705
706#if defined(FEATURE_WLAN_WAPI)
707 if (pe_session->pLimStartBssReq)
708 populate_dot11f_wapi(mac_ctx,
709 &(pe_session->pLimStartBssReq->rsnIE),
710 &frm->WAPI);
711#endif /* defined(FEATURE_WLAN_WAPI) */
712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800713 if (mac_ctx->lim.gpLimRemainOnChanReq)
714 bytes += (mac_ctx->lim.gpLimRemainOnChanReq->length -
715 sizeof(tSirRemainOnChnReq));
716 else
717 /*
718 * Only use CFG for non-listen mode. This CFG is not working for
719 * concurrency. In listening mode, probe rsp IEs is passed in
720 * the message from SME to PE.
721 */
722 addn_ie_present =
723 (pe_session->addIeParams.probeRespDataLen != 0);
724
725 if (addn_ie_present) {
726
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530727 add_ie = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 pe_session->addIeParams.probeRespDataLen);
729 if (NULL == add_ie) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700730 pe_err("add_ie allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 goto err_ret;
732 }
733
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530734 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735 pe_session->addIeParams.probeRespData_buff,
736 pe_session->addIeParams.probeRespDataLen);
737 addn_ie_len = pe_session->addIeParams.probeRespDataLen;
738
739 if (eSIR_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
740 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700741 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742 goto err_ret;
743 }
744
745 sir_status = lim_strip_extcap_update_struct(mac_ctx,
746 add_ie, &addn_ie_len,
747 &extracted_ext_cap);
748 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700749 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530750 } else {
751 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 }
753
754 bytes = bytes + addn_ie_len;
755
756 if (preq_p2pie)
757 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
758 addn_ie_len);
759
760 if (p2p_ie != NULL) {
761 /* get NoA attribute stream P2P IE */
762 noalen = lim_get_noa_attr_stream(mac_ctx,
763 noa_stream, pe_session);
764 if (noalen != 0) {
765 total_noalen =
766 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
767 &noa_stream[0], noalen);
768 bytes = bytes + total_noalen;
769 }
770 }
771 }
772
Hu Wang411e0cc2016-10-28 14:56:01 +0800773 /*
774 * Extcap IE now support variable length, merge Extcap IE from addn_ie
775 * may change the frame size. Therefore, MUST merge ExtCap IE before
776 * dot11f get packed payload size.
777 */
778 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800779 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
780 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800781
782 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
783 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700784 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800785 status);
786 /* We'll fall back on the worst case scenario: */
787 payload = sizeof(tDot11fProbeResponse);
788 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700789 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800790 status);
791 }
792
793 bytes += payload + sizeof(tSirMacMgmtHdr);
794
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530795 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530797 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700798 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799 goto err_ret;
800 }
801 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530802 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803
804 /* Next, we fill out the buffer descriptor: */
805 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
806 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
807 pe_session->selfMacAddr);
808
809 mac_hdr = (tpSirMacMgmtHdr) frame;
810
811 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 /* That done, pack the Probe Response: */
814 status =
815 dot11f_pack_probe_response(mac_ctx, frm,
816 frame + sizeof(tSirMacMgmtHdr),
817 payload, &payload);
818 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700819 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 status);
821 goto err_ret;
822 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700823 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 }
825
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700826 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530827 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 if (mac_ctx->lim.gpLimRemainOnChanReq)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530830 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 mac_ctx->lim.gpLimRemainOnChanReq->probeRspIe,
832 (mac_ctx->lim.gpLimRemainOnChanReq->length -
833 sizeof(tSirRemainOnChnReq)));
834
835 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530836 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 &add_ie[0], addn_ie_len);
838
839 if (noalen != 0) {
840 if (total_noalen >
841 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700842 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 total_noalen);
844 goto err_ret;
845 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530846 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 &noa_ie[0], total_noalen);
848 }
849 }
850
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800851 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530852 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
853 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 )
855 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
856
857 /* Queue Probe Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530858 qdf_status = wma_tx_frame((tHalHandle) mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 (uint16_t) bytes,
860 TXRX_FRM_802_11_MGMT,
861 ANI_TXDIR_TODS,
862 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -0700863 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864
865 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530866 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700867 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868
869 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530870 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530872 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 return;
874
875err_ret:
876 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530877 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 if (frm != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530879 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 if (packet != NULL)
881 cds_packet_free((void *)packet);
882 return;
883
884} /* End lim_send_probe_rsp_mgmt_frame. */
885
886void
887lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
888 tSirMacAddr peerMacAddr,
889 tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry)
890{
891 uint16_t i;
892 uint8_t *pFrame;
893 tDot11fAddTSRequest AddTSReq;
894 tDot11fWMMAddTSRequest WMMAddTSReq;
895 uint32_t nPayload, nBytes, nStatus;
896 tpSirMacMgmtHdr pMacHdr;
897 void *pPacket;
898#ifdef FEATURE_WLAN_ESE
899 uint32_t phyMode;
900#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530901 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 uint8_t txFlag = 0;
903 uint8_t smeSessionId = 0;
904
905 if (NULL == psessionEntry) {
906 return;
907 }
908
909 smeSessionId = psessionEntry->smeSessionId;
910
911 if (!pAddTS->wmeTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530912 qdf_mem_set((uint8_t *) &AddTSReq, sizeof(AddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913
914 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
915 AddTSReq.DialogToken.token = pAddTS->dialogToken;
916 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
917 if (pAddTS->lleTspecPresent) {
918 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
919 } else {
920 populate_dot11f_wmmtspec(&pAddTS->tspec,
921 &AddTSReq.WMMTSPEC);
922 }
923
924 if (pAddTS->lleTspecPresent) {
925 AddTSReq.num_WMMTCLAS = 0;
926 AddTSReq.num_TCLAS = pAddTS->numTclas;
927 for (i = 0; i < pAddTS->numTclas; ++i) {
928 populate_dot11f_tclas(pMac, &pAddTS->tclasInfo[i],
929 &AddTSReq.TCLAS[i]);
930 }
931 } else {
932 AddTSReq.num_TCLAS = 0;
933 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
934 for (i = 0; i < pAddTS->numTclas; ++i) {
935 populate_dot11f_wmmtclas(pMac,
936 &pAddTS->tclasInfo[i],
937 &AddTSReq.WMMTCLAS[i]);
938 }
939 }
940
941 if (pAddTS->tclasProcPresent) {
942 if (pAddTS->lleTspecPresent) {
943 AddTSReq.TCLASSPROC.processing =
944 pAddTS->tclasProc;
945 AddTSReq.TCLASSPROC.present = 1;
946 } else {
947 AddTSReq.WMMTCLASPROC.version = 1;
948 AddTSReq.WMMTCLASPROC.processing =
949 pAddTS->tclasProc;
950 AddTSReq.WMMTCLASPROC.present = 1;
951 }
952 }
953
954 nStatus =
955 dot11f_get_packed_add_ts_request_size(pMac, &AddTSReq, &nPayload);
956 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700957 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
958 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 /* We'll fall back on the worst case scenario: */
960 nPayload = sizeof(tDot11fAddTSRequest);
961 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700962 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
963 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 }
965 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530966 qdf_mem_set((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967
968 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
969 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
970 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
971
972 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
973 WMMAddTSReq.StatusCode.statusCode = 0;
974
975 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
976#ifdef FEATURE_WLAN_ESE
977 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
978
979 if (phyMode == WNI_CFG_PHY_MODE_11G
980 || phyMode == WNI_CFG_PHY_MODE_11A) {
981 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
982 } else {
983 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
984 }
985 populate_dot11_tsrsie(pMac, &pAddTS->tsrsIE,
986 &WMMAddTSReq.ESETrafStrmRateSet,
987 sizeof(uint8_t));
988#endif
989 /* fillWmeTspecIE */
990
991 nStatus =
992 dot11f_get_packed_wmm_add_ts_request_size(pMac, &WMMAddTSReq,
993 &nPayload);
994 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700995 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 nStatus);
997 /* We'll fall back on the worst case scenario: */
998 nPayload = sizeof(tDot11fAddTSRequest);
999 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001000 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
1001 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 }
1003 }
1004
1005 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1006
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301007 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301009 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001010 pe_err("Failed to allocate %d bytes for an Add TS Request",
1011 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 return;
1013 }
1014 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301015 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001016
1017 /* Next, we fill out the buffer descriptor: */
1018 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1019 SIR_MAC_MGMT_ACTION, peerMacAddr, psessionEntry->selfMacAddr);
1020 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1021
1022 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1023
1024#ifdef WLAN_FEATURE_11W
1025 lim_set_protected_bit(pMac, psessionEntry, peerMacAddr, pMacHdr);
1026#endif
1027
1028 /* That done, pack the struct: */
1029 if (!pAddTS->wmeTspecPresent) {
1030 nStatus = dot11f_pack_add_ts_request(pMac, &AddTSReq,
1031 pFrame +
1032 sizeof(tSirMacMgmtHdr),
1033 nPayload, &nPayload);
1034 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001035 pe_err("Failed to pack an Add TS Request "
1036 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 cds_packet_free((void *)pPacket);
1038 return; /* allocated! */
1039 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001040 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1041 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 }
1043 } else {
1044 nStatus = dot11f_pack_wmm_add_ts_request(pMac, &WMMAddTSReq,
1045 pFrame +
1046 sizeof(tSirMacMgmtHdr),
1047 nPayload, &nPayload);
1048 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001049 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1050 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 cds_packet_free((void *)pPacket);
1052 return; /* allocated! */
1053 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001054 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1055 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 }
1057 }
1058
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001059 pe_debug("Sending an Add TS Request frame to");
1060 lim_print_mac_addr(pMac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001062 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301064 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1065 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 ) {
1067 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1068 }
1069
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301070 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001072 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
1073 psessionEntry, eSIR_SUCCESS,
1074 eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075
1076 /* Queue Addts Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301077 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 TXRX_FRM_802_11_MGMT,
1079 ANI_TXDIR_TODS,
1080 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001081 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301082 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301083 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001085 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1086 pe_err("Could not send an Add TS Request (%X",
1087 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088} /* End lim_send_addts_req_action_frame. */
1089
1090/**
1091 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1092 * @mac_ctx: Handle for mac context
1093 * @status_code: Status code for assoc response frame
1094 * @aid: Association ID
1095 * @peer_addr: Mac address of requesting peer
1096 * @subtype: Assoc/Reassoc
1097 * @sta: Pointer to station node
1098 * @pe_session: PE session id.
1099 *
1100 * Builds and sends association response frame to the requesting peer.
1101 *
1102 * Return: void
1103 */
1104
1105void
1106lim_send_assoc_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
1107 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
1108 uint8_t subtype, tpDphHashNode sta, tpPESession pe_session)
1109{
1110 static tDot11fAssocResponse frm;
1111 uint8_t *frame;
1112 tpSirMacMgmtHdr mac_hdr;
1113 tSirRetStatus sir_status;
1114 uint8_t lle_mode = 0, addts;
1115 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001116 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301118 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119 tUpdateBeaconParams beacon_params;
1120 uint8_t tx_flag = 0;
1121 uint32_t addn_ie_len = 0;
1122 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1123 tpSirAssocReq assoc_req = NULL;
1124 uint8_t sme_session = 0;
1125 bool is_vht = false;
1126 uint16_t stripoff_len = 0;
1127 tDot11fIEExtCap extracted_ext_cap;
1128 bool extracted_flag = false;
1129#ifdef WLAN_FEATURE_11W
1130 uint32_t retry_int;
1131 uint32_t max_retries;
1132#endif
1133
1134 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001135 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 return;
1137 }
1138
1139 sme_session = pe_session->smeSessionId;
1140
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301141 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142
1143 limGetQosMode(pe_session, &qos_mode);
1144 limGetWmeMode(pe_session, &wme_mode);
1145
1146 /*
1147 * An Add TS IE is added only if the AP supports it and
1148 * the requesting STA sent a traffic spec.
1149 */
1150 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1151
1152 frm.Status.status = status_code;
1153
1154 frm.AID.associd = aid | LIM_AID_MASK;
1155
1156 if (NULL == sta) {
1157 populate_dot11f_supp_rates(mac_ctx,
1158 POPULATE_DOT11F_RATES_OPERATIONAL,
1159 &frm.SuppRates, pe_session);
1160 populate_dot11f_ext_supp_rates(mac_ctx,
1161 POPULATE_DOT11F_RATES_OPERATIONAL,
1162 &frm.ExtSuppRates, pe_session);
1163 } else {
1164 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1165 &frm.ExtSuppRates,
1166 sta->supportedRates.llbRates,
1167 sta->supportedRates.llaRates);
1168 }
1169
1170 if (LIM_IS_AP_ROLE(pe_session) && sta != NULL &&
1171 eSIR_SUCCESS == status_code) {
1172 assoc_req = (tpSirAssocReq)
1173 pe_session->parsedAssocReq[sta->assocId];
1174 /*
1175 * populate P2P IE in AssocRsp when assocReq from the peer
1176 * includes P2P IE
1177 */
1178 if (assoc_req != NULL && assoc_req->addIEPresent)
1179 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1180 &frm.P2PAssocRes,
1181 assoc_req);
1182 }
1183
1184 if (NULL != sta) {
1185 if (eHAL_SET == qos_mode) {
1186 if (sta->lleEnabled) {
1187 lle_mode = 1;
1188 populate_dot11f_edca_param_set(mac_ctx,
1189 &frm.EDCAParamSet, pe_session);
1190 }
1191 }
1192
1193 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1194 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1195 pe_session);
1196
1197 if (sta->wsmEnabled)
1198 populate_dot11f_wmm_caps(&frm.WMMCaps);
1199 }
1200
1201 if (sta->mlmStaContext.htCapability &&
1202 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001203 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 populate_dot11f_ht_caps(mac_ctx, pe_session,
1205 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001206 /*
1207 * Check the STA capability and
1208 * update the HTCaps accordingly
1209 */
1210 frm.HTCaps.supportedChannelWidthSet = (
1211 sta->htSupportedChannelWidthSet <
1212 pe_session->htSupportedChannelWidthSet) ?
1213 sta->htSupportedChannelWidthSet :
1214 pe_session->htSupportedChannelWidthSet;
1215 if (!frm.HTCaps.supportedChannelWidthSet)
1216 frm.HTCaps.shortGI40MHz = 0;
1217
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
1219 pe_session);
1220 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001221 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 +05301222 frm.HTCaps.supportedChannelWidthSet,
1223 frm.HTCaps.mimoPowerSave,
1224 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1225 frm.HTCaps.shortGI40MHz,
1226 frm.HTCaps.dsssCckMode40MHz,
1227 frm.HTCaps.maxRxAMPDUFactor);
1228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 if (sta->mlmStaContext.vhtCapability &&
1230 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001231 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232 populate_dot11f_vht_caps(mac_ctx, pe_session,
1233 &frm.VHTCaps);
1234 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301235 &frm.VHTOperation);
1236 is_vht = true;
1237 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001238
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301239 if (pe_session->vhtCapability &&
1240 pe_session->vendor_vht_sap &&
1241 (assoc_req != NULL) &&
1242 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001243 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301244 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001245 frm.vendor_vht_ie.sub_type =
1246 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301247 frm.vendor_vht_ie.VHTCaps.present = 1;
1248 populate_dot11f_vht_caps(mac_ctx, pe_session,
1249 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001250 populate_dot11f_vht_operation(mac_ctx, pe_session,
1251 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 is_vht = true;
1253 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1255 pe_session);
1256
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001257 if (lim_is_sta_he_capable(sta) &&
1258 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001259 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001260 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001261 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001262 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001263 &frm.he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001264 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265#ifdef WLAN_FEATURE_11W
1266 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
1267 if (wlan_cfg_get_int
1268 (mac_ctx, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1269 &max_retries) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001270 pe_err("get WNI_CFG_PMF_SA_QUERY_MAX_RETRIES failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 else if (wlan_cfg_get_int
1272 (mac_ctx,
1273 WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1274 &retry_int) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001275 pe_err("get WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 else
1277 populate_dot11f_timeout_interval(mac_ctx,
1278 &frm.TimeoutInterval,
1279 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1280 (max_retries -
1281 sta->pmfSaQueryRetryCount)
1282 * retry_int);
1283 }
1284#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001285
1286 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1287 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 }
1289
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301290 qdf_mem_set((uint8_t *) &beacon_params, sizeof(beacon_params), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291
1292 if (LIM_IS_AP_ROLE(pe_session) &&
1293 (pe_session->gLimProtectionControl !=
1294 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE))
1295 lim_decide_ap_protection(mac_ctx, peer_addr,
1296 &beacon_params, pe_session);
1297
1298 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1299 pe_session);
1300 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1301 pe_session);
1302
1303 /*
1304 * Populate Do11capabilities after updating session with
1305 * Assos req details
1306 */
1307 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1308
1309 beacon_params.bssIdx = pe_session->bssIdx;
1310
1311 /* Send message to HAL about beacon parameter change. */
1312 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1313 && beacon_params.paramChangeBitmap) {
1314 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1315 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1316 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317
Arif Hussain1513cb22018-01-05 19:56:31 -08001318 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 if (assoc_req != NULL) {
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001321 addn_ie_len = pe_session->addIeParams.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322
1323 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001324 if (addn_ie_len > 0 &&
1325 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1326 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301327 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 pe_session->addIeParams.assocRespData_buff,
1329 pe_session->addIeParams.assocRespDataLen);
1330
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301331 qdf_mem_set((uint8_t *) &extracted_ext_cap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 sizeof(extracted_ext_cap), 0);
1333
1334 stripoff_len = addn_ie_len;
1335 sir_status =
1336 lim_strip_extcap_update_struct
1337 (mac_ctx, &add_ie[0], &stripoff_len,
1338 &extracted_ext_cap);
1339 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001340 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 } else {
1342 addn_ie_len = stripoff_len;
1343 extracted_flag = true;
1344 }
1345 bytes = bytes + addn_ie_len;
1346 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001347 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 addn_ie_len, assoc_req->addIEPresent);
1349 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001350
1351 /*
1352 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1353 * may change the frame size. Therefore, MUST merge ExtCap IE before
1354 * dot11f get packed payload size.
1355 */
1356 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001357 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1358 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001359
1360 /* Allocate a buffer for this frame: */
1361 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1362 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001363 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001364 status);
1365 return;
1366 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001367 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001368 status);
1369 }
1370
1371 bytes += sizeof(tSirMacMgmtHdr) + payload;
1372
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301373 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301375 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001376 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 return;
1378 }
1379 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301380 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381
1382 /* Next, we fill out the buffer descriptor: */
1383 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1384 (LIM_ASSOC == subtype) ?
1385 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1386 peer_addr,
1387 pe_session->selfMacAddr);
1388 mac_hdr = (tpSirMacMgmtHdr) frame;
1389
1390 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1393 frame + sizeof(tSirMacMgmtHdr),
1394 payload, &payload);
1395 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001396 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 status);
1398 cds_packet_free((void *)packet);
1399 return;
1400 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001401 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 status);
1403 }
1404
1405 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001406 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 status_code, aid);
1408 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001409 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 status_code, aid);
1411
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301412 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413
1414 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301415 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416 &add_ie[0], addn_ie_len);
1417
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001418 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301420 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1421 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1423
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301424 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001426 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
1427 pe_session, eSIR_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301429 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 TXRX_FRM_802_11_MGMT,
1431 ANI_TXDIR_TODS,
1432 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001433 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301434 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301435 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436
1437 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301438 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001439 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301440 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441
1442 /*
1443 * update the ANI peer station count.
1444 * FIXME_PROTECTION : take care of different type of station
1445 * counter inside this function.
1446 */
1447 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1448
1449}
1450
1451void
1452lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
1453 tSirMacAddr peer,
1454 uint8_t wmmTspecPresent,
1455 tSirMacTSInfo *pTsinfo,
1456 tSirMacTspecIE *pTspecIe, tpPESession psessionEntry)
1457{
1458 uint8_t *pFrame;
1459 tpSirMacMgmtHdr pMacHdr;
1460 tDot11fDelTS DelTS;
1461 tDot11fWMMDelTS WMMDelTS;
1462 uint32_t nBytes, nPayload, nStatus;
1463 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301464 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 uint8_t txFlag = 0;
1466 uint8_t smeSessionId = 0;
1467
1468 if (NULL == psessionEntry) {
1469 return;
1470 }
1471
1472 smeSessionId = psessionEntry->smeSessionId;
1473
1474 if (!wmmTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301475 qdf_mem_set((uint8_t *) &DelTS, sizeof(DelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476
1477 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1478 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1479 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1480
1481 nStatus = dot11f_get_packed_del_ts_size(pMac, &DelTS, &nPayload);
1482 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001483 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001484 /* We'll fall back on the worst case scenario: */
1485 nPayload = sizeof(tDot11fDelTS);
1486 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001487 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1488 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 }
1490 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301491 qdf_mem_set((uint8_t *) &WMMDelTS, sizeof(WMMDelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492
1493 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1494 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1495 WMMDelTS.DialogToken.token = 0;
1496 WMMDelTS.StatusCode.statusCode = 0;
1497 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1498 nStatus =
1499 dot11f_get_packed_wmm_del_ts_size(pMac, &WMMDelTS, &nPayload);
1500 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001501 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 /* We'll fall back on the worst case scenario: */
1503 nPayload = sizeof(tDot11fDelTS);
1504 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001505 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1506 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 }
1508 }
1509
1510 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1511
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301512 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1514 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301515 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001516 pe_err("Failed to allocate %d bytes for an Add TS Response",
1517 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 return;
1519 }
1520 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301521 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522
1523 /* Next, we fill out the buffer descriptor: */
1524 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1525 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
1526 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1527
1528 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1529
1530#ifdef WLAN_FEATURE_11W
1531 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
1532#endif
1533
1534 /* That done, pack the struct: */
1535 if (!wmmTspecPresent) {
1536 nStatus = dot11f_pack_del_ts(pMac, &DelTS,
1537 pFrame + sizeof(tSirMacMgmtHdr),
1538 nPayload, &nPayload);
1539 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001540 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 nStatus);
1542 cds_packet_free((void *)pPacket);
1543 return; /* allocated! */
1544 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001545 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1546 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547 }
1548 } else {
1549 nStatus = dot11f_pack_wmm_del_ts(pMac, &WMMDelTS,
1550 pFrame + sizeof(tSirMacMgmtHdr),
1551 nPayload, &nPayload);
1552 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001553 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 nStatus);
1555 cds_packet_free((void *)pPacket);
1556 return; /* allocated! */
1557 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001558 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1559 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 }
1561 }
1562
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001563 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
1564 lim_print_mac_addr(pMac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001566 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301568 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1569 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570 ) {
1571 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1572 }
1573
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301574 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001576 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
1577 psessionEntry, eSIR_SUCCESS,
1578 eSIR_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301579 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 TXRX_FRM_802_11_MGMT,
1581 ANI_TXDIR_TODS,
1582 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001583 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301584 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301585 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301587 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001588 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589
1590} /* End lim_send_delts_req_action_frame. */
1591
1592/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301593 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1594 * @context: pointer to global mac
1595 * @buf: buffer
1596 * @tx_complete : Sent status
1597 * @params; tx completion params
1598 *
1599 * Return: This returns QDF_STATUS
1600 */
1601
1602static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1603 qdf_nbuf_t buf,
1604 uint32_t tx_complete,
1605 void *params)
1606{
1607 uint16_t assoc_ack_status;
1608 uint16_t reason_code;
1609 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
1610
1611 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001612 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301613 assoc_ack_status = ACKED;
1614 reason_code = eSIR_SUCCESS;
1615 } else {
1616 assoc_ack_status = NOT_ACKED;
1617 reason_code = eSIR_FAILURE;
1618 }
1619 if (buf)
1620 qdf_nbuf_free(buf);
1621
1622 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1623 NULL, assoc_ack_status, reason_code);
1624 return QDF_STATUS_SUCCESS;
1625}
1626
1627/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 * lim_send_assoc_req_mgmt_frame() - Send association request
1629 * @mac_ctx: Handle to MAC context
1630 * @mlm_assoc_req: Association request information
1631 * @pe_session: PE session information
1632 *
1633 * Builds and transmits association request frame to AP.
1634 *
1635 * Return: Void
1636 */
1637
1638void
1639lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
1640 tLimMlmAssocReq *mlm_assoc_req,
1641 tpPESession pe_session)
1642{
Naveen Rawat72475db2017-12-13 18:07:35 -08001643 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 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));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001836 } else if (pe_session->he_with_wep_tkip) {
1837 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1838 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001840 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 +05301841 frm->HTCaps.supportedChannelWidthSet,
1842 frm->HTCaps.mimoPowerSave,
1843 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1844 frm->HTCaps.shortGI40MHz,
1845 frm->HTCaps.dsssCckMode40MHz,
1846 frm->HTCaps.maxRxAMPDUFactor);
1847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 if (pe_session->vhtCapability &&
1849 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001850 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001852 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1853 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001855 if (pe_session->enableHtSmps &&
1856 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001857 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001858 populate_dot11f_operating_mode(mac_ctx,
1859 &frm->OperatingMode, pe_session);
1860 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001861 } else if (pe_session->he_with_wep_tkip) {
1862 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1863 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001865
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 if (!vht_enabled &&
1867 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001868 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301869 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001870 frm->vendor_vht_ie.sub_type =
1871 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301872 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhishek Singh68844282018-01-25 16:48:41 +05301873 if (!mac_ctx->roam.configParam.enable_subfee_vendor_vhtie &&
1874 pe_session->vht_config.su_beam_formee) {
1875 pe_debug("Disable SU beamformee for vendor IE");
1876 pe_session->vht_config.su_beam_formee = 0;
1877 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301879 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 vht_enabled = true;
1881 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301882 if (pe_session->is_ext_caps_present)
1883 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1884 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301886 if (mac_ctx->roam.configParam.qcn_ie_support)
1887 populate_dot11f_qcn_ie(&frm->QCN_IE);
1888
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001889 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001890 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001891 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001892 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001893 } else if (pe_session->he_with_wep_tkip) {
1894 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1895 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001896 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301897
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 tSirBssDescription *bssdescr;
1900
1901 bssdescr = &pe_session->pLimJoinReq->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001902 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 (unsigned int) bssdescr->mdie[0],
1904 (unsigned int) bssdescr->mdie[1],
1905 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 populate_mdie(mac_ctx, &frm->MobilityDomain,
1907 pe_session->pLimJoinReq->bssDescription.mdie);
1908 } else {
1909 /* No 11r IEs dont send any MDIE */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001910 pe_debug("MDIE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912
1913#ifdef FEATURE_WLAN_ESE
1914 /*
1915 * ESE Version IE will be included in association request
1916 * when ESE is enabled on DUT through ini and it is also
1917 * advertised by the peer AP to which we are trying to
1918 * associate to.
1919 */
1920 if (pe_session->is_ese_version_ie_present &&
1921 mac_ctx->roam.configParam.isEseIniFeatureEnabled)
1922 populate_dot11f_ese_version(&frm->ESEVersion);
1923 /* For ESE Associations fill the ESE IEs */
1924 if (pe_session->isESEconnection &&
1925 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1926#ifndef FEATURE_DISABLE_RM
1927 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1928#endif
1929 }
1930#endif
1931
Hu Wang411e0cc2016-10-28 14:56:01 +08001932 /*
1933 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1934 * may change the frame size. Therefore, MUST merge ExtCap IE before
1935 * dot11f get packed payload size.
1936 */
1937 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001938 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1939
1940 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1941 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1942 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1943 DOT11F_FF_BEACONINTERVAL_LEN +
1944 DOT11F_FF_CAPABILITIES_LEN;
1945
1946 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1947 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1948 bcn_ie = pe_session->beacon + ie_offset;
1949 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001950 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001951 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001952 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001953 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1954 &bcn_ext_cap);
1955 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1956 false);
1957 }
1958 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001959
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001960 if (eSIR_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
1961 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001962 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001963
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301964 if (lim_is_fils_connection(pe_session)) {
1965 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
1966 aes_block_size_len = AES_BLOCK_SIZE;
1967 }
1968
1969 /*
1970 * Do unpack to populate the add_ie buffer to frm structure
1971 * before packing the frm structure. In this way, the IE ordering
1972 * which the latest 802.11 spec mandates is maintained.
1973 */
Naveen Rawat72475db2017-12-13 18:07:35 -08001974 if (add_ie_len) {
1975 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301976 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08001977 if (DOT11F_FAILED(ret)) {
1978 pe_err("unpack failed, ret: 0x%x", ret);
1979 goto end;
1980 }
1981 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
1984 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001985 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986 status);
1987 /* We'll fall back on the worst case scenario: */
1988 payload = sizeof(tDot11fAssocRequest);
1989 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001990 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 status);
1992 }
1993
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301994 bytes = payload + sizeof(tSirMacMgmtHdr) +
1995 aes_block_size_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301997 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301999 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002000 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001
2002 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302003 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 pe_session->peSessionId,
2005 pe_session->limMlmState));
2006
2007 /* Update PE session id */
2008 assoc_cnf.sessionId = pe_session->peSessionId;
2009
2010 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2011
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2013 (uint32_t *) &assoc_cnf);
2014
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302015 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016 }
2017 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302018 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019
2020 /* Next, we fill out the buffer descriptor: */
2021 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2022 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
2023 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 /* That done, pack the Assoc Request: */
2025 status = dot11f_pack_assoc_request(mac_ctx, frm,
2026 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2027 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002028 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302030 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002032 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 }
2034
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 if (pe_session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302036 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002038 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 }
2040
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302041 if (lim_is_fils_connection(pe_session)) {
2042 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2043 frame, &payload);
2044 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2045 cds_packet_free((void *)packet);
2046 qdf_mem_free(frm);
2047 return;
2048 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 }
2050
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302051 pe_session->assocReq = qdf_mem_malloc(payload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052 if (NULL == pe_session->assocReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002053 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 } else {
2055 /*
2056 * Store the Assoc request. This is sent to csr/hdd in
2057 * join cnf response.
2058 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302059 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 frame + sizeof(tSirMacMgmtHdr), payload);
2061 pe_session->assocReqLen = payload;
2062 }
2063
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002064 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302065 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
2066 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 )
2068 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2069
Anurag Chouhan6d760662016-02-20 16:05:43 +05302070 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
2071 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2073
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302075 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302077
2078 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002079 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002080 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
2081 pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
2082 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
2083 pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302084 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302085 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2087 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302088 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002089 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302090 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302091 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302092 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002093
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302094 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002095 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302096 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302097 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
2098 pe_session, SENT_FAIL, eSIR_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100 }
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302101end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302103 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302105 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 return;
2107}
2108
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302110 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302111 * @context: pointer to global mac
2112 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302113 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302114 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302115 *
2116 * Return: This returns QDF_STATUS
2117 */
2118
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302119static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2120 qdf_nbuf_t buf,
2121 uint32_t tx_complete,
2122 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302123{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302124 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302125 uint16_t auth_ack_status;
2126 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302127
Naveen Rawat684e8b12017-09-20 15:54:44 -07002128 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002129 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2130 "success" : "fail");
2131 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302132 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302133 auth_ack_status = ACKED;
2134 reason_code = eSIR_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302135 /* 'Change' timer for future activations */
2136 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2137 } else {
2138 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302139 auth_ack_status = NOT_ACKED;
2140 reason_code = eSIR_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302141 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302142
2143 if (buf)
2144 qdf_nbuf_free(buf);
2145
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302146 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2147 NULL, auth_ack_status, reason_code);
2148
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302149 return QDF_STATUS_SUCCESS;
2150}
2151
2152/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2154 *
2155 * @mac_ctx: Pointer to Global MAC structure
2156 * @auth_frame: Pointer to Authentication frame structure
2157 * @peer_addr: MAC address of destination peer
2158 * @wep_bit: wep bit in frame control for Authentication frame3
2159 * @session: PE session information
2160 *
2161 * This function is called by lim_process_mlm_messages(). Authentication frame
2162 * is formatted and sent when this function is called.
2163 *
2164 * Return: void
2165 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166void
2167lim_send_auth_mgmt_frame(tpAniSirGlobal mac_ctx,
2168 tpSirMacAuthFrameBody auth_frame,
2169 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302170 uint8_t wep_challenge_len,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302171 tpPESession session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172{
2173 uint8_t *frame, *body;
2174 uint32_t frame_len = 0, body_len = 0;
2175 tpSirMacMgmtHdr mac_hdr;
2176 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302177 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178 uint8_t tx_flag = 0;
2179 uint8_t sme_sessionid = 0;
2180 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002181 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002182 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183
2184 if (NULL == session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002185 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 return;
2187 }
2188
2189 sme_sessionid = session->smeSessionId;
2190
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302191 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002192 /*
2193 * Auth frame3 to be sent with encrypted framebody
2194 *
2195 * Allocate buffer for Authenticaton frame of size
2196 * equal to management frame header length plus 2 bytes
2197 * each for auth algorithm number, transaction number,
2198 * status code, 128 bytes for challenge text and
2199 * 4 bytes each for IV & ICV.
2200 */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002201 pe_debug("Sending encrypted auth frame to " MAC_ADDRESS_STR,
2202 MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002203
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302204 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002205 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002206
2207 goto alloc_packet;
2208 }
2209
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302210 pe_info("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002211 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212 auth_frame->authTransactionSeqNumber,
2213 auth_frame->authStatusCode,
2214 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
2215 MAC_ADDR_ARRAY(peer_addr));
2216
2217 switch (auth_frame->authTransactionSeqNumber) {
2218 case SIR_MAC_AUTH_FRAME_1:
2219 /*
2220 * Allocate buffer for Authenticaton frame of size
2221 * equal to management frame header length plus 2 bytes
2222 * each for auth algorithm number, transaction number
2223 * and status code.
2224 */
2225
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002226 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2227 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302229 frame_len += lim_create_fils_auth_data(mac_ctx,
2230 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
2232 if (NULL != session->ftPEContext.pFTPreAuthReq &&
2233 0 != session->ftPEContext.pFTPreAuthReq->
2234 ft_ies_length) {
2235 ft_ies_length = session->ftPEContext.
2236 pFTPreAuthReq->ft_ies_length;
2237 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002238 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 ft_ies_length);
2240 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002241 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 frame_len += (2 + SIR_MDIE_SIZE);
2243 }
2244 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245 break;
2246
2247 case SIR_MAC_AUTH_FRAME_2:
2248 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2249 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2250 (auth_frame->authStatusCode !=
2251 eSIR_MAC_SUCCESS_STATUS))) {
2252 /*
2253 * Allocate buffer for Authenticaton frame of size
2254 * equal to management frame header length plus
2255 * 2 bytes each for auth algorithm number,
2256 * transaction number and status code.
2257 */
2258
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002259 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2260 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261 } else {
2262 /*
2263 * Shared Key algorithm with challenge text
2264 * to be sent.
2265 *
2266 * Allocate buffer for Authenticaton frame of size
2267 * equal to management frame header length plus
2268 * 2 bytes each for auth algorithm number,
2269 * transaction number, status code and 128 bytes
2270 * for challenge text.
2271 */
2272
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002273 challenge_req = true;
2274 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302275 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2276 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002277 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278 }
2279 break;
2280
2281 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002282 /*
2283 * Auth frame3 to be sent without encrypted framebody
2284 *
2285 * Allocate buffer for Authenticaton frame of size equal
2286 * to management frame header length plus 2 bytes each
2287 * for auth algorithm number, transaction number and
2288 * status code.
2289 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002291 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2292 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293 break;
2294
2295 case SIR_MAC_AUTH_FRAME_4:
2296 /*
2297 * Allocate buffer for Authenticaton frame of size equal
2298 * to management frame header length plus 2 bytes each
2299 * for auth algorithm number, transaction number and
2300 * status code.
2301 */
2302
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002303 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2304 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305
2306 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002307 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002308 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002309 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 } /* switch (auth_frame->authTransactionSeqNumber) */
2311
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002312alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302313 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 (void **)&packet);
2315
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302316 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002317 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 return;
2319 }
2320
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302321 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322
2323 /* Prepare BD */
2324 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2325 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2326 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302327 if (wep_challenge_len)
2328 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2329 else
2330 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331
2332 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002333 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302334 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335 (uint8_t *) session->bssId,
2336 sizeof(tSirMacAddr));
2337
2338 /* Prepare Authentication frame body */
2339 body = frame + sizeof(tSirMacMgmtHdr);
2340
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302341 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302342 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002343
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002344 pe_debug("Sending Auth seq# 3 to " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 MAC_ADDR_ARRAY(mac_hdr->da));
2346
2347 } else {
2348 *((uint16_t *) (body)) =
2349 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2350 body += sizeof(uint16_t);
2351 body_len -= sizeof(uint16_t);
2352
2353 *((uint16_t *) (body)) =
2354 sir_swap_u16if_needed(
2355 auth_frame->authTransactionSeqNumber);
2356 body += sizeof(uint16_t);
2357 body_len -= sizeof(uint16_t);
2358
2359 *((uint16_t *) (body)) =
2360 sir_swap_u16if_needed(auth_frame->authStatusCode);
2361 body += sizeof(uint16_t);
2362 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002363
2364 if (challenge_req) {
2365 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302366 /* copy challenge IE id, len, challenge text */
2367 *body = auth_frame->type;
2368 body++;
2369 body_len -= sizeof(uint8_t);
2370 *body = auth_frame->length;
2371 body++;
2372 body_len -= sizeof(uint8_t);
2373 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002374 body_len);
2375 pe_err("Incomplete challenge info: length: %d, expected: %d",
2376 body_len,
2377 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2378 body += body_len;
2379 body_len = 0;
2380 } else {
2381 /* copy challenge IE id, len, challenge text */
2382 *body = auth_frame->type;
2383 body++;
2384 *body = auth_frame->length;
2385 body++;
2386 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302387 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2388 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002389
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302390 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2391 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002392 }
2393 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2396 (auth_frame->authTransactionSeqNumber ==
2397 SIR_MAC_AUTH_FRAME_1) &&
2398 (session->ftPEContext.pFTPreAuthReq != NULL)) {
2399
2400 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302401 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002402 session->ftPEContext.
2403 pFTPreAuthReq->ft_ies,
2404 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002405 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002406 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2407 QDF_TRACE_LEVEL_DEBUG,
2408 (uint8_t *) body,
2409 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 } else if (NULL != session->ftPEContext.
2411 pFTPreAuthReq->pbssDescription) {
2412 /* MDID attr is 54 */
2413 *body = SIR_MDIE_ELEMENT_ID;
2414 body++;
2415 *body = SIR_MDIE_SIZE;
2416 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302417 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 &session->ftPEContext.pFTPreAuthReq->
2419 pbssDescription->mdie[0],
2420 SIR_MDIE_SIZE);
2421 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302422 } else if (auth_frame->authAlgoNumber ==
Varun Reddy Yeturu5faa1772017-10-23 11:22:01 -07002423 SIR_FILS_SK_WITHOUT_PFS) {
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302424 /* TODO MDIE */
2425 pe_debug("appending fils Auth data");
2426 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002429 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
2430 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 auth_frame->authTransactionSeqNumber,
2432 auth_frame->authStatusCode,
2433 (auth_frame->authStatusCode ==
2434 eSIR_MAC_SUCCESS_STATUS),
2435 MAC_ADDR_ARRAY(mac_hdr->da));
2436 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002437 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2438 QDF_TRACE_LEVEL_DEBUG,
2439 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302441 if ((NULL != session->ftPEContext.pFTPreAuthReq) &&
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002442 (BAND_5G == lim_get_rf_band(
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302443 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002445 else if ((BAND_5G ==
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302446 lim_get_rf_band(session->currentOperChannel))
2447 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2448 || (session->pePersona == QDF_P2P_GO_MODE))
2449 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450
Anurag Chouhan6d760662016-02-20 16:05:43 +05302451 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2452 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2454
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302455 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302458 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002459 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002460 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
2461 session, eSIR_SUCCESS, eSIR_SUCCESS);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302462 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2463 (uint16_t)frame_len,
2464 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2465 7, lim_tx_complete, frame,
2466 lim_auth_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002467 tx_flag, sme_sessionid, false, 0, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302468 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2469 session->peSessionId, qdf_status));
2470 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2471 pe_err("*** Could not send Auth frame, retCode=%X ***",
2472 qdf_status);
2473 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2474 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2475 session, SENT_FAIL, eSIR_FAILURE);
2476 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302477 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 return;
2479}
2480
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002481QDF_STATUS lim_send_deauth_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482{
2483 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002484 tpDphHashNode sta_ds;
2485 tLimMlmDeauthReq *deauth_req;
2486 tLimMlmDeauthCnf deauth_cnf;
2487 tpPESession session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002489 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2490 if (deauth_req) {
2491 if (tx_timer_running(
2492 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2493 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002496 session_entry = pe_find_session_by_session_id(mac_ctx,
2497 deauth_req->sessionId);
2498 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002499 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002500 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 eSIR_SME_INVALID_PARAMETERS;
2502 goto end;
2503 }
2504
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002505 sta_ds =
2506 dph_lookup_hash_entry(mac_ctx,
2507 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002508 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002509 &session_entry->dph.dphHashTable);
2510 if (sta_ds == NULL) {
2511 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 goto end;
2513 }
2514
2515 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002516 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2517 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2518 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2519 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302520#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002521 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302522#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002523 (session_entry->isFastRoamIniFeatureEnabled) ||
2524 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002525 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002526 session_entry,
2527 session_entry->peSessionId,
2528 deauth_req->reasonCode,
2529 deauth_req->deauthTrigger);
2530 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002531 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002532 pe_debug("No FT Preauth Session Cleanup in role %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002533#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002534 " isESE %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002535#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002536 " isLFR %d"
2537 " is11r %d, Deauth reason %d Trigger = %d",
2538 session_entry->limSystemRole,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002539#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002540 session_entry->isESEconnection,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002541#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002542 session_entry->isFastRoamIniFeatureEnabled,
2543 session_entry->is11Rconnection,
2544 deauth_req->reasonCode,
2545 deauth_req->deauthTrigger);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002546 }
2547 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002548 qdf_mem_free(deauth_req);
2549 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302551 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002553 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2554 &deauth_req->peer_macaddr);
2555 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2556 deauth_cnf.aid = deauth_req->aid;
2557 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558
2559 /* Free up buffer allocated */
2560 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002561 qdf_mem_free(deauth_req);
2562 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002564 lim_post_sme_message(mac_ctx,
2565 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302566 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567}
2568
2569/**
2570 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2571 *
2572 * @mac_ctx: Handle to MAC context
2573 *
2574 * Sends disassoc confirmation to SME. Removes disassoc request stored
2575 * in lim.
2576 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302577 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 */
2579
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302580QDF_STATUS lim_send_disassoc_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581{
2582 uint16_t aid;
2583 tpDphHashNode sta_ds;
2584 tLimMlmDisassocCnf disassoc_cnf;
2585 tpPESession pe_session;
2586 tLimMlmDisassocReq *disassoc_req;
2587
2588 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2589 if (disassoc_req) {
2590 if (tx_timer_running(
2591 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2592 lim_deactivate_and_change_timer(mac_ctx,
2593 eLIM_DISASSOC_ACK_TIMER);
2594
2595 pe_session = pe_find_session_by_session_id(
2596 mac_ctx, disassoc_req->sessionId);
2597 if (pe_session == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002598 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 disassoc_cnf.resultCode =
2600 eSIR_SME_INVALID_PARAMETERS;
2601 goto end;
2602 }
2603
2604 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002605 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 &pe_session->dph.dphHashTable);
2607 if (sta_ds == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002608 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2610 goto end;
2611 }
2612 /* Receive path cleanup with dummy packet */
2613 if (eSIR_SUCCESS !=
2614 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2615 disassoc_cnf.resultCode =
2616 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002617 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 goto end;
2619 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002620 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002621 (disassoc_req->reasonCode !=
2622 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002623 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002624 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002626 /* Delete FT session if there exists one */
2627 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302630 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302632 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302634 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635 }
2636end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302637 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002638 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302639 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 disassoc_cnf.aid = disassoc_req->aid;
2641 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2642
2643 /* Update PE session ID */
2644 disassoc_cnf.sessionId = disassoc_req->sessionId;
2645
2646 if (disassoc_req != NULL) {
2647 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302648 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2650 }
2651
2652 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2653 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302654 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655}
2656
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302657QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002658 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302659 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002661 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302662
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002663 pe_debug("tx_success: %d", tx_success);
2664
2665 return lim_send_disassoc_cnf(max_ctx);
2666}
2667
2668static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2669 qdf_nbuf_t buf,
2670 uint32_t tx_success,
2671 void *params)
2672{
2673 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
2674 QDF_STATUS status_code;
2675 struct scheduler_msg msg = {0};
2676
2677 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302678
2679 if (buf)
2680 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002681 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2682 msg.bodyptr = params;
2683 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302684
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002685 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2686 if (status_code != QDF_STATUS_SUCCESS)
2687 pe_err("posting message: %X to LIM failed, reason: %d",
2688 msg.type, status_code);
2689 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690}
2691
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302692QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002693 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302694 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002696 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302697
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002698 pe_debug("tx_success: %d", tx_success);
2699
2700 return lim_send_deauth_cnf(mac_ctx);
2701}
2702
2703static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2704 qdf_nbuf_t buf,
2705 uint32_t tx_success,
2706 void *params)
2707{
2708 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2709 QDF_STATUS status_code;
2710 struct scheduler_msg msg = {0};
2711
2712 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302713
2714 if (buf)
2715 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002716 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2717 msg.bodyptr = params;
2718 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302719
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002720 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2721 if (status_code != QDF_STATUS_SUCCESS)
2722 pe_err("posting message: %X to LIM failed, reason: %d",
2723 msg.type, status_code);
2724 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725}
2726
2727/**
2728 * \brief This function is called to send Disassociate frame.
2729 *
2730 *
2731 * \param pMac Pointer to Global MAC structure
2732 *
2733 * \param nReason Indicates the reason that need to be sent in
2734 * Disassociation frame
2735 *
2736 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2737 * sent
2738 *
2739 *
2740 */
2741
2742void
2743lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
2744 uint16_t nReason,
2745 tSirMacAddr peer,
2746 tpPESession psessionEntry, bool waitForAck)
2747{
2748 tDot11fDisassociation frm;
2749 uint8_t *pFrame;
2750 tpSirMacMgmtHdr pMacHdr;
2751 uint32_t nBytes, nPayload, nStatus;
2752 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302753 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754 uint8_t txFlag = 0;
2755 uint32_t val = 0;
2756 uint8_t smeSessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002757
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 if (NULL == psessionEntry) {
2759 return;
2760 }
2761
2762 /*
2763 * In case when cac timer is running for this SAP session then
2764 * avoid sending disassoc out. It is violation of dfs specification.
2765 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302766 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2767 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302769 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 FL
2771 ("CAC timer is running, drop disassoc from going out"));
2772 return;
2773 }
2774 smeSessionId = psessionEntry->smeSessionId;
2775
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302776 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777
2778 frm.Reason.code = nReason;
2779
2780 nStatus = dot11f_get_packed_disassociation_size(pMac, &frm, &nPayload);
2781 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002782 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 nStatus);
2784 /* We'll fall back on the worst case scenario: */
2785 nPayload = sizeof(tDot11fDisassociation);
2786 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002787 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2788 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789 }
2790
2791 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2792
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302793 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002794 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302795 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002796 pe_err("Failed to allocate %d bytes for a Disassociation",
2797 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 return;
2799 }
2800 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302801 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802
2803 /* Next, we fill out the buffer descriptor: */
2804 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2805 SIR_MAC_MGMT_DISASSOC, peer, psessionEntry->selfMacAddr);
2806 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2807
2808 /* Prepare the BSSID */
2809 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2810
2811#ifdef WLAN_FEATURE_11W
2812 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2813#endif
2814
2815 nStatus = dot11f_pack_disassociation(pMac, &frm, pFrame +
2816 sizeof(tSirMacMgmtHdr),
2817 nPayload, &nPayload);
2818 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002819 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820 nStatus);
2821 cds_packet_free((void *)pPacket);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002822 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002824 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
2825 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 }
2827
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002828 pe_debug("***Sessionid %d Sending Disassociation frame with "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002830 MAC_ADDRESS_STR, psessionEntry->peSessionId, nReason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
2832 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2833
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002834 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302835 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2836 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837 ) {
2838 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2839 }
2840
Sushant Kaushik46556062015-12-02 16:57:47 +05302841 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842
2843 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302844 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 psessionEntry->peSessionId,
2846 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002847 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
2848 psessionEntry, eSIR_SUCCESS,
2849 eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 /* Queue Disassociation frame in high priority WQ */
2851 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302852 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2854 TXRX_FRM_802_11_MGMT,
2855 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002856 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07002857 txFlag, smeSessionId, false, 0,
2858 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302859 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302860 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302861 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862
2863 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2864
2865 if (tx_timer_change
2866 (&pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
2867 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002868 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869 return;
2870 } else if (TX_SUCCESS !=
2871 tx_timer_activate(&pMac->lim.limTimers.
2872 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002873 pe_err("Unable to activate Disassoc ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 lim_deactivate_and_change_timer(pMac,
2875 eLIM_DISASSOC_ACK_TIMER);
2876 return;
2877 }
2878 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302879 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 psessionEntry->peSessionId,
2881 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002882 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
2883 psessionEntry,
2884 eSIR_SUCCESS, eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002885 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302886 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887 TXRX_FRM_802_11_MGMT,
2888 ANI_TXDIR_TODS,
2889 7,
2890 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07002891 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302892 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302893 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302894 psessionEntry->peSessionId, qdf_status));
2895 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002896 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302897 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 /* Pkt will be freed up by the callback */
2899 }
2900 }
2901} /* End lim_send_disassoc_mgmt_frame. */
2902
2903/**
2904 * \brief This function is called to send a Deauthenticate frame
2905 *
2906 *
2907 * \param pMac Pointer to global MAC structure
2908 *
2909 * \param nReason Indicates the reason that need to be sent in the
2910 * Deauthenticate frame
2911 *
2912 * \param peeer address of the STA to which the frame is to be sent
2913 *
2914 *
2915 */
2916
2917void
2918lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
2919 uint16_t nReason,
2920 tSirMacAddr peer,
2921 tpPESession psessionEntry, bool waitForAck)
2922{
2923 tDot11fDeAuth frm;
2924 uint8_t *pFrame;
2925 tpSirMacMgmtHdr pMacHdr;
2926 uint32_t nBytes, nPayload, nStatus;
2927 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302928 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 uint8_t txFlag = 0;
2930 uint32_t val = 0;
2931#ifdef FEATURE_WLAN_TDLS
2932 uint16_t aid;
2933 tpDphHashNode pStaDs;
2934#endif
2935 uint8_t smeSessionId = 0;
2936
2937 if (NULL == psessionEntry) {
2938 return;
2939 }
2940
2941 /*
2942 * In case when cac timer is running for this SAP session then
2943 * avoid deauth frame out. It is violation of dfs specification.
2944 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302945 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2946 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302948 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 FL
2950 ("CAC timer is running, drop the deauth from going out"));
2951 return;
2952 }
2953 smeSessionId = psessionEntry->smeSessionId;
2954
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302955 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956
2957 frm.Reason.code = nReason;
2958
2959 nStatus = dot11f_get_packed_de_auth_size(pMac, &frm, &nPayload);
2960 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002961 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 nStatus);
2963 /* We'll fall back on the worst case scenario: */
2964 nPayload = sizeof(tDot11fDeAuth);
2965 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002966 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
2967 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 }
2969
2970 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2971
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302972 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302974 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002975 pe_err("Failed to allocate %d bytes for a De-Authentication",
2976 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 return;
2978 }
2979 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302980 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981
2982 /* Next, we fill out the buffer descriptor: */
2983 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2984 SIR_MAC_MGMT_DEAUTH, peer, psessionEntry->selfMacAddr);
2985 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2986
2987 /* Prepare the BSSID */
2988 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2989
2990#ifdef WLAN_FEATURE_11W
2991 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2992#endif
2993
2994 nStatus = dot11f_pack_de_auth(pMac, &frm, pFrame +
2995 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
2996 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002997 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 nStatus);
2999 cds_packet_free((void *)pPacket);
3000 return;
3001 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003002 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3003 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003005 pe_debug("***Sessionid %d Sending Deauth frame with "
3006 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
3007 " ,From " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 psessionEntry->peSessionId, nReason, waitForAck,
3009 MAC_ADDR_ARRAY(pMacHdr->da),
3010 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3011
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003012 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303013 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3014 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 ) {
3016 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3017 }
3018
Sushant Kaushik46556062015-12-02 16:57:47 +05303019 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020#ifdef FEATURE_WLAN_TDLS
3021 pStaDs =
3022 dph_lookup_hash_entry(pMac, peer, &aid,
3023 &psessionEntry->dph.dphHashTable);
3024#endif
3025
3026 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303027 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 psessionEntry->peSessionId,
3029 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08003030 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3031 psessionEntry,
3032 eSIR_SUCCESS, eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303034 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
3036 TXRX_FRM_802_11_MGMT,
3037 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003038 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003039 txFlag, smeSessionId, false, 0,
3040 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303041 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303042 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303043 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303045 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003046 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303047 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048
3049 /* Call lim_process_deauth_ack_timeout which will send
3050 * DeauthCnf for this frame
3051 */
3052 lim_process_deauth_ack_timeout(pMac);
3053 return;
3054 }
3055
3056 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3057
3058 if (tx_timer_change
3059 (&pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3060 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003061 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062 return;
3063 } else if (TX_SUCCESS !=
3064 tx_timer_activate(&pMac->lim.limTimers.
3065 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003066 pe_err("Unable to activate Deauth ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067 lim_deactivate_and_change_timer(pMac,
3068 eLIM_DEAUTH_ACK_TIMER);
3069 return;
3070 }
3071 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303072 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073 psessionEntry->peSessionId,
3074 pMacHdr->fc.subType));
3075#ifdef FEATURE_WLAN_TDLS
3076 if ((NULL != pStaDs)
3077 && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
3078 /* Queue Disassociation frame in high priority WQ */
Krunal Sonic65fc492018-03-09 15:53:28 -08003079 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3080 psessionEntry,
3081 eSIR_SUCCESS,
3082 eSIR_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303083 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3085 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3086 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003087 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088 } else {
3089#endif
Krunal Sonic65fc492018-03-09 15:53:28 -08003090 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3091 psessionEntry,
3092 eSIR_SUCCESS,
3093 eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303095 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3097 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3098 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003099 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100#ifdef FEATURE_WLAN_TDLS
3101 }
3102#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303103 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303104 psessionEntry->peSessionId, qdf_status));
3105 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003106 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303107 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108 /* Pkt will be freed up by the callback */
3109 }
3110 }
3111
3112} /* End lim_send_deauth_mgmt_frame. */
3113
3114#ifdef ANI_SUPPORT_11H
3115/**
3116 * \brief Send a Measurement Report Action frame
3117 *
3118 *
3119 * \param pMac Pointer to the global MAC structure
3120 *
3121 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3122 *
3123 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3124 *
3125 *
3126 */
3127
3128tSirRetStatus
3129lim_send_meas_report_frame(tpAniSirGlobal pMac,
3130 tpSirMacMeasReqActionFrame pMeasReqFrame,
3131 tSirMacAddr peer, tpPESession psessionEntry)
3132{
3133 tDot11fMeasurementReport frm;
3134 uint8_t *pFrame;
3135 tSirRetStatus nSirStatus;
3136 tpSirMacMgmtHdr pMacHdr;
3137 uint32_t nBytes, nPayload, nStatus;
3138 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303139 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303141 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142
3143 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3144 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3145 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3146
3147 switch (pMeasReqFrame->measReqIE.measType) {
3148 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3149 nSirStatus =
3150 populate_dot11f_measurement_report0(pMac, pMeasReqFrame,
3151 &frm.MeasurementReport);
3152 break;
3153 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3154 nSirStatus =
3155 populate_dot11f_measurement_report1(pMac, pMeasReqFrame,
3156 &frm.MeasurementReport);
3157 break;
3158 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3159 nSirStatus =
3160 populate_dot11f_measurement_report2(pMac, pMeasReqFrame,
3161 &frm.MeasurementReport);
3162 break;
3163 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003164 pe_err("Unknown measurement type %d in limSen"
3165 "dMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 pMeasReqFrame->measReqIE.measType);
3167 return eSIR_FAILURE;
3168 }
3169
3170 if (eSIR_SUCCESS != nSirStatus)
3171 return eSIR_FAILURE;
3172
3173 nStatus = dot11f_get_packed_measurement_report_size(pMac, &frm, &nPayload);
3174 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003175 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 nStatus);
3177 /* We'll fall back on the worst case scenario: */
3178 nPayload = sizeof(tDot11fMeasurementReport);
3179 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003180 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3181 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182 }
3183
3184 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3185
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303186 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3188 (uint16_t) nBytes, (void **)&pFrame,
3189 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303190 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003191 pe_err("Failed to allocate %d bytes for a "
3192 "De-Authentication", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 return eSIR_FAILURE;
3194 }
3195 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303196 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197
3198 /* Next, we fill out the buffer descriptor: */
3199 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3200 SIR_MAC_MGMT_ACTION, peer);
3201 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3202
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303203 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204
3205#ifdef WLAN_FEATURE_11W
3206 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3207#endif
3208
3209 nStatus = dot11f_pack_measurement_report(pMac, &frm, pFrame +
3210 sizeof(tSirMacMgmtHdr),
3211 nPayload, &nPayload);
3212 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003213 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 nStatus);
3215 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3216 (void *)pFrame, (void *)pPacket);
3217 return eSIR_FAILURE; /* allocated! */
3218 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003219 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3220 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 }
3222
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303223 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 ((psessionEntry) ? psessionEntry->
3225 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303226 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3228 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003229 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303230 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303231 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303233 qdf_status));
3234 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003235 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303236 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 /* Pkt will be freed up by the callback */
3238 return eSIR_FAILURE; /* just allocated... */
3239 }
3240
3241 return eSIR_SUCCESS;
3242
3243} /* End lim_send_meas_report_frame. */
3244
3245/**
3246 * \brief Send a TPC Request Action frame
3247 *
3248 *
3249 * \param pMac Pointer to the global MAC datastructure
3250 *
3251 * \param peer MAC address to which the frame should be sent
3252 *
3253 *
3254 */
3255
3256void
3257lim_send_tpc_request_frame(tpAniSirGlobal pMac,
3258 tSirMacAddr peer, tpPESession psessionEntry)
3259{
3260 tDot11fTPCRequest frm;
3261 uint8_t *pFrame;
3262 tpSirMacMgmtHdr pMacHdr;
3263 uint32_t nBytes, nPayload, nStatus;
3264 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303265 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303267 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268
3269 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3270 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
3271 frm.DialogToken.token = 1;
3272 frm.TPCRequest.present = 1;
3273
3274 nStatus = dot11f_get_packed_tpc_request_size(pMac, &frm, &nPayload);
3275 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003276 pe_err("Failed to calculate the packed size for a TPC Request (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 /* We'll fall back on the worst case scenario: */
3278 nPayload = sizeof(tDot11fTPCRequest);
3279 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003280 pe_warn("There were warnings while calculating the packed size for a TPC Request (0x%08x)",
3281 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282 }
3283
3284 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3285
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303286 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3288 (uint16_t) nBytes, (void **)&pFrame,
3289 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303290 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003291 pe_err("Failed to allocate %d bytes for a TPC"
3292 " Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 return;
3294 }
3295 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303296 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297
3298 /* Next, we fill out the buffer descriptor: */
3299 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3300 SIR_MAC_MGMT_ACTION, peer);
3301 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3302
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303303 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003304
3305#ifdef WLAN_FEATURE_11W
3306 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3307#endif
3308
3309 nStatus = dot11f_pack_tpc_request(pMac, &frm, pFrame +
3310 sizeof(tSirMacMgmtHdr),
3311 nPayload, &nPayload);
3312 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003313 pe_err("Failed to pack a TPC Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 nStatus);
3315 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3316 (void *)pFrame, (void *)pPacket);
3317 return; /* allocated! */
3318 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003319 pe_warn("There were warnings while packing a TPC Request (0x%08x)",
3320 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 }
3322
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303323 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 ((psessionEntry) ? psessionEntry->
3325 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303326 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3328 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003329 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303330 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303331 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303333 qdf_status));
3334 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003335 pe_err("Failed to send a TPC Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303336 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 /* Pkt will be freed up by the callback */
3338 }
3339
3340} /* End lim_send_tpc_request_frame. */
3341
3342/**
3343 * \brief Send a TPC Report Action frame
3344 *
3345 *
3346 * \param pMac Pointer to the global MAC datastructure
3347 *
3348 * \param pTpcReqFrame Pointer to the received TPC Request
3349 *
3350 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3351 *
3352 *
3353 */
3354
3355tSirRetStatus
3356lim_send_tpc_report_frame(tpAniSirGlobal pMac,
3357 tpSirMacTpcReqActionFrame pTpcReqFrame,
3358 tSirMacAddr peer, tpPESession psessionEntry)
3359{
3360 tDot11fTPCReport frm;
3361 uint8_t *pFrame;
3362 tpSirMacMgmtHdr pMacHdr;
3363 uint32_t nBytes, nPayload, nStatus;
3364 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303365 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303367 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368
3369 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3370 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3371 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3372
3373 frm.TPCReport.tx_power = 0;
3374 frm.TPCReport.link_margin = 0;
3375 frm.TPCReport.present = 1;
3376
3377 nStatus = dot11f_get_packed_tpc_report_size(pMac, &frm, &nPayload);
3378 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003379 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 /* We'll fall back on the worst case scenario: */
3381 nPayload = sizeof(tDot11fTPCReport);
3382 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003383 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3384 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385 }
3386
3387 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3388
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303389 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3391 (uint16_t) nBytes, (void **)&pFrame,
3392 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303393 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003394 pe_err("Failed to allocate %d bytes for a TPC"
3395 " Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 return eSIR_FAILURE;
3397 }
3398 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303399 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400
3401 /* Next, we fill out the buffer descriptor: */
3402 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3403 SIR_MAC_MGMT_ACTION, peer);
3404
3405 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3406
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303407 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408
3409#ifdef WLAN_FEATURE_11W
3410 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3411#endif
3412
3413 nStatus = dot11f_pack_tpc_report(pMac, &frm, pFrame +
3414 sizeof(tSirMacMgmtHdr),
3415 nPayload, &nPayload);
3416 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003417 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 nStatus);
3419 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3420 (void *)pFrame, (void *)pPacket);
3421 return eSIR_FAILURE; /* allocated! */
3422 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003423 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3424 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303426 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 ((psessionEntry) ? psessionEntry->
3428 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303429 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3431 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003432 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303433 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003434 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3435 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
3436 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303437 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003438 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303439 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 /* Pkt will be freed up by the callback */
3441 return eSIR_FAILURE; /* just allocated... */
3442 }
3443
3444 return eSIR_SUCCESS;
3445
3446} /* End lim_send_tpc_report_frame. */
3447#endif /* ANI_SUPPORT_11H */
3448
3449/**
3450 * \brief Send a Channel Switch Announcement
3451 *
3452 *
3453 * \param pMac Pointer to the global MAC datastructure
3454 *
3455 * \param peer MAC address to which this frame will be sent
3456 *
3457 * \param nMode
3458 *
3459 * \param nNewChannel
3460 *
3461 * \param nCount
3462 *
3463 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3464 *
3465 *
3466 */
3467
3468tSirRetStatus
3469lim_send_channel_switch_mgmt_frame(tpAniSirGlobal pMac,
3470 tSirMacAddr peer,
3471 uint8_t nMode,
3472 uint8_t nNewChannel,
3473 uint8_t nCount, tpPESession psessionEntry)
3474{
3475 tDot11fChannelSwitch frm;
3476 uint8_t *pFrame;
3477 tpSirMacMgmtHdr pMacHdr;
3478 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3479 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303480 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 uint8_t txFlag = 0;
3482
3483 uint8_t smeSessionId = 0;
3484
3485 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003486 pe_err("Session entry is NULL!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 return eSIR_FAILURE;
3488 }
3489 smeSessionId = psessionEntry->smeSessionId;
3490
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303491 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492
3493 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3494 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3495 frm.ChanSwitchAnn.switchMode = nMode;
3496 frm.ChanSwitchAnn.newChannel = nNewChannel;
3497 frm.ChanSwitchAnn.switchCount = nCount;
3498 frm.ChanSwitchAnn.present = 1;
3499
3500 nStatus = dot11f_get_packed_channel_switch_size(pMac, &frm, &nPayload);
3501 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003502 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 nStatus);
3504 /* We'll fall back on the worst case scenario: */
3505 nPayload = sizeof(tDot11fChannelSwitch);
3506 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003507 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3508 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509 }
3510
3511 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3512
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303513 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3515 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303516 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003517 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 return eSIR_FAILURE;
3519 }
3520 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303521 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522
3523 /* Next, we fill out the buffer descriptor: */
3524 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3525 SIR_MAC_MGMT_ACTION, peer,
3526 psessionEntry->selfMacAddr);
3527 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303528 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3530
3531#ifdef WLAN_FEATURE_11W
3532 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3533#endif
3534
3535 nStatus = dot11f_pack_channel_switch(pMac, &frm, pFrame +
3536 sizeof(tSirMacMgmtHdr),
3537 nPayload, &nPayload);
3538 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003539 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540 nStatus);
3541 cds_packet_free((void *)pPacket);
3542 return eSIR_FAILURE; /* allocated! */
3543 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003544 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3545 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 }
3547
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003548 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303549 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3550 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 ) {
3552 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3553 }
3554
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303555 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303557 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 TXRX_FRM_802_11_MGMT,
3559 ANI_TXDIR_TODS,
3560 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003561 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303562 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303563 psessionEntry->peSessionId, qdf_status));
3564 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003565 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303566 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 /* Pkt will be freed up by the callback */
3568 return eSIR_FAILURE;
3569 }
3570
3571 return eSIR_SUCCESS;
3572
3573} /* End lim_send_channel_switch_mgmt_frame. */
3574
Abhishek Singh518323d2015-10-19 17:42:01 +05303575/**
3576 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3577 * action frame over the air .
3578 * @mac_ctx: pointer to global mac structure
3579 * @peer: Destination mac.
3580 * @mode: channel switch mode
3581 * @new_op_class: new op class
3582 * @new_channel: new channel to switch
3583 * @count: channel switch count
3584 *
3585 * This function is called to send ECSA frame.
3586 *
3587 * Return: success if frame is sent else return failure
3588 */
3589
3590tSirRetStatus
3591lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
3592 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
3593 uint8_t new_channel, uint8_t count, tpPESession session_entry)
3594{
3595 tDot11fext_channel_switch_action_frame frm;
3596 uint8_t *frame;
3597 tpSirMacMgmtHdr mac_hdr;
3598 uint32_t num_bytes, n_payload, status;
3599 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303600 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303601 uint8_t txFlag = 0;
3602 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303603 uint8_t ch_spacing;
3604 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303605
3606 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003607 pe_err("Session entry is NULL!!!");
Abhishek Singh518323d2015-10-19 17:42:01 +05303608 return eSIR_FAILURE;
3609 }
3610
3611 sme_session_id = session_entry->smeSessionId;
3612
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303613 qdf_mem_set(&frm, sizeof(frm), 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303614
3615 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3616 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3617
3618 frm.ext_chan_switch_ann_action.switch_mode = mode;
3619 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3620 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3621 frm.ext_chan_switch_ann_action.switch_count = count;
3622
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303623 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3624 mac_ctx->scan.countryCodeCurrent, new_channel,
3625 new_op_class);
3626 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3627
3628 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3629 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3630 frm.WiderBWChanSwitchAnn.newChanWidth =
3631 wide_bw_ie->newChanWidth;
3632 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3633 wide_bw_ie->newCenterChanFreq0;
3634 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3635 wide_bw_ie->newCenterChanFreq1;
3636 frm.WiderBWChanSwitchAnn.present = 1;
3637 pe_debug("wrapper: width:%d f0:%d f1:%d",
3638 frm.WiderBWChanSwitchAnn.newChanWidth,
3639 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3640 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3641 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303642
3643 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3644 &frm, &n_payload);
3645 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003646 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303647 status);
3648 /* We'll fall back on the worst case scenario*/
3649 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3650 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003651 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303652 status);
3653 }
3654
3655 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3656
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303657 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303658 (void **) &frame, (void **) &packet);
3659
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303660 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003661 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303662 num_bytes);
3663 return eSIR_FAILURE;
3664 }
3665
3666 /* Paranoia*/
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303667 qdf_mem_set(frame, num_bytes, 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303668
3669 /* Next, we fill out the buffer descriptor */
3670 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3671 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3672 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303673 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303674 (uint8_t *) session_entry->bssId,
3675 sizeof(tSirMacAddr));
3676
3677 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3678 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3679 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003680 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303681 cds_packet_free((void *)packet);
3682 return eSIR_FAILURE;
3683 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003684 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303685 status);
3686 }
3687
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003688 if ((BAND_5G ==
Abhishek Singh518323d2015-10-19 17:42:01 +05303689 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303690 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3691 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303692 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3693 }
3694
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003695 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 +05303696 MAC_ADDR_ARRAY(mac_hdr->da),
3697 frm.ext_chan_switch_ann_action.switch_count,
3698 frm.ext_chan_switch_ann_action.switch_mode,
3699 frm.ext_chan_switch_ann_action.new_channel,
3700 frm.ext_chan_switch_ann_action.op_class);
3701
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303702 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303703 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303704 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303705 TXRX_FRM_802_11_MGMT,
3706 ANI_TXDIR_TODS,
3707 7,
3708 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003709 txFlag, sme_session_id, 0,
3710 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303711 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303712 session_entry->peSessionId, qdf_status));
3713 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003714 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303715 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303716 /* Pkt will be freed up by the callback */
3717 return eSIR_FAILURE;
3718 }
3719 return eSIR_SUCCESS;
3720} /* End lim_send_extended_chan_switch_action_frame */
3721
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303722
3723/**
3724 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3725 * sent over the air
3726 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303727 * @context: pointer to global mac
3728 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303729 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303730 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303731 *
3732 * Return: This returns QDF_STATUS
3733 */
3734
3735static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303736 void *context,
3737 qdf_nbuf_t buf,
3738 uint32_t tx_complete,
3739 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303740{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003741 pe_debug("tx_complete: %d", tx_complete);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303742 return QDF_STATUS_SUCCESS;
3743}
3744
3745/**
3746 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3747 * p2p oper chan change confirm action frame
3748 * @mac_ctx: pointer to global mac structure
3749 * @peer: Destination mac.
3750 * @session_entry: session entry
3751 *
3752 * This function is called to send p2p oper chan change confirm action frame.
3753 *
3754 * Return: success if frame is sent else return failure
3755 */
3756
3757tSirRetStatus
3758lim_p2p_oper_chan_change_confirm_action_frame(tpAniSirGlobal mac_ctx,
3759 tSirMacAddr peer, tpPESession session_entry)
3760{
3761 tDot11fp2p_oper_chan_change_confirm frm;
3762 uint8_t *frame;
3763 tpSirMacMgmtHdr mac_hdr;
3764 uint32_t num_bytes, n_payload, status;
3765 void *packet;
3766 QDF_STATUS qdf_status;
3767 uint8_t tx_flag = 0;
3768 uint8_t sme_session_id = 0;
3769
3770 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003771 pe_err("Session entry is NULL!!!");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303772 return eSIR_FAILURE;
3773 }
3774
3775 sme_session_id = session_entry->smeSessionId;
3776
3777 qdf_mem_set(&frm, sizeof(frm), 0);
3778
3779 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3780
3781 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3782 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3783 frm.p2p_action_subtype.subtype = 0x04;
3784 frm.DialogToken.token = 0x0;
3785
3786 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003787 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303788 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3789 }
3790
3791 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003792 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303793 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3794 populate_dot11f_operating_mode(mac_ctx,
3795 &frm.OperatingMode, session_entry);
3796 }
3797
3798 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3799 &frm, &n_payload);
3800 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003801 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303802 /* We'll fall back on the worst case scenario*/
3803 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3804 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003805 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3806 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303807 }
3808
3809 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3810
3811 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3812 (void **) &frame, (void **) &packet);
3813
3814 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003815 pe_err("Failed to allocate %d bytes", num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303816 return eSIR_FAILURE;
3817 }
3818
3819 qdf_mem_set(frame, num_bytes, 0);
3820
3821 /* Next, fill out the buffer descriptor */
3822 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3823 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3824 mac_hdr = (tpSirMacMgmtHdr) frame;
3825 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3826 (uint8_t *) session_entry->bssId,
3827 sizeof(tSirMacAddr));
3828
3829 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3830 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3831 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003832 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303833 cds_packet_free((void *)packet);
3834 return eSIR_FAILURE;
3835 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003836 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303837 status);
3838 }
3839
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003840 if ((BAND_5G ==
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303841 lim_get_rf_band(session_entry->currentOperChannel)) ||
3842 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3843 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
3844 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3845 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003846 pe_debug("Send frame on channel %d to mac "
3847 MAC_ADDRESS_STR, session_entry->currentOperChannel,
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303848 MAC_ADDR_ARRAY(peer));
3849
3850 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3851 session_entry->peSessionId, mac_hdr->fc.subType));
3852
3853 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3854 (uint16_t)num_bytes,
3855 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3856 7, lim_tx_complete, frame,
3857 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07003858 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303859
3860 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3861 session_entry->peSessionId, qdf_status));
3862 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003863 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303864 /* Pkt will be freed up by the callback */
3865 return eSIR_FAILURE;
3866 }
3867 return eSIR_SUCCESS;
3868}
3869
3870
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871tSirRetStatus
3872lim_send_vht_opmode_notification_frame(tpAniSirGlobal pMac,
3873 tSirMacAddr peer,
3874 uint8_t nMode, tpPESession psessionEntry)
3875{
3876 tDot11fOperatingMode frm;
3877 uint8_t *pFrame;
3878 tpSirMacMgmtHdr pMacHdr;
3879 uint32_t nBytes, nPayload = 0, nStatus; /* , nCfg; */
3880 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303881 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882 uint8_t txFlag = 0;
3883
3884 uint8_t smeSessionId = 0;
3885
3886 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003887 pe_err("Session entry is NULL!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 return eSIR_FAILURE;
3889 }
3890 smeSessionId = psessionEntry->smeSessionId;
3891
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303892 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003893
3894 frm.Category.category = SIR_MAC_ACTION_VHT;
3895 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
3896 frm.OperatingMode.chanWidth = nMode;
3897 frm.OperatingMode.rxNSS = 0;
3898 frm.OperatingMode.rxNSSType = 0;
3899
3900 nStatus = dot11f_get_packed_operating_mode_size(pMac, &frm, &nPayload);
3901 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003902 pe_err("Failed to calculate the packed size for a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903 nStatus);
3904 /* We'll fall back on the worst case scenario: */
3905 nPayload = sizeof(tDot11fOperatingMode);
3906 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003907 pe_warn("There were warnings while calculating the packed size for a Operating Mode (0x%08x)",
3908 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909 }
3910
3911 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3912
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303913 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3915 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303916 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003917 pe_err("Failed to allocate %d bytes for a Operating Mode Report",
3918 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 return eSIR_FAILURE;
3920 }
3921 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303922 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923
3924 /* Next, we fill out the buffer descriptor: */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303925 if (psessionEntry->pePersona == QDF_SAP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3927 SIR_MAC_MGMT_ACTION, peer,
3928 psessionEntry->selfMacAddr);
3929 else
3930 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3931 SIR_MAC_MGMT_ACTION, psessionEntry->bssId,
3932 psessionEntry->selfMacAddr);
3933 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303934 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003935 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3936 nStatus = dot11f_pack_operating_mode(pMac, &frm, pFrame +
3937 sizeof(tSirMacMgmtHdr),
3938 nPayload, &nPayload);
3939 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003940 pe_err("Failed to pack a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 nStatus);
3942 cds_packet_free((void *)pPacket);
3943 return eSIR_FAILURE; /* allocated! */
3944 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003945 pe_warn("There were warnings while packing a Operating Mode (0x%08x)",
3946 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003948 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303949 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3950 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003951 ) {
3952 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3953 }
3954
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303955 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003956 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303957 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003958 TXRX_FRM_802_11_MGMT,
3959 ANI_TXDIR_TODS,
3960 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003961 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303962 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303963 psessionEntry->peSessionId, qdf_status));
3964 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003965 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303966 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967 /* Pkt will be freed up by the callback */
3968 return eSIR_FAILURE;
3969 }
3970
3971 return eSIR_SUCCESS;
3972}
3973
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003974/**
3975 * \brief Send a Neighbor Report Request Action frame
3976 *
3977 *
3978 * \param pMac Pointer to the global MAC structure
3979 *
3980 * \param pNeighborReq Address of a tSirMacNeighborReportReq
3981 *
3982 * \param peer mac address of peer station.
3983 *
3984 * \param psessionEntry address of session entry.
3985 *
3986 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3987 *
3988 *
3989 */
3990
3991tSirRetStatus
3992lim_send_neighbor_report_request_frame(tpAniSirGlobal pMac,
3993 tpSirMacNeighborReportReq pNeighborReq,
3994 tSirMacAddr peer, tpPESession psessionEntry)
3995{
3996 tSirRetStatus statusCode = eSIR_SUCCESS;
3997 tDot11fNeighborReportRequest frm;
3998 uint8_t *pFrame;
3999 tpSirMacMgmtHdr pMacHdr;
4000 uint32_t nBytes, nPayload, nStatus;
4001 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304002 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 uint8_t txFlag = 0;
4004 uint8_t smeSessionId = 0;
4005
4006 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004007 pe_err("(psession == NULL) in Request to send Neighbor Report request action frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008 return eSIR_FAILURE;
4009 }
4010 smeSessionId = psessionEntry->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304011 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004012
4013 frm.Category.category = SIR_MAC_ACTION_RRM;
4014 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
4015 frm.DialogToken.token = pNeighborReq->dialogToken;
4016
4017 if (pNeighborReq->ssid_present) {
4018 populate_dot11f_ssid(pMac, &pNeighborReq->ssid, &frm.SSID);
4019 }
4020
4021 nStatus =
4022 dot11f_get_packed_neighbor_report_request_size(pMac, &frm, &nPayload);
4023 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004024 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 nStatus);
4026 /* We'll fall back on the worst case scenario: */
4027 nPayload = sizeof(tDot11fNeighborReportRequest);
4028 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004029 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4030 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031 }
4032
4033 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4034
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304035 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4037 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304038 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004039 pe_err("Failed to allocate %d bytes for a Neighbor "
4040 "Report Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041 return eSIR_FAILURE;
4042 }
4043 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304044 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045
4046 /* Copy necessary info to BD */
4047 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4048 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4049
4050 /* Update A3 with the BSSID */
4051 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4052
4053 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4054
4055#ifdef WLAN_FEATURE_11W
4056 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4057#endif
4058
4059 /* Now, we're ready to "pack" the frames */
4060 nStatus = dot11f_pack_neighbor_report_request(pMac,
4061 &frm,
4062 pFrame +
4063 sizeof(tSirMacMgmtHdr),
4064 nPayload, &nPayload);
4065
4066 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004067 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004068 nStatus);
4069
4070 /* FIXME - Need to convert to tSirRetStatus */
4071 statusCode = eSIR_FAILURE;
4072 goto returnAfterError;
4073 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004074 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4075 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 }
4077
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004078 pe_debug("Sending a Neighbor Report Request to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +05304079 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004081 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304082 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4083 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 ) {
4085 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4086 }
4087
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304088 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304090 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 pPacket,
4092 (uint16_t) nBytes,
4093 TXRX_FRM_802_11_MGMT,
4094 ANI_TXDIR_TODS,
4095 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004096 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304097 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304098 psessionEntry->peSessionId, qdf_status));
4099 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004100 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 statusCode = eSIR_FAILURE;
4102 /* Pkt will be freed up by the callback */
4103 return statusCode;
4104 } else
4105 return eSIR_SUCCESS;
4106
4107returnAfterError:
4108 cds_packet_free((void *)pPacket);
4109
4110 return statusCode;
4111} /* End lim_send_neighbor_report_request_frame. */
4112
4113/**
4114 * \brief Send a Link Report Action frame
4115 *
4116 *
4117 * \param pMac Pointer to the global MAC structure
4118 *
4119 * \param pLinkReport Address of a tSirMacLinkReport
4120 *
4121 * \param peer mac address of peer station.
4122 *
4123 * \param psessionEntry address of session entry.
4124 *
4125 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4126 *
4127 *
4128 */
4129
4130tSirRetStatus
4131lim_send_link_report_action_frame(tpAniSirGlobal pMac,
4132 tpSirMacLinkReport pLinkReport,
4133 tSirMacAddr peer, tpPESession psessionEntry)
4134{
4135 tSirRetStatus statusCode = eSIR_SUCCESS;
4136 tDot11fLinkMeasurementReport frm;
4137 uint8_t *pFrame;
4138 tpSirMacMgmtHdr pMacHdr;
4139 uint32_t nBytes, nPayload, nStatus;
4140 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304141 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142 uint8_t txFlag = 0;
4143 uint8_t smeSessionId = 0;
4144
4145 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004146 pe_err("(psession == NULL) in Request to send Link Report action frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 return eSIR_FAILURE;
4148 }
4149
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304150 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004151
4152 frm.Category.category = SIR_MAC_ACTION_RRM;
4153 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
4154 frm.DialogToken.token = pLinkReport->dialogToken;
4155
4156 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4157 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4158 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4159 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4160 /* such case this way than changing the frame parser. */
4161 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
4162 frm.TPCEleLen.TPCLen = 2;
4163 frm.TxPower.txPower = pLinkReport->txPower;
4164 frm.LinkMargin.linkMargin = 0;
4165
4166 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4167 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4168 frm.RCPI.rcpi = pLinkReport->rcpi;
4169 frm.RSNI.rsni = pLinkReport->rsni;
4170
4171 nStatus =
4172 dot11f_get_packed_link_measurement_report_size(pMac, &frm, &nPayload);
4173 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004174 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175 /* We'll fall back on the worst case scenario: */
4176 nPayload = sizeof(tDot11fLinkMeasurementReport);
4177 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004178 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4179 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 }
4181
4182 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4183
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304184 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4186 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304187 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004188 pe_err("Failed to allocate %d bytes for a Link "
4189 "Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190 return eSIR_FAILURE;
4191 }
4192 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304193 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194
4195 /* Copy necessary info to BD */
4196 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4197 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4198
4199 /* Update A3 with the BSSID */
4200 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4201
4202 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4203
4204#ifdef WLAN_FEATURE_11W
4205 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4206#endif
4207
4208 /* Now, we're ready to "pack" the frames */
4209 nStatus = dot11f_pack_link_measurement_report(pMac,
4210 &frm,
4211 pFrame +
4212 sizeof(tSirMacMgmtHdr),
4213 nPayload, &nPayload);
4214
4215 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004216 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004217
4218 /* FIXME - Need to convert to tSirRetStatus */
4219 statusCode = eSIR_FAILURE;
4220 goto returnAfterError;
4221 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004222 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223 nStatus);
4224 }
4225
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004226 pe_warn("Sending a Link Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 lim_print_mac_addr(pMac, peer, LOGW);
4228
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004229 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304230 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4231 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4233 }
4234
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304235 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304237 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238 pPacket,
4239 (uint16_t) nBytes,
4240 TXRX_FRM_802_11_MGMT,
4241 ANI_TXDIR_TODS,
4242 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004243 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304244 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304245 psessionEntry->peSessionId, qdf_status));
4246 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004247 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248 statusCode = eSIR_FAILURE;
4249 /* Pkt will be freed up by the callback */
4250 return statusCode;
4251 } else
4252 return eSIR_SUCCESS;
4253
4254returnAfterError:
4255 cds_packet_free((void *)pPacket);
4256
4257 return statusCode;
4258} /* End lim_send_link_report_action_frame. */
4259
4260/**
4261 * \brief Send a Beacon Report Action frame
4262 *
4263 *
4264 * \param pMac Pointer to the global MAC structure
4265 *
4266 * \param dialog_token dialog token to be used in the action frame.
4267 *
4268 * \param num_report number of reports in pRRMReport.
4269 *
4270 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
4271 *
4272 * \param peer mac address of peer station.
4273 *
4274 * \param psessionEntry address of session entry.
4275 *
4276 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4277 *
4278 *
4279 */
4280
4281tSirRetStatus
4282lim_send_radio_measure_report_action_frame(tpAniSirGlobal pMac,
4283 uint8_t dialog_token,
4284 uint8_t num_report,
4285 tpSirMacRadioMeasureReport pRRMReport,
4286 tSirMacAddr peer,
4287 tpPESession psessionEntry)
4288{
4289 tSirRetStatus statusCode = eSIR_SUCCESS;
4290 uint8_t *pFrame;
4291 tpSirMacMgmtHdr pMacHdr;
4292 uint32_t nBytes, nPayload, nStatus;
4293 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304294 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295 uint8_t i;
4296 uint8_t txFlag = 0;
4297 uint8_t smeSessionId = 0;
4298
4299 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304300 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301 if (!frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004302 pe_err("Not enough memory to allocate tDot11fRadioMeasurementReport");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004303 return eSIR_MEM_ALLOC_FAILED;
4304 }
4305
4306 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004307 pe_err("(psession == NULL) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304308 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 return eSIR_FAILURE;
4310 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004312 smeSessionId = psessionEntry->smeSessionId;
4313
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004314 pe_debug("dialog_token %d num_report %d",
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304315 dialog_token, num_report);
4316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317 frm->Category.category = SIR_MAC_ACTION_RRM;
4318 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4319 frm->DialogToken.token = dialog_token;
4320
4321 frm->num_MeasurementReport =
4322 (num_report >
4323 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4324 num_report;
4325
4326 for (i = 0; i < frm->num_MeasurementReport; i++) {
4327 frm->MeasurementReport[i].type = pRRMReport[i].type;
4328 frm->MeasurementReport[i].token = pRRMReport[i].token;
4329 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4330 switch (pRRMReport[i].type) {
4331 case SIR_MAC_RRM_BEACON_TYPE:
4332 populate_dot11f_beacon_report(pMac,
4333 &frm->MeasurementReport[i],
4334 &pRRMReport[i].report.
4335 beaconReport);
4336 frm->MeasurementReport[i].incapable =
4337 pRRMReport[i].incapable;
4338 frm->MeasurementReport[i].refused =
4339 pRRMReport[i].refused;
4340 frm->MeasurementReport[i].present = 1;
4341 break;
4342 default:
4343 frm->MeasurementReport[i].incapable =
4344 pRRMReport[i].incapable;
4345 frm->MeasurementReport[i].refused =
4346 pRRMReport[i].refused;
4347 frm->MeasurementReport[i].present = 1;
4348 break;
4349 }
4350 }
4351
4352 nStatus =
4353 dot11f_get_packed_radio_measurement_report_size(pMac, frm, &nPayload);
4354 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004355 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004356 nStatus);
4357 /* We'll fall back on the worst case scenario: */
4358 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304359 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004360 return eSIR_FAILURE;
4361 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004362 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4363 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 }
4365
4366 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4367
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304368 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4370 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304371 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004372 pe_err("Failed to allocate %d bytes for a Radio Measure "
4373 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304374 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 return eSIR_FAILURE;
4376 }
4377 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304378 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379
4380 /* Copy necessary info to BD */
4381 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4382 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4383
4384 /* Update A3 with the BSSID */
4385 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4386
4387 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4388
4389#ifdef WLAN_FEATURE_11W
4390 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4391#endif
4392
4393 /* Now, we're ready to "pack" the frames */
4394 nStatus = dot11f_pack_radio_measurement_report(pMac,
4395 frm,
4396 pFrame +
4397 sizeof(tSirMacMgmtHdr),
4398 nPayload, &nPayload);
4399
4400 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004401 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402 nStatus);
4403
4404 /* FIXME - Need to convert to tSirRetStatus */
4405 statusCode = eSIR_FAILURE;
4406 goto returnAfterError;
4407 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004408 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4409 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 }
4411
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004412 pe_warn("Sending a Radio Measure Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413 lim_print_mac_addr(pMac, peer, LOGW);
4414
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004415 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304416 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4417 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418 ) {
4419 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4420 }
4421
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304422 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304424 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 pPacket,
4426 (uint16_t) nBytes,
4427 TXRX_FRM_802_11_MGMT,
4428 ANI_TXDIR_TODS,
4429 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004430 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304431 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304432 psessionEntry->peSessionId, qdf_status));
4433 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004434 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 statusCode = eSIR_FAILURE;
4436 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304437 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 return statusCode;
4439 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304440 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 return eSIR_SUCCESS;
4442 }
4443
4444returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304445 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446 cds_packet_free((void *)pPacket);
4447 return statusCode;
4448}
4449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450#ifdef WLAN_FEATURE_11W
4451/**
4452 * \brief Send SA query request action frame to peer
4453 *
4454 * \sa lim_send_sa_query_request_frame
4455 *
4456 *
4457 * \param pMac The global tpAniSirGlobal object
4458 *
4459 * \param transId Transaction identifier
4460 *
4461 * \param peer The Mac address of the station to which this action frame is addressed
4462 *
4463 * \param psessionEntry The PE session entry
4464 *
4465 * \return eSIR_SUCCESS if setup completes successfully
4466 * eSIR_FAILURE is some problem is encountered
4467 */
4468
4469tSirRetStatus lim_send_sa_query_request_frame(tpAniSirGlobal pMac, uint8_t *transId,
4470 tSirMacAddr peer,
4471 tpPESession psessionEntry)
4472{
4473
4474 tDot11fSaQueryReq frm; /* SA query request action frame */
4475 uint8_t *pFrame;
4476 tSirRetStatus nSirStatus;
4477 tpSirMacMgmtHdr pMacHdr;
4478 uint32_t nBytes, nPayload, nStatus;
4479 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304480 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 uint8_t txFlag = 0;
4482 uint8_t smeSessionId = 0;
4483
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304484 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4486 /* 11w action field is :
4487 action: 0 --> SA Query Request action frame
4488 action: 1 --> SA Query Response action frame */
4489 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4490 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304491 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492
4493 nStatus = dot11f_get_packed_sa_query_req_size(pMac, &frm, &nPayload);
4494 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004495 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 nStatus);
4497 /* We'll fall back on the worst case scenario: */
4498 nPayload = sizeof(tDot11fSaQueryReq);
4499 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004500 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4501 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 }
4503
4504 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304505 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004506 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304507 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004508 pe_err("Failed to allocate %d bytes for a SA Query Request "
4509 "action frame", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510 return eSIR_FAILURE;
4511 }
4512 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304513 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514
4515 /* Copy necessary info to BD */
4516 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4517 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4518
4519 /* Update A3 with the BSSID */
4520 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4521
4522 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4523
4524 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4525 /* in the FC */
4526 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4527
4528 /* Pack 11w SA Query Request frame */
4529 nStatus = dot11f_pack_sa_query_req(pMac,
4530 &frm,
4531 pFrame + sizeof(tSirMacMgmtHdr),
4532 nPayload, &nPayload);
4533
4534 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004535 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004536 nStatus);
4537 /* FIXME - Need to convert to tSirRetStatus */
4538 nSirStatus = eSIR_FAILURE;
4539 goto returnAfterError;
4540 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004541 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542 nStatus);
4543 }
4544
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004545 pe_debug("Sending an SA Query Request to");
4546 lim_print_mac_addr(pMac, peer, LOGD);
4547 pe_debug("Sending an SA Query Request from ");
4548 lim_print_mac_addr(pMac, psessionEntry->selfMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004550 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304552 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4553 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554#endif
4555 ) {
4556 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4557 }
4558 smeSessionId = psessionEntry->smeSessionId;
4559
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304560 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 pPacket,
4562 (uint16_t) nBytes,
4563 TXRX_FRM_802_11_MGMT,
4564 ANI_TXDIR_TODS,
4565 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004566 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304567 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004568 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 nSirStatus = eSIR_FAILURE;
4570 /* Pkt will be freed up by the callback */
4571 return nSirStatus;
4572 } else {
4573 return eSIR_SUCCESS;
4574 }
4575
4576returnAfterError:
4577 cds_packet_free((void *)pPacket);
4578 return nSirStatus;
4579} /* End lim_send_sa_query_request_frame */
4580
4581/**
4582 * \brief Send SA query response action frame to peer
4583 *
4584 * \sa lim_send_sa_query_response_frame
4585 *
4586 *
4587 * \param pMac The global tpAniSirGlobal object
4588 *
4589 * \param transId Transaction identifier received in SA query request action frame
4590 *
4591 * \param peer The Mac address of the AP to which this action frame is addressed
4592 *
4593 * \param psessionEntry The PE session entry
4594 *
4595 * \return eSIR_SUCCESS if setup completes successfully
4596 * eSIR_FAILURE is some problem is encountered
4597 */
4598
4599tSirRetStatus lim_send_sa_query_response_frame(tpAniSirGlobal pMac,
4600 uint8_t *transId, tSirMacAddr peer,
4601 tpPESession psessionEntry)
4602{
4603
4604 tDot11fSaQueryRsp frm; /* SA query reponse action frame */
4605 uint8_t *pFrame;
4606 tSirRetStatus nSirStatus;
4607 tpSirMacMgmtHdr pMacHdr;
4608 uint32_t nBytes, nPayload, nStatus;
4609 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304610 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 uint8_t txFlag = 0;
4612 uint8_t smeSessionId = 0;
4613
4614 smeSessionId = psessionEntry->smeSessionId;
4615
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304616 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4618 /*11w action field is :
4619 action: 0 --> SA query request action frame
4620 action: 1 --> SA query response action frame */
4621 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4622 /*11w SA query response transId is same as
4623 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304624 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625
4626 nStatus = dot11f_get_packed_sa_query_rsp_size(pMac, &frm, &nPayload);
4627 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004628 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 nStatus);
4630 /* We'll fall back on the worst case scenario: */
4631 nPayload = sizeof(tDot11fSaQueryRsp);
4632 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004633 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4634 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 }
4636
4637 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304638 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304640 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004641 pe_err("Failed to allocate %d bytes for a SA query response"
4642 " action frame", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 return eSIR_FAILURE;
4644 }
4645 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304646 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647
4648 /* Copy necessary info to BD */
4649 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4650 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4651
4652 /* Update A3 with the BSSID */
4653 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4654
4655 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4656
4657 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4658 /* in the FC */
4659 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4660
4661 /* Pack 11w SA query response frame */
4662 nStatus = dot11f_pack_sa_query_rsp(pMac,
4663 &frm,
4664 pFrame + sizeof(tSirMacMgmtHdr),
4665 nPayload, &nPayload);
4666
4667 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004668 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004669 nStatus);
4670 /* FIXME - Need to convert to tSirRetStatus */
4671 nSirStatus = eSIR_FAILURE;
4672 goto returnAfterError;
4673 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004674 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 nStatus);
4676 }
4677
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004678 pe_debug("Sending a SA Query Response to");
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07004679 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004681 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304683 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4684 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004685#endif
4686 ) {
4687 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4688 }
4689
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304690 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304692 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 pPacket,
4694 (uint16_t) nBytes,
4695 TXRX_FRM_802_11_MGMT,
4696 ANI_TXDIR_TODS,
4697 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004698 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304699 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304700 psessionEntry->peSessionId, qdf_status));
4701 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004702 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 nSirStatus = eSIR_FAILURE;
4704 /* Pkt will be freed up by the callback */
4705 return nSirStatus;
4706 } else {
4707 return eSIR_SUCCESS;
4708 }
4709
4710returnAfterError:
4711 cds_packet_free((void *)pPacket);
4712 return nSirStatus;
4713} /* End lim_send_sa_query_response_frame */
4714#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004715
4716/**
4717 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4718 * @mac_ctx: mac context
4719 * @peer_mac: Peer MAC address
4720 * @tid: TID for which addba response is being sent
4721 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004722 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004723 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004724 *
4725 * This function is called when ADDBA request is successful. ADDBA response is
4726 * setup by calling addba_response_setup API and frame is then sent out OTA.
4727 *
4728 * Return: QDF_STATUS
4729 */
4730QDF_STATUS lim_send_addba_response_frame(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004731 tSirMacAddr peer_mac, uint16_t tid,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004732 tpPESession session, uint8_t addba_extn_present,
4733 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004734{
4735
4736 tDot11faddba_rsp frm;
4737 uint8_t *frame_ptr;
4738 tpSirMacMgmtHdr mgmt_hdr;
4739 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004740 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004741 QDF_STATUS qdf_status;
4742 uint8_t tx_flag = 0;
4743 uint8_t sme_sessionid = 0;
4744 uint16_t buff_size, status_code, batimeout;
4745 uint8_t peer_id, dialog_token;
4746 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4747 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004748 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004749
4750 sme_sessionid = session->smeSessionId;
4751
4752 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4753 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004754 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004755 return QDF_STATUS_E_FAILURE;
4756 }
4757
Mohit Khannac4c22252017-11-20 11:06:33 -08004758 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4759 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004760 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004761 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004762 return QDF_STATUS_E_FAILURE;
4763 }
4764
4765 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4766 &status_code, &buff_size, &batimeout);
4767
Mohit Khannac4c22252017-11-20 11:06:33 -08004768 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004769 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
4770 frm.Category.category = SIR_MAC_ACTION_BLKACK;
4771 frm.Action.action = SIR_MAC_ADDBA_RSP;
4772
4773 frm.DialogToken.token = dialog_token;
4774 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004775 if (mac_ctx->reject_addba_req) {
4776 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4777 pe_err("refused addba req");
4778 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004779 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere96180e12018-03-12 17:58:23 -07004780 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004781 if (mac_ctx->usr_cfg_ba_buff_size)
4782 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Arif Hussain0e246802018-05-01 18:13:44 -07004783 if (mac_ctx->is_usr_cfg_amsdu_enabled)
4784 frm.addba_param_set.amsdu_supp = amsdu_support;
4785 else
4786 frm.addba_param_set.amsdu_supp = 0;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004787 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004788 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004789 if (addba_extn_present) {
4790 frm.addba_extn_element.present = 1;
4791 frm.addba_extn_element.no_fragmentation = 1;
4792 if (lim_is_session_he_capable(session)) {
4793 he_frag = lim_get_session_he_frag_cap(session);
4794 if (he_frag != 0) {
4795 frm.addba_extn_element.no_fragmentation = 0;
4796 frm.addba_extn_element.he_frag_operation =
4797 he_frag;
4798 }
4799 }
4800 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004801
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004802 pe_debug("Sending a ADDBA Response from %pM to %pM",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004803 session->selfMacAddr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004804 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004805 tid, frm.DialogToken.token, frm.Status.status,
4806 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004807 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4808 addba_extn_present,
4809 lim_is_session_he_capable(session),
4810 frm.addba_extn_element.no_fragmentation,
4811 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004812
4813 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4814 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004815 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004816 status);
4817 /* We'll fall back on the worst case scenario: */
4818 payload_size = sizeof(tDot11faddba_rsp);
4819 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004820 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 -08004821 }
4822
4823 num_bytes = payload_size + sizeof(*mgmt_hdr);
4824 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4825 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004826 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004827 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4828 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004829 return QDF_STATUS_E_FAILURE;
4830 }
4831 qdf_mem_set(frame_ptr, num_bytes, 0);
4832
4833 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
4834 SIR_MAC_MGMT_ACTION, peer_mac, session->selfMacAddr);
4835
4836 /* Update A3 with the BSSID */
4837 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4838 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4839
4840 /* ADDBA Response is a robust mgmt action frame,
4841 * set the "protect" (aka WEP) bit in the FC
4842 */
4843 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4844
4845 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4846 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4847 &payload_size);
4848
4849 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004850 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004851 status);
4852 qdf_status = QDF_STATUS_E_FAILURE;
4853 goto error_addba_rsp;
4854 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004855 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004856 status);
4857 }
4858
4859
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004860 if ((BAND_5G == lim_get_rf_band(session->currentOperChannel))
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004861#ifdef WLAN_FEATURE_P2P
4862 || (session->pePersona == QDF_P2P_CLIENT_MODE) ||
4863 (session->pePersona == QDF_P2P_GO_MODE)
4864#endif
4865 ) {
4866 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4867 }
4868
4869 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4870 session->peSessionId, mgmt_hdr->fc.subType));
4871 qdf_status = wma_tx_frame(mac_ctx, pkt_ptr, (uint16_t) num_bytes,
4872 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07004873 lim_tx_complete, frame_ptr, tx_flag, sme_sessionid, 0,
4874 RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004875 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4876 session->peSessionId, qdf_status));
4877 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004878 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004879 qdf_status);
4880 qdf_status = QDF_STATUS_E_FAILURE;
4881 /*
4882 * wma_tx_frame free memory in certain cases, free pkt_ptr
4883 * only if not freed already.
4884 */
4885 if (pkt_ptr)
4886 cds_packet_free((void *)pkt_ptr);
4887 return qdf_status;
4888 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004889 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004890 }
4891
4892error_addba_rsp:
4893 cds_packet_free((void *)pkt_ptr);
4894 return qdf_status;
4895}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304896
4897/**
4898 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4899 * @mac_ctx Pointer to Global MAC structure
4900 * @mb_msg: Received message info
4901 * @msg_len: Received message length
4902 * @packet: Packet to be transmitted
4903 * @frame: Received frame
4904 *
4905 * Return: None
4906 */
4907static void lim_tx_mgmt_frame(tpAniSirGlobal mac_ctx,
4908 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
4909 void *packet, uint8_t *frame)
4910{
4911 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4912 QDF_STATUS qdf_status;
4913 uint8_t sme_session_id = 0;
4914 tpPESession session;
4915 uint16_t auth_ack_status;
4916 enum rateid min_rid = RATEID_DEFAULT;
4917
4918 sme_session_id = mb_msg->session_id;
4919 session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
4920 if (session == NULL) {
4921 pe_err("session not found for given sme session");
4922 return;
4923 }
4924
4925 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4926 session->peSessionId, fc->subType));
4927
4928 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
4929 min_rid = lim_get_min_session_txrate(session);
4930
4931 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4932 (uint16_t)msg_len,
4933 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4934 7, lim_tx_complete, frame,
4935 lim_auth_tx_complete_cnf,
4936 0, sme_session_id, false, 0, min_rid);
4937 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4938 session->peSessionId, qdf_status));
4939 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05304940 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
4941 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304942 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
4943 auth_ack_status = SENT_FAIL;
4944 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
4945 session, auth_ack_status, eSIR_FAILURE);
4946 /* Pkt will be freed up by the callback */
4947 }
4948}
4949
4950void lim_send_mgmt_frame_tx(tpAniSirGlobal mac_ctx,
4951 struct scheduler_msg *msg)
4952{
4953 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
4954 uint32_t msg_len;
4955 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4956 uint8_t sme_session_id;
4957 QDF_STATUS qdf_status;
4958 uint8_t *frame;
4959 void *packet;
4960
4961 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
4962 pe_debug("sending fc->type: %d fc->subType: %d",
4963 fc->type, fc->subType);
4964
4965 sme_session_id = mb_msg->session_id;
4966
4967 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
4968 (void **)&packet);
4969 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4970 pe_err("call to bufAlloc failed for AUTH frame");
4971 return;
4972 }
4973
4974 qdf_mem_copy(frame, mb_msg->data, msg_len);
4975
4976 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
4977}