blob: e4c7fed03fc1d5cb564d49661f9439a6f46bf798 [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;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530185 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 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;
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800193 uint32_t chan_freq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194
Arif Hussain4c265132018-04-23 18:55:26 -0700195 if (additional_ielen)
196 addn_ielen = *additional_ielen;
197
Jeff Johnson919f2c32019-01-16 11:22:24 -0800198 /*
199 * The probe req should not send 11ac capabilities if band is
200 * 2.4GHz, unless gEnableVhtFor24GHzBand is enabled in INI. So
201 * if gEnableVhtFor24GHzBand is false and dot11mode is 11ac
202 * set it to 11n.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 */
204 if (channel <= SIR_11B_CHANNEL_END &&
Abhinav Kumare057b412018-10-09 17:28:16 +0530205 !mac_ctx->mlme_cfg->vht_caps.vht_cap_info.b24ghz_band &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530206 (MLME_DOT11_MODE_11AC == dot11mode ||
207 MLME_DOT11_MODE_11AC_ONLY == dot11mode))
208 dot11mode = MLME_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 /*
210 * session context may or may not be present, when probe request needs
211 * to be sent out. Following cases exist:
212 * --heartbeat failure: session needed
213 * --join req: session needed
214 * --foreground scan: no session
215 * --background scan: no session
216 * --sch_beacon_processing: to get EDCA parameters: session needed
217 * If session context does not exist, some IEs will be populated from
218 * CFGs, e.g. Supported and Extended rate set IEs
219 */
220 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
221
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700222 if (pesession)
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530223 vdev_id = pesession->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224
225 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
226 /* and then hand it off to 'dot11f_pack_probe_request' (for */
227 /* serialization). We start by zero-initializing the structure: */
hangtian127c9532019-01-12 13:29:07 +0800228 qdf_mem_zero((uint8_t *) &pr, sizeof(pr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229
230 /* & delegating to assorted helpers: */
231 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
232
233 if (addn_ielen && additional_ie)
234 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
235
236 /*
237 * Don't include 11b rate if it is a P2P serach or probe request is
238 * sent by P2P Client
239 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700240 if ((MLME_DOT11_MODE_11B != dot11mode) && (p2pie) &&
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530241 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 /*
243 * In the below API pass channel number > 14, do that it fills
244 * only 11a rates in supported rates
245 */
246 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
247 pesession);
248 } else {
249 populate_dot11f_supp_rates(mac_ctx, channel,
250 &pr.SuppRates, pesession);
251
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530252 if (MLME_DOT11_MODE_11B != dot11mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
254 &pr.ExtSuppRates);
255 }
256 }
257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 /*
259 * Table 7-14 in IEEE Std. 802.11k-2008 says
260 * DS params "can" be present in RRM is disabled and "is" present if
261 * RRM is enabled. It should be ok even if we add it into probe req when
262 * RRM is not enabled.
263 */
264 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
265 /* Call RRM module to get the tx power for management used. */
266 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
267 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
268
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700270 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800271 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
272 /* Include HT Capability IE */
273 if (pesession->htCapability)
274 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700275 } else { /* !pesession */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276 if (IS_DOT11_MODE_HT(dot11mode))
277 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
278 }
279
280 /*
281 * Set channelbonding information as "disabled" when tunned to a
282 * 2.4 GHz channel
283 */
284 if (channel <= SIR_11B_CHANNEL_END) {
285 if (mac_ctx->roam.configParam.channelBondingMode24GHz
286 == PHY_SINGLE_CHANNEL_CENTERED) {
287 pr.HTCaps.supportedChannelWidthSet =
288 eHT_CHANNEL_WIDTH_20MHZ;
289 pr.HTCaps.shortGI40MHz = 0;
290 } else {
291 pr.HTCaps.supportedChannelWidthSet =
292 eHT_CHANNEL_WIDTH_40MHZ;
293 }
294 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700295 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
297 /* Include VHT Capability IE */
298 if (pesession->vhtCapability) {
299 populate_dot11f_vht_caps(mac_ctx, pesession,
300 &pr.VHTCaps);
301 is_vht_enabled = true;
302 }
303 } else {
304 if (IS_DOT11_MODE_VHT(dot11mode)) {
305 populate_dot11f_vht_caps(mac_ctx, pesession,
306 &pr.VHTCaps);
307 is_vht_enabled = true;
308 }
309 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700310 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
312 pesession);
313
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700314 if (IS_DOT11_MODE_HE(dot11mode) && pesession)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800315 lim_update_session_he_capable(mac_ctx, pesession);
316
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700317 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700318 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -0700319 populate_dot11f_he_6ghz_cap(mac_ctx, pesession,
320 &pr.he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800321
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700322 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530323 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
324 sizeof(tDot11fIEExtCap));
325 sir_status = lim_strip_extcap_update_struct(mac_ctx,
326 additional_ie,
327 &addn_ielen,
328 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700329 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700330 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530331 } else {
332 struct s_ext_cap *p_ext_cap =
333 (struct s_ext_cap *)
334 extracted_ext_cap.bytes;
335 if (p_ext_cap->interworking_service)
336 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800337 extracted_ext_cap.num_bytes =
338 lim_compute_ext_cap_ie_length
339 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530340 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800341 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700342 if (additional_ielen)
343 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530344 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530345 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
346 SIR_MAC_QCN_OUI_TYPE_SIZE,
347 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530349 /* Add qcn_ie only if qcn ie is not present in additional_ie */
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -0700350 if (!qcn_ie)
351 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie, QCN_IE_ATTR_ID_ALL);
352 else
353 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie,
354 QCN_IE_ATTR_ID_VHT_MCS11);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355
Hu Wang411e0cc2016-10-28 14:56:01 +0800356 /*
357 * Extcap IE now support variable length, merge Extcap IE from addn_ie
358 * may change the frame size. Therefore, MUST merge ExtCap IE before
359 * dot11f get packed payload size.
360 */
361 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800362 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800363
364 /* That's it-- now we pack it. First, how much space are we going to */
365 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
366 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700367 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800368 status);
369 /* We'll fall back on the worst case scenario: */
370 payload = sizeof(tDot11fProbeRequest);
371 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700372 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800373 status);
374 }
375
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
377
378 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530379 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530381 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700382 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700383 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 }
385 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800386 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387
388 /* Next, we fill out the buffer descriptor: */
389 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
390 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
391
392 /* That done, pack the Probe Request: */
393 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
394 sizeof(tSirMacMgmtHdr),
395 payload, &payload);
396 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700397 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700399 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700401 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 }
403 /* Append any AddIE if present. */
404 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530405 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406 additional_ie, addn_ielen);
407 payload += addn_ielen;
408 }
409
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800410 chan_freq = wlan_reg_chan_to_freq(mac_ctx->pdev, channel);
411
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412 /* If this probe request is sent during P2P Search State, then we need
413 * to send it at OFDM rate.
414 */
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800415 if ((REG_BAND_5G == lim_get_rf_band(chan_freq)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 /*
417 * For unicast probe req mgmt from Join function we don't set
418 * above variables. So we need to add one more check whether it
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530419 * is opmode is P2P_CLIENT or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530421 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530424 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 wma_tx_frame(mac_ctx, packet,
426 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
427 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530428 lim_tx_complete, frame, txflag, vdev_id,
Naveen Rawat296a5182017-09-25 14:02:48 -0700429 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530430 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700431 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700433 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 }
435
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700436 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437} /* End lim_send_probe_req_mgmt_frame. */
438
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800439static QDF_STATUS lim_get_addn_ie_for_probe_resp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 uint8_t *addIE, uint16_t *addnIELen,
441 uint8_t probeReqP2pIe)
442{
443 /* If Probe request doesn't have P2P IE, then take out P2P IE
444 from additional IE */
445 if (!probeReqP2pIe) {
446 uint8_t *tempbuf = NULL;
447 uint16_t tempLen = 0;
448 int left = *addnIELen;
449 uint8_t *ptr = addIE;
450 uint8_t elem_id, elem_len;
451
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700452 if (!addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700453 pe_err("NULL addIE pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700454 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455 }
456
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530457 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700458 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700459 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460
461 while (left >= 2) {
462 elem_id = ptr[0];
463 elem_len = ptr[1];
464 left -= 2;
465 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700466 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530468 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700469 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 }
Srinivas Girigowda61771262019-04-01 11:55:19 -0700471 if (!((WLAN_ELEMID_VENDOR == elem_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 (memcmp
473 (&ptr[2], SIR_MAC_P2P_OUI,
474 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530475 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 elem_len + 2);
477 tempLen += (elem_len + 2);
478 }
479 left -= elem_len;
480 ptr += (elem_len + 2);
481 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530482 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530484 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700486 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487}
488
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800490lim_send_probe_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800491 tSirMacAddr peer_macaddr,
492 tpAniSSID ssid,
Jeff Johnson3c08ace2019-03-12 08:50:37 -0700493 struct pe_session *pe_session,
494 uint8_t preq_p2pie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495{
496 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700497 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800498 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800499 tpSirMacMgmtHdr mac_hdr;
500 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700501 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530502 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 uint32_t addn_ie_present = false;
504
505 uint16_t addn_ie_len = 0;
gaurank kathpalia837f6202018-09-14 21:55:32 +0530506 bool wps_ap = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 uint8_t tx_flag = 0;
508 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700509 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 uint8_t noalen = 0;
511 uint8_t total_noalen = 0;
512 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
513 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530514 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530516 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530517 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800518
519 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700520 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 return;
522
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700523 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800524 return;
525
526 /*
527 * In case when cac timer is running for this SAP session then
528 * avoid sending probe rsp out. It is violation of dfs specification.
529 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530530 if (((pe_session->opmode == QDF_SAP_MODE) ||
531 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800532 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530533 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800534 FL("CAC timer is running, probe response dropped"));
535 return;
536 }
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530537 vdev_id = pe_session->vdev_id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530538 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700539 if (!frm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800540 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800541
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800542 /*
543 * Fill out 'frm', after which we'll just hand the struct off to
544 * 'dot11f_pack_probe_response'.
545 */
hangtian127c9532019-01-12 13:29:07 +0800546 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547
548 /*
549 * Timestamp to be updated by TFP, below.
550 *
551 * Beacon Interval:
552 */
553 if (LIM_IS_AP_ROLE(pe_session)) {
554 frm->BeaconInterval.interval =
Jeff Johnsonac057412019-01-06 11:08:55 -0800555 mac_ctx->sch.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530557 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 frm->BeaconInterval.interval = (uint16_t) cfg;
559 }
560
561 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
562 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
563 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
564 &frm->SuppRates, pe_session);
565
Liangwei Dong419d7302019-07-15 15:38:28 +0800566 populate_dot11f_ds_params(
567 mac_ctx, &frm->DSParams,
568 wlan_reg_freq_to_chan(mac_ctx->pdev,
569 pe_session->curr_op_freq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
571
572 if (LIM_IS_AP_ROLE(pe_session)) {
573 if (pe_session->wps_state != SAP_WPS_DISABLED)
574 populate_dot11f_probe_res_wpsi_es(mac_ctx,
575 &frm->WscProbeRes,
576 pe_session);
577 } else {
gaurank kathpalia837f6202018-09-14 21:55:32 +0530578 wps_ap = mac_ctx->mlme_cfg->wps_params.enable_wps &
579 WNI_CFG_WPS_ENABLE_AP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 if (wps_ap)
581 populate_dot11f_wsc_in_probe_res(mac_ctx,
582 &frm->WscProbeRes);
583
584 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
585 eLIM_WSC_ENROLL_BEGIN) {
586 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
587 &frm->WscProbeRes);
588 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
589 eLIM_WSC_ENROLL_IN_PROGRESS;
590 }
591
592 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
593 eLIM_WSC_ENROLL_END) {
594 de_populate_dot11f_wsc_registrar_info_in_probe_res(
595 mac_ctx, &frm->WscProbeRes);
596 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
597 eLIM_WSC_ENROLL_NOOP;
598 }
599 }
600
601 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
602 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
603
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530604 if (pe_session->dot11mode != MLME_DOT11_MODE_11B)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800605 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
606
607 populate_dot11f_ext_supp_rates(mac_ctx,
608 POPULATE_DOT11F_RATES_OPERATIONAL,
609 &frm->ExtSuppRates, pe_session);
610
611 /* Populate HT IEs, when operating in 11n */
612 if (pe_session->htCapability) {
613 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
614 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
615 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700617 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
619 populate_dot11f_vht_operation(mac_ctx, pe_session,
620 &frm->VHTOperation);
621 /*
622 * we do not support multi users yet.
623 * populate_dot11f_vht_ext_bss_load( mac_ctx,
624 * &frm.VHTExtBssLoad );
625 */
626 is_vht_enabled = true;
627 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800628
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800629 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700630 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800631 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700632 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800633 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700634 &frm->he_op);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -0700635 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
636 &frm->he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800637 }
638
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
640 pe_session);
641
642 if (pe_session->pLimStartBssReq) {
643 populate_dot11f_wpa(mac_ctx,
644 &(pe_session->pLimStartBssReq->rsnIE),
645 &frm->WPA);
646 populate_dot11f_rsn_opaque(mac_ctx,
647 &(pe_session->pLimStartBssReq->rsnIE),
648 &frm->RSNOpaque);
649 }
650
651 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
652 &frm->WMMCaps, pe_session);
653
654#if defined(FEATURE_WLAN_WAPI)
655 if (pe_session->pLimStartBssReq)
656 populate_dot11f_wapi(mac_ctx,
657 &(pe_session->pLimStartBssReq->rsnIE),
658 &frm->WAPI);
659#endif /* defined(FEATURE_WLAN_WAPI) */
660
Liangwei Dongd7c5e012018-12-16 23:56:50 -0500661 /*
662 * Only use CFG for non-listen mode. This CFG is not working for
663 * concurrency. In listening mode, probe rsp IEs is passed in
664 * the message from SME to PE.
665 */
666 addn_ie_present =
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800667 (pe_session->add_ie_params.probeRespDataLen != 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668
669 if (addn_ie_present) {
670
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530671 add_ie = qdf_mem_malloc(
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800672 pe_session->add_ie_params.probeRespDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700673 if (!add_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 goto err_ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530676 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800677 pe_session->add_ie_params.probeRespData_buff,
678 pe_session->add_ie_params.probeRespDataLen);
679 addn_ie_len = pe_session->add_ie_params.probeRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700681 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700683 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 goto err_ret;
685 }
686
687 sir_status = lim_strip_extcap_update_struct(mac_ctx,
688 add_ie, &addn_ie_len,
689 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700690 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700691 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530692 } else {
693 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800694 }
695
696 bytes = bytes + addn_ie_len;
697
698 if (preq_p2pie)
699 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
700 addn_ie_len);
701
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700702 if (p2p_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800703 /* get NoA attribute stream P2P IE */
704 noalen = lim_get_noa_attr_stream(mac_ctx,
705 noa_stream, pe_session);
706 if (noalen != 0) {
707 total_noalen =
708 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
709 &noa_stream[0], noalen);
710 bytes = bytes + total_noalen;
711 }
712 }
713 }
714
Hu Wang411e0cc2016-10-28 14:56:01 +0800715 /*
716 * Extcap IE now support variable length, merge Extcap IE from addn_ie
717 * may change the frame size. Therefore, MUST merge ExtCap IE before
718 * dot11f get packed payload size.
719 */
720 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800721 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
722 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800723
724 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
725 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700726 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800727 status);
728 /* We'll fall back on the worst case scenario: */
729 payload = sizeof(tDot11fProbeResponse);
730 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700731 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800732 status);
733 }
734
735 bytes += payload + sizeof(tSirMacMgmtHdr);
736
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530737 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530739 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700740 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 goto err_ret;
742 }
743 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800744 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745
746 /* Next, we fill out the buffer descriptor: */
747 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
748 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530749 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750
751 mac_hdr = (tpSirMacMgmtHdr) frame;
752
753 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
754
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 /* That done, pack the Probe Response: */
756 status =
757 dot11f_pack_probe_response(mac_ctx, frm,
758 frame + sizeof(tSirMacMgmtHdr),
759 payload, &payload);
760 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700761 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 status);
763 goto err_ret;
764 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700765 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 }
767
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700768 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530769 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530772 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773 &add_ie[0], addn_ie_len);
774
775 if (noalen != 0) {
776 if (total_noalen >
777 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700778 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 total_noalen);
780 goto err_ret;
781 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530782 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783 &noa_ie[0], total_noalen);
784 }
785 }
786
Liangwei Dong419d7302019-07-15 15:38:28 +0800787 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
788 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
789 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
791
792 /* Queue Probe Response frame in high priority WQ */
Jeff Johnson59429b02018-11-07 13:53:18 -0800793 qdf_status = wma_tx_frame(mac_ctx, packet,
794 (uint16_t)bytes,
795 TXRX_FRM_802_11_MGMT,
796 ANI_TXDIR_TODS,
797 7, lim_tx_complete, frame, tx_flag,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530798 vdev_id, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799
800 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530801 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700802 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700804 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530805 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 return;
809
810err_ret:
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700811 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530812 qdf_mem_free(add_ie);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700813 if (frm)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530814 qdf_mem_free(frm);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700815 if (packet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 cds_packet_free((void *)packet);
817 return;
818
819} /* End lim_send_probe_rsp_mgmt_frame. */
820
821void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800822lim_send_addts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 tSirMacAddr peerMacAddr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800824 tSirAddtsReqInfo *pAddTS, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825{
826 uint16_t i;
827 uint8_t *pFrame;
828 tDot11fAddTSRequest AddTSReq;
829 tDot11fWMMAddTSRequest WMMAddTSReq;
830 uint32_t nPayload, nBytes, nStatus;
831 tpSirMacMgmtHdr pMacHdr;
832 void *pPacket;
833#ifdef FEATURE_WLAN_ESE
834 uint32_t phyMode;
835#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530836 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 uint8_t txFlag = 0;
838 uint8_t smeSessionId = 0;
839
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700840 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 return;
842 }
843
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800844 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845
846 if (!pAddTS->wmeTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +0800847 qdf_mem_zero((uint8_t *) &AddTSReq, sizeof(AddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700849 AddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850 AddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700851 AddTSReq.Category.category = ACTION_CATEGORY_QOS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 if (pAddTS->lleTspecPresent) {
853 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
854 } else {
855 populate_dot11f_wmmtspec(&pAddTS->tspec,
856 &AddTSReq.WMMTSPEC);
857 }
858
859 if (pAddTS->lleTspecPresent) {
860 AddTSReq.num_WMMTCLAS = 0;
861 AddTSReq.num_TCLAS = pAddTS->numTclas;
862 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800863 populate_dot11f_tclas(mac, &pAddTS->tclasInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 &AddTSReq.TCLAS[i]);
865 }
866 } else {
867 AddTSReq.num_TCLAS = 0;
868 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
869 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800870 populate_dot11f_wmmtclas(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 &pAddTS->tclasInfo[i],
872 &AddTSReq.WMMTCLAS[i]);
873 }
874 }
875
876 if (pAddTS->tclasProcPresent) {
877 if (pAddTS->lleTspecPresent) {
878 AddTSReq.TCLASSPROC.processing =
879 pAddTS->tclasProc;
880 AddTSReq.TCLASSPROC.present = 1;
881 } else {
882 AddTSReq.WMMTCLASPROC.version = 1;
883 AddTSReq.WMMTCLASPROC.processing =
884 pAddTS->tclasProc;
885 AddTSReq.WMMTCLASPROC.present = 1;
886 }
887 }
888
889 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800890 dot11f_get_packed_add_ts_request_size(mac, &AddTSReq, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700892 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
893 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800894 /* We'll fall back on the worst case scenario: */
895 nPayload = sizeof(tDot11fAddTSRequest);
896 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700897 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
898 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 }
900 } else {
hangtian127c9532019-01-12 13:29:07 +0800901 qdf_mem_zero((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700903 WMMAddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700905 WMMAddTSReq.Category.category = ACTION_CATEGORY_WMM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906
907 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
908 WMMAddTSReq.StatusCode.statusCode = 0;
909
910 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
911#ifdef FEATURE_WLAN_ESE
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800912 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913
914 if (phyMode == WNI_CFG_PHY_MODE_11G
915 || phyMode == WNI_CFG_PHY_MODE_11A) {
916 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
917 } else {
918 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
919 }
Jeff Johnson99f25042018-11-21 22:49:06 -0800920 populate_dot11_tsrsie(mac, &pAddTS->tsrsIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 &WMMAddTSReq.ESETrafStrmRateSet,
922 sizeof(uint8_t));
923#endif
924 /* fillWmeTspecIE */
925
926 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800927 dot11f_get_packed_wmm_add_ts_request_size(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928 &nPayload);
929 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700930 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931 nStatus);
932 /* We'll fall back on the worst case scenario: */
933 nPayload = sizeof(tDot11fAddTSRequest);
934 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700935 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
936 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937 }
938 }
939
940 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
941
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530942 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530944 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700945 pe_err("Failed to allocate %d bytes for an Add TS Request",
946 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947 return;
948 }
949 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800950 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
952 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -0800953 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530954 SIR_MAC_MGMT_ACTION, peerMacAddr, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 pMacHdr = (tpSirMacMgmtHdr) pFrame;
956
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800957 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800959 lim_set_protected_bit(mac, pe_session, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960
961 /* That done, pack the struct: */
962 if (!pAddTS->wmeTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800963 nStatus = dot11f_pack_add_ts_request(mac, &AddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 pFrame +
965 sizeof(tSirMacMgmtHdr),
966 nPayload, &nPayload);
967 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700968 pe_err("Failed to pack an Add TS Request "
969 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 cds_packet_free((void *)pPacket);
971 return; /* allocated! */
972 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700973 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
974 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 }
976 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -0800977 nStatus = dot11f_pack_wmm_add_ts_request(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 pFrame +
979 sizeof(tSirMacMgmtHdr),
980 nPayload, &nPayload);
981 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700982 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
983 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984 cds_packet_free((void *)pPacket);
985 return; /* allocated! */
986 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700987 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
988 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 }
990 }
991
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700992 pe_debug("Sending an Add TS Request frame to");
Jeff Johnson99f25042018-11-21 22:49:06 -0800993 lim_print_mac_addr(mac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994
Liangwei Dong419d7302019-07-15 15:38:28 +0800995 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
996 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
997 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301000 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001001 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001002 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001003 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001004 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005
1006 /* Queue Addts Response frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08001007 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 TXRX_FRM_802_11_MGMT,
1009 ANI_TXDIR_TODS,
1010 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001011 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301012 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001013 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001015 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1016 pe_err("Could not send an Add TS Request (%X",
1017 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018} /* End lim_send_addts_req_action_frame. */
1019
1020/**
bings85512332019-09-04 17:46:37 +08001021 * lim_assoc_rsp_tx_complete() - Confirmation for assoc rsp OTA
1022 * @context: pointer to global mac
1023 * @buf: buffer which is nothing but entire assoc rsp frame
1024 * @tx_complete : Sent status
1025 * @params; tx completion params
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 *
bings85512332019-09-04 17:46:37 +08001027 * Return: This returns QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 */
bings85512332019-09-04 17:46:37 +08001029static QDF_STATUS lim_assoc_rsp_tx_complete(
1030 void *context,
1031 qdf_nbuf_t buf,
1032 uint32_t tx_complete,
1033 void *params)
1034{
1035 struct mac_context *mac_ctx = (struct mac_context *)context;
1036 tSirMacMgmtHdr *mac_hdr;
1037 struct pe_session *session_entry;
1038 uint8_t session_id;
1039 tpLimMlmAssocInd lim_assoc_ind;
1040 tpDphHashNode sta_ds;
1041 uint16_t aid;
1042 uint8_t *data;
1043 struct assoc_ind *sme_assoc_ind;
1044 struct scheduler_msg msg;
1045 tpSirAssocReq assoc_req;
1046
1047 if (!buf) {
1048 pe_err("Assoc rsp frame buffer is NULL");
1049 goto null_buf;
1050 }
1051
1052 data = qdf_nbuf_data(buf);
1053
1054 if (!data) {
1055 pe_err("Assoc rsp frame is NULL");
1056 goto end;
1057 }
1058
1059 mac_hdr = (tSirMacMgmtHdr *)data;
1060
1061 session_entry = pe_find_session_by_bssid(
1062 mac_ctx, mac_hdr->sa,
1063 &session_id);
1064 if (!session_entry) {
1065 pe_err("session entry is NULL");
1066 goto end;
1067 }
1068
1069 sta_ds = dph_lookup_hash_entry(mac_ctx,
1070 (uint8_t *)mac_hdr->da, &aid,
1071 &session_entry->dph.dphHashTable);
1072 if (!sta_ds) {
1073 pe_err("sta_ds is NULL");
1074 goto end;
1075 }
1076
1077 /* Get a copy of the already parsed Assoc Request */
1078 assoc_req =
1079 (tpSirAssocReq)session_entry->parsedAssocReq[sta_ds->assocId];
1080
1081 if (!assoc_req) {
1082 pe_err("assoc req for assoc_id:%d is NULL", sta_ds->assocId);
1083 goto end;
1084 }
1085
1086 lim_assoc_ind = qdf_mem_malloc(sizeof(tLimMlmAssocInd));
1087 if (!lim_assoc_ind) {
1088 pe_err("lim assoc ind is NULL");
1089 goto free_assoc_req;
1090 }
1091 if (!lim_fill_lim_assoc_ind_params(lim_assoc_ind, mac_ctx,
1092 sta_ds, session_entry)) {
1093 pe_err("lim assoc ind fill error");
1094 goto lim_assoc_ind;
1095 }
1096
1097 sme_assoc_ind = qdf_mem_malloc(sizeof(struct assoc_ind));
1098 if (!sme_assoc_ind) {
1099 pe_err("sme assoc ind is NULL");
1100 goto lim_assoc_ind;
1101 }
1102 sme_assoc_ind->messageType = eWNI_SME_ASSOC_IND_UPPER_LAYER;
1103 lim_fill_sme_assoc_ind_params(
1104 mac_ctx, lim_assoc_ind,
1105 sme_assoc_ind,
Chaoli Zhou98d1b3e2019-10-10 17:13:44 +08001106 session_entry, true);
bings85512332019-09-04 17:46:37 +08001107
1108 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
1109 msg.type = eWNI_SME_ASSOC_IND_UPPER_LAYER;
1110 msg.bodyptr = sme_assoc_ind;
1111 msg.bodyval = 0;
bings85512332019-09-04 17:46:37 +08001112 sme_assoc_ind->reassocReq = sta_ds->mlmStaContext.subType;
1113 sme_assoc_ind->timingMeasCap = sta_ds->timingMeasCap;
Chaoli Zhou98d1b3e2019-10-10 17:13:44 +08001114 MTRACE(mac_trace_msg_tx(mac_ctx, session_entry->peSessionId, msg.type));
1115 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
bings85512332019-09-04 17:46:37 +08001116
1117 qdf_mem_free(lim_assoc_ind);
1118 if (assoc_req->assocReqFrame) {
1119 qdf_mem_free(assoc_req->assocReqFrame);
1120 assoc_req->assocReqFrame = NULL;
1121 }
1122 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
1123 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
1124 qdf_nbuf_free(buf);
1125
1126 return QDF_STATUS_SUCCESS;
1127
1128lim_assoc_ind:
1129 qdf_mem_free(lim_assoc_ind);
1130free_assoc_req:
1131 if (assoc_req->assocReqFrame) {
1132 qdf_mem_free(assoc_req->assocReqFrame);
1133 assoc_req->assocReqFrame = NULL;
1134 }
1135 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
1136 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
1137end:
1138 qdf_nbuf_free(buf);
1139null_buf:
1140 return QDF_STATUS_E_FAILURE;
1141}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142
1143void
bings85512332019-09-04 17:46:37 +08001144lim_send_assoc_rsp_mgmt_frame(
1145 struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
bings85512332019-09-04 17:46:37 +08001147 uint8_t subtype, tpDphHashNode sta, struct pe_session *pe_session,
1148 bool tx_complete)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149{
1150 static tDot11fAssocResponse frm;
1151 uint8_t *frame;
1152 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001153 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 uint8_t lle_mode = 0, addts;
1155 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001156 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301158 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001159 tUpdateBeaconParams beacon_params;
1160 uint8_t tx_flag = 0;
1161 uint32_t addn_ie_len = 0;
1162 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1163 tpSirAssocReq assoc_req = NULL;
1164 uint8_t sme_session = 0;
1165 bool is_vht = false;
1166 uint16_t stripoff_len = 0;
1167 tDot11fIEExtCap extracted_ext_cap;
1168 bool extracted_flag = false;
1169#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301170 uint8_t retry_int;
1171 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172#endif
1173
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001174 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001175 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176 return;
1177 }
1178
1179 sme_session = pe_session->smeSessionId;
1180
hangtian127c9532019-01-12 13:29:07 +08001181 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182
1183 limGetQosMode(pe_session, &qos_mode);
1184 limGetWmeMode(pe_session, &wme_mode);
1185
1186 /*
1187 * An Add TS IE is added only if the AP supports it and
1188 * the requesting STA sent a traffic spec.
1189 */
1190 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1191
1192 frm.Status.status = status_code;
1193
1194 frm.AID.associd = aid | LIM_AID_MASK;
1195
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001196 if (!sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 populate_dot11f_supp_rates(mac_ctx,
1198 POPULATE_DOT11F_RATES_OPERATIONAL,
1199 &frm.SuppRates, pe_session);
1200 populate_dot11f_ext_supp_rates(mac_ctx,
1201 POPULATE_DOT11F_RATES_OPERATIONAL,
1202 &frm.ExtSuppRates, pe_session);
1203 } else {
1204 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1205 &frm.ExtSuppRates,
1206 sta->supportedRates.llbRates,
1207 sta->supportedRates.llaRates);
1208 }
1209
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001210 if (LIM_IS_AP_ROLE(pe_session) && sta &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001211 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 assoc_req = (tpSirAssocReq)
1213 pe_session->parsedAssocReq[sta->assocId];
1214 /*
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05301215 * populate P2P IE in AssocRsp when assoc_req from the peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 * includes P2P IE
1217 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001218 if (assoc_req && assoc_req->addIEPresent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1220 &frm.P2PAssocRes,
1221 assoc_req);
1222 }
1223
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001224 if (sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 if (eHAL_SET == qos_mode) {
1226 if (sta->lleEnabled) {
1227 lle_mode = 1;
1228 populate_dot11f_edca_param_set(mac_ctx,
1229 &frm.EDCAParamSet, pe_session);
1230 }
1231 }
1232
1233 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1234 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1235 pe_session);
1236
1237 if (sta->wsmEnabled)
1238 populate_dot11f_wmm_caps(&frm.WMMCaps);
1239 }
1240
1241 if (sta->mlmStaContext.htCapability &&
1242 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001243 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 populate_dot11f_ht_caps(mac_ctx, pe_session,
1245 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001246 /*
1247 * Check the STA capability and
1248 * update the HTCaps accordingly
1249 */
1250 frm.HTCaps.supportedChannelWidthSet = (
1251 sta->htSupportedChannelWidthSet <
1252 pe_session->htSupportedChannelWidthSet) ?
1253 sta->htSupportedChannelWidthSet :
1254 pe_session->htSupportedChannelWidthSet;
1255 if (!frm.HTCaps.supportedChannelWidthSet)
1256 frm.HTCaps.shortGI40MHz = 0;
1257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301259 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001261 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 +05301262 frm.HTCaps.supportedChannelWidthSet,
1263 frm.HTCaps.mimoPowerSave,
1264 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1265 frm.HTCaps.shortGI40MHz,
1266 frm.HTCaps.dsssCckMode40MHz,
1267 frm.HTCaps.maxRxAMPDUFactor);
1268
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 if (sta->mlmStaContext.vhtCapability &&
1270 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001271 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272 populate_dot11f_vht_caps(mac_ctx, pe_session,
1273 &frm.VHTCaps);
1274 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301275 &frm.VHTOperation);
1276 is_vht = true;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301277 } else if (sta->mlmStaContext.force_1x1 &&
1278 frm.HTCaps.present) {
1279 /*
1280 * WAR: In P2P GO mode, if the P2P client device
1281 * is only HT capable and not VHT capable, but the P2P
1282 * GO device is VHT capable and advertises 2x2 NSS with
1283 * HT capablity client device, which results in IOT
1284 * issues.
1285 * When GO is operating in DBS mode, GO beacons
1286 * advertise 2x2 capability but include OMN IE to
1287 * indicate current operating mode of 1x1. But here
1288 * peer device is only HT capable and will not
1289 * understand OMN IE.
1290 */
1291 frm.HTInfo.basicMCSSet[1] = 0;
1292 frm.HTCaps.supportedMCSSet[1] = 0;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301293 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001294
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301295 if (pe_session->vhtCapability &&
1296 pe_session->vendor_vht_sap &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001297 (assoc_req) &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301298 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001299 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301300 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001301 frm.vendor_vht_ie.sub_type =
1302 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301303 frm.vendor_vht_ie.VHTCaps.present = 1;
1304 populate_dot11f_vht_caps(mac_ctx, pe_session,
1305 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001306 populate_dot11f_vht_operation(mac_ctx, pe_session,
1307 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 is_vht = true;
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07001309 populate_dot11f_qcn_ie(mac_ctx, &frm.qcn_ie,
1310 QCN_IE_ATTR_ID_ALL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1313 pe_session);
1314
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001315 if (lim_is_sta_he_capable(sta) &&
1316 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001317 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001318 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001319 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001320 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001321 &frm.he_op);
Kiran Kumar Lokereb2ea0272019-08-27 19:16:36 -07001322 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
1323 &frm.he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001324 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325#ifdef WLAN_FEATURE_11W
1326 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301327 max_retries =
1328 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1329 retry_int =
1330 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1331 populate_dot11f_timeout_interval(mac_ctx,
1332 &frm.TimeoutInterval,
1333 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1334 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 sta->pmfSaQueryRetryCount)
1336 * retry_int);
1337 }
1338#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001339
1340 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1341 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 }
1343
hangtian127c9532019-01-12 13:29:07 +08001344 qdf_mem_zero((uint8_t *) &beacon_params, sizeof(beacon_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345
1346 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301347 (pe_session->gLimProtectionControl !=
1348 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1349 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1350 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351
1352 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1353 pe_session);
1354 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1355 pe_session);
1356
1357 /*
1358 * Populate Do11capabilities after updating session with
1359 * Assos req details
1360 */
1361 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1362
Abhishek Singhc70afa32019-09-19 15:17:21 +05301363 beacon_params.bss_idx = pe_session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364
1365 /* Send message to HAL about beacon parameter change. */
1366 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1367 && beacon_params.paramChangeBitmap) {
1368 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1369 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1370 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371
Arif Hussain1513cb22018-01-05 19:56:31 -08001372 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1373
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001374 if (assoc_req) {
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001375 addn_ie_len = pe_session->add_ie_params.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376
1377 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001378 if (addn_ie_len > 0 &&
1379 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1380 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301381 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001382 pe_session->add_ie_params.assocRespData_buff,
1383 pe_session->add_ie_params.assocRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384
hangtian127c9532019-01-12 13:29:07 +08001385 qdf_mem_zero((uint8_t *) &extracted_ext_cap,
1386 sizeof(extracted_ext_cap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387
1388 stripoff_len = addn_ie_len;
1389 sir_status =
1390 lim_strip_extcap_update_struct
1391 (mac_ctx, &add_ie[0], &stripoff_len,
1392 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001393 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001394 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395 } else {
1396 addn_ie_len = stripoff_len;
1397 extracted_flag = true;
1398 }
1399 bytes = bytes + addn_ie_len;
1400 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001401 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 addn_ie_len, assoc_req->addIEPresent);
1403 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001404
1405 /*
1406 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1407 * may change the frame size. Therefore, MUST merge ExtCap IE before
1408 * dot11f get packed payload size.
1409 */
1410 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001411 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1412 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001413
1414 /* Allocate a buffer for this frame: */
1415 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1416 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001417 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001418 status);
1419 return;
1420 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001421 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001422 status);
1423 }
1424
1425 bytes += sizeof(tSirMacMgmtHdr) + payload;
1426
Min Liu0daa0982019-02-01 17:50:44 +08001427 if (sta)
1428 bytes += sta->mlmStaContext.owe_ie_len;
1429
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301430 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301432 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001433 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 return;
1435 }
1436 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001437 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438
1439 /* Next, we fill out the buffer descriptor: */
1440 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1441 (LIM_ASSOC == subtype) ?
1442 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1443 peer_addr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301444 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 mac_hdr = (tpSirMacMgmtHdr) frame;
1446
1447 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1448
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1450 frame + sizeof(tSirMacMgmtHdr),
1451 payload, &payload);
1452 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001453 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454 status);
1455 cds_packet_free((void *)packet);
1456 return;
1457 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001458 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 status);
1460 }
1461
1462 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001463 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 status_code, aid);
1465 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001466 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 status_code, aid);
1468
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301469 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470
1471 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301472 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 &add_ie[0], addn_ie_len);
1474
Min Liu0daa0982019-02-01 17:50:44 +08001475 if (sta && sta->mlmStaContext.owe_ie_len)
1476 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload
1477 + addn_ie_len,
1478 sta->mlmStaContext.owe_ie,
1479 sta->mlmStaContext.owe_ie_len);
1480
Liangwei Dong419d7302019-07-15 15:38:28 +08001481 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1482 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1483 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001484 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1485
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301486 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001488 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001489 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001490 /* Queue Association Response frame in high priority WQ */
bings85512332019-09-04 17:46:37 +08001491 if (tx_complete)
1492 qdf_status = wma_tx_frameWithTxComplete(
1493 mac_ctx, packet, (uint16_t)bytes,
1494 TXRX_FRM_802_11_MGMT,
1495 ANI_TXDIR_TODS,
1496 7, lim_tx_complete, frame,
1497 lim_assoc_rsp_tx_complete, tx_flag,
1498 sme_session, false, 0, RATEID_DEFAULT);
1499 else
1500 qdf_status = wma_tx_frame(
1501 mac_ctx, packet, (uint16_t)bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 TXRX_FRM_802_11_MGMT,
1503 ANI_TXDIR_TODS,
1504 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001505 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301506 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301507 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508
1509 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301510 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001511 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301512 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513
1514 /*
1515 * update the ANI peer station count.
1516 * FIXME_PROTECTION : take care of different type of station
1517 * counter inside this function.
1518 */
1519 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1520
1521}
1522
1523void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001524lim_send_delts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 tSirMacAddr peer,
1526 uint8_t wmmTspecPresent,
Jeff Johnson312348f2018-12-22 13:33:54 -08001527 struct mac_ts_info *pTsinfo,
Jeff Johnson56471b92018-12-22 14:36:06 -08001528 struct mac_tspec_ie *pTspecIe,
Jeff Johnson312348f2018-12-22 13:33:54 -08001529 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530{
1531 uint8_t *pFrame;
1532 tpSirMacMgmtHdr pMacHdr;
1533 tDot11fDelTS DelTS;
1534 tDot11fWMMDelTS WMMDelTS;
1535 uint32_t nBytes, nPayload, nStatus;
1536 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301537 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 uint8_t txFlag = 0;
1539 uint8_t smeSessionId = 0;
1540
Jeff Johnson312348f2018-12-22 13:33:54 -08001541 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001544 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545
1546 if (!wmmTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +08001547 qdf_mem_zero((uint8_t *) &DelTS, sizeof(DelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001549 DelTS.Category.category = ACTION_CATEGORY_QOS;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001550 DelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1552
Jeff Johnson99f25042018-11-21 22:49:06 -08001553 nStatus = dot11f_get_packed_del_ts_size(mac, &DelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001555 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)",
1556 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 /* We'll fall back on the worst case scenario: */
1558 nPayload = sizeof(tDot11fDelTS);
1559 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001560 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1561 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 }
1563 } else {
hangtian127c9532019-01-12 13:29:07 +08001564 qdf_mem_zero((uint8_t *) &WMMDelTS, sizeof(WMMDelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001566 WMMDelTS.Category.category = ACTION_CATEGORY_WMM;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001567 WMMDelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 WMMDelTS.DialogToken.token = 0;
1569 WMMDelTS.StatusCode.statusCode = 0;
1570 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1571 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08001572 dot11f_get_packed_wmm_del_ts_size(mac, &WMMDelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001574 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)",
1575 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 /* We'll fall back on the worst case scenario: */
1577 nPayload = sizeof(tDot11fDelTS);
1578 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001579 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1580 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 }
1582 }
1583
1584 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1585
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301586 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1588 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301589 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001590 pe_err("Failed to allocate %d bytes for an Add TS Response",
1591 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 return;
1593 }
1594 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001595 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596
1597 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08001598 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301599 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1601
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001602 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001604 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605
1606 /* That done, pack the struct: */
1607 if (!wmmTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -08001608 nStatus = dot11f_pack_del_ts(mac, &DelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609 pFrame + sizeof(tSirMacMgmtHdr),
1610 nPayload, &nPayload);
1611 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001612 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 nStatus);
1614 cds_packet_free((void *)pPacket);
1615 return; /* allocated! */
1616 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001617 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1618 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619 }
1620 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -08001621 nStatus = dot11f_pack_wmm_del_ts(mac, &WMMDelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 pFrame + sizeof(tSirMacMgmtHdr),
1623 nPayload, &nPayload);
1624 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001625 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 nStatus);
1627 cds_packet_free((void *)pPacket);
1628 return; /* allocated! */
1629 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001630 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1631 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 }
1633 }
1634
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001635 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
Jeff Johnson99f25042018-11-21 22:49:06 -08001636 lim_print_mac_addr(mac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637
Liangwei Dong419d7302019-07-15 15:38:28 +08001638 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1639 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1640 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301643 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001644 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001645 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001646 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001647 QDF_STATUS_SUCCESS);
Jeff Johnson99f25042018-11-21 22:49:06 -08001648 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 TXRX_FRM_802_11_MGMT,
1650 ANI_TXDIR_TODS,
1651 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001652 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301653 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001654 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301656 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001657 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001658
1659} /* End lim_send_delts_req_action_frame. */
1660
1661/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301662 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1663 * @context: pointer to global mac
1664 * @buf: buffer
1665 * @tx_complete : Sent status
1666 * @params; tx completion params
1667 *
1668 * Return: This returns QDF_STATUS
1669 */
1670
1671static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1672 qdf_nbuf_t buf,
1673 uint32_t tx_complete,
1674 void *params)
1675{
1676 uint16_t assoc_ack_status;
1677 uint16_t reason_code;
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001678 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301679
1680 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001681 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301682 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001683 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301684 } else {
1685 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001686 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301687 }
1688 if (buf)
1689 qdf_nbuf_free(buf);
1690
1691 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1692 NULL, assoc_ack_status, reason_code);
1693 return QDF_STATUS_SUCCESS;
1694}
1695
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301696#ifdef WLAN_ADAPTIVE_11R
1697/**
1698 * lim_fill_adaptive_11r_ie() - Populate the Vendor secific adaptive 11r
1699 * IE to association request frame
1700 * @pe_session: pointer to PE session
1701 * @ie_buf: buffer to which Adaptive 11r IE will be copied
1702 * @ie_len: length of the Adaptive 11r Vendor specific IE
1703 *
1704 * Return QDF_STATUS
1705 */
1706static QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1707 uint8_t **ie_buf, uint8_t *ie_len)
1708{
1709 uint8_t *buf = NULL, *adaptive_11r_ie = NULL;
1710
1711 if (!pe_session->is_adaptive_11r_connection)
1712 return QDF_STATUS_SUCCESS;
1713
1714 /*
1715 * Vendor specific Adaptive 11r IE to be advertised in Assoc
1716 * req:
1717 * Type 0xDD
1718 * Length 0x0B
1719 * OUI 0x00 0x00 0x0F
1720 * Type 0x22
1721 * subtype 0x00
1722 * Version 0x01
1723 * Length 0x04
1724 * Data 0x00 00 00 01(0th bit is 1 means adaptive 11r is
1725 * supported)
1726 */
1727 adaptive_11r_ie = qdf_mem_malloc(ADAPTIVE_11R_STA_IE_LEN + 2);
1728 if (!adaptive_11r_ie)
1729 return QDF_STATUS_E_FAILURE;
1730
1731 /* Fill the Vendor IE Type (0xDD) */
1732 buf = adaptive_11r_ie;
Srinivas Girigowda8e7ecab2019-05-16 11:31:19 -07001733 *buf = WLAN_ELEMID_VENDOR;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301734 buf++;
1735
1736 /* Fill the Vendor IE length (0x0B) */
1737 *buf = ADAPTIVE_11R_STA_IE_LEN;
1738 buf++;
1739
1740 /*
1741 * Fill the Adaptive 11r Vendor specific OUI(0x00 0x00 0x0F 0x22)
1742 */
1743 qdf_mem_copy(buf, ADAPTIVE_11R_STA_OUI, ADAPTIVE_11R_OUI_LEN);
1744 buf += ADAPTIVE_11R_OUI_LEN;
1745
1746 /* Fill Adaptive 11r Vendor specific Subtype (0x00) */
1747 *buf = ADAPTIVE_11R_OUI_SUBTYPE;
1748 buf++;
1749
1750 /* Fill Adaptive 11r Version (0x01) */
1751 *buf = ADAPTIVE_11R_OUI_VERSION;
1752 buf++;
1753
1754 /* Fill Adaptive 11r IE Data length (0x04) */
1755 *buf = ADAPTIVE_11R_DATA_LEN;
1756 buf++;
1757
1758 /* Fill Adaptive 11r IE Data (0x00 0x00 0x00 0x01) */
1759 qdf_mem_copy(buf, ADAPTIVE_11R_OUI_DATA, ADAPTIVE_11R_DATA_LEN);
1760
1761 *ie_len = ADAPTIVE_11R_STA_IE_LEN + 2;
1762 *ie_buf = adaptive_11r_ie;
1763
1764 return QDF_STATUS_SUCCESS;
1765}
1766
1767#else
1768static inline
1769QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1770 uint8_t **ie_buf, uint8_t *ie_len)
1771{
1772 return QDF_STATUS_SUCCESS;
1773}
1774#endif
1775
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301776/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 * lim_send_assoc_req_mgmt_frame() - Send association request
1778 * @mac_ctx: Handle to MAC context
1779 * @mlm_assoc_req: Association request information
1780 * @pe_session: PE session information
1781 *
1782 * Builds and transmits association request frame to AP.
1783 *
1784 * Return: Void
1785 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001787lim_send_assoc_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 tLimMlmAssocReq *mlm_assoc_req,
Jeff Johnsona7815652018-11-18 22:58:30 -08001789 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790{
Naveen Rawat72475db2017-12-13 18:07:35 -08001791 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 tDot11fAssocRequest *frm;
1793 uint16_t caps;
1794 uint8_t *frame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001795 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001797 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1799 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301800 QDF_STATUS qdf_status;
Srinivas Dasari22397902019-07-29 21:34:10 +05301801 uint16_t add_ie_len, current_len = 0, vendor_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001803 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 uint8_t tx_flag = 0;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05301806 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 bool vht_enabled = false;
1808 tDot11fIEExtCap extr_ext_cap;
1809 bool extr_ext_flag = true;
1810 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001811 uint32_t ie_offset = 0;
1812 uint8_t *p_ext_cap = NULL;
1813 tDot11fIEExtCap bcn_ext_cap;
1814 uint8_t *bcn_ie = NULL;
1815 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301816 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001817 enum rateid min_rid = RATEID_DEFAULT;
Srinivas Dasari22397902019-07-29 21:34:10 +05301818 uint8_t *mbo_ie = NULL, *adaptive_11r_ie = NULL, *vendor_ies = NULL;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301819 uint8_t mbo_ie_len = 0, adaptive_11r_ie_len = 0;
Srinivas Dasari603d4972019-09-20 17:28:44 +05301820 struct wlan_objmgr_peer *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001822 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001823 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301824 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825 return;
1826 }
1827
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05301828 vdev_id = pe_session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
1830 /* check this early to avoid unncessary operation */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301831 if (!pe_session->lim_join_req) {
1832 pe_err("pe_session->lim_join_req is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301833 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 return;
1835 }
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301836 add_ie_len = pe_session->lim_join_req->addIEAssoc.length;
1837 add_ie = pe_session->lim_join_req->addIEAssoc.addIEdata;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301839 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001840 if (!frm) {
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301841 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 return;
1843 }
hangtian127c9532019-01-12 13:29:07 +08001844 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301846 if (add_ie_len && pe_session->is_ext_caps_present) {
hangtian127c9532019-01-12 13:29:07 +08001847 qdf_mem_zero((uint8_t *) &extr_ext_cap,
1848 sizeof(tDot11fIEExtCap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1850 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001851 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001853 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 } else {
1855 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1856 extr_ext_cap.bytes;
1857
1858 if (p_ext_cap->interworking_service)
1859 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001860 extr_ext_cap.num_bytes =
1861 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1862 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863 }
1864 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001865 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 extr_ext_flag = false;
1867 }
1868
1869 caps = mlm_assoc_req->capabilityInfo;
1870#if defined(FEATURE_WLAN_WAPI)
1871 /*
1872 * According to WAPI standard:
1873 * 7.3.1.4 Capability Information field
1874 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1875 * in transmitted Association or Reassociation management frames.
1876 * APs ignore the Privacy subfield within received Association and
1877 * Reassociation management frames.
1878 */
1879 if (pe_session->encryptType == eSIR_ED_WPI)
1880 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1881#endif
1882 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1883
1884 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1885 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1886 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1887 &frm->SuppRates, pe_session);
1888
1889 qos_enabled = (pe_session->limQosEnabled) &&
1890 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1891
1892 wme_enabled = (pe_session->limWmeEnabled) &&
1893 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1894
1895 /* We prefer .11e asociations: */
1896 if (qos_enabled)
1897 wme_enabled = false;
1898
1899 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1900 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1901
1902 if (pe_session->lim11hEnable &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301903 pe_session->lim_join_req->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904 power_caps = true;
1905
1906 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1907 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1909 LIM_ASSOC, pe_session);
1910
1911 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1913 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1914 if (power_caps == false) {
1915 power_caps = true;
1916 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1917 LIM_ASSOC, pe_session);
1918 }
1919 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001921 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1922 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923
1924 populate_dot11f_ext_supp_rates(mac_ctx,
1925 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1926 pe_session);
1927
Gupta, Kapil54a16992016-01-13 19:34:02 +05301928 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1929 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1931 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 /*
1934 * The join request *should* contain zero or one of the WPA and RSN
1935 * IEs. The payload send along with the request is a
Jeff Johnson701444f2019-02-02 22:35:13 -08001936 * 'struct join_req'; the IE portion is held inside a 'tSirRSNie':
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 * typedef struct sSirRSNie
1938 * {
1939 * uint16_t length;
Srinivas Girigowdacf161402019-03-14 11:37:33 -07001940 * uint8_t rsnIEdata[WLAN_MAX_IE_LEN+2];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941 * } tSirRSNie, *tpSirRSNie;
1942 * So, we should be able to make the following two calls harmlessly,
1943 * since they do nothing if they don't find the given IE in the
1944 * bytestream with which they're provided.
1945 * The net effect of this will be to faithfully transmit whatever
1946 * security IE is in the join request.
1947 * However, if we're associating for the purpose of WPS
1948 * enrollment, and we've been configured to indicate that by
1949 * eliding the WPA or RSN IE, we just skip this:
1950 */
1951 if (add_ie_len && add_ie)
1952 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1953
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001954 if (!wps_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955 populate_dot11f_rsn_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301956 &pe_session->lim_join_req->rsnIE,
1957 &frm->RSNOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 populate_dot11f_wpa_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301959 &pe_session->lim_join_req->rsnIE,
1960 &frm->WPAOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961#if defined(FEATURE_WLAN_WAPI)
1962 populate_dot11f_wapi_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301963 &(pe_session->lim_join_req->rsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 &frm->WAPIOpaque);
1965#endif /* defined(FEATURE_WLAN_WAPI) */
1966 }
1967 /* include WME EDCA IE as well */
1968 if (wme_enabled) {
1969 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1970 pe_session, &frm->WMMInfoStation);
1971
1972 if (wsm_enabled)
1973 populate_dot11f_wmm_caps(&frm->WMMCaps);
1974 }
1975
1976 /*
1977 * Populate HT IEs, when operating in 11n and
1978 * when AP is also operating in 11n mode
1979 */
1980 if (pe_session->htCapability &&
1981 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001982 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001984 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1985 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001986 } else if (pe_session->he_with_wep_tkip) {
1987 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1988 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001990 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 +05301991 frm->HTCaps.supportedChannelWidthSet,
1992 frm->HTCaps.mimoPowerSave,
1993 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1994 frm->HTCaps.shortGI40MHz,
1995 frm->HTCaps.dsssCckMode40MHz,
1996 frm->HTCaps.maxRxAMPDUFactor);
1997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 if (pe_session->vhtCapability &&
1999 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002000 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07002002 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
2003 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07002005 if (pe_session->enableHtSmps &&
2006 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002007 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07002008 populate_dot11f_operating_mode(mac_ctx,
2009 &frm->OperatingMode, pe_session);
2010 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002011 } else if (pe_session->he_with_wep_tkip) {
2012 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
2013 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002015
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016 if (!vht_enabled &&
2017 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002018 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302019 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07002020 frm->vendor_vht_ie.sub_type =
2021 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302022 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05302023 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05302024 pe_session->vht_config.su_beam_formee) {
2025 pe_debug("Disable SU beamformee for vendor IE");
2026 pe_session->vht_config.su_beam_formee = 0;
2027 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302029 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 vht_enabled = true;
2031 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05302032 if (pe_session->is_ext_caps_present)
2033 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
2034 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07002036 populate_dot11f_qcn_ie(mac_ctx, &frm->qcn_ie, QCN_IE_ATTR_ID_ALL);
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05302037
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002038 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07002039 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002040 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07002041 &frm->he_cap);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -07002042 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
2043 &frm->he_6ghz_band_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002044 } else if (pe_session->he_with_wep_tkip) {
2045 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
2046 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -07002047 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
2048 &frm->he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002049 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05302050
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302051 if (pe_session->lim_join_req->is11Rconnection) {
Pragaspathi Thilagaraj1112c962019-05-23 23:45:38 +05302052 struct bss_description *bssdescr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302054 bssdescr = &pe_session->lim_join_req->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002055 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 (unsigned int) bssdescr->mdie[0],
2057 (unsigned int) bssdescr->mdie[1],
2058 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059 populate_mdie(mac_ctx, &frm->MobilityDomain,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302060 pe_session->lim_join_req->bssDescription.mdie);
Pragaspathi Thilagaraj03839b92019-03-12 17:45:21 +05302061
2062 /*
2063 * IEEE80211-ai [13.2.4 FT initial mobility domain association
2064 * over FILS in an RSN]
2065 * Populate FT IE in association request. This FT IE should be
2066 * same as the FT IE received in auth response frame during the
2067 * FT-FILS authentication.
2068 */
2069 if (lim_is_fils_connection(pe_session))
2070 populate_fils_ft_info(mac_ctx, &frm->FTInfo,
2071 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073
2074#ifdef FEATURE_WLAN_ESE
2075 /*
2076 * ESE Version IE will be included in association request
2077 * when ESE is enabled on DUT through ini and it is also
2078 * advertised by the peer AP to which we are trying to
2079 * associate to.
2080 */
2081 if (pe_session->is_ese_version_ie_present &&
Wu Gao51a63562018-11-08 16:29:10 +08002082 mac_ctx->mlme_cfg->lfr.ese_enabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 populate_dot11f_ese_version(&frm->ESEVersion);
2084 /* For ESE Associations fill the ESE IEs */
2085 if (pe_session->isESEconnection &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302086 pe_session->lim_join_req->isESEFeatureIniEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087#ifndef FEATURE_DISABLE_RM
2088 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
2089#endif
2090 }
2091#endif
2092
Hu Wang411e0cc2016-10-28 14:56:01 +08002093 /*
2094 * Extcap IE now support variable length, merge Extcap IE from addn_ie
2095 * may change the frame size. Therefore, MUST merge ExtCap IE before
2096 * dot11f get packed payload size.
2097 */
2098 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08002099 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
2100
2101 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
2102 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
2103 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
2104 DOT11F_FF_BEACONINTERVAL_LEN +
2105 DOT11F_FF_CAPABILITIES_LEN;
2106
2107 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
2108 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
2109 bcn_ie = pe_session->beacon + ie_offset;
2110 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07002111 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08002112 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07002113 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08002114 lim_update_extcap_struct(mac_ctx, p_ext_cap,
2115 &bcn_ext_cap);
2116 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
2117 false);
2118 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07002119 /*
2120 * TWT extended capabilities should be populated after the
2121 * intersection of beacon caps and self caps is done because
2122 * the bits for TWT are unique to STA and AP and cannot be
2123 * intersected.
2124 */
2125 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
2126 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08002127 }
Hu Wang411e0cc2016-10-28 14:56:01 +08002128
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002129 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08002130 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002131 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08002132
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302133 if (lim_is_fils_connection(pe_session)) {
2134 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
2135 aes_block_size_len = AES_BLOCK_SIZE;
2136 }
2137
2138 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302139 * MBO IE needs to be appendded at the end of the assoc request
2140 * frame and is not parsed and unpacked by the frame parser
2141 * as the supplicant can send multiple TLVs with same Attribute
2142 * in the MBO IE and the frame parser does not support multiple
2143 * TLVs with same attribute in a single IE.
2144 * Strip off the MBO IE from add_ie and append it at the end.
2145 */
2146 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
2147 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
2148 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002149 if (!mbo_ie)
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302150 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302151
2152 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
Srinivas Girigowda61771262019-04-01 11:55:19 -07002153 WLAN_ELEMID_VENDOR, ONE_BYTE,
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302154 SIR_MAC_MBO_OUI,
2155 SIR_MAC_MBO_OUI_SIZE,
2156 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
2157 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2158 pe_err("Failed to strip MBO IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302159 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302160 }
2161
2162 /* Include the EID and length fields */
2163 mbo_ie_len = mbo_ie[1] + 2;
2164 pe_debug("Stripped MBO IE of length %d", mbo_ie_len);
Srinivas Dasari603d4972019-09-20 17:28:44 +05302165
2166 peer = wlan_objmgr_get_peer_by_mac(mac_ctx->psoc,
2167 mlm_assoc_req->peerMacAddr,
2168 WLAN_MBO_ID);
2169 if (peer && !mlme_get_peer_pmf_status(peer)) {
2170 pe_debug("Peer doesn't support PMF, Don't add MBO IE");
2171 qdf_mem_free(mbo_ie);
2172 mbo_ie = NULL;
2173 mbo_ie_len = 0;
2174 }
2175 if (peer)
2176 wlan_objmgr_peer_release_ref(peer, WLAN_MBO_ID);
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302177 }
2178
Srinivas Dasari22397902019-07-29 21:34:10 +05302179 /*
2180 * Strip rest of the vendor IEs and append to the assoc request frame.
2181 * Append the IEs just before MBO IEs as MBO IEs have to be at the
2182 * end of the frame.
2183 */
2184 if (wlan_get_ie_ptr_from_eid(WLAN_ELEMID_VENDOR, add_ie, add_ie_len)) {
2185 vendor_ies = qdf_mem_malloc(MAX_VENDOR_IES_LEN + 2);
2186 if (vendor_ies) {
2187 current_len = add_ie_len;
2188 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
2189 WLAN_ELEMID_VENDOR, ONE_BYTE,
2190 NULL,
2191 0,
2192 vendor_ies,
2193 MAX_VENDOR_IES_LEN);
2194 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2195 pe_err("Failed to strip Vendor IEs");
2196 goto end;
2197 }
2198
2199 vendor_ie_len = current_len - add_ie_len;
2200 pe_debug("Stripped vendor IEs of size: %u",
2201 current_len);
2202 }
2203 }
2204
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302205 qdf_status = lim_fill_adaptive_11r_ie(pe_session, &adaptive_11r_ie,
2206 &adaptive_11r_ie_len);
2207 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2208 pe_err("Failed to fill adaptive 11r IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302209 goto end;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302210 }
2211
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302212 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302213 * Do unpack to populate the add_ie buffer to frm structure
2214 * before packing the frm structure. In this way, the IE ordering
2215 * which the latest 802.11 spec mandates is maintained.
2216 */
Naveen Rawat72475db2017-12-13 18:07:35 -08002217 if (add_ie_len) {
2218 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302219 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08002220 if (DOT11F_FAILED(ret)) {
2221 pe_err("unpack failed, ret: 0x%x", ret);
2222 goto end;
2223 }
2224 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302225
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
2227 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002228 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 status);
2230 /* We'll fall back on the worst case scenario: */
2231 payload = sizeof(tDot11fAssocRequest);
2232 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002233 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234 status);
2235 }
2236
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302237 bytes = payload + sizeof(tSirMacMgmtHdr) +
Srinivas Dasari22397902019-07-29 21:34:10 +05302238 aes_block_size_len + mbo_ie_len + adaptive_11r_ie_len +
2239 vendor_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302241 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302243 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002244 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245
2246 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302247 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248 pe_session->peSessionId,
2249 pe_session->limMlmState));
2250
2251 /* Update PE session id */
2252 assoc_cnf.sessionId = pe_session->peSessionId;
2253
2254 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2255
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2257 (uint32_t *) &assoc_cnf);
2258
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302259 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260 }
2261 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08002262 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263
2264 /* Next, we fill out the buffer descriptor: */
2265 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2266 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302267 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002268 /* That done, pack the Assoc Request: */
2269 status = dot11f_pack_assoc_request(mac_ctx, frm,
2270 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2271 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002272 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302274 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002276 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 }
2278
Srinivas Dasari22397902019-07-29 21:34:10 +05302279 /* Copy the vendor IEs to the end of the frame */
2280 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2281 vendor_ies, vendor_ie_len);
2282 payload = payload + vendor_ie_len;
2283
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302284 /* Copy the MBO IE to the end of the frame */
2285 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2286 mbo_ie, mbo_ie_len);
2287 payload = payload + mbo_ie_len;
2288
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302289 /*
2290 * Copy the Vendor specific Adaptive 11r IE to end of the
2291 * assoc request frame
2292 */
2293 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2294 adaptive_11r_ie, adaptive_11r_ie_len);
2295 payload = payload + adaptive_11r_ie_len;
2296
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05302297 if (pe_session->assoc_req) {
2298 qdf_mem_free(pe_session->assoc_req);
2299 pe_session->assoc_req = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002300 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 }
2302
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302303 if (lim_is_fils_connection(pe_session)) {
2304 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2305 frame, &payload);
2306 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2307 cds_packet_free((void *)packet);
Srinivas Dasari22397902019-07-29 21:34:10 +05302308 goto end;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302309 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 }
2311
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05302312 pe_session->assoc_req = qdf_mem_malloc(payload);
2313 if (pe_session->assoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 /*
2315 * Store the Assoc request. This is sent to csr/hdd in
2316 * join cnf response.
2317 */
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05302318 qdf_mem_copy(pe_session->assoc_req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 frame + sizeof(tSirMacMgmtHdr), payload);
2320 pe_session->assocReqLen = payload;
2321 }
2322
Liangwei Dong419d7302019-07-15 15:38:28 +08002323 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
2324 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2325 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2327
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302328 if (pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2329 pe_session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302333 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302335
2336 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002337 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002338 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002339 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002340 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002341 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302342 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302343 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2345 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302346 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302347 tx_flag, vdev_id, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302348 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302349 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302350 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002351
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302352 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002353 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302354 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302355 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002356 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302359
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302360end:
Srinivas Dasari22397902019-07-29 21:34:10 +05302361 qdf_mem_free(vendor_ies);
2362 qdf_mem_free(mbo_ie);
2363
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364 /* Free up buffer allocated for mlm_assoc_req */
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302365 qdf_mem_free(adaptive_11r_ie);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302366 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302368 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369 return;
2370}
2371
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002373 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2374 * @context: pointer to global mac
2375 * @buf: buffer which is nothing but entire ADD BA frame
2376 * @tx_complete : Sent status
2377 * @params; tx completion params
2378 *
2379 * Return: This returns QDF_STATUS
2380 */
2381static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2382 qdf_nbuf_t buf,
2383 uint32_t tx_complete,
2384 void *params)
2385{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002386 struct mac_context *mac_ctx = (struct mac_context *)context;
Krunal Sonid2136c72018-06-01 17:26:39 -07002387 tSirMacMgmtHdr *mac_hdr;
2388 tDot11faddba_rsp rsp;
2389 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2390 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
2391 uint8_t peer_id;
2392 void *peer;
2393 uint32_t frame_len;
2394 QDF_STATUS status;
2395 uint8_t *data;
2396
2397 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2398 pe_debug("Add ba response successfully sent");
2399 else
2400 pe_debug("Fail to send add ba response");
2401
2402 if (!buf) {
2403 pe_err("Addba response frame buffer is NULL");
2404 return QDF_STATUS_E_FAILURE;
2405 }
2406
2407 data = qdf_nbuf_data(buf);
2408
2409 if (!data) {
2410 pe_err("Addba response frame is NULL");
2411 return QDF_STATUS_E_FAILURE;
2412 }
2413
2414 mac_hdr = (tSirMacMgmtHdr *)data;
2415 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2416 frame_len = sizeof(rsp);
2417 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2418 sizeof(*mac_hdr), frame_len,
2419 &rsp, false);
2420
2421 if (DOT11F_FAILED(status)) {
2422 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2423 status, frame_len);
2424 goto error;
2425 }
2426
2427 peer = cdp_peer_get_ref_by_addr(soc, pdev, mac_hdr->da, &peer_id,
2428 PEER_DEBUG_ID_WMA_ADDBA_REQ);
2429 if (!peer) {
2430 pe_debug("no PEER found for mac_addr:%pM", mac_hdr->da);
2431 goto error;
2432 }
2433 cdp_addba_resp_tx_completion(soc, peer, rsp.addba_param_set.tid,
2434 tx_complete);
2435 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_WMA_ADDBA_REQ);
2436error:
2437 if (buf)
2438 qdf_nbuf_free(buf);
2439
2440 return QDF_STATUS_SUCCESS;
2441}
2442
2443/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302444 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302445 * @context: pointer to global mac
2446 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302447 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302448 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302449 *
2450 * Return: This returns QDF_STATUS
2451 */
2452
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302453static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2454 qdf_nbuf_t buf,
2455 uint32_t tx_complete,
2456 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302457{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002458 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302459 uint16_t auth_ack_status;
2460 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302461
Naveen Rawat684e8b12017-09-20 15:54:44 -07002462 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002463 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2464 "success" : "fail");
2465 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302466 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302467 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002468 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302469 /* 'Change' timer for future activations */
2470 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2471 } else {
2472 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302473 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002474 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302475 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302476
2477 if (buf)
2478 qdf_nbuf_free(buf);
2479
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302480 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2481 NULL, auth_ack_status, reason_code);
2482
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302483 return QDF_STATUS_SUCCESS;
2484}
2485
2486/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2488 *
2489 * @mac_ctx: Pointer to Global MAC structure
2490 * @auth_frame: Pointer to Authentication frame structure
2491 * @peer_addr: MAC address of destination peer
2492 * @wep_bit: wep bit in frame control for Authentication frame3
2493 * @session: PE session information
2494 *
2495 * This function is called by lim_process_mlm_messages(). Authentication frame
2496 * is formatted and sent when this function is called.
2497 *
2498 * Return: void
2499 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002501lim_send_auth_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502 tpSirMacAuthFrameBody auth_frame,
2503 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302504 uint8_t wep_challenge_len,
Jeff Johnsona7815652018-11-18 22:58:30 -08002505 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506{
2507 uint8_t *frame, *body;
2508 uint32_t frame_len = 0, body_len = 0;
2509 tpSirMacMgmtHdr mac_hdr;
2510 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302511 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 uint8_t tx_flag = 0;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302513 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002515 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002516 enum rateid min_rid = RATEID_DEFAULT;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302517 uint16_t ch_freq_tx_frame = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002519 if (!session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002520 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 return;
2522 }
2523
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302524 vdev_id = session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302526 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002527 /*
2528 * Auth frame3 to be sent with encrypted framebody
2529 *
2530 * Allocate buffer for Authenticaton frame of size
2531 * equal to management frame header length plus 2 bytes
2532 * each for auth algorithm number, transaction number,
2533 * status code, 128 bytes for challenge text and
2534 * 4 bytes each for IV & ICV.
2535 */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002536 pe_debug("Sending encrypted auth frame to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002537 QDF_MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002538
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302539 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002540 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002541
2542 goto alloc_packet;
2543 }
2544
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002545 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002546 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547 auth_frame->authTransactionSeqNumber,
2548 auth_frame->authStatusCode,
2549 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002550 QDF_MAC_ADDR_ARRAY(peer_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551
2552 switch (auth_frame->authTransactionSeqNumber) {
2553 case SIR_MAC_AUTH_FRAME_1:
2554 /*
2555 * Allocate buffer for Authenticaton frame of size
2556 * equal to management frame header length plus 2 bytes
2557 * each for auth algorithm number, transaction number
2558 * and status code.
2559 */
2560
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002561 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2562 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302564 frame_len += lim_create_fils_auth_data(mac_ctx,
2565 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002566 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002567 if (session->ftPEContext.pFTPreAuthReq &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568 0 != session->ftPEContext.pFTPreAuthReq->
2569 ft_ies_length) {
2570 ft_ies_length = session->ftPEContext.
2571 pFTPreAuthReq->ft_ies_length;
2572 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002573 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 ft_ies_length);
2575 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002576 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 frame_len += (2 + SIR_MDIE_SIZE);
2578 }
2579 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302580
2581 /* include MDIE in FILS authentication frame */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302582 if (session->lim_join_req &&
2583 session->lim_join_req->is11Rconnection &&
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302584 auth_frame->authAlgoNumber == SIR_FILS_SK_WITHOUT_PFS &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302585 session->lim_join_req->bssDescription.mdiePresent)
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302586 frame_len += (2 + SIR_MDIE_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 break;
2588
2589 case SIR_MAC_AUTH_FRAME_2:
2590 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2591 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2592 (auth_frame->authStatusCode !=
2593 eSIR_MAC_SUCCESS_STATUS))) {
2594 /*
2595 * Allocate buffer for Authenticaton frame of size
2596 * equal to management frame header length plus
2597 * 2 bytes each for auth algorithm number,
2598 * transaction number and status code.
2599 */
2600
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002601 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2602 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 } else {
2604 /*
2605 * Shared Key algorithm with challenge text
2606 * to be sent.
2607 *
2608 * Allocate buffer for Authenticaton frame of size
2609 * equal to management frame header length plus
2610 * 2 bytes each for auth algorithm number,
2611 * transaction number, status code and 128 bytes
2612 * for challenge text.
2613 */
2614
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002615 challenge_req = true;
2616 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302617 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2618 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002619 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620 }
2621 break;
2622
2623 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002624 /*
2625 * Auth frame3 to be sent without encrypted framebody
2626 *
2627 * Allocate buffer for Authenticaton frame of size equal
2628 * to management frame header length plus 2 bytes each
2629 * for auth algorithm number, transaction number and
2630 * status code.
2631 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002633 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2634 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635 break;
2636
2637 case SIR_MAC_AUTH_FRAME_4:
2638 /*
2639 * Allocate buffer for Authenticaton frame of size equal
2640 * to management frame header length plus 2 bytes each
2641 * for auth algorithm number, transaction number and
2642 * status code.
2643 */
2644
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002645 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2646 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647
2648 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002649 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002650 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002651 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 } /* switch (auth_frame->authTransactionSeqNumber) */
2653
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002654alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302655 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 (void **)&packet);
2657
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302658 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002659 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 return;
2661 }
2662
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302663 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664
2665 /* Prepare BD */
2666 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302667 SIR_MAC_MGMT_AUTH, peer_addr, session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302669 if (wep_challenge_len)
2670 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2671 else
2672 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673
2674 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002675 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302676 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 (uint8_t *) session->bssId,
2678 sizeof(tSirMacAddr));
2679
2680 /* Prepare Authentication frame body */
2681 body = frame + sizeof(tSirMacMgmtHdr);
2682
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302683 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302684 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002686 pe_debug("Sending Auth seq# 3 to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002687 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688
2689 } else {
2690 *((uint16_t *) (body)) =
2691 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2692 body += sizeof(uint16_t);
2693 body_len -= sizeof(uint16_t);
2694
2695 *((uint16_t *) (body)) =
2696 sir_swap_u16if_needed(
2697 auth_frame->authTransactionSeqNumber);
2698 body += sizeof(uint16_t);
2699 body_len -= sizeof(uint16_t);
2700
2701 *((uint16_t *) (body)) =
2702 sir_swap_u16if_needed(auth_frame->authStatusCode);
2703 body += sizeof(uint16_t);
2704 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002705
2706 if (challenge_req) {
2707 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302708 /* copy challenge IE id, len, challenge text */
2709 *body = auth_frame->type;
2710 body++;
2711 body_len -= sizeof(uint8_t);
2712 *body = auth_frame->length;
2713 body++;
2714 body_len -= sizeof(uint8_t);
2715 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002716 body_len);
2717 pe_err("Incomplete challenge info: length: %d, expected: %d",
2718 body_len,
2719 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2720 body += body_len;
2721 body_len = 0;
2722 } else {
2723 /* copy challenge IE id, len, challenge text */
2724 *body = auth_frame->type;
2725 body++;
2726 *body = auth_frame->length;
2727 body++;
2728 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302729 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2730 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002731
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302732 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2733 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002734 }
2735 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2738 (auth_frame->authTransactionSeqNumber ==
2739 SIR_MAC_AUTH_FRAME_1) &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002740 (session->ftPEContext.pFTPreAuthReq)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741
2742 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302743 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 session->ftPEContext.
2745 pFTPreAuthReq->ft_ies,
2746 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002747 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002748 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2749 QDF_TRACE_LEVEL_DEBUG,
2750 (uint8_t *) body,
2751 ft_ies_length);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002752 } else if (session->ftPEContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002753 pFTPreAuthReq->pbssDescription) {
2754 /* MDID attr is 54 */
Srinivas Girigowda61771262019-04-01 11:55:19 -07002755 *body = WLAN_ELEMID_MOBILITY_DOMAIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 body++;
2757 *body = SIR_MDIE_SIZE;
2758 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302759 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 &session->ftPEContext.pFTPreAuthReq->
2761 pbssDescription->mdie[0],
2762 SIR_MDIE_SIZE);
2763 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302764 } else if ((auth_frame->authAlgoNumber ==
2765 SIR_FILS_SK_WITHOUT_PFS) &&
2766 (auth_frame->authTransactionSeqNumber ==
2767 SIR_MAC_AUTH_FRAME_1)) {
2768 pe_debug("FILS: appending fils Auth data");
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302769 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002772 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002773 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 auth_frame->authTransactionSeqNumber,
2775 auth_frame->authStatusCode,
2776 (auth_frame->authStatusCode ==
2777 eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002778 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002780 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2781 QDF_TRACE_LEVEL_DEBUG,
2782 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002784 if ((session->ftPEContext.pFTPreAuthReq) &&
Wu Gaoceac2852019-11-18 20:13:19 +08002785 (!wlan_reg_is_24ghz_ch_freq(
2786 session->ftPEContext.pFTPreAuthReq->pre_auth_channel_freq)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Liangwei Dong419d7302019-07-15 15:38:28 +08002788 else if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
2789 session->opmode == QDF_P2P_CLIENT_MODE ||
2790 session->opmode == QDF_P2P_GO_MODE)
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302791 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302793 if (session->opmode == QDF_P2P_CLIENT_MODE ||
2794 session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2796
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302797 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302800 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002801 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002802 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002803 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302804
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002805 if (session->ftPEContext.pFTPreAuthReq)
Wu Gaoceac2852019-11-18 20:13:19 +08002806 ch_freq_tx_frame = session->ftPEContext.
2807 pFTPreAuthReq->pre_auth_channel_freq;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302808
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302809 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2810 (uint16_t)frame_len,
2811 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2812 7, lim_tx_complete, frame,
2813 lim_auth_tx_complete_cnf,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302814 tx_flag, vdev_id, false,
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302815 ch_freq_tx_frame, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302816 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2817 session->peSessionId, qdf_status));
2818 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2819 pe_err("*** Could not send Auth frame, retCode=%X ***",
2820 qdf_status);
2821 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2822 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002823 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302824 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302825 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 return;
2827}
2828
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002829QDF_STATUS lim_send_deauth_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830{
2831 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002832 tpDphHashNode sta_ds;
2833 tLimMlmDeauthReq *deauth_req;
2834 tLimMlmDeauthCnf deauth_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002835 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002837 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2838 if (deauth_req) {
2839 if (tx_timer_running(
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05302840 &mac_ctx->lim.lim_timers.gLimDeauthAckTimer))
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002841 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002844 session_entry = pe_find_session_by_session_id(mac_ctx,
2845 deauth_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002846 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002847 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002848 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 eSIR_SME_INVALID_PARAMETERS;
2850 goto end;
2851 }
2852
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002853 sta_ds =
2854 dph_lookup_hash_entry(mac_ctx,
2855 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002856 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002857 &session_entry->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002858 if (!sta_ds) {
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002859 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 goto end;
2861 }
2862
2863 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002864 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2865 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2866 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2867 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302868#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002869 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302870#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002871 (session_entry->isFastRoamIniFeatureEnabled) ||
2872 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002873 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002874 session_entry,
2875 session_entry->peSessionId,
2876 deauth_req->reasonCode,
2877 deauth_req->deauthTrigger);
2878 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002879 } else {
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002880#ifdef FEATURE_WLAN_ESE
Nirav Shahf359dd22019-02-20 10:34:28 +05302881 pe_debug("No FT Preauth Session Cleanup in role %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002882 " isESE %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002883 " isLFR %d"
2884 " is11r %d, Deauth reason %d Trigger = %d",
2885 session_entry->limSystemRole,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002886 session_entry->isESEconnection,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002887 session_entry->isFastRoamIniFeatureEnabled,
2888 session_entry->is11Rconnection,
2889 deauth_req->reasonCode,
2890 deauth_req->deauthTrigger);
Nirav Shahf359dd22019-02-20 10:34:28 +05302891#else
2892 pe_debug("No FT Preauth Session Cleanup in role %d"
2893 " isLFR %d"
2894 " is11r %d, Deauth reason %d Trigger = %d",
2895 session_entry->limSystemRole,
2896 session_entry->isFastRoamIniFeatureEnabled,
2897 session_entry->is11Rconnection,
2898 deauth_req->reasonCode,
2899 deauth_req->deauthTrigger);
2900#endif
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002901 }
2902 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002903 qdf_mem_free(deauth_req);
2904 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302906 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002908 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2909 &deauth_req->peer_macaddr);
2910 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2911 deauth_cnf.aid = deauth_req->aid;
2912 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913
2914 /* Free up buffer allocated */
2915 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002916 qdf_mem_free(deauth_req);
2917 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002919 lim_post_sme_message(mac_ctx,
2920 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302921 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922}
2923
2924/**
2925 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2926 *
2927 * @mac_ctx: Handle to MAC context
2928 *
2929 * Sends disassoc confirmation to SME. Removes disassoc request stored
2930 * in lim.
2931 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302932 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 */
2934
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002935QDF_STATUS lim_send_disassoc_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936{
2937 uint16_t aid;
2938 tpDphHashNode sta_ds;
2939 tLimMlmDisassocCnf disassoc_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002940 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941 tLimMlmDisassocReq *disassoc_req;
2942
2943 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2944 if (disassoc_req) {
2945 if (tx_timer_running(
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05302946 &mac_ctx->lim.lim_timers.gLimDisassocAckTimer))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 lim_deactivate_and_change_timer(mac_ctx,
2948 eLIM_DISASSOC_ACK_TIMER);
2949
2950 pe_session = pe_find_session_by_session_id(
2951 mac_ctx, disassoc_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002952 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002953 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 disassoc_cnf.resultCode =
2955 eSIR_SME_INVALID_PARAMETERS;
2956 goto end;
2957 }
2958
2959 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002960 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961 &pe_session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002962 if (!sta_ds) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002963 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2965 goto end;
2966 }
2967 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002968 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002969 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2970 disassoc_cnf.resultCode =
2971 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002972 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 goto end;
2974 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002975 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002976 (disassoc_req->reasonCode !=
2977 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002978 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002979 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002980
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 /* Delete FT session if there exists one */
2982 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002984 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302985 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302987 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302989 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 }
2991end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302992 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002993 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302994 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 disassoc_cnf.aid = disassoc_req->aid;
2996 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2997
2998 /* Update PE session ID */
2999 disassoc_cnf.sessionId = disassoc_req->sessionId;
3000
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003001 if (disassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303003 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3005 }
3006
3007 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
3008 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303009 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010}
3011
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303012QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003013 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303014 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003016 struct mac_context *max_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303017
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003018 pe_debug("tx_success: %d", tx_success);
3019
3020 return lim_send_disassoc_cnf(max_ctx);
3021}
3022
3023static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
3024 qdf_nbuf_t buf,
3025 uint32_t tx_success,
3026 void *params)
3027{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003028 struct mac_context *max_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003029 QDF_STATUS status_code;
3030 struct scheduler_msg msg = {0};
3031
3032 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303033
3034 if (buf)
3035 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003036 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
3037 msg.bodyptr = params;
3038 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303039
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003040 status_code = lim_post_msg_high_priority(max_ctx, &msg);
3041 if (status_code != QDF_STATUS_SUCCESS)
3042 pe_err("posting message: %X to LIM failed, reason: %d",
3043 msg.type, status_code);
3044 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045}
3046
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303047QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003048 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303049 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003051 struct mac_context *mac_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303052
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003053 pe_debug("tx_success: %d", tx_success);
3054
3055 return lim_send_deauth_cnf(mac_ctx);
3056}
3057
3058static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
3059 qdf_nbuf_t buf,
3060 uint32_t tx_success,
3061 void *params)
3062{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003063 struct mac_context *mac_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003064 QDF_STATUS status_code;
3065 struct scheduler_msg msg = {0};
3066
3067 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303068
3069 if (buf)
3070 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003071 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
3072 msg.bodyptr = params;
3073 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303074
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003075 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
3076 if (status_code != QDF_STATUS_SUCCESS)
3077 pe_err("posting message: %X to LIM failed, reason: %d",
3078 msg.type, status_code);
3079 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080}
3081
3082/**
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303083 * lim_append_ies_to_frame() - Append IEs to the frame
3084 *
3085 * @frame: Pointer to the frame buffer that needs to be populated
3086 * @frame_len: Pointer for current frame length
3087 * @ie: pointer for disconnect IEs
3088 *
3089 * This function is called by lim_send_disassoc_mgmt_frame and
3090 * lim_send_deauth_mgmt_frame APIs as part of disconnection.
3091 * Append IEs and update frame length.
3092 *
3093 * Return: None
3094 */
3095static void
3096lim_append_ies_to_frame(uint8_t *frame, uint32_t *frame_len,
3097 struct wlan_ies *ie)
3098{
3099 if (!ie || !ie->len || !ie->data)
3100 return;
3101 qdf_mem_copy(frame, ie->data, ie->len);
3102 *frame_len += ie->len;
3103 pe_debug("Appended IEs len: %u", ie->len);
3104}
3105
3106/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 * \brief This function is called to send Disassociate frame.
3108 *
3109 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003110 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 *
3112 * \param nReason Indicates the reason that need to be sent in
3113 * Disassociation frame
3114 *
3115 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3116 * sent
3117 *
3118 *
3119 */
3120
3121void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003122lim_send_disassoc_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 uint16_t nReason,
3124 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003125 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126{
3127 tDot11fDisassociation frm;
3128 uint8_t *pFrame;
3129 tpSirMacMgmtHdr pMacHdr;
3130 uint32_t nBytes, nPayload, nStatus;
3131 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303132 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 uint8_t txFlag = 0;
3134 uint32_t val = 0;
3135 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303136 struct wlan_ies *discon_ie;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003137
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003138 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003139 return;
3140 }
3141
3142 /*
3143 * In case when cac timer is running for this SAP session then
3144 * avoid sending disassoc out. It is violation of dfs specification.
3145 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303146 if (((pe_session->opmode == QDF_SAP_MODE) ||
3147 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003148 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303149 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303150 FL("CAC timer is running, drop disassoc from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303151 if (waitForAck)
3152 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 return;
3154 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003155 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156
hangtian127c9532019-01-12 13:29:07 +08003157 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158
3159 frm.Reason.code = nReason;
3160
Jeff Johnson99f25042018-11-21 22:49:06 -08003161 nStatus = dot11f_get_packed_disassociation_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003163 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 nStatus);
3165 /* We'll fall back on the worst case scenario: */
3166 nPayload = sizeof(tDot11fDisassociation);
3167 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003168 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
3169 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 }
3171
3172 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3173
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303174 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3175 if (discon_ie && discon_ie->len)
3176 nBytes += discon_ie->len;
3177
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303178 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303180 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003181 pe_err("Failed to allocate %d bytes for a Disassociation",
3182 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303183 if (waitForAck)
3184 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 return;
3186 }
3187 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003188 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189
3190 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003191 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303192 SIR_MAC_MGMT_DISASSOC, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3194
3195 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003196 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003198 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199
Jeff Johnson99f25042018-11-21 22:49:06 -08003200 nStatus = dot11f_pack_disassociation(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 sizeof(tSirMacMgmtHdr),
3202 nPayload, &nPayload);
3203 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003204 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 nStatus);
3206 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303207 if (waitForAck)
3208 lim_send_disassoc_cnf(mac);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003209 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003211 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
3212 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 }
3214
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303215 /* Copy disconnect IEs to the end of the frame */
3216 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3217 &nPayload, discon_ie);
3218 mlme_free_self_disconnect_ies(pe_session->vdev);
3219
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003220 pe_debug("***Sessionid %d Sending Disassociation frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003221 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR " ,From "
3222 QDF_MAC_ADDR_STR, pe_session->peSessionId, nReason,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003223 waitForAck, QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303224 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225
Liangwei Dong419d7302019-07-15 15:38:28 +08003226 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3227 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3228 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230
Sushant Kaushik46556062015-12-02 16:57:47 +05303231 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232
3233 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303234 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003235 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003237 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003238 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003239 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 /* Queue Disassociation frame in high priority WQ */
3241 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303242 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003243 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 TXRX_FRM_802_11_MGMT,
3245 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003246 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003247 txFlag, smeSessionId, false, 0,
3248 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303249 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303250 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003251 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252
3253 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3254
3255 if (tx_timer_change
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303256 (&mac->lim.lim_timers.gLimDisassocAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003258 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 return;
3260 } else if (TX_SUCCESS !=
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303261 tx_timer_activate(&mac->lim.lim_timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003263 pe_err("Unable to activate Disassoc ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003264 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 eLIM_DISASSOC_ACK_TIMER);
3266 return;
3267 }
3268 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303269 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003270 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003272 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003273 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003274 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003276 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 TXRX_FRM_802_11_MGMT,
3278 ANI_TXDIR_TODS,
3279 7,
3280 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003281 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303282 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303283 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003284 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303285 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003286 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303287 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 /* Pkt will be freed up by the callback */
3289 }
3290 }
3291} /* End lim_send_disassoc_mgmt_frame. */
3292
3293/**
3294 * \brief This function is called to send a Deauthenticate frame
3295 *
3296 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003297 * \param mac Pointer to global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 *
3299 * \param nReason Indicates the reason that need to be sent in the
3300 * Deauthenticate frame
3301 *
3302 * \param peeer address of the STA to which the frame is to be sent
3303 *
3304 *
3305 */
3306
3307void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003308lim_send_deauth_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 uint16_t nReason,
3310 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003311 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312{
3313 tDot11fDeAuth frm;
3314 uint8_t *pFrame;
3315 tpSirMacMgmtHdr pMacHdr;
3316 uint32_t nBytes, nPayload, nStatus;
3317 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303318 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 uint8_t txFlag = 0;
3320 uint32_t val = 0;
3321#ifdef FEATURE_WLAN_TDLS
3322 uint16_t aid;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003323 tpDphHashNode sta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324#endif
3325 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303326 struct wlan_ies *discon_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003328 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 return;
3330 }
3331
3332 /*
3333 * In case when cac timer is running for this SAP session then
3334 * avoid deauth frame out. It is violation of dfs specification.
3335 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303336 if (((pe_session->opmode == QDF_SAP_MODE) ||
3337 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003338 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303339 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 FL
3341 ("CAC timer is running, drop the deauth from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303342 if (waitForAck)
3343 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 return;
3345 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003346 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347
hangtian127c9532019-01-12 13:29:07 +08003348 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349
3350 frm.Reason.code = nReason;
3351
Jeff Johnson99f25042018-11-21 22:49:06 -08003352 nStatus = dot11f_get_packed_de_auth_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003354 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003355 nStatus);
3356 /* We'll fall back on the worst case scenario: */
3357 nPayload = sizeof(tDot11fDeAuth);
3358 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003359 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3360 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 }
3362
3363 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303364 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3365 if (discon_ie && discon_ie->len)
3366 nBytes += discon_ie->len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303368 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303370 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003371 pe_err("Failed to allocate %d bytes for a De-Authentication",
3372 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303373 if (waitForAck)
3374 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375 return;
3376 }
3377 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003378 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379
3380 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003381 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303382 SIR_MAC_MGMT_DEAUTH, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3384
3385 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003386 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003388 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389
Jeff Johnson99f25042018-11-21 22:49:06 -08003390 nStatus = dot11f_pack_de_auth(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3392 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003393 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394 nStatus);
3395 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303396 if (waitForAck)
3397 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 return;
3399 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003400 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3401 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 }
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303403
3404 /* Copy disconnect IEs to the end of the frame */
3405 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3406 &nPayload, discon_ie);
3407 mlme_free_self_disconnect_ies(pe_session->vdev);
3408
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003409 pe_debug("***Sessionid %d Sending Deauth frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003410 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR
3411 " ,From " QDF_MAC_ADDR_STR,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003412 pe_session->peSessionId, nReason, waitForAck,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003413 QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303414 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415
Liangwei Dong419d7302019-07-15 15:38:28 +08003416 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3417 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3418 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420
Sushant Kaushik46556062015-12-02 16:57:47 +05303421 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003423 sta =
Jeff Johnson99f25042018-11-21 22:49:06 -08003424 dph_lookup_hash_entry(mac, peer, &aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003425 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426#endif
3427
3428 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303429 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003430 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003432 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003433 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003434 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303436 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003437 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 TXRX_FRM_802_11_MGMT,
3439 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003440 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003441 txFlag, smeSessionId, false, 0,
3442 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303443 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303444 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003445 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303447 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003448 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303449 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450
3451 /* Call lim_process_deauth_ack_timeout which will send
3452 * DeauthCnf for this frame
3453 */
Jeff Johnson99f25042018-11-21 22:49:06 -08003454 lim_process_deauth_ack_timeout(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 return;
3456 }
3457
3458 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3459
3460 if (tx_timer_change
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303461 (&mac->lim.lim_timers.gLimDeauthAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003463 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 return;
3465 } else if (TX_SUCCESS !=
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303466 tx_timer_activate(&mac->lim.lim_timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003468 pe_err("Unable to activate Deauth ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003469 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 eLIM_DEAUTH_ACK_TIMER);
3471 return;
3472 }
3473 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303474 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003475 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 pMacHdr->fc.subType));
3477#ifdef FEATURE_WLAN_TDLS
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003478 if ((sta)
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003479 && (STA_ENTRY_TDLS_PEER == sta->staType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003481 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003482 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003483 QDF_STATUS_SUCCESS,
3484 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303485 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003486 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3488 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003489 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 } else {
3491#endif
Jeff Johnson99f25042018-11-21 22:49:06 -08003492 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003493 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003494 QDF_STATUS_SUCCESS,
3495 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303497 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003498 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3500 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003501 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502#ifdef FEATURE_WLAN_TDLS
3503 }
3504#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303505 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003506 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303507 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003508 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303509 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 /* Pkt will be freed up by the callback */
3511 }
3512 }
3513
3514} /* End lim_send_deauth_mgmt_frame. */
3515
3516#ifdef ANI_SUPPORT_11H
3517/**
3518 * \brief Send a Measurement Report Action frame
3519 *
3520 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003521 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 *
3523 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3524 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003525 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 *
3527 *
3528 */
3529
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003530QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003531lim_send_meas_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532 tpSirMacMeasReqActionFrame pMeasReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003533 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534{
3535 tDot11fMeasurementReport frm;
3536 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003537 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538 tpSirMacMgmtHdr pMacHdr;
3539 uint32_t nBytes, nPayload, nStatus;
3540 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303541 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003542
hangtian127c9532019-01-12 13:29:07 +08003543 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003545 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003546 frm.Action.action = ACTION_SPCT_MSR_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3548
3549 switch (pMeasReqFrame->measReqIE.measType) {
3550 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3551 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003552 populate_dot11f_measurement_report0(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 &frm.MeasurementReport);
3554 break;
3555 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3556 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003557 populate_dot11f_measurement_report1(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 &frm.MeasurementReport);
3559 break;
3560 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3561 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003562 populate_dot11f_measurement_report2(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 &frm.MeasurementReport);
3564 break;
3565 default:
Jeff Johnson0711e272018-12-14 23:16:38 -08003566 pe_err("Unknown measurement type %d in limSendMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003568 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 }
3570
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003571 if (QDF_STATUS_SUCCESS != nSirStatus)
3572 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573
Jeff Johnson99f25042018-11-21 22:49:06 -08003574 nStatus = dot11f_get_packed_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003576 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577 nStatus);
3578 /* We'll fall back on the worst case scenario: */
3579 nPayload = sizeof(tDot11fMeasurementReport);
3580 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003581 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3582 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 }
3584
3585 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3586
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303587 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003588 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 (uint16_t) nBytes, (void **)&pFrame,
3590 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303591 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson0711e272018-12-14 23:16:38 -08003592 pe_err("Failed to allocate %d bytes for a De-Authentication",
3593 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003594 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 }
3596 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003597 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598
3599 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003600 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 SIR_MAC_MGMT_ACTION, peer);
3602 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3603
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003604 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003606 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607
Jeff Johnson99f25042018-11-21 22:49:06 -08003608 nStatus = dot11f_pack_measurement_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 sizeof(tSirMacMgmtHdr),
3610 nPayload, &nPayload);
3611 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003612 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003614 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003616 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003618 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3619 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620 }
3621
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303622 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003623 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303625 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003626 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003628 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303629 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303630 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003631 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303632 qdf_status));
3633 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003634 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303635 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003637 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 }
3639
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003640 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641
3642} /* End lim_send_meas_report_frame. */
3643
3644/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 * \brief Send a TPC Report Action frame
3646 *
3647 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003648 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 *
3650 * \param pTpcReqFrame Pointer to the received TPC Request
3651 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003652 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 *
3654 *
3655 */
3656
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003657QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003658lim_send_tpc_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659 tpSirMacTpcReqActionFrame pTpcReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003660 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661{
3662 tDot11fTPCReport frm;
3663 uint8_t *pFrame;
3664 tpSirMacMgmtHdr pMacHdr;
3665 uint32_t nBytes, nPayload, nStatus;
3666 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303667 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668
hangtian127c9532019-01-12 13:29:07 +08003669 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003671 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003672 frm.Action.action = ACTION_SPCT_TPC_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3674
3675 frm.TPCReport.tx_power = 0;
3676 frm.TPCReport.link_margin = 0;
3677 frm.TPCReport.present = 1;
3678
Jeff Johnson99f25042018-11-21 22:49:06 -08003679 nStatus = dot11f_get_packed_tpc_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003681 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 /* We'll fall back on the worst case scenario: */
3683 nPayload = sizeof(tDot11fTPCReport);
3684 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003685 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3686 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 }
3688
3689 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3690
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303691 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003692 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693 (uint16_t) nBytes, (void **)&pFrame,
3694 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303695 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003696 pe_err("Failed to allocate %d bytes for a TPC"
3697 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003698 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 }
3700 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003701 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702
3703 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003704 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705 SIR_MAC_MGMT_ACTION, peer);
3706
3707 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3708
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003709 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003711 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712
Jeff Johnson99f25042018-11-21 22:49:06 -08003713 nStatus = dot11f_pack_tpc_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 sizeof(tSirMacMgmtHdr),
3715 nPayload, &nPayload);
3716 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003717 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003719 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003721 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003723 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3724 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303726 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003727 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303729 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003730 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003732 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303733 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003734 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003735 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003736 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303737 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003738 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303739 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003740 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003741 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003742 }
3743
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003744 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745
3746} /* End lim_send_tpc_report_frame. */
3747#endif /* ANI_SUPPORT_11H */
3748
3749/**
3750 * \brief Send a Channel Switch Announcement
3751 *
3752 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003753 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003754 *
3755 * \param peer MAC address to which this frame will be sent
3756 *
3757 * \param nMode
3758 *
3759 * \param nNewChannel
3760 *
3761 * \param nCount
3762 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003763 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003764 *
3765 *
3766 */
3767
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003768QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003769lim_send_channel_switch_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003770 tSirMacAddr peer,
3771 uint8_t nMode,
3772 uint8_t nNewChannel,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003773 uint8_t nCount, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774{
3775 tDot11fChannelSwitch frm;
3776 uint8_t *pFrame;
3777 tpSirMacMgmtHdr pMacHdr;
3778 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3779 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303780 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 uint8_t txFlag = 0;
3782
3783 uint8_t smeSessionId = 0;
3784
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003785 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003786 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003787 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003789 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790
hangtian127c9532019-01-12 13:29:07 +08003791 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003793 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003794 frm.Action.action = ACTION_SPCT_CHL_SWITCH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 frm.ChanSwitchAnn.switchMode = nMode;
3796 frm.ChanSwitchAnn.newChannel = nNewChannel;
3797 frm.ChanSwitchAnn.switchCount = nCount;
3798 frm.ChanSwitchAnn.present = 1;
3799
Jeff Johnson99f25042018-11-21 22:49:06 -08003800 nStatus = dot11f_get_packed_channel_switch_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003802 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 nStatus);
3804 /* We'll fall back on the worst case scenario: */
3805 nPayload = sizeof(tDot11fChannelSwitch);
3806 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003807 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3808 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 }
3810
3811 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3812
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303813 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3815 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303816 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003817 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003818 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 }
3820 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003821 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822
3823 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003824 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825 SIR_MAC_MGMT_ACTION, peer,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303826 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303828 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003829 (uint8_t *) pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003831 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832
Jeff Johnson99f25042018-11-21 22:49:06 -08003833 nStatus = dot11f_pack_channel_switch(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003834 sizeof(tSirMacMgmtHdr),
3835 nPayload, &nPayload);
3836 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003837 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003838 nStatus);
3839 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003840 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003842 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3843 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003844 }
3845
Liangwei Dong419d7302019-07-15 15:38:28 +08003846 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3847 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3848 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303851 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003852 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003853 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 TXRX_FRM_802_11_MGMT,
3855 ANI_TXDIR_TODS,
3856 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003857 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303858 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003859 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303860 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003861 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303862 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003864 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865 }
3866
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003867 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868
3869} /* End lim_send_channel_switch_mgmt_frame. */
3870
Abhishek Singh518323d2015-10-19 17:42:01 +05303871/**
3872 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3873 * action frame over the air .
3874 * @mac_ctx: pointer to global mac structure
3875 * @peer: Destination mac.
3876 * @mode: channel switch mode
3877 * @new_op_class: new op class
3878 * @new_channel: new channel to switch
3879 * @count: channel switch count
3880 *
3881 * This function is called to send ECSA frame.
3882 *
3883 * Return: success if frame is sent else return failure
3884 */
3885
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003886QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003887lim_send_extended_chan_switch_action_frame(struct mac_context *mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05303888 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
Jeff Johnsona7815652018-11-18 22:58:30 -08003889 uint8_t new_channel, uint8_t count, struct pe_session *session_entry)
Abhishek Singh518323d2015-10-19 17:42:01 +05303890{
3891 tDot11fext_channel_switch_action_frame frm;
3892 uint8_t *frame;
3893 tpSirMacMgmtHdr mac_hdr;
3894 uint32_t num_bytes, n_payload, status;
3895 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303896 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303897 uint8_t txFlag = 0;
Abhishek Singh345be412019-11-19 10:59:29 +05303898 uint8_t vdev_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303899 uint8_t ch_spacing;
3900 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303901
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003902 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003903 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003904 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303905 }
3906
Abhishek Singh345be412019-11-19 10:59:29 +05303907 vdev_id = session_entry->smeSessionId;
Abhishek Singh518323d2015-10-19 17:42:01 +05303908
hangtian127c9532019-01-12 13:29:07 +08003909 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh518323d2015-10-19 17:42:01 +05303910
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003911 frm.Category.category = ACTION_CATEGORY_PUBLIC;
Abhishek Singh518323d2015-10-19 17:42:01 +05303912 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3913
3914 frm.ext_chan_switch_ann_action.switch_mode = mode;
3915 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3916 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3917 frm.ext_chan_switch_ann_action.switch_count = count;
3918
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303919 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3920 mac_ctx->scan.countryCodeCurrent, new_channel,
3921 new_op_class);
3922 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3923
3924 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3925 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3926 frm.WiderBWChanSwitchAnn.newChanWidth =
3927 wide_bw_ie->newChanWidth;
3928 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3929 wide_bw_ie->newCenterChanFreq0;
3930 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3931 wide_bw_ie->newCenterChanFreq1;
3932 frm.WiderBWChanSwitchAnn.present = 1;
3933 pe_debug("wrapper: width:%d f0:%d f1:%d",
3934 frm.WiderBWChanSwitchAnn.newChanWidth,
3935 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3936 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3937 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303938
3939 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3940 &frm, &n_payload);
3941 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003942 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303943 status);
3944 /* We'll fall back on the worst case scenario*/
3945 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3946 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003947 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303948 status);
3949 }
3950
3951 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3952
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303953 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303954 (void **) &frame, (void **) &packet);
3955
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303956 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003957 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303958 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003959 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303960 }
3961
3962 /* Paranoia*/
hangtian127c9532019-01-12 13:29:07 +08003963 qdf_mem_zero(frame, num_bytes);
Abhishek Singh518323d2015-10-19 17:42:01 +05303964
3965 /* Next, we fill out the buffer descriptor */
3966 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303967 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh518323d2015-10-19 17:42:01 +05303968 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303969 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303970 (uint8_t *) session_entry->bssId,
3971 sizeof(tSirMacAddr));
3972
gaolez4b62a9e2018-08-16 15:57:50 +08003973 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
3974
Abhishek Singh518323d2015-10-19 17:42:01 +05303975 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3976 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3977 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003978 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303979 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003980 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303981 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003982 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303983 status);
3984 }
3985
Liangwei Dong419d7302019-07-15 15:38:28 +08003986 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
3987 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
3988 session_entry->opmode == QDF_P2P_GO_MODE)
Abhishek Singh518323d2015-10-19 17:42:01 +05303989 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Abhishek Singh518323d2015-10-19 17:42:01 +05303990
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003991 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 -07003992 QDF_MAC_ADDR_ARRAY(mac_hdr->da),
Abhishek Singh518323d2015-10-19 17:42:01 +05303993 frm.ext_chan_switch_ann_action.switch_count,
3994 frm.ext_chan_switch_ann_action.switch_mode,
3995 frm.ext_chan_switch_ann_action.new_channel,
3996 frm.ext_chan_switch_ann_action.op_class);
3997
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303998 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303999 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304000 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05304001 TXRX_FRM_802_11_MGMT,
4002 ANI_TXDIR_TODS,
4003 7,
4004 lim_tx_complete, frame,
Abhishek Singh345be412019-11-19 10:59:29 +05304005 txFlag, vdev_id, 0,
Naveen Rawat296a5182017-09-25 14:02:48 -07004006 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304007 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304008 session_entry->peSessionId, qdf_status));
4009 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004010 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304011 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05304012 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004013 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05304014 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004015 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05304016} /* End lim_send_extended_chan_switch_action_frame */
4017
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304018
4019/**
4020 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
4021 * sent over the air
4022 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304023 * @context: pointer to global mac
4024 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304025 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304026 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304027 *
4028 * Return: This returns QDF_STATUS
4029 */
4030
4031static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304032 void *context,
4033 qdf_nbuf_t buf,
4034 uint32_t tx_complete,
4035 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304036{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004037 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08004038 if (buf)
4039 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304040 return QDF_STATUS_SUCCESS;
4041}
4042
4043/**
4044 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
4045 * p2p oper chan change confirm action frame
4046 * @mac_ctx: pointer to global mac structure
4047 * @peer: Destination mac.
4048 * @session_entry: session entry
4049 *
4050 * This function is called to send p2p oper chan change confirm action frame.
4051 *
4052 * Return: success if frame is sent else return failure
4053 */
4054
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004055QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004056lim_p2p_oper_chan_change_confirm_action_frame(struct mac_context *mac_ctx,
Jeff Johnsona7815652018-11-18 22:58:30 -08004057 tSirMacAddr peer, struct pe_session *session_entry)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304058{
4059 tDot11fp2p_oper_chan_change_confirm frm;
4060 uint8_t *frame;
4061 tpSirMacMgmtHdr mac_hdr;
4062 uint32_t num_bytes, n_payload, status;
4063 void *packet;
4064 QDF_STATUS qdf_status;
4065 uint8_t tx_flag = 0;
Abhishek Singh345be412019-11-19 10:59:29 +05304066 uint8_t vdev_id = 0;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304067
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004068 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004069 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004070 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304071 }
4072
Abhishek Singh345be412019-11-19 10:59:29 +05304073 vdev_id = session_entry->smeSessionId;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304074
hangtian127c9532019-01-12 13:29:07 +08004075 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304076
4077 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
4078
4079 qdf_mem_copy(frm.p2p_action_oui.oui_data,
4080 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
4081 frm.p2p_action_subtype.subtype = 0x04;
4082 frm.DialogToken.token = 0x0;
4083
4084 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004085 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304086 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
4087 }
4088
4089 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004090 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304091 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
4092 populate_dot11f_operating_mode(mac_ctx,
4093 &frm.OperatingMode, session_entry);
4094 }
4095
4096 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
4097 &frm, &n_payload);
4098 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004099 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304100 /* We'll fall back on the worst case scenario*/
4101 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
4102 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004103 pe_warn("There were warnings while calculating the packed size (0x%08x)",
4104 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304105 }
4106
4107 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
4108
4109 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
4110 (void **) &frame, (void **) &packet);
4111
4112 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004113 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004114 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304115 }
4116
hangtian127c9532019-01-12 13:29:07 +08004117 qdf_mem_zero(frame, num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304118
4119 /* Next, fill out the buffer descriptor */
4120 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304121 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304122 mac_hdr = (tpSirMacMgmtHdr) frame;
4123 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
4124 (uint8_t *) session_entry->bssId,
4125 sizeof(tSirMacAddr));
4126
4127 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
4128 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
4129 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004130 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304131 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004132 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304133 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004134 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304135 status);
4136 }
4137
Liangwei Dong419d7302019-07-15 15:38:28 +08004138 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
4139 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
4140 session_entry->opmode == QDF_P2P_GO_MODE) {
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304141 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4142 }
Liangwei Dong419d7302019-07-15 15:38:28 +08004143 pe_debug("Send frame on channel freq %d to mac "
4144 QDF_MAC_ADDR_STR, session_entry->curr_op_freq,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07004145 QDF_MAC_ADDR_ARRAY(peer));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304146
4147 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4148 session_entry->peSessionId, mac_hdr->fc.subType));
4149
4150 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4151 (uint16_t)num_bytes,
4152 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4153 7, lim_tx_complete, frame,
4154 lim_oper_chan_change_confirm_tx_complete_cnf,
Abhishek Singh345be412019-11-19 10:59:29 +05304155 tx_flag, vdev_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304156
4157 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4158 session_entry->peSessionId, qdf_status));
4159 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004160 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304161 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004162 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304163 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004164 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304165}
4166
4167
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168/**
4169 * \brief Send a Neighbor Report Request Action frame
4170 *
4171 *
Jeff Johnson99f25042018-11-21 22:49:06 -08004172 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 *
4174 * \param pNeighborReq Address of a tSirMacNeighborReportReq
4175 *
4176 * \param peer mac address of peer station.
4177 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004178 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004180 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 *
4182 *
4183 */
4184
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004185QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004186lim_send_neighbor_report_request_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 tpSirMacNeighborReportReq pNeighborReq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004188 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304190 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191 tDot11fNeighborReportRequest frm;
4192 uint8_t *pFrame;
4193 tpSirMacMgmtHdr pMacHdr;
4194 uint32_t nBytes, nPayload, nStatus;
4195 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304196 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 uint8_t txFlag = 0;
4198 uint8_t smeSessionId = 0;
4199
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004200 if (!pe_session) {
4201 pe_err("(!psession) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004202 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004204 smeSessionId = pe_session->smeSessionId;
hangtian127c9532019-01-12 13:29:07 +08004205 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004207 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004208 frm.Action.action = RRM_NEIGHBOR_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 frm.DialogToken.token = pNeighborReq->dialogToken;
4210
4211 if (pNeighborReq->ssid_present) {
Jeff Johnson99f25042018-11-21 22:49:06 -08004212 populate_dot11f_ssid(mac, &pNeighborReq->ssid, &frm.SSID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 }
4214
4215 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004216 dot11f_get_packed_neighbor_report_request_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004217 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004218 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219 nStatus);
4220 /* We'll fall back on the worst case scenario: */
4221 nPayload = sizeof(tDot11fNeighborReportRequest);
4222 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004223 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4224 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 }
4226
4227 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4228
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304229 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004230 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4231 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304232 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004233 pe_err("Failed to allocate %d bytes for a Neighbor "
4234 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004235 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236 }
4237 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004238 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004239
4240 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004241 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304242 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243
4244 /* Update A3 with the BSSID */
4245 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4246
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004247 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004249 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250
4251 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004252 nStatus = dot11f_pack_neighbor_report_request(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 &frm,
4254 pFrame +
4255 sizeof(tSirMacMgmtHdr),
4256 nPayload, &nPayload);
4257
4258 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004259 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 nStatus);
4261
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004262 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304263 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 goto returnAfterError;
4265 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004266 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4267 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 }
4269
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004270 pe_debug("Sending a Neighbor Report Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004271 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272
Liangwei Dong419d7302019-07-15 15:38:28 +08004273 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4274 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4275 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304278 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004279 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004280 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 pPacket,
4282 (uint16_t) nBytes,
4283 TXRX_FRM_802_11_MGMT,
4284 ANI_TXDIR_TODS,
4285 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004286 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304287 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004288 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304289 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004290 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304291 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304293 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004295 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296
4297returnAfterError:
4298 cds_packet_free((void *)pPacket);
4299
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304300 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301} /* End lim_send_neighbor_report_request_frame. */
4302
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004303QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004304lim_send_link_report_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 tpSirMacLinkReport pLinkReport,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004306 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304308 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 tDot11fLinkMeasurementReport frm;
4310 uint8_t *pFrame;
4311 tpSirMacMgmtHdr pMacHdr;
4312 uint32_t nBytes, nPayload, nStatus;
4313 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304314 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 uint8_t txFlag = 0;
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304316 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004318 if (!pe_session) {
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304319 pe_err("RRM: Send link report: NULL PE session");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004320 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004321 }
4322
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304323 vdev_id = pe_session->vdev_id;
hangtian127c9532019-01-12 13:29:07 +08004324 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004326 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004327 frm.Action.action = RRM_LINK_MEASUREMENT_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328 frm.DialogToken.token = pLinkReport->dialogToken;
4329
4330 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4331 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4332 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4333 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4334 /* such case this way than changing the frame parser. */
Srinivas Girigowda61771262019-04-01 11:55:19 -07004335 frm.TPCEleID.TPCId = WLAN_ELEMID_TPCREP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 frm.TPCEleLen.TPCLen = 2;
4337 frm.TxPower.txPower = pLinkReport->txPower;
4338 frm.LinkMargin.linkMargin = 0;
4339
4340 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4341 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4342 frm.RCPI.rcpi = pLinkReport->rcpi;
4343 frm.RSNI.rsni = pLinkReport->rsni;
4344
4345 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004346 dot11f_get_packed_link_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004348 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004349 /* We'll fall back on the worst case scenario: */
4350 nPayload = sizeof(tDot11fLinkMeasurementReport);
4351 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004352 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4353 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354 }
4355
4356 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4357
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304358 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4360 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304361 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004362 pe_err("Failed to allocate %d bytes for a Link "
4363 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004364 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365 }
4366 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004367 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368
4369 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004370 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304371 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004372
4373 /* Update A3 with the BSSID */
4374 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4375
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004376 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004378 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379
4380 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004381 nStatus = dot11f_pack_link_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004382 &frm,
4383 pFrame +
4384 sizeof(tSirMacMgmtHdr),
4385 nPayload, &nPayload);
4386
4387 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004388 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004389
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004390 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304391 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004392 goto returnAfterError;
4393 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004394 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 nStatus);
4396 }
4397
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304398 pe_warn("RRM: Sending Link Report to %pM on vdev[%d]", peer, vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399
Liangwei Dong419d7302019-07-15 15:38:28 +08004400 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4401 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4402 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304405 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004406 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004407 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 pPacket,
4409 (uint16_t) nBytes,
4410 TXRX_FRM_802_11_MGMT,
4411 ANI_TXDIR_TODS,
4412 7, lim_tx_complete, pFrame, txFlag,
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304413 vdev_id, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304414 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004415 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304416 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004417 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304418 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304420 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004422 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423
4424returnAfterError:
4425 cds_packet_free((void *)pPacket);
4426
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304427 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428} /* End lim_send_link_report_action_frame. */
4429
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004430QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004431lim_send_radio_measure_report_action_frame(struct mac_context *mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304432 uint8_t dialog_token,
4433 uint8_t num_report,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304434 bool is_last_frame,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304435 tpSirMacRadioMeasureReport pRRMReport,
4436 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004437 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304439 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440 uint8_t *pFrame;
4441 tpSirMacMgmtHdr pMacHdr;
4442 uint32_t nBytes, nPayload, nStatus;
4443 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304444 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 uint8_t i;
4446 uint8_t txFlag = 0;
4447 uint8_t smeSessionId = 0;
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304448 bool is_last_report = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449
4450 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304451 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004452 if (!frm)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004453 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004455 if (!pe_session) {
4456 pe_err("(!psession) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304457 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004458 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004461 smeSessionId = pe_session->smeSessionId;
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004462
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304463 pe_debug("dialog_token %d num_report %d is_last_frame %d",
4464 dialog_token, num_report, is_last_frame);
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304465
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004466 frm->Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004467 frm->Action.action = RRM_RADIO_MEASURE_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004468 frm->DialogToken.token = dialog_token;
4469
4470 frm->num_MeasurementReport =
4471 (num_report >
4472 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4473 num_report;
4474
4475 for (i = 0; i < frm->num_MeasurementReport; i++) {
4476 frm->MeasurementReport[i].type = pRRMReport[i].type;
4477 frm->MeasurementReport[i].token = pRRMReport[i].token;
4478 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4479 switch (pRRMReport[i].type) {
4480 case SIR_MAC_RRM_BEACON_TYPE:
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304481 /*
4482 * Last beacon report indication needs to be set to 1
4483 * only for the last report in the last frame
4484 */
4485 if (is_last_frame &&
4486 (i == (frm->num_MeasurementReport - 1)))
4487 is_last_report = true;
4488
Jeff Johnson99f25042018-11-21 22:49:06 -08004489 populate_dot11f_beacon_report(mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304490 &frm->MeasurementReport[i],
4491 &pRRMReport[i].report.
4492 beaconReport,
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304493 is_last_report);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 frm->MeasurementReport[i].incapable =
4495 pRRMReport[i].incapable;
4496 frm->MeasurementReport[i].refused =
4497 pRRMReport[i].refused;
4498 frm->MeasurementReport[i].present = 1;
4499 break;
4500 default:
4501 frm->MeasurementReport[i].incapable =
4502 pRRMReport[i].incapable;
4503 frm->MeasurementReport[i].refused =
4504 pRRMReport[i].refused;
4505 frm->MeasurementReport[i].present = 1;
4506 break;
4507 }
4508 }
4509
4510 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004511 dot11f_get_packed_radio_measurement_report_size(mac, frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004513 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514 nStatus);
4515 /* We'll fall back on the worst case scenario: */
4516 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304517 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004518 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004520 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4521 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 }
4523
4524 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4525
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304526 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4528 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304529 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004530 pe_err("Failed to allocate %d bytes for a Radio Measure "
4531 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304532 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004533 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 }
4535 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004536 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537
4538 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004539 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304540 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004541
4542 /* Update A3 with the BSSID */
4543 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4544
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004545 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004547 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548
4549 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004550 nStatus = dot11f_pack_radio_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 frm,
4552 pFrame +
4553 sizeof(tSirMacMgmtHdr),
4554 nPayload, &nPayload);
4555
4556 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004557 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558 nStatus);
4559
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004560 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304561 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 goto returnAfterError;
4563 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004564 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4565 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 }
4567
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004568 pe_warn("Sending a Radio Measure Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004569 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570
Liangwei Dong419d7302019-07-15 15:38:28 +08004571 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4572 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4573 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304576 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004577 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004578 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 pPacket,
4580 (uint16_t) nBytes,
4581 TXRX_FRM_802_11_MGMT,
4582 ANI_TXDIR_TODS,
4583 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004584 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304585 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004586 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304587 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004588 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304589 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004590 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304591 qdf_mem_free(frm);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304592 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304594 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004595 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 }
4597
4598returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304599 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 cds_packet_free((void *)pPacket);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304601 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602}
4603
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604#ifdef WLAN_FEATURE_11W
4605/**
4606 * \brief Send SA query request action frame to peer
4607 *
4608 * \sa lim_send_sa_query_request_frame
4609 *
4610 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004611 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 *
4613 * \param transId Transaction identifier
4614 *
4615 * \param peer The Mac address of the station to which this action frame is addressed
4616 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004617 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004619 * \return QDF_STATUS_SUCCESS if setup completes successfully
4620 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 */
4622
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004623QDF_STATUS lim_send_sa_query_request_frame(struct mac_context *mac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004625 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626{
4627
4628 tDot11fSaQueryReq frm; /* SA query request action frame */
4629 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004630 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 tpSirMacMgmtHdr pMacHdr;
4632 uint32_t nBytes, nPayload, nStatus;
4633 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304634 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 uint8_t txFlag = 0;
4636 uint8_t smeSessionId = 0;
4637
hangtian127c9532019-01-12 13:29:07 +08004638 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004639 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 /* 11w action field is :
4641 action: 0 --> SA Query Request action frame
4642 action: 1 --> SA Query Response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004643 frm.Action.action = SA_QUERY_REQUEST;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304645 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646
Jeff Johnson99f25042018-11-21 22:49:06 -08004647 nStatus = dot11f_get_packed_sa_query_req_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004649 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 nStatus);
4651 /* We'll fall back on the worst case scenario: */
4652 nPayload = sizeof(tDot11fSaQueryReq);
4653 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004654 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4655 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 }
4657
4658 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304659 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304661 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004662 pe_err("Failed to allocate %d bytes for a SA Query Request "
4663 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004664 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 }
4666 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004667 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668
4669 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004670 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304671 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672
4673 /* Update A3 with the BSSID */
4674 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4675
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004676 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677
4678 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4679 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004680 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681
4682 /* Pack 11w SA Query Request frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004683 nStatus = dot11f_pack_sa_query_req(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 &frm,
4685 pFrame + sizeof(tSirMacMgmtHdr),
4686 nPayload, &nPayload);
4687
4688 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004689 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004691 /* FIXME - Need to convert to QDF_STATUS */
4692 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 goto returnAfterError;
4694 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004695 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 nStatus);
4697 }
4698
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004699 pe_debug("Sending an SA Query Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004700 lim_print_mac_addr(mac, peer, LOGD);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004701 pe_debug("Sending an SA Query Request from ");
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304702 lim_print_mac_addr(mac, pe_session->self_mac_addr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703
Liangwei Dong419d7302019-07-15 15:38:28 +08004704 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4705 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4706 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304708
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004709 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710
Jeff Johnson99f25042018-11-21 22:49:06 -08004711 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 pPacket,
4713 (uint16_t) nBytes,
4714 TXRX_FRM_802_11_MGMT,
4715 ANI_TXDIR_TODS,
4716 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004717 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304718 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004719 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004720 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721 /* Pkt will be freed up by the callback */
4722 return nSirStatus;
4723 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004724 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725 }
4726
4727returnAfterError:
4728 cds_packet_free((void *)pPacket);
4729 return nSirStatus;
4730} /* End lim_send_sa_query_request_frame */
4731
4732/**
4733 * \brief Send SA query response action frame to peer
4734 *
4735 * \sa lim_send_sa_query_response_frame
4736 *
4737 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004738 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004739 *
4740 * \param transId Transaction identifier received in SA query request action frame
4741 *
4742 * \param peer The Mac address of the AP to which this action frame is addressed
4743 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004744 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004746 * \return QDF_STATUS_SUCCESS if setup completes successfully
4747 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 */
4749
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004750QDF_STATUS lim_send_sa_query_response_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 uint8_t *transId, tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004752 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753{
4754
Jeff Johnson47d75242018-05-12 15:58:53 -07004755 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004756 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004757 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758 tpSirMacMgmtHdr pMacHdr;
4759 uint32_t nBytes, nPayload, nStatus;
4760 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304761 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762 uint8_t txFlag = 0;
4763 uint8_t smeSessionId = 0;
4764
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004765 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766
hangtian127c9532019-01-12 13:29:07 +08004767 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004768 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004769 /*11w action field is :
4770 action: 0 --> SA query request action frame
4771 action: 1 --> SA query response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004772 frm.Action.action = SA_QUERY_RESPONSE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004773 /*11w SA query response transId is same as
4774 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304775 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776
Jeff Johnson99f25042018-11-21 22:49:06 -08004777 nStatus = dot11f_get_packed_sa_query_rsp_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004778 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004779 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004780 nStatus);
4781 /* We'll fall back on the worst case scenario: */
4782 nPayload = sizeof(tDot11fSaQueryRsp);
4783 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004784 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4785 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786 }
4787
4788 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304789 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004790 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304791 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004792 pe_err("Failed to allocate %d bytes for a SA query response"
4793 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004794 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004795 }
4796 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004797 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798
4799 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004800 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304801 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802
4803 /* Update A3 with the BSSID */
4804 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4805
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004806 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807
4808 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4809 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004810 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811
4812 /* Pack 11w SA query response frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004813 nStatus = dot11f_pack_sa_query_rsp(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004814 &frm,
4815 pFrame + sizeof(tSirMacMgmtHdr),
4816 nPayload, &nPayload);
4817
4818 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004819 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004821 /* FIXME - Need to convert to QDF_STATUS */
4822 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004823 goto returnAfterError;
4824 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004825 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004826 nStatus);
4827 }
4828
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004829 pe_debug("Sending a SA Query Response to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004830 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831
Liangwei Dong419d7302019-07-15 15:38:28 +08004832 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4833 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4834 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004836
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304837 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004838 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004839 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004840 pPacket,
4841 (uint16_t) nBytes,
4842 TXRX_FRM_802_11_MGMT,
4843 ANI_TXDIR_TODS,
4844 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004845 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304846 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004847 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304848 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004849 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004850 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851 /* Pkt will be freed up by the callback */
4852 return nSirStatus;
4853 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004854 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 }
4856
4857returnAfterError:
4858 cds_packet_free((void *)pPacket);
4859 return nSirStatus;
4860} /* End lim_send_sa_query_response_frame */
4861#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004862
Manjunathappa Prakash458f6fe2019-05-13 18:33:01 -07004863#if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390) || \
4864 defined(QCA_WIFI_QCA6490)
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004865#ifdef WLAN_FEATURE_11AX
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004866#define IS_PE_SESSION_HE_MODE(_session) ((_session)->he_capable)
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004867#else
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004868#define IS_PE_SESSION_HE_MODE(_session) false
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004869#endif /* WLAN_FEATURE_11AX */
4870#else
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004871#define IS_PE_SESSION_HE_MODE(_session) false
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004872#endif
4873
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004874/**
4875 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4876 * @mac_ctx: mac context
4877 * @peer_mac: Peer MAC address
4878 * @tid: TID for which addba response is being sent
4879 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004880 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004881 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004882 *
4883 * This function is called when ADDBA request is successful. ADDBA response is
4884 * setup by calling addba_response_setup API and frame is then sent out OTA.
4885 *
4886 * Return: QDF_STATUS
4887 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004888QDF_STATUS lim_send_addba_response_frame(struct mac_context *mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004889 tSirMacAddr peer_mac, uint16_t tid,
Jeff Johnsona7815652018-11-18 22:58:30 -08004890 struct pe_session *session, uint8_t addba_extn_present,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004891 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004892{
4893
4894 tDot11faddba_rsp frm;
4895 uint8_t *frame_ptr;
4896 tpSirMacMgmtHdr mgmt_hdr;
4897 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004898 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004899 QDF_STATUS qdf_status;
4900 uint8_t tx_flag = 0;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05304901 uint8_t vdev_id = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004902 uint16_t buff_size, status_code, batimeout;
4903 uint8_t peer_id, dialog_token;
4904 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4905 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004906 uint8_t he_frag = 0;
Yu Wang36d52102019-09-20 12:08:04 +08004907 tpDphHashNode sta_ds;
4908 uint16_t aid;
4909 bool he_cap = false;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004910
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05304911 vdev_id = session->vdev_id;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004912
4913 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4914 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004915 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004916 return QDF_STATUS_E_FAILURE;
4917 }
4918
Mohit Khannac4c22252017-11-20 11:06:33 -08004919 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4920 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004921 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004922 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004923 return QDF_STATUS_E_FAILURE;
4924 }
4925
4926 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4927 &status_code, &buff_size, &batimeout);
4928
Mohit Khannac4c22252017-11-20 11:06:33 -08004929 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
hangtian127c9532019-01-12 13:29:07 +08004930 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004931 frm.Category.category = ACTION_CATEGORY_BACK;
Srinivas Girigowdaef0d7142019-05-17 17:07:47 -07004932 frm.Action.action = ADDBA_RESPONSE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004933
4934 frm.DialogToken.token = dialog_token;
4935 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004936 if (mac_ctx->reject_addba_req) {
4937 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4938 pe_err("refused addba req");
4939 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004940 frm.addba_param_set.tid = tid;
Yu Wang36d52102019-09-20 12:08:04 +08004941
4942 if (lim_is_session_he_capable(session)) {
4943 sta_ds = dph_lookup_hash_entry(mac_ctx, peer_mac, &aid,
4944 &session->dph.dphHashTable);
4945 if (sta_ds)
4946 he_cap = lim_is_sta_he_capable(sta_ds);
4947 }
4948
4949 if (he_cap)
Kiran Kumar Lokere22f05d42019-06-28 18:33:43 -07004950 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4951 else
4952 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Yu Wang36d52102019-09-20 12:08:04 +08004953
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004954 if (mac_ctx->usr_cfg_ba_buff_size)
4955 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07004956
4957 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
4958 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4959
4960 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
4961 if (session->active_ba_64_session) {
4962 frm.addba_param_set.buff_size =
4963 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
4964 }
4965 } else if (!session->active_ba_64_session) {
4966 session->active_ba_64_session = true;
4967 }
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004968
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004969 /* Enable RX AMSDU only in HE mode if supported */
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004970 if (mac_ctx->is_usr_cfg_amsdu_enabled &&
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004971 ((IS_PE_SESSION_HE_MODE(session) &&
4972 WLAN_REG_IS_24GHZ_CH_FREQ(session->curr_op_freq)) ||
4973 WLAN_REG_IS_5GHZ_CH_FREQ(session->curr_op_freq)))
Arif Hussain0e246802018-05-01 18:13:44 -07004974 frm.addba_param_set.amsdu_supp = amsdu_support;
4975 else
4976 frm.addba_param_set.amsdu_supp = 0;
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004977
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004978 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004979 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004980 if (addba_extn_present) {
4981 frm.addba_extn_element.present = 1;
4982 frm.addba_extn_element.no_fragmentation = 1;
4983 if (lim_is_session_he_capable(session)) {
4984 he_frag = lim_get_session_he_frag_cap(session);
4985 if (he_frag != 0) {
4986 frm.addba_extn_element.no_fragmentation = 0;
4987 frm.addba_extn_element.he_frag_operation =
4988 he_frag;
4989 }
4990 }
4991 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004992
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004993 pe_debug("Sending a ADDBA Response from %pM to %pM",
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304994 session->self_mac_addr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004995 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004996 tid, frm.DialogToken.token, frm.Status.status,
4997 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004998 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4999 addba_extn_present,
5000 lim_is_session_he_capable(session),
5001 frm.addba_extn_element.no_fragmentation,
5002 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005003
5004 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
5005 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005006 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005007 status);
5008 /* We'll fall back on the worst case scenario: */
5009 payload_size = sizeof(tDot11faddba_rsp);
5010 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005011 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 -08005012 }
5013
5014 num_bytes = payload_size + sizeof(*mgmt_hdr);
5015 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
5016 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07005017 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005018 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
5019 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005020 return QDF_STATUS_E_FAILURE;
5021 }
hangtian127c9532019-01-12 13:29:07 +08005022 qdf_mem_zero(frame_ptr, num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005023
5024 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05305025 SIR_MAC_MGMT_ACTION, peer_mac, session->self_mac_addr);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005026
5027 /* Update A3 with the BSSID */
5028 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
5029 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
5030
5031 /* ADDBA Response is a robust mgmt action frame,
5032 * set the "protect" (aka WEP) bit in the FC
5033 */
5034 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
5035
5036 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
5037 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
5038 &payload_size);
5039
5040 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005041 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005042 status);
5043 qdf_status = QDF_STATUS_E_FAILURE;
5044 goto error_addba_rsp;
5045 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005046 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005047 status);
5048 }
5049
5050
Liangwei Dong419d7302019-07-15 15:38:28 +08005051 if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
5052 session->opmode == QDF_P2P_CLIENT_MODE ||
5053 session->opmode == QDF_P2P_GO_MODE)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005054 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005055
5056 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
5057 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07005058 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
5059 (uint16_t)num_bytes,
5060 TXRX_FRM_802_11_MGMT,
5061 ANI_TXDIR_TODS, 7,
5062 NULL, frame_ptr,
5063 lim_addba_rsp_tx_complete_cnf,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05305064 tx_flag, vdev_id,
Krunal Sonid2136c72018-06-01 17:26:39 -07005065 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005066 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5067 session->peSessionId, qdf_status));
5068 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005069 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005070 qdf_status);
chenguo90c68462019-01-24 18:27:01 +08005071 return QDF_STATUS_E_FAILURE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005072 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07005073 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005074 }
5075
5076error_addba_rsp:
5077 cds_packet_free((void *)pkt_ptr);
5078 return qdf_status;
5079}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305080
5081/**
5082 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
5083 * @mac_ctx Pointer to Global MAC structure
5084 * @mb_msg: Received message info
5085 * @msg_len: Received message length
5086 * @packet: Packet to be transmitted
5087 * @frame: Received frame
5088 *
5089 * Return: None
5090 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08005091static void lim_tx_mgmt_frame(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305092 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
5093 void *packet, uint8_t *frame)
5094{
5095 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5096 QDF_STATUS qdf_status;
Abhishek Singhefe21e62019-09-20 10:03:24 +05305097 uint8_t vdev_id = 0;
Jeff Johnsona7815652018-11-18 22:58:30 -08005098 struct pe_session *session;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305099 uint16_t auth_ack_status;
5100 enum rateid min_rid = RATEID_DEFAULT;
5101
Abhishek Singh345be412019-11-19 10:59:29 +05305102 vdev_id = mb_msg->vdev_id;
Abhishek Singhefe21e62019-09-20 10:03:24 +05305103 session = pe_find_session_by_vdev_id(mac_ctx, vdev_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07005104 if (!session) {
Wu Gao7c0a23f2019-03-12 14:16:37 +08005105 cds_packet_free((void *)packet);
Abhishek Singhefe21e62019-09-20 10:03:24 +05305106 pe_err("session not found for given vdev_id %d",
5107 vdev_id);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305108 return;
5109 }
5110
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05305111 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
5112 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305113
5114 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
5115 min_rid = lim_get_min_session_txrate(session);
5116
5117 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
5118 (uint16_t)msg_len,
5119 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
5120 7, lim_tx_complete, frame,
5121 lim_auth_tx_complete_cnf,
Abhishek Singhefe21e62019-09-20 10:03:24 +05305122 0, vdev_id, false, 0, min_rid);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305123 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5124 session->peSessionId, qdf_status));
5125 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05305126 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
5127 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305128 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
5129 auth_ack_status = SENT_FAIL;
5130 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005131 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305132 /* Pkt will be freed up by the callback */
5133 }
5134}
5135
Jeff Johnson9320c1e2018-12-02 13:09:20 -08005136void lim_send_mgmt_frame_tx(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305137 struct scheduler_msg *msg)
5138{
5139 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
5140 uint32_t msg_len;
5141 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
Abhishek Singh345be412019-11-19 10:59:29 +05305142 uint8_t vdev_id;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305143 QDF_STATUS qdf_status;
5144 uint8_t *frame;
5145 void *packet;
Srinivas Dasari76218492019-01-22 15:08:20 +05305146 tpSirMacMgmtHdr mac_hdr;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305147
5148 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
5149 pe_debug("sending fc->type: %d fc->subType: %d",
5150 fc->type, fc->subType);
5151
Abhishek Singh345be412019-11-19 10:59:29 +05305152 vdev_id = mb_msg->vdev_id;
Srinivas Dasari76218492019-01-22 15:08:20 +05305153 mac_hdr = (tpSirMacMgmtHdr)mb_msg->data;
5154
5155 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305156
5157 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
5158 (void **)&packet);
5159 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5160 pe_err("call to bufAlloc failed for AUTH frame");
5161 return;
5162 }
5163
5164 qdf_mem_copy(frame, mb_msg->data, msg_len);
5165
5166 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5167}