blob: 827720b4a1cf12fc31f8ae51978c62d7a0c93a27 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302 * Copyright (c) 2011-2019 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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080030#include "utils_api.h"
31#include "lim_types.h"
32#include "lim_utils.h"
33#include "lim_security_utils.h"
34#include "lim_prop_exts_utils.h"
35#include "dot11f.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080036#include "sch_api.h"
37#include "lim_send_messages.h"
38#include "lim_assoc_utils.h"
39#include "lim_ft.h"
40#ifdef WLAN_FEATURE_11W
41#include "wni_cfg.h"
42#endif
43
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080044#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053046#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053047#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "cds_utils.h"
49#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "rrm_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053051#include "qdf_crypto.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052
53#include "wma_types.h"
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -080054#include <cdp_txrx_cmn.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070055#include <cdp_txrx_peer_ops.h>
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053056#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070057#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080058
59/**
60 *
61 * \brief This function is called to add the sequence number to the
62 * management frames
63 *
Jeff Johnson99f25042018-11-21 22:49:06 -080064 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065 *
66 * \param pMacHdr Pointer to MAC management header
67 *
68 * The pMacHdr argument points to the MAC management header. The
Jeff Johnson99f25042018-11-21 22:49:06 -080069 * sequence number stored in the mac structure will be incremented
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 * and updated to the MAC management header. The start sequence
71 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
72 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
73 * number will roll over.
74 *
75 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080076static void lim_add_mgmt_seq_num(struct mac_context *mac, tpSirMacMgmtHdr pMacHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077{
Jeff Johnson99f25042018-11-21 22:49:06 -080078 if (mac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
79 mac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 }
81
Jeff Johnson99f25042018-11-21 22:49:06 -080082 mac->mgmtSeqNum++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083
Jeff Johnson99f25042018-11-21 22:49:06 -080084 pMacHdr->seqControl.seqNumLo = (mac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085 pMacHdr->seqControl.seqNumHi =
Jeff Johnson99f25042018-11-21 22:49:06 -080086 ((mac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087}
88
89/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090 * lim_populate_mac_header() - Fill in 802.11 header of frame
91 *
92 * @mac_ctx: Pointer to Global MAC structure
93 * @buf: Pointer to the frame buffer that needs to be populate
94 * @type: 802.11 Type of the frame
95 * @sub_type: 802.11 Subtype of the frame
96 * @peer_addr: dst address
97 * @self_mac_addr: local mac address
98 *
99 * This function is called by various LIM modules to prepare the
100 * 802.11 frame MAC header
101 *
102 * The buf argument points to the beginning of the frame buffer to
103 * which - a) The 802.11 MAC header is set b) Following this MAC header
104 * will be the MGMT frame payload The payload itself is populated by the
105 * caller API
106 *
107 * Return: None
108 */
109
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800110void lim_populate_mac_header(struct mac_context *mac_ctx, uint8_t *buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
112 tSirMacAddr self_mac_addr)
113{
114 tpSirMacMgmtHdr mac_hdr;
115
116 /* Prepare MAC management header */
117 mac_hdr = (tpSirMacMgmtHdr) (buf);
118
119 /* Prepare FC */
120 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
121 mac_hdr->fc.type = type;
122 mac_hdr->fc.subType = sub_type;
123
124 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530125 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800126 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
127
128 /* Prepare Address 2 */
129 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
130
131 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530132 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
134
135 /* Prepare sequence number */
136 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700137 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138 mac_hdr->seqControl.seqNumLo,
139 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
140}
141
142/**
143 * lim_send_probe_req_mgmt_frame() - send probe request management frame
144 * @mac_ctx: Pointer to Global MAC structure
145 * @ssid: SSID to be sent in Probe Request frame
146 * @bssid: BSSID to be sent in Probe Request frame
147 * @channel: Channel # on which the Probe Request is going out
148 * @self_macaddr: self MAC address
149 * @dot11mode: self dotllmode
150 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
151 * frame
152 * @additional_ie: if additional_ielen is non zero, include this field in the
153 * Probe Request frame
154 *
155 * This function is called by various LIM modules to send Probe Request frame
156 * during active scan/learn phase.
157 * Probe request is sent out in the following scenarios:
158 * --heartbeat failure: session needed
159 * --join req: session needed
160 * --foreground scan: no session
161 * --background scan: no session
162 * --sch_beacon_processing: to get EDCA parameters: session needed
163 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700164 * Return: QDF_STATUS (QDF_STATUS_SUCCESS on success and error codes otherwise)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700166QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800167lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 tSirMacSSid *ssid,
169 tSirMacAddr bssid,
170 uint8_t channel,
171 tSirMacAddr self_macaddr,
172 uint32_t dot11mode,
Jeff Johnson919f2c32019-01-16 11:22:24 -0800173 uint16_t *additional_ielen,
174 uint8_t *additional_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175{
176 tDot11fProbeRequest pr;
177 uint32_t status, bytes, payload;
178 uint8_t *frame;
179 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530180 QDF_STATUS qdf_status;
Jeff Johnsona7815652018-11-18 22:58:30 -0800181 struct pe_session *pesession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 uint8_t sessionid;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700183 const uint8_t *p2pie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 uint8_t txflag = 0;
185 uint8_t sme_sessionid = 0;
186 bool is_vht_enabled = false;
187 uint8_t txPower;
Arif Hussain4c265132018-04-23 18:55:26 -0700188 uint16_t addn_ielen = 0;
Kapil Guptac03eb072016-08-09 14:01:36 +0530189 bool extracted_ext_cap_flag = false;
190 tDot11fIEExtCap extracted_ext_cap;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700191 QDF_STATUS sir_status;
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530192 const uint8_t *qcn_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193
Arif Hussain4c265132018-04-23 18:55:26 -0700194 if (additional_ielen)
195 addn_ielen = *additional_ielen;
196
Jeff Johnson919f2c32019-01-16 11:22:24 -0800197 /*
198 * The probe req should not send 11ac capabilities if band is
199 * 2.4GHz, unless gEnableVhtFor24GHzBand is enabled in INI. So
200 * if gEnableVhtFor24GHzBand is false and dot11mode is 11ac
201 * set it to 11n.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202 */
203 if (channel <= SIR_11B_CHANNEL_END &&
Abhinav Kumare057b412018-10-09 17:28:16 +0530204 !mac_ctx->mlme_cfg->vht_caps.vht_cap_info.b24ghz_band &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530205 (MLME_DOT11_MODE_11AC == dot11mode ||
206 MLME_DOT11_MODE_11AC_ONLY == dot11mode))
207 dot11mode = MLME_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 /*
209 * session context may or may not be present, when probe request needs
210 * to be sent out. Following cases exist:
211 * --heartbeat failure: session needed
212 * --join req: session needed
213 * --foreground scan: no session
214 * --background scan: no session
215 * --sch_beacon_processing: to get EDCA parameters: session needed
216 * If session context does not exist, some IEs will be populated from
217 * CFGs, e.g. Supported and Extended rate set IEs
218 */
219 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
220
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700221 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 sme_sessionid = pesession->smeSessionId;
223
224 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
225 /* and then hand it off to 'dot11f_pack_probe_request' (for */
226 /* serialization). We start by zero-initializing the structure: */
hangtian127c9532019-01-12 13:29:07 +0800227 qdf_mem_zero((uint8_t *) &pr, sizeof(pr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228
229 /* & delegating to assorted helpers: */
230 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
231
232 if (addn_ielen && additional_ie)
233 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
234
235 /*
236 * Don't include 11b rate if it is a P2P serach or probe request is
237 * sent by P2P Client
238 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700239 if ((MLME_DOT11_MODE_11B != dot11mode) && (p2pie) &&
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530240 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 /*
242 * In the below API pass channel number > 14, do that it fills
243 * only 11a rates in supported rates
244 */
245 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
246 pesession);
247 } else {
248 populate_dot11f_supp_rates(mac_ctx, channel,
249 &pr.SuppRates, pesession);
250
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530251 if (MLME_DOT11_MODE_11B != dot11mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
253 &pr.ExtSuppRates);
254 }
255 }
256
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 /*
258 * Table 7-14 in IEEE Std. 802.11k-2008 says
259 * DS params "can" be present in RRM is disabled and "is" present if
260 * RRM is enabled. It should be ok even if we add it into probe req when
261 * RRM is not enabled.
262 */
263 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
264 /* Call RRM module to get the tx power for management used. */
265 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
266 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700269 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
271 /* Include HT Capability IE */
272 if (pesession->htCapability)
273 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700274 } else { /* !pesession */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 if (IS_DOT11_MODE_HT(dot11mode))
276 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
277 }
278
279 /*
280 * Set channelbonding information as "disabled" when tunned to a
281 * 2.4 GHz channel
282 */
283 if (channel <= SIR_11B_CHANNEL_END) {
284 if (mac_ctx->roam.configParam.channelBondingMode24GHz
285 == PHY_SINGLE_CHANNEL_CENTERED) {
286 pr.HTCaps.supportedChannelWidthSet =
287 eHT_CHANNEL_WIDTH_20MHZ;
288 pr.HTCaps.shortGI40MHz = 0;
289 } else {
290 pr.HTCaps.supportedChannelWidthSet =
291 eHT_CHANNEL_WIDTH_40MHZ;
292 }
293 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700294 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
296 /* Include VHT Capability IE */
297 if (pesession->vhtCapability) {
298 populate_dot11f_vht_caps(mac_ctx, pesession,
299 &pr.VHTCaps);
300 is_vht_enabled = true;
301 }
302 } else {
303 if (IS_DOT11_MODE_VHT(dot11mode)) {
304 populate_dot11f_vht_caps(mac_ctx, pesession,
305 &pr.VHTCaps);
306 is_vht_enabled = true;
307 }
308 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700309 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
311 pesession);
312
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700313 if (IS_DOT11_MODE_HE(dot11mode) && pesession)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800314 lim_update_session_he_capable(mac_ctx, pesession);
315
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700316 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700317 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800318
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700319 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530320 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
321 sizeof(tDot11fIEExtCap));
322 sir_status = lim_strip_extcap_update_struct(mac_ctx,
323 additional_ie,
324 &addn_ielen,
325 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700326 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700327 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530328 } else {
329 struct s_ext_cap *p_ext_cap =
330 (struct s_ext_cap *)
331 extracted_ext_cap.bytes;
332 if (p_ext_cap->interworking_service)
333 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800334 extracted_ext_cap.num_bytes =
335 lim_compute_ext_cap_ie_length
336 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530337 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800338 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700339 if (additional_ielen)
340 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530341 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530342 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
343 SIR_MAC_QCN_OUI_TYPE_SIZE,
344 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530346 /* Add qcn_ie only if qcn ie is not present in additional_ie */
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -0700347 if (!qcn_ie)
348 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie, QCN_IE_ATTR_ID_ALL);
349 else
350 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie,
351 QCN_IE_ATTR_ID_VHT_MCS11);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352
Hu Wang411e0cc2016-10-28 14:56:01 +0800353 /*
354 * Extcap IE now support variable length, merge Extcap IE from addn_ie
355 * may change the frame size. Therefore, MUST merge ExtCap IE before
356 * dot11f get packed payload size.
357 */
358 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800359 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800360
361 /* That's it-- now we pack it. First, how much space are we going to */
362 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
363 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700364 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800365 status);
366 /* We'll fall back on the worst case scenario: */
367 payload = sizeof(tDot11fProbeRequest);
368 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700369 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800370 status);
371 }
372
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
374
375 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530376 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530378 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700379 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700380 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 }
382 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800383 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384
385 /* Next, we fill out the buffer descriptor: */
386 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
387 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
388
389 /* That done, pack the Probe Request: */
390 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
391 sizeof(tSirMacMgmtHdr),
392 payload, &payload);
393 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700394 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700396 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700398 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 }
400 /* Append any AddIE if present. */
401 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530402 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403 additional_ie, addn_ielen);
404 payload += addn_ielen;
405 }
406
407 /* If this probe request is sent during P2P Search State, then we need
408 * to send it at OFDM rate.
409 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530410 if ((BAND_5G == lim_get_rf_band(channel)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 /*
412 * For unicast probe req mgmt from Join function we don't set
413 * above variables. So we need to add one more check whether it
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530414 * is opmode is P2P_CLIENT or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530416 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530419 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420 wma_tx_frame(mac_ctx, packet,
421 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
422 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
423 lim_tx_complete, frame, txflag, sme_sessionid,
Naveen Rawat296a5182017-09-25 14:02:48 -0700424 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530425 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700426 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700428 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 }
430
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700431 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432} /* End lim_send_probe_req_mgmt_frame. */
433
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800434static QDF_STATUS lim_get_addn_ie_for_probe_resp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 uint8_t *addIE, uint16_t *addnIELen,
436 uint8_t probeReqP2pIe)
437{
438 /* If Probe request doesn't have P2P IE, then take out P2P IE
439 from additional IE */
440 if (!probeReqP2pIe) {
441 uint8_t *tempbuf = NULL;
442 uint16_t tempLen = 0;
443 int left = *addnIELen;
444 uint8_t *ptr = addIE;
445 uint8_t elem_id, elem_len;
446
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700447 if (!addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700448 pe_err("NULL addIE pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700449 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 }
451
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530452 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700453 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700454 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455
456 while (left >= 2) {
457 elem_id = ptr[0];
458 elem_len = ptr[1];
459 left -= 2;
460 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700461 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530463 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700464 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 }
Srinivas Girigowda61771262019-04-01 11:55:19 -0700466 if (!((WLAN_ELEMID_VENDOR == elem_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467 (memcmp
468 (&ptr[2], SIR_MAC_P2P_OUI,
469 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530470 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471 elem_len + 2);
472 tempLen += (elem_len + 2);
473 }
474 left -= elem_len;
475 ptr += (elem_len + 2);
476 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530477 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530479 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700481 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482}
483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800485lim_send_probe_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 tSirMacAddr peer_macaddr,
487 tpAniSSID ssid,
Jeff Johnson3c08ace2019-03-12 08:50:37 -0700488 struct pe_session *pe_session,
489 uint8_t preq_p2pie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490{
491 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700492 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800493 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 tpSirMacMgmtHdr mac_hdr;
495 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700496 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530497 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 uint32_t addn_ie_present = false;
499
500 uint16_t addn_ie_len = 0;
gaurank kathpalia837f6202018-09-14 21:55:32 +0530501 bool wps_ap = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 uint8_t tx_flag = 0;
503 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700504 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 uint8_t noalen = 0;
506 uint8_t total_noalen = 0;
507 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
508 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
509 uint8_t sme_sessionid = 0;
510 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530511 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530512 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513
514 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700515 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 return;
517
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700518 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 return;
520
521 /*
522 * In case when cac timer is running for this SAP session then
523 * avoid sending probe rsp out. It is violation of dfs specification.
524 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530525 if (((pe_session->opmode == QDF_SAP_MODE) ||
526 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530528 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529 FL("CAC timer is running, probe response dropped"));
530 return;
531 }
532 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530533 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700534 if (!frm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800535 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537 /*
538 * Fill out 'frm', after which we'll just hand the struct off to
539 * 'dot11f_pack_probe_response'.
540 */
hangtian127c9532019-01-12 13:29:07 +0800541 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800542
543 /*
544 * Timestamp to be updated by TFP, below.
545 *
546 * Beacon Interval:
547 */
548 if (LIM_IS_AP_ROLE(pe_session)) {
549 frm->BeaconInterval.interval =
Jeff Johnsonac057412019-01-06 11:08:55 -0800550 mac_ctx->sch.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530552 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800553 frm->BeaconInterval.interval = (uint16_t) cfg;
554 }
555
556 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
557 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
558 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
559 &frm->SuppRates, pe_session);
560
Liangwei Dong419d7302019-07-15 15:38:28 +0800561 populate_dot11f_ds_params(
562 mac_ctx, &frm->DSParams,
563 wlan_reg_freq_to_chan(mac_ctx->pdev,
564 pe_session->curr_op_freq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
566
567 if (LIM_IS_AP_ROLE(pe_session)) {
568 if (pe_session->wps_state != SAP_WPS_DISABLED)
569 populate_dot11f_probe_res_wpsi_es(mac_ctx,
570 &frm->WscProbeRes,
571 pe_session);
572 } else {
gaurank kathpalia837f6202018-09-14 21:55:32 +0530573 wps_ap = mac_ctx->mlme_cfg->wps_params.enable_wps &
574 WNI_CFG_WPS_ENABLE_AP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 if (wps_ap)
576 populate_dot11f_wsc_in_probe_res(mac_ctx,
577 &frm->WscProbeRes);
578
579 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
580 eLIM_WSC_ENROLL_BEGIN) {
581 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
582 &frm->WscProbeRes);
583 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
584 eLIM_WSC_ENROLL_IN_PROGRESS;
585 }
586
587 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
588 eLIM_WSC_ENROLL_END) {
589 de_populate_dot11f_wsc_registrar_info_in_probe_res(
590 mac_ctx, &frm->WscProbeRes);
591 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
592 eLIM_WSC_ENROLL_NOOP;
593 }
594 }
595
596 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
597 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
598
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530599 if (pe_session->dot11mode != MLME_DOT11_MODE_11B)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
601
602 populate_dot11f_ext_supp_rates(mac_ctx,
603 POPULATE_DOT11F_RATES_OPERATIONAL,
604 &frm->ExtSuppRates, pe_session);
605
606 /* Populate HT IEs, when operating in 11n */
607 if (pe_session->htCapability) {
608 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
609 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
610 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700612 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
614 populate_dot11f_vht_operation(mac_ctx, pe_session,
615 &frm->VHTOperation);
616 /*
617 * we do not support multi users yet.
618 * populate_dot11f_vht_ext_bss_load( mac_ctx,
619 * &frm.VHTExtBssLoad );
620 */
621 is_vht_enabled = true;
622 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800624 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700625 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800626 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700627 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800628 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700629 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800630 }
631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
633 pe_session);
634
635 if (pe_session->pLimStartBssReq) {
636 populate_dot11f_wpa(mac_ctx,
637 &(pe_session->pLimStartBssReq->rsnIE),
638 &frm->WPA);
639 populate_dot11f_rsn_opaque(mac_ctx,
640 &(pe_session->pLimStartBssReq->rsnIE),
641 &frm->RSNOpaque);
642 }
643
644 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
645 &frm->WMMCaps, pe_session);
646
647#if defined(FEATURE_WLAN_WAPI)
648 if (pe_session->pLimStartBssReq)
649 populate_dot11f_wapi(mac_ctx,
650 &(pe_session->pLimStartBssReq->rsnIE),
651 &frm->WAPI);
652#endif /* defined(FEATURE_WLAN_WAPI) */
653
Liangwei Dongd7c5e012018-12-16 23:56:50 -0500654 /*
655 * Only use CFG for non-listen mode. This CFG is not working for
656 * concurrency. In listening mode, probe rsp IEs is passed in
657 * the message from SME to PE.
658 */
659 addn_ie_present =
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800660 (pe_session->add_ie_params.probeRespDataLen != 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661
662 if (addn_ie_present) {
663
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530664 add_ie = qdf_mem_malloc(
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800665 pe_session->add_ie_params.probeRespDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700666 if (!add_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 goto err_ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530669 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800670 pe_session->add_ie_params.probeRespData_buff,
671 pe_session->add_ie_params.probeRespDataLen);
672 addn_ie_len = pe_session->add_ie_params.probeRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700674 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700676 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 goto err_ret;
678 }
679
680 sir_status = lim_strip_extcap_update_struct(mac_ctx,
681 add_ie, &addn_ie_len,
682 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700683 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700684 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530685 } else {
686 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 }
688
689 bytes = bytes + addn_ie_len;
690
691 if (preq_p2pie)
692 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
693 addn_ie_len);
694
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700695 if (p2p_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 /* get NoA attribute stream P2P IE */
697 noalen = lim_get_noa_attr_stream(mac_ctx,
698 noa_stream, pe_session);
699 if (noalen != 0) {
700 total_noalen =
701 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
702 &noa_stream[0], noalen);
703 bytes = bytes + total_noalen;
704 }
705 }
706 }
707
Hu Wang411e0cc2016-10-28 14:56:01 +0800708 /*
709 * Extcap IE now support variable length, merge Extcap IE from addn_ie
710 * may change the frame size. Therefore, MUST merge ExtCap IE before
711 * dot11f get packed payload size.
712 */
713 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800714 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
715 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800716
717 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
718 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700719 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800720 status);
721 /* We'll fall back on the worst case scenario: */
722 payload = sizeof(tDot11fProbeResponse);
723 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700724 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800725 status);
726 }
727
728 bytes += payload + sizeof(tSirMacMgmtHdr);
729
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530730 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530732 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700733 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 goto err_ret;
735 }
736 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800737 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738
739 /* Next, we fill out the buffer descriptor: */
740 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
741 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530742 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743
744 mac_hdr = (tpSirMacMgmtHdr) frame;
745
746 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 /* That done, pack the Probe Response: */
749 status =
750 dot11f_pack_probe_response(mac_ctx, frm,
751 frame + sizeof(tSirMacMgmtHdr),
752 payload, &payload);
753 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700754 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 status);
756 goto err_ret;
757 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700758 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759 }
760
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700761 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530762 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530765 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 &add_ie[0], addn_ie_len);
767
768 if (noalen != 0) {
769 if (total_noalen >
770 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700771 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772 total_noalen);
773 goto err_ret;
774 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530775 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776 &noa_ie[0], total_noalen);
777 }
778 }
779
Liangwei Dong419d7302019-07-15 15:38:28 +0800780 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
781 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
782 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
784
785 /* Queue Probe Response frame in high priority WQ */
Jeff Johnson59429b02018-11-07 13:53:18 -0800786 qdf_status = wma_tx_frame(mac_ctx, packet,
787 (uint16_t)bytes,
788 TXRX_FRM_802_11_MGMT,
789 ANI_TXDIR_TODS,
790 7, lim_tx_complete, frame, tx_flag,
791 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792
793 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530794 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700795 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700797 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530798 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530800 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 return;
802
803err_ret:
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700804 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530805 qdf_mem_free(add_ie);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700806 if (frm)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_free(frm);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700808 if (packet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 cds_packet_free((void *)packet);
810 return;
811
812} /* End lim_send_probe_rsp_mgmt_frame. */
813
814void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800815lim_send_addts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 tSirMacAddr peerMacAddr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800817 tSirAddtsReqInfo *pAddTS, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818{
819 uint16_t i;
820 uint8_t *pFrame;
821 tDot11fAddTSRequest AddTSReq;
822 tDot11fWMMAddTSRequest WMMAddTSReq;
823 uint32_t nPayload, nBytes, nStatus;
824 tpSirMacMgmtHdr pMacHdr;
825 void *pPacket;
826#ifdef FEATURE_WLAN_ESE
827 uint32_t phyMode;
828#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530829 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830 uint8_t txFlag = 0;
831 uint8_t smeSessionId = 0;
832
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700833 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 return;
835 }
836
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800837 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838
839 if (!pAddTS->wmeTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +0800840 qdf_mem_zero((uint8_t *) &AddTSReq, sizeof(AddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700842 AddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 AddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700844 AddTSReq.Category.category = ACTION_CATEGORY_QOS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 if (pAddTS->lleTspecPresent) {
846 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
847 } else {
848 populate_dot11f_wmmtspec(&pAddTS->tspec,
849 &AddTSReq.WMMTSPEC);
850 }
851
852 if (pAddTS->lleTspecPresent) {
853 AddTSReq.num_WMMTCLAS = 0;
854 AddTSReq.num_TCLAS = pAddTS->numTclas;
855 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800856 populate_dot11f_tclas(mac, &pAddTS->tclasInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 &AddTSReq.TCLAS[i]);
858 }
859 } else {
860 AddTSReq.num_TCLAS = 0;
861 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
862 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800863 populate_dot11f_wmmtclas(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 &pAddTS->tclasInfo[i],
865 &AddTSReq.WMMTCLAS[i]);
866 }
867 }
868
869 if (pAddTS->tclasProcPresent) {
870 if (pAddTS->lleTspecPresent) {
871 AddTSReq.TCLASSPROC.processing =
872 pAddTS->tclasProc;
873 AddTSReq.TCLASSPROC.present = 1;
874 } else {
875 AddTSReq.WMMTCLASPROC.version = 1;
876 AddTSReq.WMMTCLASPROC.processing =
877 pAddTS->tclasProc;
878 AddTSReq.WMMTCLASPROC.present = 1;
879 }
880 }
881
882 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800883 dot11f_get_packed_add_ts_request_size(mac, &AddTSReq, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700885 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
886 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 /* We'll fall back on the worst case scenario: */
888 nPayload = sizeof(tDot11fAddTSRequest);
889 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700890 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
891 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 }
893 } else {
hangtian127c9532019-01-12 13:29:07 +0800894 qdf_mem_zero((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700896 WMMAddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700898 WMMAddTSReq.Category.category = ACTION_CATEGORY_WMM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899
900 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
901 WMMAddTSReq.StatusCode.statusCode = 0;
902
903 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
904#ifdef FEATURE_WLAN_ESE
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800905 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906
907 if (phyMode == WNI_CFG_PHY_MODE_11G
908 || phyMode == WNI_CFG_PHY_MODE_11A) {
909 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
910 } else {
911 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
912 }
Jeff Johnson99f25042018-11-21 22:49:06 -0800913 populate_dot11_tsrsie(mac, &pAddTS->tsrsIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 &WMMAddTSReq.ESETrafStrmRateSet,
915 sizeof(uint8_t));
916#endif
917 /* fillWmeTspecIE */
918
919 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800920 dot11f_get_packed_wmm_add_ts_request_size(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 &nPayload);
922 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700923 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924 nStatus);
925 /* We'll fall back on the worst case scenario: */
926 nPayload = sizeof(tDot11fAddTSRequest);
927 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700928 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
929 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 }
931 }
932
933 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
934
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530935 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530937 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700938 pe_err("Failed to allocate %d bytes for an Add TS Request",
939 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940 return;
941 }
942 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800943 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944
945 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -0800946 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530947 SIR_MAC_MGMT_ACTION, peerMacAddr, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 pMacHdr = (tpSirMacMgmtHdr) pFrame;
949
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800950 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800952 lim_set_protected_bit(mac, pe_session, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953
954 /* That done, pack the struct: */
955 if (!pAddTS->wmeTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800956 nStatus = dot11f_pack_add_ts_request(mac, &AddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 pFrame +
958 sizeof(tSirMacMgmtHdr),
959 nPayload, &nPayload);
960 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700961 pe_err("Failed to pack an Add TS Request "
962 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 cds_packet_free((void *)pPacket);
964 return; /* allocated! */
965 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700966 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
967 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 }
969 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -0800970 nStatus = dot11f_pack_wmm_add_ts_request(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 pFrame +
972 sizeof(tSirMacMgmtHdr),
973 nPayload, &nPayload);
974 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700975 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
976 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 cds_packet_free((void *)pPacket);
978 return; /* allocated! */
979 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700980 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
981 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 }
983 }
984
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700985 pe_debug("Sending an Add TS Request frame to");
Jeff Johnson99f25042018-11-21 22:49:06 -0800986 lim_print_mac_addr(mac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987
Liangwei Dong419d7302019-07-15 15:38:28 +0800988 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
989 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
990 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530993 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800994 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -0800995 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800996 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700997 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998
999 /* Queue Addts Response frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08001000 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 TXRX_FRM_802_11_MGMT,
1002 ANI_TXDIR_TODS,
1003 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001004 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301005 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001006 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001008 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1009 pe_err("Could not send an Add TS Request (%X",
1010 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011} /* End lim_send_addts_req_action_frame. */
1012
1013/**
1014 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1015 * @mac_ctx: Handle for mac context
1016 * @status_code: Status code for assoc response frame
1017 * @aid: Association ID
1018 * @peer_addr: Mac address of requesting peer
1019 * @subtype: Assoc/Reassoc
1020 * @sta: Pointer to station node
1021 * @pe_session: PE session id.
1022 *
1023 * Builds and sends association response frame to the requesting peer.
1024 *
1025 * Return: void
1026 */
1027
1028void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001029lim_send_assoc_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
Jeff Johnsona7815652018-11-18 22:58:30 -08001031 uint8_t subtype, tpDphHashNode sta, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032{
1033 static tDot11fAssocResponse frm;
1034 uint8_t *frame;
1035 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001036 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 uint8_t lle_mode = 0, addts;
1038 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001039 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301041 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 tUpdateBeaconParams beacon_params;
1043 uint8_t tx_flag = 0;
1044 uint32_t addn_ie_len = 0;
1045 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1046 tpSirAssocReq assoc_req = NULL;
1047 uint8_t sme_session = 0;
1048 bool is_vht = false;
1049 uint16_t stripoff_len = 0;
1050 tDot11fIEExtCap extracted_ext_cap;
1051 bool extracted_flag = false;
1052#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301053 uint8_t retry_int;
1054 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055#endif
1056
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001057 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001058 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 return;
1060 }
1061
1062 sme_session = pe_session->smeSessionId;
1063
hangtian127c9532019-01-12 13:29:07 +08001064 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065
1066 limGetQosMode(pe_session, &qos_mode);
1067 limGetWmeMode(pe_session, &wme_mode);
1068
1069 /*
1070 * An Add TS IE is added only if the AP supports it and
1071 * the requesting STA sent a traffic spec.
1072 */
1073 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1074
1075 frm.Status.status = status_code;
1076
1077 frm.AID.associd = aid | LIM_AID_MASK;
1078
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001079 if (!sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 populate_dot11f_supp_rates(mac_ctx,
1081 POPULATE_DOT11F_RATES_OPERATIONAL,
1082 &frm.SuppRates, pe_session);
1083 populate_dot11f_ext_supp_rates(mac_ctx,
1084 POPULATE_DOT11F_RATES_OPERATIONAL,
1085 &frm.ExtSuppRates, pe_session);
1086 } else {
1087 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1088 &frm.ExtSuppRates,
1089 sta->supportedRates.llbRates,
1090 sta->supportedRates.llaRates);
1091 }
1092
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001093 if (LIM_IS_AP_ROLE(pe_session) && sta &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001094 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 assoc_req = (tpSirAssocReq)
1096 pe_session->parsedAssocReq[sta->assocId];
1097 /*
1098 * populate P2P IE in AssocRsp when assocReq from the peer
1099 * includes P2P IE
1100 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001101 if (assoc_req && assoc_req->addIEPresent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1103 &frm.P2PAssocRes,
1104 assoc_req);
1105 }
1106
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001107 if (sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108 if (eHAL_SET == qos_mode) {
1109 if (sta->lleEnabled) {
1110 lle_mode = 1;
1111 populate_dot11f_edca_param_set(mac_ctx,
1112 &frm.EDCAParamSet, pe_session);
1113 }
1114 }
1115
1116 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1117 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1118 pe_session);
1119
1120 if (sta->wsmEnabled)
1121 populate_dot11f_wmm_caps(&frm.WMMCaps);
1122 }
1123
1124 if (sta->mlmStaContext.htCapability &&
1125 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001126 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001127 populate_dot11f_ht_caps(mac_ctx, pe_session,
1128 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001129 /*
1130 * Check the STA capability and
1131 * update the HTCaps accordingly
1132 */
1133 frm.HTCaps.supportedChannelWidthSet = (
1134 sta->htSupportedChannelWidthSet <
1135 pe_session->htSupportedChannelWidthSet) ?
1136 sta->htSupportedChannelWidthSet :
1137 pe_session->htSupportedChannelWidthSet;
1138 if (!frm.HTCaps.supportedChannelWidthSet)
1139 frm.HTCaps.shortGI40MHz = 0;
1140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001141 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301142 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001144 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 +05301145 frm.HTCaps.supportedChannelWidthSet,
1146 frm.HTCaps.mimoPowerSave,
1147 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1148 frm.HTCaps.shortGI40MHz,
1149 frm.HTCaps.dsssCckMode40MHz,
1150 frm.HTCaps.maxRxAMPDUFactor);
1151
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 if (sta->mlmStaContext.vhtCapability &&
1153 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001154 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155 populate_dot11f_vht_caps(mac_ctx, pe_session,
1156 &frm.VHTCaps);
1157 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301158 &frm.VHTOperation);
1159 is_vht = true;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301160 } else if (sta->mlmStaContext.force_1x1 &&
1161 frm.HTCaps.present) {
1162 /*
1163 * WAR: In P2P GO mode, if the P2P client device
1164 * is only HT capable and not VHT capable, but the P2P
1165 * GO device is VHT capable and advertises 2x2 NSS with
1166 * HT capablity client device, which results in IOT
1167 * issues.
1168 * When GO is operating in DBS mode, GO beacons
1169 * advertise 2x2 capability but include OMN IE to
1170 * indicate current operating mode of 1x1. But here
1171 * peer device is only HT capable and will not
1172 * understand OMN IE.
1173 */
1174 frm.HTInfo.basicMCSSet[1] = 0;
1175 frm.HTCaps.supportedMCSSet[1] = 0;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301176 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001177
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301178 if (pe_session->vhtCapability &&
1179 pe_session->vendor_vht_sap &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001180 (assoc_req) &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301181 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001182 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301183 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001184 frm.vendor_vht_ie.sub_type =
1185 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301186 frm.vendor_vht_ie.VHTCaps.present = 1;
1187 populate_dot11f_vht_caps(mac_ctx, pe_session,
1188 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001189 populate_dot11f_vht_operation(mac_ctx, pe_session,
1190 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191 is_vht = true;
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07001192 populate_dot11f_qcn_ie(mac_ctx, &frm.qcn_ie,
1193 QCN_IE_ATTR_ID_ALL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1196 pe_session);
1197
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001198 if (lim_is_sta_he_capable(sta) &&
1199 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001200 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001201 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001202 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001203 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001204 &frm.he_op);
Kiran Kumar Lokereb2ea0272019-08-27 19:16:36 -07001205 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
1206 &frm.he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001207 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208#ifdef WLAN_FEATURE_11W
1209 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301210 max_retries =
1211 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1212 retry_int =
1213 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1214 populate_dot11f_timeout_interval(mac_ctx,
1215 &frm.TimeoutInterval,
1216 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1217 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 sta->pmfSaQueryRetryCount)
1219 * retry_int);
1220 }
1221#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001222
1223 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1224 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 }
1226
hangtian127c9532019-01-12 13:29:07 +08001227 qdf_mem_zero((uint8_t *) &beacon_params, sizeof(beacon_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228
1229 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301230 (pe_session->gLimProtectionControl !=
1231 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1232 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1233 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234
1235 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1236 pe_session);
1237 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1238 pe_session);
1239
1240 /*
1241 * Populate Do11capabilities after updating session with
1242 * Assos req details
1243 */
1244 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1245
Abhishek Singhc70afa32019-09-19 15:17:21 +05301246 beacon_params.bss_idx = pe_session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247
1248 /* Send message to HAL about beacon parameter change. */
1249 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1250 && beacon_params.paramChangeBitmap) {
1251 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1252 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1253 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254
Arif Hussain1513cb22018-01-05 19:56:31 -08001255 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1256
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001257 if (assoc_req) {
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001258 addn_ie_len = pe_session->add_ie_params.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259
1260 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001261 if (addn_ie_len > 0 &&
1262 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1263 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301264 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001265 pe_session->add_ie_params.assocRespData_buff,
1266 pe_session->add_ie_params.assocRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267
hangtian127c9532019-01-12 13:29:07 +08001268 qdf_mem_zero((uint8_t *) &extracted_ext_cap,
1269 sizeof(extracted_ext_cap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270
1271 stripoff_len = addn_ie_len;
1272 sir_status =
1273 lim_strip_extcap_update_struct
1274 (mac_ctx, &add_ie[0], &stripoff_len,
1275 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001276 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001277 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278 } else {
1279 addn_ie_len = stripoff_len;
1280 extracted_flag = true;
1281 }
1282 bytes = bytes + addn_ie_len;
1283 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001284 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285 addn_ie_len, assoc_req->addIEPresent);
1286 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001287
1288 /*
1289 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1290 * may change the frame size. Therefore, MUST merge ExtCap IE before
1291 * dot11f get packed payload size.
1292 */
1293 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001294 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1295 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001296
1297 /* Allocate a buffer for this frame: */
1298 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1299 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001300 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001301 status);
1302 return;
1303 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001304 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001305 status);
1306 }
1307
1308 bytes += sizeof(tSirMacMgmtHdr) + payload;
1309
Min Liu0daa0982019-02-01 17:50:44 +08001310 if (sta)
1311 bytes += sta->mlmStaContext.owe_ie_len;
1312
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301313 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301315 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001316 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 return;
1318 }
1319 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001320 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321
1322 /* Next, we fill out the buffer descriptor: */
1323 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1324 (LIM_ASSOC == subtype) ?
1325 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1326 peer_addr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301327 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 mac_hdr = (tpSirMacMgmtHdr) frame;
1329
1330 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1333 frame + sizeof(tSirMacMgmtHdr),
1334 payload, &payload);
1335 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001336 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 status);
1338 cds_packet_free((void *)packet);
1339 return;
1340 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001341 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 status);
1343 }
1344
1345 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001346 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 status_code, aid);
1348 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001349 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350 status_code, aid);
1351
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301352 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353
1354 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301355 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 &add_ie[0], addn_ie_len);
1357
Min Liu0daa0982019-02-01 17:50:44 +08001358 if (sta && sta->mlmStaContext.owe_ie_len)
1359 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload
1360 + addn_ie_len,
1361 sta->mlmStaContext.owe_ie,
1362 sta->mlmStaContext.owe_ie_len);
1363
Liangwei Dong419d7302019-07-15 15:38:28 +08001364 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1365 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1366 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1368
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301369 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001371 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001372 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301374 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 TXRX_FRM_802_11_MGMT,
1376 ANI_TXDIR_TODS,
1377 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001378 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301379 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301380 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381
1382 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301383 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001384 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301385 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386
1387 /*
1388 * update the ANI peer station count.
1389 * FIXME_PROTECTION : take care of different type of station
1390 * counter inside this function.
1391 */
1392 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1393
1394}
1395
1396void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001397lim_send_delts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 tSirMacAddr peer,
1399 uint8_t wmmTspecPresent,
Jeff Johnson312348f2018-12-22 13:33:54 -08001400 struct mac_ts_info *pTsinfo,
Jeff Johnson56471b92018-12-22 14:36:06 -08001401 struct mac_tspec_ie *pTspecIe,
Jeff Johnson312348f2018-12-22 13:33:54 -08001402 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403{
1404 uint8_t *pFrame;
1405 tpSirMacMgmtHdr pMacHdr;
1406 tDot11fDelTS DelTS;
1407 tDot11fWMMDelTS WMMDelTS;
1408 uint32_t nBytes, nPayload, nStatus;
1409 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301410 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 uint8_t txFlag = 0;
1412 uint8_t smeSessionId = 0;
1413
Jeff Johnson312348f2018-12-22 13:33:54 -08001414 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001415 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001417 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418
1419 if (!wmmTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +08001420 qdf_mem_zero((uint8_t *) &DelTS, sizeof(DelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001422 DelTS.Category.category = ACTION_CATEGORY_QOS;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001423 DelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1425
Jeff Johnson99f25042018-11-21 22:49:06 -08001426 nStatus = dot11f_get_packed_del_ts_size(mac, &DelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001428 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)",
1429 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 /* We'll fall back on the worst case scenario: */
1431 nPayload = sizeof(tDot11fDelTS);
1432 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001433 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1434 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001435 }
1436 } else {
hangtian127c9532019-01-12 13:29:07 +08001437 qdf_mem_zero((uint8_t *) &WMMDelTS, sizeof(WMMDelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001439 WMMDelTS.Category.category = ACTION_CATEGORY_WMM;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001440 WMMDelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 WMMDelTS.DialogToken.token = 0;
1442 WMMDelTS.StatusCode.statusCode = 0;
1443 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1444 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08001445 dot11f_get_packed_wmm_del_ts_size(mac, &WMMDelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001447 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)",
1448 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 /* We'll fall back on the worst case scenario: */
1450 nPayload = sizeof(tDot11fDelTS);
1451 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001452 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1453 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454 }
1455 }
1456
1457 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1458
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301459 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1461 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301462 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001463 pe_err("Failed to allocate %d bytes for an Add TS Response",
1464 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 return;
1466 }
1467 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001468 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469
1470 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08001471 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301472 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1474
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001475 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001477 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478
1479 /* That done, pack the struct: */
1480 if (!wmmTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -08001481 nStatus = dot11f_pack_del_ts(mac, &DelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482 pFrame + sizeof(tSirMacMgmtHdr),
1483 nPayload, &nPayload);
1484 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001485 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001486 nStatus);
1487 cds_packet_free((void *)pPacket);
1488 return; /* allocated! */
1489 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001490 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1491 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 }
1493 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -08001494 nStatus = dot11f_pack_wmm_del_ts(mac, &WMMDelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495 pFrame + sizeof(tSirMacMgmtHdr),
1496 nPayload, &nPayload);
1497 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001498 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 nStatus);
1500 cds_packet_free((void *)pPacket);
1501 return; /* allocated! */
1502 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001503 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1504 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 }
1506 }
1507
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001508 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
Jeff Johnson99f25042018-11-21 22:49:06 -08001509 lim_print_mac_addr(mac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510
Liangwei Dong419d7302019-07-15 15:38:28 +08001511 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1512 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1513 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301516 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001517 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001518 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001519 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001520 QDF_STATUS_SUCCESS);
Jeff Johnson99f25042018-11-21 22:49:06 -08001521 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 TXRX_FRM_802_11_MGMT,
1523 ANI_TXDIR_TODS,
1524 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001525 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301526 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001527 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301529 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001530 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531
1532} /* End lim_send_delts_req_action_frame. */
1533
1534/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301535 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1536 * @context: pointer to global mac
1537 * @buf: buffer
1538 * @tx_complete : Sent status
1539 * @params; tx completion params
1540 *
1541 * Return: This returns QDF_STATUS
1542 */
1543
1544static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1545 qdf_nbuf_t buf,
1546 uint32_t tx_complete,
1547 void *params)
1548{
1549 uint16_t assoc_ack_status;
1550 uint16_t reason_code;
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001551 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301552
1553 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001554 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301555 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001556 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301557 } else {
1558 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001559 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301560 }
1561 if (buf)
1562 qdf_nbuf_free(buf);
1563
1564 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1565 NULL, assoc_ack_status, reason_code);
1566 return QDF_STATUS_SUCCESS;
1567}
1568
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301569#ifdef WLAN_ADAPTIVE_11R
1570/**
1571 * lim_fill_adaptive_11r_ie() - Populate the Vendor secific adaptive 11r
1572 * IE to association request frame
1573 * @pe_session: pointer to PE session
1574 * @ie_buf: buffer to which Adaptive 11r IE will be copied
1575 * @ie_len: length of the Adaptive 11r Vendor specific IE
1576 *
1577 * Return QDF_STATUS
1578 */
1579static QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1580 uint8_t **ie_buf, uint8_t *ie_len)
1581{
1582 uint8_t *buf = NULL, *adaptive_11r_ie = NULL;
1583
1584 if (!pe_session->is_adaptive_11r_connection)
1585 return QDF_STATUS_SUCCESS;
1586
1587 /*
1588 * Vendor specific Adaptive 11r IE to be advertised in Assoc
1589 * req:
1590 * Type 0xDD
1591 * Length 0x0B
1592 * OUI 0x00 0x00 0x0F
1593 * Type 0x22
1594 * subtype 0x00
1595 * Version 0x01
1596 * Length 0x04
1597 * Data 0x00 00 00 01(0th bit is 1 means adaptive 11r is
1598 * supported)
1599 */
1600 adaptive_11r_ie = qdf_mem_malloc(ADAPTIVE_11R_STA_IE_LEN + 2);
1601 if (!adaptive_11r_ie)
1602 return QDF_STATUS_E_FAILURE;
1603
1604 /* Fill the Vendor IE Type (0xDD) */
1605 buf = adaptive_11r_ie;
Srinivas Girigowda8e7ecab2019-05-16 11:31:19 -07001606 *buf = WLAN_ELEMID_VENDOR;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301607 buf++;
1608
1609 /* Fill the Vendor IE length (0x0B) */
1610 *buf = ADAPTIVE_11R_STA_IE_LEN;
1611 buf++;
1612
1613 /*
1614 * Fill the Adaptive 11r Vendor specific OUI(0x00 0x00 0x0F 0x22)
1615 */
1616 qdf_mem_copy(buf, ADAPTIVE_11R_STA_OUI, ADAPTIVE_11R_OUI_LEN);
1617 buf += ADAPTIVE_11R_OUI_LEN;
1618
1619 /* Fill Adaptive 11r Vendor specific Subtype (0x00) */
1620 *buf = ADAPTIVE_11R_OUI_SUBTYPE;
1621 buf++;
1622
1623 /* Fill Adaptive 11r Version (0x01) */
1624 *buf = ADAPTIVE_11R_OUI_VERSION;
1625 buf++;
1626
1627 /* Fill Adaptive 11r IE Data length (0x04) */
1628 *buf = ADAPTIVE_11R_DATA_LEN;
1629 buf++;
1630
1631 /* Fill Adaptive 11r IE Data (0x00 0x00 0x00 0x01) */
1632 qdf_mem_copy(buf, ADAPTIVE_11R_OUI_DATA, ADAPTIVE_11R_DATA_LEN);
1633
1634 *ie_len = ADAPTIVE_11R_STA_IE_LEN + 2;
1635 *ie_buf = adaptive_11r_ie;
1636
1637 return QDF_STATUS_SUCCESS;
1638}
1639
1640#else
1641static inline
1642QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1643 uint8_t **ie_buf, uint8_t *ie_len)
1644{
1645 return QDF_STATUS_SUCCESS;
1646}
1647#endif
1648
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301649/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 * lim_send_assoc_req_mgmt_frame() - Send association request
1651 * @mac_ctx: Handle to MAC context
1652 * @mlm_assoc_req: Association request information
1653 * @pe_session: PE session information
1654 *
1655 * Builds and transmits association request frame to AP.
1656 *
1657 * Return: Void
1658 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001660lim_send_assoc_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 tLimMlmAssocReq *mlm_assoc_req,
Jeff Johnsona7815652018-11-18 22:58:30 -08001662 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663{
Naveen Rawat72475db2017-12-13 18:07:35 -08001664 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 tDot11fAssocRequest *frm;
1666 uint16_t caps;
1667 uint8_t *frame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001668 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001670 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1672 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301673 QDF_STATUS qdf_status;
Srinivas Dasari22397902019-07-29 21:34:10 +05301674 uint16_t add_ie_len, current_len = 0, vendor_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001676 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 uint8_t tx_flag = 0;
1679 uint8_t sme_sessionid = 0;
1680 bool vht_enabled = false;
1681 tDot11fIEExtCap extr_ext_cap;
1682 bool extr_ext_flag = true;
1683 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001684 uint32_t ie_offset = 0;
1685 uint8_t *p_ext_cap = NULL;
1686 tDot11fIEExtCap bcn_ext_cap;
1687 uint8_t *bcn_ie = NULL;
1688 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301689 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001690 enum rateid min_rid = RATEID_DEFAULT;
Srinivas Dasari22397902019-07-29 21:34:10 +05301691 uint8_t *mbo_ie = NULL, *adaptive_11r_ie = NULL, *vendor_ies = NULL;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301692 uint8_t mbo_ie_len = 0, adaptive_11r_ie_len = 0;
Srinivas Dasari603d4972019-09-20 17:28:44 +05301693 struct wlan_objmgr_peer *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001695 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001696 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301697 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 return;
1699 }
1700
1701 sme_sessionid = pe_session->smeSessionId;
1702
1703 /* check this early to avoid unncessary operation */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301704 if (!pe_session->lim_join_req) {
1705 pe_err("pe_session->lim_join_req is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301706 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 return;
1708 }
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301709 add_ie_len = pe_session->lim_join_req->addIEAssoc.length;
1710 add_ie = pe_session->lim_join_req->addIEAssoc.addIEdata;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301712 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001713 if (!frm) {
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301714 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715 return;
1716 }
hangtian127c9532019-01-12 13:29:07 +08001717 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301719 if (add_ie_len && pe_session->is_ext_caps_present) {
hangtian127c9532019-01-12 13:29:07 +08001720 qdf_mem_zero((uint8_t *) &extr_ext_cap,
1721 sizeof(tDot11fIEExtCap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001722 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1723 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001724 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001726 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 } else {
1728 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1729 extr_ext_cap.bytes;
1730
1731 if (p_ext_cap->interworking_service)
1732 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001733 extr_ext_cap.num_bytes =
1734 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1735 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 }
1737 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001738 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 extr_ext_flag = false;
1740 }
1741
1742 caps = mlm_assoc_req->capabilityInfo;
1743#if defined(FEATURE_WLAN_WAPI)
1744 /*
1745 * According to WAPI standard:
1746 * 7.3.1.4 Capability Information field
1747 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1748 * in transmitted Association or Reassociation management frames.
1749 * APs ignore the Privacy subfield within received Association and
1750 * Reassociation management frames.
1751 */
1752 if (pe_session->encryptType == eSIR_ED_WPI)
1753 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1754#endif
1755 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1756
1757 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1758 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1759 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1760 &frm->SuppRates, pe_session);
1761
1762 qos_enabled = (pe_session->limQosEnabled) &&
1763 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1764
1765 wme_enabled = (pe_session->limWmeEnabled) &&
1766 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1767
1768 /* We prefer .11e asociations: */
1769 if (qos_enabled)
1770 wme_enabled = false;
1771
1772 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1773 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1774
1775 if (pe_session->lim11hEnable &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301776 pe_session->lim_join_req->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 power_caps = true;
1778
1779 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1780 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1782 LIM_ASSOC, pe_session);
1783
1784 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1786 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1787 if (power_caps == false) {
1788 power_caps = true;
1789 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1790 LIM_ASSOC, pe_session);
1791 }
1792 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001794 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1795 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796
1797 populate_dot11f_ext_supp_rates(mac_ctx,
1798 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1799 pe_session);
1800
Gupta, Kapil54a16992016-01-13 19:34:02 +05301801 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1802 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1804 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001805
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806 /*
1807 * The join request *should* contain zero or one of the WPA and RSN
1808 * IEs. The payload send along with the request is a
Jeff Johnson701444f2019-02-02 22:35:13 -08001809 * 'struct join_req'; the IE portion is held inside a 'tSirRSNie':
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 * typedef struct sSirRSNie
1811 * {
1812 * uint16_t length;
Srinivas Girigowdacf161402019-03-14 11:37:33 -07001813 * uint8_t rsnIEdata[WLAN_MAX_IE_LEN+2];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 * } tSirRSNie, *tpSirRSNie;
1815 * So, we should be able to make the following two calls harmlessly,
1816 * since they do nothing if they don't find the given IE in the
1817 * bytestream with which they're provided.
1818 * The net effect of this will be to faithfully transmit whatever
1819 * security IE is in the join request.
1820 * However, if we're associating for the purpose of WPS
1821 * enrollment, and we've been configured to indicate that by
1822 * eliding the WPA or RSN IE, we just skip this:
1823 */
1824 if (add_ie_len && add_ie)
1825 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1826
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001827 if (!wps_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 populate_dot11f_rsn_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301829 &pe_session->lim_join_req->rsnIE,
1830 &frm->RSNOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 populate_dot11f_wpa_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301832 &pe_session->lim_join_req->rsnIE,
1833 &frm->WPAOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834#if defined(FEATURE_WLAN_WAPI)
1835 populate_dot11f_wapi_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301836 &(pe_session->lim_join_req->rsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 &frm->WAPIOpaque);
1838#endif /* defined(FEATURE_WLAN_WAPI) */
1839 }
1840 /* include WME EDCA IE as well */
1841 if (wme_enabled) {
1842 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1843 pe_session, &frm->WMMInfoStation);
1844
1845 if (wsm_enabled)
1846 populate_dot11f_wmm_caps(&frm->WMMCaps);
1847 }
1848
1849 /*
1850 * Populate HT IEs, when operating in 11n and
1851 * when AP is also operating in 11n mode
1852 */
1853 if (pe_session->htCapability &&
1854 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001855 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001857 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1858 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001859 } else if (pe_session->he_with_wep_tkip) {
1860 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1861 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001863 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 +05301864 frm->HTCaps.supportedChannelWidthSet,
1865 frm->HTCaps.mimoPowerSave,
1866 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1867 frm->HTCaps.shortGI40MHz,
1868 frm->HTCaps.dsssCckMode40MHz,
1869 frm->HTCaps.maxRxAMPDUFactor);
1870
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 if (pe_session->vhtCapability &&
1872 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001873 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001875 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1876 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001878 if (pe_session->enableHtSmps &&
1879 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001880 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001881 populate_dot11f_operating_mode(mac_ctx,
1882 &frm->OperatingMode, pe_session);
1883 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001884 } else if (pe_session->he_with_wep_tkip) {
1885 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1886 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001888
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 if (!vht_enabled &&
1890 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001891 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301892 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001893 frm->vendor_vht_ie.sub_type =
1894 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301895 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05301896 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05301897 pe_session->vht_config.su_beam_formee) {
1898 pe_debug("Disable SU beamformee for vendor IE");
1899 pe_session->vht_config.su_beam_formee = 0;
1900 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301902 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 vht_enabled = true;
1904 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301905 if (pe_session->is_ext_caps_present)
1906 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1907 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07001909 populate_dot11f_qcn_ie(mac_ctx, &frm->qcn_ie, QCN_IE_ATTR_ID_ALL);
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301910
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001911 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001912 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001913 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001914 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001915 } else if (pe_session->he_with_wep_tkip) {
1916 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1917 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001918 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301919
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301920 if (pe_session->lim_join_req->is11Rconnection) {
Pragaspathi Thilagaraj1112c962019-05-23 23:45:38 +05301921 struct bss_description *bssdescr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301923 bssdescr = &pe_session->lim_join_req->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001924 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925 (unsigned int) bssdescr->mdie[0],
1926 (unsigned int) bssdescr->mdie[1],
1927 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001928 populate_mdie(mac_ctx, &frm->MobilityDomain,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301929 pe_session->lim_join_req->bssDescription.mdie);
Pragaspathi Thilagaraj03839b92019-03-12 17:45:21 +05301930
1931 /*
1932 * IEEE80211-ai [13.2.4 FT initial mobility domain association
1933 * over FILS in an RSN]
1934 * Populate FT IE in association request. This FT IE should be
1935 * same as the FT IE received in auth response frame during the
1936 * FT-FILS authentication.
1937 */
1938 if (lim_is_fils_connection(pe_session))
1939 populate_fils_ft_info(mac_ctx, &frm->FTInfo,
1940 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942
1943#ifdef FEATURE_WLAN_ESE
1944 /*
1945 * ESE Version IE will be included in association request
1946 * when ESE is enabled on DUT through ini and it is also
1947 * advertised by the peer AP to which we are trying to
1948 * associate to.
1949 */
1950 if (pe_session->is_ese_version_ie_present &&
Wu Gao51a63562018-11-08 16:29:10 +08001951 mac_ctx->mlme_cfg->lfr.ese_enabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 populate_dot11f_ese_version(&frm->ESEVersion);
1953 /* For ESE Associations fill the ESE IEs */
1954 if (pe_session->isESEconnection &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301955 pe_session->lim_join_req->isESEFeatureIniEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956#ifndef FEATURE_DISABLE_RM
1957 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1958#endif
1959 }
1960#endif
1961
Hu Wang411e0cc2016-10-28 14:56:01 +08001962 /*
1963 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1964 * may change the frame size. Therefore, MUST merge ExtCap IE before
1965 * dot11f get packed payload size.
1966 */
1967 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001968 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1969
1970 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1971 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1972 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1973 DOT11F_FF_BEACONINTERVAL_LEN +
1974 DOT11F_FF_CAPABILITIES_LEN;
1975
1976 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1977 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1978 bcn_ie = pe_session->beacon + ie_offset;
1979 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001980 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001981 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001982 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001983 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1984 &bcn_ext_cap);
1985 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1986 false);
1987 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07001988 /*
1989 * TWT extended capabilities should be populated after the
1990 * intersection of beacon caps and self caps is done because
1991 * the bits for TWT are unique to STA and AP and cannot be
1992 * intersected.
1993 */
1994 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
1995 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08001996 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001997
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001998 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001999 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002000 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08002001
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302002 if (lim_is_fils_connection(pe_session)) {
2003 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
2004 aes_block_size_len = AES_BLOCK_SIZE;
2005 }
2006
2007 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302008 * MBO IE needs to be appendded at the end of the assoc request
2009 * frame and is not parsed and unpacked by the frame parser
2010 * as the supplicant can send multiple TLVs with same Attribute
2011 * in the MBO IE and the frame parser does not support multiple
2012 * TLVs with same attribute in a single IE.
2013 * Strip off the MBO IE from add_ie and append it at the end.
2014 */
2015 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
2016 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
2017 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002018 if (!mbo_ie)
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302019 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302020
2021 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
Srinivas Girigowda61771262019-04-01 11:55:19 -07002022 WLAN_ELEMID_VENDOR, ONE_BYTE,
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302023 SIR_MAC_MBO_OUI,
2024 SIR_MAC_MBO_OUI_SIZE,
2025 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
2026 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2027 pe_err("Failed to strip MBO IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302028 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302029 }
2030
2031 /* Include the EID and length fields */
2032 mbo_ie_len = mbo_ie[1] + 2;
2033 pe_debug("Stripped MBO IE of length %d", mbo_ie_len);
Srinivas Dasari603d4972019-09-20 17:28:44 +05302034
2035 peer = wlan_objmgr_get_peer_by_mac(mac_ctx->psoc,
2036 mlm_assoc_req->peerMacAddr,
2037 WLAN_MBO_ID);
2038 if (peer && !mlme_get_peer_pmf_status(peer)) {
2039 pe_debug("Peer doesn't support PMF, Don't add MBO IE");
2040 qdf_mem_free(mbo_ie);
2041 mbo_ie = NULL;
2042 mbo_ie_len = 0;
2043 }
2044 if (peer)
2045 wlan_objmgr_peer_release_ref(peer, WLAN_MBO_ID);
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302046 }
2047
Srinivas Dasari22397902019-07-29 21:34:10 +05302048 /*
2049 * Strip rest of the vendor IEs and append to the assoc request frame.
2050 * Append the IEs just before MBO IEs as MBO IEs have to be at the
2051 * end of the frame.
2052 */
2053 if (wlan_get_ie_ptr_from_eid(WLAN_ELEMID_VENDOR, add_ie, add_ie_len)) {
2054 vendor_ies = qdf_mem_malloc(MAX_VENDOR_IES_LEN + 2);
2055 if (vendor_ies) {
2056 current_len = add_ie_len;
2057 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
2058 WLAN_ELEMID_VENDOR, ONE_BYTE,
2059 NULL,
2060 0,
2061 vendor_ies,
2062 MAX_VENDOR_IES_LEN);
2063 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2064 pe_err("Failed to strip Vendor IEs");
2065 goto end;
2066 }
2067
2068 vendor_ie_len = current_len - add_ie_len;
2069 pe_debug("Stripped vendor IEs of size: %u",
2070 current_len);
2071 }
2072 }
2073
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302074 qdf_status = lim_fill_adaptive_11r_ie(pe_session, &adaptive_11r_ie,
2075 &adaptive_11r_ie_len);
2076 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2077 pe_err("Failed to fill adaptive 11r IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302078 goto end;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302079 }
2080
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302081 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302082 * Do unpack to populate the add_ie buffer to frm structure
2083 * before packing the frm structure. In this way, the IE ordering
2084 * which the latest 802.11 spec mandates is maintained.
2085 */
Naveen Rawat72475db2017-12-13 18:07:35 -08002086 if (add_ie_len) {
2087 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302088 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08002089 if (DOT11F_FAILED(ret)) {
2090 pe_err("unpack failed, ret: 0x%x", ret);
2091 goto end;
2092 }
2093 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302094
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
2096 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002097 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 status);
2099 /* We'll fall back on the worst case scenario: */
2100 payload = sizeof(tDot11fAssocRequest);
2101 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002102 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 status);
2104 }
2105
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302106 bytes = payload + sizeof(tSirMacMgmtHdr) +
Srinivas Dasari22397902019-07-29 21:34:10 +05302107 aes_block_size_len + mbo_ie_len + adaptive_11r_ie_len +
2108 vendor_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302110 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302112 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002113 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114
2115 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302116 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 pe_session->peSessionId,
2118 pe_session->limMlmState));
2119
2120 /* Update PE session id */
2121 assoc_cnf.sessionId = pe_session->peSessionId;
2122
2123 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2126 (uint32_t *) &assoc_cnf);
2127
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302128 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 }
2130 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08002131 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132
2133 /* Next, we fill out the buffer descriptor: */
2134 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2135 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302136 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 /* That done, pack the Assoc Request: */
2138 status = dot11f_pack_assoc_request(mac_ctx, frm,
2139 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2140 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002141 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302143 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002145 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 }
2147
Srinivas Dasari22397902019-07-29 21:34:10 +05302148 /* Copy the vendor IEs to the end of the frame */
2149 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2150 vendor_ies, vendor_ie_len);
2151 payload = payload + vendor_ie_len;
2152
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302153 /* Copy the MBO IE to the end of the frame */
2154 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2155 mbo_ie, mbo_ie_len);
2156 payload = payload + mbo_ie_len;
2157
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302158 /*
2159 * Copy the Vendor specific Adaptive 11r IE to end of the
2160 * assoc request frame
2161 */
2162 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2163 adaptive_11r_ie, adaptive_11r_ie_len);
2164 payload = payload + adaptive_11r_ie_len;
2165
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002166 if (pe_session->assocReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302167 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002169 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170 }
2171
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302172 if (lim_is_fils_connection(pe_session)) {
2173 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2174 frame, &payload);
2175 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2176 cds_packet_free((void *)packet);
Srinivas Dasari22397902019-07-29 21:34:10 +05302177 goto end;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302178 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 }
2180
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302181 pe_session->assocReq = qdf_mem_malloc(payload);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002182 if (pe_session->assocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 /*
2184 * Store the Assoc request. This is sent to csr/hdd in
2185 * join cnf response.
2186 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302187 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 frame + sizeof(tSirMacMgmtHdr), payload);
2189 pe_session->assocReqLen = payload;
2190 }
2191
Liangwei Dong419d7302019-07-15 15:38:28 +08002192 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
2193 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2194 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002195 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2196
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302197 if (pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2198 pe_session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2200
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302202 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302204
2205 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002206 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002207 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002208 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002209 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002210 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302211 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302212 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2214 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302215 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002216 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302217 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302218 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302219 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002220
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302221 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002222 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302223 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302224 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002225 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302228
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302229end:
Srinivas Dasari22397902019-07-29 21:34:10 +05302230 qdf_mem_free(vendor_ies);
2231 qdf_mem_free(mbo_ie);
2232
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 /* Free up buffer allocated for mlm_assoc_req */
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302234 qdf_mem_free(adaptive_11r_ie);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302235 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302237 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 return;
2239}
2240
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002242 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2243 * @context: pointer to global mac
2244 * @buf: buffer which is nothing but entire ADD BA frame
2245 * @tx_complete : Sent status
2246 * @params; tx completion params
2247 *
2248 * Return: This returns QDF_STATUS
2249 */
2250static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2251 qdf_nbuf_t buf,
2252 uint32_t tx_complete,
2253 void *params)
2254{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002255 struct mac_context *mac_ctx = (struct mac_context *)context;
Krunal Sonid2136c72018-06-01 17:26:39 -07002256 tSirMacMgmtHdr *mac_hdr;
2257 tDot11faddba_rsp rsp;
2258 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2259 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
2260 uint8_t peer_id;
2261 void *peer;
2262 uint32_t frame_len;
2263 QDF_STATUS status;
2264 uint8_t *data;
2265
2266 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2267 pe_debug("Add ba response successfully sent");
2268 else
2269 pe_debug("Fail to send add ba response");
2270
2271 if (!buf) {
2272 pe_err("Addba response frame buffer is NULL");
2273 return QDF_STATUS_E_FAILURE;
2274 }
2275
2276 data = qdf_nbuf_data(buf);
2277
2278 if (!data) {
2279 pe_err("Addba response frame is NULL");
2280 return QDF_STATUS_E_FAILURE;
2281 }
2282
2283 mac_hdr = (tSirMacMgmtHdr *)data;
2284 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2285 frame_len = sizeof(rsp);
2286 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2287 sizeof(*mac_hdr), frame_len,
2288 &rsp, false);
2289
2290 if (DOT11F_FAILED(status)) {
2291 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2292 status, frame_len);
2293 goto error;
2294 }
2295
2296 peer = cdp_peer_get_ref_by_addr(soc, pdev, mac_hdr->da, &peer_id,
2297 PEER_DEBUG_ID_WMA_ADDBA_REQ);
2298 if (!peer) {
2299 pe_debug("no PEER found for mac_addr:%pM", mac_hdr->da);
2300 goto error;
2301 }
2302 cdp_addba_resp_tx_completion(soc, peer, rsp.addba_param_set.tid,
2303 tx_complete);
2304 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_WMA_ADDBA_REQ);
2305error:
2306 if (buf)
2307 qdf_nbuf_free(buf);
2308
2309 return QDF_STATUS_SUCCESS;
2310}
2311
2312/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302313 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302314 * @context: pointer to global mac
2315 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302316 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302317 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302318 *
2319 * Return: This returns QDF_STATUS
2320 */
2321
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302322static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2323 qdf_nbuf_t buf,
2324 uint32_t tx_complete,
2325 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302326{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002327 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302328 uint16_t auth_ack_status;
2329 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302330
Naveen Rawat684e8b12017-09-20 15:54:44 -07002331 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002332 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2333 "success" : "fail");
2334 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302335 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302336 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002337 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302338 /* 'Change' timer for future activations */
2339 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2340 } else {
2341 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302342 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002343 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302344 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302345
2346 if (buf)
2347 qdf_nbuf_free(buf);
2348
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302349 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2350 NULL, auth_ack_status, reason_code);
2351
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302352 return QDF_STATUS_SUCCESS;
2353}
2354
2355/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2357 *
2358 * @mac_ctx: Pointer to Global MAC structure
2359 * @auth_frame: Pointer to Authentication frame structure
2360 * @peer_addr: MAC address of destination peer
2361 * @wep_bit: wep bit in frame control for Authentication frame3
2362 * @session: PE session information
2363 *
2364 * This function is called by lim_process_mlm_messages(). Authentication frame
2365 * is formatted and sent when this function is called.
2366 *
2367 * Return: void
2368 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002370lim_send_auth_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 tpSirMacAuthFrameBody auth_frame,
2372 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302373 uint8_t wep_challenge_len,
Jeff Johnsona7815652018-11-18 22:58:30 -08002374 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375{
2376 uint8_t *frame, *body;
2377 uint32_t frame_len = 0, body_len = 0;
2378 tpSirMacMgmtHdr mac_hdr;
2379 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302380 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 uint8_t tx_flag = 0;
2382 uint8_t sme_sessionid = 0;
2383 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002384 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002385 enum rateid min_rid = RATEID_DEFAULT;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302386 uint16_t ch_freq_tx_frame = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002388 if (!session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002389 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002390 return;
2391 }
2392
2393 sme_sessionid = session->smeSessionId;
2394
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302395 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002396 /*
2397 * Auth frame3 to be sent with encrypted framebody
2398 *
2399 * Allocate buffer for Authenticaton frame of size
2400 * equal to management frame header length plus 2 bytes
2401 * each for auth algorithm number, transaction number,
2402 * status code, 128 bytes for challenge text and
2403 * 4 bytes each for IV & ICV.
2404 */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002405 pe_debug("Sending encrypted auth frame to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002406 QDF_MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002407
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302408 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002409 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002410
2411 goto alloc_packet;
2412 }
2413
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002414 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002415 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 auth_frame->authTransactionSeqNumber,
2417 auth_frame->authStatusCode,
2418 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002419 QDF_MAC_ADDR_ARRAY(peer_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420
2421 switch (auth_frame->authTransactionSeqNumber) {
2422 case SIR_MAC_AUTH_FRAME_1:
2423 /*
2424 * Allocate buffer for Authenticaton frame of size
2425 * equal to management frame header length plus 2 bytes
2426 * each for auth algorithm number, transaction number
2427 * and status code.
2428 */
2429
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002430 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2431 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302433 frame_len += lim_create_fils_auth_data(mac_ctx,
2434 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002436 if (session->ftPEContext.pFTPreAuthReq &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 0 != session->ftPEContext.pFTPreAuthReq->
2438 ft_ies_length) {
2439 ft_ies_length = session->ftPEContext.
2440 pFTPreAuthReq->ft_ies_length;
2441 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002442 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 ft_ies_length);
2444 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002445 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 frame_len += (2 + SIR_MDIE_SIZE);
2447 }
2448 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302449
2450 /* include MDIE in FILS authentication frame */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302451 if (session->lim_join_req &&
2452 session->lim_join_req->is11Rconnection &&
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302453 auth_frame->authAlgoNumber == SIR_FILS_SK_WITHOUT_PFS &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302454 session->lim_join_req->bssDescription.mdiePresent)
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302455 frame_len += (2 + SIR_MDIE_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 break;
2457
2458 case SIR_MAC_AUTH_FRAME_2:
2459 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2460 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2461 (auth_frame->authStatusCode !=
2462 eSIR_MAC_SUCCESS_STATUS))) {
2463 /*
2464 * Allocate buffer for Authenticaton frame of size
2465 * equal to management frame header length plus
2466 * 2 bytes each for auth algorithm number,
2467 * transaction number and status code.
2468 */
2469
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002470 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2471 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 } else {
2473 /*
2474 * Shared Key algorithm with challenge text
2475 * to be sent.
2476 *
2477 * Allocate buffer for Authenticaton frame of size
2478 * equal to management frame header length plus
2479 * 2 bytes each for auth algorithm number,
2480 * transaction number, status code and 128 bytes
2481 * for challenge text.
2482 */
2483
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002484 challenge_req = true;
2485 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302486 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2487 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002488 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 }
2490 break;
2491
2492 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002493 /*
2494 * Auth frame3 to be sent without encrypted framebody
2495 *
2496 * Allocate buffer for Authenticaton frame of size equal
2497 * to management frame header length plus 2 bytes each
2498 * for auth algorithm number, transaction number and
2499 * status code.
2500 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002502 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2503 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002504 break;
2505
2506 case SIR_MAC_AUTH_FRAME_4:
2507 /*
2508 * Allocate buffer for Authenticaton frame of size equal
2509 * to management frame header length plus 2 bytes each
2510 * for auth algorithm number, transaction number and
2511 * status code.
2512 */
2513
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002514 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2515 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516
2517 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002518 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002519 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002520 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 } /* switch (auth_frame->authTransactionSeqNumber) */
2522
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002523alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302524 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 (void **)&packet);
2526
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302527 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002528 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529 return;
2530 }
2531
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302532 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533
2534 /* Prepare BD */
2535 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302536 SIR_MAC_MGMT_AUTH, peer_addr, session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302538 if (wep_challenge_len)
2539 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2540 else
2541 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542
2543 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002544 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302545 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546 (uint8_t *) session->bssId,
2547 sizeof(tSirMacAddr));
2548
2549 /* Prepare Authentication frame body */
2550 body = frame + sizeof(tSirMacMgmtHdr);
2551
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302552 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302553 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002555 pe_debug("Sending Auth seq# 3 to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002556 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557
2558 } else {
2559 *((uint16_t *) (body)) =
2560 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2561 body += sizeof(uint16_t);
2562 body_len -= sizeof(uint16_t);
2563
2564 *((uint16_t *) (body)) =
2565 sir_swap_u16if_needed(
2566 auth_frame->authTransactionSeqNumber);
2567 body += sizeof(uint16_t);
2568 body_len -= sizeof(uint16_t);
2569
2570 *((uint16_t *) (body)) =
2571 sir_swap_u16if_needed(auth_frame->authStatusCode);
2572 body += sizeof(uint16_t);
2573 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002574
2575 if (challenge_req) {
2576 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302577 /* copy challenge IE id, len, challenge text */
2578 *body = auth_frame->type;
2579 body++;
2580 body_len -= sizeof(uint8_t);
2581 *body = auth_frame->length;
2582 body++;
2583 body_len -= sizeof(uint8_t);
2584 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002585 body_len);
2586 pe_err("Incomplete challenge info: length: %d, expected: %d",
2587 body_len,
2588 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2589 body += body_len;
2590 body_len = 0;
2591 } else {
2592 /* copy challenge IE id, len, challenge text */
2593 *body = auth_frame->type;
2594 body++;
2595 *body = auth_frame->length;
2596 body++;
2597 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302598 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2599 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002600
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302601 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2602 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002603 }
2604 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2607 (auth_frame->authTransactionSeqNumber ==
2608 SIR_MAC_AUTH_FRAME_1) &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002609 (session->ftPEContext.pFTPreAuthReq)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610
2611 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302612 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 session->ftPEContext.
2614 pFTPreAuthReq->ft_ies,
2615 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002616 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002617 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2618 QDF_TRACE_LEVEL_DEBUG,
2619 (uint8_t *) body,
2620 ft_ies_length);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002621 } else if (session->ftPEContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 pFTPreAuthReq->pbssDescription) {
2623 /* MDID attr is 54 */
Srinivas Girigowda61771262019-04-01 11:55:19 -07002624 *body = WLAN_ELEMID_MOBILITY_DOMAIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 body++;
2626 *body = SIR_MDIE_SIZE;
2627 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302628 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 &session->ftPEContext.pFTPreAuthReq->
2630 pbssDescription->mdie[0],
2631 SIR_MDIE_SIZE);
2632 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302633 } else if ((auth_frame->authAlgoNumber ==
2634 SIR_FILS_SK_WITHOUT_PFS) &&
2635 (auth_frame->authTransactionSeqNumber ==
2636 SIR_MAC_AUTH_FRAME_1)) {
2637 pe_debug("FILS: appending fils Auth data");
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302638 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002641 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002642 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643 auth_frame->authTransactionSeqNumber,
2644 auth_frame->authStatusCode,
2645 (auth_frame->authStatusCode ==
2646 eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002647 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002649 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2650 QDF_TRACE_LEVEL_DEBUG,
2651 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002653 if ((session->ftPEContext.pFTPreAuthReq) &&
Liangwei Dong419d7302019-07-15 15:38:28 +08002654 (lim_get_rf_band(
2655 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)) ==
2656 BAND_5G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Liangwei Dong419d7302019-07-15 15:38:28 +08002658 else if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
2659 session->opmode == QDF_P2P_CLIENT_MODE ||
2660 session->opmode == QDF_P2P_GO_MODE)
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302661 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302663 if (session->opmode == QDF_P2P_CLIENT_MODE ||
2664 session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2666
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302667 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302670 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002671 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002672 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002673 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302674
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002675 if (session->ftPEContext.pFTPreAuthReq)
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302676 ch_freq_tx_frame = cds_chan_to_freq(
2677 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum);
2678
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302679 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2680 (uint16_t)frame_len,
2681 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2682 7, lim_tx_complete, frame,
2683 lim_auth_tx_complete_cnf,
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302684 tx_flag, sme_sessionid, false,
2685 ch_freq_tx_frame, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302686 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2687 session->peSessionId, qdf_status));
2688 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2689 pe_err("*** Could not send Auth frame, retCode=%X ***",
2690 qdf_status);
2691 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2692 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002693 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302694 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302695 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 return;
2697}
2698
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002699QDF_STATUS lim_send_deauth_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700{
2701 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002702 tpDphHashNode sta_ds;
2703 tLimMlmDeauthReq *deauth_req;
2704 tLimMlmDeauthCnf deauth_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002705 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002707 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2708 if (deauth_req) {
2709 if (tx_timer_running(
2710 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2711 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002714 session_entry = pe_find_session_by_session_id(mac_ctx,
2715 deauth_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002716 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002717 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002718 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 eSIR_SME_INVALID_PARAMETERS;
2720 goto end;
2721 }
2722
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002723 sta_ds =
2724 dph_lookup_hash_entry(mac_ctx,
2725 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002726 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002727 &session_entry->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002728 if (!sta_ds) {
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002729 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 goto end;
2731 }
2732
2733 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002734 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2735 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2736 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2737 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302738#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002739 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302740#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002741 (session_entry->isFastRoamIniFeatureEnabled) ||
2742 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002743 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002744 session_entry,
2745 session_entry->peSessionId,
2746 deauth_req->reasonCode,
2747 deauth_req->deauthTrigger);
2748 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002749 } else {
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002750#ifdef FEATURE_WLAN_ESE
Nirav Shahf359dd22019-02-20 10:34:28 +05302751 pe_debug("No FT Preauth Session Cleanup in role %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002752 " isESE %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002753 " isLFR %d"
2754 " is11r %d, Deauth reason %d Trigger = %d",
2755 session_entry->limSystemRole,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002756 session_entry->isESEconnection,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002757 session_entry->isFastRoamIniFeatureEnabled,
2758 session_entry->is11Rconnection,
2759 deauth_req->reasonCode,
2760 deauth_req->deauthTrigger);
Nirav Shahf359dd22019-02-20 10:34:28 +05302761#else
2762 pe_debug("No FT Preauth Session Cleanup in role %d"
2763 " isLFR %d"
2764 " is11r %d, Deauth reason %d Trigger = %d",
2765 session_entry->limSystemRole,
2766 session_entry->isFastRoamIniFeatureEnabled,
2767 session_entry->is11Rconnection,
2768 deauth_req->reasonCode,
2769 deauth_req->deauthTrigger);
2770#endif
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002771 }
2772 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002773 qdf_mem_free(deauth_req);
2774 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302776 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002778 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2779 &deauth_req->peer_macaddr);
2780 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2781 deauth_cnf.aid = deauth_req->aid;
2782 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783
2784 /* Free up buffer allocated */
2785 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002786 qdf_mem_free(deauth_req);
2787 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002789 lim_post_sme_message(mac_ctx,
2790 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302791 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792}
2793
2794/**
2795 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2796 *
2797 * @mac_ctx: Handle to MAC context
2798 *
2799 * Sends disassoc confirmation to SME. Removes disassoc request stored
2800 * in lim.
2801 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302802 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 */
2804
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002805QDF_STATUS lim_send_disassoc_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806{
2807 uint16_t aid;
2808 tpDphHashNode sta_ds;
2809 tLimMlmDisassocCnf disassoc_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002810 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 tLimMlmDisassocReq *disassoc_req;
2812
2813 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2814 if (disassoc_req) {
2815 if (tx_timer_running(
2816 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2817 lim_deactivate_and_change_timer(mac_ctx,
2818 eLIM_DISASSOC_ACK_TIMER);
2819
2820 pe_session = pe_find_session_by_session_id(
2821 mac_ctx, disassoc_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002822 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002823 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 disassoc_cnf.resultCode =
2825 eSIR_SME_INVALID_PARAMETERS;
2826 goto end;
2827 }
2828
2829 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002830 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 &pe_session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002832 if (!sta_ds) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002833 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2835 goto end;
2836 }
2837 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002838 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2840 disassoc_cnf.resultCode =
2841 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002842 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 goto end;
2844 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002845 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002846 (disassoc_req->reasonCode !=
2847 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002848 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002849 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 /* Delete FT session if there exists one */
2852 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302855 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302857 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302859 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 }
2861end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302862 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002863 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302864 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 disassoc_cnf.aid = disassoc_req->aid;
2866 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2867
2868 /* Update PE session ID */
2869 disassoc_cnf.sessionId = disassoc_req->sessionId;
2870
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002871 if (disassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302873 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2875 }
2876
2877 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2878 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302879 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880}
2881
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302882QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002883 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302884 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002885{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002886 struct mac_context *max_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302887
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002888 pe_debug("tx_success: %d", tx_success);
2889
2890 return lim_send_disassoc_cnf(max_ctx);
2891}
2892
2893static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2894 qdf_nbuf_t buf,
2895 uint32_t tx_success,
2896 void *params)
2897{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002898 struct mac_context *max_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002899 QDF_STATUS status_code;
2900 struct scheduler_msg msg = {0};
2901
2902 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302903
2904 if (buf)
2905 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002906 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2907 msg.bodyptr = params;
2908 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302909
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002910 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2911 if (status_code != QDF_STATUS_SUCCESS)
2912 pe_err("posting message: %X to LIM failed, reason: %d",
2913 msg.type, status_code);
2914 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002915}
2916
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302917QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002918 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302919 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002921 struct mac_context *mac_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302922
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002923 pe_debug("tx_success: %d", tx_success);
2924
2925 return lim_send_deauth_cnf(mac_ctx);
2926}
2927
2928static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2929 qdf_nbuf_t buf,
2930 uint32_t tx_success,
2931 void *params)
2932{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002933 struct mac_context *mac_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002934 QDF_STATUS status_code;
2935 struct scheduler_msg msg = {0};
2936
2937 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302938
2939 if (buf)
2940 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002941 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2942 msg.bodyptr = params;
2943 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302944
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002945 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2946 if (status_code != QDF_STATUS_SUCCESS)
2947 pe_err("posting message: %X to LIM failed, reason: %d",
2948 msg.type, status_code);
2949 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950}
2951
2952/**
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05302953 * lim_append_ies_to_frame() - Append IEs to the frame
2954 *
2955 * @frame: Pointer to the frame buffer that needs to be populated
2956 * @frame_len: Pointer for current frame length
2957 * @ie: pointer for disconnect IEs
2958 *
2959 * This function is called by lim_send_disassoc_mgmt_frame and
2960 * lim_send_deauth_mgmt_frame APIs as part of disconnection.
2961 * Append IEs and update frame length.
2962 *
2963 * Return: None
2964 */
2965static void
2966lim_append_ies_to_frame(uint8_t *frame, uint32_t *frame_len,
2967 struct wlan_ies *ie)
2968{
2969 if (!ie || !ie->len || !ie->data)
2970 return;
2971 qdf_mem_copy(frame, ie->data, ie->len);
2972 *frame_len += ie->len;
2973 pe_debug("Appended IEs len: %u", ie->len);
2974}
2975
2976/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 * \brief This function is called to send Disassociate frame.
2978 *
2979 *
Jeff Johnson99f25042018-11-21 22:49:06 -08002980 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 *
2982 * \param nReason Indicates the reason that need to be sent in
2983 * Disassociation frame
2984 *
2985 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2986 * sent
2987 *
2988 *
2989 */
2990
2991void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002992lim_send_disassoc_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993 uint16_t nReason,
2994 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002995 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996{
2997 tDot11fDisassociation frm;
2998 uint8_t *pFrame;
2999 tpSirMacMgmtHdr pMacHdr;
3000 uint32_t nBytes, nPayload, nStatus;
3001 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303002 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 uint8_t txFlag = 0;
3004 uint32_t val = 0;
3005 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303006 struct wlan_ies *discon_ie;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003007
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003008 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003009 return;
3010 }
3011
3012 /*
3013 * In case when cac timer is running for this SAP session then
3014 * avoid sending disassoc out. It is violation of dfs specification.
3015 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303016 if (((pe_session->opmode == QDF_SAP_MODE) ||
3017 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003018 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303019 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303020 FL("CAC timer is running, drop disassoc from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303021 if (waitForAck)
3022 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023 return;
3024 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003025 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026
hangtian127c9532019-01-12 13:29:07 +08003027 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028
3029 frm.Reason.code = nReason;
3030
Jeff Johnson99f25042018-11-21 22:49:06 -08003031 nStatus = dot11f_get_packed_disassociation_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003033 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 nStatus);
3035 /* We'll fall back on the worst case scenario: */
3036 nPayload = sizeof(tDot11fDisassociation);
3037 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003038 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
3039 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 }
3041
3042 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3043
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303044 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3045 if (discon_ie && discon_ie->len)
3046 nBytes += discon_ie->len;
3047
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303048 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303050 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003051 pe_err("Failed to allocate %d bytes for a Disassociation",
3052 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303053 if (waitForAck)
3054 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 return;
3056 }
3057 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003058 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059
3060 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003061 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303062 SIR_MAC_MGMT_DISASSOC, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3064
3065 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003066 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003068 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069
Jeff Johnson99f25042018-11-21 22:49:06 -08003070 nStatus = dot11f_pack_disassociation(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 sizeof(tSirMacMgmtHdr),
3072 nPayload, &nPayload);
3073 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003074 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003075 nStatus);
3076 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303077 if (waitForAck)
3078 lim_send_disassoc_cnf(mac);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003079 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003081 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
3082 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 }
3084
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303085 /* Copy disconnect IEs to the end of the frame */
3086 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3087 &nPayload, discon_ie);
3088 mlme_free_self_disconnect_ies(pe_session->vdev);
3089
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003090 pe_debug("***Sessionid %d Sending Disassociation frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003091 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR " ,From "
3092 QDF_MAC_ADDR_STR, pe_session->peSessionId, nReason,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003093 waitForAck, QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303094 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095
Liangwei Dong419d7302019-07-15 15:38:28 +08003096 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3097 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3098 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100
Sushant Kaushik46556062015-12-02 16:57:47 +05303101 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102
3103 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303104 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003105 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003107 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003108 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003109 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 /* Queue Disassociation frame in high priority WQ */
3111 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303112 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003113 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003114 TXRX_FRM_802_11_MGMT,
3115 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003116 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003117 txFlag, smeSessionId, false, 0,
3118 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303119 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303120 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003121 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122
3123 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3124
3125 if (tx_timer_change
Jeff Johnson99f25042018-11-21 22:49:06 -08003126 (&mac->lim.limTimers.gLimDisassocAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003128 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 return;
3130 } else if (TX_SUCCESS !=
Jeff Johnson99f25042018-11-21 22:49:06 -08003131 tx_timer_activate(&mac->lim.limTimers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003133 pe_err("Unable to activate Disassoc ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003134 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003135 eLIM_DISASSOC_ACK_TIMER);
3136 return;
3137 }
3138 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303139 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003140 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003142 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003143 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003144 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003146 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 TXRX_FRM_802_11_MGMT,
3148 ANI_TXDIR_TODS,
3149 7,
3150 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003151 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303152 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303153 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003154 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303155 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003156 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303157 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 /* Pkt will be freed up by the callback */
3159 }
3160 }
3161} /* End lim_send_disassoc_mgmt_frame. */
3162
3163/**
3164 * \brief This function is called to send a Deauthenticate frame
3165 *
3166 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003167 * \param mac Pointer to global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 *
3169 * \param nReason Indicates the reason that need to be sent in the
3170 * Deauthenticate frame
3171 *
3172 * \param peeer address of the STA to which the frame is to be sent
3173 *
3174 *
3175 */
3176
3177void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003178lim_send_deauth_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 uint16_t nReason,
3180 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003181 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182{
3183 tDot11fDeAuth frm;
3184 uint8_t *pFrame;
3185 tpSirMacMgmtHdr pMacHdr;
3186 uint32_t nBytes, nPayload, nStatus;
3187 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303188 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 uint8_t txFlag = 0;
3190 uint32_t val = 0;
3191#ifdef FEATURE_WLAN_TDLS
3192 uint16_t aid;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003193 tpDphHashNode sta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194#endif
3195 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303196 struct wlan_ies *discon_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003198 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 return;
3200 }
3201
3202 /*
3203 * In case when cac timer is running for this SAP session then
3204 * avoid deauth frame out. It is violation of dfs specification.
3205 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303206 if (((pe_session->opmode == QDF_SAP_MODE) ||
3207 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003208 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303209 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 FL
3211 ("CAC timer is running, drop the deauth from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303212 if (waitForAck)
3213 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 return;
3215 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003216 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217
hangtian127c9532019-01-12 13:29:07 +08003218 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219
3220 frm.Reason.code = nReason;
3221
Jeff Johnson99f25042018-11-21 22:49:06 -08003222 nStatus = dot11f_get_packed_de_auth_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003224 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 nStatus);
3226 /* We'll fall back on the worst case scenario: */
3227 nPayload = sizeof(tDot11fDeAuth);
3228 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003229 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3230 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 }
3232
3233 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303234 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3235 if (discon_ie && discon_ie->len)
3236 nBytes += discon_ie->len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303238 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303240 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003241 pe_err("Failed to allocate %d bytes for a De-Authentication",
3242 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303243 if (waitForAck)
3244 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 return;
3246 }
3247 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003248 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249
3250 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003251 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303252 SIR_MAC_MGMT_DEAUTH, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3254
3255 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003256 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003258 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259
Jeff Johnson99f25042018-11-21 22:49:06 -08003260 nStatus = dot11f_pack_de_auth(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3262 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003263 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 nStatus);
3265 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303266 if (waitForAck)
3267 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 return;
3269 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003270 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3271 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 }
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303273
3274 /* Copy disconnect IEs to the end of the frame */
3275 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3276 &nPayload, discon_ie);
3277 mlme_free_self_disconnect_ies(pe_session->vdev);
3278
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003279 pe_debug("***Sessionid %d Sending Deauth frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003280 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR
3281 " ,From " QDF_MAC_ADDR_STR,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003282 pe_session->peSessionId, nReason, waitForAck,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003283 QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303284 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285
Liangwei Dong419d7302019-07-15 15:38:28 +08003286 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3287 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3288 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290
Sushant Kaushik46556062015-12-02 16:57:47 +05303291 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003293 sta =
Jeff Johnson99f25042018-11-21 22:49:06 -08003294 dph_lookup_hash_entry(mac, peer, &aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003295 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296#endif
3297
3298 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303299 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003300 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003302 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003303 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003304 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303306 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003307 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 TXRX_FRM_802_11_MGMT,
3309 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003310 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003311 txFlag, smeSessionId, false, 0,
3312 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303313 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303314 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003315 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303317 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003318 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303319 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320
3321 /* Call lim_process_deauth_ack_timeout which will send
3322 * DeauthCnf for this frame
3323 */
Jeff Johnson99f25042018-11-21 22:49:06 -08003324 lim_process_deauth_ack_timeout(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 return;
3326 }
3327
3328 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3329
3330 if (tx_timer_change
Jeff Johnson99f25042018-11-21 22:49:06 -08003331 (&mac->lim.limTimers.gLimDeauthAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003333 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 return;
3335 } else if (TX_SUCCESS !=
Jeff Johnson99f25042018-11-21 22:49:06 -08003336 tx_timer_activate(&mac->lim.limTimers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003338 pe_err("Unable to activate Deauth ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003339 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 eLIM_DEAUTH_ACK_TIMER);
3341 return;
3342 }
3343 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303344 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003345 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346 pMacHdr->fc.subType));
3347#ifdef FEATURE_WLAN_TDLS
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003348 if ((sta)
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003349 && (STA_ENTRY_TDLS_PEER == sta->staType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003351 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003352 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003353 QDF_STATUS_SUCCESS,
3354 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303355 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003356 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3358 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003359 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 } else {
3361#endif
Jeff Johnson99f25042018-11-21 22:49:06 -08003362 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003363 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003364 QDF_STATUS_SUCCESS,
3365 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303367 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003368 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3370 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003371 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372#ifdef FEATURE_WLAN_TDLS
3373 }
3374#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303375 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003376 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303377 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003378 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303379 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 /* Pkt will be freed up by the callback */
3381 }
3382 }
3383
3384} /* End lim_send_deauth_mgmt_frame. */
3385
3386#ifdef ANI_SUPPORT_11H
3387/**
3388 * \brief Send a Measurement Report Action frame
3389 *
3390 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003391 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 *
3393 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3394 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003395 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 *
3397 *
3398 */
3399
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003400QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003401lim_send_meas_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 tpSirMacMeasReqActionFrame pMeasReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003403 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404{
3405 tDot11fMeasurementReport frm;
3406 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003407 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 tpSirMacMgmtHdr pMacHdr;
3409 uint32_t nBytes, nPayload, nStatus;
3410 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303411 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003412
hangtian127c9532019-01-12 13:29:07 +08003413 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003415 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003416 frm.Action.action = ACTION_SPCT_MSR_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3418
3419 switch (pMeasReqFrame->measReqIE.measType) {
3420 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3421 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003422 populate_dot11f_measurement_report0(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 &frm.MeasurementReport);
3424 break;
3425 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3426 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003427 populate_dot11f_measurement_report1(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 &frm.MeasurementReport);
3429 break;
3430 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3431 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003432 populate_dot11f_measurement_report2(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 &frm.MeasurementReport);
3434 break;
3435 default:
Jeff Johnson0711e272018-12-14 23:16:38 -08003436 pe_err("Unknown measurement type %d in limSendMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003438 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 }
3440
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003441 if (QDF_STATUS_SUCCESS != nSirStatus)
3442 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443
Jeff Johnson99f25042018-11-21 22:49:06 -08003444 nStatus = dot11f_get_packed_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003446 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 nStatus);
3448 /* We'll fall back on the worst case scenario: */
3449 nPayload = sizeof(tDot11fMeasurementReport);
3450 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003451 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3452 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 }
3454
3455 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3456
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303457 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003458 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459 (uint16_t) nBytes, (void **)&pFrame,
3460 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303461 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson0711e272018-12-14 23:16:38 -08003462 pe_err("Failed to allocate %d bytes for a De-Authentication",
3463 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003464 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 }
3466 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003467 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468
3469 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003470 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 SIR_MAC_MGMT_ACTION, peer);
3472 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3473
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003474 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003476 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477
Jeff Johnson99f25042018-11-21 22:49:06 -08003478 nStatus = dot11f_pack_measurement_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479 sizeof(tSirMacMgmtHdr),
3480 nPayload, &nPayload);
3481 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003482 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003484 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003486 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003488 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3489 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 }
3491
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303492 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003493 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303495 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003496 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003497 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003498 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303499 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303500 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003501 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303502 qdf_status));
3503 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003504 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303505 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003507 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 }
3509
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003510 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511
3512} /* End lim_send_meas_report_frame. */
3513
3514/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 * \brief Send a TPC Report Action frame
3516 *
3517 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003518 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003519 *
3520 * \param pTpcReqFrame Pointer to the received TPC Request
3521 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003522 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 *
3524 *
3525 */
3526
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003527QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003528lim_send_tpc_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 tpSirMacTpcReqActionFrame pTpcReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003530 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531{
3532 tDot11fTPCReport frm;
3533 uint8_t *pFrame;
3534 tpSirMacMgmtHdr pMacHdr;
3535 uint32_t nBytes, nPayload, nStatus;
3536 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303537 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538
hangtian127c9532019-01-12 13:29:07 +08003539 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003541 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003542 frm.Action.action = ACTION_SPCT_TPC_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3544
3545 frm.TPCReport.tx_power = 0;
3546 frm.TPCReport.link_margin = 0;
3547 frm.TPCReport.present = 1;
3548
Jeff Johnson99f25042018-11-21 22:49:06 -08003549 nStatus = dot11f_get_packed_tpc_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003551 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 /* We'll fall back on the worst case scenario: */
3553 nPayload = sizeof(tDot11fTPCReport);
3554 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003555 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3556 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557 }
3558
3559 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3560
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303561 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003562 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 (uint16_t) nBytes, (void **)&pFrame,
3564 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303565 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003566 pe_err("Failed to allocate %d bytes for a TPC"
3567 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003568 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 }
3570 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003571 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572
3573 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003574 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575 SIR_MAC_MGMT_ACTION, peer);
3576
3577 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3578
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003579 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003581 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582
Jeff Johnson99f25042018-11-21 22:49:06 -08003583 nStatus = dot11f_pack_tpc_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 sizeof(tSirMacMgmtHdr),
3585 nPayload, &nPayload);
3586 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003587 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003589 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003591 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003592 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003593 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3594 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303596 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003597 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303599 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003600 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003602 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303603 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003604 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003605 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003606 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303607 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003608 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303609 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003611 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 }
3613
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003614 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615
3616} /* End lim_send_tpc_report_frame. */
3617#endif /* ANI_SUPPORT_11H */
3618
3619/**
3620 * \brief Send a Channel Switch Announcement
3621 *
3622 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003623 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624 *
3625 * \param peer MAC address to which this frame will be sent
3626 *
3627 * \param nMode
3628 *
3629 * \param nNewChannel
3630 *
3631 * \param nCount
3632 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003633 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 *
3635 *
3636 */
3637
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003638QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003639lim_send_channel_switch_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 tSirMacAddr peer,
3641 uint8_t nMode,
3642 uint8_t nNewChannel,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003643 uint8_t nCount, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644{
3645 tDot11fChannelSwitch frm;
3646 uint8_t *pFrame;
3647 tpSirMacMgmtHdr pMacHdr;
3648 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3649 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303650 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 uint8_t txFlag = 0;
3652
3653 uint8_t smeSessionId = 0;
3654
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003655 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003656 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003657 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003659 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660
hangtian127c9532019-01-12 13:29:07 +08003661 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003663 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003664 frm.Action.action = ACTION_SPCT_CHL_SWITCH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665 frm.ChanSwitchAnn.switchMode = nMode;
3666 frm.ChanSwitchAnn.newChannel = nNewChannel;
3667 frm.ChanSwitchAnn.switchCount = nCount;
3668 frm.ChanSwitchAnn.present = 1;
3669
Jeff Johnson99f25042018-11-21 22:49:06 -08003670 nStatus = dot11f_get_packed_channel_switch_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003672 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 nStatus);
3674 /* We'll fall back on the worst case scenario: */
3675 nPayload = sizeof(tDot11fChannelSwitch);
3676 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003677 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3678 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679 }
3680
3681 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3682
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303683 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3685 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303686 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003687 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003688 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 }
3690 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003691 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692
3693 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003694 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695 SIR_MAC_MGMT_ACTION, peer,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303696 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303698 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003699 (uint8_t *) pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003701 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702
Jeff Johnson99f25042018-11-21 22:49:06 -08003703 nStatus = dot11f_pack_channel_switch(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704 sizeof(tSirMacMgmtHdr),
3705 nPayload, &nPayload);
3706 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003707 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708 nStatus);
3709 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003710 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003712 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3713 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 }
3715
Liangwei Dong419d7302019-07-15 15:38:28 +08003716 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3717 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3718 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303721 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003722 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003723 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724 TXRX_FRM_802_11_MGMT,
3725 ANI_TXDIR_TODS,
3726 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003727 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303728 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003729 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303730 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003731 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303732 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003734 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003735 }
3736
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003737 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003738
3739} /* End lim_send_channel_switch_mgmt_frame. */
3740
Abhishek Singh518323d2015-10-19 17:42:01 +05303741/**
3742 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3743 * action frame over the air .
3744 * @mac_ctx: pointer to global mac structure
3745 * @peer: Destination mac.
3746 * @mode: channel switch mode
3747 * @new_op_class: new op class
3748 * @new_channel: new channel to switch
3749 * @count: channel switch count
3750 *
3751 * This function is called to send ECSA frame.
3752 *
3753 * Return: success if frame is sent else return failure
3754 */
3755
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003756QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003757lim_send_extended_chan_switch_action_frame(struct mac_context *mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05303758 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
Jeff Johnsona7815652018-11-18 22:58:30 -08003759 uint8_t new_channel, uint8_t count, struct pe_session *session_entry)
Abhishek Singh518323d2015-10-19 17:42:01 +05303760{
3761 tDot11fext_channel_switch_action_frame frm;
3762 uint8_t *frame;
3763 tpSirMacMgmtHdr mac_hdr;
3764 uint32_t num_bytes, n_payload, status;
3765 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303766 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303767 uint8_t txFlag = 0;
3768 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303769 uint8_t ch_spacing;
3770 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303771
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003772 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003773 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003774 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303775 }
3776
3777 sme_session_id = session_entry->smeSessionId;
3778
hangtian127c9532019-01-12 13:29:07 +08003779 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh518323d2015-10-19 17:42:01 +05303780
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003781 frm.Category.category = ACTION_CATEGORY_PUBLIC;
Abhishek Singh518323d2015-10-19 17:42:01 +05303782 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3783
3784 frm.ext_chan_switch_ann_action.switch_mode = mode;
3785 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3786 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3787 frm.ext_chan_switch_ann_action.switch_count = count;
3788
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303789 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3790 mac_ctx->scan.countryCodeCurrent, new_channel,
3791 new_op_class);
3792 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3793
3794 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3795 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3796 frm.WiderBWChanSwitchAnn.newChanWidth =
3797 wide_bw_ie->newChanWidth;
3798 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3799 wide_bw_ie->newCenterChanFreq0;
3800 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3801 wide_bw_ie->newCenterChanFreq1;
3802 frm.WiderBWChanSwitchAnn.present = 1;
3803 pe_debug("wrapper: width:%d f0:%d f1:%d",
3804 frm.WiderBWChanSwitchAnn.newChanWidth,
3805 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3806 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3807 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303808
3809 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3810 &frm, &n_payload);
3811 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003812 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303813 status);
3814 /* We'll fall back on the worst case scenario*/
3815 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3816 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003817 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303818 status);
3819 }
3820
3821 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3822
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303823 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303824 (void **) &frame, (void **) &packet);
3825
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303826 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003827 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303828 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003829 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303830 }
3831
3832 /* Paranoia*/
hangtian127c9532019-01-12 13:29:07 +08003833 qdf_mem_zero(frame, num_bytes);
Abhishek Singh518323d2015-10-19 17:42:01 +05303834
3835 /* Next, we fill out the buffer descriptor */
3836 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303837 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh518323d2015-10-19 17:42:01 +05303838 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303839 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303840 (uint8_t *) session_entry->bssId,
3841 sizeof(tSirMacAddr));
3842
gaolez4b62a9e2018-08-16 15:57:50 +08003843 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
3844
Abhishek Singh518323d2015-10-19 17:42:01 +05303845 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3846 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3847 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003848 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303849 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003850 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303851 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003852 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303853 status);
3854 }
3855
Liangwei Dong419d7302019-07-15 15:38:28 +08003856 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
3857 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
3858 session_entry->opmode == QDF_P2P_GO_MODE)
Abhishek Singh518323d2015-10-19 17:42:01 +05303859 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Abhishek Singh518323d2015-10-19 17:42:01 +05303860
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003861 pe_debug("Send Ext channel Switch to :"QDF_MAC_ADDR_STR" with swcount %d, swmode %d , newchannel %d newops %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003862 QDF_MAC_ADDR_ARRAY(mac_hdr->da),
Abhishek Singh518323d2015-10-19 17:42:01 +05303863 frm.ext_chan_switch_ann_action.switch_count,
3864 frm.ext_chan_switch_ann_action.switch_mode,
3865 frm.ext_chan_switch_ann_action.new_channel,
3866 frm.ext_chan_switch_ann_action.op_class);
3867
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303868 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303869 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303870 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303871 TXRX_FRM_802_11_MGMT,
3872 ANI_TXDIR_TODS,
3873 7,
3874 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003875 txFlag, sme_session_id, 0,
3876 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303877 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303878 session_entry->peSessionId, qdf_status));
3879 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003880 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303881 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303882 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003883 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303884 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003885 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05303886} /* End lim_send_extended_chan_switch_action_frame */
3887
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303888
3889/**
3890 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3891 * sent over the air
3892 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303893 * @context: pointer to global mac
3894 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303895 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303896 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303897 *
3898 * Return: This returns QDF_STATUS
3899 */
3900
3901static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303902 void *context,
3903 qdf_nbuf_t buf,
3904 uint32_t tx_complete,
3905 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303906{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003907 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08003908 if (buf)
3909 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303910 return QDF_STATUS_SUCCESS;
3911}
3912
3913/**
3914 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3915 * p2p oper chan change confirm action frame
3916 * @mac_ctx: pointer to global mac structure
3917 * @peer: Destination mac.
3918 * @session_entry: session entry
3919 *
3920 * This function is called to send p2p oper chan change confirm action frame.
3921 *
3922 * Return: success if frame is sent else return failure
3923 */
3924
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003925QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003926lim_p2p_oper_chan_change_confirm_action_frame(struct mac_context *mac_ctx,
Jeff Johnsona7815652018-11-18 22:58:30 -08003927 tSirMacAddr peer, struct pe_session *session_entry)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303928{
3929 tDot11fp2p_oper_chan_change_confirm frm;
3930 uint8_t *frame;
3931 tpSirMacMgmtHdr mac_hdr;
3932 uint32_t num_bytes, n_payload, status;
3933 void *packet;
3934 QDF_STATUS qdf_status;
3935 uint8_t tx_flag = 0;
3936 uint8_t sme_session_id = 0;
3937
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003938 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003939 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003940 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303941 }
3942
3943 sme_session_id = session_entry->smeSessionId;
3944
hangtian127c9532019-01-12 13:29:07 +08003945 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303946
3947 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3948
3949 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3950 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3951 frm.p2p_action_subtype.subtype = 0x04;
3952 frm.DialogToken.token = 0x0;
3953
3954 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003955 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303956 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3957 }
3958
3959 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003960 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303961 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3962 populate_dot11f_operating_mode(mac_ctx,
3963 &frm.OperatingMode, session_entry);
3964 }
3965
3966 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3967 &frm, &n_payload);
3968 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003969 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303970 /* We'll fall back on the worst case scenario*/
3971 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3972 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003973 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3974 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303975 }
3976
3977 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3978
3979 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3980 (void **) &frame, (void **) &packet);
3981
3982 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003983 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003984 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303985 }
3986
hangtian127c9532019-01-12 13:29:07 +08003987 qdf_mem_zero(frame, num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303988
3989 /* Next, fill out the buffer descriptor */
3990 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303991 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303992 mac_hdr = (tpSirMacMgmtHdr) frame;
3993 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3994 (uint8_t *) session_entry->bssId,
3995 sizeof(tSirMacAddr));
3996
3997 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3998 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3999 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004000 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304001 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004002 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304003 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004004 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304005 status);
4006 }
4007
Liangwei Dong419d7302019-07-15 15:38:28 +08004008 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
4009 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
4010 session_entry->opmode == QDF_P2P_GO_MODE) {
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304011 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4012 }
Liangwei Dong419d7302019-07-15 15:38:28 +08004013 pe_debug("Send frame on channel freq %d to mac "
4014 QDF_MAC_ADDR_STR, session_entry->curr_op_freq,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07004015 QDF_MAC_ADDR_ARRAY(peer));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304016
4017 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4018 session_entry->peSessionId, mac_hdr->fc.subType));
4019
4020 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4021 (uint16_t)num_bytes,
4022 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4023 7, lim_tx_complete, frame,
4024 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07004025 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304026
4027 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4028 session_entry->peSessionId, qdf_status));
4029 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004030 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304031 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004032 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304033 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004034 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304035}
4036
4037
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038/**
4039 * \brief Send a Neighbor Report Request Action frame
4040 *
4041 *
Jeff Johnson99f25042018-11-21 22:49:06 -08004042 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043 *
4044 * \param pNeighborReq Address of a tSirMacNeighborReportReq
4045 *
4046 * \param peer mac address of peer station.
4047 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004048 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004050 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 *
4052 *
4053 */
4054
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004055QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004056lim_send_neighbor_report_request_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057 tpSirMacNeighborReportReq pNeighborReq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004058 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304060 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 tDot11fNeighborReportRequest frm;
4062 uint8_t *pFrame;
4063 tpSirMacMgmtHdr pMacHdr;
4064 uint32_t nBytes, nPayload, nStatus;
4065 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304066 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067 uint8_t txFlag = 0;
4068 uint8_t smeSessionId = 0;
4069
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004070 if (!pe_session) {
4071 pe_err("(!psession) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004072 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004074 smeSessionId = pe_session->smeSessionId;
hangtian127c9532019-01-12 13:29:07 +08004075 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004077 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004078 frm.Action.action = RRM_NEIGHBOR_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079 frm.DialogToken.token = pNeighborReq->dialogToken;
4080
4081 if (pNeighborReq->ssid_present) {
Jeff Johnson99f25042018-11-21 22:49:06 -08004082 populate_dot11f_ssid(mac, &pNeighborReq->ssid, &frm.SSID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083 }
4084
4085 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004086 dot11f_get_packed_neighbor_report_request_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004088 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089 nStatus);
4090 /* We'll fall back on the worst case scenario: */
4091 nPayload = sizeof(tDot11fNeighborReportRequest);
4092 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004093 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4094 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095 }
4096
4097 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4098
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304099 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4101 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304102 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004103 pe_err("Failed to allocate %d bytes for a Neighbor "
4104 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004105 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 }
4107 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004108 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109
4110 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004111 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304112 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113
4114 /* Update A3 with the BSSID */
4115 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4116
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004117 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004119 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120
4121 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004122 nStatus = dot11f_pack_neighbor_report_request(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123 &frm,
4124 pFrame +
4125 sizeof(tSirMacMgmtHdr),
4126 nPayload, &nPayload);
4127
4128 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004129 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130 nStatus);
4131
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004132 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304133 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 goto returnAfterError;
4135 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004136 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4137 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 }
4139
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004140 pe_debug("Sending a Neighbor Report Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004141 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142
Liangwei Dong419d7302019-07-15 15:38:28 +08004143 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4144 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4145 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304148 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004149 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004150 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004151 pPacket,
4152 (uint16_t) nBytes,
4153 TXRX_FRM_802_11_MGMT,
4154 ANI_TXDIR_TODS,
4155 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004156 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304157 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004158 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304159 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004160 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304161 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304163 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004165 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004166
4167returnAfterError:
4168 cds_packet_free((void *)pPacket);
4169
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304170 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171} /* End lim_send_neighbor_report_request_frame. */
4172
4173/**
4174 * \brief Send a Link Report Action frame
4175 *
4176 *
Jeff Johnson99f25042018-11-21 22:49:06 -08004177 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 *
4179 * \param pLinkReport Address of a tSirMacLinkReport
4180 *
4181 * \param peer mac address of peer station.
4182 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004183 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004184 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004185 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 *
4187 *
4188 */
4189
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004190QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004191lim_send_link_report_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 tpSirMacLinkReport pLinkReport,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004193 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304195 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196 tDot11fLinkMeasurementReport frm;
4197 uint8_t *pFrame;
4198 tpSirMacMgmtHdr pMacHdr;
4199 uint32_t nBytes, nPayload, nStatus;
4200 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304201 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202 uint8_t txFlag = 0;
4203 uint8_t smeSessionId = 0;
4204
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004205 if (!pe_session) {
4206 pe_err("(!psession) in Request to send Link Report action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004207 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 }
4209
hangtian127c9532019-01-12 13:29:07 +08004210 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004212 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004213 frm.Action.action = RRM_LINK_MEASUREMENT_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214 frm.DialogToken.token = pLinkReport->dialogToken;
4215
4216 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4217 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4218 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4219 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4220 /* such case this way than changing the frame parser. */
Srinivas Girigowda61771262019-04-01 11:55:19 -07004221 frm.TPCEleID.TPCId = WLAN_ELEMID_TPCREP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 frm.TPCEleLen.TPCLen = 2;
4223 frm.TxPower.txPower = pLinkReport->txPower;
4224 frm.LinkMargin.linkMargin = 0;
4225
4226 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4227 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4228 frm.RCPI.rcpi = pLinkReport->rcpi;
4229 frm.RSNI.rsni = pLinkReport->rsni;
4230
4231 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004232 dot11f_get_packed_link_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004234 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 /* We'll fall back on the worst case scenario: */
4236 nPayload = sizeof(tDot11fLinkMeasurementReport);
4237 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004238 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4239 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240 }
4241
4242 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4243
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304244 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4246 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304247 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004248 pe_err("Failed to allocate %d bytes for a Link "
4249 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004250 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 }
4252 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004253 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254
4255 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004256 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304257 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258
4259 /* Update A3 with the BSSID */
4260 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4261
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004262 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004264 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265
4266 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004267 nStatus = dot11f_pack_link_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 &frm,
4269 pFrame +
4270 sizeof(tSirMacMgmtHdr),
4271 nPayload, &nPayload);
4272
4273 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004274 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004276 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304277 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278 goto returnAfterError;
4279 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004280 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 nStatus);
4282 }
4283
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004284 pe_warn("Sending a Link Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004285 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286
Liangwei Dong419d7302019-07-15 15:38:28 +08004287 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4288 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4289 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004290 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304292 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004293 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004294 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295 pPacket,
4296 (uint16_t) nBytes,
4297 TXRX_FRM_802_11_MGMT,
4298 ANI_TXDIR_TODS,
4299 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004300 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304301 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004302 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304303 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004304 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304305 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304307 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004309 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310
4311returnAfterError:
4312 cds_packet_free((void *)pPacket);
4313
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304314 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315} /* End lim_send_link_report_action_frame. */
4316
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004317QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004318lim_send_radio_measure_report_action_frame(struct mac_context *mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304319 uint8_t dialog_token,
4320 uint8_t num_report,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304321 bool is_last_frame,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304322 tpSirMacRadioMeasureReport pRRMReport,
4323 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004324 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304326 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327 uint8_t *pFrame;
4328 tpSirMacMgmtHdr pMacHdr;
4329 uint32_t nBytes, nPayload, nStatus;
4330 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304331 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004332 uint8_t i;
4333 uint8_t txFlag = 0;
4334 uint8_t smeSessionId = 0;
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304335 bool is_last_report = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336
4337 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304338 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004339 if (!frm)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004340 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004341
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004342 if (!pe_session) {
4343 pe_err("(!psession) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304344 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004345 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004348 smeSessionId = pe_session->smeSessionId;
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004349
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304350 pe_debug("dialog_token %d num_report %d is_last_frame %d",
4351 dialog_token, num_report, is_last_frame);
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304352
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004353 frm->Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004354 frm->Action.action = RRM_RADIO_MEASURE_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004355 frm->DialogToken.token = dialog_token;
4356
4357 frm->num_MeasurementReport =
4358 (num_report >
4359 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4360 num_report;
4361
4362 for (i = 0; i < frm->num_MeasurementReport; i++) {
4363 frm->MeasurementReport[i].type = pRRMReport[i].type;
4364 frm->MeasurementReport[i].token = pRRMReport[i].token;
4365 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4366 switch (pRRMReport[i].type) {
4367 case SIR_MAC_RRM_BEACON_TYPE:
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304368 /*
4369 * Last beacon report indication needs to be set to 1
4370 * only for the last report in the last frame
4371 */
4372 if (is_last_frame &&
4373 (i == (frm->num_MeasurementReport - 1)))
4374 is_last_report = true;
4375
Jeff Johnson99f25042018-11-21 22:49:06 -08004376 populate_dot11f_beacon_report(mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304377 &frm->MeasurementReport[i],
4378 &pRRMReport[i].report.
4379 beaconReport,
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304380 is_last_report);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 frm->MeasurementReport[i].incapable =
4382 pRRMReport[i].incapable;
4383 frm->MeasurementReport[i].refused =
4384 pRRMReport[i].refused;
4385 frm->MeasurementReport[i].present = 1;
4386 break;
4387 default:
4388 frm->MeasurementReport[i].incapable =
4389 pRRMReport[i].incapable;
4390 frm->MeasurementReport[i].refused =
4391 pRRMReport[i].refused;
4392 frm->MeasurementReport[i].present = 1;
4393 break;
4394 }
4395 }
4396
4397 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004398 dot11f_get_packed_radio_measurement_report_size(mac, frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004400 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 nStatus);
4402 /* We'll fall back on the worst case scenario: */
4403 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304404 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004405 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004407 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4408 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 }
4410
4411 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4412
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304413 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4415 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304416 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004417 pe_err("Failed to allocate %d bytes for a Radio Measure "
4418 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304419 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004420 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 }
4422 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004423 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424
4425 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004426 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304427 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428
4429 /* Update A3 with the BSSID */
4430 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4431
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004432 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004434 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435
4436 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004437 nStatus = dot11f_pack_radio_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 frm,
4439 pFrame +
4440 sizeof(tSirMacMgmtHdr),
4441 nPayload, &nPayload);
4442
4443 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004444 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 nStatus);
4446
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004447 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304448 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449 goto returnAfterError;
4450 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004451 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4452 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 }
4454
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004455 pe_warn("Sending a Radio Measure Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004456 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457
Liangwei Dong419d7302019-07-15 15:38:28 +08004458 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4459 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4460 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304463 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004464 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004465 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466 pPacket,
4467 (uint16_t) nBytes,
4468 TXRX_FRM_802_11_MGMT,
4469 ANI_TXDIR_TODS,
4470 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004471 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304472 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004473 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304474 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004475 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304476 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304478 qdf_mem_free(frm);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304479 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304481 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004482 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 }
4484
4485returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304486 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 cds_packet_free((void *)pPacket);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304488 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004489}
4490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491#ifdef WLAN_FEATURE_11W
4492/**
4493 * \brief Send SA query request action frame to peer
4494 *
4495 * \sa lim_send_sa_query_request_frame
4496 *
4497 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004498 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 *
4500 * \param transId Transaction identifier
4501 *
4502 * \param peer The Mac address of the station to which this action frame is addressed
4503 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004504 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004506 * \return QDF_STATUS_SUCCESS if setup completes successfully
4507 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 */
4509
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004510QDF_STATUS lim_send_sa_query_request_frame(struct mac_context *mac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004512 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513{
4514
4515 tDot11fSaQueryReq frm; /* SA query request action frame */
4516 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004517 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 tpSirMacMgmtHdr pMacHdr;
4519 uint32_t nBytes, nPayload, nStatus;
4520 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304521 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 uint8_t txFlag = 0;
4523 uint8_t smeSessionId = 0;
4524
hangtian127c9532019-01-12 13:29:07 +08004525 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004526 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 /* 11w action field is :
4528 action: 0 --> SA Query Request action frame
4529 action: 1 --> SA Query Response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004530 frm.Action.action = SA_QUERY_REQUEST;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304532 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533
Jeff Johnson99f25042018-11-21 22:49:06 -08004534 nStatus = dot11f_get_packed_sa_query_req_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004536 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537 nStatus);
4538 /* We'll fall back on the worst case scenario: */
4539 nPayload = sizeof(tDot11fSaQueryReq);
4540 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004541 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4542 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 }
4544
4545 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304546 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304548 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004549 pe_err("Failed to allocate %d bytes for a SA Query Request "
4550 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004551 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004552 }
4553 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004554 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555
4556 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004557 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304558 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559
4560 /* Update A3 with the BSSID */
4561 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4562
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004563 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004564
4565 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4566 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004567 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568
4569 /* Pack 11w SA Query Request frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004570 nStatus = dot11f_pack_sa_query_req(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 &frm,
4572 pFrame + sizeof(tSirMacMgmtHdr),
4573 nPayload, &nPayload);
4574
4575 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004576 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004578 /* FIXME - Need to convert to QDF_STATUS */
4579 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 goto returnAfterError;
4581 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004582 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 nStatus);
4584 }
4585
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004586 pe_debug("Sending an SA Query Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004587 lim_print_mac_addr(mac, peer, LOGD);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004588 pe_debug("Sending an SA Query Request from ");
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304589 lim_print_mac_addr(mac, pe_session->self_mac_addr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004590
Liangwei Dong419d7302019-07-15 15:38:28 +08004591 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4592 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4593 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304595
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004596 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597
Jeff Johnson99f25042018-11-21 22:49:06 -08004598 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 pPacket,
4600 (uint16_t) nBytes,
4601 TXRX_FRM_802_11_MGMT,
4602 ANI_TXDIR_TODS,
4603 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004604 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304605 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004606 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004607 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 /* Pkt will be freed up by the callback */
4609 return nSirStatus;
4610 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004611 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 }
4613
4614returnAfterError:
4615 cds_packet_free((void *)pPacket);
4616 return nSirStatus;
4617} /* End lim_send_sa_query_request_frame */
4618
4619/**
4620 * \brief Send SA query response action frame to peer
4621 *
4622 * \sa lim_send_sa_query_response_frame
4623 *
4624 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004625 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626 *
4627 * \param transId Transaction identifier received in SA query request action frame
4628 *
4629 * \param peer The Mac address of the AP to which this action frame is addressed
4630 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004631 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004633 * \return QDF_STATUS_SUCCESS if setup completes successfully
4634 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 */
4636
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004637QDF_STATUS lim_send_sa_query_response_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638 uint8_t *transId, tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004639 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640{
4641
Jeff Johnson47d75242018-05-12 15:58:53 -07004642 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004644 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 tpSirMacMgmtHdr pMacHdr;
4646 uint32_t nBytes, nPayload, nStatus;
4647 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304648 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 uint8_t txFlag = 0;
4650 uint8_t smeSessionId = 0;
4651
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004652 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653
hangtian127c9532019-01-12 13:29:07 +08004654 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004655 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 /*11w action field is :
4657 action: 0 --> SA query request action frame
4658 action: 1 --> SA query response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004659 frm.Action.action = SA_QUERY_RESPONSE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 /*11w SA query response transId is same as
4661 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304662 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663
Jeff Johnson99f25042018-11-21 22:49:06 -08004664 nStatus = dot11f_get_packed_sa_query_rsp_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004666 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004667 nStatus);
4668 /* We'll fall back on the worst case scenario: */
4669 nPayload = sizeof(tDot11fSaQueryRsp);
4670 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004671 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4672 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004673 }
4674
4675 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304676 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304678 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004679 pe_err("Failed to allocate %d bytes for a SA query response"
4680 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004681 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682 }
4683 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004684 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004685
4686 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004687 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304688 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004689
4690 /* Update A3 with the BSSID */
4691 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4692
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004693 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694
4695 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4696 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004697 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698
4699 /* Pack 11w SA query response frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004700 nStatus = dot11f_pack_sa_query_rsp(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004701 &frm,
4702 pFrame + sizeof(tSirMacMgmtHdr),
4703 nPayload, &nPayload);
4704
4705 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004706 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004708 /* FIXME - Need to convert to QDF_STATUS */
4709 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710 goto returnAfterError;
4711 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004712 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004713 nStatus);
4714 }
4715
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004716 pe_debug("Sending a SA Query Response to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004717 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718
Liangwei Dong419d7302019-07-15 15:38:28 +08004719 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4720 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4721 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304724 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004725 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004726 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727 pPacket,
4728 (uint16_t) nBytes,
4729 TXRX_FRM_802_11_MGMT,
4730 ANI_TXDIR_TODS,
4731 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004732 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304733 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004734 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304735 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004736 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004737 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004738 /* Pkt will be freed up by the callback */
4739 return nSirStatus;
4740 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004741 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 }
4743
4744returnAfterError:
4745 cds_packet_free((void *)pPacket);
4746 return nSirStatus;
4747} /* End lim_send_sa_query_response_frame */
4748#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004749
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004750#if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390)
4751#ifdef WLAN_FEATURE_11AX
4752#define IS_PE_SESSION_11N_MODE(_session) \
4753 ((_session)->htCapability && !(_session)->vhtCapability && \
4754 !(_session)->he_capable)
4755#else
4756#define IS_PE_SESSION_11N_MODE(_session) \
4757 ((_session)->htCapability && !(_session)->vhtCapability)
4758#endif /* WLAN_FEATURE_11AX */
4759#else
4760#define IS_PE_SESSION_11N_MODE(_session) false
4761#endif
4762
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004763/**
4764 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4765 * @mac_ctx: mac context
4766 * @peer_mac: Peer MAC address
4767 * @tid: TID for which addba response is being sent
4768 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004769 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004770 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004771 *
4772 * This function is called when ADDBA request is successful. ADDBA response is
4773 * setup by calling addba_response_setup API and frame is then sent out OTA.
4774 *
4775 * Return: QDF_STATUS
4776 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004777QDF_STATUS lim_send_addba_response_frame(struct mac_context *mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004778 tSirMacAddr peer_mac, uint16_t tid,
Jeff Johnsona7815652018-11-18 22:58:30 -08004779 struct pe_session *session, uint8_t addba_extn_present,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004780 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004781{
4782
4783 tDot11faddba_rsp frm;
4784 uint8_t *frame_ptr;
4785 tpSirMacMgmtHdr mgmt_hdr;
4786 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004787 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004788 QDF_STATUS qdf_status;
4789 uint8_t tx_flag = 0;
4790 uint8_t sme_sessionid = 0;
4791 uint16_t buff_size, status_code, batimeout;
4792 uint8_t peer_id, dialog_token;
4793 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4794 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004795 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004796
4797 sme_sessionid = session->smeSessionId;
4798
4799 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4800 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004801 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004802 return QDF_STATUS_E_FAILURE;
4803 }
4804
Mohit Khannac4c22252017-11-20 11:06:33 -08004805 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4806 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004807 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004808 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004809 return QDF_STATUS_E_FAILURE;
4810 }
4811
4812 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4813 &status_code, &buff_size, &batimeout);
4814
Mohit Khannac4c22252017-11-20 11:06:33 -08004815 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
hangtian127c9532019-01-12 13:29:07 +08004816 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004817 frm.Category.category = ACTION_CATEGORY_BACK;
Srinivas Girigowdaef0d7142019-05-17 17:07:47 -07004818 frm.Action.action = ADDBA_RESPONSE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004819
4820 frm.DialogToken.token = dialog_token;
4821 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004822 if (mac_ctx->reject_addba_req) {
4823 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4824 pe_err("refused addba req");
4825 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004826 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere22f05d42019-06-28 18:33:43 -07004827 if (lim_is_session_he_capable(session))
4828 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4829 else
4830 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004831 if (mac_ctx->usr_cfg_ba_buff_size)
4832 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07004833
4834 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
4835 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4836
4837 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
4838 if (session->active_ba_64_session) {
4839 frm.addba_param_set.buff_size =
4840 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
4841 }
4842 } else if (!session->active_ba_64_session) {
4843 session->active_ba_64_session = true;
4844 }
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004845
4846 /* disable 11n RX AMSDU */
4847 if (mac_ctx->is_usr_cfg_amsdu_enabled &&
Tushnim Bhattacharyyabb128592019-09-12 11:56:37 -07004848 !IS_PE_SESSION_11N_MODE(session) &&
4849 !WLAN_REG_IS_24GHZ_CH_FREQ(session->curr_op_freq))
Arif Hussain0e246802018-05-01 18:13:44 -07004850 frm.addba_param_set.amsdu_supp = amsdu_support;
4851 else
4852 frm.addba_param_set.amsdu_supp = 0;
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004853
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",
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304870 session->self_mac_addr, 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 }
hangtian127c9532019-01-12 13:29:07 +08004898 qdf_mem_zero(frame_ptr, num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004899
4900 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304901 SIR_MAC_MGMT_ACTION, peer_mac, session->self_mac_addr);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004902
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
Liangwei Dong419d7302019-07-15 15:38:28 +08004927 if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
4928 session->opmode == QDF_P2P_CLIENT_MODE ||
4929 session->opmode == QDF_P2P_GO_MODE)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004930 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004931
4932 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4933 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07004934 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
4935 (uint16_t)num_bytes,
4936 TXRX_FRM_802_11_MGMT,
4937 ANI_TXDIR_TODS, 7,
4938 NULL, frame_ptr,
4939 lim_addba_rsp_tx_complete_cnf,
4940 tx_flag, sme_sessionid,
4941 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004942 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4943 session->peSessionId, qdf_status));
4944 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004945 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004946 qdf_status);
chenguo90c68462019-01-24 18:27:01 +08004947 return QDF_STATUS_E_FAILURE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004948 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004949 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004950 }
4951
4952error_addba_rsp:
4953 cds_packet_free((void *)pkt_ptr);
4954 return qdf_status;
4955}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304956
4957/**
4958 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4959 * @mac_ctx Pointer to Global MAC structure
4960 * @mb_msg: Received message info
4961 * @msg_len: Received message length
4962 * @packet: Packet to be transmitted
4963 * @frame: Received frame
4964 *
4965 * Return: None
4966 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004967static void lim_tx_mgmt_frame(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304968 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
4969 void *packet, uint8_t *frame)
4970{
4971 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4972 QDF_STATUS qdf_status;
Abhishek Singhefe21e62019-09-20 10:03:24 +05304973 uint8_t vdev_id = 0;
Jeff Johnsona7815652018-11-18 22:58:30 -08004974 struct pe_session *session;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304975 uint16_t auth_ack_status;
4976 enum rateid min_rid = RATEID_DEFAULT;
4977
Abhishek Singhefe21e62019-09-20 10:03:24 +05304978 vdev_id = mb_msg->session_id;
4979 session = pe_find_session_by_vdev_id(mac_ctx, vdev_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004980 if (!session) {
Wu Gao7c0a23f2019-03-12 14:16:37 +08004981 cds_packet_free((void *)packet);
Abhishek Singhefe21e62019-09-20 10:03:24 +05304982 pe_err("session not found for given vdev_id %d",
4983 vdev_id);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304984 return;
4985 }
4986
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05304987 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
4988 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304989
4990 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
4991 min_rid = lim_get_min_session_txrate(session);
4992
4993 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4994 (uint16_t)msg_len,
4995 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4996 7, lim_tx_complete, frame,
4997 lim_auth_tx_complete_cnf,
Abhishek Singhefe21e62019-09-20 10:03:24 +05304998 0, vdev_id, false, 0, min_rid);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304999 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5000 session->peSessionId, qdf_status));
5001 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05305002 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
5003 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305004 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
5005 auth_ack_status = SENT_FAIL;
5006 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005007 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305008 /* Pkt will be freed up by the callback */
5009 }
5010}
5011
Jeff Johnson9320c1e2018-12-02 13:09:20 -08005012void lim_send_mgmt_frame_tx(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305013 struct scheduler_msg *msg)
5014{
5015 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
5016 uint32_t msg_len;
5017 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5018 uint8_t sme_session_id;
5019 QDF_STATUS qdf_status;
5020 uint8_t *frame;
5021 void *packet;
Srinivas Dasari76218492019-01-22 15:08:20 +05305022 tpSirMacMgmtHdr mac_hdr;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305023
5024 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
5025 pe_debug("sending fc->type: %d fc->subType: %d",
5026 fc->type, fc->subType);
5027
5028 sme_session_id = mb_msg->session_id;
Srinivas Dasari76218492019-01-22 15:08:20 +05305029 mac_hdr = (tpSirMacMgmtHdr)mb_msg->data;
5030
5031 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305032
5033 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
5034 (void **)&packet);
5035 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5036 pe_err("call to bufAlloc failed for AUTH frame");
5037 return;
5038 }
5039
5040 qdf_mem_copy(frame, mb_msg->data, msg_len);
5041
5042 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5043}