blob: 230e942311b3bffdc1761dd9da15c089f738bd0c [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 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700197 * Return: QDF_STATUS (QDF_STATUS_SUCCESS on success and error codes otherwise)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700199QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800200lim_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;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700223 QDF_STATUS 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 &&
Abhinav Kumare057b412018-10-09 17:28:16 +0530234 !mac_ctx->mlme_cfg->vht_caps.vht_cap_info.b24ghz_band &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 (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);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700357 if (QDF_STATUS_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 */
Wu Gao93816212018-08-31 16:49:54 +0800378 if (mac_ctx->mlme_cfg->sta.qcn_ie_support && !qcn_ie)
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530379 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);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700408 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 }
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);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700424 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 } 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 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700458 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 }
460
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700461 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462} /* End lim_send_probe_req_mgmt_frame. */
463
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700464static QDF_STATUS 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");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700479 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 }
481
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530482 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700483 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700484 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485
486 while (left >= 2) {
487 elem_id = ptr[0];
488 elem_len = ptr[1];
489 left -= 2;
490 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700491 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530493 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700494 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495 }
496 if (!((SIR_MAC_EID_VENDOR == elem_id) &&
497 (memcmp
498 (&ptr[2], SIR_MAC_P2P_OUI,
499 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530500 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800501 elem_len + 2);
502 tempLen += (elem_len + 2);
503 }
504 left -= elem_len;
505 ptr += (elem_len + 2);
506 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530507 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530509 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700511 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512}
513
514/**
515 * lim_send_probe_rsp_mgmt_frame() - Send probe response
516 *
517 * @mac_ctx: Handle for mac context
518 * @peer_macaddr: Mac address of requesting peer
519 * @ssid: SSID for response
520 * @n_staid: Station ID, currently unused.
521 * @pe_session: PE session id
522 * @keepalive: Keep alive flag. Currently unused.
523 * @preq_p2pie: P2P IE in incoming probe request
524 *
525 * Builds and sends probe response frame to the requesting peer
526 *
527 * Return: void
528 */
529
530void
531lim_send_probe_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
532 tSirMacAddr peer_macaddr,
533 tpAniSSID ssid,
534 short n_staid,
535 uint8_t keepalive,
536 tpPESession pe_session, uint8_t preq_p2pie)
537{
538 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700539 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800540 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800541 tpSirMacMgmtHdr mac_hdr;
542 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700543 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530544 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 uint32_t addn_ie_present = false;
546
547 uint16_t addn_ie_len = 0;
gaurank kathpalia837f6202018-09-14 21:55:32 +0530548 bool wps_ap = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549 uint8_t tx_flag = 0;
550 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700551 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800552 uint8_t noalen = 0;
553 uint8_t total_noalen = 0;
554 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
555 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
556 uint8_t sme_sessionid = 0;
557 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530558 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530559 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560
561 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700562 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800563 return;
564
565 if (NULL == pe_session)
566 return;
567
568 /*
569 * In case when cac timer is running for this SAP session then
570 * avoid sending probe rsp out. It is violation of dfs specification.
571 */
Anurag Chouhan6d760662016-02-20 16:05:43 +0530572 if (((pe_session->pePersona == QDF_SAP_MODE) ||
573 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530575 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 FL("CAC timer is running, probe response dropped"));
577 return;
578 }
579 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530580 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700581 if (!frm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800584 /*
585 * Fill out 'frm', after which we'll just hand the struct off to
586 * 'dot11f_pack_probe_response'.
587 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530588 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fProbeResponse), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589
590 /*
591 * Timestamp to be updated by TFP, below.
592 *
593 * Beacon Interval:
594 */
595 if (LIM_IS_AP_ROLE(pe_session)) {
596 frm->BeaconInterval.interval =
597 mac_ctx->sch.schObject.gSchBeaconInterval;
598 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530599 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600 frm->BeaconInterval.interval = (uint16_t) cfg;
601 }
602
603 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
604 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
605 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
606 &frm->SuppRates, pe_session);
607
608 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
609 pe_session->currentOperChannel);
610 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
611
612 if (LIM_IS_AP_ROLE(pe_session)) {
613 if (pe_session->wps_state != SAP_WPS_DISABLED)
614 populate_dot11f_probe_res_wpsi_es(mac_ctx,
615 &frm->WscProbeRes,
616 pe_session);
617 } else {
gaurank kathpalia837f6202018-09-14 21:55:32 +0530618 wps_ap = mac_ctx->mlme_cfg->wps_params.enable_wps &
619 WNI_CFG_WPS_ENABLE_AP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620 if (wps_ap)
621 populate_dot11f_wsc_in_probe_res(mac_ctx,
622 &frm->WscProbeRes);
623
624 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
625 eLIM_WSC_ENROLL_BEGIN) {
626 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
627 &frm->WscProbeRes);
628 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
629 eLIM_WSC_ENROLL_IN_PROGRESS;
630 }
631
632 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
633 eLIM_WSC_ENROLL_END) {
634 de_populate_dot11f_wsc_registrar_info_in_probe_res(
635 mac_ctx, &frm->WscProbeRes);
636 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
637 eLIM_WSC_ENROLL_NOOP;
638 }
639 }
640
641 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
642 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
643
644 if (pe_session->dot11mode != WNI_CFG_DOT11_MODE_11B)
645 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
646
647 populate_dot11f_ext_supp_rates(mac_ctx,
648 POPULATE_DOT11F_RATES_OPERATIONAL,
649 &frm->ExtSuppRates, pe_session);
650
651 /* Populate HT IEs, when operating in 11n */
652 if (pe_session->htCapability) {
653 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
654 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
655 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700657 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
659 populate_dot11f_vht_operation(mac_ctx, pe_session,
660 &frm->VHTOperation);
661 /*
662 * we do not support multi users yet.
663 * populate_dot11f_vht_ext_bss_load( mac_ctx,
664 * &frm.VHTExtBssLoad );
665 */
666 is_vht_enabled = true;
667 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800669 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700670 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800671 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700672 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800673 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700674 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800675 }
676
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
678 pe_session);
679
680 if (pe_session->pLimStartBssReq) {
681 populate_dot11f_wpa(mac_ctx,
682 &(pe_session->pLimStartBssReq->rsnIE),
683 &frm->WPA);
684 populate_dot11f_rsn_opaque(mac_ctx,
685 &(pe_session->pLimStartBssReq->rsnIE),
686 &frm->RSNOpaque);
687 }
688
689 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
690 &frm->WMMCaps, pe_session);
691
692#if defined(FEATURE_WLAN_WAPI)
693 if (pe_session->pLimStartBssReq)
694 populate_dot11f_wapi(mac_ctx,
695 &(pe_session->pLimStartBssReq->rsnIE),
696 &frm->WAPI);
697#endif /* defined(FEATURE_WLAN_WAPI) */
698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 if (mac_ctx->lim.gpLimRemainOnChanReq)
700 bytes += (mac_ctx->lim.gpLimRemainOnChanReq->length -
701 sizeof(tSirRemainOnChnReq));
702 else
703 /*
704 * Only use CFG for non-listen mode. This CFG is not working for
705 * concurrency. In listening mode, probe rsp IEs is passed in
706 * the message from SME to PE.
707 */
708 addn_ie_present =
709 (pe_session->addIeParams.probeRespDataLen != 0);
710
711 if (addn_ie_present) {
712
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530713 add_ie = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800714 pe_session->addIeParams.probeRespDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700715 if (!add_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800716 goto err_ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530718 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719 pe_session->addIeParams.probeRespData_buff,
720 pe_session->addIeParams.probeRespDataLen);
721 addn_ie_len = pe_session->addIeParams.probeRespDataLen;
722
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700723 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700725 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800726 goto err_ret;
727 }
728
729 sir_status = lim_strip_extcap_update_struct(mac_ctx,
730 add_ie, &addn_ie_len,
731 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700732 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700733 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530734 } else {
735 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 }
737
738 bytes = bytes + addn_ie_len;
739
740 if (preq_p2pie)
741 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
742 addn_ie_len);
743
744 if (p2p_ie != NULL) {
745 /* get NoA attribute stream P2P IE */
746 noalen = lim_get_noa_attr_stream(mac_ctx,
747 noa_stream, pe_session);
748 if (noalen != 0) {
749 total_noalen =
750 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
751 &noa_stream[0], noalen);
752 bytes = bytes + total_noalen;
753 }
754 }
755 }
756
Hu Wang411e0cc2016-10-28 14:56:01 +0800757 /*
758 * Extcap IE now support variable length, merge Extcap IE from addn_ie
759 * may change the frame size. Therefore, MUST merge ExtCap IE before
760 * dot11f get packed payload size.
761 */
762 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800763 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
764 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800765
766 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
767 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700768 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800769 status);
770 /* We'll fall back on the worst case scenario: */
771 payload = sizeof(tDot11fProbeResponse);
772 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700773 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800774 status);
775 }
776
777 bytes += payload + sizeof(tSirMacMgmtHdr);
778
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530779 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530781 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700782 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783 goto err_ret;
784 }
785 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530786 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800787
788 /* Next, we fill out the buffer descriptor: */
789 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
790 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
791 pe_session->selfMacAddr);
792
793 mac_hdr = (tpSirMacMgmtHdr) frame;
794
795 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797 /* That done, pack the Probe Response: */
798 status =
799 dot11f_pack_probe_response(mac_ctx, frm,
800 frame + sizeof(tSirMacMgmtHdr),
801 payload, &payload);
802 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700803 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 status);
805 goto err_ret;
806 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700807 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 }
809
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700810 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530811 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 if (mac_ctx->lim.gpLimRemainOnChanReq)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530814 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 mac_ctx->lim.gpLimRemainOnChanReq->probeRspIe,
816 (mac_ctx->lim.gpLimRemainOnChanReq->length -
817 sizeof(tSirRemainOnChnReq)));
818
819 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530820 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 &add_ie[0], addn_ie_len);
822
823 if (noalen != 0) {
824 if (total_noalen >
825 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700826 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 total_noalen);
828 goto err_ret;
829 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530830 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 &noa_ie[0], total_noalen);
832 }
833 }
834
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800835 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530836 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
837 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 )
839 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
840
841 /* Queue Probe Response frame in high priority WQ */
Jeff Johnson59429b02018-11-07 13:53:18 -0800842 qdf_status = wma_tx_frame(mac_ctx, packet,
843 (uint16_t)bytes,
844 TXRX_FRM_802_11_MGMT,
845 ANI_TXDIR_TODS,
846 7, lim_tx_complete, frame, tx_flag,
847 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848
849 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530850 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700851 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852
853 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530854 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530856 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 return;
858
859err_ret:
860 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530861 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 if (frm != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530863 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 if (packet != NULL)
865 cds_packet_free((void *)packet);
866 return;
867
868} /* End lim_send_probe_rsp_mgmt_frame. */
869
870void
871lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
872 tSirMacAddr peerMacAddr,
873 tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry)
874{
875 uint16_t i;
876 uint8_t *pFrame;
877 tDot11fAddTSRequest AddTSReq;
878 tDot11fWMMAddTSRequest WMMAddTSReq;
879 uint32_t nPayload, nBytes, nStatus;
880 tpSirMacMgmtHdr pMacHdr;
881 void *pPacket;
882#ifdef FEATURE_WLAN_ESE
883 uint32_t phyMode;
884#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530885 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 uint8_t txFlag = 0;
887 uint8_t smeSessionId = 0;
888
889 if (NULL == psessionEntry) {
890 return;
891 }
892
893 smeSessionId = psessionEntry->smeSessionId;
894
895 if (!pAddTS->wmeTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530896 qdf_mem_set((uint8_t *) &AddTSReq, sizeof(AddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897
898 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
899 AddTSReq.DialogToken.token = pAddTS->dialogToken;
900 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
901 if (pAddTS->lleTspecPresent) {
902 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
903 } else {
904 populate_dot11f_wmmtspec(&pAddTS->tspec,
905 &AddTSReq.WMMTSPEC);
906 }
907
908 if (pAddTS->lleTspecPresent) {
909 AddTSReq.num_WMMTCLAS = 0;
910 AddTSReq.num_TCLAS = pAddTS->numTclas;
911 for (i = 0; i < pAddTS->numTclas; ++i) {
912 populate_dot11f_tclas(pMac, &pAddTS->tclasInfo[i],
913 &AddTSReq.TCLAS[i]);
914 }
915 } else {
916 AddTSReq.num_TCLAS = 0;
917 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
918 for (i = 0; i < pAddTS->numTclas; ++i) {
919 populate_dot11f_wmmtclas(pMac,
920 &pAddTS->tclasInfo[i],
921 &AddTSReq.WMMTCLAS[i]);
922 }
923 }
924
925 if (pAddTS->tclasProcPresent) {
926 if (pAddTS->lleTspecPresent) {
927 AddTSReq.TCLASSPROC.processing =
928 pAddTS->tclasProc;
929 AddTSReq.TCLASSPROC.present = 1;
930 } else {
931 AddTSReq.WMMTCLASPROC.version = 1;
932 AddTSReq.WMMTCLASPROC.processing =
933 pAddTS->tclasProc;
934 AddTSReq.WMMTCLASPROC.present = 1;
935 }
936 }
937
938 nStatus =
939 dot11f_get_packed_add_ts_request_size(pMac, &AddTSReq, &nPayload);
940 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700941 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
942 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 /* We'll fall back on the worst case scenario: */
944 nPayload = sizeof(tDot11fAddTSRequest);
945 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700946 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
947 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 }
949 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530950 qdf_mem_set((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
952 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
953 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
954 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
955
956 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
957 WMMAddTSReq.StatusCode.statusCode = 0;
958
959 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
960#ifdef FEATURE_WLAN_ESE
961 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
962
963 if (phyMode == WNI_CFG_PHY_MODE_11G
964 || phyMode == WNI_CFG_PHY_MODE_11A) {
965 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
966 } else {
967 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
968 }
969 populate_dot11_tsrsie(pMac, &pAddTS->tsrsIE,
970 &WMMAddTSReq.ESETrafStrmRateSet,
971 sizeof(uint8_t));
972#endif
973 /* fillWmeTspecIE */
974
975 nStatus =
976 dot11f_get_packed_wmm_add_ts_request_size(pMac, &WMMAddTSReq,
977 &nPayload);
978 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700979 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 nStatus);
981 /* We'll fall back on the worst case scenario: */
982 nPayload = sizeof(tDot11fAddTSRequest);
983 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700984 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
985 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 }
987 }
988
989 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
990
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530991 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530993 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700994 pe_err("Failed to allocate %d bytes for an Add TS Request",
995 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 return;
997 }
998 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530999 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000
1001 /* Next, we fill out the buffer descriptor: */
1002 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1003 SIR_MAC_MGMT_ACTION, peerMacAddr, psessionEntry->selfMacAddr);
1004 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1005
1006 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1007
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 lim_set_protected_bit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009
1010 /* That done, pack the struct: */
1011 if (!pAddTS->wmeTspecPresent) {
1012 nStatus = dot11f_pack_add_ts_request(pMac, &AddTSReq,
1013 pFrame +
1014 sizeof(tSirMacMgmtHdr),
1015 nPayload, &nPayload);
1016 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001017 pe_err("Failed to pack an Add TS Request "
1018 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019 cds_packet_free((void *)pPacket);
1020 return; /* allocated! */
1021 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001022 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1023 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 }
1025 } else {
1026 nStatus = dot11f_pack_wmm_add_ts_request(pMac, &WMMAddTSReq,
1027 pFrame +
1028 sizeof(tSirMacMgmtHdr),
1029 nPayload, &nPayload);
1030 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001031 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1032 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 cds_packet_free((void *)pPacket);
1034 return; /* allocated! */
1035 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001036 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1037 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 }
1039 }
1040
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001041 pe_debug("Sending an Add TS Request frame to");
1042 lim_print_mac_addr(pMac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001044 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301046 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1047 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 ) {
1049 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1050 }
1051
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301052 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001054 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001055 psessionEntry, QDF_STATUS_SUCCESS,
1056 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057
1058 /* Queue Addts Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301059 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 TXRX_FRM_802_11_MGMT,
1061 ANI_TXDIR_TODS,
1062 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001063 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301064 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301065 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001067 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1068 pe_err("Could not send an Add TS Request (%X",
1069 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070} /* End lim_send_addts_req_action_frame. */
1071
1072/**
1073 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1074 * @mac_ctx: Handle for mac context
1075 * @status_code: Status code for assoc response frame
1076 * @aid: Association ID
1077 * @peer_addr: Mac address of requesting peer
1078 * @subtype: Assoc/Reassoc
1079 * @sta: Pointer to station node
1080 * @pe_session: PE session id.
1081 *
1082 * Builds and sends association response frame to the requesting peer.
1083 *
1084 * Return: void
1085 */
1086
1087void
1088lim_send_assoc_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
1089 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
1090 uint8_t subtype, tpDphHashNode sta, tpPESession pe_session)
1091{
1092 static tDot11fAssocResponse frm;
1093 uint8_t *frame;
1094 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001095 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 uint8_t lle_mode = 0, addts;
1097 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001098 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001099 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301100 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 tUpdateBeaconParams beacon_params;
1102 uint8_t tx_flag = 0;
1103 uint32_t addn_ie_len = 0;
1104 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1105 tpSirAssocReq assoc_req = NULL;
1106 uint8_t sme_session = 0;
1107 bool is_vht = false;
1108 uint16_t stripoff_len = 0;
1109 tDot11fIEExtCap extracted_ext_cap;
1110 bool extracted_flag = false;
1111#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301112 uint8_t retry_int;
1113 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001114#endif
1115
1116 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001117 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001118 return;
1119 }
1120
1121 sme_session = pe_session->smeSessionId;
1122
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301123 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124
1125 limGetQosMode(pe_session, &qos_mode);
1126 limGetWmeMode(pe_session, &wme_mode);
1127
1128 /*
1129 * An Add TS IE is added only if the AP supports it and
1130 * the requesting STA sent a traffic spec.
1131 */
1132 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1133
1134 frm.Status.status = status_code;
1135
1136 frm.AID.associd = aid | LIM_AID_MASK;
1137
1138 if (NULL == sta) {
1139 populate_dot11f_supp_rates(mac_ctx,
1140 POPULATE_DOT11F_RATES_OPERATIONAL,
1141 &frm.SuppRates, pe_session);
1142 populate_dot11f_ext_supp_rates(mac_ctx,
1143 POPULATE_DOT11F_RATES_OPERATIONAL,
1144 &frm.ExtSuppRates, pe_session);
1145 } else {
1146 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1147 &frm.ExtSuppRates,
1148 sta->supportedRates.llbRates,
1149 sta->supportedRates.llaRates);
1150 }
1151
1152 if (LIM_IS_AP_ROLE(pe_session) && sta != NULL &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001153 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 assoc_req = (tpSirAssocReq)
1155 pe_session->parsedAssocReq[sta->assocId];
1156 /*
1157 * populate P2P IE in AssocRsp when assocReq from the peer
1158 * includes P2P IE
1159 */
1160 if (assoc_req != NULL && assoc_req->addIEPresent)
1161 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1162 &frm.P2PAssocRes,
1163 assoc_req);
1164 }
1165
1166 if (NULL != sta) {
1167 if (eHAL_SET == qos_mode) {
1168 if (sta->lleEnabled) {
1169 lle_mode = 1;
1170 populate_dot11f_edca_param_set(mac_ctx,
1171 &frm.EDCAParamSet, pe_session);
1172 }
1173 }
1174
1175 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1176 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1177 pe_session);
1178
1179 if (sta->wsmEnabled)
1180 populate_dot11f_wmm_caps(&frm.WMMCaps);
1181 }
1182
1183 if (sta->mlmStaContext.htCapability &&
1184 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001185 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186 populate_dot11f_ht_caps(mac_ctx, pe_session,
1187 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001188 /*
1189 * Check the STA capability and
1190 * update the HTCaps accordingly
1191 */
1192 frm.HTCaps.supportedChannelWidthSet = (
1193 sta->htSupportedChannelWidthSet <
1194 pe_session->htSupportedChannelWidthSet) ?
1195 sta->htSupportedChannelWidthSet :
1196 pe_session->htSupportedChannelWidthSet;
1197 if (!frm.HTCaps.supportedChannelWidthSet)
1198 frm.HTCaps.shortGI40MHz = 0;
1199
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001200 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
1201 pe_session);
1202 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001203 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 +05301204 frm.HTCaps.supportedChannelWidthSet,
1205 frm.HTCaps.mimoPowerSave,
1206 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1207 frm.HTCaps.shortGI40MHz,
1208 frm.HTCaps.dsssCckMode40MHz,
1209 frm.HTCaps.maxRxAMPDUFactor);
1210
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211 if (sta->mlmStaContext.vhtCapability &&
1212 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001213 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 populate_dot11f_vht_caps(mac_ctx, pe_session,
1215 &frm.VHTCaps);
1216 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301217 &frm.VHTOperation);
1218 is_vht = true;
1219 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001220
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301221 if (pe_session->vhtCapability &&
1222 pe_session->vendor_vht_sap &&
1223 (assoc_req != NULL) &&
1224 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001225 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301226 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001227 frm.vendor_vht_ie.sub_type =
1228 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301229 frm.vendor_vht_ie.VHTCaps.present = 1;
1230 populate_dot11f_vht_caps(mac_ctx, pe_session,
1231 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001232 populate_dot11f_vht_operation(mac_ctx, pe_session,
1233 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 is_vht = true;
1235 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1237 pe_session);
1238
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001239 if (lim_is_sta_he_capable(sta) &&
1240 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001241 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001242 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001243 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001244 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001245 &frm.he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001246 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247#ifdef WLAN_FEATURE_11W
1248 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301249 max_retries =
1250 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1251 retry_int =
1252 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1253 populate_dot11f_timeout_interval(mac_ctx,
1254 &frm.TimeoutInterval,
1255 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1256 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257 sta->pmfSaQueryRetryCount)
1258 * retry_int);
1259 }
1260#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001261
1262 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1263 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 }
1265
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301266 qdf_mem_set((uint8_t *) &beacon_params, sizeof(beacon_params), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267
1268 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301269 (pe_session->gLimProtectionControl !=
1270 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1271 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1272 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273
1274 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1275 pe_session);
1276 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1277 pe_session);
1278
1279 /*
1280 * Populate Do11capabilities after updating session with
1281 * Assos req details
1282 */
1283 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1284
1285 beacon_params.bssIdx = pe_session->bssIdx;
1286
1287 /* Send message to HAL about beacon parameter change. */
1288 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1289 && beacon_params.paramChangeBitmap) {
1290 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1291 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1292 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293
Arif Hussain1513cb22018-01-05 19:56:31 -08001294 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1295
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 if (assoc_req != NULL) {
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001297 addn_ie_len = pe_session->addIeParams.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001298
1299 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001300 if (addn_ie_len > 0 &&
1301 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1302 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301303 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 pe_session->addIeParams.assocRespData_buff,
1305 pe_session->addIeParams.assocRespDataLen);
1306
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301307 qdf_mem_set((uint8_t *) &extracted_ext_cap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 sizeof(extracted_ext_cap), 0);
1309
1310 stripoff_len = addn_ie_len;
1311 sir_status =
1312 lim_strip_extcap_update_struct
1313 (mac_ctx, &add_ie[0], &stripoff_len,
1314 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001315 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001316 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 } else {
1318 addn_ie_len = stripoff_len;
1319 extracted_flag = true;
1320 }
1321 bytes = bytes + addn_ie_len;
1322 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001323 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 addn_ie_len, assoc_req->addIEPresent);
1325 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001326
1327 /*
1328 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1329 * may change the frame size. Therefore, MUST merge ExtCap IE before
1330 * dot11f get packed payload size.
1331 */
1332 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001333 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1334 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001335
1336 /* Allocate a buffer for this frame: */
1337 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1338 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001339 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001340 status);
1341 return;
1342 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001343 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001344 status);
1345 }
1346
1347 bytes += sizeof(tSirMacMgmtHdr) + payload;
1348
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301349 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301351 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001352 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 return;
1354 }
1355 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301356 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357
1358 /* Next, we fill out the buffer descriptor: */
1359 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1360 (LIM_ASSOC == subtype) ?
1361 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1362 peer_addr,
1363 pe_session->selfMacAddr);
1364 mac_hdr = (tpSirMacMgmtHdr) frame;
1365
1366 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1367
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1369 frame + sizeof(tSirMacMgmtHdr),
1370 payload, &payload);
1371 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001372 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 status);
1374 cds_packet_free((void *)packet);
1375 return;
1376 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001377 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 status);
1379 }
1380
1381 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001382 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383 status_code, aid);
1384 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001385 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 status_code, aid);
1387
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301388 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389
1390 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301391 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392 &add_ie[0], addn_ie_len);
1393
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001394 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301396 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1397 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1399
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301400 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001402 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001403 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301405 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 TXRX_FRM_802_11_MGMT,
1407 ANI_TXDIR_TODS,
1408 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001409 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301410 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301411 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412
1413 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301414 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001415 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301416 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417
1418 /*
1419 * update the ANI peer station count.
1420 * FIXME_PROTECTION : take care of different type of station
1421 * counter inside this function.
1422 */
1423 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1424
1425}
1426
1427void
1428lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
1429 tSirMacAddr peer,
1430 uint8_t wmmTspecPresent,
1431 tSirMacTSInfo *pTsinfo,
1432 tSirMacTspecIE *pTspecIe, tpPESession psessionEntry)
1433{
1434 uint8_t *pFrame;
1435 tpSirMacMgmtHdr pMacHdr;
1436 tDot11fDelTS DelTS;
1437 tDot11fWMMDelTS WMMDelTS;
1438 uint32_t nBytes, nPayload, nStatus;
1439 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301440 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 uint8_t txFlag = 0;
1442 uint8_t smeSessionId = 0;
1443
1444 if (NULL == psessionEntry) {
1445 return;
1446 }
1447
1448 smeSessionId = psessionEntry->smeSessionId;
1449
1450 if (!wmmTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301451 qdf_mem_set((uint8_t *) &DelTS, sizeof(DelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452
1453 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1454 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1455 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1456
1457 nStatus = dot11f_get_packed_del_ts_size(pMac, &DelTS, &nPayload);
1458 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001459 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 /* We'll fall back on the worst case scenario: */
1461 nPayload = sizeof(tDot11fDelTS);
1462 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001463 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1464 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 }
1466 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301467 qdf_mem_set((uint8_t *) &WMMDelTS, sizeof(WMMDelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001468
1469 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1470 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1471 WMMDelTS.DialogToken.token = 0;
1472 WMMDelTS.StatusCode.statusCode = 0;
1473 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1474 nStatus =
1475 dot11f_get_packed_wmm_del_ts_size(pMac, &WMMDelTS, &nPayload);
1476 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001477 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 /* We'll fall back on the worst case scenario: */
1479 nPayload = sizeof(tDot11fDelTS);
1480 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001481 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1482 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483 }
1484 }
1485
1486 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1487
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301488 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1490 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301491 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001492 pe_err("Failed to allocate %d bytes for an Add TS Response",
1493 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494 return;
1495 }
1496 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301497 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498
1499 /* Next, we fill out the buffer descriptor: */
1500 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1501 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
1502 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1503
1504 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507
1508 /* That done, pack the struct: */
1509 if (!wmmTspecPresent) {
1510 nStatus = dot11f_pack_del_ts(pMac, &DelTS,
1511 pFrame + sizeof(tSirMacMgmtHdr),
1512 nPayload, &nPayload);
1513 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001514 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 nStatus);
1516 cds_packet_free((void *)pPacket);
1517 return; /* allocated! */
1518 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001519 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1520 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 }
1522 } else {
1523 nStatus = dot11f_pack_wmm_del_ts(pMac, &WMMDelTS,
1524 pFrame + sizeof(tSirMacMgmtHdr),
1525 nPayload, &nPayload);
1526 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001527 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 nStatus);
1529 cds_packet_free((void *)pPacket);
1530 return; /* allocated! */
1531 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001532 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1533 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 }
1535 }
1536
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001537 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
1538 lim_print_mac_addr(pMac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001540 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301542 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1543 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 ) {
1545 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1546 }
1547
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301548 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001550 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001551 psessionEntry, QDF_STATUS_SUCCESS,
1552 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301553 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 TXRX_FRM_802_11_MGMT,
1555 ANI_TXDIR_TODS,
1556 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001557 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301558 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301559 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301561 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001562 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563
1564} /* End lim_send_delts_req_action_frame. */
1565
1566/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301567 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1568 * @context: pointer to global mac
1569 * @buf: buffer
1570 * @tx_complete : Sent status
1571 * @params; tx completion params
1572 *
1573 * Return: This returns QDF_STATUS
1574 */
1575
1576static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1577 qdf_nbuf_t buf,
1578 uint32_t tx_complete,
1579 void *params)
1580{
1581 uint16_t assoc_ack_status;
1582 uint16_t reason_code;
1583 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
1584
1585 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001586 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301587 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001588 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301589 } else {
1590 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001591 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301592 }
1593 if (buf)
1594 qdf_nbuf_free(buf);
1595
1596 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1597 NULL, assoc_ack_status, reason_code);
1598 return QDF_STATUS_SUCCESS;
1599}
1600
1601/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602 * lim_send_assoc_req_mgmt_frame() - Send association request
1603 * @mac_ctx: Handle to MAC context
1604 * @mlm_assoc_req: Association request information
1605 * @pe_session: PE session information
1606 *
1607 * Builds and transmits association request frame to AP.
1608 *
1609 * Return: Void
1610 */
1611
1612void
1613lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
1614 tLimMlmAssocReq *mlm_assoc_req,
1615 tpPESession pe_session)
1616{
Naveen Rawat72475db2017-12-13 18:07:35 -08001617 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 tDot11fAssocRequest *frm;
1619 uint16_t caps;
1620 uint8_t *frame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001621 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001623 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1625 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301626 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627 uint16_t add_ie_len;
1628 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001629 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001631 uint8_t tx_flag = 0;
1632 uint8_t sme_sessionid = 0;
1633 bool vht_enabled = false;
1634 tDot11fIEExtCap extr_ext_cap;
1635 bool extr_ext_flag = true;
1636 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001637 uint32_t ie_offset = 0;
1638 uint8_t *p_ext_cap = NULL;
1639 tDot11fIEExtCap bcn_ext_cap;
1640 uint8_t *bcn_ie = NULL;
1641 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301642 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001643 enum rateid min_rid = RATEID_DEFAULT;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301644 uint8_t *mbo_ie = NULL;
1645 uint8_t mbo_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646
1647 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001648 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301649 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 return;
1651 }
1652
1653 sme_sessionid = pe_session->smeSessionId;
1654
1655 /* check this early to avoid unncessary operation */
1656 if (NULL == pe_session->pLimJoinReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001657 pe_err("pe_session->pLimJoinReq is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301658 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 return;
1660 }
1661 add_ie_len = pe_session->pLimJoinReq->addIEAssoc.length;
1662 add_ie = pe_session->pLimJoinReq->addIEAssoc.addIEdata;
1663
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301664 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001665 if (!frm) {
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301666 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 return;
1668 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001669 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fAssocRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301671 if (add_ie_len && pe_session->is_ext_caps_present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301672 qdf_mem_set((uint8_t *) &extr_ext_cap, sizeof(tDot11fIEExtCap),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 0);
1674 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1675 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001676 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001678 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 } else {
1680 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1681 extr_ext_cap.bytes;
1682
1683 if (p_ext_cap->interworking_service)
1684 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001685 extr_ext_cap.num_bytes =
1686 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1687 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 }
1689 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001690 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 extr_ext_flag = false;
1692 }
1693
1694 caps = mlm_assoc_req->capabilityInfo;
1695#if defined(FEATURE_WLAN_WAPI)
1696 /*
1697 * According to WAPI standard:
1698 * 7.3.1.4 Capability Information field
1699 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1700 * in transmitted Association or Reassociation management frames.
1701 * APs ignore the Privacy subfield within received Association and
1702 * Reassociation management frames.
1703 */
1704 if (pe_session->encryptType == eSIR_ED_WPI)
1705 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1706#endif
1707 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1708
1709 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1710 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1711 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1712 &frm->SuppRates, pe_session);
1713
1714 qos_enabled = (pe_session->limQosEnabled) &&
1715 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1716
1717 wme_enabled = (pe_session->limWmeEnabled) &&
1718 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1719
1720 /* We prefer .11e asociations: */
1721 if (qos_enabled)
1722 wme_enabled = false;
1723
1724 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1725 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1726
1727 if (pe_session->lim11hEnable &&
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001728 pe_session->pLimJoinReq->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729 power_caps = true;
1730
1731 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1732 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1734 LIM_ASSOC, pe_session);
1735
1736 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1738 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1739 if (power_caps == false) {
1740 power_caps = true;
1741 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1742 LIM_ASSOC, pe_session);
1743 }
1744 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001746 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1747 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748
1749 populate_dot11f_ext_supp_rates(mac_ctx,
1750 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1751 pe_session);
1752
Gupta, Kapil54a16992016-01-13 19:34:02 +05301753 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1754 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1756 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001757
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 /*
1759 * The join request *should* contain zero or one of the WPA and RSN
1760 * IEs. The payload send along with the request is a
1761 * 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
1762 * typedef struct sSirRSNie
1763 * {
1764 * uint16_t length;
1765 * uint8_t rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
1766 * } tSirRSNie, *tpSirRSNie;
1767 * So, we should be able to make the following two calls harmlessly,
1768 * since they do nothing if they don't find the given IE in the
1769 * bytestream with which they're provided.
1770 * The net effect of this will be to faithfully transmit whatever
1771 * security IE is in the join request.
1772 * However, if we're associating for the purpose of WPS
1773 * enrollment, and we've been configured to indicate that by
1774 * eliding the WPA or RSN IE, we just skip this:
1775 */
1776 if (add_ie_len && add_ie)
1777 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1778
1779 if (NULL == wps_ie) {
1780 populate_dot11f_rsn_opaque(mac_ctx,
1781 &(pe_session->pLimJoinReq->rsnIE),
1782 &frm->RSNOpaque);
1783 populate_dot11f_wpa_opaque(mac_ctx,
1784 &(pe_session->pLimJoinReq->rsnIE),
1785 &frm->WPAOpaque);
1786#if defined(FEATURE_WLAN_WAPI)
1787 populate_dot11f_wapi_opaque(mac_ctx,
1788 &(pe_session->pLimJoinReq->rsnIE),
1789 &frm->WAPIOpaque);
1790#endif /* defined(FEATURE_WLAN_WAPI) */
1791 }
1792 /* include WME EDCA IE as well */
1793 if (wme_enabled) {
1794 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1795 pe_session, &frm->WMMInfoStation);
1796
1797 if (wsm_enabled)
1798 populate_dot11f_wmm_caps(&frm->WMMCaps);
1799 }
1800
1801 /*
1802 * Populate HT IEs, when operating in 11n and
1803 * when AP is also operating in 11n mode
1804 */
1805 if (pe_session->htCapability &&
1806 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001807 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001809 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1810 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001811 } else if (pe_session->he_with_wep_tkip) {
1812 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1813 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001815 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 +05301816 frm->HTCaps.supportedChannelWidthSet,
1817 frm->HTCaps.mimoPowerSave,
1818 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1819 frm->HTCaps.shortGI40MHz,
1820 frm->HTCaps.dsssCckMode40MHz,
1821 frm->HTCaps.maxRxAMPDUFactor);
1822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 if (pe_session->vhtCapability &&
1824 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001825 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001827 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1828 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001830 if (pe_session->enableHtSmps &&
1831 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001832 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001833 populate_dot11f_operating_mode(mac_ctx,
1834 &frm->OperatingMode, pe_session);
1835 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001836 } else if (pe_session->he_with_wep_tkip) {
1837 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1838 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 if (!vht_enabled &&
1842 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001843 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301844 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001845 frm->vendor_vht_ie.sub_type =
1846 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301847 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05301848 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05301849 pe_session->vht_config.su_beam_formee) {
1850 pe_debug("Disable SU beamformee for vendor IE");
1851 pe_session->vht_config.su_beam_formee = 0;
1852 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301854 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 vht_enabled = true;
1856 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301857 if (pe_session->is_ext_caps_present)
1858 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1859 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860
Wu Gao93816212018-08-31 16:49:54 +08001861 if (mac_ctx->mlme_cfg->sta.qcn_ie_support)
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301862 populate_dot11f_qcn_ie(&frm->QCN_IE);
1863
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001864 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001865 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001866 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001867 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001868 } else if (pe_session->he_with_wep_tkip) {
1869 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1870 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001871 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301872
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 tSirBssDescription *bssdescr;
1875
1876 bssdescr = &pe_session->pLimJoinReq->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001877 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 (unsigned int) bssdescr->mdie[0],
1879 (unsigned int) bssdescr->mdie[1],
1880 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 populate_mdie(mac_ctx, &frm->MobilityDomain,
1882 pe_session->pLimJoinReq->bssDescription.mdie);
1883 } else {
1884 /* No 11r IEs dont send any MDIE */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001885 pe_debug("MDIE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887
1888#ifdef FEATURE_WLAN_ESE
1889 /*
1890 * ESE Version IE will be included in association request
1891 * when ESE is enabled on DUT through ini and it is also
1892 * advertised by the peer AP to which we are trying to
1893 * associate to.
1894 */
1895 if (pe_session->is_ese_version_ie_present &&
1896 mac_ctx->roam.configParam.isEseIniFeatureEnabled)
1897 populate_dot11f_ese_version(&frm->ESEVersion);
1898 /* For ESE Associations fill the ESE IEs */
1899 if (pe_session->isESEconnection &&
1900 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1901#ifndef FEATURE_DISABLE_RM
1902 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1903#endif
1904 }
1905#endif
1906
Hu Wang411e0cc2016-10-28 14:56:01 +08001907 /*
1908 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1909 * may change the frame size. Therefore, MUST merge ExtCap IE before
1910 * dot11f get packed payload size.
1911 */
1912 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001913 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1914
1915 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1916 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1917 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1918 DOT11F_FF_BEACONINTERVAL_LEN +
1919 DOT11F_FF_CAPABILITIES_LEN;
1920
1921 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1922 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1923 bcn_ie = pe_session->beacon + ie_offset;
1924 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001925 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001926 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001927 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001928 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1929 &bcn_ext_cap);
1930 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1931 false);
1932 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07001933 /*
1934 * TWT extended capabilities should be populated after the
1935 * intersection of beacon caps and self caps is done because
1936 * the bits for TWT are unique to STA and AP and cannot be
1937 * intersected.
1938 */
1939 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
1940 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08001941 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001942
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001943 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001944 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001945 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001946
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301947 if (lim_is_fils_connection(pe_session)) {
1948 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
1949 aes_block_size_len = AES_BLOCK_SIZE;
1950 }
1951
1952 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301953 * MBO IE needs to be appendded at the end of the assoc request
1954 * frame and is not parsed and unpacked by the frame parser
1955 * as the supplicant can send multiple TLVs with same Attribute
1956 * in the MBO IE and the frame parser does not support multiple
1957 * TLVs with same attribute in a single IE.
1958 * Strip off the MBO IE from add_ie and append it at the end.
1959 */
1960 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
1961 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
1962 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001963 if (!mbo_ie)
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301964 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301965
1966 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
1967 SIR_MAC_EID_VENDOR, ONE_BYTE,
1968 SIR_MAC_MBO_OUI,
1969 SIR_MAC_MBO_OUI_SIZE,
1970 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
1971 if (QDF_IS_STATUS_ERROR(qdf_status)) {
1972 pe_err("Failed to strip MBO IE");
1973 goto free_mbo_ie;
1974 }
1975
1976 /* Include the EID and length fields */
1977 mbo_ie_len = mbo_ie[1] + 2;
1978 pe_debug("Stripped MBO IE of length %d", mbo_ie_len);
1979 }
1980
1981 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301982 * Do unpack to populate the add_ie buffer to frm structure
1983 * before packing the frm structure. In this way, the IE ordering
1984 * which the latest 802.11 spec mandates is maintained.
1985 */
Naveen Rawat72475db2017-12-13 18:07:35 -08001986 if (add_ie_len) {
1987 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301988 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08001989 if (DOT11F_FAILED(ret)) {
1990 pe_err("unpack failed, ret: 0x%x", ret);
1991 goto end;
1992 }
1993 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301994
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
1996 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001997 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 status);
1999 /* We'll fall back on the worst case scenario: */
2000 payload = sizeof(tDot11fAssocRequest);
2001 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002002 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 status);
2004 }
2005
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302006 bytes = payload + sizeof(tSirMacMgmtHdr) +
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302007 aes_block_size_len + mbo_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302009 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302011 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002012 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013
2014 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302015 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016 pe_session->peSessionId,
2017 pe_session->limMlmState));
2018
2019 /* Update PE session id */
2020 assoc_cnf.sessionId = pe_session->peSessionId;
2021
2022 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2023
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2025 (uint32_t *) &assoc_cnf);
2026
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302027 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 }
2029 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302030 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031
2032 /* Next, we fill out the buffer descriptor: */
2033 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2034 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
2035 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002036 /* That done, pack the Assoc Request: */
2037 status = dot11f_pack_assoc_request(mac_ctx, frm,
2038 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2039 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002040 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302042 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002044 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 }
2046
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302047 /* Copy the MBO IE to the end of the frame */
2048 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2049 mbo_ie, mbo_ie_len);
2050 payload = payload + mbo_ie_len;
2051
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052 if (pe_session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302053 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002055 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 }
2057
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302058 if (lim_is_fils_connection(pe_session)) {
2059 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2060 frame, &payload);
2061 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2062 cds_packet_free((void *)packet);
2063 qdf_mem_free(frm);
2064 return;
2065 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 }
2067
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302068 pe_session->assocReq = qdf_mem_malloc(payload);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002069 if (pe_session->assocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070 /*
2071 * Store the Assoc request. This is sent to csr/hdd in
2072 * join cnf response.
2073 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302074 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 frame + sizeof(tSirMacMgmtHdr), payload);
2076 pe_session->assocReqLen = payload;
2077 }
2078
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002079 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302080 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
2081 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 )
2083 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2084
Anurag Chouhan6d760662016-02-20 16:05:43 +05302085 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
2086 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2088
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302090 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302092
2093 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002094 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002095 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002096 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002097 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002098 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302099 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302100 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2102 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302103 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002104 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302105 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302106 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302107 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002108
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302109 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002110 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302111 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302112 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002113 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302116free_mbo_ie:
2117 if (mbo_ie)
2118 qdf_mem_free(mbo_ie);
2119
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302120end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302122 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302124 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 return;
2126}
2127
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002129 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2130 * @context: pointer to global mac
2131 * @buf: buffer which is nothing but entire ADD BA frame
2132 * @tx_complete : Sent status
2133 * @params; tx completion params
2134 *
2135 * Return: This returns QDF_STATUS
2136 */
2137static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2138 qdf_nbuf_t buf,
2139 uint32_t tx_complete,
2140 void *params)
2141{
2142 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2143 tSirMacMgmtHdr *mac_hdr;
2144 tDot11faddba_rsp rsp;
2145 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2146 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
2147 uint8_t peer_id;
2148 void *peer;
2149 uint32_t frame_len;
2150 QDF_STATUS status;
2151 uint8_t *data;
2152
2153 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2154 pe_debug("Add ba response successfully sent");
2155 else
2156 pe_debug("Fail to send add ba response");
2157
2158 if (!buf) {
2159 pe_err("Addba response frame buffer is NULL");
2160 return QDF_STATUS_E_FAILURE;
2161 }
2162
2163 data = qdf_nbuf_data(buf);
2164
2165 if (!data) {
2166 pe_err("Addba response frame is NULL");
2167 return QDF_STATUS_E_FAILURE;
2168 }
2169
2170 mac_hdr = (tSirMacMgmtHdr *)data;
2171 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2172 frame_len = sizeof(rsp);
2173 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2174 sizeof(*mac_hdr), frame_len,
2175 &rsp, false);
2176
2177 if (DOT11F_FAILED(status)) {
2178 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2179 status, frame_len);
2180 goto error;
2181 }
2182
2183 peer = cdp_peer_get_ref_by_addr(soc, pdev, mac_hdr->da, &peer_id,
2184 PEER_DEBUG_ID_WMA_ADDBA_REQ);
2185 if (!peer) {
2186 pe_debug("no PEER found for mac_addr:%pM", mac_hdr->da);
2187 goto error;
2188 }
2189 cdp_addba_resp_tx_completion(soc, peer, rsp.addba_param_set.tid,
2190 tx_complete);
2191 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_WMA_ADDBA_REQ);
2192error:
2193 if (buf)
2194 qdf_nbuf_free(buf);
2195
2196 return QDF_STATUS_SUCCESS;
2197}
2198
2199/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302200 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302201 * @context: pointer to global mac
2202 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302203 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302204 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302205 *
2206 * Return: This returns QDF_STATUS
2207 */
2208
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302209static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2210 qdf_nbuf_t buf,
2211 uint32_t tx_complete,
2212 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302213{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302214 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302215 uint16_t auth_ack_status;
2216 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302217
Naveen Rawat684e8b12017-09-20 15:54:44 -07002218 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002219 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2220 "success" : "fail");
2221 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302222 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302223 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002224 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302225 /* 'Change' timer for future activations */
2226 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2227 } else {
2228 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302229 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002230 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302231 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302232
2233 if (buf)
2234 qdf_nbuf_free(buf);
2235
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302236 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2237 NULL, auth_ack_status, reason_code);
2238
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302239 return QDF_STATUS_SUCCESS;
2240}
2241
2242/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2244 *
2245 * @mac_ctx: Pointer to Global MAC structure
2246 * @auth_frame: Pointer to Authentication frame structure
2247 * @peer_addr: MAC address of destination peer
2248 * @wep_bit: wep bit in frame control for Authentication frame3
2249 * @session: PE session information
2250 *
2251 * This function is called by lim_process_mlm_messages(). Authentication frame
2252 * is formatted and sent when this function is called.
2253 *
2254 * Return: void
2255 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256void
2257lim_send_auth_mgmt_frame(tpAniSirGlobal mac_ctx,
2258 tpSirMacAuthFrameBody auth_frame,
2259 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302260 uint8_t wep_challenge_len,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302261 tpPESession session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262{
2263 uint8_t *frame, *body;
2264 uint32_t frame_len = 0, body_len = 0;
2265 tpSirMacMgmtHdr mac_hdr;
2266 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302267 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002268 uint8_t tx_flag = 0;
2269 uint8_t sme_sessionid = 0;
2270 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002271 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002272 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273
2274 if (NULL == session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002275 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 return;
2277 }
2278
2279 sme_sessionid = session->smeSessionId;
2280
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302281 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002282 /*
2283 * Auth frame3 to be sent with encrypted framebody
2284 *
2285 * Allocate buffer for Authenticaton frame of size
2286 * equal to management frame header length plus 2 bytes
2287 * each for auth algorithm number, transaction number,
2288 * status code, 128 bytes for challenge text and
2289 * 4 bytes each for IV & ICV.
2290 */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002291 pe_debug("Sending encrypted auth frame to " MAC_ADDRESS_STR,
2292 MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002293
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302294 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002295 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002296
2297 goto alloc_packet;
2298 }
2299
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002300 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002301 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302 auth_frame->authTransactionSeqNumber,
2303 auth_frame->authStatusCode,
2304 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
2305 MAC_ADDR_ARRAY(peer_addr));
2306
2307 switch (auth_frame->authTransactionSeqNumber) {
2308 case SIR_MAC_AUTH_FRAME_1:
2309 /*
2310 * Allocate buffer for Authenticaton frame of size
2311 * equal to management frame header length plus 2 bytes
2312 * each for auth algorithm number, transaction number
2313 * and status code.
2314 */
2315
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002316 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2317 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302319 frame_len += lim_create_fils_auth_data(mac_ctx,
2320 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
2322 if (NULL != session->ftPEContext.pFTPreAuthReq &&
2323 0 != session->ftPEContext.pFTPreAuthReq->
2324 ft_ies_length) {
2325 ft_ies_length = session->ftPEContext.
2326 pFTPreAuthReq->ft_ies_length;
2327 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002328 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 ft_ies_length);
2330 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002331 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 frame_len += (2 + SIR_MDIE_SIZE);
2333 }
2334 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335 break;
2336
2337 case SIR_MAC_AUTH_FRAME_2:
2338 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2339 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2340 (auth_frame->authStatusCode !=
2341 eSIR_MAC_SUCCESS_STATUS))) {
2342 /*
2343 * Allocate buffer for Authenticaton frame of size
2344 * equal to management frame header length plus
2345 * 2 bytes each for auth algorithm number,
2346 * transaction number and status code.
2347 */
2348
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002349 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2350 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 } else {
2352 /*
2353 * Shared Key algorithm with challenge text
2354 * to be sent.
2355 *
2356 * Allocate buffer for Authenticaton frame of size
2357 * equal to management frame header length plus
2358 * 2 bytes each for auth algorithm number,
2359 * transaction number, status code and 128 bytes
2360 * for challenge text.
2361 */
2362
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002363 challenge_req = true;
2364 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302365 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2366 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002367 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 }
2369 break;
2370
2371 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002372 /*
2373 * Auth frame3 to be sent without encrypted framebody
2374 *
2375 * Allocate buffer for Authenticaton frame of size equal
2376 * to management frame header length plus 2 bytes each
2377 * for auth algorithm number, transaction number and
2378 * status code.
2379 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002381 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2382 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 break;
2384
2385 case SIR_MAC_AUTH_FRAME_4:
2386 /*
2387 * Allocate buffer for Authenticaton frame of size equal
2388 * to management frame header length plus 2 bytes each
2389 * for auth algorithm number, transaction number and
2390 * status code.
2391 */
2392
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002393 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2394 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395
2396 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002397 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002398 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002399 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002400 } /* switch (auth_frame->authTransactionSeqNumber) */
2401
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002402alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302403 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 (void **)&packet);
2405
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302406 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002407 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 return;
2409 }
2410
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302411 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412
2413 /* Prepare BD */
2414 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2415 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2416 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302417 if (wep_challenge_len)
2418 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2419 else
2420 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421
2422 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002423 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302424 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 (uint8_t *) session->bssId,
2426 sizeof(tSirMacAddr));
2427
2428 /* Prepare Authentication frame body */
2429 body = frame + sizeof(tSirMacMgmtHdr);
2430
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302431 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302432 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002434 pe_debug("Sending Auth seq# 3 to " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 MAC_ADDR_ARRAY(mac_hdr->da));
2436
2437 } else {
2438 *((uint16_t *) (body)) =
2439 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2440 body += sizeof(uint16_t);
2441 body_len -= sizeof(uint16_t);
2442
2443 *((uint16_t *) (body)) =
2444 sir_swap_u16if_needed(
2445 auth_frame->authTransactionSeqNumber);
2446 body += sizeof(uint16_t);
2447 body_len -= sizeof(uint16_t);
2448
2449 *((uint16_t *) (body)) =
2450 sir_swap_u16if_needed(auth_frame->authStatusCode);
2451 body += sizeof(uint16_t);
2452 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002453
2454 if (challenge_req) {
2455 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302456 /* copy challenge IE id, len, challenge text */
2457 *body = auth_frame->type;
2458 body++;
2459 body_len -= sizeof(uint8_t);
2460 *body = auth_frame->length;
2461 body++;
2462 body_len -= sizeof(uint8_t);
2463 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002464 body_len);
2465 pe_err("Incomplete challenge info: length: %d, expected: %d",
2466 body_len,
2467 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2468 body += body_len;
2469 body_len = 0;
2470 } else {
2471 /* copy challenge IE id, len, challenge text */
2472 *body = auth_frame->type;
2473 body++;
2474 *body = auth_frame->length;
2475 body++;
2476 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302477 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2478 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002479
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302480 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2481 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002482 }
2483 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2486 (auth_frame->authTransactionSeqNumber ==
2487 SIR_MAC_AUTH_FRAME_1) &&
2488 (session->ftPEContext.pFTPreAuthReq != NULL)) {
2489
2490 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302491 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 session->ftPEContext.
2493 pFTPreAuthReq->ft_ies,
2494 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002495 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002496 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2497 QDF_TRACE_LEVEL_DEBUG,
2498 (uint8_t *) body,
2499 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 } else if (NULL != session->ftPEContext.
2501 pFTPreAuthReq->pbssDescription) {
2502 /* MDID attr is 54 */
2503 *body = SIR_MDIE_ELEMENT_ID;
2504 body++;
2505 *body = SIR_MDIE_SIZE;
2506 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302507 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508 &session->ftPEContext.pFTPreAuthReq->
2509 pbssDescription->mdie[0],
2510 SIR_MDIE_SIZE);
2511 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302512 } else if (auth_frame->authAlgoNumber ==
Varun Reddy Yeturu5faa1772017-10-23 11:22:01 -07002513 SIR_FILS_SK_WITHOUT_PFS) {
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302514 /* TODO MDIE */
2515 pe_debug("appending fils Auth data");
2516 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002519 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
2520 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 auth_frame->authTransactionSeqNumber,
2522 auth_frame->authStatusCode,
2523 (auth_frame->authStatusCode ==
2524 eSIR_MAC_SUCCESS_STATUS),
2525 MAC_ADDR_ARRAY(mac_hdr->da));
2526 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002527 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2528 QDF_TRACE_LEVEL_DEBUG,
2529 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302531 if ((NULL != session->ftPEContext.pFTPreAuthReq) &&
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002532 (BAND_5G == lim_get_rf_band(
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302533 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002535 else if ((BAND_5G ==
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302536 lim_get_rf_band(session->currentOperChannel))
2537 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2538 || (session->pePersona == QDF_P2P_GO_MODE))
2539 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540
Anurag Chouhan6d760662016-02-20 16:05:43 +05302541 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2542 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2544
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302545 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302548 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002549 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002550 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002551 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302552 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2553 (uint16_t)frame_len,
2554 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2555 7, lim_tx_complete, frame,
2556 lim_auth_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002557 tx_flag, sme_sessionid, false, 0, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302558 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2559 session->peSessionId, qdf_status));
2560 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2561 pe_err("*** Could not send Auth frame, retCode=%X ***",
2562 qdf_status);
2563 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2564 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002565 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302566 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302567 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568 return;
2569}
2570
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002571QDF_STATUS lim_send_deauth_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572{
2573 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002574 tpDphHashNode sta_ds;
2575 tLimMlmDeauthReq *deauth_req;
2576 tLimMlmDeauthCnf deauth_cnf;
2577 tpPESession session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002579 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2580 if (deauth_req) {
2581 if (tx_timer_running(
2582 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2583 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002586 session_entry = pe_find_session_by_session_id(mac_ctx,
2587 deauth_req->sessionId);
2588 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002589 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002590 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 eSIR_SME_INVALID_PARAMETERS;
2592 goto end;
2593 }
2594
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002595 sta_ds =
2596 dph_lookup_hash_entry(mac_ctx,
2597 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002598 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002599 &session_entry->dph.dphHashTable);
2600 if (sta_ds == NULL) {
2601 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 goto end;
2603 }
2604
2605 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002606 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2607 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2608 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2609 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302610#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002611 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302612#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002613 (session_entry->isFastRoamIniFeatureEnabled) ||
2614 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002615 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002616 session_entry,
2617 session_entry->peSessionId,
2618 deauth_req->reasonCode,
2619 deauth_req->deauthTrigger);
2620 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002621 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002622 pe_debug("No FT Preauth Session Cleanup in role %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002623#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002624 " isESE %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002625#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002626 " isLFR %d"
2627 " is11r %d, Deauth reason %d Trigger = %d",
2628 session_entry->limSystemRole,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002629#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002630 session_entry->isESEconnection,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002631#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002632 session_entry->isFastRoamIniFeatureEnabled,
2633 session_entry->is11Rconnection,
2634 deauth_req->reasonCode,
2635 deauth_req->deauthTrigger);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002636 }
2637 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002638 qdf_mem_free(deauth_req);
2639 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302641 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002643 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2644 &deauth_req->peer_macaddr);
2645 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2646 deauth_cnf.aid = deauth_req->aid;
2647 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648
2649 /* Free up buffer allocated */
2650 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002651 qdf_mem_free(deauth_req);
2652 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002654 lim_post_sme_message(mac_ctx,
2655 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302656 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657}
2658
2659/**
2660 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2661 *
2662 * @mac_ctx: Handle to MAC context
2663 *
2664 * Sends disassoc confirmation to SME. Removes disassoc request stored
2665 * in lim.
2666 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302667 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 */
2669
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302670QDF_STATUS lim_send_disassoc_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671{
2672 uint16_t aid;
2673 tpDphHashNode sta_ds;
2674 tLimMlmDisassocCnf disassoc_cnf;
2675 tpPESession pe_session;
2676 tLimMlmDisassocReq *disassoc_req;
2677
2678 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2679 if (disassoc_req) {
2680 if (tx_timer_running(
2681 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2682 lim_deactivate_and_change_timer(mac_ctx,
2683 eLIM_DISASSOC_ACK_TIMER);
2684
2685 pe_session = pe_find_session_by_session_id(
2686 mac_ctx, disassoc_req->sessionId);
2687 if (pe_session == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002688 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 disassoc_cnf.resultCode =
2690 eSIR_SME_INVALID_PARAMETERS;
2691 goto end;
2692 }
2693
2694 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002695 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 &pe_session->dph.dphHashTable);
2697 if (sta_ds == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002698 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2700 goto end;
2701 }
2702 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002703 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2705 disassoc_cnf.resultCode =
2706 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002707 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 goto end;
2709 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002710 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002711 (disassoc_req->reasonCode !=
2712 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002713 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002714 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 /* Delete FT session if there exists one */
2717 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302720 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302722 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302724 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 }
2726end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302727 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002728 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302729 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 disassoc_cnf.aid = disassoc_req->aid;
2731 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2732
2733 /* Update PE session ID */
2734 disassoc_cnf.sessionId = disassoc_req->sessionId;
2735
2736 if (disassoc_req != NULL) {
2737 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302738 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2740 }
2741
2742 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2743 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302744 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745}
2746
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302747QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002748 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302749 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002751 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302752
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002753 pe_debug("tx_success: %d", tx_success);
2754
2755 return lim_send_disassoc_cnf(max_ctx);
2756}
2757
2758static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2759 qdf_nbuf_t buf,
2760 uint32_t tx_success,
2761 void *params)
2762{
2763 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
2764 QDF_STATUS status_code;
2765 struct scheduler_msg msg = {0};
2766
2767 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302768
2769 if (buf)
2770 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002771 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2772 msg.bodyptr = params;
2773 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302774
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002775 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2776 if (status_code != QDF_STATUS_SUCCESS)
2777 pe_err("posting message: %X to LIM failed, reason: %d",
2778 msg.type, status_code);
2779 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780}
2781
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302782QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002783 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302784 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002786 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302787
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002788 pe_debug("tx_success: %d", tx_success);
2789
2790 return lim_send_deauth_cnf(mac_ctx);
2791}
2792
2793static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2794 qdf_nbuf_t buf,
2795 uint32_t tx_success,
2796 void *params)
2797{
2798 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2799 QDF_STATUS status_code;
2800 struct scheduler_msg msg = {0};
2801
2802 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302803
2804 if (buf)
2805 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002806 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2807 msg.bodyptr = params;
2808 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302809
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002810 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2811 if (status_code != QDF_STATUS_SUCCESS)
2812 pe_err("posting message: %X to LIM failed, reason: %d",
2813 msg.type, status_code);
2814 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815}
2816
2817/**
2818 * \brief This function is called to send Disassociate frame.
2819 *
2820 *
2821 * \param pMac Pointer to Global MAC structure
2822 *
2823 * \param nReason Indicates the reason that need to be sent in
2824 * Disassociation frame
2825 *
2826 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2827 * sent
2828 *
2829 *
2830 */
2831
2832void
2833lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
2834 uint16_t nReason,
2835 tSirMacAddr peer,
2836 tpPESession psessionEntry, bool waitForAck)
2837{
2838 tDot11fDisassociation frm;
2839 uint8_t *pFrame;
2840 tpSirMacMgmtHdr pMacHdr;
2841 uint32_t nBytes, nPayload, nStatus;
2842 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302843 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844 uint8_t txFlag = 0;
2845 uint32_t val = 0;
2846 uint8_t smeSessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 if (NULL == psessionEntry) {
2849 return;
2850 }
2851
2852 /*
2853 * In case when cac timer is running for this SAP session then
2854 * avoid sending disassoc out. It is violation of dfs specification.
2855 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302856 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2857 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302859 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 FL
2861 ("CAC timer is running, drop disassoc from going out"));
2862 return;
2863 }
2864 smeSessionId = psessionEntry->smeSessionId;
2865
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302866 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867
2868 frm.Reason.code = nReason;
2869
2870 nStatus = dot11f_get_packed_disassociation_size(pMac, &frm, &nPayload);
2871 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002872 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 nStatus);
2874 /* We'll fall back on the worst case scenario: */
2875 nPayload = sizeof(tDot11fDisassociation);
2876 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002877 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2878 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 }
2880
2881 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2882
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302883 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302885 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002886 pe_err("Failed to allocate %d bytes for a Disassociation",
2887 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888 return;
2889 }
2890 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302891 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892
2893 /* Next, we fill out the buffer descriptor: */
2894 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2895 SIR_MAC_MGMT_DISASSOC, peer, psessionEntry->selfMacAddr);
2896 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2897
2898 /* Prepare the BSSID */
2899 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2900
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902
2903 nStatus = dot11f_pack_disassociation(pMac, &frm, pFrame +
2904 sizeof(tSirMacMgmtHdr),
2905 nPayload, &nPayload);
2906 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002907 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908 nStatus);
2909 cds_packet_free((void *)pPacket);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002910 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002912 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
2913 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 }
2915
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002916 pe_debug("***Sessionid %d Sending Disassociation frame with "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002918 MAC_ADDRESS_STR, psessionEntry->peSessionId, nReason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
2920 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2921
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002922 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302923 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2924 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925 ) {
2926 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2927 }
2928
Sushant Kaushik46556062015-12-02 16:57:47 +05302929 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930
2931 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302932 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 psessionEntry->peSessionId,
2934 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002935 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002936 psessionEntry, QDF_STATUS_SUCCESS,
2937 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 /* Queue Disassociation frame in high priority WQ */
2939 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302940 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2942 TXRX_FRM_802_11_MGMT,
2943 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002944 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07002945 txFlag, smeSessionId, false, 0,
2946 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302947 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302948 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302949 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950
2951 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2952
2953 if (tx_timer_change
2954 (&pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
2955 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002956 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957 return;
2958 } else if (TX_SUCCESS !=
2959 tx_timer_activate(&pMac->lim.limTimers.
2960 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002961 pe_err("Unable to activate Disassoc ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 lim_deactivate_and_change_timer(pMac,
2963 eLIM_DISASSOC_ACK_TIMER);
2964 return;
2965 }
2966 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302967 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 psessionEntry->peSessionId,
2969 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002970 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
2971 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002972 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302974 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 TXRX_FRM_802_11_MGMT,
2976 ANI_TXDIR_TODS,
2977 7,
2978 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07002979 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302980 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302981 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302982 psessionEntry->peSessionId, qdf_status));
2983 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002984 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302985 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 /* Pkt will be freed up by the callback */
2987 }
2988 }
2989} /* End lim_send_disassoc_mgmt_frame. */
2990
2991/**
2992 * \brief This function is called to send a Deauthenticate frame
2993 *
2994 *
2995 * \param pMac Pointer to global MAC structure
2996 *
2997 * \param nReason Indicates the reason that need to be sent in the
2998 * Deauthenticate frame
2999 *
3000 * \param peeer address of the STA to which the frame is to be sent
3001 *
3002 *
3003 */
3004
3005void
3006lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
3007 uint16_t nReason,
3008 tSirMacAddr peer,
3009 tpPESession psessionEntry, bool waitForAck)
3010{
3011 tDot11fDeAuth frm;
3012 uint8_t *pFrame;
3013 tpSirMacMgmtHdr pMacHdr;
3014 uint32_t nBytes, nPayload, nStatus;
3015 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303016 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 uint8_t txFlag = 0;
3018 uint32_t val = 0;
3019#ifdef FEATURE_WLAN_TDLS
3020 uint16_t aid;
3021 tpDphHashNode pStaDs;
3022#endif
3023 uint8_t smeSessionId = 0;
3024
3025 if (NULL == psessionEntry) {
3026 return;
3027 }
3028
3029 /*
3030 * In case when cac timer is running for this SAP session then
3031 * avoid deauth frame out. It is violation of dfs specification.
3032 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303033 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
3034 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303036 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 FL
3038 ("CAC timer is running, drop the deauth from going out"));
3039 return;
3040 }
3041 smeSessionId = psessionEntry->smeSessionId;
3042
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303043 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044
3045 frm.Reason.code = nReason;
3046
3047 nStatus = dot11f_get_packed_de_auth_size(pMac, &frm, &nPayload);
3048 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003049 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 nStatus);
3051 /* We'll fall back on the worst case scenario: */
3052 nPayload = sizeof(tDot11fDeAuth);
3053 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003054 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3055 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 }
3057
3058 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3059
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303060 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303062 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003063 pe_err("Failed to allocate %d bytes for a De-Authentication",
3064 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 return;
3066 }
3067 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303068 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069
3070 /* Next, we fill out the buffer descriptor: */
3071 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3072 SIR_MAC_MGMT_DEAUTH, peer, psessionEntry->selfMacAddr);
3073 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3074
3075 /* Prepare the BSSID */
3076 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
3077
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079
3080 nStatus = dot11f_pack_de_auth(pMac, &frm, pFrame +
3081 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3082 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003083 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084 nStatus);
3085 cds_packet_free((void *)pPacket);
3086 return;
3087 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003088 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3089 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003091 pe_debug("***Sessionid %d Sending Deauth frame with "
3092 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
3093 " ,From " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 psessionEntry->peSessionId, nReason, waitForAck,
3095 MAC_ADDR_ARRAY(pMacHdr->da),
3096 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3097
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003098 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303099 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3100 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101 ) {
3102 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3103 }
3104
Sushant Kaushik46556062015-12-02 16:57:47 +05303105 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106#ifdef FEATURE_WLAN_TDLS
3107 pStaDs =
3108 dph_lookup_hash_entry(pMac, peer, &aid,
3109 &psessionEntry->dph.dphHashTable);
3110#endif
3111
3112 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303113 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003114 psessionEntry->peSessionId,
3115 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08003116 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3117 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003118 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303120 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
3122 TXRX_FRM_802_11_MGMT,
3123 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003124 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003125 txFlag, smeSessionId, false, 0,
3126 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303127 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303128 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303129 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303131 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003132 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303133 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134
3135 /* Call lim_process_deauth_ack_timeout which will send
3136 * DeauthCnf for this frame
3137 */
3138 lim_process_deauth_ack_timeout(pMac);
3139 return;
3140 }
3141
3142 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3143
3144 if (tx_timer_change
3145 (&pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3146 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003147 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 return;
3149 } else if (TX_SUCCESS !=
3150 tx_timer_activate(&pMac->lim.limTimers.
3151 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003152 pe_err("Unable to activate Deauth ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 lim_deactivate_and_change_timer(pMac,
3154 eLIM_DEAUTH_ACK_TIMER);
3155 return;
3156 }
3157 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303158 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 psessionEntry->peSessionId,
3160 pMacHdr->fc.subType));
3161#ifdef FEATURE_WLAN_TDLS
3162 if ((NULL != pStaDs)
3163 && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
3164 /* Queue Disassociation frame in high priority WQ */
Krunal Sonic65fc492018-03-09 15:53:28 -08003165 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3166 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003167 QDF_STATUS_SUCCESS,
3168 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303169 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3171 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3172 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003173 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 } else {
3175#endif
Krunal Sonic65fc492018-03-09 15:53:28 -08003176 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3177 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003178 QDF_STATUS_SUCCESS,
3179 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303181 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3183 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3184 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003185 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186#ifdef FEATURE_WLAN_TDLS
3187 }
3188#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303189 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303190 psessionEntry->peSessionId, qdf_status));
3191 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003192 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303193 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 /* Pkt will be freed up by the callback */
3195 }
3196 }
3197
3198} /* End lim_send_deauth_mgmt_frame. */
3199
3200#ifdef ANI_SUPPORT_11H
3201/**
3202 * \brief Send a Measurement Report Action frame
3203 *
3204 *
3205 * \param pMac Pointer to the global MAC structure
3206 *
3207 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3208 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003209 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 *
3211 *
3212 */
3213
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003214QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215lim_send_meas_report_frame(tpAniSirGlobal pMac,
3216 tpSirMacMeasReqActionFrame pMeasReqFrame,
3217 tSirMacAddr peer, tpPESession psessionEntry)
3218{
3219 tDot11fMeasurementReport frm;
3220 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003221 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 tpSirMacMgmtHdr pMacHdr;
3223 uint32_t nBytes, nPayload, nStatus;
3224 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303225 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303227 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228
3229 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3230 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3231 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3232
3233 switch (pMeasReqFrame->measReqIE.measType) {
3234 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3235 nSirStatus =
3236 populate_dot11f_measurement_report0(pMac, pMeasReqFrame,
3237 &frm.MeasurementReport);
3238 break;
3239 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3240 nSirStatus =
3241 populate_dot11f_measurement_report1(pMac, pMeasReqFrame,
3242 &frm.MeasurementReport);
3243 break;
3244 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3245 nSirStatus =
3246 populate_dot11f_measurement_report2(pMac, pMeasReqFrame,
3247 &frm.MeasurementReport);
3248 break;
3249 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003250 pe_err("Unknown measurement type %d in limSen"
3251 "dMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003253 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 }
3255
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003256 if (QDF_STATUS_SUCCESS != nSirStatus)
3257 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258
3259 nStatus = dot11f_get_packed_measurement_report_size(pMac, &frm, &nPayload);
3260 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003261 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 nStatus);
3263 /* We'll fall back on the worst case scenario: */
3264 nPayload = sizeof(tDot11fMeasurementReport);
3265 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003266 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3267 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 }
3269
3270 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3271
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303272 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003273 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 (uint16_t) nBytes, (void **)&pFrame,
3275 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303276 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003277 pe_err("Failed to allocate %d bytes for a "
3278 "De-Authentication", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003279 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 }
3281 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303282 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283
3284 /* Next, we fill out the buffer descriptor: */
3285 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3286 SIR_MAC_MGMT_ACTION, peer);
3287 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3288
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303289 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003291 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292
3293 nStatus = dot11f_pack_measurement_report(pMac, &frm, pFrame +
3294 sizeof(tSirMacMgmtHdr),
3295 nPayload, &nPayload);
3296 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003297 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003299 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003301 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003303 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3304 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 }
3306
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303307 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 ((psessionEntry) ? psessionEntry->
3309 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303310 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3312 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003313 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303314 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303315 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303317 qdf_status));
3318 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003319 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303320 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003322 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 }
3324
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003325 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326
3327} /* End lim_send_meas_report_frame. */
3328
3329/**
3330 * \brief Send a TPC Request Action frame
3331 *
3332 *
3333 * \param pMac Pointer to the global MAC datastructure
3334 *
3335 * \param peer MAC address to which the frame should be sent
3336 *
3337 *
3338 */
3339
3340void
3341lim_send_tpc_request_frame(tpAniSirGlobal pMac,
3342 tSirMacAddr peer, tpPESession psessionEntry)
3343{
3344 tDot11fTPCRequest frm;
3345 uint8_t *pFrame;
3346 tpSirMacMgmtHdr pMacHdr;
3347 uint32_t nBytes, nPayload, nStatus;
3348 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303349 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303351 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352
3353 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3354 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
3355 frm.DialogToken.token = 1;
3356 frm.TPCRequest.present = 1;
3357
3358 nStatus = dot11f_get_packed_tpc_request_size(pMac, &frm, &nPayload);
3359 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003360 pe_err("Failed to calculate the packed size for a TPC Request (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 /* We'll fall back on the worst case scenario: */
3362 nPayload = sizeof(tDot11fTPCRequest);
3363 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003364 pe_warn("There were warnings while calculating the packed size for a TPC Request (0x%08x)",
3365 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 }
3367
3368 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3369
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303370 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003371 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372 (uint16_t) nBytes, (void **)&pFrame,
3373 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303374 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003375 pe_err("Failed to allocate %d bytes for a TPC"
3376 " Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377 return;
3378 }
3379 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303380 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381
3382 /* Next, we fill out the buffer descriptor: */
3383 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3384 SIR_MAC_MGMT_ACTION, peer);
3385 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3386
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303387 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390
3391 nStatus = dot11f_pack_tpc_request(pMac, &frm, pFrame +
3392 sizeof(tSirMacMgmtHdr),
3393 nPayload, &nPayload);
3394 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003395 pe_err("Failed to pack a TPC Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003397 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 (void *)pFrame, (void *)pPacket);
3399 return; /* allocated! */
3400 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003401 pe_warn("There were warnings while packing a TPC Request (0x%08x)",
3402 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 }
3404
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303405 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 ((psessionEntry) ? psessionEntry->
3407 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303408 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3410 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003411 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303412 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303413 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303415 qdf_status));
3416 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003417 pe_err("Failed to send a TPC Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303418 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 /* Pkt will be freed up by the callback */
3420 }
3421
3422} /* End lim_send_tpc_request_frame. */
3423
3424/**
3425 * \brief Send a TPC Report Action frame
3426 *
3427 *
3428 * \param pMac Pointer to the global MAC datastructure
3429 *
3430 * \param pTpcReqFrame Pointer to the received TPC Request
3431 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003432 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 *
3434 *
3435 */
3436
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003437QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438lim_send_tpc_report_frame(tpAniSirGlobal pMac,
3439 tpSirMacTpcReqActionFrame pTpcReqFrame,
3440 tSirMacAddr peer, tpPESession psessionEntry)
3441{
3442 tDot11fTPCReport frm;
3443 uint8_t *pFrame;
3444 tpSirMacMgmtHdr pMacHdr;
3445 uint32_t nBytes, nPayload, nStatus;
3446 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303447 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303449 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450
3451 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3452 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3453 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3454
3455 frm.TPCReport.tx_power = 0;
3456 frm.TPCReport.link_margin = 0;
3457 frm.TPCReport.present = 1;
3458
3459 nStatus = dot11f_get_packed_tpc_report_size(pMac, &frm, &nPayload);
3460 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003461 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 /* We'll fall back on the worst case scenario: */
3463 nPayload = sizeof(tDot11fTPCReport);
3464 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003465 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3466 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 }
3468
3469 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3470
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303471 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003472 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473 (uint16_t) nBytes, (void **)&pFrame,
3474 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303475 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003476 pe_err("Failed to allocate %d bytes for a TPC"
3477 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003478 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479 }
3480 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303481 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482
3483 /* Next, we fill out the buffer descriptor: */
3484 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3485 SIR_MAC_MGMT_ACTION, peer);
3486
3487 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3488
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303489 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492
3493 nStatus = dot11f_pack_tpc_report(pMac, &frm, pFrame +
3494 sizeof(tSirMacMgmtHdr),
3495 nPayload, &nPayload);
3496 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003497 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003499 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003501 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003503 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3504 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303506 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003507 ((psessionEntry) ? psessionEntry->
3508 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303509 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3511 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003512 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303513 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003514 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3515 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
3516 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303517 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003518 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303519 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003521 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 }
3523
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003524 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525
3526} /* End lim_send_tpc_report_frame. */
3527#endif /* ANI_SUPPORT_11H */
3528
3529/**
3530 * \brief Send a Channel Switch Announcement
3531 *
3532 *
3533 * \param pMac Pointer to the global MAC datastructure
3534 *
3535 * \param peer MAC address to which this frame will be sent
3536 *
3537 * \param nMode
3538 *
3539 * \param nNewChannel
3540 *
3541 * \param nCount
3542 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003543 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 *
3545 *
3546 */
3547
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003548QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549lim_send_channel_switch_mgmt_frame(tpAniSirGlobal pMac,
3550 tSirMacAddr peer,
3551 uint8_t nMode,
3552 uint8_t nNewChannel,
3553 uint8_t nCount, tpPESession psessionEntry)
3554{
3555 tDot11fChannelSwitch frm;
3556 uint8_t *pFrame;
3557 tpSirMacMgmtHdr pMacHdr;
3558 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3559 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303560 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 uint8_t txFlag = 0;
3562
3563 uint8_t smeSessionId = 0;
3564
3565 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003566 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003567 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 }
3569 smeSessionId = psessionEntry->smeSessionId;
3570
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303571 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572
3573 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3574 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3575 frm.ChanSwitchAnn.switchMode = nMode;
3576 frm.ChanSwitchAnn.newChannel = nNewChannel;
3577 frm.ChanSwitchAnn.switchCount = nCount;
3578 frm.ChanSwitchAnn.present = 1;
3579
3580 nStatus = dot11f_get_packed_channel_switch_size(pMac, &frm, &nPayload);
3581 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003582 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 nStatus);
3584 /* We'll fall back on the worst case scenario: */
3585 nPayload = sizeof(tDot11fChannelSwitch);
3586 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003587 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3588 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 }
3590
3591 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3592
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303593 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3595 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303596 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003597 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003598 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003599 }
3600 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303601 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602
3603 /* Next, we fill out the buffer descriptor: */
3604 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3605 SIR_MAC_MGMT_ACTION, peer,
3606 psessionEntry->selfMacAddr);
3607 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303608 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3610
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612
3613 nStatus = dot11f_pack_channel_switch(pMac, &frm, pFrame +
3614 sizeof(tSirMacMgmtHdr),
3615 nPayload, &nPayload);
3616 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003617 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 nStatus);
3619 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003620 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003622 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3623 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624 }
3625
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003626 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303627 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3628 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 ) {
3630 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3631 }
3632
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303633 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303635 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 TXRX_FRM_802_11_MGMT,
3637 ANI_TXDIR_TODS,
3638 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003639 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303640 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303641 psessionEntry->peSessionId, qdf_status));
3642 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003643 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303644 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003646 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 }
3648
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003649 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650
3651} /* End lim_send_channel_switch_mgmt_frame. */
3652
Abhishek Singh518323d2015-10-19 17:42:01 +05303653/**
3654 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3655 * action frame over the air .
3656 * @mac_ctx: pointer to global mac structure
3657 * @peer: Destination mac.
3658 * @mode: channel switch mode
3659 * @new_op_class: new op class
3660 * @new_channel: new channel to switch
3661 * @count: channel switch count
3662 *
3663 * This function is called to send ECSA frame.
3664 *
3665 * Return: success if frame is sent else return failure
3666 */
3667
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003668QDF_STATUS
Abhishek Singh518323d2015-10-19 17:42:01 +05303669lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
3670 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
3671 uint8_t new_channel, uint8_t count, tpPESession session_entry)
3672{
3673 tDot11fext_channel_switch_action_frame frm;
3674 uint8_t *frame;
3675 tpSirMacMgmtHdr mac_hdr;
3676 uint32_t num_bytes, n_payload, status;
3677 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303678 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303679 uint8_t txFlag = 0;
3680 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303681 uint8_t ch_spacing;
3682 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303683
3684 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003685 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003686 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303687 }
3688
3689 sme_session_id = session_entry->smeSessionId;
3690
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303691 qdf_mem_set(&frm, sizeof(frm), 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303692
3693 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3694 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3695
3696 frm.ext_chan_switch_ann_action.switch_mode = mode;
3697 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3698 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3699 frm.ext_chan_switch_ann_action.switch_count = count;
3700
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303701 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3702 mac_ctx->scan.countryCodeCurrent, new_channel,
3703 new_op_class);
3704 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3705
3706 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3707 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3708 frm.WiderBWChanSwitchAnn.newChanWidth =
3709 wide_bw_ie->newChanWidth;
3710 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3711 wide_bw_ie->newCenterChanFreq0;
3712 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3713 wide_bw_ie->newCenterChanFreq1;
3714 frm.WiderBWChanSwitchAnn.present = 1;
3715 pe_debug("wrapper: width:%d f0:%d f1:%d",
3716 frm.WiderBWChanSwitchAnn.newChanWidth,
3717 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3718 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3719 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303720
3721 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3722 &frm, &n_payload);
3723 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003724 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303725 status);
3726 /* We'll fall back on the worst case scenario*/
3727 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3728 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003729 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303730 status);
3731 }
3732
3733 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3734
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303735 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303736 (void **) &frame, (void **) &packet);
3737
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303738 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003739 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303740 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003741 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303742 }
3743
3744 /* Paranoia*/
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303745 qdf_mem_set(frame, num_bytes, 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303746
3747 /* Next, we fill out the buffer descriptor */
3748 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3749 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3750 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303751 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303752 (uint8_t *) session_entry->bssId,
3753 sizeof(tSirMacAddr));
3754
gaolez4b62a9e2018-08-16 15:57:50 +08003755 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
3756
Abhishek Singh518323d2015-10-19 17:42:01 +05303757 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3758 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3759 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003760 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303761 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003762 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303763 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003764 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303765 status);
3766 }
3767
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003768 if ((BAND_5G ==
Abhishek Singh518323d2015-10-19 17:42:01 +05303769 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303770 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3771 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303772 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3773 }
3774
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003775 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 +05303776 MAC_ADDR_ARRAY(mac_hdr->da),
3777 frm.ext_chan_switch_ann_action.switch_count,
3778 frm.ext_chan_switch_ann_action.switch_mode,
3779 frm.ext_chan_switch_ann_action.new_channel,
3780 frm.ext_chan_switch_ann_action.op_class);
3781
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303782 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303783 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303784 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303785 TXRX_FRM_802_11_MGMT,
3786 ANI_TXDIR_TODS,
3787 7,
3788 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003789 txFlag, sme_session_id, 0,
3790 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303791 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303792 session_entry->peSessionId, qdf_status));
3793 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003794 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303795 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303796 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003797 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303798 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003799 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05303800} /* End lim_send_extended_chan_switch_action_frame */
3801
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303802
3803/**
3804 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3805 * sent over the air
3806 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303807 * @context: pointer to global mac
3808 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303809 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303810 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303811 *
3812 * Return: This returns QDF_STATUS
3813 */
3814
3815static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303816 void *context,
3817 qdf_nbuf_t buf,
3818 uint32_t tx_complete,
3819 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303820{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003821 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08003822 if (buf)
3823 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303824 return QDF_STATUS_SUCCESS;
3825}
3826
3827/**
3828 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3829 * p2p oper chan change confirm action frame
3830 * @mac_ctx: pointer to global mac structure
3831 * @peer: Destination mac.
3832 * @session_entry: session entry
3833 *
3834 * This function is called to send p2p oper chan change confirm action frame.
3835 *
3836 * Return: success if frame is sent else return failure
3837 */
3838
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003839QDF_STATUS
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303840lim_p2p_oper_chan_change_confirm_action_frame(tpAniSirGlobal mac_ctx,
3841 tSirMacAddr peer, tpPESession session_entry)
3842{
3843 tDot11fp2p_oper_chan_change_confirm frm;
3844 uint8_t *frame;
3845 tpSirMacMgmtHdr mac_hdr;
3846 uint32_t num_bytes, n_payload, status;
3847 void *packet;
3848 QDF_STATUS qdf_status;
3849 uint8_t tx_flag = 0;
3850 uint8_t sme_session_id = 0;
3851
3852 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003853 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003854 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303855 }
3856
3857 sme_session_id = session_entry->smeSessionId;
3858
3859 qdf_mem_set(&frm, sizeof(frm), 0);
3860
3861 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3862
3863 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3864 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3865 frm.p2p_action_subtype.subtype = 0x04;
3866 frm.DialogToken.token = 0x0;
3867
3868 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003869 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303870 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3871 }
3872
3873 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003874 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303875 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3876 populate_dot11f_operating_mode(mac_ctx,
3877 &frm.OperatingMode, session_entry);
3878 }
3879
3880 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3881 &frm, &n_payload);
3882 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003883 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303884 /* We'll fall back on the worst case scenario*/
3885 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3886 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003887 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3888 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303889 }
3890
3891 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3892
3893 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3894 (void **) &frame, (void **) &packet);
3895
3896 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003897 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003898 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303899 }
3900
3901 qdf_mem_set(frame, num_bytes, 0);
3902
3903 /* Next, fill out the buffer descriptor */
3904 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3905 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3906 mac_hdr = (tpSirMacMgmtHdr) frame;
3907 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3908 (uint8_t *) session_entry->bssId,
3909 sizeof(tSirMacAddr));
3910
3911 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3912 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3913 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003914 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303915 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003916 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303917 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003918 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303919 status);
3920 }
3921
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003922 if ((BAND_5G ==
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303923 lim_get_rf_band(session_entry->currentOperChannel)) ||
3924 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3925 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
3926 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3927 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003928 pe_debug("Send frame on channel %d to mac "
3929 MAC_ADDRESS_STR, session_entry->currentOperChannel,
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303930 MAC_ADDR_ARRAY(peer));
3931
3932 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3933 session_entry->peSessionId, mac_hdr->fc.subType));
3934
3935 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3936 (uint16_t)num_bytes,
3937 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3938 7, lim_tx_complete, frame,
3939 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07003940 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303941
3942 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3943 session_entry->peSessionId, qdf_status));
3944 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003945 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303946 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003947 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303948 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003949 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303950}
3951
3952
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003953QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954lim_send_vht_opmode_notification_frame(tpAniSirGlobal pMac,
3955 tSirMacAddr peer,
3956 uint8_t nMode, tpPESession psessionEntry)
3957{
3958 tDot11fOperatingMode frm;
3959 uint8_t *pFrame;
3960 tpSirMacMgmtHdr pMacHdr;
3961 uint32_t nBytes, nPayload = 0, nStatus; /* , nCfg; */
3962 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303963 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003964 uint8_t txFlag = 0;
3965
3966 uint8_t smeSessionId = 0;
3967
3968 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003969 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003970 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971 }
3972 smeSessionId = psessionEntry->smeSessionId;
3973
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303974 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975
3976 frm.Category.category = SIR_MAC_ACTION_VHT;
3977 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
3978 frm.OperatingMode.chanWidth = nMode;
3979 frm.OperatingMode.rxNSS = 0;
3980 frm.OperatingMode.rxNSSType = 0;
3981
3982 nStatus = dot11f_get_packed_operating_mode_size(pMac, &frm, &nPayload);
3983 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003984 pe_err("Failed to calculate the packed size for a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 nStatus);
3986 /* We'll fall back on the worst case scenario: */
3987 nPayload = sizeof(tDot11fOperatingMode);
3988 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003989 pe_warn("There were warnings while calculating the packed size for a Operating Mode (0x%08x)",
3990 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 }
3992
3993 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3994
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303995 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003996 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3997 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303998 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003999 pe_err("Failed to allocate %d bytes for a Operating Mode Report",
4000 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004001 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002 }
4003 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304004 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005
4006 /* Next, we fill out the buffer descriptor: */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304007 if (psessionEntry->pePersona == QDF_SAP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4009 SIR_MAC_MGMT_ACTION, peer,
4010 psessionEntry->selfMacAddr);
4011 else
4012 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4013 SIR_MAC_MGMT_ACTION, psessionEntry->bssId,
4014 psessionEntry->selfMacAddr);
4015 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304016 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
4018 nStatus = dot11f_pack_operating_mode(pMac, &frm, pFrame +
4019 sizeof(tSirMacMgmtHdr),
4020 nPayload, &nPayload);
4021 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004022 pe_err("Failed to pack a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 nStatus);
4024 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004025 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004027 pe_warn("There were warnings while packing a Operating Mode (0x%08x)",
4028 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004030 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304031 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4032 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 ) {
4034 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4035 }
4036
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304037 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304039 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004040 TXRX_FRM_802_11_MGMT,
4041 ANI_TXDIR_TODS,
4042 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004043 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304044 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304045 psessionEntry->peSessionId, qdf_status));
4046 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004047 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304048 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004050 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 }
4052
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004053 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054}
4055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056/**
4057 * \brief Send a Neighbor Report Request Action frame
4058 *
4059 *
4060 * \param pMac Pointer to the global MAC structure
4061 *
4062 * \param pNeighborReq Address of a tSirMacNeighborReportReq
4063 *
4064 * \param peer mac address of peer station.
4065 *
4066 * \param psessionEntry address of session entry.
4067 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004068 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069 *
4070 *
4071 */
4072
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004073QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074lim_send_neighbor_report_request_frame(tpAniSirGlobal pMac,
4075 tpSirMacNeighborReportReq pNeighborReq,
4076 tSirMacAddr peer, tpPESession psessionEntry)
4077{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004078 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079 tDot11fNeighborReportRequest frm;
4080 uint8_t *pFrame;
4081 tpSirMacMgmtHdr pMacHdr;
4082 uint32_t nBytes, nPayload, nStatus;
4083 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304084 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085 uint8_t txFlag = 0;
4086 uint8_t smeSessionId = 0;
4087
4088 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004089 pe_err("(psession == NULL) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004090 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 }
4092 smeSessionId = psessionEntry->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304093 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094
4095 frm.Category.category = SIR_MAC_ACTION_RRM;
4096 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
4097 frm.DialogToken.token = pNeighborReq->dialogToken;
4098
4099 if (pNeighborReq->ssid_present) {
4100 populate_dot11f_ssid(pMac, &pNeighborReq->ssid, &frm.SSID);
4101 }
4102
4103 nStatus =
4104 dot11f_get_packed_neighbor_report_request_size(pMac, &frm, &nPayload);
4105 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004106 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107 nStatus);
4108 /* We'll fall back on the worst case scenario: */
4109 nPayload = sizeof(tDot11fNeighborReportRequest);
4110 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004111 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4112 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 }
4114
4115 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4116
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304117 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4119 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304120 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004121 pe_err("Failed to allocate %d bytes for a Neighbor "
4122 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004123 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004124 }
4125 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304126 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127
4128 /* Copy necessary info to BD */
4129 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4130 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4131
4132 /* Update A3 with the BSSID */
4133 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4134
4135 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138
4139 /* Now, we're ready to "pack" the frames */
4140 nStatus = dot11f_pack_neighbor_report_request(pMac,
4141 &frm,
4142 pFrame +
4143 sizeof(tSirMacMgmtHdr),
4144 nPayload, &nPayload);
4145
4146 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004147 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 nStatus);
4149
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004150 /* FIXME - Need to convert to QDF_STATUS */
4151 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 goto returnAfterError;
4153 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004154 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4155 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156 }
4157
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004158 pe_debug("Sending a Neighbor Report Request to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +05304159 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004161 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304162 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4163 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 ) {
4165 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4166 }
4167
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304168 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304170 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 pPacket,
4172 (uint16_t) nBytes,
4173 TXRX_FRM_802_11_MGMT,
4174 ANI_TXDIR_TODS,
4175 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004176 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304177 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304178 psessionEntry->peSessionId, qdf_status));
4179 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004180 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004181 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 /* Pkt will be freed up by the callback */
4183 return statusCode;
4184 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004185 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186
4187returnAfterError:
4188 cds_packet_free((void *)pPacket);
4189
4190 return statusCode;
4191} /* End lim_send_neighbor_report_request_frame. */
4192
4193/**
4194 * \brief Send a Link Report Action frame
4195 *
4196 *
4197 * \param pMac Pointer to the global MAC structure
4198 *
4199 * \param pLinkReport Address of a tSirMacLinkReport
4200 *
4201 * \param peer mac address of peer station.
4202 *
4203 * \param psessionEntry address of session entry.
4204 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004205 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 *
4207 *
4208 */
4209
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004210QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211lim_send_link_report_action_frame(tpAniSirGlobal pMac,
4212 tpSirMacLinkReport pLinkReport,
4213 tSirMacAddr peer, tpPESession psessionEntry)
4214{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004215 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216 tDot11fLinkMeasurementReport frm;
4217 uint8_t *pFrame;
4218 tpSirMacMgmtHdr pMacHdr;
4219 uint32_t nBytes, nPayload, nStatus;
4220 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304221 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 uint8_t txFlag = 0;
4223 uint8_t smeSessionId = 0;
4224
4225 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004226 pe_err("(psession == NULL) in Request to send Link Report action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004227 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228 }
4229
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304230 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231
4232 frm.Category.category = SIR_MAC_ACTION_RRM;
4233 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
4234 frm.DialogToken.token = pLinkReport->dialogToken;
4235
4236 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4237 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4238 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4239 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4240 /* such case this way than changing the frame parser. */
4241 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
4242 frm.TPCEleLen.TPCLen = 2;
4243 frm.TxPower.txPower = pLinkReport->txPower;
4244 frm.LinkMargin.linkMargin = 0;
4245
4246 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4247 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4248 frm.RCPI.rcpi = pLinkReport->rcpi;
4249 frm.RSNI.rsni = pLinkReport->rsni;
4250
4251 nStatus =
4252 dot11f_get_packed_link_measurement_report_size(pMac, &frm, &nPayload);
4253 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004254 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 /* We'll fall back on the worst case scenario: */
4256 nPayload = sizeof(tDot11fLinkMeasurementReport);
4257 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004258 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4259 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 }
4261
4262 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4263
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304264 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4266 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304267 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004268 pe_err("Failed to allocate %d bytes for a Link "
4269 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004270 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271 }
4272 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304273 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274
4275 /* Copy necessary info to BD */
4276 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4277 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4278
4279 /* Update A3 with the BSSID */
4280 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4281
4282 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4283
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004285
4286 /* Now, we're ready to "pack" the frames */
4287 nStatus = dot11f_pack_link_measurement_report(pMac,
4288 &frm,
4289 pFrame +
4290 sizeof(tSirMacMgmtHdr),
4291 nPayload, &nPayload);
4292
4293 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004294 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004296 /* FIXME - Need to convert to QDF_STATUS */
4297 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298 goto returnAfterError;
4299 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004300 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301 nStatus);
4302 }
4303
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004304 pe_warn("Sending a Link Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 lim_print_mac_addr(pMac, peer, LOGW);
4306
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004307 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304308 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4309 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4311 }
4312
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304313 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304315 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316 pPacket,
4317 (uint16_t) nBytes,
4318 TXRX_FRM_802_11_MGMT,
4319 ANI_TXDIR_TODS,
4320 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004321 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304322 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304323 psessionEntry->peSessionId, qdf_status));
4324 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004325 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004326 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327 /* Pkt will be freed up by the callback */
4328 return statusCode;
4329 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004330 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331
4332returnAfterError:
4333 cds_packet_free((void *)pPacket);
4334
4335 return statusCode;
4336} /* End lim_send_link_report_action_frame. */
4337
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004338QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339lim_send_radio_measure_report_action_frame(tpAniSirGlobal pMac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304340 uint8_t dialog_token,
4341 uint8_t num_report,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304342 bool is_last_frame,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304343 tpSirMacRadioMeasureReport pRRMReport,
4344 tSirMacAddr peer,
4345 tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004347 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348 uint8_t *pFrame;
4349 tpSirMacMgmtHdr pMacHdr;
4350 uint32_t nBytes, nPayload, nStatus;
4351 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304352 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353 uint8_t i;
4354 uint8_t txFlag = 0;
4355 uint8_t smeSessionId = 0;
4356
4357 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304358 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004359 if (!frm)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004360 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004361
4362 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004363 pe_err("(psession == NULL) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304364 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004365 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004367
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004368 smeSessionId = psessionEntry->smeSessionId;
4369
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304370 pe_debug("dialog_token %d num_report %d is_last_frame %d",
4371 dialog_token, num_report, is_last_frame);
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304372
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373 frm->Category.category = SIR_MAC_ACTION_RRM;
4374 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4375 frm->DialogToken.token = dialog_token;
4376
4377 frm->num_MeasurementReport =
4378 (num_report >
4379 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4380 num_report;
4381
4382 for (i = 0; i < frm->num_MeasurementReport; i++) {
4383 frm->MeasurementReport[i].type = pRRMReport[i].type;
4384 frm->MeasurementReport[i].token = pRRMReport[i].token;
4385 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4386 switch (pRRMReport[i].type) {
4387 case SIR_MAC_RRM_BEACON_TYPE:
4388 populate_dot11f_beacon_report(pMac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304389 &frm->MeasurementReport[i],
4390 &pRRMReport[i].report.
4391 beaconReport,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304392 is_last_frame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393 frm->MeasurementReport[i].incapable =
4394 pRRMReport[i].incapable;
4395 frm->MeasurementReport[i].refused =
4396 pRRMReport[i].refused;
4397 frm->MeasurementReport[i].present = 1;
4398 break;
4399 default:
4400 frm->MeasurementReport[i].incapable =
4401 pRRMReport[i].incapable;
4402 frm->MeasurementReport[i].refused =
4403 pRRMReport[i].refused;
4404 frm->MeasurementReport[i].present = 1;
4405 break;
4406 }
4407 }
4408
4409 nStatus =
4410 dot11f_get_packed_radio_measurement_report_size(pMac, frm, &nPayload);
4411 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004412 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413 nStatus);
4414 /* We'll fall back on the worst case scenario: */
4415 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304416 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004417 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004419 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4420 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 }
4422
4423 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4424
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304425 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4427 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304428 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004429 pe_err("Failed to allocate %d bytes for a Radio Measure "
4430 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304431 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004432 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433 }
4434 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304435 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436
4437 /* Copy necessary info to BD */
4438 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4439 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4440
4441 /* Update A3 with the BSSID */
4442 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4443
4444 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4445
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447
4448 /* Now, we're ready to "pack" the frames */
4449 nStatus = dot11f_pack_radio_measurement_report(pMac,
4450 frm,
4451 pFrame +
4452 sizeof(tSirMacMgmtHdr),
4453 nPayload, &nPayload);
4454
4455 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004456 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457 nStatus);
4458
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004459 /* FIXME - Need to convert to QDF_STATUS */
4460 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461 goto returnAfterError;
4462 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004463 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4464 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 }
4466
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004467 pe_warn("Sending a Radio Measure Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004468 lim_print_mac_addr(pMac, peer, LOGW);
4469
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004470 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304471 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4472 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 ) {
4474 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4475 }
4476
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304477 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304479 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 pPacket,
4481 (uint16_t) nBytes,
4482 TXRX_FRM_802_11_MGMT,
4483 ANI_TXDIR_TODS,
4484 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004485 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304486 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304487 psessionEntry->peSessionId, qdf_status));
4488 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004489 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004490 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304492 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 return statusCode;
4494 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304495 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004496 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 }
4498
4499returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304500 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 cds_packet_free((void *)pPacket);
4502 return statusCode;
4503}
4504
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505#ifdef WLAN_FEATURE_11W
4506/**
4507 * \brief Send SA query request action frame to peer
4508 *
4509 * \sa lim_send_sa_query_request_frame
4510 *
4511 *
4512 * \param pMac The global tpAniSirGlobal object
4513 *
4514 * \param transId Transaction identifier
4515 *
4516 * \param peer The Mac address of the station to which this action frame is addressed
4517 *
4518 * \param psessionEntry The PE session entry
4519 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004520 * \return QDF_STATUS_SUCCESS if setup completes successfully
4521 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 */
4523
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004524QDF_STATUS lim_send_sa_query_request_frame(tpAniSirGlobal pMac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 tSirMacAddr peer,
4526 tpPESession psessionEntry)
4527{
4528
4529 tDot11fSaQueryReq frm; /* SA query request action frame */
4530 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004531 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532 tpSirMacMgmtHdr pMacHdr;
4533 uint32_t nBytes, nPayload, nStatus;
4534 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304535 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004536 uint8_t txFlag = 0;
4537 uint8_t smeSessionId = 0;
4538
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304539 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004540 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4541 /* 11w action field is :
4542 action: 0 --> SA Query Request action frame
4543 action: 1 --> SA Query Response action frame */
4544 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4545 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304546 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547
4548 nStatus = dot11f_get_packed_sa_query_req_size(pMac, &frm, &nPayload);
4549 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004550 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 nStatus);
4552 /* We'll fall back on the worst case scenario: */
4553 nPayload = sizeof(tDot11fSaQueryReq);
4554 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004555 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4556 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 }
4558
4559 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304560 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304562 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004563 pe_err("Failed to allocate %d bytes for a SA Query Request "
4564 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004565 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 }
4567 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304568 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569
4570 /* Copy necessary info to BD */
4571 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4572 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4573
4574 /* Update A3 with the BSSID */
4575 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4576
4577 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4578
4579 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4580 /* in the FC */
4581 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4582
4583 /* Pack 11w SA Query Request frame */
4584 nStatus = dot11f_pack_sa_query_req(pMac,
4585 &frm,
4586 pFrame + sizeof(tSirMacMgmtHdr),
4587 nPayload, &nPayload);
4588
4589 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004590 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004592 /* FIXME - Need to convert to QDF_STATUS */
4593 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 goto returnAfterError;
4595 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004596 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 nStatus);
4598 }
4599
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004600 pe_debug("Sending an SA Query Request to");
4601 lim_print_mac_addr(pMac, peer, LOGD);
4602 pe_debug("Sending an SA Query Request from ");
4603 lim_print_mac_addr(pMac, psessionEntry->selfMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004605 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304607 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4608 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609#endif
4610 ) {
4611 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4612 }
4613 smeSessionId = psessionEntry->smeSessionId;
4614
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304615 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616 pPacket,
4617 (uint16_t) nBytes,
4618 TXRX_FRM_802_11_MGMT,
4619 ANI_TXDIR_TODS,
4620 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004621 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304622 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004623 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004624 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625 /* Pkt will be freed up by the callback */
4626 return nSirStatus;
4627 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004628 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 }
4630
4631returnAfterError:
4632 cds_packet_free((void *)pPacket);
4633 return nSirStatus;
4634} /* End lim_send_sa_query_request_frame */
4635
4636/**
4637 * \brief Send SA query response action frame to peer
4638 *
4639 * \sa lim_send_sa_query_response_frame
4640 *
4641 *
4642 * \param pMac The global tpAniSirGlobal object
4643 *
4644 * \param transId Transaction identifier received in SA query request action frame
4645 *
4646 * \param peer The Mac address of the AP to which this action frame is addressed
4647 *
4648 * \param psessionEntry The PE session entry
4649 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004650 * \return QDF_STATUS_SUCCESS if setup completes successfully
4651 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 */
4653
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004654QDF_STATUS lim_send_sa_query_response_frame(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 uint8_t *transId, tSirMacAddr peer,
4656 tpPESession psessionEntry)
4657{
4658
Jeff Johnson47d75242018-05-12 15:58:53 -07004659 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004661 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662 tpSirMacMgmtHdr pMacHdr;
4663 uint32_t nBytes, nPayload, nStatus;
4664 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304665 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 uint8_t txFlag = 0;
4667 uint8_t smeSessionId = 0;
4668
4669 smeSessionId = psessionEntry->smeSessionId;
4670
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304671 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4673 /*11w action field is :
4674 action: 0 --> SA query request action frame
4675 action: 1 --> SA query response action frame */
4676 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4677 /*11w SA query response transId is same as
4678 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304679 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680
4681 nStatus = dot11f_get_packed_sa_query_rsp_size(pMac, &frm, &nPayload);
4682 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004683 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 nStatus);
4685 /* We'll fall back on the worst case scenario: */
4686 nPayload = sizeof(tDot11fSaQueryRsp);
4687 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004688 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4689 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 }
4691
4692 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304693 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304695 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004696 pe_err("Failed to allocate %d bytes for a SA query response"
4697 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004698 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 }
4700 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304701 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004702
4703 /* Copy necessary info to BD */
4704 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4705 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4706
4707 /* Update A3 with the BSSID */
4708 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4709
4710 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4711
4712 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4713 /* in the FC */
4714 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4715
4716 /* Pack 11w SA query response frame */
4717 nStatus = dot11f_pack_sa_query_rsp(pMac,
4718 &frm,
4719 pFrame + sizeof(tSirMacMgmtHdr),
4720 nPayload, &nPayload);
4721
4722 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004723 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004725 /* FIXME - Need to convert to QDF_STATUS */
4726 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727 goto returnAfterError;
4728 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004729 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004730 nStatus);
4731 }
4732
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004733 pe_debug("Sending a SA Query Response to");
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07004734 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004735
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004736 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004737#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304738 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4739 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004740#endif
4741 ) {
4742 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4743 }
4744
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304745 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304747 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 pPacket,
4749 (uint16_t) nBytes,
4750 TXRX_FRM_802_11_MGMT,
4751 ANI_TXDIR_TODS,
4752 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004753 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304754 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304755 psessionEntry->peSessionId, qdf_status));
4756 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004757 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004758 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759 /* Pkt will be freed up by the callback */
4760 return nSirStatus;
4761 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004762 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 }
4764
4765returnAfterError:
4766 cds_packet_free((void *)pPacket);
4767 return nSirStatus;
4768} /* End lim_send_sa_query_response_frame */
4769#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004770
4771/**
4772 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4773 * @mac_ctx: mac context
4774 * @peer_mac: Peer MAC address
4775 * @tid: TID for which addba response is being sent
4776 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004777 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004778 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004779 *
4780 * This function is called when ADDBA request is successful. ADDBA response is
4781 * setup by calling addba_response_setup API and frame is then sent out OTA.
4782 *
4783 * Return: QDF_STATUS
4784 */
4785QDF_STATUS lim_send_addba_response_frame(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004786 tSirMacAddr peer_mac, uint16_t tid,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004787 tpPESession session, uint8_t addba_extn_present,
4788 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004789{
4790
4791 tDot11faddba_rsp frm;
4792 uint8_t *frame_ptr;
4793 tpSirMacMgmtHdr mgmt_hdr;
4794 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004795 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004796 QDF_STATUS qdf_status;
4797 uint8_t tx_flag = 0;
4798 uint8_t sme_sessionid = 0;
4799 uint16_t buff_size, status_code, batimeout;
4800 uint8_t peer_id, dialog_token;
4801 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4802 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004803 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004804
4805 sme_sessionid = session->smeSessionId;
4806
4807 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4808 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004809 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004810 return QDF_STATUS_E_FAILURE;
4811 }
4812
Mohit Khannac4c22252017-11-20 11:06:33 -08004813 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4814 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004815 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004816 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004817 return QDF_STATUS_E_FAILURE;
4818 }
4819
4820 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4821 &status_code, &buff_size, &batimeout);
4822
Mohit Khannac4c22252017-11-20 11:06:33 -08004823 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004824 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
4825 frm.Category.category = SIR_MAC_ACTION_BLKACK;
4826 frm.Action.action = SIR_MAC_ADDBA_RSP;
4827
4828 frm.DialogToken.token = dialog_token;
4829 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004830 if (mac_ctx->reject_addba_req) {
4831 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4832 pe_err("refused addba req");
4833 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004834 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere96180e12018-03-12 17:58:23 -07004835 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004836 if (mac_ctx->usr_cfg_ba_buff_size)
4837 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07004838
4839 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
4840 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4841
4842 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
4843 if (session->active_ba_64_session) {
4844 frm.addba_param_set.buff_size =
4845 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
4846 }
4847 } else if (!session->active_ba_64_session) {
4848 session->active_ba_64_session = true;
4849 }
Arif Hussain0e246802018-05-01 18:13:44 -07004850 if (mac_ctx->is_usr_cfg_amsdu_enabled)
4851 frm.addba_param_set.amsdu_supp = amsdu_support;
4852 else
4853 frm.addba_param_set.amsdu_supp = 0;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004854 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004855 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004856 if (addba_extn_present) {
4857 frm.addba_extn_element.present = 1;
4858 frm.addba_extn_element.no_fragmentation = 1;
4859 if (lim_is_session_he_capable(session)) {
4860 he_frag = lim_get_session_he_frag_cap(session);
4861 if (he_frag != 0) {
4862 frm.addba_extn_element.no_fragmentation = 0;
4863 frm.addba_extn_element.he_frag_operation =
4864 he_frag;
4865 }
4866 }
4867 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004868
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004869 pe_debug("Sending a ADDBA Response from %pM to %pM",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004870 session->selfMacAddr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004871 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004872 tid, frm.DialogToken.token, frm.Status.status,
4873 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004874 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4875 addba_extn_present,
4876 lim_is_session_he_capable(session),
4877 frm.addba_extn_element.no_fragmentation,
4878 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004879
4880 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4881 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004882 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004883 status);
4884 /* We'll fall back on the worst case scenario: */
4885 payload_size = sizeof(tDot11faddba_rsp);
4886 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004887 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 -08004888 }
4889
4890 num_bytes = payload_size + sizeof(*mgmt_hdr);
4891 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4892 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004893 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004894 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4895 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004896 return QDF_STATUS_E_FAILURE;
4897 }
4898 qdf_mem_set(frame_ptr, num_bytes, 0);
4899
4900 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
4901 SIR_MAC_MGMT_ACTION, peer_mac, session->selfMacAddr);
4902
4903 /* Update A3 with the BSSID */
4904 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4905 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4906
4907 /* ADDBA Response is a robust mgmt action frame,
4908 * set the "protect" (aka WEP) bit in the FC
4909 */
4910 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4911
4912 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4913 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4914 &payload_size);
4915
4916 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004917 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004918 status);
4919 qdf_status = QDF_STATUS_E_FAILURE;
4920 goto error_addba_rsp;
4921 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004922 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004923 status);
4924 }
4925
4926
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004927 if ((BAND_5G == lim_get_rf_band(session->currentOperChannel))
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004928#ifdef WLAN_FEATURE_P2P
4929 || (session->pePersona == QDF_P2P_CLIENT_MODE) ||
4930 (session->pePersona == QDF_P2P_GO_MODE)
4931#endif
4932 ) {
4933 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4934 }
4935
4936 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4937 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07004938 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
4939 (uint16_t)num_bytes,
4940 TXRX_FRM_802_11_MGMT,
4941 ANI_TXDIR_TODS, 7,
4942 NULL, frame_ptr,
4943 lim_addba_rsp_tx_complete_cnf,
4944 tx_flag, sme_sessionid,
4945 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004946 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4947 session->peSessionId, qdf_status));
4948 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004949 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004950 qdf_status);
4951 qdf_status = QDF_STATUS_E_FAILURE;
4952 /*
4953 * wma_tx_frame free memory in certain cases, free pkt_ptr
4954 * only if not freed already.
4955 */
4956 if (pkt_ptr)
4957 cds_packet_free((void *)pkt_ptr);
4958 return qdf_status;
4959 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004960 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004961 }
4962
4963error_addba_rsp:
4964 cds_packet_free((void *)pkt_ptr);
4965 return qdf_status;
4966}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304967
4968/**
4969 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4970 * @mac_ctx Pointer to Global MAC structure
4971 * @mb_msg: Received message info
4972 * @msg_len: Received message length
4973 * @packet: Packet to be transmitted
4974 * @frame: Received frame
4975 *
4976 * Return: None
4977 */
4978static void lim_tx_mgmt_frame(tpAniSirGlobal mac_ctx,
4979 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
4980 void *packet, uint8_t *frame)
4981{
4982 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4983 QDF_STATUS qdf_status;
4984 uint8_t sme_session_id = 0;
4985 tpPESession session;
4986 uint16_t auth_ack_status;
4987 enum rateid min_rid = RATEID_DEFAULT;
4988
4989 sme_session_id = mb_msg->session_id;
4990 session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
4991 if (session == NULL) {
4992 pe_err("session not found for given sme session");
4993 return;
4994 }
4995
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05304996 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
4997 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304998
4999 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
5000 min_rid = lim_get_min_session_txrate(session);
5001
5002 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
5003 (uint16_t)msg_len,
5004 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
5005 7, lim_tx_complete, frame,
5006 lim_auth_tx_complete_cnf,
5007 0, sme_session_id, false, 0, min_rid);
5008 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5009 session->peSessionId, qdf_status));
5010 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05305011 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
5012 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305013 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
5014 auth_ack_status = SENT_FAIL;
5015 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005016 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305017 /* Pkt will be freed up by the callback */
5018 }
5019}
5020
5021void lim_send_mgmt_frame_tx(tpAniSirGlobal mac_ctx,
5022 struct scheduler_msg *msg)
5023{
5024 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
5025 uint32_t msg_len;
5026 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5027 uint8_t sme_session_id;
5028 QDF_STATUS qdf_status;
5029 uint8_t *frame;
5030 void *packet;
5031
5032 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
5033 pe_debug("sending fc->type: %d fc->subType: %d",
5034 fc->type, fc->subType);
5035
5036 sme_session_id = mb_msg->session_id;
5037
5038 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
5039 (void **)&packet);
5040 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5041 pe_err("call to bufAlloc failed for AUTH frame");
5042 return;
5043 }
5044
5045 qdf_mem_copy(frame, mb_msg->data, msg_len);
5046
5047 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5048}