blob: 85a32264fde8745be6c288dc1e392e38aa22652f [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Alok Kumar2107a962020-01-13 15:35:29 +05302 * Copyright (c) 2011-2020 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
Amruta Kulkarni1d93a852020-02-11 11:05:41 -0800147 * @chan_freq: Channel frequency on which the Probe Request is going out
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148 * @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,
Amruta Kulkarni1d93a852020-02-11 11:05:41 -0800170 qdf_freq_t chan_freq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 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 Kulkarni1d93a852020-02-11 11:05:41 -0800193 uint8_t channel;
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
Amruta Kulkarni1d93a852020-02-11 11:05:41 -0800198 channel = wlan_reg_freq_to_chan(mac_ctx->pdev, chan_freq);
Jeff Johnson919f2c32019-01-16 11:22:24 -0800199 /*
200 * The probe req should not send 11ac capabilities if band is
201 * 2.4GHz, unless gEnableVhtFor24GHzBand is enabled in INI. So
202 * if gEnableVhtFor24GHzBand is false and dot11mode is 11ac
203 * set it to 11n.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 */
205 if (channel <= SIR_11B_CHANNEL_END &&
Abhinav Kumare057b412018-10-09 17:28:16 +0530206 !mac_ctx->mlme_cfg->vht_caps.vht_cap_info.b24ghz_band &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530207 (MLME_DOT11_MODE_11AC == dot11mode ||
208 MLME_DOT11_MODE_11AC_ONLY == dot11mode))
209 dot11mode = MLME_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210 /*
211 * session context may or may not be present, when probe request needs
212 * to be sent out. Following cases exist:
213 * --heartbeat failure: session needed
214 * --join req: session needed
215 * --foreground scan: no session
216 * --background scan: no session
217 * --sch_beacon_processing: to get EDCA parameters: session needed
218 * If session context does not exist, some IEs will be populated from
219 * CFGs, e.g. Supported and Extended rate set IEs
220 */
221 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
222
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700223 if (pesession)
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530224 vdev_id = pesession->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225
226 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
227 /* and then hand it off to 'dot11f_pack_probe_request' (for */
228 /* serialization). We start by zero-initializing the structure: */
hangtian127c9532019-01-12 13:29:07 +0800229 qdf_mem_zero((uint8_t *) &pr, sizeof(pr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230
231 /* & delegating to assorted helpers: */
232 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
233
234 if (addn_ielen && additional_ie)
235 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
236
237 /*
238 * Don't include 11b rate if it is a P2P serach or probe request is
239 * sent by P2P Client
240 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700241 if ((MLME_DOT11_MODE_11B != dot11mode) && (p2pie) &&
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530242 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 /*
244 * In the below API pass channel number > 14, do that it fills
245 * only 11a rates in supported rates
246 */
247 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
248 pesession);
249 } else {
250 populate_dot11f_supp_rates(mac_ctx, channel,
251 &pr.SuppRates, pesession);
252
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530253 if (MLME_DOT11_MODE_11B != dot11mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800254 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
255 &pr.ExtSuppRates);
256 }
257 }
258
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259 /*
260 * Table 7-14 in IEEE Std. 802.11k-2008 says
261 * DS params "can" be present in RRM is disabled and "is" present if
262 * RRM is enabled. It should be ok even if we add it into probe req when
263 * RRM is not enabled.
264 */
265 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
266 /* Call RRM module to get the tx power for management used. */
267 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
268 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
269
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 */
Amruta Kulkarni1d93a852020-02-11 11:05:41 -0800273 if (pesession->htCapability &&
274 !(WLAN_REG_IS_6GHZ_CHAN_FREQ(chan_freq)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700276 } else { /* !pesession */
Amruta Kulkarni1d93a852020-02-11 11:05:41 -0800277 if (IS_DOT11_MODE_HT(dot11mode) &&
278 !(WLAN_REG_IS_6GHZ_CHAN_FREQ(chan_freq)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
280 }
281
282 /*
283 * Set channelbonding information as "disabled" when tunned to a
284 * 2.4 GHz channel
285 */
Amruta Kulkarni1d93a852020-02-11 11:05:41 -0800286 if (channel <= SIR_11B_CHANNEL_END &&
287 !(WLAN_REG_IS_6GHZ_CHAN_FREQ(chan_freq))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 if (mac_ctx->roam.configParam.channelBondingMode24GHz
289 == PHY_SINGLE_CHANNEL_CENTERED) {
290 pr.HTCaps.supportedChannelWidthSet =
291 eHT_CHANNEL_WIDTH_20MHZ;
292 pr.HTCaps.shortGI40MHz = 0;
293 } else {
294 pr.HTCaps.supportedChannelWidthSet =
295 eHT_CHANNEL_WIDTH_40MHZ;
296 }
297 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700298 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
300 /* Include VHT Capability IE */
Amruta Kulkarni1d93a852020-02-11 11:05:41 -0800301 if (pesession->vhtCapability &&
302 !(WLAN_REG_IS_6GHZ_CHAN_FREQ(chan_freq))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303 populate_dot11f_vht_caps(mac_ctx, pesession,
304 &pr.VHTCaps);
305 is_vht_enabled = true;
306 }
307 } else {
Amruta Kulkarni1d93a852020-02-11 11:05:41 -0800308 if (IS_DOT11_MODE_VHT(dot11mode) &&
309 !(WLAN_REG_IS_6GHZ_CHAN_FREQ(chan_freq))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310 populate_dot11f_vht_caps(mac_ctx, pesession,
311 &pr.VHTCaps);
312 is_vht_enabled = true;
313 }
314 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700315 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
317 pesession);
318
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700319 if (IS_DOT11_MODE_HE(dot11mode) && pesession)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800320 lim_update_session_he_capable(mac_ctx, pesession);
321
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700322 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700323 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -0700324 populate_dot11f_he_6ghz_cap(mac_ctx, pesession,
325 &pr.he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800326
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700327 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530328 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
329 sizeof(tDot11fIEExtCap));
330 sir_status = lim_strip_extcap_update_struct(mac_ctx,
331 additional_ie,
332 &addn_ielen,
333 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700334 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700335 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530336 } else {
337 struct s_ext_cap *p_ext_cap =
338 (struct s_ext_cap *)
339 extracted_ext_cap.bytes;
340 if (p_ext_cap->interworking_service)
341 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800342 extracted_ext_cap.num_bytes =
343 lim_compute_ext_cap_ie_length
344 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530345 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800346 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700347 if (additional_ielen)
348 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530349 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530350 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
351 SIR_MAC_QCN_OUI_TYPE_SIZE,
352 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530354 /* Add qcn_ie only if qcn ie is not present in additional_ie */
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -0700355 if (!qcn_ie)
356 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie, QCN_IE_ATTR_ID_ALL);
357 else
358 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie,
359 QCN_IE_ATTR_ID_VHT_MCS11);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360
Hu Wang411e0cc2016-10-28 14:56:01 +0800361 /*
362 * Extcap IE now support variable length, merge Extcap IE from addn_ie
363 * may change the frame size. Therefore, MUST merge ExtCap IE before
364 * dot11f get packed payload size.
365 */
366 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800367 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800368
369 /* That's it-- now we pack it. First, how much space are we going to */
370 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
371 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700372 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800373 status);
374 /* We'll fall back on the worst case scenario: */
375 payload = sizeof(tDot11fProbeRequest);
376 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700377 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800378 status);
379 }
380
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
382
383 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530384 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530386 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700387 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700388 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389 }
390 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800391 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392
393 /* Next, we fill out the buffer descriptor: */
394 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
395 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
396
397 /* That done, pack the Probe Request: */
398 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
399 sizeof(tSirMacMgmtHdr),
400 payload, &payload);
401 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700402 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700404 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700406 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407 }
408 /* Append any AddIE if present. */
409 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530410 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 additional_ie, addn_ielen);
412 payload += addn_ielen;
413 }
414
415 /* If this probe request is sent during P2P Search State, then we need
416 * to send it at OFDM rate.
417 */
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800418 if ((REG_BAND_5G == lim_get_rf_band(chan_freq)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800419 /*
420 * For unicast probe req mgmt from Join function we don't set
421 * above variables. So we need to add one more check whether it
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530422 * is opmode is P2P_CLIENT or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530424 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530427 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 wma_tx_frame(mac_ctx, packet,
429 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
430 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530431 lim_tx_complete, frame, txflag, vdev_id,
Naveen Rawat296a5182017-09-25 14:02:48 -0700432 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530433 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700434 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700436 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 }
438
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700439 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440} /* End lim_send_probe_req_mgmt_frame. */
441
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800442static QDF_STATUS lim_get_addn_ie_for_probe_resp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 uint8_t *addIE, uint16_t *addnIELen,
444 uint8_t probeReqP2pIe)
445{
446 /* If Probe request doesn't have P2P IE, then take out P2P IE
447 from additional IE */
448 if (!probeReqP2pIe) {
449 uint8_t *tempbuf = NULL;
450 uint16_t tempLen = 0;
451 int left = *addnIELen;
452 uint8_t *ptr = addIE;
453 uint8_t elem_id, elem_len;
454
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700455 if (!addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700456 pe_err("NULL addIE pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700457 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 }
459
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530460 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700461 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700462 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800463
464 while (left >= 2) {
465 elem_id = ptr[0];
466 elem_len = ptr[1];
467 left -= 2;
468 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700469 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530471 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700472 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800473 }
Srinivas Girigowda61771262019-04-01 11:55:19 -0700474 if (!((WLAN_ELEMID_VENDOR == elem_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475 (memcmp
476 (&ptr[2], SIR_MAC_P2P_OUI,
477 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530478 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 elem_len + 2);
480 tempLen += (elem_len + 2);
481 }
482 left -= elem_len;
483 ptr += (elem_len + 2);
484 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530485 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530487 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700489 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490}
491
Wu Gao88053692019-12-11 12:17:13 +0800492/**
493 * lim_add_additional_ie() - Add additional IE to management frame
494 * @frame: pointer to frame
495 * @frame_offset: current offset of frame
496 * @add_ie: pointer to addtional ie
497 * @add_ie_len: length of addtional ie
498 * @p2p_ie: pointer to p2p ie
499 * @noa_ie: pointer to noa ie, this is seperate p2p ie
500 * @noa_ie_len: length of noa ie
501 * @noa_stream: pointer to noa stream, this is noa attribute only
502 * @noa_stream_len: length of noa stream
503 *
504 * This function adds additional IE to management frame.
505 *
506 * Return: None
507 */
508static void lim_add_additional_ie(uint8_t *frame, uint32_t frame_offset,
509 uint8_t *add_ie, uint32_t add_ie_len,
510 uint8_t *p2p_ie, uint8_t *noa_ie,
511 uint32_t noa_ie_len, uint8_t *noa_stream,
512 uint32_t noa_stream_len) {
513 uint16_t p2p_ie_offset;
514
515 if (!add_ie_len || !add_ie) {
516 pe_debug("no valid addtional ie");
517 return;
518 }
519
520 if (!noa_stream_len) {
521 qdf_mem_copy(frame + frame_offset, &add_ie[0], add_ie_len);
522 return;
523 }
524
525 if (noa_ie_len > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
526 pe_err("Not able to insert NoA, len=%d", noa_ie_len);
527 return;
528 } else if (noa_ie_len > 0) {
529 pe_debug("new p2p ie for noa attr");
530 qdf_mem_copy(frame + frame_offset, &add_ie[0], add_ie_len);
531 frame_offset += add_ie_len;
532 qdf_mem_copy(frame + frame_offset, &noa_ie[0], noa_ie_len);
533 } else {
534 if (!p2p_ie || (p2p_ie < add_ie) ||
535 (p2p_ie > (add_ie + add_ie_len))) {
536 pe_err("invalid p2p ie");
537 return;
538 }
539 p2p_ie_offset = p2p_ie - add_ie + p2p_ie[1] + 2;
540 if (p2p_ie_offset > add_ie_len) {
541 pe_err("Invalid p2p ie");
542 return;
543 }
544 pe_debug("insert noa attr to existed p2p ie");
545 p2p_ie[1] = p2p_ie[1] + noa_stream_len;
546 qdf_mem_copy(frame + frame_offset, &add_ie[0], p2p_ie_offset);
547 frame_offset += p2p_ie_offset;
548 qdf_mem_copy(frame + frame_offset, &noa_stream[0],
549 noa_stream_len);
550 if (p2p_ie_offset < add_ie_len) {
551 frame_offset += noa_stream_len;
552 qdf_mem_copy(frame + frame_offset,
553 &add_ie[p2p_ie_offset],
554 add_ie_len - p2p_ie_offset);
555 }
556 }
557}
558
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800559void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800560lim_send_probe_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 tSirMacAddr peer_macaddr,
562 tpAniSSID ssid,
Jeff Johnson3c08ace2019-03-12 08:50:37 -0700563 struct pe_session *pe_session,
564 uint8_t preq_p2pie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565{
566 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700567 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800568 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569 tpSirMacMgmtHdr mac_hdr;
570 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700571 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530572 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573 uint32_t addn_ie_present = false;
574
575 uint16_t addn_ie_len = 0;
gaurank kathpalia837f6202018-09-14 21:55:32 +0530576 bool wps_ap = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577 uint8_t tx_flag = 0;
578 uint8_t *add_ie = NULL;
Wu Gao88053692019-12-11 12:17:13 +0800579 uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 uint8_t noalen = 0;
581 uint8_t total_noalen = 0;
582 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
583 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530584 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530586 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530587 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588
589 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700590 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 return;
592
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700593 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 return;
595
596 /*
597 * In case when cac timer is running for this SAP session then
598 * avoid sending probe rsp out. It is violation of dfs specification.
599 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530600 if (((pe_session->opmode == QDF_SAP_MODE) ||
601 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800602 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530603 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604 FL("CAC timer is running, probe response dropped"));
605 return;
606 }
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530607 vdev_id = pe_session->vdev_id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530608 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700609 if (!frm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 /*
613 * Fill out 'frm', after which we'll just hand the struct off to
614 * 'dot11f_pack_probe_response'.
615 */
hangtian127c9532019-01-12 13:29:07 +0800616 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617
618 /*
619 * Timestamp to be updated by TFP, below.
620 *
621 * Beacon Interval:
622 */
623 if (LIM_IS_AP_ROLE(pe_session)) {
624 frm->BeaconInterval.interval =
Jeff Johnsonac057412019-01-06 11:08:55 -0800625 mac_ctx->sch.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800626 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530627 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800628 frm->BeaconInterval.interval = (uint16_t) cfg;
629 }
630
631 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
632 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
633 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
634 &frm->SuppRates, pe_session);
635
Liangwei Dong419d7302019-07-15 15:38:28 +0800636 populate_dot11f_ds_params(
637 mac_ctx, &frm->DSParams,
638 wlan_reg_freq_to_chan(mac_ctx->pdev,
639 pe_session->curr_op_freq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
641
642 if (LIM_IS_AP_ROLE(pe_session)) {
643 if (pe_session->wps_state != SAP_WPS_DISABLED)
644 populate_dot11f_probe_res_wpsi_es(mac_ctx,
645 &frm->WscProbeRes,
646 pe_session);
647 } else {
gaurank kathpalia837f6202018-09-14 21:55:32 +0530648 wps_ap = mac_ctx->mlme_cfg->wps_params.enable_wps &
649 WNI_CFG_WPS_ENABLE_AP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650 if (wps_ap)
651 populate_dot11f_wsc_in_probe_res(mac_ctx,
652 &frm->WscProbeRes);
653
654 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
655 eLIM_WSC_ENROLL_BEGIN) {
656 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
657 &frm->WscProbeRes);
658 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
659 eLIM_WSC_ENROLL_IN_PROGRESS;
660 }
661
662 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
663 eLIM_WSC_ENROLL_END) {
664 de_populate_dot11f_wsc_registrar_info_in_probe_res(
665 mac_ctx, &frm->WscProbeRes);
666 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
667 eLIM_WSC_ENROLL_NOOP;
668 }
669 }
670
671 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
672 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
673
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530674 if (pe_session->dot11mode != MLME_DOT11_MODE_11B)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
676
677 populate_dot11f_ext_supp_rates(mac_ctx,
678 POPULATE_DOT11F_RATES_OPERATIONAL,
679 &frm->ExtSuppRates, pe_session);
680
681 /* Populate HT IEs, when operating in 11n */
682 if (pe_session->htCapability) {
683 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
684 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
685 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700687 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
689 populate_dot11f_vht_operation(mac_ctx, pe_session,
690 &frm->VHTOperation);
691 /*
692 * we do not support multi users yet.
693 * populate_dot11f_vht_ext_bss_load( mac_ctx,
694 * &frm.VHTExtBssLoad );
695 */
696 is_vht_enabled = true;
697 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800699 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700700 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800701 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700702 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800703 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700704 &frm->he_op);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -0700705 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
706 &frm->he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800707 }
708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
710 pe_session);
711
712 if (pe_session->pLimStartBssReq) {
713 populate_dot11f_wpa(mac_ctx,
714 &(pe_session->pLimStartBssReq->rsnIE),
715 &frm->WPA);
716 populate_dot11f_rsn_opaque(mac_ctx,
717 &(pe_session->pLimStartBssReq->rsnIE),
718 &frm->RSNOpaque);
719 }
720
721 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
722 &frm->WMMCaps, pe_session);
723
724#if defined(FEATURE_WLAN_WAPI)
725 if (pe_session->pLimStartBssReq)
726 populate_dot11f_wapi(mac_ctx,
727 &(pe_session->pLimStartBssReq->rsnIE),
728 &frm->WAPI);
729#endif /* defined(FEATURE_WLAN_WAPI) */
730
Liangwei Dongd7c5e012018-12-16 23:56:50 -0500731 /*
732 * Only use CFG for non-listen mode. This CFG is not working for
733 * concurrency. In listening mode, probe rsp IEs is passed in
734 * the message from SME to PE.
735 */
736 addn_ie_present =
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800737 (pe_session->add_ie_params.probeRespDataLen != 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738
739 if (addn_ie_present) {
740
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530741 add_ie = qdf_mem_malloc(
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800742 pe_session->add_ie_params.probeRespDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700743 if (!add_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744 goto err_ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530746 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800747 pe_session->add_ie_params.probeRespData_buff,
748 pe_session->add_ie_params.probeRespDataLen);
749 addn_ie_len = pe_session->add_ie_params.probeRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700751 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700753 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 goto err_ret;
755 }
756
757 sir_status = lim_strip_extcap_update_struct(mac_ctx,
758 add_ie, &addn_ie_len,
759 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700760 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700761 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530762 } else {
763 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 }
765
766 bytes = bytes + addn_ie_len;
767
768 if (preq_p2pie)
Wu Gao88053692019-12-11 12:17:13 +0800769 p2p_ie = (uint8_t *)limGetP2pIEPtr(mac_ctx, &add_ie[0],
770 addn_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700772 if (p2p_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773 /* get NoA attribute stream P2P IE */
774 noalen = lim_get_noa_attr_stream(mac_ctx,
775 noa_stream, pe_session);
Wu Gao88053692019-12-11 12:17:13 +0800776 if (noalen) {
777 if ((p2p_ie[1] + noalen) >
778 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN) {
779 total_noalen = lim_build_p2p_ie(
780 mac_ctx,
781 &noa_ie[0],
782 &noa_stream[0],
783 noalen);
784 bytes = bytes + total_noalen;
785 } else {
786 bytes = bytes + noalen;
787 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 }
789 }
790 }
791
Hu Wang411e0cc2016-10-28 14:56:01 +0800792 /*
793 * Extcap IE now support variable length, merge Extcap IE from addn_ie
794 * may change the frame size. Therefore, MUST merge ExtCap IE before
795 * dot11f get packed payload size.
796 */
797 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800798 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
799 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800800
801 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
802 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700803 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800804 status);
805 /* We'll fall back on the worst case scenario: */
806 payload = sizeof(tDot11fProbeResponse);
807 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700808 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800809 status);
810 }
811
812 bytes += payload + sizeof(tSirMacMgmtHdr);
813
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530814 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530816 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700817 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 goto err_ret;
819 }
820 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800821 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822
823 /* Next, we fill out the buffer descriptor: */
824 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
825 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530826 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827
828 mac_hdr = (tpSirMacMgmtHdr) frame;
829
830 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
831
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832 /* That done, pack the Probe Response: */
833 status =
834 dot11f_pack_probe_response(mac_ctx, frm,
835 frame + sizeof(tSirMacMgmtHdr),
836 payload, &payload);
837 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700838 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 status);
840 goto err_ret;
841 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700842 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 }
844
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700845 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530846 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
Wu Gao88053692019-12-11 12:17:13 +0800848 lim_add_additional_ie(frame, sizeof(tSirMacMgmtHdr) + payload, add_ie,
849 addn_ie_len, p2p_ie, noa_ie, total_noalen,
850 noa_stream, noalen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851
Liangwei Dong419d7302019-07-15 15:38:28 +0800852 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
853 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
854 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
856
857 /* Queue Probe Response frame in high priority WQ */
Jeff Johnson59429b02018-11-07 13:53:18 -0800858 qdf_status = wma_tx_frame(mac_ctx, packet,
859 (uint16_t)bytes,
860 TXRX_FRM_802_11_MGMT,
861 ANI_TXDIR_TODS,
862 7, lim_tx_complete, frame, tx_flag,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530863 vdev_id, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864
865 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530866 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700867 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700869 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530870 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530872 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 return;
874
875err_ret:
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700876 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530877 qdf_mem_free(add_ie);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700878 if (frm)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530879 qdf_mem_free(frm);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700880 if (packet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 cds_packet_free((void *)packet);
882 return;
883
884} /* End lim_send_probe_rsp_mgmt_frame. */
885
886void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800887lim_send_addts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 tSirMacAddr peerMacAddr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800889 tSirAddtsReqInfo *pAddTS, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890{
891 uint16_t i;
892 uint8_t *pFrame;
893 tDot11fAddTSRequest AddTSReq;
894 tDot11fWMMAddTSRequest WMMAddTSReq;
895 uint32_t nPayload, nBytes, nStatus;
896 tpSirMacMgmtHdr pMacHdr;
897 void *pPacket;
898#ifdef FEATURE_WLAN_ESE
899 uint32_t phyMode;
900#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530901 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 uint8_t txFlag = 0;
903 uint8_t smeSessionId = 0;
904
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700905 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 return;
907 }
908
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800909 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910
911 if (!pAddTS->wmeTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +0800912 qdf_mem_zero((uint8_t *) &AddTSReq, sizeof(AddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700914 AddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 AddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700916 AddTSReq.Category.category = ACTION_CATEGORY_QOS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917 if (pAddTS->lleTspecPresent) {
918 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
919 } else {
920 populate_dot11f_wmmtspec(&pAddTS->tspec,
921 &AddTSReq.WMMTSPEC);
922 }
923
924 if (pAddTS->lleTspecPresent) {
925 AddTSReq.num_WMMTCLAS = 0;
926 AddTSReq.num_TCLAS = pAddTS->numTclas;
927 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800928 populate_dot11f_tclas(mac, &pAddTS->tclasInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 &AddTSReq.TCLAS[i]);
930 }
931 } else {
932 AddTSReq.num_TCLAS = 0;
933 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
934 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800935 populate_dot11f_wmmtclas(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 &pAddTS->tclasInfo[i],
937 &AddTSReq.WMMTCLAS[i]);
938 }
939 }
940
941 if (pAddTS->tclasProcPresent) {
942 if (pAddTS->lleTspecPresent) {
943 AddTSReq.TCLASSPROC.processing =
944 pAddTS->tclasProc;
945 AddTSReq.TCLASSPROC.present = 1;
946 } else {
947 AddTSReq.WMMTCLASPROC.version = 1;
948 AddTSReq.WMMTCLASPROC.processing =
949 pAddTS->tclasProc;
950 AddTSReq.WMMTCLASPROC.present = 1;
951 }
952 }
953
954 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800955 dot11f_get_packed_add_ts_request_size(mac, &AddTSReq, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700957 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
958 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 /* We'll fall back on the worst case scenario: */
960 nPayload = sizeof(tDot11fAddTSRequest);
961 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700962 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
963 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 }
965 } else {
hangtian127c9532019-01-12 13:29:07 +0800966 qdf_mem_zero((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700968 WMMAddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700970 WMMAddTSReq.Category.category = ACTION_CATEGORY_WMM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971
972 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
973 WMMAddTSReq.StatusCode.statusCode = 0;
974
975 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
976#ifdef FEATURE_WLAN_ESE
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800977 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978
979 if (phyMode == WNI_CFG_PHY_MODE_11G
980 || phyMode == WNI_CFG_PHY_MODE_11A) {
981 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
982 } else {
983 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
984 }
Jeff Johnson99f25042018-11-21 22:49:06 -0800985 populate_dot11_tsrsie(mac, &pAddTS->tsrsIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 &WMMAddTSReq.ESETrafStrmRateSet,
987 sizeof(uint8_t));
988#endif
989 /* fillWmeTspecIE */
990
991 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800992 dot11f_get_packed_wmm_add_ts_request_size(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 &nPayload);
994 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700995 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 nStatus);
997 /* We'll fall back on the worst case scenario: */
998 nPayload = sizeof(tDot11fAddTSRequest);
999 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001000 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
1001 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 }
1003 }
1004
1005 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1006
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301007 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301009 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001010 pe_err("Failed to allocate %d bytes for an Add TS Request",
1011 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 return;
1013 }
1014 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001015 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001016
1017 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08001018 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301019 SIR_MAC_MGMT_ACTION, peerMacAddr, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1021
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001022 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001024 lim_set_protected_bit(mac, pe_session, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025
1026 /* That done, pack the struct: */
1027 if (!pAddTS->wmeTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -08001028 nStatus = dot11f_pack_add_ts_request(mac, &AddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 pFrame +
1030 sizeof(tSirMacMgmtHdr),
1031 nPayload, &nPayload);
1032 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001033 pe_err("Failed to pack an Add TS Request "
1034 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 cds_packet_free((void *)pPacket);
1036 return; /* allocated! */
1037 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001038 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1039 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 }
1041 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -08001042 nStatus = dot11f_pack_wmm_add_ts_request(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 pFrame +
1044 sizeof(tSirMacMgmtHdr),
1045 nPayload, &nPayload);
1046 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001047 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1048 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 cds_packet_free((void *)pPacket);
1050 return; /* allocated! */
1051 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001052 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1053 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 }
1055 }
1056
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001057 pe_debug("Sending an Add TS Request frame to");
Jeff Johnson99f25042018-11-21 22:49:06 -08001058 lim_print_mac_addr(mac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059
Liangwei Dong419d7302019-07-15 15:38:28 +08001060 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1061 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1062 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301065 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001066 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001067 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001068 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001069 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070
1071 /* Queue Addts Response frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08001072 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 TXRX_FRM_802_11_MGMT,
1074 ANI_TXDIR_TODS,
1075 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001076 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301077 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001078 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001080 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1081 pe_err("Could not send an Add TS Request (%X",
1082 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083} /* End lim_send_addts_req_action_frame. */
1084
1085/**
bings85512332019-09-04 17:46:37 +08001086 * lim_assoc_rsp_tx_complete() - Confirmation for assoc rsp OTA
1087 * @context: pointer to global mac
1088 * @buf: buffer which is nothing but entire assoc rsp frame
1089 * @tx_complete : Sent status
1090 * @params; tx completion params
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 *
bings85512332019-09-04 17:46:37 +08001092 * Return: This returns QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 */
bings85512332019-09-04 17:46:37 +08001094static QDF_STATUS lim_assoc_rsp_tx_complete(
1095 void *context,
1096 qdf_nbuf_t buf,
1097 uint32_t tx_complete,
1098 void *params)
1099{
1100 struct mac_context *mac_ctx = (struct mac_context *)context;
1101 tSirMacMgmtHdr *mac_hdr;
1102 struct pe_session *session_entry;
1103 uint8_t session_id;
1104 tpLimMlmAssocInd lim_assoc_ind;
1105 tpDphHashNode sta_ds;
1106 uint16_t aid;
1107 uint8_t *data;
1108 struct assoc_ind *sme_assoc_ind;
1109 struct scheduler_msg msg;
1110 tpSirAssocReq assoc_req;
1111
1112 if (!buf) {
1113 pe_err("Assoc rsp frame buffer is NULL");
1114 goto null_buf;
1115 }
1116
1117 data = qdf_nbuf_data(buf);
1118
1119 if (!data) {
1120 pe_err("Assoc rsp frame is NULL");
1121 goto end;
1122 }
1123
1124 mac_hdr = (tSirMacMgmtHdr *)data;
1125
1126 session_entry = pe_find_session_by_bssid(
1127 mac_ctx, mac_hdr->sa,
1128 &session_id);
1129 if (!session_entry) {
1130 pe_err("session entry is NULL");
1131 goto end;
1132 }
1133
1134 sta_ds = dph_lookup_hash_entry(mac_ctx,
1135 (uint8_t *)mac_hdr->da, &aid,
1136 &session_entry->dph.dphHashTable);
1137 if (!sta_ds) {
1138 pe_err("sta_ds is NULL");
1139 goto end;
1140 }
1141
1142 /* Get a copy of the already parsed Assoc Request */
1143 assoc_req =
1144 (tpSirAssocReq)session_entry->parsedAssocReq[sta_ds->assocId];
1145
1146 if (!assoc_req) {
1147 pe_err("assoc req for assoc_id:%d is NULL", sta_ds->assocId);
1148 goto end;
1149 }
1150
1151 lim_assoc_ind = qdf_mem_malloc(sizeof(tLimMlmAssocInd));
1152 if (!lim_assoc_ind) {
1153 pe_err("lim assoc ind is NULL");
1154 goto free_assoc_req;
1155 }
1156 if (!lim_fill_lim_assoc_ind_params(lim_assoc_ind, mac_ctx,
1157 sta_ds, session_entry)) {
1158 pe_err("lim assoc ind fill error");
1159 goto lim_assoc_ind;
1160 }
1161
1162 sme_assoc_ind = qdf_mem_malloc(sizeof(struct assoc_ind));
1163 if (!sme_assoc_ind) {
1164 pe_err("sme assoc ind is NULL");
1165 goto lim_assoc_ind;
1166 }
1167 sme_assoc_ind->messageType = eWNI_SME_ASSOC_IND_UPPER_LAYER;
1168 lim_fill_sme_assoc_ind_params(
1169 mac_ctx, lim_assoc_ind,
1170 sme_assoc_ind,
Chaoli Zhou98d1b3e2019-10-10 17:13:44 +08001171 session_entry, true);
bings85512332019-09-04 17:46:37 +08001172
1173 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
1174 msg.type = eWNI_SME_ASSOC_IND_UPPER_LAYER;
1175 msg.bodyptr = sme_assoc_ind;
1176 msg.bodyval = 0;
bings85512332019-09-04 17:46:37 +08001177 sme_assoc_ind->reassocReq = sta_ds->mlmStaContext.subType;
1178 sme_assoc_ind->timingMeasCap = sta_ds->timingMeasCap;
Chaoli Zhou98d1b3e2019-10-10 17:13:44 +08001179 MTRACE(mac_trace_msg_tx(mac_ctx, session_entry->peSessionId, msg.type));
1180 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
bings85512332019-09-04 17:46:37 +08001181
1182 qdf_mem_free(lim_assoc_ind);
1183 if (assoc_req->assocReqFrame) {
1184 qdf_mem_free(assoc_req->assocReqFrame);
1185 assoc_req->assocReqFrame = NULL;
1186 }
1187 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
1188 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
1189 qdf_nbuf_free(buf);
1190
1191 return QDF_STATUS_SUCCESS;
1192
1193lim_assoc_ind:
1194 qdf_mem_free(lim_assoc_ind);
1195free_assoc_req:
1196 if (assoc_req->assocReqFrame) {
1197 qdf_mem_free(assoc_req->assocReqFrame);
1198 assoc_req->assocReqFrame = NULL;
1199 }
1200 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
1201 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
1202end:
1203 qdf_nbuf_free(buf);
1204null_buf:
1205 return QDF_STATUS_E_FAILURE;
1206}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207
1208void
bings85512332019-09-04 17:46:37 +08001209lim_send_assoc_rsp_mgmt_frame(
1210 struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
bings85512332019-09-04 17:46:37 +08001212 uint8_t subtype, tpDphHashNode sta, struct pe_session *pe_session,
1213 bool tx_complete)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214{
1215 static tDot11fAssocResponse frm;
1216 uint8_t *frame;
1217 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001218 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219 uint8_t lle_mode = 0, addts;
1220 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001221 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301223 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001224 tUpdateBeaconParams beacon_params;
1225 uint8_t tx_flag = 0;
1226 uint32_t addn_ie_len = 0;
1227 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1228 tpSirAssocReq assoc_req = NULL;
1229 uint8_t sme_session = 0;
1230 bool is_vht = false;
1231 uint16_t stripoff_len = 0;
1232 tDot11fIEExtCap extracted_ext_cap;
1233 bool extracted_flag = false;
1234#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301235 uint8_t retry_int;
1236 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237#endif
1238
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001239 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001240 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 return;
1242 }
1243
1244 sme_session = pe_session->smeSessionId;
1245
hangtian127c9532019-01-12 13:29:07 +08001246 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247
1248 limGetQosMode(pe_session, &qos_mode);
1249 limGetWmeMode(pe_session, &wme_mode);
1250
1251 /*
1252 * An Add TS IE is added only if the AP supports it and
1253 * the requesting STA sent a traffic spec.
1254 */
1255 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1256
1257 frm.Status.status = status_code;
1258
1259 frm.AID.associd = aid | LIM_AID_MASK;
1260
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001261 if (!sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 populate_dot11f_supp_rates(mac_ctx,
1263 POPULATE_DOT11F_RATES_OPERATIONAL,
1264 &frm.SuppRates, pe_session);
1265 populate_dot11f_ext_supp_rates(mac_ctx,
1266 POPULATE_DOT11F_RATES_OPERATIONAL,
1267 &frm.ExtSuppRates, pe_session);
1268 } else {
1269 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1270 &frm.ExtSuppRates,
1271 sta->supportedRates.llbRates,
1272 sta->supportedRates.llaRates);
1273 }
1274
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001275 if (LIM_IS_AP_ROLE(pe_session) && sta &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001276 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 assoc_req = (tpSirAssocReq)
1278 pe_session->parsedAssocReq[sta->assocId];
1279 /*
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05301280 * populate P2P IE in AssocRsp when assoc_req from the peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281 * includes P2P IE
1282 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001283 if (assoc_req && assoc_req->addIEPresent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1285 &frm.P2PAssocRes,
1286 assoc_req);
1287 }
1288
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001289 if (sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 if (eHAL_SET == qos_mode) {
1291 if (sta->lleEnabled) {
1292 lle_mode = 1;
1293 populate_dot11f_edca_param_set(mac_ctx,
1294 &frm.EDCAParamSet, pe_session);
1295 }
1296 }
1297
1298 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1299 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1300 pe_session);
1301
1302 if (sta->wsmEnabled)
1303 populate_dot11f_wmm_caps(&frm.WMMCaps);
1304 }
1305
1306 if (sta->mlmStaContext.htCapability &&
1307 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001308 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 populate_dot11f_ht_caps(mac_ctx, pe_session,
1310 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001311 /*
1312 * Check the STA capability and
1313 * update the HTCaps accordingly
1314 */
1315 frm.HTCaps.supportedChannelWidthSet = (
1316 sta->htSupportedChannelWidthSet <
1317 pe_session->htSupportedChannelWidthSet) ?
1318 sta->htSupportedChannelWidthSet :
1319 pe_session->htSupportedChannelWidthSet;
1320 if (!frm.HTCaps.supportedChannelWidthSet)
1321 frm.HTCaps.shortGI40MHz = 0;
1322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301324 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001326 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 +05301327 frm.HTCaps.supportedChannelWidthSet,
1328 frm.HTCaps.mimoPowerSave,
1329 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1330 frm.HTCaps.shortGI40MHz,
1331 frm.HTCaps.dsssCckMode40MHz,
1332 frm.HTCaps.maxRxAMPDUFactor);
1333
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 if (sta->mlmStaContext.vhtCapability &&
1335 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001336 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 populate_dot11f_vht_caps(mac_ctx, pe_session,
1338 &frm.VHTCaps);
1339 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301340 &frm.VHTOperation);
1341 is_vht = true;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301342 } else if (sta->mlmStaContext.force_1x1 &&
1343 frm.HTCaps.present) {
1344 /*
1345 * WAR: In P2P GO mode, if the P2P client device
1346 * is only HT capable and not VHT capable, but the P2P
1347 * GO device is VHT capable and advertises 2x2 NSS with
1348 * HT capablity client device, which results in IOT
1349 * issues.
1350 * When GO is operating in DBS mode, GO beacons
1351 * advertise 2x2 capability but include OMN IE to
1352 * indicate current operating mode of 1x1. But here
1353 * peer device is only HT capable and will not
1354 * understand OMN IE.
1355 */
1356 frm.HTInfo.basicMCSSet[1] = 0;
1357 frm.HTCaps.supportedMCSSet[1] = 0;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301358 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001359
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301360 if (pe_session->vhtCapability &&
1361 pe_session->vendor_vht_sap &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001362 (assoc_req) &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301363 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001364 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301365 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001366 frm.vendor_vht_ie.sub_type =
1367 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301368 frm.vendor_vht_ie.VHTCaps.present = 1;
1369 populate_dot11f_vht_caps(mac_ctx, pe_session,
1370 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001371 populate_dot11f_vht_operation(mac_ctx, pe_session,
1372 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 is_vht = true;
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07001374 populate_dot11f_qcn_ie(mac_ctx, &frm.qcn_ie,
1375 QCN_IE_ATTR_ID_ALL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1378 pe_session);
1379
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001380 if (lim_is_sta_he_capable(sta) &&
1381 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001382 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001383 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001384 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001385 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001386 &frm.he_op);
Kiran Kumar Lokereb2ea0272019-08-27 19:16:36 -07001387 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
1388 &frm.he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001389 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390#ifdef WLAN_FEATURE_11W
1391 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301392 max_retries =
1393 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1394 retry_int =
1395 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1396 populate_dot11f_timeout_interval(mac_ctx,
1397 &frm.TimeoutInterval,
1398 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1399 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 sta->pmfSaQueryRetryCount)
1401 * retry_int);
1402 }
1403#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001404
1405 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1406 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 }
1408
hangtian127c9532019-01-12 13:29:07 +08001409 qdf_mem_zero((uint8_t *) &beacon_params, sizeof(beacon_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410
1411 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301412 (pe_session->gLimProtectionControl !=
1413 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1414 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1415 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416
1417 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1418 pe_session);
1419 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1420 pe_session);
1421
1422 /*
1423 * Populate Do11capabilities after updating session with
1424 * Assos req details
1425 */
1426 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1427
Abhishek Singhc70afa32019-09-19 15:17:21 +05301428 beacon_params.bss_idx = pe_session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429
1430 /* Send message to HAL about beacon parameter change. */
1431 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1432 && beacon_params.paramChangeBitmap) {
1433 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1434 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1435 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436
Arif Hussain1513cb22018-01-05 19:56:31 -08001437 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1438
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001439 if (assoc_req) {
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001440 addn_ie_len = pe_session->add_ie_params.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441
1442 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001443 if (addn_ie_len > 0 &&
1444 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1445 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301446 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001447 pe_session->add_ie_params.assocRespData_buff,
1448 pe_session->add_ie_params.assocRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449
hangtian127c9532019-01-12 13:29:07 +08001450 qdf_mem_zero((uint8_t *) &extracted_ext_cap,
1451 sizeof(extracted_ext_cap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452
1453 stripoff_len = addn_ie_len;
1454 sir_status =
1455 lim_strip_extcap_update_struct
1456 (mac_ctx, &add_ie[0], &stripoff_len,
1457 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001458 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001459 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 } else {
1461 addn_ie_len = stripoff_len;
1462 extracted_flag = true;
1463 }
1464 bytes = bytes + addn_ie_len;
1465 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001466 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 addn_ie_len, assoc_req->addIEPresent);
1468 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001469
1470 /*
1471 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1472 * may change the frame size. Therefore, MUST merge ExtCap IE before
1473 * dot11f get packed payload size.
1474 */
1475 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001476 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1477 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001478
1479 /* Allocate a buffer for this frame: */
1480 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1481 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001482 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001483 status);
1484 return;
1485 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001486 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001487 status);
1488 }
1489
1490 bytes += sizeof(tSirMacMgmtHdr) + payload;
1491
Min Liu0daa0982019-02-01 17:50:44 +08001492 if (sta)
1493 bytes += sta->mlmStaContext.owe_ie_len;
1494
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301495 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301497 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001498 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 return;
1500 }
1501 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001502 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503
1504 /* Next, we fill out the buffer descriptor: */
1505 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1506 (LIM_ASSOC == subtype) ?
1507 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1508 peer_addr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301509 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510 mac_hdr = (tpSirMacMgmtHdr) frame;
1511
1512 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1513
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1515 frame + sizeof(tSirMacMgmtHdr),
1516 payload, &payload);
1517 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001518 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 status);
1520 cds_packet_free((void *)packet);
1521 return;
1522 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001523 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524 status);
1525 }
1526
Abhishek Singh78800962020-02-17 14:40:57 +05301527 pe_nofl_debug("Assoc rsp TX: vdev %d subtype %d to %pM seq num %d status %d aid %d",
1528 pe_session->vdev_id, subtype, mac_hdr->da,
1529 mac_ctx->mgmtSeqNum, status_code, aid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530
1531 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301532 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 &add_ie[0], addn_ie_len);
1534
Min Liu0daa0982019-02-01 17:50:44 +08001535 if (sta && sta->mlmStaContext.owe_ie_len)
1536 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload
1537 + addn_ie_len,
1538 sta->mlmStaContext.owe_ie,
1539 sta->mlmStaContext.owe_ie_len);
1540
Liangwei Dong419d7302019-07-15 15:38:28 +08001541 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1542 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1543 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1545
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301546 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001548 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001549 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 /* Queue Association Response frame in high priority WQ */
bings85512332019-09-04 17:46:37 +08001551 if (tx_complete)
1552 qdf_status = wma_tx_frameWithTxComplete(
1553 mac_ctx, packet, (uint16_t)bytes,
1554 TXRX_FRM_802_11_MGMT,
1555 ANI_TXDIR_TODS,
1556 7, lim_tx_complete, frame,
1557 lim_assoc_rsp_tx_complete, tx_flag,
1558 sme_session, false, 0, RATEID_DEFAULT);
1559 else
1560 qdf_status = wma_tx_frame(
1561 mac_ctx, packet, (uint16_t)bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 TXRX_FRM_802_11_MGMT,
1563 ANI_TXDIR_TODS,
1564 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001565 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301566 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301567 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568
1569 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301570 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001571 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301572 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573
1574 /*
1575 * update the ANI peer station count.
1576 * FIXME_PROTECTION : take care of different type of station
1577 * counter inside this function.
1578 */
1579 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1580
1581}
1582
1583void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001584lim_send_delts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 tSirMacAddr peer,
1586 uint8_t wmmTspecPresent,
Jeff Johnson312348f2018-12-22 13:33:54 -08001587 struct mac_ts_info *pTsinfo,
Jeff Johnson56471b92018-12-22 14:36:06 -08001588 struct mac_tspec_ie *pTspecIe,
Jeff Johnson312348f2018-12-22 13:33:54 -08001589 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590{
1591 uint8_t *pFrame;
1592 tpSirMacMgmtHdr pMacHdr;
1593 tDot11fDelTS DelTS;
1594 tDot11fWMMDelTS WMMDelTS;
1595 uint32_t nBytes, nPayload, nStatus;
1596 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301597 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 uint8_t txFlag = 0;
1599 uint8_t smeSessionId = 0;
1600
Jeff Johnson312348f2018-12-22 13:33:54 -08001601 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001604 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605
1606 if (!wmmTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +08001607 qdf_mem_zero((uint8_t *) &DelTS, sizeof(DelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001609 DelTS.Category.category = ACTION_CATEGORY_QOS;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001610 DelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1612
Jeff Johnson99f25042018-11-21 22:49:06 -08001613 nStatus = dot11f_get_packed_del_ts_size(mac, &DelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001615 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)",
1616 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 /* We'll fall back on the worst case scenario: */
1618 nPayload = sizeof(tDot11fDelTS);
1619 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001620 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1621 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 }
1623 } else {
hangtian127c9532019-01-12 13:29:07 +08001624 qdf_mem_zero((uint8_t *) &WMMDelTS, sizeof(WMMDelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001626 WMMDelTS.Category.category = ACTION_CATEGORY_WMM;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001627 WMMDelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 WMMDelTS.DialogToken.token = 0;
1629 WMMDelTS.StatusCode.statusCode = 0;
1630 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1631 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08001632 dot11f_get_packed_wmm_del_ts_size(mac, &WMMDelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001634 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)",
1635 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 /* We'll fall back on the worst case scenario: */
1637 nPayload = sizeof(tDot11fDelTS);
1638 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001639 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1640 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 }
1642 }
1643
1644 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1645
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301646 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1648 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301649 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001650 pe_err("Failed to allocate %d bytes for an Add TS Response",
1651 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 return;
1653 }
1654 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001655 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656
1657 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08001658 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301659 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1661
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001662 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001664 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665
1666 /* That done, pack the struct: */
1667 if (!wmmTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -08001668 nStatus = dot11f_pack_del_ts(mac, &DelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 pFrame + sizeof(tSirMacMgmtHdr),
1670 nPayload, &nPayload);
1671 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001672 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 nStatus);
1674 cds_packet_free((void *)pPacket);
1675 return; /* allocated! */
1676 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001677 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1678 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 }
1680 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -08001681 nStatus = dot11f_pack_wmm_del_ts(mac, &WMMDelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 pFrame + sizeof(tSirMacMgmtHdr),
1683 nPayload, &nPayload);
1684 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001685 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 nStatus);
1687 cds_packet_free((void *)pPacket);
1688 return; /* allocated! */
1689 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001690 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1691 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 }
1693 }
1694
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001695 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
Jeff Johnson99f25042018-11-21 22:49:06 -08001696 lim_print_mac_addr(mac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697
Liangwei Dong419d7302019-07-15 15:38:28 +08001698 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1699 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1700 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001701 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301703 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001704 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001705 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001706 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001707 QDF_STATUS_SUCCESS);
Jeff Johnson99f25042018-11-21 22:49:06 -08001708 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 TXRX_FRM_802_11_MGMT,
1710 ANI_TXDIR_TODS,
1711 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001712 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301713 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001714 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301716 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001717 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718
1719} /* End lim_send_delts_req_action_frame. */
1720
1721/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301722 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1723 * @context: pointer to global mac
1724 * @buf: buffer
1725 * @tx_complete : Sent status
1726 * @params; tx completion params
1727 *
1728 * Return: This returns QDF_STATUS
1729 */
1730
1731static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1732 qdf_nbuf_t buf,
1733 uint32_t tx_complete,
1734 void *params)
1735{
1736 uint16_t assoc_ack_status;
1737 uint16_t reason_code;
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001738 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301739
Abhishek Singh78800962020-02-17 14:40:57 +05301740 pe_nofl_info("Assoc req TX: %s",
Arun Kumar Khandavalli5ba27432020-01-20 11:47:44 +05301741 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
1742 "success" : "fail");
1743
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001744 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301745 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001746 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301747 } else {
1748 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001749 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301750 }
1751 if (buf)
1752 qdf_nbuf_free(buf);
1753
1754 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1755 NULL, assoc_ack_status, reason_code);
1756 return QDF_STATUS_SUCCESS;
1757}
1758
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301759#ifdef WLAN_ADAPTIVE_11R
1760/**
1761 * lim_fill_adaptive_11r_ie() - Populate the Vendor secific adaptive 11r
1762 * IE to association request frame
1763 * @pe_session: pointer to PE session
1764 * @ie_buf: buffer to which Adaptive 11r IE will be copied
1765 * @ie_len: length of the Adaptive 11r Vendor specific IE
1766 *
1767 * Return QDF_STATUS
1768 */
1769static QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1770 uint8_t **ie_buf, uint8_t *ie_len)
1771{
1772 uint8_t *buf = NULL, *adaptive_11r_ie = NULL;
1773
1774 if (!pe_session->is_adaptive_11r_connection)
1775 return QDF_STATUS_SUCCESS;
1776
1777 /*
1778 * Vendor specific Adaptive 11r IE to be advertised in Assoc
1779 * req:
1780 * Type 0xDD
1781 * Length 0x0B
1782 * OUI 0x00 0x00 0x0F
1783 * Type 0x22
1784 * subtype 0x00
1785 * Version 0x01
1786 * Length 0x04
1787 * Data 0x00 00 00 01(0th bit is 1 means adaptive 11r is
1788 * supported)
1789 */
1790 adaptive_11r_ie = qdf_mem_malloc(ADAPTIVE_11R_STA_IE_LEN + 2);
1791 if (!adaptive_11r_ie)
1792 return QDF_STATUS_E_FAILURE;
1793
1794 /* Fill the Vendor IE Type (0xDD) */
1795 buf = adaptive_11r_ie;
Srinivas Girigowda8e7ecab2019-05-16 11:31:19 -07001796 *buf = WLAN_ELEMID_VENDOR;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301797 buf++;
1798
1799 /* Fill the Vendor IE length (0x0B) */
1800 *buf = ADAPTIVE_11R_STA_IE_LEN;
1801 buf++;
1802
1803 /*
1804 * Fill the Adaptive 11r Vendor specific OUI(0x00 0x00 0x0F 0x22)
1805 */
1806 qdf_mem_copy(buf, ADAPTIVE_11R_STA_OUI, ADAPTIVE_11R_OUI_LEN);
1807 buf += ADAPTIVE_11R_OUI_LEN;
1808
1809 /* Fill Adaptive 11r Vendor specific Subtype (0x00) */
1810 *buf = ADAPTIVE_11R_OUI_SUBTYPE;
1811 buf++;
1812
1813 /* Fill Adaptive 11r Version (0x01) */
1814 *buf = ADAPTIVE_11R_OUI_VERSION;
1815 buf++;
1816
1817 /* Fill Adaptive 11r IE Data length (0x04) */
1818 *buf = ADAPTIVE_11R_DATA_LEN;
1819 buf++;
1820
1821 /* Fill Adaptive 11r IE Data (0x00 0x00 0x00 0x01) */
1822 qdf_mem_copy(buf, ADAPTIVE_11R_OUI_DATA, ADAPTIVE_11R_DATA_LEN);
1823
1824 *ie_len = ADAPTIVE_11R_STA_IE_LEN + 2;
1825 *ie_buf = adaptive_11r_ie;
1826
1827 return QDF_STATUS_SUCCESS;
1828}
1829
1830#else
1831static inline
1832QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1833 uint8_t **ie_buf, uint8_t *ie_len)
1834{
1835 return QDF_STATUS_SUCCESS;
1836}
1837#endif
1838
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301839/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 * lim_send_assoc_req_mgmt_frame() - Send association request
1841 * @mac_ctx: Handle to MAC context
1842 * @mlm_assoc_req: Association request information
1843 * @pe_session: PE session information
1844 *
1845 * Builds and transmits association request frame to AP.
1846 *
1847 * Return: Void
1848 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001850lim_send_assoc_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 tLimMlmAssocReq *mlm_assoc_req,
Jeff Johnsona7815652018-11-18 22:58:30 -08001852 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853{
Naveen Rawat72475db2017-12-13 18:07:35 -08001854 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 tDot11fAssocRequest *frm;
1856 uint16_t caps;
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05301857 uint8_t *frame, *rsnx_ie = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001858 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001860 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1862 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301863 QDF_STATUS qdf_status;
Srinivas Dasari22397902019-07-29 21:34:10 +05301864 uint16_t add_ie_len, current_len = 0, vendor_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001866 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 uint8_t tx_flag = 0;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05301869 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 bool vht_enabled = false;
1871 tDot11fIEExtCap extr_ext_cap;
Pragaspathi Thilagaraj376ead92019-12-11 19:13:28 +05301872 bool extr_ext_flag = true, is_open_auth = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001874 uint32_t ie_offset = 0;
1875 uint8_t *p_ext_cap = NULL;
1876 tDot11fIEExtCap bcn_ext_cap;
1877 uint8_t *bcn_ie = NULL;
1878 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301879 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001880 enum rateid min_rid = RATEID_DEFAULT;
Srinivas Dasari22397902019-07-29 21:34:10 +05301881 uint8_t *mbo_ie = NULL, *adaptive_11r_ie = NULL, *vendor_ies = NULL;
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05301882 uint8_t mbo_ie_len = 0, adaptive_11r_ie_len = 0, rsnx_ie_len = 0;
Liangwei Dongdc8baf32020-01-20 15:35:17 +08001883 bool bss_mfp_capable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001885 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001886 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301887 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 return;
1889 }
1890
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05301891 vdev_id = pe_session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892
1893 /* check this early to avoid unncessary operation */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301894 if (!pe_session->lim_join_req) {
1895 pe_err("pe_session->lim_join_req is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301896 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 return;
1898 }
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301899 add_ie_len = pe_session->lim_join_req->addIEAssoc.length;
1900 add_ie = pe_session->lim_join_req->addIEAssoc.addIEdata;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301902 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001903 if (!frm) {
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301904 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905 return;
1906 }
hangtian127c9532019-01-12 13:29:07 +08001907 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301909 if (add_ie_len && pe_session->is_ext_caps_present) {
hangtian127c9532019-01-12 13:29:07 +08001910 qdf_mem_zero((uint8_t *) &extr_ext_cap,
1911 sizeof(tDot11fIEExtCap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1913 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001914 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001916 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917 } else {
1918 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1919 extr_ext_cap.bytes;
1920
1921 if (p_ext_cap->interworking_service)
1922 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001923 extr_ext_cap.num_bytes =
1924 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1925 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926 }
1927 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001928 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 extr_ext_flag = false;
1930 }
1931
1932 caps = mlm_assoc_req->capabilityInfo;
1933#if defined(FEATURE_WLAN_WAPI)
1934 /*
1935 * According to WAPI standard:
1936 * 7.3.1.4 Capability Information field
1937 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1938 * in transmitted Association or Reassociation management frames.
1939 * APs ignore the Privacy subfield within received Association and
1940 * Reassociation management frames.
1941 */
1942 if (pe_session->encryptType == eSIR_ED_WPI)
1943 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1944#endif
1945 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1946
1947 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1948 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1949 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1950 &frm->SuppRates, pe_session);
1951
1952 qos_enabled = (pe_session->limQosEnabled) &&
1953 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1954
1955 wme_enabled = (pe_session->limWmeEnabled) &&
1956 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1957
1958 /* We prefer .11e asociations: */
1959 if (qos_enabled)
1960 wme_enabled = false;
1961
1962 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1963 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1964
1965 if (pe_session->lim11hEnable &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301966 pe_session->lim_join_req->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967 power_caps = true;
1968
1969 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1970 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1972 LIM_ASSOC, pe_session);
1973
1974 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1976 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1977 if (power_caps == false) {
1978 power_caps = true;
1979 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1980 LIM_ASSOC, pe_session);
1981 }
1982 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001984 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1985 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986
1987 populate_dot11f_ext_supp_rates(mac_ctx,
1988 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1989 pe_session);
1990
Gupta, Kapil54a16992016-01-13 19:34:02 +05301991 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1992 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1994 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001995
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 /*
1997 * The join request *should* contain zero or one of the WPA and RSN
1998 * IEs. The payload send along with the request is a
Jeff Johnson701444f2019-02-02 22:35:13 -08001999 * 'struct join_req'; the IE portion is held inside a 'tSirRSNie':
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 * typedef struct sSirRSNie
2001 * {
2002 * uint16_t length;
Srinivas Girigowdacf161402019-03-14 11:37:33 -07002003 * uint8_t rsnIEdata[WLAN_MAX_IE_LEN+2];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 * } tSirRSNie, *tpSirRSNie;
2005 * So, we should be able to make the following two calls harmlessly,
2006 * since they do nothing if they don't find the given IE in the
2007 * bytestream with which they're provided.
2008 * The net effect of this will be to faithfully transmit whatever
2009 * security IE is in the join request.
2010 * However, if we're associating for the purpose of WPS
2011 * enrollment, and we've been configured to indicate that by
2012 * eliding the WPA or RSN IE, we just skip this:
2013 */
2014 if (add_ie_len && add_ie)
2015 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
2016
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002017 if (!wps_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 populate_dot11f_rsn_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302019 &pe_session->lim_join_req->rsnIE,
2020 &frm->RSNOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 populate_dot11f_wpa_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302022 &pe_session->lim_join_req->rsnIE,
2023 &frm->WPAOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024#if defined(FEATURE_WLAN_WAPI)
2025 populate_dot11f_wapi_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302026 &(pe_session->lim_join_req->rsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 &frm->WAPIOpaque);
2028#endif /* defined(FEATURE_WLAN_WAPI) */
2029 }
2030 /* include WME EDCA IE as well */
2031 if (wme_enabled) {
2032 populate_dot11f_wmm_info_station_per_session(mac_ctx,
2033 pe_session, &frm->WMMInfoStation);
2034
2035 if (wsm_enabled)
2036 populate_dot11f_wmm_caps(&frm->WMMCaps);
2037 }
2038
2039 /*
2040 * Populate HT IEs, when operating in 11n and
2041 * when AP is also operating in 11n mode
2042 */
2043 if (pe_session->htCapability &&
2044 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002045 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002047 } else if (pe_session->he_with_wep_tkip) {
2048 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
2049 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 }
Agrawal Ashishc38e58d2015-09-16 17:17:29 +05302051
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052 if (pe_session->vhtCapability &&
2053 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002054 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002055 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
2056 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07002057 if (pe_session->enableHtSmps &&
2058 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002059 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07002060 populate_dot11f_operating_mode(mac_ctx,
2061 &frm->OperatingMode, pe_session);
2062 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002063 } else if (pe_session->he_with_wep_tkip) {
2064 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
2065 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068 if (!vht_enabled &&
2069 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002070 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302071 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07002072 frm->vendor_vht_ie.sub_type =
2073 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302074 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05302075 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05302076 pe_session->vht_config.su_beam_formee) {
2077 pe_debug("Disable SU beamformee for vendor IE");
2078 pe_session->vht_config.su_beam_formee = 0;
2079 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302081 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 vht_enabled = true;
2083 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05302084 if (pe_session->is_ext_caps_present)
2085 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
2086 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07002088 populate_dot11f_qcn_ie(mac_ctx, &frm->qcn_ie, QCN_IE_ATTR_ID_ALL);
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05302089
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002090 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07002091 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002092 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07002093 &frm->he_cap);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -07002094 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
2095 &frm->he_6ghz_band_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002096 } else if (pe_session->he_with_wep_tkip) {
2097 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
2098 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -07002099 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
2100 &frm->he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002101 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05302102
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302103 if (pe_session->lim_join_req->is11Rconnection) {
Pragaspathi Thilagaraj1112c962019-05-23 23:45:38 +05302104 struct bss_description *bssdescr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302106 bssdescr = &pe_session->lim_join_req->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002107 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 (unsigned int) bssdescr->mdie[0],
2109 (unsigned int) bssdescr->mdie[1],
2110 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111 populate_mdie(mac_ctx, &frm->MobilityDomain,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302112 pe_session->lim_join_req->bssDescription.mdie);
Pragaspathi Thilagaraj03839b92019-03-12 17:45:21 +05302113
2114 /*
2115 * IEEE80211-ai [13.2.4 FT initial mobility domain association
2116 * over FILS in an RSN]
2117 * Populate FT IE in association request. This FT IE should be
2118 * same as the FT IE received in auth response frame during the
2119 * FT-FILS authentication.
2120 */
2121 if (lim_is_fils_connection(pe_session))
2122 populate_fils_ft_info(mac_ctx, &frm->FTInfo,
2123 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125
2126#ifdef FEATURE_WLAN_ESE
2127 /*
2128 * ESE Version IE will be included in association request
2129 * when ESE is enabled on DUT through ini and it is also
2130 * advertised by the peer AP to which we are trying to
2131 * associate to.
2132 */
2133 if (pe_session->is_ese_version_ie_present &&
Wu Gao51a63562018-11-08 16:29:10 +08002134 mac_ctx->mlme_cfg->lfr.ese_enabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 populate_dot11f_ese_version(&frm->ESEVersion);
2136 /* For ESE Associations fill the ESE IEs */
2137 if (pe_session->isESEconnection &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302138 pe_session->lim_join_req->isESEFeatureIniEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139#ifndef FEATURE_DISABLE_RM
2140 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
2141#endif
2142 }
2143#endif
2144
Hu Wang411e0cc2016-10-28 14:56:01 +08002145 /*
2146 * Extcap IE now support variable length, merge Extcap IE from addn_ie
2147 * may change the frame size. Therefore, MUST merge ExtCap IE before
2148 * dot11f get packed payload size.
2149 */
2150 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08002151 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
2152
2153 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
2154 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
2155 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
2156 DOT11F_FF_BEACONINTERVAL_LEN +
2157 DOT11F_FF_CAPABILITIES_LEN;
2158
2159 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
2160 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
2161 bcn_ie = pe_session->beacon + ie_offset;
2162 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07002163 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08002164 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07002165 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08002166 lim_update_extcap_struct(mac_ctx, p_ext_cap,
2167 &bcn_ext_cap);
2168 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
2169 false);
2170 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07002171 /*
2172 * TWT extended capabilities should be populated after the
2173 * intersection of beacon caps and self caps is done because
2174 * the bits for TWT are unique to STA and AP and cannot be
2175 * intersected.
2176 */
2177 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
2178 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08002179 }
Hu Wang411e0cc2016-10-28 14:56:01 +08002180
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002181 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08002182 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002183 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08002184
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302185 if (lim_is_fils_connection(pe_session)) {
2186 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
2187 aes_block_size_len = AES_BLOCK_SIZE;
2188 }
2189
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05302190 /* RSNX IE for SAE PWE derivation based on H2E */
2191 if (wlan_get_ie_ptr_from_eid(WLAN_ELEMID_RSNXE, add_ie, add_ie_len)) {
2192 rsnx_ie = qdf_mem_malloc(WLAN_MAX_IE_LEN + 2);
2193 if (!rsnx_ie)
2194 goto end;
2195
2196 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
2197 WLAN_ELEMID_RSNXE, ONE_BYTE,
2198 NULL, 0, rsnx_ie, WLAN_MAX_IE_LEN);
2199 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2200 pe_err("Failed to strip Vendor IEs");
2201 goto end;
2202 }
2203 rsnx_ie_len = rsnx_ie[1] + 2;
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05302204 }
2205
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302206 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302207 * MBO IE needs to be appendded at the end of the assoc request
2208 * frame and is not parsed and unpacked by the frame parser
2209 * as the supplicant can send multiple TLVs with same Attribute
2210 * in the MBO IE and the frame parser does not support multiple
2211 * TLVs with same attribute in a single IE.
2212 * Strip off the MBO IE from add_ie and append it at the end.
2213 */
2214 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
2215 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
2216 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002217 if (!mbo_ie)
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302218 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302219
2220 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
Srinivas Girigowda61771262019-04-01 11:55:19 -07002221 WLAN_ELEMID_VENDOR, ONE_BYTE,
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302222 SIR_MAC_MBO_OUI,
2223 SIR_MAC_MBO_OUI_SIZE,
2224 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
2225 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2226 pe_err("Failed to strip MBO IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302227 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302228 }
2229
2230 /* Include the EID and length fields */
2231 mbo_ie_len = mbo_ie[1] + 2;
Srinivas Dasari603d4972019-09-20 17:28:44 +05302232
Pragaspathi Thilagaraj376ead92019-12-11 19:13:28 +05302233 if (pe_session->connected_akm == ANI_AKM_TYPE_NONE)
2234 is_open_auth = true;
2235
2236 pe_debug("Stripped MBO IE of length %d is_open_auth:%d",
2237 mbo_ie_len, is_open_auth);
2238
2239 if (!is_open_auth) {
Liangwei Dongdc8baf32020-01-20 15:35:17 +08002240 bss_mfp_capable =
Pragaspathi Thilagaraj2d0aeba2020-02-04 20:47:39 +05302241 lim_get_vdev_rmf_capable(mac_ctx, pe_session);
Liangwei Dongdc8baf32020-01-20 15:35:17 +08002242 if (!bss_mfp_capable) {
Pragaspathi Thilagaraj376ead92019-12-11 19:13:28 +05302243 pe_debug("Peer doesn't support PMF, Don't add MBO IE");
2244 qdf_mem_free(mbo_ie);
2245 mbo_ie = NULL;
2246 mbo_ie_len = 0;
2247 }
Srinivas Dasari603d4972019-09-20 17:28:44 +05302248 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302249 }
2250
Srinivas Dasari22397902019-07-29 21:34:10 +05302251 /*
2252 * Strip rest of the vendor IEs and append to the assoc request frame.
2253 * Append the IEs just before MBO IEs as MBO IEs have to be at the
2254 * end of the frame.
2255 */
2256 if (wlan_get_ie_ptr_from_eid(WLAN_ELEMID_VENDOR, add_ie, add_ie_len)) {
2257 vendor_ies = qdf_mem_malloc(MAX_VENDOR_IES_LEN + 2);
2258 if (vendor_ies) {
2259 current_len = add_ie_len;
2260 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
2261 WLAN_ELEMID_VENDOR, ONE_BYTE,
2262 NULL,
2263 0,
2264 vendor_ies,
2265 MAX_VENDOR_IES_LEN);
2266 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2267 pe_err("Failed to strip Vendor IEs");
2268 goto end;
2269 }
2270
2271 vendor_ie_len = current_len - add_ie_len;
2272 pe_debug("Stripped vendor IEs of size: %u",
2273 current_len);
2274 }
2275 }
2276
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302277 qdf_status = lim_fill_adaptive_11r_ie(pe_session, &adaptive_11r_ie,
2278 &adaptive_11r_ie_len);
2279 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2280 pe_err("Failed to fill adaptive 11r IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302281 goto end;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302282 }
2283
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302284 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302285 * Do unpack to populate the add_ie buffer to frm structure
2286 * before packing the frm structure. In this way, the IE ordering
2287 * which the latest 802.11 spec mandates is maintained.
2288 */
Naveen Rawat72475db2017-12-13 18:07:35 -08002289 if (add_ie_len) {
2290 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302291 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08002292 if (DOT11F_FAILED(ret)) {
2293 pe_err("unpack failed, ret: 0x%x", ret);
2294 goto end;
2295 }
2296 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
2299 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002300 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 status);
2302 /* We'll fall back on the worst case scenario: */
2303 payload = sizeof(tDot11fAssocRequest);
2304 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002305 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 status);
2307 }
2308
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05302309 bytes = payload + sizeof(tSirMacMgmtHdr) + aes_block_size_len +
2310 rsnx_ie_len + mbo_ie_len + adaptive_11r_ie_len + vendor_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302312 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302314 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002315 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316
2317 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302318 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 pe_session->peSessionId,
2320 pe_session->limMlmState));
2321
2322 /* Update PE session id */
2323 assoc_cnf.sessionId = pe_session->peSessionId;
2324
2325 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2326
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2328 (uint32_t *) &assoc_cnf);
2329
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302330 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 }
2332 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08002333 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334
2335 /* Next, we fill out the buffer descriptor: */
2336 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2337 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302338 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339 /* That done, pack the Assoc Request: */
2340 status = dot11f_pack_assoc_request(mac_ctx, frm,
2341 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2342 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002343 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302345 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002347 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 }
2349
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05302350 if (rsnx_ie && rsnx_ie_len) {
2351 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2352 rsnx_ie, rsnx_ie_len);
2353 payload = payload + rsnx_ie_len;
2354 }
2355
Srinivas Dasari22397902019-07-29 21:34:10 +05302356 /* Copy the vendor IEs to the end of the frame */
2357 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2358 vendor_ies, vendor_ie_len);
2359 payload = payload + vendor_ie_len;
2360
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302361 /* Copy the MBO IE to the end of the frame */
2362 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2363 mbo_ie, mbo_ie_len);
2364 payload = payload + mbo_ie_len;
2365
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302366 /*
2367 * Copy the Vendor specific Adaptive 11r IE to end of the
2368 * assoc request frame
2369 */
2370 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2371 adaptive_11r_ie, adaptive_11r_ie_len);
2372 payload = payload + adaptive_11r_ie_len;
2373
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05302374 if (pe_session->assoc_req) {
2375 qdf_mem_free(pe_session->assoc_req);
2376 pe_session->assoc_req = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002377 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 }
2379
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302380 if (lim_is_fils_connection(pe_session)) {
2381 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2382 frame, &payload);
2383 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2384 cds_packet_free((void *)packet);
Srinivas Dasari22397902019-07-29 21:34:10 +05302385 goto end;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302386 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 }
2388
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05302389 pe_session->assoc_req = qdf_mem_malloc(payload);
2390 if (pe_session->assoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 /*
2392 * Store the Assoc request. This is sent to csr/hdd in
2393 * join cnf response.
2394 */
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05302395 qdf_mem_copy(pe_session->assoc_req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 frame + sizeof(tSirMacMgmtHdr), payload);
2397 pe_session->assocReqLen = payload;
2398 }
2399
Liangwei Dong419d7302019-07-15 15:38:28 +08002400 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
2401 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2402 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2404
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302405 if (pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2406 pe_session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2408
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302410 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302412
Abhishek Singh78800962020-02-17 14:40:57 +05302413 pe_nofl_info("Assoc req TX: vdev %d to %pM seq num %d", pe_session->vdev_id,
Abhishek Singh01db29f2020-02-12 10:46:06 +05302414 pe_session->bssId, mac_ctx->mgmtSeqNum);
2415 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
2416 frame, (uint16_t)(sizeof(tSirMacMgmtHdr) + payload));
Arun Kumar Khandavalli5ba27432020-01-20 11:47:44 +05302417
Naveen Rawat296a5182017-09-25 14:02:48 -07002418 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002419 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002420 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002421 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002422 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302423 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302424 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2426 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302427 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302428 tx_flag, vdev_id, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302429 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302430 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302431 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002432
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302433 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002434 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302435 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302436 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002437 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302440
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302441end:
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05302442 qdf_mem_free(rsnx_ie);
Srinivas Dasari22397902019-07-29 21:34:10 +05302443 qdf_mem_free(vendor_ies);
2444 qdf_mem_free(mbo_ie);
2445
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 /* Free up buffer allocated for mlm_assoc_req */
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302447 qdf_mem_free(adaptive_11r_ie);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302448 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302450 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 return;
2452}
2453
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002455 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2456 * @context: pointer to global mac
2457 * @buf: buffer which is nothing but entire ADD BA frame
2458 * @tx_complete : Sent status
2459 * @params; tx completion params
2460 *
2461 * Return: This returns QDF_STATUS
2462 */
2463static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2464 qdf_nbuf_t buf,
2465 uint32_t tx_complete,
2466 void *params)
2467{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002468 struct mac_context *mac_ctx = (struct mac_context *)context;
Krunal Sonid2136c72018-06-01 17:26:39 -07002469 tSirMacMgmtHdr *mac_hdr;
2470 tDot11faddba_rsp rsp;
2471 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Krunal Sonid2136c72018-06-01 17:26:39 -07002472 uint32_t frame_len;
2473 QDF_STATUS status;
2474 uint8_t *data;
Vevek Venkatesan0ac759f2019-10-03 04:14:29 +05302475 struct wmi_mgmt_params *mgmt_params = (struct wmi_mgmt_params *)params;
Krunal Sonid2136c72018-06-01 17:26:39 -07002476
2477 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2478 pe_debug("Add ba response successfully sent");
2479 else
2480 pe_debug("Fail to send add ba response");
2481
2482 if (!buf) {
2483 pe_err("Addba response frame buffer is NULL");
2484 return QDF_STATUS_E_FAILURE;
2485 }
2486
2487 data = qdf_nbuf_data(buf);
2488
2489 if (!data) {
2490 pe_err("Addba response frame is NULL");
2491 return QDF_STATUS_E_FAILURE;
2492 }
2493
2494 mac_hdr = (tSirMacMgmtHdr *)data;
2495 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2496 frame_len = sizeof(rsp);
2497 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2498 sizeof(*mac_hdr), frame_len,
2499 &rsp, false);
2500
2501 if (DOT11F_FAILED(status)) {
2502 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2503 status, frame_len);
2504 goto error;
2505 }
2506
Vevek Venkatesan0ac759f2019-10-03 04:14:29 +05302507 cdp_addba_resp_tx_completion(soc, mac_hdr->da, mgmt_params->vdev_id,
2508 rsp.addba_param_set.tid, tx_complete);
Krunal Sonid2136c72018-06-01 17:26:39 -07002509error:
2510 if (buf)
2511 qdf_nbuf_free(buf);
2512
2513 return QDF_STATUS_SUCCESS;
2514}
2515
2516/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302517 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302518 * @context: pointer to global mac
2519 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302520 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302521 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302522 *
2523 * Return: This returns QDF_STATUS
2524 */
2525
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302526static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2527 qdf_nbuf_t buf,
2528 uint32_t tx_complete,
2529 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302530{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002531 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302532 uint16_t auth_ack_status;
2533 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302534
Abhishek Singh78800962020-02-17 14:40:57 +05302535 pe_nofl_info("Auth TX: %s",
Arun Kumar Khandavalli5ba27432020-01-20 11:47:44 +05302536 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2537 "success" : "fail");
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002538 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302539 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302540 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002541 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302542 /* 'Change' timer for future activations */
2543 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2544 } else {
2545 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302546 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002547 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302548 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302549
2550 if (buf)
2551 qdf_nbuf_free(buf);
2552
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302553 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2554 NULL, auth_ack_status, reason_code);
2555
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302556 return QDF_STATUS_SUCCESS;
2557}
2558
2559/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2561 *
2562 * @mac_ctx: Pointer to Global MAC structure
2563 * @auth_frame: Pointer to Authentication frame structure
2564 * @peer_addr: MAC address of destination peer
2565 * @wep_bit: wep bit in frame control for Authentication frame3
2566 * @session: PE session information
2567 *
2568 * This function is called by lim_process_mlm_messages(). Authentication frame
2569 * is formatted and sent when this function is called.
2570 *
2571 * Return: void
2572 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002574lim_send_auth_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 tpSirMacAuthFrameBody auth_frame,
2576 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302577 uint8_t wep_challenge_len,
Jeff Johnsona7815652018-11-18 22:58:30 -08002578 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579{
2580 uint8_t *frame, *body;
2581 uint32_t frame_len = 0, body_len = 0;
2582 tpSirMacMgmtHdr mac_hdr;
2583 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302584 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 uint8_t tx_flag = 0;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302586 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002588 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002589 enum rateid min_rid = RATEID_DEFAULT;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302590 uint16_t ch_freq_tx_frame = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002592 if (!session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002593 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 return;
2595 }
2596
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302597 vdev_id = session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302599 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002600 /*
2601 * Auth frame3 to be sent with encrypted framebody
2602 *
2603 * Allocate buffer for Authenticaton frame of size
2604 * equal to management frame header length plus 2 bytes
2605 * each for auth algorithm number, transaction number,
2606 * status code, 128 bytes for challenge text and
2607 * 4 bytes each for IV & ICV.
2608 */
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302609 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002610 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002611
2612 goto alloc_packet;
2613 }
2614
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002615 switch (auth_frame->authTransactionSeqNumber) {
2616 case SIR_MAC_AUTH_FRAME_1:
2617 /*
2618 * Allocate buffer for Authenticaton frame of size
2619 * equal to management frame header length plus 2 bytes
2620 * each for auth algorithm number, transaction number
2621 * and status code.
2622 */
2623
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002624 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2625 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002626
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302627 frame_len += lim_create_fils_auth_data(mac_ctx,
2628 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002630 if (session->ftPEContext.pFTPreAuthReq &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 0 != session->ftPEContext.pFTPreAuthReq->
2632 ft_ies_length) {
2633 ft_ies_length = session->ftPEContext.
2634 pFTPreAuthReq->ft_ies_length;
2635 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002636 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 ft_ies_length);
2638 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002639 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 frame_len += (2 + SIR_MDIE_SIZE);
2641 }
2642 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302643
2644 /* include MDIE in FILS authentication frame */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302645 if (session->lim_join_req &&
2646 session->lim_join_req->is11Rconnection &&
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302647 auth_frame->authAlgoNumber == SIR_FILS_SK_WITHOUT_PFS &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302648 session->lim_join_req->bssDescription.mdiePresent)
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302649 frame_len += (2 + SIR_MDIE_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 break;
2651
2652 case SIR_MAC_AUTH_FRAME_2:
2653 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2654 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2655 (auth_frame->authStatusCode !=
2656 eSIR_MAC_SUCCESS_STATUS))) {
2657 /*
2658 * Allocate buffer for Authenticaton frame of size
2659 * equal to management frame header length plus
2660 * 2 bytes each for auth algorithm number,
2661 * transaction number and status code.
2662 */
2663
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002664 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2665 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 } else {
2667 /*
2668 * Shared Key algorithm with challenge text
2669 * to be sent.
2670 *
2671 * Allocate buffer for Authenticaton frame of size
2672 * equal to management frame header length plus
2673 * 2 bytes each for auth algorithm number,
2674 * transaction number, status code and 128 bytes
2675 * for challenge text.
2676 */
2677
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002678 challenge_req = true;
2679 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302680 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2681 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002682 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 }
2684 break;
2685
2686 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002687 /*
2688 * Auth frame3 to be sent without encrypted framebody
2689 *
2690 * Allocate buffer for Authenticaton frame of size equal
2691 * to management frame header length plus 2 bytes each
2692 * for auth algorithm number, transaction number and
2693 * status code.
2694 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002696 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2697 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 break;
2699
2700 case SIR_MAC_AUTH_FRAME_4:
2701 /*
2702 * Allocate buffer for Authenticaton frame of size equal
2703 * to management frame header length plus 2 bytes each
2704 * for auth algorithm number, transaction number and
2705 * status code.
2706 */
2707
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002708 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2709 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710
2711 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002712 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002713 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002714 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 } /* switch (auth_frame->authTransactionSeqNumber) */
2716
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002717alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302718 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 (void **)&packet);
2720
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302721 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002722 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 return;
2724 }
2725
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302726 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727
2728 /* Prepare BD */
2729 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302730 SIR_MAC_MGMT_AUTH, peer_addr, session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302732 if (wep_challenge_len)
2733 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2734 else
2735 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736
2737 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002738 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302739 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 (uint8_t *) session->bssId,
2741 sizeof(tSirMacAddr));
2742
2743 /* Prepare Authentication frame body */
2744 body = frame + sizeof(tSirMacMgmtHdr);
2745
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302746 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302747 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 } else {
2749 *((uint16_t *) (body)) =
2750 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2751 body += sizeof(uint16_t);
2752 body_len -= sizeof(uint16_t);
2753
2754 *((uint16_t *) (body)) =
2755 sir_swap_u16if_needed(
2756 auth_frame->authTransactionSeqNumber);
2757 body += sizeof(uint16_t);
2758 body_len -= sizeof(uint16_t);
2759
2760 *((uint16_t *) (body)) =
2761 sir_swap_u16if_needed(auth_frame->authStatusCode);
2762 body += sizeof(uint16_t);
2763 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002764
2765 if (challenge_req) {
2766 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302767 /* copy challenge IE id, len, challenge text */
2768 *body = auth_frame->type;
2769 body++;
2770 body_len -= sizeof(uint8_t);
2771 *body = auth_frame->length;
2772 body++;
2773 body_len -= sizeof(uint8_t);
2774 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002775 body_len);
2776 pe_err("Incomplete challenge info: length: %d, expected: %d",
2777 body_len,
2778 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2779 body += body_len;
2780 body_len = 0;
2781 } else {
2782 /* copy challenge IE id, len, challenge text */
2783 *body = auth_frame->type;
2784 body++;
2785 *body = auth_frame->length;
2786 body++;
2787 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302788 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2789 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302790 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
Arun Kumar Khandavalli5ba27432020-01-20 11:47:44 +05302791 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002792 }
2793 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2796 (auth_frame->authTransactionSeqNumber ==
2797 SIR_MAC_AUTH_FRAME_1) &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002798 (session->ftPEContext.pFTPreAuthReq)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799
2800 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302801 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 session->ftPEContext.
2803 pFTPreAuthReq->ft_ies,
2804 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002805 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002806 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2807 QDF_TRACE_LEVEL_DEBUG,
2808 (uint8_t *) body,
2809 ft_ies_length);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002810 } else if (session->ftPEContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 pFTPreAuthReq->pbssDescription) {
2812 /* MDID attr is 54 */
Srinivas Girigowda61771262019-04-01 11:55:19 -07002813 *body = WLAN_ELEMID_MOBILITY_DOMAIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 body++;
2815 *body = SIR_MDIE_SIZE;
2816 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302817 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 &session->ftPEContext.pFTPreAuthReq->
2819 pbssDescription->mdie[0],
2820 SIR_MDIE_SIZE);
2821 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302822 } else if ((auth_frame->authAlgoNumber ==
2823 SIR_FILS_SK_WITHOUT_PFS) &&
2824 (auth_frame->authTransactionSeqNumber ==
2825 SIR_MAC_AUTH_FRAME_1)) {
2826 pe_debug("FILS: appending fils Auth data");
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302827 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829 }
gaurank kathpalia385977d2020-02-06 11:41:10 +05302830
Abhishek Singh78800962020-02-17 14:40:57 +05302831 pe_nofl_info("Auth TX: seq %d seq num %d status %d WEP %d to " QDF_MAC_ADDR_STR,
gaurank kathpalia385977d2020-02-06 11:41:10 +05302832 auth_frame->authTransactionSeqNumber, mac_ctx->mgmtSeqNum,
2833 auth_frame->authStatusCode, mac_hdr->fc.wep,
2834 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
2835 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002836 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002838 if ((session->ftPEContext.pFTPreAuthReq) &&
Wu Gaoceac2852019-11-18 20:13:19 +08002839 (!wlan_reg_is_24ghz_ch_freq(
2840 session->ftPEContext.pFTPreAuthReq->pre_auth_channel_freq)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Liangwei Dong419d7302019-07-15 15:38:28 +08002842 else if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
2843 session->opmode == QDF_P2P_CLIENT_MODE ||
2844 session->opmode == QDF_P2P_GO_MODE)
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302845 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302847 if (session->opmode == QDF_P2P_CLIENT_MODE ||
2848 session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2850
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302851 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002852 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302854 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002855 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002856 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002857 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302858
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002859 if (session->ftPEContext.pFTPreAuthReq)
Wu Gaoceac2852019-11-18 20:13:19 +08002860 ch_freq_tx_frame = session->ftPEContext.
2861 pFTPreAuthReq->pre_auth_channel_freq;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302862
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302863 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2864 (uint16_t)frame_len,
2865 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2866 7, lim_tx_complete, frame,
2867 lim_auth_tx_complete_cnf,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302868 tx_flag, vdev_id, false,
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302869 ch_freq_tx_frame, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302870 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2871 session->peSessionId, qdf_status));
2872 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2873 pe_err("*** Could not send Auth frame, retCode=%X ***",
2874 qdf_status);
2875 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2876 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002877 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302878 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302879 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 return;
2881}
2882
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002883QDF_STATUS lim_send_deauth_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884{
2885 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002886 tpDphHashNode sta_ds;
2887 tLimMlmDeauthReq *deauth_req;
2888 tLimMlmDeauthCnf deauth_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002889 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002891 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2892 if (deauth_req) {
2893 if (tx_timer_running(
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05302894 &mac_ctx->lim.lim_timers.gLimDeauthAckTimer))
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002895 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002898 session_entry = pe_find_session_by_session_id(mac_ctx,
2899 deauth_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002900 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002901 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002902 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 eSIR_SME_INVALID_PARAMETERS;
2904 goto end;
2905 }
2906
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002907 sta_ds =
2908 dph_lookup_hash_entry(mac_ctx,
2909 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002910 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002911 &session_entry->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002912 if (!sta_ds) {
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002913 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 goto end;
2915 }
2916
2917 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002918 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2919 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2920 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2921 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302922#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002923 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302924#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002925 (session_entry->isFastRoamIniFeatureEnabled) ||
2926 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002927 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002928 session_entry,
2929 session_entry->peSessionId,
2930 deauth_req->reasonCode,
2931 deauth_req->deauthTrigger);
2932 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002933 } else {
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002934#ifdef FEATURE_WLAN_ESE
Nirav Shahf359dd22019-02-20 10:34:28 +05302935 pe_debug("No FT Preauth Session Cleanup in role %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002936 " isESE %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002937 " isLFR %d"
2938 " is11r %d, Deauth reason %d Trigger = %d",
2939 session_entry->limSystemRole,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002940 session_entry->isESEconnection,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002941 session_entry->isFastRoamIniFeatureEnabled,
2942 session_entry->is11Rconnection,
2943 deauth_req->reasonCode,
2944 deauth_req->deauthTrigger);
Nirav Shahf359dd22019-02-20 10:34:28 +05302945#else
2946 pe_debug("No FT Preauth Session Cleanup in role %d"
2947 " isLFR %d"
2948 " is11r %d, Deauth reason %d Trigger = %d",
2949 session_entry->limSystemRole,
2950 session_entry->isFastRoamIniFeatureEnabled,
2951 session_entry->is11Rconnection,
2952 deauth_req->reasonCode,
2953 deauth_req->deauthTrigger);
2954#endif
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002955 }
2956 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002957 qdf_mem_free(deauth_req);
2958 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302960 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002962 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2963 &deauth_req->peer_macaddr);
2964 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2965 deauth_cnf.aid = deauth_req->aid;
2966 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967
2968 /* Free up buffer allocated */
2969 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002970 qdf_mem_free(deauth_req);
2971 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002973 lim_post_sme_message(mac_ctx,
2974 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302975 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976}
2977
2978/**
2979 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2980 *
2981 * @mac_ctx: Handle to MAC context
2982 *
2983 * Sends disassoc confirmation to SME. Removes disassoc request stored
2984 * in lim.
2985 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302986 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987 */
2988
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002989QDF_STATUS lim_send_disassoc_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990{
2991 uint16_t aid;
2992 tpDphHashNode sta_ds;
2993 tLimMlmDisassocCnf disassoc_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002994 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 tLimMlmDisassocReq *disassoc_req;
2996
2997 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2998 if (disassoc_req) {
2999 if (tx_timer_running(
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303000 &mac_ctx->lim.lim_timers.gLimDisassocAckTimer))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 lim_deactivate_and_change_timer(mac_ctx,
3002 eLIM_DISASSOC_ACK_TIMER);
3003
3004 pe_session = pe_find_session_by_session_id(
3005 mac_ctx, disassoc_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003006 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003007 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 disassoc_cnf.resultCode =
3009 eSIR_SME_INVALID_PARAMETERS;
3010 goto end;
3011 }
3012
3013 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08003014 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 &pe_session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003016 if (!sta_ds) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003017 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3019 goto end;
3020 }
3021 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003022 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
3024 disassoc_cnf.resultCode =
3025 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003026 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 goto end;
3028 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07003029 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003030 (disassoc_req->reasonCode !=
3031 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07003032 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003033 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 /* Delete FT session if there exists one */
3036 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303039 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303041 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303043 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 }
3045end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303046 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08003047 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303048 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 disassoc_cnf.aid = disassoc_req->aid;
3050 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
3051
3052 /* Update PE session ID */
3053 disassoc_cnf.sessionId = disassoc_req->sessionId;
3054
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003055 if (disassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303057 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3059 }
3060
3061 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
3062 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303063 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064}
3065
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303066QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003067 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303068 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003070 struct mac_context *max_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303071
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003072 pe_debug("tx_success: %d", tx_success);
3073
3074 return lim_send_disassoc_cnf(max_ctx);
3075}
3076
3077static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
3078 qdf_nbuf_t buf,
3079 uint32_t tx_success,
3080 void *params)
3081{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003082 struct mac_context *max_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003083 QDF_STATUS status_code;
3084 struct scheduler_msg msg = {0};
3085
3086 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303087
3088 if (buf)
3089 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003090 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
3091 msg.bodyptr = params;
3092 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303093
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003094 status_code = lim_post_msg_high_priority(max_ctx, &msg);
3095 if (status_code != QDF_STATUS_SUCCESS)
3096 pe_err("posting message: %X to LIM failed, reason: %d",
3097 msg.type, status_code);
3098 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099}
3100
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303101QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003102 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303103 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003105 struct mac_context *mac_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303106
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003107 pe_debug("tx_success: %d", tx_success);
3108
3109 return lim_send_deauth_cnf(mac_ctx);
3110}
3111
3112static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
3113 qdf_nbuf_t buf,
3114 uint32_t tx_success,
3115 void *params)
3116{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003117 struct mac_context *mac_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003118 QDF_STATUS status_code;
3119 struct scheduler_msg msg = {0};
3120
gaurank kathpalia3c996e62020-01-23 16:07:32 +05303121 pe_debug("tx_complete = %s tx_success = %d",
3122 (tx_success == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
3123 "success" : "fail", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303124
3125 if (buf)
3126 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003127 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
3128 msg.bodyptr = params;
3129 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303130
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003131 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
3132 if (status_code != QDF_STATUS_SUCCESS)
3133 pe_err("posting message: %X to LIM failed, reason: %d",
3134 msg.type, status_code);
3135 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136}
3137
3138/**
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303139 * lim_append_ies_to_frame() - Append IEs to the frame
3140 *
3141 * @frame: Pointer to the frame buffer that needs to be populated
3142 * @frame_len: Pointer for current frame length
3143 * @ie: pointer for disconnect IEs
3144 *
3145 * This function is called by lim_send_disassoc_mgmt_frame and
3146 * lim_send_deauth_mgmt_frame APIs as part of disconnection.
3147 * Append IEs and update frame length.
3148 *
3149 * Return: None
3150 */
3151static void
3152lim_append_ies_to_frame(uint8_t *frame, uint32_t *frame_len,
3153 struct wlan_ies *ie)
3154{
3155 if (!ie || !ie->len || !ie->data)
3156 return;
3157 qdf_mem_copy(frame, ie->data, ie->len);
3158 *frame_len += ie->len;
3159 pe_debug("Appended IEs len: %u", ie->len);
3160}
3161
3162/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 * \brief This function is called to send Disassociate frame.
3164 *
3165 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003166 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167 *
3168 * \param nReason Indicates the reason that need to be sent in
3169 * Disassociation frame
3170 *
3171 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3172 * sent
3173 *
3174 *
3175 */
3176
3177void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003178lim_send_disassoc_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 uint16_t nReason,
3180 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003181 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182{
3183 tDot11fDisassociation frm;
3184 uint8_t *pFrame;
3185 tpSirMacMgmtHdr pMacHdr;
3186 uint32_t nBytes, nPayload, nStatus;
3187 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303188 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 uint8_t txFlag = 0;
3190 uint32_t val = 0;
3191 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303192 struct wlan_ies *discon_ie;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003193
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003194 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 return;
3196 }
3197
3198 /*
3199 * In case when cac timer is running for this SAP session then
3200 * avoid sending disassoc out. It is violation of dfs specification.
3201 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303202 if (((pe_session->opmode == QDF_SAP_MODE) ||
3203 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003204 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303205 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303206 FL("CAC timer is running, drop disassoc from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303207 if (waitForAck)
3208 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 return;
3210 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003211 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212
hangtian127c9532019-01-12 13:29:07 +08003213 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214
3215 frm.Reason.code = nReason;
3216
Jeff Johnson99f25042018-11-21 22:49:06 -08003217 nStatus = dot11f_get_packed_disassociation_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003219 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 nStatus);
3221 /* We'll fall back on the worst case scenario: */
3222 nPayload = sizeof(tDot11fDisassociation);
3223 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003224 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
3225 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 }
3227
3228 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3229
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303230 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3231 if (discon_ie && discon_ie->len)
3232 nBytes += discon_ie->len;
3233
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303234 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303236 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003237 pe_err("Failed to allocate %d bytes for a Disassociation",
3238 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303239 if (waitForAck)
3240 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 return;
3242 }
3243 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003244 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245
3246 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003247 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303248 SIR_MAC_MGMT_DISASSOC, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3250
3251 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003252 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003254 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255
Jeff Johnson99f25042018-11-21 22:49:06 -08003256 nStatus = dot11f_pack_disassociation(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 sizeof(tSirMacMgmtHdr),
3258 nPayload, &nPayload);
3259 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003260 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 nStatus);
3262 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303263 if (waitForAck)
3264 lim_send_disassoc_cnf(mac);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003265 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003267 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
3268 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 }
3270
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303271 /* Copy disconnect IEs to the end of the frame */
3272 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3273 &nPayload, discon_ie);
3274 mlme_free_self_disconnect_ies(pe_session->vdev);
3275
Abhishek Singh29405dc2020-02-17 13:08:32 +05303276 pe_nofl_info("Disassoc TX: vdev %d seq %d reason %u and waitForAck %d to " QDF_MAC_ADDR_STR " From " QDF_MAC_ADDR_STR,
3277 pe_session->vdev_id, mac->mgmtSeqNum, nReason, waitForAck,
3278 QDF_MAC_ADDR_ARRAY(pMacHdr->da),
3279 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280
Liangwei Dong419d7302019-07-15 15:38:28 +08003281 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3282 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3283 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285
Sushant Kaushik46556062015-12-02 16:57:47 +05303286 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287
3288 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303289 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003290 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003291 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003292 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003293 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003294 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 /* Queue Disassociation frame in high priority WQ */
3296 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303297 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003298 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 TXRX_FRM_802_11_MGMT,
3300 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003301 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003302 txFlag, smeSessionId, false, 0,
3303 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303304 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303305 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003306 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307
3308 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3309
3310 if (tx_timer_change
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303311 (&mac->lim.lim_timers.gLimDisassocAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003313 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 return;
3315 } else if (TX_SUCCESS !=
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303316 tx_timer_activate(&mac->lim.lim_timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003318 pe_err("Unable to activate Disassoc ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003319 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 eLIM_DISASSOC_ACK_TIMER);
3321 return;
3322 }
3323 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303324 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003325 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003327 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003328 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003329 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003331 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 TXRX_FRM_802_11_MGMT,
3333 ANI_TXDIR_TODS,
3334 7,
3335 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003336 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303337 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303338 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003339 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303340 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003341 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303342 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003343 /* Pkt will be freed up by the callback */
3344 }
3345 }
3346} /* End lim_send_disassoc_mgmt_frame. */
3347
3348/**
3349 * \brief This function is called to send a Deauthenticate frame
3350 *
3351 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003352 * \param mac Pointer to global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 *
3354 * \param nReason Indicates the reason that need to be sent in the
3355 * Deauthenticate frame
3356 *
3357 * \param peeer address of the STA to which the frame is to be sent
3358 *
3359 *
3360 */
3361
3362void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003363lim_send_deauth_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364 uint16_t nReason,
3365 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003366 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367{
3368 tDot11fDeAuth frm;
3369 uint8_t *pFrame;
3370 tpSirMacMgmtHdr pMacHdr;
3371 uint32_t nBytes, nPayload, nStatus;
3372 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303373 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 uint8_t txFlag = 0;
3375 uint32_t val = 0;
3376#ifdef FEATURE_WLAN_TDLS
3377 uint16_t aid;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003378 tpDphHashNode sta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379#endif
3380 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303381 struct wlan_ies *discon_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003383 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 return;
3385 }
3386
3387 /*
3388 * In case when cac timer is running for this SAP session then
3389 * avoid deauth frame out. It is violation of dfs specification.
3390 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303391 if (((pe_session->opmode == QDF_SAP_MODE) ||
3392 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003393 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303394 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 FL
3396 ("CAC timer is running, drop the deauth from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303397 if (waitForAck)
3398 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 return;
3400 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003401 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402
hangtian127c9532019-01-12 13:29:07 +08003403 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404
3405 frm.Reason.code = nReason;
3406
Jeff Johnson99f25042018-11-21 22:49:06 -08003407 nStatus = dot11f_get_packed_de_auth_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003409 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 nStatus);
3411 /* We'll fall back on the worst case scenario: */
3412 nPayload = sizeof(tDot11fDeAuth);
3413 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003414 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3415 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 }
3417
3418 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303419 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3420 if (discon_ie && discon_ie->len)
3421 nBytes += discon_ie->len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303423 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303425 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003426 pe_err("Failed to allocate %d bytes for a De-Authentication",
3427 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303428 if (waitForAck)
3429 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 return;
3431 }
3432 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003433 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434
3435 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003436 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303437 SIR_MAC_MGMT_DEAUTH, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3439
3440 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003441 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003443 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444
Jeff Johnson99f25042018-11-21 22:49:06 -08003445 nStatus = dot11f_pack_de_auth(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3447 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003448 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449 nStatus);
3450 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303451 if (waitForAck)
3452 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 return;
3454 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003455 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3456 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 }
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303458
3459 /* Copy disconnect IEs to the end of the frame */
3460 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3461 &nPayload, discon_ie);
3462 mlme_free_self_disconnect_ies(pe_session->vdev);
3463
Abhishek Singh29405dc2020-02-17 13:08:32 +05303464 pe_nofl_info("Deauth TX: vdev %d seq_num %d reason %u waitForAck %d to " QDF_MAC_ADDR_STR " from " QDF_MAC_ADDR_STR,
3465 pe_session->vdev_id, mac->mgmtSeqNum, nReason, waitForAck,
gaurank kathpalia3c996e62020-01-23 16:07:32 +05303466 QDF_MAC_ADDR_ARRAY(pMacHdr->da),
3467 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468
Liangwei Dong419d7302019-07-15 15:38:28 +08003469 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3470 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3471 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473
Sushant Kaushik46556062015-12-02 16:57:47 +05303474 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003476 sta =
Jeff Johnson99f25042018-11-21 22:49:06 -08003477 dph_lookup_hash_entry(mac, peer, &aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003478 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479#endif
3480
3481 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303482 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003483 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003485 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003486 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003487 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303489 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003490 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 TXRX_FRM_802_11_MGMT,
3492 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003493 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003494 txFlag, smeSessionId, false, 0,
3495 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303496 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303497 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003498 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303500 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003501 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303502 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503
3504 /* Call lim_process_deauth_ack_timeout which will send
3505 * DeauthCnf for this frame
3506 */
Jeff Johnson99f25042018-11-21 22:49:06 -08003507 lim_process_deauth_ack_timeout(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 return;
3509 }
3510
3511 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3512
3513 if (tx_timer_change
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303514 (&mac->lim.lim_timers.gLimDeauthAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003516 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517 return;
3518 } else if (TX_SUCCESS !=
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303519 tx_timer_activate(&mac->lim.lim_timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003521 pe_err("Unable to activate Deauth ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003522 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 eLIM_DEAUTH_ACK_TIMER);
3524 return;
3525 }
3526 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303527 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003528 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 pMacHdr->fc.subType));
3530#ifdef FEATURE_WLAN_TDLS
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003531 if ((sta)
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003532 && (STA_ENTRY_TDLS_PEER == sta->staType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003533 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003534 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003535 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003536 QDF_STATUS_SUCCESS,
3537 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303538 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003539 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3541 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003542 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 } else {
3544#endif
Jeff Johnson99f25042018-11-21 22:49:06 -08003545 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003546 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003547 QDF_STATUS_SUCCESS,
3548 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303550 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003551 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3553 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003554 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555#ifdef FEATURE_WLAN_TDLS
3556 }
3557#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303558 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003559 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303560 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003561 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303562 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 /* Pkt will be freed up by the callback */
3564 }
3565 }
3566
3567} /* End lim_send_deauth_mgmt_frame. */
3568
3569#ifdef ANI_SUPPORT_11H
3570/**
3571 * \brief Send a Measurement Report Action frame
3572 *
3573 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003574 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575 *
3576 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3577 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003578 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 *
3580 *
3581 */
3582
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003583QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003584lim_send_meas_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 tpSirMacMeasReqActionFrame pMeasReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003586 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587{
3588 tDot11fMeasurementReport frm;
3589 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003590 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 tpSirMacMgmtHdr pMacHdr;
3592 uint32_t nBytes, nPayload, nStatus;
3593 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303594 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595
hangtian127c9532019-01-12 13:29:07 +08003596 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003598 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003599 frm.Action.action = ACTION_SPCT_MSR_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3601
3602 switch (pMeasReqFrame->measReqIE.measType) {
3603 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3604 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003605 populate_dot11f_measurement_report0(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 &frm.MeasurementReport);
3607 break;
3608 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3609 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003610 populate_dot11f_measurement_report1(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 &frm.MeasurementReport);
3612 break;
3613 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3614 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003615 populate_dot11f_measurement_report2(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616 &frm.MeasurementReport);
3617 break;
3618 default:
Jeff Johnson0711e272018-12-14 23:16:38 -08003619 pe_err("Unknown measurement type %d in limSendMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003621 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 }
3623
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003624 if (QDF_STATUS_SUCCESS != nSirStatus)
3625 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003626
Jeff Johnson99f25042018-11-21 22:49:06 -08003627 nStatus = dot11f_get_packed_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003629 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 nStatus);
3631 /* We'll fall back on the worst case scenario: */
3632 nPayload = sizeof(tDot11fMeasurementReport);
3633 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003634 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3635 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 }
3637
3638 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3639
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303640 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003641 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642 (uint16_t) nBytes, (void **)&pFrame,
3643 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303644 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson0711e272018-12-14 23:16:38 -08003645 pe_err("Failed to allocate %d bytes for a De-Authentication",
3646 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003647 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 }
3649 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003650 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651
3652 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003653 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 SIR_MAC_MGMT_ACTION, peer);
3655 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3656
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003657 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003659 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660
Jeff Johnson99f25042018-11-21 22:49:06 -08003661 nStatus = dot11f_pack_measurement_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662 sizeof(tSirMacMgmtHdr),
3663 nPayload, &nPayload);
3664 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003665 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003667 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003669 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003671 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3672 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 }
3674
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303675 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003676 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303678 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003679 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003681 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303682 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303683 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003684 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303685 qdf_status));
3686 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003687 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303688 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003690 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691 }
3692
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003693 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694
3695} /* End lim_send_meas_report_frame. */
3696
3697/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 * \brief Send a TPC Report Action frame
3699 *
3700 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003701 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702 *
3703 * \param pTpcReqFrame Pointer to the received TPC Request
3704 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003705 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706 *
3707 *
3708 */
3709
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003710QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003711lim_send_tpc_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712 tpSirMacTpcReqActionFrame pTpcReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003713 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714{
3715 tDot11fTPCReport frm;
3716 uint8_t *pFrame;
3717 tpSirMacMgmtHdr pMacHdr;
3718 uint32_t nBytes, nPayload, nStatus;
3719 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303720 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003721
hangtian127c9532019-01-12 13:29:07 +08003722 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003724 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003725 frm.Action.action = ACTION_SPCT_TPC_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3727
3728 frm.TPCReport.tx_power = 0;
3729 frm.TPCReport.link_margin = 0;
3730 frm.TPCReport.present = 1;
3731
Jeff Johnson99f25042018-11-21 22:49:06 -08003732 nStatus = dot11f_get_packed_tpc_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003734 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003735 /* We'll fall back on the worst case scenario: */
3736 nPayload = sizeof(tDot11fTPCReport);
3737 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003738 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3739 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003740 }
3741
3742 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3743
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303744 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003745 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003746 (uint16_t) nBytes, (void **)&pFrame,
3747 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303748 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003749 pe_err("Failed to allocate %d bytes for a TPC"
3750 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003751 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003752 }
3753 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003754 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755
3756 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003757 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758 SIR_MAC_MGMT_ACTION, peer);
3759
3760 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3761
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003762 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003763
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003764 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765
Jeff Johnson99f25042018-11-21 22:49:06 -08003766 nStatus = dot11f_pack_tpc_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767 sizeof(tSirMacMgmtHdr),
3768 nPayload, &nPayload);
3769 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003770 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003772 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003773 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003774 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003776 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3777 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303779 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003780 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303782 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003783 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003785 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303786 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003787 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003788 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003789 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303790 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003791 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303792 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003794 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 }
3796
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003797 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798
3799} /* End lim_send_tpc_report_frame. */
3800#endif /* ANI_SUPPORT_11H */
3801
3802/**
3803 * \brief Send a Channel Switch Announcement
3804 *
3805 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003806 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 *
3808 * \param peer MAC address to which this frame will be sent
3809 *
3810 * \param nMode
3811 *
3812 * \param nNewChannel
3813 *
3814 * \param nCount
3815 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003816 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 *
3818 *
3819 */
3820
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003821QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003822lim_send_channel_switch_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823 tSirMacAddr peer,
3824 uint8_t nMode,
3825 uint8_t nNewChannel,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003826 uint8_t nCount, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827{
3828 tDot11fChannelSwitch frm;
3829 uint8_t *pFrame;
3830 tpSirMacMgmtHdr pMacHdr;
3831 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3832 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303833 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003834 uint8_t txFlag = 0;
3835
3836 uint8_t smeSessionId = 0;
3837
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003838 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003839 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003840 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003842 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003843
hangtian127c9532019-01-12 13:29:07 +08003844 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003846 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003847 frm.Action.action = ACTION_SPCT_CHL_SWITCH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848 frm.ChanSwitchAnn.switchMode = nMode;
3849 frm.ChanSwitchAnn.newChannel = nNewChannel;
3850 frm.ChanSwitchAnn.switchCount = nCount;
3851 frm.ChanSwitchAnn.present = 1;
3852
Jeff Johnson99f25042018-11-21 22:49:06 -08003853 nStatus = dot11f_get_packed_channel_switch_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003855 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 nStatus);
3857 /* We'll fall back on the worst case scenario: */
3858 nPayload = sizeof(tDot11fChannelSwitch);
3859 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003860 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3861 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 }
3863
3864 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3865
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303866 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3868 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303869 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003870 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003871 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 }
3873 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003874 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875
3876 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003877 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878 SIR_MAC_MGMT_ACTION, peer,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303879 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303881 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003882 (uint8_t *) pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003884 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885
Jeff Johnson99f25042018-11-21 22:49:06 -08003886 nStatus = dot11f_pack_channel_switch(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 sizeof(tSirMacMgmtHdr),
3888 nPayload, &nPayload);
3889 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003890 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891 nStatus);
3892 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003893 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003895 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3896 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 }
3898
Liangwei Dong419d7302019-07-15 15:38:28 +08003899 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3900 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3901 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003902 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303904 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003905 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003906 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907 TXRX_FRM_802_11_MGMT,
3908 ANI_TXDIR_TODS,
3909 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003910 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303911 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003912 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303913 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003914 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303915 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003917 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 }
3919
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003920 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921
3922} /* End lim_send_channel_switch_mgmt_frame. */
3923
Abhishek Singh518323d2015-10-19 17:42:01 +05303924/**
3925 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3926 * action frame over the air .
3927 * @mac_ctx: pointer to global mac structure
3928 * @peer: Destination mac.
3929 * @mode: channel switch mode
3930 * @new_op_class: new op class
3931 * @new_channel: new channel to switch
3932 * @count: channel switch count
3933 *
3934 * This function is called to send ECSA frame.
3935 *
3936 * Return: success if frame is sent else return failure
3937 */
3938
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003939QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003940lim_send_extended_chan_switch_action_frame(struct mac_context *mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05303941 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
Jeff Johnsona7815652018-11-18 22:58:30 -08003942 uint8_t new_channel, uint8_t count, struct pe_session *session_entry)
Abhishek Singh518323d2015-10-19 17:42:01 +05303943{
3944 tDot11fext_channel_switch_action_frame frm;
3945 uint8_t *frame;
3946 tpSirMacMgmtHdr mac_hdr;
3947 uint32_t num_bytes, n_payload, status;
3948 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303949 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303950 uint8_t txFlag = 0;
Abhishek Singh345be412019-11-19 10:59:29 +05303951 uint8_t vdev_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303952 uint8_t ch_spacing;
3953 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303954
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003955 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003956 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003957 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303958 }
3959
Abhishek Singh345be412019-11-19 10:59:29 +05303960 vdev_id = session_entry->smeSessionId;
Abhishek Singh518323d2015-10-19 17:42:01 +05303961
hangtian127c9532019-01-12 13:29:07 +08003962 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh518323d2015-10-19 17:42:01 +05303963
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003964 frm.Category.category = ACTION_CATEGORY_PUBLIC;
Abhishek Singh518323d2015-10-19 17:42:01 +05303965 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3966
3967 frm.ext_chan_switch_ann_action.switch_mode = mode;
3968 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3969 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3970 frm.ext_chan_switch_ann_action.switch_count = count;
3971
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303972 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3973 mac_ctx->scan.countryCodeCurrent, new_channel,
3974 new_op_class);
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303975
3976 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3977 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3978 frm.WiderBWChanSwitchAnn.newChanWidth =
3979 wide_bw_ie->newChanWidth;
3980 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3981 wide_bw_ie->newCenterChanFreq0;
3982 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3983 wide_bw_ie->newCenterChanFreq1;
3984 frm.WiderBWChanSwitchAnn.present = 1;
3985 pe_debug("wrapper: width:%d f0:%d f1:%d",
3986 frm.WiderBWChanSwitchAnn.newChanWidth,
3987 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3988 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3989 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303990
3991 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3992 &frm, &n_payload);
3993 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003994 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303995 status);
3996 /* We'll fall back on the worst case scenario*/
3997 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3998 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003999 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05304000 status);
4001 }
4002
4003 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
4004
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304005 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05304006 (void **) &frame, (void **) &packet);
4007
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304008 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004009 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05304010 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004011 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05304012 }
4013
4014 /* Paranoia*/
hangtian127c9532019-01-12 13:29:07 +08004015 qdf_mem_zero(frame, num_bytes);
Abhishek Singh518323d2015-10-19 17:42:01 +05304016
4017 /* Next, we fill out the buffer descriptor */
4018 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304019 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh518323d2015-10-19 17:42:01 +05304020 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304021 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05304022 (uint8_t *) session_entry->bssId,
4023 sizeof(tSirMacAddr));
4024
gaolez4b62a9e2018-08-16 15:57:50 +08004025 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
4026
Abhishek Singh518323d2015-10-19 17:42:01 +05304027 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
4028 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
4029 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004030 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05304031 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004032 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05304033 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004034 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05304035 status);
4036 }
4037
Liangwei Dong419d7302019-07-15 15:38:28 +08004038 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
4039 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
4040 session_entry->opmode == QDF_P2P_GO_MODE)
Abhishek Singh518323d2015-10-19 17:42:01 +05304041 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Abhishek Singh518323d2015-10-19 17:42:01 +05304042
Abhishek Singh98ab5e42020-02-14 11:07:31 +05304043 pe_debug("ECSA frame to :"QDF_MAC_ADDR_STR" count %d mode %d chan %d op class %d",
4044 QDF_MAC_ADDR_ARRAY(mac_hdr->da),
4045 frm.ext_chan_switch_ann_action.switch_count,
4046 frm.ext_chan_switch_ann_action.switch_mode,
4047 frm.ext_chan_switch_ann_action.new_channel,
4048 frm.ext_chan_switch_ann_action.op_class);
Abhishek Singh518323d2015-10-19 17:42:01 +05304049
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304050 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05304051 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304052 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05304053 TXRX_FRM_802_11_MGMT,
4054 ANI_TXDIR_TODS,
4055 7,
4056 lim_tx_complete, frame,
Abhishek Singh345be412019-11-19 10:59:29 +05304057 txFlag, vdev_id, 0,
Naveen Rawat296a5182017-09-25 14:02:48 -07004058 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304059 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304060 session_entry->peSessionId, qdf_status));
4061 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004062 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304063 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05304064 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004065 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05304066 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004067 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05304068} /* End lim_send_extended_chan_switch_action_frame */
4069
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304070
4071/**
4072 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
4073 * sent over the air
4074 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304075 * @context: pointer to global mac
4076 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304077 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304078 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304079 *
4080 * Return: This returns QDF_STATUS
4081 */
4082
4083static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304084 void *context,
4085 qdf_nbuf_t buf,
4086 uint32_t tx_complete,
4087 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304088{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004089 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08004090 if (buf)
4091 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304092 return QDF_STATUS_SUCCESS;
4093}
4094
4095/**
4096 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
4097 * p2p oper chan change confirm action frame
4098 * @mac_ctx: pointer to global mac structure
4099 * @peer: Destination mac.
4100 * @session_entry: session entry
4101 *
4102 * This function is called to send p2p oper chan change confirm action frame.
4103 *
4104 * Return: success if frame is sent else return failure
4105 */
4106
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004107QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004108lim_p2p_oper_chan_change_confirm_action_frame(struct mac_context *mac_ctx,
Jeff Johnsona7815652018-11-18 22:58:30 -08004109 tSirMacAddr peer, struct pe_session *session_entry)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304110{
4111 tDot11fp2p_oper_chan_change_confirm frm;
4112 uint8_t *frame;
4113 tpSirMacMgmtHdr mac_hdr;
4114 uint32_t num_bytes, n_payload, status;
4115 void *packet;
4116 QDF_STATUS qdf_status;
4117 uint8_t tx_flag = 0;
Abhishek Singh345be412019-11-19 10:59:29 +05304118 uint8_t vdev_id = 0;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304119
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004120 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004121 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004122 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304123 }
4124
Abhishek Singh345be412019-11-19 10:59:29 +05304125 vdev_id = session_entry->smeSessionId;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304126
hangtian127c9532019-01-12 13:29:07 +08004127 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304128
4129 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
4130
4131 qdf_mem_copy(frm.p2p_action_oui.oui_data,
4132 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
4133 frm.p2p_action_subtype.subtype = 0x04;
4134 frm.DialogToken.token = 0x0;
4135
4136 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004137 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304138 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
4139 }
4140
4141 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004142 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304143 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
4144 populate_dot11f_operating_mode(mac_ctx,
4145 &frm.OperatingMode, session_entry);
4146 }
4147
4148 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
4149 &frm, &n_payload);
4150 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004151 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304152 /* We'll fall back on the worst case scenario*/
4153 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
4154 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004155 pe_warn("There were warnings while calculating the packed size (0x%08x)",
4156 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304157 }
4158
4159 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
4160
4161 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
4162 (void **) &frame, (void **) &packet);
4163
4164 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004165 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004166 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304167 }
4168
hangtian127c9532019-01-12 13:29:07 +08004169 qdf_mem_zero(frame, num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304170
4171 /* Next, fill out the buffer descriptor */
4172 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304173 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304174 mac_hdr = (tpSirMacMgmtHdr) frame;
4175 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
4176 (uint8_t *) session_entry->bssId,
4177 sizeof(tSirMacAddr));
4178
4179 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
4180 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
4181 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004182 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304183 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004184 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304185 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004186 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304187 status);
4188 }
4189
Liangwei Dong419d7302019-07-15 15:38:28 +08004190 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
4191 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
4192 session_entry->opmode == QDF_P2P_GO_MODE) {
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304193 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4194 }
Liangwei Dong419d7302019-07-15 15:38:28 +08004195 pe_debug("Send frame on channel freq %d to mac "
4196 QDF_MAC_ADDR_STR, session_entry->curr_op_freq,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07004197 QDF_MAC_ADDR_ARRAY(peer));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304198
4199 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4200 session_entry->peSessionId, mac_hdr->fc.subType));
4201
4202 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4203 (uint16_t)num_bytes,
4204 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4205 7, lim_tx_complete, frame,
4206 lim_oper_chan_change_confirm_tx_complete_cnf,
Abhishek Singh345be412019-11-19 10:59:29 +05304207 tx_flag, vdev_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304208
4209 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4210 session_entry->peSessionId, qdf_status));
4211 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004212 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304213 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004214 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304215 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004216 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304217}
4218
4219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220/**
4221 * \brief Send a Neighbor Report Request Action frame
4222 *
4223 *
Jeff Johnson99f25042018-11-21 22:49:06 -08004224 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 *
4226 * \param pNeighborReq Address of a tSirMacNeighborReportReq
4227 *
4228 * \param peer mac address of peer station.
4229 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004230 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004232 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233 *
4234 *
4235 */
4236
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004237QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004238lim_send_neighbor_report_request_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004239 tpSirMacNeighborReportReq pNeighborReq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004240 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304242 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 tDot11fNeighborReportRequest frm;
4244 uint8_t *pFrame;
4245 tpSirMacMgmtHdr pMacHdr;
4246 uint32_t nBytes, nPayload, nStatus;
4247 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304248 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 uint8_t txFlag = 0;
4250 uint8_t smeSessionId = 0;
4251
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004252 if (!pe_session) {
4253 pe_err("(!psession) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004254 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004256 smeSessionId = pe_session->smeSessionId;
hangtian127c9532019-01-12 13:29:07 +08004257 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004259 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004260 frm.Action.action = RRM_NEIGHBOR_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004261 frm.DialogToken.token = pNeighborReq->dialogToken;
4262
4263 if (pNeighborReq->ssid_present) {
Jeff Johnson99f25042018-11-21 22:49:06 -08004264 populate_dot11f_ssid(mac, &pNeighborReq->ssid, &frm.SSID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 }
4266
4267 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004268 dot11f_get_packed_neighbor_report_request_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004270 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271 nStatus);
4272 /* We'll fall back on the worst case scenario: */
4273 nPayload = sizeof(tDot11fNeighborReportRequest);
4274 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004275 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4276 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 }
4278
4279 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4280
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304281 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4283 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304284 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004285 pe_err("Failed to allocate %d bytes for a Neighbor "
4286 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004287 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288 }
4289 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004290 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291
4292 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004293 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304294 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295
4296 /* Update A3 with the BSSID */
4297 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4298
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004299 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004301 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302
4303 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004304 nStatus = dot11f_pack_neighbor_report_request(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 &frm,
4306 pFrame +
4307 sizeof(tSirMacMgmtHdr),
4308 nPayload, &nPayload);
4309
4310 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004311 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 nStatus);
4313
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004314 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304315 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316 goto returnAfterError;
4317 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004318 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4319 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 }
4321
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004322 pe_debug("Sending a Neighbor Report Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004323 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324
Liangwei Dong419d7302019-07-15 15:38:28 +08004325 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4326 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4327 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304330 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004331 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004332 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 pPacket,
4334 (uint16_t) nBytes,
4335 TXRX_FRM_802_11_MGMT,
4336 ANI_TXDIR_TODS,
4337 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004338 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304339 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004340 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304341 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004342 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304343 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304345 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004347 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348
4349returnAfterError:
4350 cds_packet_free((void *)pPacket);
4351
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304352 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353} /* End lim_send_neighbor_report_request_frame. */
4354
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004355QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004356lim_send_link_report_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004357 tpSirMacLinkReport pLinkReport,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004358 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304360 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004361 tDot11fLinkMeasurementReport frm;
4362 uint8_t *pFrame;
4363 tpSirMacMgmtHdr pMacHdr;
4364 uint32_t nBytes, nPayload, nStatus;
4365 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304366 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004367 uint8_t txFlag = 0;
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304368 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004370 if (!pe_session) {
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304371 pe_err("RRM: Send link report: NULL PE session");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004372 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373 }
4374
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304375 vdev_id = pe_session->vdev_id;
hangtian127c9532019-01-12 13:29:07 +08004376 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004378 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004379 frm.Action.action = RRM_LINK_MEASUREMENT_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 frm.DialogToken.token = pLinkReport->dialogToken;
4381
4382 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4383 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4384 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4385 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4386 /* such case this way than changing the frame parser. */
Srinivas Girigowda61771262019-04-01 11:55:19 -07004387 frm.TPCEleID.TPCId = WLAN_ELEMID_TPCREP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388 frm.TPCEleLen.TPCLen = 2;
4389 frm.TxPower.txPower = pLinkReport->txPower;
4390 frm.LinkMargin.linkMargin = 0;
4391
4392 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4393 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4394 frm.RCPI.rcpi = pLinkReport->rcpi;
4395 frm.RSNI.rsni = pLinkReport->rsni;
4396
4397 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004398 dot11f_get_packed_link_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004400 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 /* We'll fall back on the worst case scenario: */
4402 nPayload = sizeof(tDot11fLinkMeasurementReport);
4403 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004404 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4405 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406 }
4407
4408 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4409
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304410 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4412 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304413 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004414 pe_err("Failed to allocate %d bytes for a Link "
4415 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004416 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 }
4418 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004419 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420
4421 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004422 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304423 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424
4425 /* Update A3 with the BSSID */
4426 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4427
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004428 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004429
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004430 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431
4432 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004433 nStatus = dot11f_pack_link_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004434 &frm,
4435 pFrame +
4436 sizeof(tSirMacMgmtHdr),
4437 nPayload, &nPayload);
4438
4439 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004440 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004442 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304443 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004444 goto returnAfterError;
4445 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004446 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 nStatus);
4448 }
4449
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304450 pe_warn("RRM: Sending Link Report to %pM on vdev[%d]", peer, vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451
Liangwei Dong419d7302019-07-15 15:38:28 +08004452 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4453 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4454 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304457 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004458 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004459 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460 pPacket,
4461 (uint16_t) nBytes,
4462 TXRX_FRM_802_11_MGMT,
4463 ANI_TXDIR_TODS,
4464 7, lim_tx_complete, pFrame, txFlag,
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304465 vdev_id, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304466 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004467 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304468 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004469 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304470 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004471 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304472 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004474 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475
4476returnAfterError:
4477 cds_packet_free((void *)pPacket);
4478
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304479 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480} /* End lim_send_link_report_action_frame. */
4481
sheenam monga26165ab2020-02-23 05:25:01 +05304482#ifdef WLAN_FEATURE_BCN_RPT_VSIE
4483/**
4484 * lim_fill_beacon_report_error_vsie: To fill beacon report error vsie
4485 * @param pe_session: session
4486 * @param ie_buf: double pointer that holds address of error vsie
4487 * @param error_code: beacon_report_status_code
4488 *
4489 * @return QDF_STATUS: success/failure
4490 */
4491static QDF_STATUS
4492lim_fill_beacon_report_error_vsie(struct pe_session *pe_session,
4493 uint8_t **ie_buf, uint8_t *ie_len,
4494 enum beacon_report_status_code
4495 error_code)
4496{
4497 uint8_t *buf = NULL, *vsie_ie = NULL;
4498
4499 /*
4500 * Vendor specific IE to be advertised in beacon report response
4501 * req:
4502 * Type 0xDD
4503 * Length 0x0A
4504 * OUI 0x00 0x00 0x0F
4505 * Type 0x22
4506 * subtype 0x05
4507 * Version 0x01
4508 * Length 0x01
4509 * Data 0x00-0x07 (beacon report error)
4510 * supported)
4511 */
4512 vsie_ie = qdf_mem_malloc(BEACON_RPT_ERR_VSIE_STA_IE_LEN + 2);
4513 if (!vsie_ie)
4514 return QDF_STATUS_E_FAILURE;
4515
4516 /* Fill the Vendor IE Type (0xDD) */
4517 buf = vsie_ie;
4518 *buf = WLAN_ELEMID_VENDOR;
4519 buf++;
4520
4521 /* Fill the Vendor IE length (0x0A) */
4522 *buf = BEACON_RPT_ERR_VSIE_STA_IE_LEN;
4523 buf++;
4524
4525 /*
4526 * Fill the vsie Vendor specific OUI(0x00 0x00 0x0F 0x22)
4527 */
4528 qdf_mem_copy(buf, BEACON_RPT_ERR_VSIE_STA_OUI,
4529 BEACON_RPT_ERR_VSIE_OUI_LEN);
4530 buf += BEACON_RPT_ERR_VSIE_OUI_LEN;
4531
4532 /*
4533 * Fill Subtype version and length (0x05 0x01 0x01)
4534 */
4535 qdf_mem_copy(buf, BEACON_RPT_ERR_VSIE_OUI_DATA,
4536 BEACON_RPT_ERR_VSIE_DATA_LEN);
4537 buf += BEACON_RPT_ERR_VSIE_DATA_LEN;
4538
4539 /* Fill error code */
4540 *buf = error_code;
4541
4542 *ie_len = BEACON_RPT_ERR_VSIE_STA_IE_LEN + 2;
4543 *ie_buf = vsie_ie;
4544 return QDF_STATUS_SUCCESS;
4545}
4546#else
4547static QDF_STATUS
4548lim_fill_beacon_report_error_vsie(struct pe_session *pe_session,
4549 uint8_t **ie_buf, uint8_t *ie_len,
4550 enum beacon_report_status_code
4551 error_code)
4552{
4553 return QDF_STATUS_SUCCESS;
4554}
4555#endif
4556
4557#ifdef WLAN_FEATURE_BCN_RPT_VSIE
4558static bool
4559lim_check_bcn_rpt_err_vsie_status(struct mac_context *mac,
4560 enum beacon_report_status_code error_code)
4561{
4562 if (mac->mlme_cfg->sta.bcn_rpt_err_vsie && error_code !=
4563 BCN_RPT_SUCCESS) {
4564 return true;
4565 }
4566
4567 return false;
4568}
4569#else
4570static bool
4571lim_check_bcn_rpt_err_vsie_status(struct mac_context *mac,
4572 enum beacon_report_status_code error_code)
4573{
4574 return false;
4575}
4576#endif
4577
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004578QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004579lim_send_radio_measure_report_action_frame(struct mac_context *mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304580 uint8_t dialog_token,
4581 uint8_t num_report,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304582 bool is_last_frame,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304583 tpSirMacRadioMeasureReport pRRMReport,
4584 tSirMacAddr peer,
sheenam monga26165ab2020-02-23 05:25:01 +05304585 struct pe_session *pe_session,
4586 enum beacon_report_status_code error_code)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304588 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 uint8_t *pFrame;
4590 tpSirMacMgmtHdr pMacHdr;
sheenam monga26165ab2020-02-23 05:25:01 +05304591 uint32_t nPayload, nStatus;
4592 uint32_t nBytes = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304594 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 uint8_t i;
4596 uint8_t txFlag = 0;
4597 uint8_t smeSessionId = 0;
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304598 bool is_last_report = false;
sheenam monga26165ab2020-02-23 05:25:01 +05304599 uint8_t *bcn_rpt_err_vsie = NULL;
4600 uint8_t vs_ie_len = 0;
4601 bool bcn_rpt_err_vsie_enable = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602
4603 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304604 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004605 if (!frm)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004606 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004608 if (!pe_session) {
sheenam monga724306f2020-02-08 14:59:35 +05304609 pe_err("session not found");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304610 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004611 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613
sheenam monga26165ab2020-02-23 05:25:01 +05304614 bcn_rpt_err_vsie_enable = lim_check_bcn_rpt_err_vsie_status(mac,
4615 error_code);
4616
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004617 smeSessionId = pe_session->smeSessionId;
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004618
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304619
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004620 frm->Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004621 frm->Action.action = RRM_RADIO_MEASURE_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 frm->DialogToken.token = dialog_token;
4623
4624 frm->num_MeasurementReport =
4625 (num_report >
4626 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4627 num_report;
4628
4629 for (i = 0; i < frm->num_MeasurementReport; i++) {
4630 frm->MeasurementReport[i].type = pRRMReport[i].type;
4631 frm->MeasurementReport[i].token = pRRMReport[i].token;
4632 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4633 switch (pRRMReport[i].type) {
4634 case SIR_MAC_RRM_BEACON_TYPE:
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304635 /*
4636 * Last beacon report indication needs to be set to 1
4637 * only for the last report in the last frame
4638 */
4639 if (is_last_frame &&
4640 (i == (frm->num_MeasurementReport - 1)))
4641 is_last_report = true;
4642
Jeff Johnson99f25042018-11-21 22:49:06 -08004643 populate_dot11f_beacon_report(mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304644 &frm->MeasurementReport[i],
4645 &pRRMReport[i].report.
4646 beaconReport,
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304647 is_last_report);
sheenam monga26165ab2020-02-23 05:25:01 +05304648
4649 if (bcn_rpt_err_vsie_enable) {
4650 lim_fill_beacon_report_error_vsie
4651 (pe_session,
4652 &bcn_rpt_err_vsie,
4653 &vs_ie_len, error_code);
4654 nBytes = vs_ie_len;
4655 }
4656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657 frm->MeasurementReport[i].incapable =
4658 pRRMReport[i].incapable;
4659 frm->MeasurementReport[i].refused =
4660 pRRMReport[i].refused;
4661 frm->MeasurementReport[i].present = 1;
4662 break;
4663 default:
4664 frm->MeasurementReport[i].incapable =
4665 pRRMReport[i].incapable;
4666 frm->MeasurementReport[i].refused =
4667 pRRMReport[i].refused;
4668 frm->MeasurementReport[i].present = 1;
4669 break;
4670 }
4671 }
4672
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05304673
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004675 dot11f_get_packed_radio_measurement_report_size(mac, frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 if (DOT11F_FAILED(nStatus)) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05304677 pe_nofl_err("TX: [802.11 RRM] Failed to get packed size for RM Report (0x%08x)",
4678 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679 /* We'll fall back on the worst case scenario: */
4680 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304681 qdf_mem_free(frm);
sheenam monga26165ab2020-02-23 05:25:01 +05304682 qdf_mem_free(bcn_rpt_err_vsie);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004683 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 } else if (DOT11F_WARNED(nStatus)) {
sheenam monga724306f2020-02-08 14:59:35 +05304685 pe_warn("Warnings while calculating the size for Radio Measure Report (0x%08x)",
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004686 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 }
4688
sheenam monga26165ab2020-02-23 05:25:01 +05304689 nBytes += nPayload + sizeof(tSirMacMgmtHdr);
4690
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304692 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4694 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304695 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05304696 pe_nofl_err("TX: [802.11 RRM] Allocation of %d bytes failed for RM"
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004697 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304698 qdf_mem_free(frm);
sheenam monga26165ab2020-02-23 05:25:01 +05304699 qdf_mem_free(bcn_rpt_err_vsie);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004700 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004701 }
4702 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004703 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704
4705 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004706 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304707 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708
4709 /* Update A3 with the BSSID */
4710 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4711
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004712 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004713
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004714 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004715
4716 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004717 nStatus = dot11f_pack_radio_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 frm,
4719 pFrame +
4720 sizeof(tSirMacMgmtHdr),
4721 nPayload, &nPayload);
4722
4723 if (DOT11F_FAILED(nStatus)) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05304724 pe_nofl_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725 nStatus);
4726
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004727 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304728 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 goto returnAfterError;
4730 } else if (DOT11F_WARNED(nStatus)) {
sheenam monga724306f2020-02-08 14:59:35 +05304731 pe_warn("Warnings while packing Radio Measure Report (0x%08x)",
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004732 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004733 }
4734
sheenam monga26165ab2020-02-23 05:25:01 +05304735 if (bcn_rpt_err_vsie_enable) {
4736 qdf_mem_copy(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
4737 bcn_rpt_err_vsie, vs_ie_len);
4738 }
4739
sheenam monga724306f2020-02-08 14:59:35 +05304740 pe_nofl_info("TX: %s seq_no:%d dialog_token:%d no. of APs:%d is_last_rpt:%d num_report: %d peer:%pM",
4741 frm->MeasurementReport[0].type == SIR_MAC_RRM_BEACON_TYPE ?
4742 "[802.11 BCN_RPT]" : "[802.11 RRM]",
4743 (pMacHdr->seqControl.seqNumHi << HIGH_SEQ_NUM_OFFSET |
4744 pMacHdr->seqControl.seqNumLo),
4745 dialog_token, frm->num_MeasurementReport,
4746 is_last_report, num_report, peer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747
Liangwei Dong419d7302019-07-15 15:38:28 +08004748 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4749 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4750 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304753 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004754 pe_session->peSessionId, pMacHdr->fc.subType));
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05304755 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t)nBytes,
4756 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4757 7, lim_tx_complete, pFrame, txFlag,
4758 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304759 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004760 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304761 if (QDF_STATUS_SUCCESS != qdf_status) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05304762 pe_nofl_err("TX: [802.11 RRM] Send FAILED! err_status [%d]",
4763 qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304764 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004765 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 }
4767
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05304768 qdf_mem_free(frm);
sheenam monga26165ab2020-02-23 05:25:01 +05304769 qdf_mem_free(bcn_rpt_err_vsie);
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05304770 return status_code;
4771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004772returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304773 qdf_mem_free(frm);
sheenam monga26165ab2020-02-23 05:25:01 +05304774 qdf_mem_free(bcn_rpt_err_vsie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775 cds_packet_free((void *)pPacket);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304776 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777}
4778
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779#ifdef WLAN_FEATURE_11W
4780/**
4781 * \brief Send SA query request action frame to peer
4782 *
4783 * \sa lim_send_sa_query_request_frame
4784 *
4785 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004786 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 *
4788 * \param transId Transaction identifier
4789 *
4790 * \param peer The Mac address of the station to which this action frame is addressed
4791 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004792 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004793 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004794 * \return QDF_STATUS_SUCCESS if setup completes successfully
4795 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004796 */
4797
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004798QDF_STATUS lim_send_sa_query_request_frame(struct mac_context *mac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004799 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004800 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004801{
4802
4803 tDot11fSaQueryReq frm; /* SA query request action frame */
4804 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004805 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004806 tpSirMacMgmtHdr pMacHdr;
4807 uint32_t nBytes, nPayload, nStatus;
4808 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304809 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810 uint8_t txFlag = 0;
4811 uint8_t smeSessionId = 0;
4812
hangtian127c9532019-01-12 13:29:07 +08004813 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004814 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815 /* 11w action field is :
4816 action: 0 --> SA Query Request action frame
4817 action: 1 --> SA Query Response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004818 frm.Action.action = SA_QUERY_REQUEST;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004819 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304820 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004821
Jeff Johnson99f25042018-11-21 22:49:06 -08004822 nStatus = dot11f_get_packed_sa_query_req_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004823 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004824 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825 nStatus);
4826 /* We'll fall back on the worst case scenario: */
4827 nPayload = sizeof(tDot11fSaQueryReq);
4828 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004829 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4830 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 }
4832
4833 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304834 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304836 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004837 pe_err("Failed to allocate %d bytes for a SA Query Request "
4838 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004839 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004840 }
4841 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004842 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843
4844 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004845 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304846 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847
4848 /* Update A3 with the BSSID */
4849 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4850
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004851 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004852
4853 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4854 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004855 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856
4857 /* Pack 11w SA Query Request frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004858 nStatus = dot11f_pack_sa_query_req(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859 &frm,
4860 pFrame + sizeof(tSirMacMgmtHdr),
4861 nPayload, &nPayload);
4862
4863 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004864 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004865 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004866 /* FIXME - Need to convert to QDF_STATUS */
4867 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004868 goto returnAfterError;
4869 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004870 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 nStatus);
4872 }
4873
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004874 pe_debug("Sending an SA Query Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004875 lim_print_mac_addr(mac, peer, LOGD);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004876 pe_debug("Sending an SA Query Request from ");
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304877 lim_print_mac_addr(mac, pe_session->self_mac_addr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878
Liangwei Dong419d7302019-07-15 15:38:28 +08004879 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4880 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4881 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304883
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004884 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885
Jeff Johnson99f25042018-11-21 22:49:06 -08004886 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004887 pPacket,
4888 (uint16_t) nBytes,
4889 TXRX_FRM_802_11_MGMT,
4890 ANI_TXDIR_TODS,
4891 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004892 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304893 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004894 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004895 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896 /* Pkt will be freed up by the callback */
4897 return nSirStatus;
4898 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004899 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 }
4901
4902returnAfterError:
4903 cds_packet_free((void *)pPacket);
4904 return nSirStatus;
4905} /* End lim_send_sa_query_request_frame */
4906
4907/**
4908 * \brief Send SA query response action frame to peer
4909 *
4910 * \sa lim_send_sa_query_response_frame
4911 *
4912 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004913 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 *
4915 * \param transId Transaction identifier received in SA query request action frame
4916 *
4917 * \param peer The Mac address of the AP to which this action frame is addressed
4918 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004919 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004921 * \return QDF_STATUS_SUCCESS if setup completes successfully
4922 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004923 */
4924
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004925QDF_STATUS lim_send_sa_query_response_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 uint8_t *transId, tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004927 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004928{
4929
Jeff Johnson47d75242018-05-12 15:58:53 -07004930 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004932 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 tpSirMacMgmtHdr pMacHdr;
4934 uint32_t nBytes, nPayload, nStatus;
4935 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304936 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 uint8_t txFlag = 0;
4938 uint8_t smeSessionId = 0;
4939
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004940 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941
hangtian127c9532019-01-12 13:29:07 +08004942 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004943 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 /*11w action field is :
4945 action: 0 --> SA query request action frame
4946 action: 1 --> SA query response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004947 frm.Action.action = SA_QUERY_RESPONSE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948 /*11w SA query response transId is same as
4949 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304950 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951
Jeff Johnson99f25042018-11-21 22:49:06 -08004952 nStatus = dot11f_get_packed_sa_query_rsp_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004954 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 nStatus);
4956 /* We'll fall back on the worst case scenario: */
4957 nPayload = sizeof(tDot11fSaQueryRsp);
4958 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004959 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4960 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 }
4962
4963 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304964 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004965 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304966 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004967 pe_err("Failed to allocate %d bytes for a SA query response"
4968 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004969 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 }
4971 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004972 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004973
4974 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004975 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304976 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004977
4978 /* Update A3 with the BSSID */
4979 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4980
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004981 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004982
4983 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4984 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004985 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004986
4987 /* Pack 11w SA query response frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004988 nStatus = dot11f_pack_sa_query_rsp(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004989 &frm,
4990 pFrame + sizeof(tSirMacMgmtHdr),
4991 nPayload, &nPayload);
4992
4993 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004994 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004995 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004996 /* FIXME - Need to convert to QDF_STATUS */
4997 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004998 goto returnAfterError;
4999 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07005000 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001 nStatus);
5002 }
5003
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07005004 pe_debug("Sending a SA Query Response to");
Jeff Johnson99f25042018-11-21 22:49:06 -08005005 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005006
Liangwei Dong419d7302019-07-15 15:38:28 +08005007 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
5008 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
5009 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005011
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305012 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005013 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08005014 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015 pPacket,
5016 (uint16_t) nBytes,
5017 TXRX_FRM_802_11_MGMT,
5018 ANI_TXDIR_TODS,
5019 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07005020 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305021 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005022 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305023 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07005024 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005025 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005026 /* Pkt will be freed up by the callback */
5027 return nSirStatus;
5028 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005029 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030 }
5031
5032returnAfterError:
5033 cds_packet_free((void *)pPacket);
5034 return nSirStatus;
5035} /* End lim_send_sa_query_response_frame */
5036#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005037
Manjunathappa Prakash458f6fe2019-05-13 18:33:01 -07005038#if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390) || \
Alok Kumar2107a962020-01-13 15:35:29 +05305039 defined(QCA_WIFI_QCA6490) || defined(QCA_WIFI_QCA6750)
Jinwei Chen332b5cf2019-03-05 13:26:17 +08005040#ifdef WLAN_FEATURE_11AX
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07005041#define IS_PE_SESSION_HE_MODE(_session) ((_session)->he_capable)
Jinwei Chen332b5cf2019-03-05 13:26:17 +08005042#else
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07005043#define IS_PE_SESSION_HE_MODE(_session) false
Jinwei Chen332b5cf2019-03-05 13:26:17 +08005044#endif /* WLAN_FEATURE_11AX */
5045#else
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07005046#define IS_PE_SESSION_HE_MODE(_session) false
Jinwei Chen332b5cf2019-03-05 13:26:17 +08005047#endif
5048
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005049/**
5050 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
5051 * @mac_ctx: mac context
5052 * @peer_mac: Peer MAC address
5053 * @tid: TID for which addba response is being sent
5054 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08005055 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07005056 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005057 *
5058 * This function is called when ADDBA request is successful. ADDBA response is
5059 * setup by calling addba_response_setup API and frame is then sent out OTA.
5060 *
5061 * Return: QDF_STATUS
5062 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08005063QDF_STATUS lim_send_addba_response_frame(struct mac_context *mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08005064 tSirMacAddr peer_mac, uint16_t tid,
Jeff Johnsona7815652018-11-18 22:58:30 -08005065 struct pe_session *session, uint8_t addba_extn_present,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07005066 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005067{
5068
5069 tDot11faddba_rsp frm;
5070 uint8_t *frame_ptr;
5071 tpSirMacMgmtHdr mgmt_hdr;
5072 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07005073 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005074 QDF_STATUS qdf_status;
5075 uint8_t tx_flag = 0;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05305076 uint8_t vdev_id = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005077 uint16_t buff_size, status_code, batimeout;
gaurank kathpalia8197e352019-09-11 16:09:53 +05305078 uint8_t dialog_token;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005079 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08005080 uint8_t he_frag = 0;
Yu Wang36d52102019-09-20 12:08:04 +08005081 tpDphHashNode sta_ds;
5082 uint16_t aid;
5083 bool he_cap = false;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005084
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05305085 vdev_id = session->vdev_id;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005086
Vevek Venkatesan0ac759f2019-10-03 04:14:29 +05305087 cdp_addba_responsesetup(soc, peer_mac, vdev_id, tid,
5088 &dialog_token, &status_code, &buff_size,
5089 &batimeout);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005090
hangtian127c9532019-01-12 13:29:07 +08005091 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07005092 frm.Category.category = ACTION_CATEGORY_BACK;
Srinivas Girigowdaef0d7142019-05-17 17:07:47 -07005093 frm.Action.action = ADDBA_RESPONSE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005094
5095 frm.DialogToken.token = dialog_token;
5096 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005097 if (mac_ctx->reject_addba_req) {
5098 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
5099 pe_err("refused addba req");
5100 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005101 frm.addba_param_set.tid = tid;
Yu Wang36d52102019-09-20 12:08:04 +08005102
5103 if (lim_is_session_he_capable(session)) {
5104 sta_ds = dph_lookup_hash_entry(mac_ctx, peer_mac, &aid,
5105 &session->dph.dphHashTable);
5106 if (sta_ds)
5107 he_cap = lim_is_sta_he_capable(sta_ds);
5108 }
5109
5110 if (he_cap)
Kiran Kumar Lokere22f05d42019-06-28 18:33:43 -07005111 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
5112 else
5113 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Yu Wang36d52102019-09-20 12:08:04 +08005114
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08005115 if (mac_ctx->usr_cfg_ba_buff_size)
5116 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07005117
5118 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
5119 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
5120
5121 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
5122 if (session->active_ba_64_session) {
5123 frm.addba_param_set.buff_size =
5124 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
5125 }
5126 } else if (!session->active_ba_64_session) {
5127 session->active_ba_64_session = true;
5128 }
Jianmin Zhufd3b8872020-02-14 17:25:04 +08005129 if (frm.addba_param_set.buff_size > buff_size) {
5130 pe_debug("buff size: %d larger than peer's capability: %d",
5131 frm.addba_param_set.buff_size, buff_size);
5132 frm.addba_param_set.buff_size = buff_size;
5133 }
Jinwei Chen332b5cf2019-03-05 13:26:17 +08005134
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07005135 /* Enable RX AMSDU only in HE mode if supported */
Jinwei Chen332b5cf2019-03-05 13:26:17 +08005136 if (mac_ctx->is_usr_cfg_amsdu_enabled &&
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07005137 ((IS_PE_SESSION_HE_MODE(session) &&
5138 WLAN_REG_IS_24GHZ_CH_FREQ(session->curr_op_freq)) ||
5139 WLAN_REG_IS_5GHZ_CH_FREQ(session->curr_op_freq)))
Arif Hussain0e246802018-05-01 18:13:44 -07005140 frm.addba_param_set.amsdu_supp = amsdu_support;
5141 else
5142 frm.addba_param_set.amsdu_supp = 0;
Jinwei Chen332b5cf2019-03-05 13:26:17 +08005143
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08005144 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005145 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08005146 if (addba_extn_present) {
5147 frm.addba_extn_element.present = 1;
5148 frm.addba_extn_element.no_fragmentation = 1;
5149 if (lim_is_session_he_capable(session)) {
5150 he_frag = lim_get_session_he_frag_cap(session);
5151 if (he_frag != 0) {
5152 frm.addba_extn_element.no_fragmentation = 0;
5153 frm.addba_extn_element.he_frag_operation =
5154 he_frag;
5155 }
5156 }
5157 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005158
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005159 pe_debug("Sending a ADDBA Response from %pM to %pM",
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05305160 session->self_mac_addr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005161 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005162 tid, frm.DialogToken.token, frm.Status.status,
5163 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08005164 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
5165 addba_extn_present,
5166 lim_is_session_he_capable(session),
5167 frm.addba_extn_element.no_fragmentation,
5168 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005169
5170 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
5171 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005172 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005173 status);
5174 /* We'll fall back on the worst case scenario: */
5175 payload_size = sizeof(tDot11faddba_rsp);
5176 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005177 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 -08005178 }
5179
5180 num_bytes = payload_size + sizeof(*mgmt_hdr);
5181 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
5182 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07005183 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005184 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
5185 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005186 return QDF_STATUS_E_FAILURE;
5187 }
hangtian127c9532019-01-12 13:29:07 +08005188 qdf_mem_zero(frame_ptr, num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005189
5190 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05305191 SIR_MAC_MGMT_ACTION, peer_mac, session->self_mac_addr);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005192
5193 /* Update A3 with the BSSID */
5194 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
5195 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
5196
5197 /* ADDBA Response is a robust mgmt action frame,
5198 * set the "protect" (aka WEP) bit in the FC
5199 */
5200 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
5201
5202 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
5203 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
5204 &payload_size);
5205
5206 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005207 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005208 status);
5209 qdf_status = QDF_STATUS_E_FAILURE;
5210 goto error_addba_rsp;
5211 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005212 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005213 status);
5214 }
5215
5216
Liangwei Dong419d7302019-07-15 15:38:28 +08005217 if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
5218 session->opmode == QDF_P2P_CLIENT_MODE ||
5219 session->opmode == QDF_P2P_GO_MODE)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005220 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005221
5222 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
5223 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07005224 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
5225 (uint16_t)num_bytes,
5226 TXRX_FRM_802_11_MGMT,
5227 ANI_TXDIR_TODS, 7,
5228 NULL, frame_ptr,
5229 lim_addba_rsp_tx_complete_cnf,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05305230 tx_flag, vdev_id,
Krunal Sonid2136c72018-06-01 17:26:39 -07005231 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005232 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5233 session->peSessionId, qdf_status));
5234 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005235 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005236 qdf_status);
chenguo90c68462019-01-24 18:27:01 +08005237 return QDF_STATUS_E_FAILURE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005238 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07005239 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005240 }
5241
5242error_addba_rsp:
5243 cds_packet_free((void *)pkt_ptr);
5244 return qdf_status;
5245}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305246
5247/**
5248 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
5249 * @mac_ctx Pointer to Global MAC structure
5250 * @mb_msg: Received message info
5251 * @msg_len: Received message length
5252 * @packet: Packet to be transmitted
5253 * @frame: Received frame
5254 *
5255 * Return: None
5256 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08005257static void lim_tx_mgmt_frame(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305258 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
5259 void *packet, uint8_t *frame)
5260{
5261 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5262 QDF_STATUS qdf_status;
Abhishek Singhefe21e62019-09-20 10:03:24 +05305263 uint8_t vdev_id = 0;
Jeff Johnsona7815652018-11-18 22:58:30 -08005264 struct pe_session *session;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305265 uint16_t auth_ack_status;
5266 enum rateid min_rid = RATEID_DEFAULT;
5267
Abhishek Singh345be412019-11-19 10:59:29 +05305268 vdev_id = mb_msg->vdev_id;
Abhishek Singhefe21e62019-09-20 10:03:24 +05305269 session = pe_find_session_by_vdev_id(mac_ctx, vdev_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07005270 if (!session) {
Wu Gao7c0a23f2019-03-12 14:16:37 +08005271 cds_packet_free((void *)packet);
Abhishek Singhefe21e62019-09-20 10:03:24 +05305272 pe_err("session not found for given vdev_id %d",
5273 vdev_id);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305274 return;
5275 }
5276
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05305277 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
5278 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305279
5280 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
5281 min_rid = lim_get_min_session_txrate(session);
5282
5283 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
5284 (uint16_t)msg_len,
5285 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
5286 7, lim_tx_complete, frame,
5287 lim_auth_tx_complete_cnf,
Abhishek Singhefe21e62019-09-20 10:03:24 +05305288 0, vdev_id, false, 0, min_rid);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305289 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5290 session->peSessionId, qdf_status));
5291 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05305292 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
5293 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305294 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
5295 auth_ack_status = SENT_FAIL;
5296 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005297 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305298 /* Pkt will be freed up by the callback */
5299 }
5300}
5301
Jeff Johnson9320c1e2018-12-02 13:09:20 -08005302void lim_send_mgmt_frame_tx(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305303 struct scheduler_msg *msg)
5304{
5305 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
5306 uint32_t msg_len;
5307 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
Abhishek Singh345be412019-11-19 10:59:29 +05305308 uint8_t vdev_id;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305309 QDF_STATUS qdf_status;
5310 uint8_t *frame;
5311 void *packet;
Srinivas Dasari76218492019-01-22 15:08:20 +05305312 tpSirMacMgmtHdr mac_hdr;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305313
5314 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
5315 pe_debug("sending fc->type: %d fc->subType: %d",
5316 fc->type, fc->subType);
5317
Abhishek Singh345be412019-11-19 10:59:29 +05305318 vdev_id = mb_msg->vdev_id;
Srinivas Dasari76218492019-01-22 15:08:20 +05305319 mac_hdr = (tpSirMacMgmtHdr)mb_msg->data;
5320
5321 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305322
5323 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
5324 (void **)&packet);
5325 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5326 pe_err("call to bufAlloc failed for AUTH frame");
5327 return;
5328 }
5329
5330 qdf_mem_copy(frame, mb_msg->data, msg_len);
5331
5332 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5333}