blob: aefee295f41376fa3375ebd03f403ba7659da52f [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Yue Mad03d10b2019-12-23 15:09:53 -08002 * Copyright (c) 2012-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
19/*
Naveen Rawatada5fac2016-01-28 16:24:32 -080020 * This file lim_process_assoc_req_frame.c contains the code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021 * for processing Re/Association Request Frame.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080022 */
23#include "cds_api.h"
24#include "ani_global.h"
25#include "wni_cfg.h"
26#include "sir_api.h"
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +053027#include "cfg_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080028
29#include "sch_api.h"
30#include "utils_api.h"
31#include "lim_types.h"
32#include "lim_utils.h"
33#include "lim_assoc_utils.h"
34#include "lim_security_utils.h"
35#include "lim_ser_des_utils.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080036#include "lim_admit_control.h"
37#include "cds_packet.h"
38#include "lim_session_utils.h"
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -070039#include "utils_parser.h"
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +053040#include "wlan_p2p_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080041
Anurag Chouhan6d760662016-02-20 16:05:43 +053042#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043#include "cds_utils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070044#include "wlan_utility.h"
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -070045#include "wlan_crypto_global_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046
47/**
48 * lim_convert_supported_channels - Parses channel support IE
Krunal Soni99752a12016-04-12 17:44:45 -070049 * @mac_ctx: A pointer to Global MAC structure
50 * @assoc_ind: A pointer to SME ASSOC/REASSOC IND
51 * @assoc_req: A pointer to ASSOC/REASSOC Request frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052 *
53 * This function is called by lim_process_assoc_req_frame() to
54 * parse the channel support IE in the Assoc/Reassoc Request
55 * frame, and send relevant information in the SME_ASSOC_IND
56 *
Krunal Soni99752a12016-04-12 17:44:45 -070057 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080058 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080059static void lim_convert_supported_channels(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -070060 tpLimMlmAssocInd assoc_ind,
61 tSirAssocReq *assoc_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062{
63 uint16_t i, j, index = 0;
Naveen Rawatada5fac2016-01-28 16:24:32 -080064 uint8_t first_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065 uint8_t chn_count;
Naveen Rawatada5fac2016-01-28 16:24:32 -080066 uint8_t next_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067 uint8_t channel_offset = 0;
Amruta Kulkarni453c4e22019-11-20 10:59:21 -080068 uint32_t chan_freq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069
70 if (assoc_req->supportedChannels.length >=
71 SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +053072 pe_err("Number of supported channels: %d is more than MAX",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073 assoc_req->supportedChannels.length);
74 assoc_ind->supportedChannels.numChnl = 0;
75 return;
76 }
77
78 for (i = 0; i < (assoc_req->supportedChannels.length); i++) {
79 /* Get First Channel Number */
Naveen Rawatada5fac2016-01-28 16:24:32 -080080 first_ch_no = assoc_req->supportedChannels.supportedChannels[i];
81 assoc_ind->supportedChannels.channelList[index] = first_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082 i++;
83 index++;
84
85 /* Get Number of Channels in a Subband */
Naveen Rawatada5fac2016-01-28 16:24:32 -080086 chn_count = assoc_req->supportedChannels.supportedChannels[i];
Nishank Aggarwal8935e442017-03-23 19:11:08 +053087 pe_debug("Rcv assoc_req: chnl: %d numOfChnl: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -080088 first_ch_no, chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089 if (index >= SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +053090 pe_warn("Ch count > max supported: %d", chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 assoc_ind->supportedChannels.numChnl = 0;
92 return;
93 }
94 if (chn_count <= 1)
95 continue;
Naveen Rawatada5fac2016-01-28 16:24:32 -080096 next_ch_no = first_ch_no;
Amruta Kulkarni453c4e22019-11-20 10:59:21 -080097 chan_freq = wlan_reg_legacy_chan_to_freq(mac_ctx->pdev,
98 first_ch_no);
99
100 if (REG_BAND_5G == lim_get_rf_band(chan_freq))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101 channel_offset = SIR_11A_FREQUENCY_OFFSET;
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800102 else if (REG_BAND_2G == lim_get_rf_band(chan_freq))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 channel_offset = SIR_11B_FREQUENCY_OFFSET;
104 else
105 continue;
106
107 for (j = 1; j < chn_count; j++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800108 next_ch_no += channel_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800109 assoc_ind->supportedChannels.channelList[index]
Naveen Rawatada5fac2016-01-28 16:24:32 -0800110 = next_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 index++;
112 if (index >= SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530113 pe_warn("Ch count > supported: %d", chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114 assoc_ind->supportedChannels.numChnl = 0;
115 return;
116 }
117 }
118 }
119
120 assoc_ind->supportedChannels.numChnl = (uint8_t) index;
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530121 pe_debug("Send AssocInd to WSM: minPwr: %d maxPwr: %d numChnl: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122 assoc_ind->powerCap.minTxPower,
123 assoc_ind->powerCap.maxTxPower,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800124 assoc_ind->supportedChannels.numChnl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125}
126
Naveen Rawatada5fac2016-01-28 16:24:32 -0800127/**
128 * lim_check_sta_in_pe_entries() - checks if sta exists in any dph tables.
Krunal Soni99752a12016-04-12 17:44:45 -0700129 * @mac_ctx: Pointer to Global MAC structure
130 * @hdr: A pointer to the MAC header
Poddar, Siddarth7ca1e082016-08-09 19:06:48 +0530131 * @sessionid - session id for which session is initiated
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800132 * @dup_entry: pointer for duplicate entry found
Naveen Rawatada5fac2016-01-28 16:24:32 -0800133 *
134 * This function is called by lim_process_assoc_req_frame() to check if STA
135 * entry already exists in any of the PE entries of the AP. If it exists, deauth
136 * will be sent on that session and the STA deletion will happen. After this,
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800137 * the ASSOC request will be processed. If the STA is already in deleting phase
138 * this will return failure so that assoc req will be rejected till STA is
139 * deleted.
Naveen Rawatada5fac2016-01-28 16:24:32 -0800140 *
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800141 * Return: QDF_STATUS.
Naveen Rawatada5fac2016-01-28 16:24:32 -0800142 */
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800143static QDF_STATUS lim_check_sta_in_pe_entries(struct mac_context *mac_ctx,
144 tpSirMacMgmtHdr hdr,
145 uint16_t sessionid,
146 bool *dup_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147{
148 uint8_t i;
Naveen Rawatada5fac2016-01-28 16:24:32 -0800149 uint16_t assoc_id = 0;
150 tpDphHashNode sta_ds = NULL;
Jeff Johnsoneac5aad2019-03-19 12:57:04 -0700151 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800153 *dup_entry = false;
Naveen Rawatada5fac2016-01-28 16:24:32 -0800154 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Jeff Johnsoneac5aad2019-03-19 12:57:04 -0700155 session = &mac_ctx->lim.gpSession[i];
156 if (session->valid &&
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530157 (session->opmode == QDF_SAP_MODE)) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800158 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa,
159 &assoc_id, &session->dph.dphHashTable);
160 if (sta_ds
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161#ifdef WLAN_FEATURE_11W
Poddar, Siddarth7ca1e082016-08-09 19:06:48 +0530162 && (!sta_ds->rmfEnabled ||
163 (sessionid != session->peSessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164#endif
165 ) {
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800166 if (sta_ds->mlmStaContext.mlmState ==
167 eLIM_MLM_WT_DEL_STA_RSP_STATE ||
168 sta_ds->mlmStaContext.mlmState ==
169 eLIM_MLM_WT_DEL_BSS_RSP_STATE ||
170 sta_ds->sta_deletion_in_progress) {
171 pe_debug(
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700172 "Deletion is in progress (%d) for peer:"QDF_MAC_ADDR_FMT" in mlmState %d",
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800173 sta_ds->sta_deletion_in_progress,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700174 QDF_MAC_ADDR_REF(sta_ds->staAddr),
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800175 sta_ds->mlmStaContext.mlmState);
176 *dup_entry = true;
177 return QDF_STATUS_E_AGAIN;
178 }
179 sta_ds->sta_deletion_in_progress = true;
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530180 pe_err("Sending Disassoc and Deleting existing STA entry:"
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700181 QDF_MAC_ADDR_FMT,
182 QDF_MAC_ADDR_REF(
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530183 session->self_mac_addr));
Sandeep Puligilla2eeaf6a2016-07-22 20:02:02 -0700184 lim_send_disassoc_mgmt_frame(mac_ctx,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800185 eSIR_MAC_UNSPEC_FAILURE_REASON,
186 (uint8_t *) hdr->sa, session, false);
Sandeep Puligilla2eeaf6a2016-07-22 20:02:02 -0700187 /*
188 * Cleanup Rx path posts eWNI_SME_DISASSOC_RSP
189 * msg to SME after delete sta which will update
190 * the userspace with disconnect
191 */
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700192 sta_ds->mlmStaContext.cleanupTrigger =
193 eLIM_DUPLICATE_ENTRY;
194 sta_ds->mlmStaContext.disassocReason =
195 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
196 lim_send_sme_disassoc_ind(mac_ctx, sta_ds,
197 session);
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800198 *dup_entry = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 break;
200 }
201 }
202 }
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800203
204 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205}
206
Naveen Rawatada5fac2016-01-28 16:24:32 -0800207/**
Krunal Soni99752a12016-04-12 17:44:45 -0700208 * lim_chk_sa_da() - checks source addr to destination addr of assoc req frame
209 * @mac_ctx: pointer to Global MAC structure
210 * @hdr: pointer to the MAC head
211 * @session: pointer to pe session entry
212 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
Naveen Rawatada5fac2016-01-28 16:24:32 -0800213 *
Krunal Soni99752a12016-04-12 17:44:45 -0700214 * Checks source addr to destination addr of assoc req frame
Naveen Rawatada5fac2016-01-28 16:24:32 -0800215 *
Ankit Guptaa5076012016-09-14 11:32:19 -0700216 * Return: true if source and destination address are different
Naveen Rawatada5fac2016-01-28 16:24:32 -0800217 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800218static bool lim_chk_sa_da(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800219 struct pe_session *session, uint8_t sub_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220{
Ankit Guptaa5076012016-09-14 11:32:19 -0700221 if (qdf_mem_cmp((uint8_t *) hdr->sa,
Krunal Soni99752a12016-04-12 17:44:45 -0700222 (uint8_t *) hdr->da,
Ankit Guptaa5076012016-09-14 11:32:19 -0700223 (uint8_t) (sizeof(tSirMacAddr))))
Krunal Soni99752a12016-04-12 17:44:45 -0700224 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530226 pe_err("Assoc Req rejected: wlan.sa = wlan.da");
Krunal Soni99752a12016-04-12 17:44:45 -0700227 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
bings85512332019-09-04 17:46:37 +0800228 1, hdr->sa, sub_type, 0, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -0700229 return false;
230}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231
Krunal Soni99752a12016-04-12 17:44:45 -0700232/**
233 * lim_chk_tkip() - checks TKIP counter measure is active
234 * @mac_ctx: pointer to Global MAC structure
235 * @hdr: pointer to the MAC head
236 * @session: pointer to pe session entry
237 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
238 *
239 * Checks TKIP counter measure is active
240 *
241 * Return: true of no error, false otherwise
242 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800243static bool lim_chk_tkip(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800244 struct pe_session *session, uint8_t sub_type)
Krunal Soni99752a12016-04-12 17:44:45 -0700245{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 /*
Krunal Soni99752a12016-04-12 17:44:45 -0700247 * If TKIP counter measures active send Assoc Rsp frame to station
248 * with eSIR_MAC_MIC_FAILURE_REASON
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 */
Krunal Soni99752a12016-04-12 17:44:45 -0700250 if (!(session->bTkipCntrMeasActive && LIM_IS_AP_ROLE(session)))
251 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530253 pe_err("Assoc Req rejected: TKIP counter measure is active");
Krunal Soni99752a12016-04-12 17:44:45 -0700254 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_MIC_FAILURE_REASON, 1,
bings85512332019-09-04 17:46:37 +0800255 hdr->sa, sub_type, 0, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -0700256 return false;
257}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258
Krunal Soni99752a12016-04-12 17:44:45 -0700259/**
260 * lim_chk_assoc_req_parse_error() - checks for error in frame parsing
261 * @mac_ctx: pointer to Global MAC structure
262 * @hdr: pointer to the MAC head
263 * @session: pointer to pe session entry
264 * @assoc_req: pointer to ASSOC/REASSOC Request frame
265 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
266 * @frm_body: frame body
267 * @frame_len: frame len
268 *
269 * Checks for error in frame parsing
270 *
271 * Return: true of no error, false otherwise
272 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800273static bool lim_chk_assoc_req_parse_error(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700274 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800275 struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -0700276 tpSirAssocReq assoc_req,
277 uint8_t sub_type, uint8_t *frm_body,
Krishna Kumaar Natarajandb582ec2016-03-08 17:37:04 -0800278 uint32_t frame_len)
Krunal Soni99752a12016-04-12 17:44:45 -0700279{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700280 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281
Naveen Rawatada5fac2016-01-28 16:24:32 -0800282 if (sub_type == LIM_ASSOC)
Krunal Soni99752a12016-04-12 17:44:45 -0700283 status = sir_convert_assoc_req_frame2_struct(mac_ctx, frm_body,
Pragaspathi Thilagaraj0bd369d2019-04-08 00:07:53 +0530284 frame_len,
285 assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286 else
Krunal Soni99752a12016-04-12 17:44:45 -0700287 status = sir_convert_reassoc_req_frame2_struct(mac_ctx,
288 frm_body, frame_len, assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700290 if (status == QDF_STATUS_SUCCESS)
Krunal Soni99752a12016-04-12 17:44:45 -0700291 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530293 pe_warn("Assoc Req rejected: frame parsing error. source addr:"
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700294 QDF_MAC_ADDR_FMT, QDF_MAC_ADDR_REF(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700295 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
bings85512332019-09-04 17:46:37 +0800296 1, hdr->sa, sub_type, 0, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -0700297 return false;
298}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299
Krunal Soni99752a12016-04-12 17:44:45 -0700300/**
301 * lim_chk_capab() - checks for capab match
302 * @mac_ctx: pointer to Global MAC structure
303 * @hdr: pointer to the MAC head
304 * @session: pointer to pe session entry
305 * @assoc_req: pointer to ASSOC/REASSOC Request frame
306 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
307 * @local_cap: local capabilities of SAP
308 *
309 * Checks for capab match
310 *
311 * Return: true of no error, false otherwise
312 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800313static bool lim_chk_capab(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800314 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700315 uint8_t sub_type, tSirMacCapabilityInfo *local_cap)
316{
317 uint16_t temp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800318
Wu Gao5c3d94b2019-01-17 21:15:54 +0800319 if (lim_get_capability_info(mac_ctx, &temp, session) !=
320 QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530321 pe_err("could not retrieve Capabilities");
Krunal Soni99752a12016-04-12 17:44:45 -0700322 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 }
Krunal Soni99752a12016-04-12 17:44:45 -0700324
325 lim_copy_u16((uint8_t *) local_cap, temp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326
Naveen Rawatada5fac2016-01-28 16:24:32 -0800327 if (lim_compare_capabilities(mac_ctx, assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700328 local_cap, session) == false) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530329 pe_warn("Rcvd %s Req with unsupported capab from"
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700330 QDF_MAC_ADDR_FMT,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800331 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700332 QDF_MAC_ADDR_REF(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700333 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334 * Capabilities of requesting STA does not match with
335 * local capabilities. Respond with 'unsupported capabilities'
336 * status code.
337 */
bings85512332019-09-04 17:46:37 +0800338 lim_send_assoc_rsp_mgmt_frame(
339 mac_ctx, eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
340 1, hdr->sa, sub_type, 0, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -0700341 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 }
Krunal Soni99752a12016-04-12 17:44:45 -0700343 return true;
344}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345
Krunal Soni99752a12016-04-12 17:44:45 -0700346/**
347 * lim_chk_ssid() - checks for SSID match
348 * @mac_ctx: pointer to Global MAC structure
349 * @hdr: pointer to the MAC head
350 * @session: pointer to pe session entry
351 * @assoc_req: pointer to ASSOC/REASSOC Request frame
352 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
353 *
354 * Checks for SSID match
355 *
356 * Return: true of no error, false otherwise
357 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800358static bool lim_chk_ssid(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800359 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700360 uint8_t sub_type)
361{
362 if (lim_cmp_ssid(&assoc_req->ssId, session) != true)
363 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530365 pe_err("%s Req with ssid wrong(Rcvd: %.*s self: %.*s) from "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700366 QDF_MAC_ADDR_FMT,
Krunal Soni99752a12016-04-12 17:44:45 -0700367 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
368 assoc_req->ssId.length, assoc_req->ssId.ssId,
369 session->ssId.length, session->ssId.ssId,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700370 QDF_MAC_ADDR_REF(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371
Krunal Soni99752a12016-04-12 17:44:45 -0700372 /*
373 * Received Re/Association Request with either Broadcast SSID OR with
374 * SSID that does not match with local one. Respond with unspecified
375 * status code.
376 */
377 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
bings85512332019-09-04 17:46:37 +0800378 1, hdr->sa, sub_type, 0, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -0700379 return false;
380}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381
Krunal Soni99752a12016-04-12 17:44:45 -0700382/**
383 * lim_chk_rates() - checks for supported rates
384 * @mac_ctx: pointer to Global MAC structure
385 * @hdr: pointer to the MAC head
386 * @session: pointer to pe session entry
387 * @assoc_req: pointer to ASSOC/REASSOC Request frame
388 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
389 *
390 * Checks for supported rates
391 *
392 * Return: true of no error, false otherwise
393 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800394static bool lim_chk_rates(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800395 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700396 uint8_t sub_type)
397{
398 uint8_t i = 0, j = 0;
399 tSirMacRateSet basic_rates;
400 /*
401 * Verify if the requested rates are available in supported rate
402 * set or Extended rate set. Some APs are adding basic rates in
403 * Extended rateset IE
404 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800405 basic_rates.numRates = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406
Krunal Soni99752a12016-04-12 17:44:45 -0700407 for (i = 0; i < assoc_req->supportedRates.numRates
Srinivas Girigowda61771262019-04-01 11:55:19 -0700408 && (i < WLAN_SUPPORTED_RATES_IE_MAX_LEN); i++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800409 basic_rates.rate[i] = assoc_req->supportedRates.rate[i];
410 basic_rates.numRates++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 }
412
Krunal Soni99752a12016-04-12 17:44:45 -0700413 for (j = 0; (j < assoc_req->extendedRates.numRates)
Srinivas Girigowda61771262019-04-01 11:55:19 -0700414 && (i < WLAN_SUPPORTED_RATES_IE_MAX_LEN); i++, j++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800415 basic_rates.rate[i] = assoc_req->extendedRates.rate[j];
416 basic_rates.numRates++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418
Krunal Soni99752a12016-04-12 17:44:45 -0700419 if (lim_check_rx_basic_rates(mac_ctx, basic_rates, session) == true)
420 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530422 pe_warn("Assoc Req rejected: unsupported rates, soruce addr: %s"
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700423 QDF_MAC_ADDR_FMT,
Krunal Soni99752a12016-04-12 17:44:45 -0700424 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700425 QDF_MAC_ADDR_REF(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700426 /*
427 * Requesting STA does not support ALL BSS basic rates. Respond with
428 * 'basic rates not supported' status code.
429 */
bings85512332019-09-04 17:46:37 +0800430 lim_send_assoc_rsp_mgmt_frame(
431 mac_ctx, eSIR_MAC_BASIC_RATES_NOT_SUPPORTED_STATUS, 1,
432 hdr->sa, sub_type, 0, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -0700433 return false;
434}
435
436/**
437 * lim_chk_11g_only() - checks for non 11g STA
438 * @mac_ctx: pointer to Global MAC structure
439 * @hdr: pointer to the MAC head
440 * @session: pointer to pe session entry
441 * @assoc_req: pointer to ASSOC/REASSOC Request frame
442 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
443 *
444 * Checks for non 11g STA
445 *
446 * Return: true of no error, false otherwise
447 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800448static bool lim_chk_11g_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800449 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700450 uint8_t sub_type)
451{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800452 if (LIM_IS_AP_ROLE(session) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530453 (session->dot11mode == MLME_DOT11_MODE_11G_ONLY) &&
Naveen Rawatada5fac2016-01-28 16:24:32 -0800454 (assoc_req->HTCaps.present)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530455 pe_err("SOFTAP was in 11G only mode, rejecting legacy STA: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700456 QDF_MAC_ADDR_FMT,
457 QDF_MAC_ADDR_REF(hdr->sa));
bings85512332019-09-04 17:46:37 +0800458 lim_send_assoc_rsp_mgmt_frame(
459 mac_ctx, eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
460 1, hdr->sa, sub_type, 0, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -0700461 return false;
462 }
463 return true;
464}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465
Krunal Soni99752a12016-04-12 17:44:45 -0700466/**
467 * lim_chk_11n_only() - checks for non 11n STA
468 * @mac_ctx: pointer to Global MAC structure
469 * @hdr: pointer to the MAC head
470 * @session: pointer to pe session entry
471 * @assoc_req: pointer to ASSOC/REASSOC Request frame
472 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
473 *
474 * Checks for non 11n STA
475 *
476 * Return: true of no error, false otherwise
477 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800478static bool lim_chk_11n_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800479 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700480 uint8_t sub_type)
481{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800482 if (LIM_IS_AP_ROLE(session) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530483 (session->dot11mode == MLME_DOT11_MODE_11N_ONLY) &&
Naveen Rawatada5fac2016-01-28 16:24:32 -0800484 (!assoc_req->HTCaps.present)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530485 pe_err("SOFTAP was in 11N only mode, rejecting legacy STA: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700486 QDF_MAC_ADDR_FMT,
487 QDF_MAC_ADDR_REF(hdr->sa));
bings85512332019-09-04 17:46:37 +0800488 lim_send_assoc_rsp_mgmt_frame(
489 mac_ctx, eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
490 1, hdr->sa, sub_type, 0, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -0700491 return false;
492 }
493 return true;
494}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495
Krunal Soni99752a12016-04-12 17:44:45 -0700496/**
497 * lim_chk_11ac_only() - checks for non 11ac STA
498 * @mac_ctx: pointer to Global MAC structure
499 * @hdr: pointer to the MAC head
500 * @session: pointer to pe session entry
501 * @assoc_req: pointer to ASSOC/REASSOC Request frame
502 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
503 *
504 * Checks for non 11ac STA
505 *
506 * Return: true of no error, false otherwise
507 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800508static bool lim_chk_11ac_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800509 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700510 uint8_t sub_type)
511{
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530512 tDot11fIEVHTCaps *vht_caps;
513
514 if (assoc_req->VHTCaps.present)
515 vht_caps = &assoc_req->VHTCaps;
516 else if (assoc_req->vendor_vht_ie.VHTCaps.present &&
517 session->vendor_vht_sap)
518 vht_caps = &assoc_req->vendor_vht_ie.VHTCaps;
519 else
520 vht_caps = NULL;
521
Naveen Rawatada5fac2016-01-28 16:24:32 -0800522 if (LIM_IS_AP_ROLE(session) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530523 (session->dot11mode == MLME_DOT11_MODE_11AC_ONLY) &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700524 ((!vht_caps) || ((vht_caps) && (!vht_caps->present)))) {
bings85512332019-09-04 17:46:37 +0800525 lim_send_assoc_rsp_mgmt_frame(
526 mac_ctx, eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
527 1, hdr->sa, sub_type, 0, session, false);
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530528 pe_err("SOFTAP was in 11AC only mode, reject");
Krunal Soni99752a12016-04-12 17:44:45 -0700529 return false;
530 }
531 return true;
532}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533
Krunal Soni99752a12016-04-12 17:44:45 -0700534/**
Naveen Rawat441bc872017-12-11 17:25:27 -0800535 * lim_chk_11ax_only() - checks for non 11ax STA
536 * @mac_ctx: pointer to Global MAC structure
537 * @hdr: pointer to the MAC head
538 * @session: pointer to pe session entry
539 * @assoc_req: pointer to ASSOC/REASSOC Request frame
540 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
541 *
542 * Checks for non 11ax STA
543 *
544 * Return: true of no error, false otherwise
545 */
546#ifdef WLAN_FEATURE_11AX
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800547static bool lim_chk_11ax_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800548 struct pe_session *session, tpSirAssocReq assoc_req,
Naveen Rawat441bc872017-12-11 17:25:27 -0800549 uint8_t sub_type)
550{
551 if (LIM_IS_AP_ROLE(session) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530552 (session->dot11mode == MLME_DOT11_MODE_11AX_ONLY) &&
Naveen Rawat441bc872017-12-11 17:25:27 -0800553 !assoc_req->he_cap.present) {
bings85512332019-09-04 17:46:37 +0800554 lim_send_assoc_rsp_mgmt_frame(
555 mac_ctx, eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
556 1, hdr->sa, sub_type, 0, session, false);
Naveen Rawat441bc872017-12-11 17:25:27 -0800557 pe_err("SOFTAP was in 11AX only mode, reject");
558 return false;
559 }
560 return true;
561}
562
563/**
564 * lim_check_11ax_basic_mcs() - checks for 11ax basic MCS rates
565 * @mac_ctx: pointer to Global MAC structure
566 * @hdr: pointer to the MAC head
567 * @session: pointer to pe session entry
568 * @assoc_req: pointer to ASSOC/REASSOC Request frame
569 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
570 *
571 * Checks for non 11ax STA
572 *
573 * Return: true of no error, false otherwise
574 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800575static bool lim_check_11ax_basic_mcs(struct mac_context *mac_ctx,
Naveen Rawat441bc872017-12-11 17:25:27 -0800576 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800577 struct pe_session *session,
Naveen Rawat441bc872017-12-11 17:25:27 -0800578 tpSirAssocReq assoc_req,
579 uint8_t sub_type)
580{
Naveen Rawat441bc872017-12-11 17:25:27 -0800581 uint16_t basic_mcs, sta_mcs, rx_mcs, tx_mcs, final_mcs;
582
583 if (LIM_IS_AP_ROLE(session) &&
584 assoc_req->he_cap.present) {
585 rx_mcs = assoc_req->he_cap.rx_he_mcs_map_lt_80;
586 tx_mcs = assoc_req->he_cap.tx_he_mcs_map_lt_80;
587 sta_mcs = HE_INTERSECT_MCS(rx_mcs, tx_mcs);
Bala Venkatesh6d537092018-09-25 10:38:36 +0530588 basic_mcs =
589 (uint16_t)mac_ctx->mlme_cfg->he_caps.he_ops_basic_mcs_nss;
Naveen Rawat441bc872017-12-11 17:25:27 -0800590 final_mcs = HE_INTERSECT_MCS(sta_mcs, basic_mcs);
591 if (final_mcs != basic_mcs) {
bings85512332019-09-04 17:46:37 +0800592 lim_send_assoc_rsp_mgmt_frame(
593 mac_ctx,
Naveen Rawat441bc872017-12-11 17:25:27 -0800594 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
bings85512332019-09-04 17:46:37 +0800595 1, hdr->sa, sub_type, 0, session, false);
Jeff Johnsona642ead2018-05-11 09:26:13 -0700596 pe_err("STA did not support basic MCS required by SAP");
Naveen Rawat441bc872017-12-11 17:25:27 -0800597 return false;
598 }
599 }
600 return true;
601}
Bala Venkatesh6d537092018-09-25 10:38:36 +0530602
Naveen Rawat441bc872017-12-11 17:25:27 -0800603#else
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800604static bool lim_chk_11ax_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800605 struct pe_session *session, tpSirAssocReq assoc_req,
Naveen Rawat441bc872017-12-11 17:25:27 -0800606 uint8_t sub_type)
607{
608 return true;
609}
610
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800611static bool lim_check_11ax_basic_mcs(struct mac_context *mac_ctx,
Naveen Rawat441bc872017-12-11 17:25:27 -0800612 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800613 struct pe_session *session,
Naveen Rawat441bc872017-12-11 17:25:27 -0800614 tpSirAssocReq assoc_req,
615 uint8_t sub_type)
616{
617 return true;
618}
619#endif
620
621/**
Krunal Soni99752a12016-04-12 17:44:45 -0700622 * lim_process_for_spectrum_mgmt() - process assoc req for spectrum mgmt
623 * @mac_ctx: pointer to Global MAC structure
624 * @hdr: pointer to the MAC head
625 * @session: pointer to pe session entry
626 * @assoc_req: pointer to ASSOC/REASSOC Request frame
627 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
628 * @local_cap: local capabilities of SAP
629 *
630 * Checks for SSID match
631 *
632 * process assoc req for spectrum mgmt
633 */
634static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800635lim_process_for_spectrum_mgmt(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800636 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700637 uint8_t sub_type, tSirMacCapabilityInfo local_cap)
638{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800639 if (local_cap.spectrumMgt) {
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700640 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krunal Soni99752a12016-04-12 17:44:45 -0700641 /*
642 * If station is 11h capable, then it SHOULD send all mandatory
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 * IEs in assoc request frame. Let us verify that
644 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800645 if (assoc_req->capabilityInfo.spectrumMgt) {
Krunal Soni99752a12016-04-12 17:44:45 -0700646 if (!((assoc_req->powerCapabilityPresent)
Naveen Rawatada5fac2016-01-28 16:24:32 -0800647 && (assoc_req->supportedChannelsPresent))) {
Krunal Soni99752a12016-04-12 17:44:45 -0700648 /*
649 * One or more required information elements are
650 * missing, log the peers error
651 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800652 if (!assoc_req->powerCapabilityPresent) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530653 pe_warn("LIM Info: Missing Power capability IE in %s Req from "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700654 QDF_MAC_ADDR_FMT,
Krunal Soni99752a12016-04-12 17:44:45 -0700655 (LIM_ASSOC == sub_type) ?
656 "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700657 QDF_MAC_ADDR_REF(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 }
Naveen Rawatada5fac2016-01-28 16:24:32 -0800659 if (!assoc_req->supportedChannelsPresent) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530660 pe_warn("LIM Info: Missing Supported channel IE in %s Req from "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700661 QDF_MAC_ADDR_FMT,
Krunal Soni99752a12016-04-12 17:44:45 -0700662 (LIM_ASSOC == sub_type) ?
663 "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700664 QDF_MAC_ADDR_REF(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665 }
666 } else {
667 /* Assoc request has mandatory fields */
668 status =
Krunal Soni99752a12016-04-12 17:44:45 -0700669 lim_is_dot11h_power_capabilities_in_range(
670 mac_ctx, assoc_req, session);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700671 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530672 pe_warn("LIM Info: MinTxPower(STA) > MaxTxPower(AP) in %s Req from "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700673 QDF_MAC_ADDR_FMT,
Krunal Soni99752a12016-04-12 17:44:45 -0700674 (LIM_ASSOC == sub_type) ?
675 "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700676 QDF_MAC_ADDR_REF(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 }
Krunal Soni99752a12016-04-12 17:44:45 -0700678 status = lim_is_dot11h_supported_channels_valid(
679 mac_ctx, assoc_req);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700680 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530681 pe_warn("LIM Info: wrong supported channels (STA) in %s Req from "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700682 QDF_MAC_ADDR_FMT,
Krunal Soni99752a12016-04-12 17:44:45 -0700683 (LIM_ASSOC == sub_type) ?
684 "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700685 QDF_MAC_ADDR_REF(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 }
687 /* IEs are valid, use them if needed */
688 }
689 } /* if(assoc.capabilityInfo.spectrumMgt) */
690 else {
Krunal Soni99752a12016-04-12 17:44:45 -0700691 /*
692 * As per the capabiities, the spectrum management is
693 * not enabled on the station. The AP may allow the
694 * associations to happen even if spectrum management
695 * is not allowed, if the transmit power of station is
696 * below the regulatory maximum
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 */
698
Krunal Soni99752a12016-04-12 17:44:45 -0700699 /*
700 * TODO: presently, this is not handled. In the current
Jeff Johnson47d75242018-05-12 15:58:53 -0700701 * implementation, the AP would allow the station to
Krunal Soni99752a12016-04-12 17:44:45 -0700702 * associate even if it doesn't support spectrum
703 * management.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 */
705 }
706 } /* end of spectrum management related processing */
Krunal Soni99752a12016-04-12 17:44:45 -0700707}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800708
Krunal Soni99752a12016-04-12 17:44:45 -0700709/**
710 * lim_chk_mcs() - checks for supported MCS
711 * @mac_ctx: pointer to Global MAC structure
712 * @hdr: pointer to the MAC head
713 * @session: pointer to pe session entry
714 * @assoc_req: pointer to ASSOC/REASSOC Request frame
715 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
716 *
717 * Checks for supported MCS
718 *
719 * Return: true of no error, false otherwise
720 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800721static bool lim_chk_mcs(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800722 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700723 uint8_t sub_type)
724{
725 if ((assoc_req->HTCaps.present) && (lim_check_mcs_set(mac_ctx,
726 assoc_req->HTCaps.supportedMCSSet) == false)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530727 pe_warn("rcvd %s req with unsupported MCS Rate Set from "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700728 QDF_MAC_ADDR_FMT,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800729 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700730 QDF_MAC_ADDR_REF(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700731 /*
732 * Requesting STA does not support ALL BSS MCS basic Rate set
733 * rates. Spec does not define any status code for this
734 * scenario.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735 */
bings85512332019-09-04 17:46:37 +0800736 lim_send_assoc_rsp_mgmt_frame(
737 mac_ctx, eSIR_MAC_OUTSIDE_SCOPE_OF_SPEC_STATUS,
738 1, hdr->sa, sub_type, 0, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -0700739 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 }
Krunal Soni99752a12016-04-12 17:44:45 -0700741 return true;
742}
743
744/**
745 * lim_chk_is_11b_sta_supported() - checks if STA is 11b
746 * @mac_ctx: pointer to Global MAC structure
747 * @hdr: pointer to the MAC head
748 * @session: pointer to pe session entry
749 * @assoc_req: pointer to ASSOC/REASSOC Request frame
750 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
751 * @phy_mode: phy mode
752 *
753 * Checks if STA is 11b
754 *
755 * Return: true of no error, false otherwise
756 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800757static bool lim_chk_is_11b_sta_supported(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700758 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800759 struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -0700760 tpSirAssocReq assoc_req,
761 uint8_t sub_type, uint32_t phy_mode)
762{
763 uint32_t cfg_11g_only;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764
Naveen Rawatada5fac2016-01-28 16:24:32 -0800765 if (phy_mode == WNI_CFG_PHY_MODE_11G) {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530766 cfg_11g_only = mac_ctx->mlme_cfg->sap_cfg.sap_11g_policy;
Krunal Soni99752a12016-04-12 17:44:45 -0700767 if (!assoc_req->extendedRatesPresent && cfg_11g_only) {
768 /*
769 * Received Re/Association Request from 11b STA when 11g
770 * only policy option is set. Reject with unspecified
771 * status code.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772 */
bings85512332019-09-04 17:46:37 +0800773 lim_send_assoc_rsp_mgmt_frame(
774 mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700775 eSIR_MAC_BASIC_RATES_NOT_SUPPORTED_STATUS,
bings85512332019-09-04 17:46:37 +0800776 1, hdr->sa, sub_type, 0, session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530778 pe_warn("Rejecting Re/Assoc req from 11b STA:");
Naveen Rawatada5fac2016-01-28 16:24:32 -0800779 lim_print_mac_addr(mac_ctx, hdr->sa, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780
781#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -0800782 mac_ctx->lim.gLim11bStaAssocRejectCount++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783#endif
Krunal Soni99752a12016-04-12 17:44:45 -0700784 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 }
786 }
Krunal Soni99752a12016-04-12 17:44:45 -0700787 return true;
788}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789
Krunal Soni99752a12016-04-12 17:44:45 -0700790/**
791 * lim_print_ht_cap() - prints HT caps
792 * @mac_ctx: pointer to Global MAC structure
793 * @session: pointer to pe session entry
794 * @assoc_req: pointer to ASSOC/REASSOC Request frame
795 *
796 * Prints HT caps
797 *
798 * Return: void
799 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800800static void lim_print_ht_cap(struct mac_context *mac_ctx, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -0700801 tpSirAssocReq assoc_req)
802{
803 if (!session->htCapability)
804 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805
Krunal Soni99752a12016-04-12 17:44:45 -0700806 if (assoc_req->HTCaps.present) {
807 /* The station *does* support 802.11n HT capability... */
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530808 pe_debug("AdvCodingCap:%d ChaWidthSet:%d PowerSave:%d greenField:%d shortGI20:%d shortGI40:%d txSTBC:%d rxSTBC:%d delayBA:%d maxAMSDUsize:%d DSSS/CCK:%d PSMP:%d stbcCntl:%d lsigTXProt:%d",
Krunal Soni99752a12016-04-12 17:44:45 -0700809 assoc_req->HTCaps.advCodingCap,
810 assoc_req->HTCaps.supportedChannelWidthSet,
811 assoc_req->HTCaps.mimoPowerSave,
812 assoc_req->HTCaps.greenField,
813 assoc_req->HTCaps.shortGI20MHz,
814 assoc_req->HTCaps.shortGI40MHz,
815 assoc_req->HTCaps.txSTBC,
816 assoc_req->HTCaps.rxSTBC,
817 assoc_req->HTCaps.delayedBA,
818 assoc_req->HTCaps.maximalAMSDUsize,
819 assoc_req->HTCaps.dsssCckMode40MHz,
820 assoc_req->HTCaps.psmp,
821 assoc_req->HTCaps.stbcControlFrame,
822 assoc_req->HTCaps.lsigTXOPProtection);
823 /*
824 * Make sure the STA's caps are compatible with our own:
825 * 11.15.2 Support of DSSS/CCK in 40 MHz the AP shall refuse
826 * association requests from an HT STA that has the DSSS/CCK
827 * Mode in 40 MHz subfield set to 1;
828 */
829 }
830}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831
Nirav Shahba3eecf2020-02-17 19:38:35 +0530832static enum mac_status_code
833lim_check_crypto_param(tpSirAssocReq assoc_req,
834 struct wlan_crypto_params *peer_crypto_params)
835{
836 /* TKIP/WEP is not allowed in HT/VHT mode*/
837 if (assoc_req->HTCaps.present) {
838 if ((peer_crypto_params->ucastcipherset &
839 (1 << WLAN_CRYPTO_CIPHER_TKIP)) ||
840 (peer_crypto_params->ucastcipherset &
841 (1 << WLAN_CRYPTO_CIPHER_WEP))) {
842 pe_info("TKIP/WEP cipher with HT supported client, reject assoc");
843 return eSIR_MAC_INVALID_IE_STATUS;
844 }
845 }
846 return eSIR_MAC_SUCCESS_STATUS;
847}
848
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530849static
850enum mac_status_code lim_check_rsn_ie(struct pe_session *session,
851 struct mac_context *mac_ctx,
852 tpSirAssocReq assoc_req,
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530853 bool *pmf_connection)
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700854{
855 struct wlan_objmgr_vdev *vdev;
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700856 tSirMacRsnInfo rsn_ie;
Nirav Shahba3eecf2020-02-17 19:38:35 +0530857 struct wlan_crypto_params peer_crypto_params;
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700858
Abhishek Singh6c39a982020-05-19 20:51:45 +0530859 rsn_ie.info[0] = WLAN_ELEMID_RSN;
860 rsn_ie.info[1] = assoc_req->rsn.length;
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700861
Abhishek Singh6c39a982020-05-19 20:51:45 +0530862 rsn_ie.length = assoc_req->rsn.length + 2;
863 qdf_mem_copy(&rsn_ie.info[2], assoc_req->rsn.info,
864 assoc_req->rsn.length);
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700865 if (wlan_crypto_check_rsn_match(mac_ctx->psoc, session->smeSessionId,
Nirav Shahba3eecf2020-02-17 19:38:35 +0530866 &rsn_ie.info[0], rsn_ie.length,
867 &peer_crypto_params)) {
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700868 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
869 session->smeSessionId,
870 WLAN_LEGACY_MAC_ID);
871 if (!vdev) {
872 pe_err("vdev is NULL");
873 return eSIR_MAC_UNSPEC_FAILURE_STATUS;
874 }
Utkarsh Bhatnagar5952ff52020-05-17 18:29:20 +0530875 if ((peer_crypto_params.rsn_caps &
876 WLAN_CRYPTO_RSN_CAP_MFP_ENABLED) &&
877 wlan_crypto_vdev_is_pmf_enabled(vdev))
878 *pmf_connection = true;
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700879
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700880 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
Nirav Shahba3eecf2020-02-17 19:38:35 +0530881 return lim_check_crypto_param(assoc_req, &peer_crypto_params);
882
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700883 } else {
884 return eSIR_MAC_INVALID_IE_STATUS;
885 }
886
887 return eSIR_MAC_SUCCESS_STATUS;
888}
889
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530890static enum mac_status_code lim_check_wpa_ie(struct pe_session *session,
891 struct mac_context *mac_ctx,
892 tpSirAssocReq assoc_req,
893 tDot11fIEWPA *wpa)
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700894{
Srinivas Girigowdacf161402019-03-14 11:37:33 -0700895 uint8_t buffer[WLAN_MAX_IE_LEN];
896 uint32_t dot11f_status, written = 0, nbuffer = WLAN_MAX_IE_LEN;
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700897 tSirMacRsnInfo wpa_ie = {0};
Nirav Shahba3eecf2020-02-17 19:38:35 +0530898 struct wlan_crypto_params peer_crypto_params;
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700899
900 dot11f_status = dot11f_pack_ie_wpa(mac_ctx, wpa, buffer,
901 nbuffer, &written);
902 if (DOT11F_FAILED(dot11f_status)) {
903 pe_err("Failed to re-pack the RSN IE (0x%0x8)", dot11f_status);
904 return eSIR_MAC_INVALID_IE_STATUS;
905 }
906
907 wpa_ie.length = (uint8_t) written;
908 qdf_mem_copy(&wpa_ie.info[0], buffer, wpa_ie.length);
909 if (wlan_crypto_check_wpa_match(mac_ctx->psoc, session->smeSessionId,
Nirav Shahba3eecf2020-02-17 19:38:35 +0530910 &wpa_ie.info[0], wpa_ie.length,
911 &peer_crypto_params)) {
912 return lim_check_crypto_param(assoc_req, &peer_crypto_params);
913 }
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700914
915 return eSIR_MAC_INVALID_IE_STATUS;
916}
Min Liub3b222a2019-02-22 13:47:45 +0800917
918/**
919 * lim_check_sae_pmf_cap() - check pmf capability for SAE STA
920 * @session: pointer to pe session entry
921 * @rsn: pointer to RSN
Yu Ouyang228afe92019-08-12 18:01:56 +0800922 * @akm_type: AKM type
Min Liub3b222a2019-02-22 13:47:45 +0800923 *
924 * This function checks if SAE STA is pmf capable when SAE SAP is pmf
925 * capable. Reject with eSIR_MAC_ROBUST_MGMT_FRAMES_POLICY_VIOLATION
926 * if SAE STA is pmf disable.
927 *
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530928 * Return: mac_status_code
Min Liub3b222a2019-02-22 13:47:45 +0800929 */
Alan Chen9fcd4d32020-01-10 15:33:38 -0800930#if defined(WLAN_FEATURE_SAE) && defined(WLAN_FEATURE_11W)
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530931static enum mac_status_code lim_check_sae_pmf_cap(struct pe_session *session,
Yu Ouyang228afe92019-08-12 18:01:56 +0800932 tDot11fIERSN *rsn,
933 enum ani_akm_type akm_type)
Min Liub3b222a2019-02-22 13:47:45 +0800934{
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530935 enum mac_status_code status = eSIR_MAC_SUCCESS_STATUS;
Min Liub3b222a2019-02-22 13:47:45 +0800936
937 if (session->pLimStartBssReq->pmfCapable &&
Yu Ouyang228afe92019-08-12 18:01:56 +0800938 (rsn->RSN_Cap[0] & WLAN_CRYPTO_RSN_CAP_MFP_ENABLED) == 0 &&
939 akm_type == ANI_AKM_TYPE_SAE)
Min Liub3b222a2019-02-22 13:47:45 +0800940 status = eSIR_MAC_ROBUST_MGMT_FRAMES_POLICY_VIOLATION_STATUS;
941
942 return status;
943}
944#else
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530945static enum mac_status_code lim_check_sae_pmf_cap(struct pe_session *session,
Yu Ouyang228afe92019-08-12 18:01:56 +0800946 tDot11fIERSN *rsn,
947 enum ani_akm_type akm_type)
Min Liub3b222a2019-02-22 13:47:45 +0800948{
949 return eSIR_MAC_SUCCESS_STATUS;
950}
951#endif
952
Krunal Soni99752a12016-04-12 17:44:45 -0700953/**
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530954 * lim_check_wpa_rsn_ie() - wpa and rsn ie related checks
955 * @session: pointer to pe session entry
956 * @mac_ctx: pointer to Global MAC structure
957 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
958 * @hdr: pointer to the MAC head
959 * @assoc_req: pointer to ASSOC/REASSOC Request frame
960 * @pmf_connection: flag indicating pmf connection
Min Liuddd23302018-12-05 16:17:48 +0800961 * @akm_type: AKM type
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530962 *
963 * This function checks if wpa/rsn IE is present and validates
964 * ie version, length and mismatch.
965 *
966 * Return: true if no error, false otherwise
967 */
Min Liuddd23302018-12-05 16:17:48 +0800968static bool lim_check_wpa_rsn_ie(struct pe_session *session,
969 struct mac_context *mac_ctx,
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530970 uint8_t sub_type, tpSirMacMgmtHdr hdr,
Min Liuddd23302018-12-05 16:17:48 +0800971 tpSirAssocReq assoc_req, bool *pmf_connection,
972 enum ani_akm_type *akm_type)
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530973{
974 uint32_t ret;
975 tDot11fIEWPA dot11f_ie_wpa = {0};
976 tDot11fIERSN dot11f_ie_rsn = {0};
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530977 enum mac_status_code status = eSIR_MAC_SUCCESS_STATUS;
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530978
979 /*
980 * Clear the buffers so that frame parser knows that there isn't a
981 * previously decoded IE in these buffers
982 */
hangtian127c9532019-01-12 13:29:07 +0800983 qdf_mem_zero((uint8_t *) &dot11f_ie_rsn, sizeof(dot11f_ie_rsn));
984 qdf_mem_zero((uint8_t *) &dot11f_ie_wpa, sizeof(dot11f_ie_wpa));
Arun Kumar Khandavalli5ba27432020-01-20 11:47:44 +0530985 pe_debug("RSN enabled auth, Re/Assoc req from STA: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700986 QDF_MAC_ADDR_FMT, QDF_MAC_ADDR_REF(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530987
988 if (assoc_req->rsnPresent) {
989 if (!(assoc_req->rsn.length)) {
990 pe_warn("Re/Assoc rejected from: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700991 QDF_MAC_ADDR_FMT,
992 QDF_MAC_ADDR_REF(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530993 /*
994 * rcvd Assoc req frame with RSN IE but
995 * length is zero
996 */
bings85512332019-09-04 17:46:37 +0800997 lim_send_assoc_rsp_mgmt_frame(
998 mac_ctx, eSIR_MAC_INVALID_IE_STATUS, 1,
999 hdr->sa, sub_type, 0, session, false);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301000 return false;
1001 }
1002
1003 /* Unpack the RSN IE */
1004 ret = dot11f_unpack_ie_rsn(mac_ctx,
1005 &assoc_req->rsn.info[0],
1006 assoc_req->rsn.length,
1007 &dot11f_ie_rsn, false);
1008 if (!DOT11F_SUCCEEDED(ret)) {
1009 pe_err("Invalid RSN IE");
Liangwei Dong433a8db2018-08-14 01:43:23 -04001010 lim_send_assoc_rsp_mgmt_frame(
1011 mac_ctx, eSIR_MAC_INVALID_IE_STATUS, 1,
bings85512332019-09-04 17:46:37 +08001012 hdr->sa, sub_type, 0, session, false);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301013 return false;
1014 }
1015
1016 /* Check if the RSN version is supported */
1017 if (SIR_MAC_OUI_VERSION_1 == dot11f_ie_rsn.version) {
1018 /* check the groupwise and pairwise cipher suites */
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -07001019 status = lim_check_rsn_ie(session, mac_ctx, assoc_req,
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -07001020 pmf_connection);
1021 if (eSIR_MAC_SUCCESS_STATUS != status) {
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301022 pe_warn("Re/Assoc rejected from: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001023 QDF_MAC_ADDR_FMT,
1024 QDF_MAC_ADDR_REF(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301025
bings85512332019-09-04 17:46:37 +08001026 lim_send_assoc_rsp_mgmt_frame(
1027 mac_ctx, status, 1, hdr->sa, sub_type,
1028 0, session, false);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301029 return false;
1030 }
1031 } else {
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001032 pe_warn("Re/Assoc rejected from: " QDF_MAC_ADDR_FMT,
1033 QDF_MAC_ADDR_REF(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301034 /*
1035 * rcvd Assoc req frame with RSN IE but
1036 * IE version is wrong
1037 */
bings85512332019-09-04 17:46:37 +08001038 lim_send_assoc_rsp_mgmt_frame(
1039 mac_ctx,
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301040 eSIR_MAC_UNSUPPORTED_RSN_IE_VERSION_STATUS,
bings85512332019-09-04 17:46:37 +08001041 1, hdr->sa, sub_type, 0, session, false);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301042 return false;
1043 }
Min Liuddd23302018-12-05 16:17:48 +08001044 *akm_type = lim_translate_rsn_oui_to_akm_type(
1045 dot11f_ie_rsn.akm_suite[0]);
Min Liub3b222a2019-02-22 13:47:45 +08001046
Yu Ouyang228afe92019-08-12 18:01:56 +08001047 status = lim_check_sae_pmf_cap(session, &dot11f_ie_rsn,
1048 *akm_type);
Min Liub3b222a2019-02-22 13:47:45 +08001049 if (eSIR_MAC_SUCCESS_STATUS != status) {
1050 /* Reject pmf disable SAE STA */
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001051 pe_warn("Re/Assoc rejected from: " QDF_MAC_ADDR_FMT,
1052 QDF_MAC_ADDR_REF(hdr->sa));
Min Liub3b222a2019-02-22 13:47:45 +08001053 lim_send_assoc_rsp_mgmt_frame(mac_ctx, status,
1054 1, hdr->sa, sub_type,
bings85512332019-09-04 17:46:37 +08001055 0, session, false);
Min Liub3b222a2019-02-22 13:47:45 +08001056 return false;
1057 }
1058
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301059 } else if (assoc_req->wpaPresent) {
1060 if (!(assoc_req->wpa.length)) {
1061 pe_warn("Re/Assoc rejected from: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001062 QDF_MAC_ADDR_FMT,
1063 QDF_MAC_ADDR_REF(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301064
1065 /* rcvd Assoc req frame with invalid WPA IE length */
bings85512332019-09-04 17:46:37 +08001066 lim_send_assoc_rsp_mgmt_frame(
1067 mac_ctx, eSIR_MAC_INVALID_IE_STATUS, 1,
1068 hdr->sa, sub_type, 0, session, false);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301069 return false;
1070 }
1071 /* Unpack the WPA IE */
1072 ret = dot11f_unpack_ie_wpa(mac_ctx,
1073 &assoc_req->wpa.info[4],
1074 (assoc_req->wpa.length - 4),
1075 &dot11f_ie_wpa, false);
1076 if (!DOT11F_SUCCEEDED(ret)) {
1077 pe_err("Invalid WPA IE");
Liangwei Dong433a8db2018-08-14 01:43:23 -04001078 lim_send_assoc_rsp_mgmt_frame(
1079 mac_ctx, eSIR_MAC_INVALID_IE_STATUS, 1,
bings85512332019-09-04 17:46:37 +08001080 hdr->sa, sub_type, 0, session, false);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301081 return false;
1082 }
1083
1084 /* check the groupwise and pairwise cipher suites*/
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -07001085 status = lim_check_wpa_ie(session, mac_ctx, assoc_req,
1086 &dot11f_ie_wpa);
1087 if (eSIR_MAC_SUCCESS_STATUS != status) {
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301088 pe_warn("Re/Assoc rejected from: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001089 QDF_MAC_ADDR_FMT,
1090 QDF_MAC_ADDR_REF(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301091 /*
1092 * rcvd Assoc req frame with WPA IE
1093 * but there is mismatch
1094 */
bings85512332019-09-04 17:46:37 +08001095 lim_send_assoc_rsp_mgmt_frame(
1096 mac_ctx, status, 1,
1097 hdr->sa, sub_type, 0, session, false);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301098 return false;
1099 }
Min Liuddd23302018-12-05 16:17:48 +08001100 *akm_type = lim_translate_rsn_oui_to_akm_type(
1101 dot11f_ie_wpa.auth_suites[0]);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301102 }
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301103
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -07001104 return true;
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301105}
1106
1107/**
Krunal Soni99752a12016-04-12 17:44:45 -07001108 * lim_chk_n_process_wpa_rsn_ie() - wpa ie related checks
1109 * @mac_ctx: pointer to Global MAC structure
1110 * @hdr: pointer to the MAC head
1111 * @session: pointer to pe session entry
1112 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1113 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1114 * @pmf_connection: flag indicating pmf connection
Min Liuddd23302018-12-05 16:17:48 +08001115 * @akm_type: AKM type
Krunal Soni99752a12016-04-12 17:44:45 -07001116 *
1117 * wpa ie related checks
1118 *
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301119 * Return: true if no error, false otherwise
Krunal Soni99752a12016-04-12 17:44:45 -07001120 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001121static bool lim_chk_n_process_wpa_rsn_ie(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -07001122 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001123 struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001124 tpSirAssocReq assoc_req,
Min Liuddd23302018-12-05 16:17:48 +08001125 uint8_t sub_type,
1126 bool *pmf_connection,
1127 enum ani_akm_type *akm_type)
Krunal Soni99752a12016-04-12 17:44:45 -07001128{
Naveen Rawat08db88f2017-09-08 15:07:48 -07001129 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130
1131 /* if additional IE is present, check if it has WscIE */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001132 if (assoc_req->addIEPresent && assoc_req->addIE.length)
Krunal Soni99752a12016-04-12 17:44:45 -07001133 wps_ie = limGetWscIEPtr(mac_ctx, assoc_req->addIE.addIEdata,
1134 assoc_req->addIE.length);
1135 else
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301136 pe_debug("Assoc req addIEPresent: %d addIE length: %d",
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301137 assoc_req->addIEPresent, assoc_req->addIE.length);
Krunal Soni99752a12016-04-12 17:44:45 -07001138
Naveen Rawatada5fac2016-01-28 16:24:32 -08001139 /* when wps_ie is present, RSN/WPA IE is ignored */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001140 if (!wps_ie) {
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301141 /* check whether RSN IE is present */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001142 if (LIM_IS_AP_ROLE(session) &&
1143 session->pLimStartBssReq->privacy &&
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301144 session->pLimStartBssReq->rsnIE.length)
1145 return lim_check_wpa_rsn_ie(session, mac_ctx, sub_type,
Min Liuddd23302018-12-05 16:17:48 +08001146 hdr, assoc_req, pmf_connection,
1147 akm_type);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301148 } else {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301149 pe_debug("Assoc req WSE IE is present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 }
Krunal Soni99752a12016-04-12 17:44:45 -07001151 return true;
1152}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153
Krunal Soni99752a12016-04-12 17:44:45 -07001154/**
1155 * lim_process_assoc_req_no_sta_ctx() - process assoc req for no sta ctx present
1156 * @mac_ctx: pointer to Global MAC structure
1157 * @hdr: pointer to the MAC head
1158 * @session: pointer to pe session entry
1159 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1160 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1161 * @sta_pre_auth_ctx: sta pre auth context
1162 * @sta_ds: station dph entry
1163 * @auth_type: indicates security type
1164 *
1165 * Process assoc req for no sta ctx present
1166 *
1167 * Return: true of no error, false otherwise
1168 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001169static bool lim_process_assoc_req_no_sta_ctx(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001170 tpSirMacMgmtHdr hdr, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001171 tpSirAssocReq assoc_req, uint8_t sub_type,
1172 struct tLimPreAuthNode *sta_pre_auth_ctx,
1173 tpDphHashNode sta_ds, tAniAuthType *auth_type)
1174{
1175 /* Requesting STA is not currently associated */
1176 if (pe_get_current_stas_count(mac_ctx) ==
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301177 mac_ctx->mlme_cfg->sap_cfg.assoc_sta_limit) {
Krunal Soni99752a12016-04-12 17:44:45 -07001178 /*
1179 * Maximum number of STAs that AP can handle reached.
1180 * Send Association response to peer MAC entity
1181 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301182 pe_err("Max Sta count reached : %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001183 mac_ctx->lim.maxStation);
1184 lim_reject_association(mac_ctx, hdr->sa, sub_type, false,
1185 (tAniAuthType) 0, 0, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001186 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001187 session);
1188 return false;
1189 }
1190 /* Check if STA is pre-authenticated. */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001191 if ((!sta_pre_auth_ctx) || (sta_pre_auth_ctx &&
Krunal Soni99752a12016-04-12 17:44:45 -07001192 (sta_pre_auth_ctx->mlmState != eLIM_MLM_AUTHENTICATED_STATE))) {
1193 /*
1194 * STA is not pre-authenticated yet requesting Re/Association
1195 * before Authentication. OR STA is in the process of getting
1196 * authenticated and sent Re/Association request. Send
1197 * Deauthentication frame with 'prior authentication required'
1198 * reason code.
1199 */
1200 lim_send_deauth_mgmt_frame(mac_ctx,
1201 eSIR_MAC_STA_NOT_PRE_AUTHENTICATED_REASON,
1202 hdr->sa, session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301204 pe_warn("rcvd %s req, sessionid: %d, without pre-auth ctx"
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001205 QDF_MAC_ADDR_FMT,
Krunal Soni99752a12016-04-12 17:44:45 -07001206 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001207 session->peSessionId, QDF_MAC_ADDR_REF(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -07001208 return false;
1209 }
1210 /* Delete 'pre-auth' context of STA */
1211 *auth_type = sta_pre_auth_ctx->authType;
Srinivas Dasari5f528202019-02-11 17:29:43 +05301212 if (sta_pre_auth_ctx->authType == eSIR_AUTH_TYPE_SAE)
1213 assoc_req->is_sae_authenticated = true;
Krunal Soni99752a12016-04-12 17:44:45 -07001214 lim_delete_pre_auth_node(mac_ctx, hdr->sa);
1215 /* All is well. Assign AID (after else part) */
1216 return true;
1217}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218
Abhishek Singh7a7799b2020-01-21 10:30:28 +05301219#ifdef WLAN_DEBUG
1220static inline void
1221lim_update_assoc_drop_count(struct mac_context *mac_ctx, uint8_t sub_type)
1222{
1223 if (sub_type == LIM_ASSOC)
1224 mac_ctx->lim.gLimNumAssocReqDropInvldState++;
1225 else
1226 mac_ctx->lim.gLimNumReassocReqDropInvldState++;
1227}
1228#else
1229static inline void
1230lim_update_assoc_drop_count(struct mac_context *mac_ctx, uint8_t sub_type) {}
1231#endif
1232
1233#ifdef WLAN_FEATURE_11W
1234static inline void
1235lim_delete_pmf_query_timer(tpDphHashNode sta_ds)
1236{
1237 if (!sta_ds->rmfEnabled)
1238 return;
1239
1240 if (tx_timer_running(&sta_ds->pmfSaQueryTimer))
1241 tx_timer_deactivate(&sta_ds->pmfSaQueryTimer);
1242 tx_timer_delete(&sta_ds->pmfSaQueryTimer);
1243}
1244#else
1245static inline void
1246lim_delete_pmf_query_timer(tpDphHashNode sta_ds) {}
1247#endif
1248
Krunal Soni99752a12016-04-12 17:44:45 -07001249/**
1250 * lim_process_assoc_req_sta_ctx() - process assoc req for sta context present
1251 * @mac_ctx: pointer to Global MAC structure
1252 * @hdr: pointer to the MAC head
1253 * @session: pointer to pe session entry
1254 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1255 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1256 * @sta_pre_auth_ctx: sta pre auth context
1257 * @sta_ds: station dph entry
1258 * @peer_idx: peer index
1259 * @auth_type: indicates security type
1260 * @update_ctx: indicates if STA context already exist
1261 *
1262 * Process assoc req for sta context present
1263 *
1264 * Return: true of no error, false otherwise
1265 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001266static bool lim_process_assoc_req_sta_ctx(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001267 tpSirMacMgmtHdr hdr, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001268 tpSirAssocReq assoc_req, uint8_t sub_type,
1269 struct tLimPreAuthNode *sta_pre_auth_ctx,
1270 tpDphHashNode sta_ds, uint16_t peer_idx,
1271 tAniAuthType *auth_type, uint8_t *update_ctx)
1272{
Abhishek Singh7a7799b2020-01-21 10:30:28 +05301273 /* Drop if STA deletion is in progress or not in established state */
1274 if (sta_ds->sta_deletion_in_progress ||
1275 (sta_ds->mlmStaContext.mlmState !=
1276 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001277 pe_debug("%s: peer:"QDF_MAC_ADDR_FMT" in mlmState %d (%s) and sta del %d",
Abhishek Singh7a7799b2020-01-21 10:30:28 +05301278 (sub_type == LIM_ASSOC) ? "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001279 QDF_MAC_ADDR_REF(sta_ds->staAddr),
1280 sta_ds->mlmStaContext.mlmState,
Abhishek Singh7a7799b2020-01-21 10:30:28 +05301281 lim_mlm_state_str(sta_ds->mlmStaContext.mlmState),
1282 sta_ds->sta_deletion_in_progress);
1283 lim_update_assoc_drop_count(mac_ctx, sub_type);
Krunal Soni99752a12016-04-12 17:44:45 -07001284 return false;
1285 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286
Krunal Soni99752a12016-04-12 17:44:45 -07001287 /* STA sent assoc req frame while already in 'associated' state */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288
1289#ifdef WLAN_FEATURE_11W
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301290 pe_debug("Re/Assoc request from station that is already associated");
1291 pe_debug("PMF enabled: %d, SA Query state: %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001292 sta_ds->rmfEnabled, sta_ds->pmfSaQueryState);
1293 if (sta_ds->rmfEnabled) {
1294 switch (sta_ds->pmfSaQueryState) {
1295 /*
1296 * start SA Query procedure, respond to Association Request with
1297 * try again later
1298 */
1299 case DPH_SA_QUERY_NOT_IN_PROGRESS:
1300 /*
1301 * We should reset the retry counter before we start
1302 * the SA query procedure, otherwise in next set of SA
1303 * query procedure we will end up using the stale value.
1304 */
1305 sta_ds->pmfSaQueryRetryCount = 0;
bings85512332019-09-04 17:46:37 +08001306 lim_send_assoc_rsp_mgmt_frame(
1307 mac_ctx, eSIR_MAC_TRY_AGAIN_LATER, 1, hdr->sa,
1308 sub_type, sta_ds, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -07001309 lim_send_sa_query_request_frame(mac_ctx,
1310 (uint8_t *) &(sta_ds->pmfSaQueryCurrentTransId),
1311 hdr->sa, session);
1312 sta_ds->pmfSaQueryStartTransId =
1313 sta_ds->pmfSaQueryCurrentTransId;
1314 sta_ds->pmfSaQueryCurrentTransId++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315
Krunal Soni99752a12016-04-12 17:44:45 -07001316 /* start timer for SA Query retry */
1317 if (tx_timer_activate(&sta_ds->pmfSaQueryTimer)
1318 != TX_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301319 pe_err("PMF SA Query timer start failed!");
Krunal Soni99752a12016-04-12 17:44:45 -07001320 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 }
Krunal Soni99752a12016-04-12 17:44:45 -07001322 sta_ds->pmfSaQueryState = DPH_SA_QUERY_IN_PROGRESS;
1323 return false;
1324 /*
1325 * SA Query procedure still going, respond to Association
1326 * Request with try again later
1327 */
1328 case DPH_SA_QUERY_IN_PROGRESS:
bings85512332019-09-04 17:46:37 +08001329 lim_send_assoc_rsp_mgmt_frame(
1330 mac_ctx, eSIR_MAC_TRY_AGAIN_LATER, 1,
1331 hdr->sa, sub_type, 0, session, false);
Krunal Soni99752a12016-04-12 17:44:45 -07001332 return false;
1333
1334 /*
1335 * SA Query procedure timed out, accept Association
1336 * Request normally
1337 */
1338 case DPH_SA_QUERY_TIMED_OUT:
1339 sta_ds->pmfSaQueryState = DPH_SA_QUERY_NOT_IN_PROGRESS;
1340 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 }
Krunal Soni99752a12016-04-12 17:44:45 -07001342 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343#endif
1344
Krunal Soni99752a12016-04-12 17:44:45 -07001345 /* no change in the capability so drop the frame */
1346 if ((sub_type == LIM_ASSOC) &&
Ankit Guptaa5076012016-09-14 11:32:19 -07001347 (!qdf_mem_cmp(&sta_ds->mlmStaContext.capabilityInfo,
Krunal Soni99752a12016-04-12 17:44:45 -07001348 &assoc_req->capabilityInfo,
1349 sizeof(tSirMacCapabilityInfo)))) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301350 pe_err("Received Assoc req in state: %X STAid: %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001351 sta_ds->mlmStaContext.mlmState, peer_idx);
1352 return false;
Krunal Soni99752a12016-04-12 17:44:45 -07001353 }
Abhishek Singh7a7799b2020-01-21 10:30:28 +05301354
1355 /*
1356 * STA sent Re/association Request frame while already in
1357 * 'associated' state. Update STA capabilities and send
1358 * Association response frame with same AID
1359 */
1360 pe_debug("Rcvd Assoc req from STA already connected");
1361 sta_ds->mlmStaContext.capabilityInfo =
1362 assoc_req->capabilityInfo;
1363 if (sta_pre_auth_ctx && (sta_pre_auth_ctx->mlmState ==
1364 eLIM_MLM_AUTHENTICATED_STATE)) {
1365 /* STA has triggered pre-auth again */
1366 *auth_type = sta_pre_auth_ctx->authType;
1367 lim_delete_pre_auth_node(mac_ctx, hdr->sa);
1368 } else {
1369 *auth_type = sta_ds->mlmStaContext.authType;
1370 }
1371
1372 *update_ctx = true;
1373 /* Free pmf query timer before resetting the sta_ds */
1374 lim_delete_pmf_query_timer(sta_ds);
1375 if (dph_init_sta_state(mac_ctx, hdr->sa, peer_idx,
1376 &session->dph.dphHashTable) == NULL) {
1377 pe_err("could not Init STAid: %d", peer_idx);
1378 return false;
1379 }
1380
Krunal Soni99752a12016-04-12 17:44:45 -07001381 return true;
1382}
1383
1384/**
1385 * lim_chk_wmm() - wmm related checks
1386 * @mac_ctx: pointer to Global MAC structure
1387 * @hdr: pointer to the MAC head
1388 * @session: pointer to pe session entry
1389 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1390 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1391 * @qos_mode: qos mode
1392 *
1393 * wmm related checks
1394 *
1395 * Return: true of no error, false otherwise
1396 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001397static bool lim_chk_wmm(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001398 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -07001399 uint8_t sub_type, tHalBitVal qos_mode)
1400{
1401 tHalBitVal wme_mode;
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001402
Naveen Rawatada5fac2016-01-28 16:24:32 -08001403 limGetWmeMode(session, &wme_mode);
1404 if ((qos_mode == eHAL_SET) || (wme_mode == eHAL_SET)) {
Krunal Soni99752a12016-04-12 17:44:45 -07001405 /*
1406 * for a qsta, check if the requested Traffic spec is admissible
1407 * for a non-qsta check if the sta can be admitted
1408 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001409 if (assoc_req->addtsPresent) {
Krunal Soni99752a12016-04-12 17:44:45 -07001410 uint8_t tspecIdx = 0;
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001411
Naveen Rawatada5fac2016-01-28 16:24:32 -08001412 if (lim_admit_control_add_ts(mac_ctx, hdr->sa,
Krunal Soni99752a12016-04-12 17:44:45 -07001413 &(assoc_req->addtsReq),
1414 &(assoc_req->qosCapability),
1415 0, false, NULL, &tspecIdx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001416 QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301417 pe_warn("AdmitControl: TSPEC rejected");
bings85512332019-09-04 17:46:37 +08001418 lim_send_assoc_rsp_mgmt_frame(
1419 mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -07001420 eSIR_MAC_QAP_NO_BANDWIDTH_REASON,
bings85512332019-09-04 17:46:37 +08001421 1, hdr->sa, sub_type, 0, session,
1422 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -08001424 mac_ctx->lim.gLimNumAssocReqDropACRejectTS++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425#endif
Krunal Soni99752a12016-04-12 17:44:45 -07001426 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001428 } else if (lim_admit_control_add_sta(mac_ctx, hdr->sa, false)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001429 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301430 pe_warn("AdmitControl: Sta rejected");
bings85512332019-09-04 17:46:37 +08001431 lim_send_assoc_rsp_mgmt_frame(
1432 mac_ctx, eSIR_MAC_QAP_NO_BANDWIDTH_REASON, 1,
1433 hdr->sa, sub_type, 0, session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -08001435 mac_ctx->lim.gLimNumAssocReqDropACRejectSta++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436#endif
Krunal Soni99752a12016-04-12 17:44:45 -07001437 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 }
1439 /* else all ok */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301440 pe_debug("AdmitControl: Sta OK!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 }
Krunal Soni99752a12016-04-12 17:44:45 -07001442 return true;
1443}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444
Liangwei Dong57ef9a32019-12-25 13:14:40 +08001445static void lim_update_sta_ds_op_classes(tpSirAssocReq assoc_req,
1446 tpDphHashNode sta_ds)
1447{
1448 qdf_mem_copy(&sta_ds->supp_operating_classes,
1449 &assoc_req->supp_operating_classes,
1450 sizeof(tDot11fIESuppOperatingClasses));
1451}
1452
Krunal Soni99752a12016-04-12 17:44:45 -07001453/**
1454 * lim_update_sta_ds() - updates ds dph entry
1455 * @mac_ctx: pointer to Global MAC structure
1456 * @hdr: pointer to the MAC head
1457 * @session: pointer to pe session entry
Abhishek Singh61084982016-12-13 17:24:07 +05301458 * @assoc_req: pointer to ASSOC/REASSOC Request frame pointer
Krunal Soni99752a12016-04-12 17:44:45 -07001459 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1460 * @sta_ds: station dph entry
Krunal Soni99752a12016-04-12 17:44:45 -07001461 * @auth_type: indicates security type
Min Liuddd23302018-12-05 16:17:48 +08001462 * @akm_type: indicates security type in akm
Krunal Soni99752a12016-04-12 17:44:45 -07001463 * @assoc_req_copied: boolean to indicate if assoc req was copied to tmp above
1464 * @peer_idx: peer index
1465 * @qos_mode: qos mode
1466 * @pmf_connection: flag indicating pmf connection
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301467 * @force_1x1: Flag to check if the HT capable STA needs to be downgraded to 1x1
1468 * nss.
Krunal Soni99752a12016-04-12 17:44:45 -07001469 *
1470 * Updates ds dph entry
1471 *
1472 * Return: true of no error, false otherwise
1473 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001474static bool lim_update_sta_ds(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Min Liuddd23302018-12-05 16:17:48 +08001475 struct pe_session *session,
1476 tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -07001477 uint8_t sub_type, tpDphHashNode sta_ds,
Krunal Soni99752a12016-04-12 17:44:45 -07001478 tAniAuthType auth_type,
Min Liuddd23302018-12-05 16:17:48 +08001479 enum ani_akm_type akm_type,
Krunal Soni99752a12016-04-12 17:44:45 -07001480 bool *assoc_req_copied, uint16_t peer_idx,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301481 tHalBitVal qos_mode, bool pmf_connection,
1482 bool force_1x1)
Krunal Soni99752a12016-04-12 17:44:45 -07001483{
Krunal Soni99752a12016-04-12 17:44:45 -07001484 tHalBitVal wme_mode, wsm_mode;
1485 uint8_t *ht_cap_ie = NULL;
1486#ifdef WLAN_FEATURE_11W
1487 tPmfSaQueryTimerId timer_id;
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301488 uint16_t retry_interval;
Krunal Soni99752a12016-04-12 17:44:45 -07001489#endif
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301490 tDot11fIEVHTCaps *vht_caps;
Abhishek Singh61084982016-12-13 17:24:07 +05301491 tpSirAssocReq tmp_assoc_req;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301492
1493 if (assoc_req->VHTCaps.present)
1494 vht_caps = &assoc_req->VHTCaps;
1495 else if (assoc_req->vendor_vht_ie.VHTCaps.present &&
1496 session->vendor_vht_sap)
1497 vht_caps = &assoc_req->vendor_vht_ie.VHTCaps;
1498 else
1499 vht_caps = NULL;
1500
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 /*
Krunal Soni99752a12016-04-12 17:44:45 -07001502 * check here if the parsedAssocReq already pointing to the assoc_req
1503 * and free it before assigning this new assoc_req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001505 if (session->parsedAssocReq) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001506 tmp_assoc_req = session->parsedAssocReq[sta_ds->assocId];
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001507 if (tmp_assoc_req) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001508 if (tmp_assoc_req->assocReqFrame) {
1509 qdf_mem_free(tmp_assoc_req->assocReqFrame);
1510 tmp_assoc_req->assocReqFrame = NULL;
1511 tmp_assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001513 qdf_mem_free(tmp_assoc_req);
1514 tmp_assoc_req = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 }
1516
Naveen Rawatada5fac2016-01-28 16:24:32 -08001517 session->parsedAssocReq[sta_ds->assocId] = assoc_req;
Krunal Soni99752a12016-04-12 17:44:45 -07001518 *assoc_req_copied = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 }
1520
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001521 if (!assoc_req->wmeInfoPresent) {
1522 sta_ds->mlmStaContext.htCapability = 0;
1523 sta_ds->mlmStaContext.vhtCapability = 0;
1524 } else {
1525 sta_ds->mlmStaContext.htCapability = assoc_req->HTCaps.present;
1526 if ((vht_caps) && vht_caps->present)
1527 sta_ds->mlmStaContext.vhtCapability = vht_caps->present;
1528 else
1529 sta_ds->mlmStaContext.vhtCapability = false;
1530 }
1531
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001532 lim_update_stads_he_capable(sta_ds, assoc_req);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001533 sta_ds->qos.addtsPresent =
1534 (assoc_req->addtsPresent == 0) ? false : true;
1535 sta_ds->qos.addts = assoc_req->addtsReq;
1536 sta_ds->qos.capability = assoc_req->qosCapability;
Krunal Soni99752a12016-04-12 17:44:45 -07001537 /*
1538 * short slot and short preamble should be updated before doing
1539 * limaddsta
1540 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001541 sta_ds->shortPreambleEnabled =
1542 (uint8_t) assoc_req->capabilityInfo.shortPreamble;
1543 sta_ds->shortSlotTimeEnabled =
1544 (uint8_t) assoc_req->capabilityInfo.shortSlotTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545
Naveen Rawatada5fac2016-01-28 16:24:32 -08001546 sta_ds->valid = 0;
1547 sta_ds->mlmStaContext.authType = auth_type;
Min Liuddd23302018-12-05 16:17:48 +08001548 sta_ds->mlmStaContext.akm_type = akm_type;
Naveen Rawatada5fac2016-01-28 16:24:32 -08001549 sta_ds->staType = STA_ENTRY_PEER;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301550 sta_ds->mlmStaContext.force_1x1 = force_1x1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551
Min Liuddd23302018-12-05 16:17:48 +08001552 pe_debug("auth_type = %d, akm_type = %d", auth_type, akm_type);
1553
Krunal Soni99752a12016-04-12 17:44:45 -07001554 /*
1555 * TODO: If listen interval is more than certain limit, reject the
1556 * association. Need to check customer requirements and then implement.
1557 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001558 sta_ds->mlmStaContext.listenInterval = assoc_req->listenInterval;
1559 sta_ds->mlmStaContext.capabilityInfo = assoc_req->capabilityInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560
Naveen Rawatada5fac2016-01-28 16:24:32 -08001561 if (IS_DOT11_MODE_HT(session->dot11mode) &&
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001562 sta_ds->mlmStaContext.htCapability) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001563 sta_ds->htGreenfield = (uint8_t) assoc_req->HTCaps.greenField;
1564 sta_ds->htAMpduDensity = assoc_req->HTCaps.mpduDensity;
1565 sta_ds->htDsssCckRate40MHzSupport =
1566 (uint8_t) assoc_req->HTCaps.dsssCckMode40MHz;
1567 sta_ds->htLsigTXOPProtection =
1568 (uint8_t) assoc_req->HTCaps.lsigTXOPProtection;
1569 sta_ds->htMaxAmsduLength =
1570 (uint8_t) assoc_req->HTCaps.maximalAMSDUsize;
1571 sta_ds->htMaxRxAMpduFactor = assoc_req->HTCaps.maxRxAMPDUFactor;
1572 sta_ds->htMIMOPSState = assoc_req->HTCaps.mimoPowerSave;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573
Krunal Soni99752a12016-04-12 17:44:45 -07001574 /* assoc_req will be copied to session->parsedAssocReq later */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001575 ht_cap_ie = ((uint8_t *) &assoc_req->HTCaps) + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576
Jeff Johnsonbe119e62019-02-02 12:30:26 -08001577 if (session->ht_config.ht_sgi20) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001578 sta_ds->htShortGI20Mhz =
Krunal Soni99752a12016-04-12 17:44:45 -07001579 (uint8_t)assoc_req->HTCaps.shortGI20MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 } else {
1581 /* Unset htShortGI20Mhz in ht_caps*/
1582 *ht_cap_ie &= ~(1 << SIR_MAC_HT_CAP_SHORTGI20MHZ_S);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001583 sta_ds->htShortGI20Mhz = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001584 }
1585
Jeff Johnsonbe119e62019-02-02 12:30:26 -08001586 if (session->ht_config.ht_sgi40) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001587 sta_ds->htShortGI40Mhz =
1588 (uint8_t)assoc_req->HTCaps.shortGI40MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589 } else {
1590 /* Unset htShortGI40Mhz in ht_caps */
1591 *ht_cap_ie &= ~(1 << SIR_MAC_HT_CAP_SHORTGI40MHZ_S);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001592 sta_ds->htShortGI40Mhz = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593 }
1594
Naveen Rawatada5fac2016-01-28 16:24:32 -08001595 sta_ds->htSupportedChannelWidthSet =
1596 (uint8_t) assoc_req->HTCaps.supportedChannelWidthSet;
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001597 if (session->ch_width > CH_WIDTH_20MHZ &&
1598 session->ch_width <= CH_WIDTH_80P80MHZ &&
1599 sta_ds->htSupportedChannelWidthSet) {
Krunal Soni99752a12016-04-12 17:44:45 -07001600 /*
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001601 * peer just follows AP; so when we are softAP/GO,
1602 * we just store our session entry's secondary channel
1603 * offset here in peer INFRA STA. However, if peer's
1604 * 40MHz channel width support is disabled then
1605 * secondary channel will be zero
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001606 */
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001607 sta_ds->htSecondaryChannelOffset =
1608 session->htSecondaryChannelOffset;
1609 sta_ds->ch_width = CH_WIDTH_40MHZ;
1610 if (sta_ds->mlmStaContext.vhtCapability) {
1611 if (assoc_req->operMode.present) {
1612 sta_ds->ch_width =
1613 assoc_req->operMode.chanWidth;
1614 } else if (vht_caps->supportedChannelWidthSet ==
1615 VHT_CAP_160_AND_80P80_SUPP) {
1616 sta_ds->ch_width = CH_WIDTH_80P80MHZ;
1617 } else if (vht_caps->supportedChannelWidthSet ==
1618 VHT_CAP_160_SUPP) {
1619 if (vht_caps->vht_extended_nss_bw_cap &&
1620 vht_caps->extended_nss_bw_supp)
1621 sta_ds->ch_width =
1622 CH_WIDTH_80P80MHZ;
1623 else
1624 sta_ds->ch_width =
1625 CH_WIDTH_160MHZ;
1626 } else if (vht_caps->vht_extended_nss_bw_cap) {
1627 if (vht_caps->extended_nss_bw_supp ==
1628 VHT_EXTD_NSS_80_HALF_NSS_160)
1629 sta_ds->ch_width =
1630 CH_WIDTH_160MHZ;
1631 else if (vht_caps->extended_nss_bw_supp >
1632 VHT_EXTD_NSS_80_HALF_NSS_160)
1633 sta_ds->ch_width =
1634 CH_WIDTH_80P80MHZ;
1635 else
1636 sta_ds->ch_width =
1637 CH_WIDTH_80MHZ;
1638 } else {
1639 sta_ds->ch_width = CH_WIDTH_80MHZ;
1640 }
1641
1642 sta_ds->ch_width = QDF_MIN(sta_ds->ch_width,
1643 session->ch_width);
1644 }
1645 } else {
1646 sta_ds->htSupportedChannelWidthSet = 0;
1647 sta_ds->htSecondaryChannelOffset = 0;
1648 sta_ds->ch_width = CH_WIDTH_20MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001650 sta_ds->htLdpcCapable =
1651 (uint8_t) assoc_req->HTCaps.advCodingCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 }
1653
gaolez7bb1e742017-03-21 16:37:38 +08001654 if (assoc_req->ExtCap.present)
1655 sta_ds->non_ecsa_capable =
1656 !((struct s_ext_cap *)assoc_req->ExtCap.bytes)->
1657 ext_chan_switch;
1658 else
1659 sta_ds->non_ecsa_capable = 1;
1660
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001661 if (sta_ds->mlmStaContext.vhtCapability &&
Abhinav Kumar2ae25242020-05-11 22:46:11 +05301662 session->vhtCapability) {
hquac3362d2019-11-08 17:54:21 +08001663 sta_ds->htMaxRxAMpduFactor =
1664 vht_caps->maxAMPDULenExp;
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001665 sta_ds->vhtLdpcCapable =
1666 (uint8_t)vht_caps->ldpcCodingCap;
Krunal Soni53993f72016-07-08 18:20:03 -07001667 if (session->vht_config.su_beam_formee &&
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001668 vht_caps->suBeamFormerCap)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001669 sta_ds->vhtBeamFormerCapable = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 else
Naveen Rawatada5fac2016-01-28 16:24:32 -08001671 sta_ds->vhtBeamFormerCapable = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001672 if (session->vht_config.su_beam_former &&
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001673 vht_caps->suBeamformeeCap)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001674 sta_ds->vht_su_bfee_capable = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 else
Naveen Rawatada5fac2016-01-28 16:24:32 -08001676 sta_ds->vht_su_bfee_capable = 0;
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001677
1678 pe_debug("peer_caps: suBformer: %d, suBformee: %d",
1679 vht_caps->suBeamFormerCap,
1680 vht_caps->suBeamformeeCap);
1681 pe_debug("self_cap: suBformer: %d, suBformee: %d",
1682 session->vht_config.su_beam_former,
1683 session->vht_config.su_beam_formee);
1684 pe_debug("connection's final cap: suBformer: %d, suBformee: %d",
1685 sta_ds->vhtBeamFormerCapable,
1686 sta_ds->vht_su_bfee_capable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001688
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07001689 sta_ds->vht_mcs_10_11_supp = 0;
1690 if (IS_DOT11_MODE_HT(session->dot11mode) &&
1691 sta_ds->mlmStaContext.vhtCapability) {
1692 if (mac_ctx->mlme_cfg->vht_caps.vht_cap_info.
1693 vht_mcs_10_11_supp &&
1694 assoc_req->qcn_ie.present &&
1695 assoc_req->qcn_ie.vht_mcs11_attr.present)
1696 sta_ds->vht_mcs_10_11_supp =
1697 assoc_req->qcn_ie.vht_mcs11_attr.
1698 vht_mcs_10_11_supp;
1699 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001700 lim_intersect_sta_he_caps(assoc_req, session, sta_ds);
1701
Krunal Soni99752a12016-04-12 17:44:45 -07001702 if (lim_populate_matching_rate_set(mac_ctx, sta_ds,
1703 &(assoc_req->supportedRates),
1704 &(assoc_req->extendedRates),
1705 assoc_req->HTCaps.supportedMCSSet,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001706 session, vht_caps,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001707 &assoc_req->he_cap) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 /* Could not update hash table entry at DPH with rateset */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301709 pe_err("Couldn't update hash entry for aid: %d MacAddr: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001710 QDF_MAC_ADDR_FMT,
1711 peer_idx, QDF_MAC_ADDR_REF(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712
1713 /* Release AID */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001714 lim_release_peer_idx(mac_ctx, peer_idx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715
Naveen Rawatada5fac2016-01-28 16:24:32 -08001716 lim_reject_association(mac_ctx, hdr->sa,
Abhishek Singh0bc46d12017-01-09 13:05:54 +05301717 sub_type, true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001718 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001719 session);
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301720 pe_err("Delete dph hash entry");
Abhishek Singh0bc46d12017-01-09 13:05:54 +05301721 if (dph_delete_hash_entry(mac_ctx, hdr->sa, sta_ds->assocId,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001722 &session->dph.dphHashTable) != QDF_STATUS_SUCCESS)
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301723 pe_err("error deleting hash entry");
Krunal Soni99752a12016-04-12 17:44:45 -07001724 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001726 if (assoc_req->operMode.present) {
1727 sta_ds->vhtSupportedRxNss = assoc_req->operMode.rxNSS + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001729 sta_ds->vhtSupportedRxNss =
1730 ((sta_ds->supportedRates.vhtRxMCSMap & MCSMAPMASK2x2)
Krunal Soni99752a12016-04-12 17:44:45 -07001731 == MCSMAPMASK2x2) ? 1 : 2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 }
Liangwei Dong2b0c18b2019-12-10 13:29:53 +08001733 lim_update_stads_he_6ghz_op(session, sta_ds);
Liangwei Dong57ef9a32019-12-25 13:14:40 +08001734 lim_update_sta_ds_op_classes(assoc_req, sta_ds);
Krunal Soni99752a12016-04-12 17:44:45 -07001735 /* Add STA context at MAC HW (BMU, RHP & TFP) */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001736 sta_ds->qosMode = false;
1737 sta_ds->lleEnabled = false;
1738 if (assoc_req->capabilityInfo.qos && (qos_mode == eHAL_SET)) {
1739 sta_ds->lleEnabled = true;
1740 sta_ds->qosMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 }
1742
Naveen Rawatada5fac2016-01-28 16:24:32 -08001743 sta_ds->wmeEnabled = false;
1744 sta_ds->wsmEnabled = false;
1745 limGetWmeMode(session, &wme_mode);
1746 if ((!sta_ds->lleEnabled) && assoc_req->wmeInfoPresent
1747 && (wme_mode == eHAL_SET)) {
1748 sta_ds->wmeEnabled = true;
1749 sta_ds->qosMode = true;
1750 limGetWsmMode(session, &wsm_mode);
Krunal Soni99752a12016-04-12 17:44:45 -07001751 /*
1752 * WMM_APSD - WMM_SA related processing should be separate;
1753 * WMM_SA and WMM_APSD can coexist
1754 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001755 if (assoc_req->WMMInfoStation.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 /* check whether AP supports or not */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001757 if (LIM_IS_AP_ROLE(session) &&
Krunal Soni99752a12016-04-12 17:44:45 -07001758 (session->apUapsdEnable == 0) &&
1759 (assoc_req->WMMInfoStation.acbe_uapsd ||
1760 assoc_req->WMMInfoStation.acbk_uapsd ||
1761 assoc_req->WMMInfoStation.acvo_uapsd ||
1762 assoc_req->WMMInfoStation.acvi_uapsd)) {
1763 /*
1764 * Rcvd Re/Assoc Req from STA when UPASD is
1765 * not supported.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301767 pe_err("UAPSD not supported, reply accordingly");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 /* update UAPSD and send it to LIM to add STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001769 sta_ds->qos.capability.qosInfo.acbe_uapsd = 0;
1770 sta_ds->qos.capability.qosInfo.acbk_uapsd = 0;
1771 sta_ds->qos.capability.qosInfo.acvo_uapsd = 0;
1772 sta_ds->qos.capability.qosInfo.acvi_uapsd = 0;
1773 sta_ds->qos.capability.qosInfo.maxSpLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 } else {
1775 /* update UAPSD and send it to LIM to add STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001776 sta_ds->qos.capability.qosInfo.acbe_uapsd =
1777 assoc_req->WMMInfoStation.acbe_uapsd;
1778 sta_ds->qos.capability.qosInfo.acbk_uapsd =
1779 assoc_req->WMMInfoStation.acbk_uapsd;
1780 sta_ds->qos.capability.qosInfo.acvo_uapsd =
1781 assoc_req->WMMInfoStation.acvo_uapsd;
1782 sta_ds->qos.capability.qosInfo.acvi_uapsd =
1783 assoc_req->WMMInfoStation.acvi_uapsd;
1784 sta_ds->qos.capability.qosInfo.maxSpLen =
1785 assoc_req->WMMInfoStation.max_sp_length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 }
1787 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001788 if (assoc_req->wsmCapablePresent && (wsm_mode == eHAL_SET))
1789 sta_ds->wsmEnabled = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 }
1791 /* Re/Assoc Response frame to requesting STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001792 sta_ds->mlmStaContext.subType = sub_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793
1794#ifdef WLAN_FEATURE_11W
Naveen Rawatada5fac2016-01-28 16:24:32 -08001795 sta_ds->rmfEnabled = (pmf_connection) ? 1 : 0;
1796 sta_ds->pmfSaQueryState = DPH_SA_QUERY_NOT_IN_PROGRESS;
1797 timer_id.fields.sessionId = session->peSessionId;
1798 timer_id.fields.peerIdx = peer_idx;
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301799 retry_interval = mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1800 if (cfg_min(CFG_PMF_SA_QUERY_RETRY_INTERVAL) > retry_interval) {
1801 retry_interval = cfg_default(CFG_PMF_SA_QUERY_RETRY_INTERVAL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 }
Abhishek Singh7a7799b2020-01-21 10:30:28 +05301803 if (sta_ds->rmfEnabled) {
1804 /* Try to delete it before, creating.*/
1805 lim_delete_pmf_query_timer(sta_ds);
1806 if (tx_timer_create(mac_ctx, &sta_ds->pmfSaQueryTimer,
1807 "PMF SA Query timer", lim_pmf_sa_query_timer_handler,
1808 timer_id.value,
1809 SYS_MS_TO_TICKS((retry_interval * 1024) / 1000),
1810 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
1811 pe_err("could not create PMF SA Query timer");
1812 lim_reject_association(mac_ctx, hdr->sa, sub_type,
1813 true, auth_type, peer_idx, false,
1814 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1815 session);
1816 return false;
1817 }
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001818 pe_debug("Created pmf timer assoc-id:%d sta mac" QDF_MAC_ADDR_FMT,
1819 sta_ds->assocId, QDF_MAC_ADDR_REF(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820 }
1821#endif
1822
Naveen Rawatada5fac2016-01-28 16:24:32 -08001823 if (assoc_req->ExtCap.present) {
1824 lim_set_stads_rtt_cap(sta_ds,
1825 (struct s_ext_cap *) assoc_req->ExtCap.bytes, mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001827 sta_ds->timingMeasCap = 0;
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301828 pe_debug("ExtCap not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 }
Liangwei Dong05276172019-12-27 10:31:46 +08001830 lim_ap_check_6g_compatible_peer(mac_ctx, session);
Krunal Soni99752a12016-04-12 17:44:45 -07001831 return true;
1832}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833
Krunal Soni99752a12016-04-12 17:44:45 -07001834/**
1835 * lim_update_sta_ctx() - add/del sta depending on connection state machine
1836 * @mac_ctx: pointer to Global MAC structure
1837 * @session: pointer to pe session entry
1838 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1839 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1840 * @sta_ds: station dph entry
1841 * @update_ctx: indicates if STA context already exist
1842 *
1843 * Checks for SSID match
1844 *
1845 * Return: true of no error, false otherwise
1846 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001847static bool lim_update_sta_ctx(struct mac_context *mac_ctx, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001848 tpSirAssocReq assoc_req, uint8_t sub_type,
1849 tpDphHashNode sta_ds, uint8_t update_ctx)
1850{
1851 tLimMlmStates mlm_prev_state;
1852 /*
1853 * BTAMP: If STA context already exist (ie. update_ctx = 1) for this STA
1854 * then we should delete the old one, and add the new STA. This is taken
1855 * care of in the lim_del_sta() routine.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 *
Krunal Soni99752a12016-04-12 17:44:45 -07001857 * Prior to BTAMP, we were setting this flag so that when PE receives
1858 * SME_ASSOC_CNF, and if this flag is set, then PE shall delete the old
1859 * station and then add. But now in BTAMP, we're directly adding station
1860 * before waiting for SME_ASSOC_CNF, so we can do this now.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 */
Krunal Soni99752a12016-04-12 17:44:45 -07001862 if (!(update_ctx)) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001863 sta_ds->mlmStaContext.updateContext = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864
Krunal Soni99752a12016-04-12 17:44:45 -07001865 /*
1866 * BTAMP: Add STA context at HW - issue WMA_ADD_STA_REQ to HAL
1867 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001868 if (lim_add_sta(mac_ctx, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001869 QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301870 pe_err("could not Add STA with assocId: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -08001871 sta_ds->assocId);
1872 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001873 sta_ds->mlmStaContext.subType, true,
1874 sta_ds->mlmStaContext.authType,
1875 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001876 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001877 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878
Naveen Rawatada5fac2016-01-28 16:24:32 -08001879 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001880 assoc_req =
1881 session->parsedAssocReq[sta_ds->assocId];
1882 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 }
1884 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001885 sta_ds->mlmStaContext.updateContext = 1;
Naveen Rawatada5fac2016-01-28 16:24:32 -08001886 mlm_prev_state = sta_ds->mlmStaContext.mlmState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887
Krunal Soni99752a12016-04-12 17:44:45 -07001888 /*
1889 * As per the HAL/FW needs the reassoc req need not be calling
1890 * lim_del_sta
1891 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001892 if (sub_type != LIM_REASSOC) {
Krunal Soni99752a12016-04-12 17:44:45 -07001893 /*
1894 * we need to set the mlmState here in order
1895 * differentiate in lim_del_sta.
1896 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001897 sta_ds->mlmStaContext.mlmState =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE;
Krunal Soni99752a12016-04-12 17:44:45 -07001899 if (lim_del_sta(mac_ctx, sta_ds, true, session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001900 != QDF_STATUS_SUCCESS) {
Yeshwanth Sriram Guntukae6b54242019-07-16 14:54:16 +05301901 pe_err("Couldn't DEL STA, assocId: %d sta mac"
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001902 QDF_MAC_ADDR_FMT, sta_ds->assocId,
1903 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Naveen Rawatada5fac2016-01-28 16:24:32 -08001904 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001905 sta_ds->mlmStaContext.subType, true,
1906 sta_ds->mlmStaContext.authType,
1907 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001908 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001909 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910
1911 /* Restoring the state back. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001912 sta_ds->mlmStaContext.mlmState = mlm_prev_state;
1913 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001914 assoc_req = session->parsedAssocReq[
1915 sta_ds->assocId];
1916 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917 }
1918 } else {
Krunal Soni99752a12016-04-12 17:44:45 -07001919 /*
1920 * mlmState is changed in lim_add_sta context use the
1921 * same AID, already allocated
1922 */
1923 if (lim_add_sta(mac_ctx, sta_ds, false, session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001924 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301925 pe_err("UPASD not supported, REASSOC Failed");
Naveen Rawatada5fac2016-01-28 16:24:32 -08001926 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001927 sta_ds->mlmStaContext.subType, true,
1928 sta_ds->mlmStaContext.authType,
1929 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001930 eSIR_MAC_WME_REFUSED_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001931 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932
1933 /* Restoring the state back. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001934 sta_ds->mlmStaContext.mlmState = mlm_prev_state;
1935 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001936 assoc_req = session->parsedAssocReq[
Naveen Rawatada5fac2016-01-28 16:24:32 -08001937 sta_ds->assocId];
Krunal Soni99752a12016-04-12 17:44:45 -07001938 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941 }
Krunal Soni99752a12016-04-12 17:44:45 -07001942 return true;
1943}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05301945void lim_process_assoc_cleanup(struct mac_context *mac_ctx,
1946 struct pe_session *session,
1947 tpSirAssocReq assoc_req,
1948 tpDphHashNode sta_ds,
1949 bool assoc_req_copied)
Krunal Soni99752a12016-04-12 17:44:45 -07001950{
Abhishek Singh61084982016-12-13 17:24:07 +05301951 tpSirAssocReq tmp_assoc_req;
1952
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001953 if (assoc_req) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001954 if (assoc_req->assocReqFrame) {
1955 qdf_mem_free(assoc_req->assocReqFrame);
1956 assoc_req->assocReqFrame = NULL;
1957 assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 }
1959
Naveen Rawatada5fac2016-01-28 16:24:32 -08001960 qdf_mem_free(assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 /* to avoid double free */
sheenam mongad756ff12019-04-15 15:43:18 +05301962 if (assoc_req_copied && session->parsedAssocReq && sta_ds)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001963 session->parsedAssocReq[sta_ds->assocId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 }
1965
1966 /* If it is not duplicate Assoc request then only make to Null */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001967 if ((sta_ds) &&
Naveen Rawatada5fac2016-01-28 16:24:32 -08001968 (sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ADD_STA_RSP_STATE)) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001969 if (session->parsedAssocReq) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001970 tmp_assoc_req =
1971 session->parsedAssocReq[sta_ds->assocId];
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001972 if (tmp_assoc_req) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001973 if (tmp_assoc_req->assocReqFrame) {
Krunal Soni99752a12016-04-12 17:44:45 -07001974 qdf_mem_free(
1975 tmp_assoc_req->assocReqFrame);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001976 tmp_assoc_req->assocReqFrame = NULL;
1977 tmp_assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001979 qdf_mem_free(tmp_assoc_req);
Krunal Soni99752a12016-04-12 17:44:45 -07001980 session->parsedAssocReq[sta_ds->assocId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981 }
1982 }
1983 }
Krunal Soni99752a12016-04-12 17:44:45 -07001984}
1985
1986/**
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05301987 * lim_defer_sme_indication() - Defer assoc indication to SME
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05301988 * @mac_ctx: Pointer to Global MAC structure
1989 * @session: pe session entry
1990 * @sub_type: Indicates whether it is Association Request(=0) or Reassociation
1991 * Request(=1) frame
1992 * @hdr: A pointer to the MAC header
1993 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1994 * @pmf_connection: flag indicating pmf connection
1995 * @assoc_req_copied: boolean to indicate if assoc req was copied to tmp above
1996 * @dup_entry: flag indicating if duplicate entry found
1997 *
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05301998 * Defer Initialization of PE data structures and wait for an external event.
1999 * lim_send_assoc_ind_to_sme() will be called to initialize PE data structures
2000 * when the expected event is received.
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302001 *
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302002 * Return: void
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302003 */
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302004static void lim_defer_sme_indication(struct mac_context *mac_ctx,
2005 struct pe_session *session,
2006 uint8_t sub_type,
2007 tpSirMacMgmtHdr hdr,
2008 struct sSirAssocReq *assoc_req,
2009 bool pmf_connection,
2010 bool assoc_req_copied,
2011 bool dup_entry,
2012 struct sDphHashNode *sta_ds)
2013{
2014 struct tLimPreAuthNode *sta_pre_auth_ctx;
Srinivas Dasarifffa0b42019-09-27 14:22:47 +05302015 struct lim_assoc_data *cached_req;
2016
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302017 /* Extract pre-auth context for the STA, if any. */
2018 sta_pre_auth_ctx = lim_search_pre_auth_list(mac_ctx, hdr->sa);
Srinivas Dasarifffa0b42019-09-27 14:22:47 +05302019 if (sta_pre_auth_ctx->assoc_req.present) {
2020 pe_debug("Free the cached assoc req as a new one is received");
2021 cached_req = &sta_pre_auth_ctx->assoc_req;
2022 lim_process_assoc_cleanup(mac_ctx, session,
2023 cached_req->assoc_req,
2024 cached_req->sta_ds,
2025 cached_req->assoc_req_copied);
2026 }
2027
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302028 sta_pre_auth_ctx->assoc_req.present = true;
2029 sta_pre_auth_ctx->assoc_req.sub_type = sub_type;
2030 qdf_mem_copy(&sta_pre_auth_ctx->assoc_req.hdr, hdr,
2031 sizeof(tSirMacMgmtHdr));
2032 sta_pre_auth_ctx->assoc_req.assoc_req = assoc_req;
2033 sta_pre_auth_ctx->assoc_req.pmf_connection = pmf_connection;
2034 sta_pre_auth_ctx->assoc_req.assoc_req_copied = assoc_req_copied;
2035 sta_pre_auth_ctx->assoc_req.dup_entry = dup_entry;
2036 sta_pre_auth_ctx->assoc_req.sta_ds = sta_ds;
2037}
2038
2039bool lim_send_assoc_ind_to_sme(struct mac_context *mac_ctx,
2040 struct pe_session *session,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05302041 uint8_t sub_type, tpSirMacMgmtHdr hdr,
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302042 tpSirAssocReq assoc_req,
Min Liuddd23302018-12-05 16:17:48 +08002043 enum ani_akm_type akm_type,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05302044 bool pmf_connection, bool *assoc_req_copied,
2045 bool dup_entry, bool force_1x1)
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302046{
2047 uint16_t peer_idx;
2048 struct tLimPreAuthNode *sta_pre_auth_ctx;
2049 tpDphHashNode sta_ds = NULL;
2050 tHalBitVal qos_mode;
2051 tAniAuthType auth_type;
2052 uint8_t update_ctx = false;
2053
2054 limGetQosMode(session, &qos_mode);
2055 /* Extract 'associated' context for STA, if any. */
2056 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa, &peer_idx,
2057 &session->dph.dphHashTable);
2058
2059 /* Extract pre-auth context for the STA, if any. */
2060 sta_pre_auth_ctx = lim_search_pre_auth_list(mac_ctx, hdr->sa);
2061
2062 if (!sta_ds) {
2063 if (!lim_process_assoc_req_no_sta_ctx(mac_ctx, hdr, session,
2064 assoc_req, sub_type,
2065 sta_pre_auth_ctx, sta_ds,
2066 &auth_type))
2067 return false;
2068 } else {
2069 if (!lim_process_assoc_req_sta_ctx(mac_ctx, hdr, session,
2070 assoc_req, sub_type,
2071 sta_pre_auth_ctx, sta_ds,
2072 peer_idx, &auth_type,
2073 &update_ctx))
2074 return false;
2075 goto send_ind_to_sme;
2076 }
2077
2078 /* check if sta is allowed per QoS AC rules */
2079 if (!lim_chk_wmm(mac_ctx, hdr, session, assoc_req, sub_type, qos_mode))
2080 return false;
2081
2082 /* STA is Associated ! */
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002083 pe_debug("Received: %s Req successful from " QDF_MAC_ADDR_FMT,
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302084 (sub_type == LIM_ASSOC) ? "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002085 QDF_MAC_ADDR_REF(hdr->sa));
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302086
2087 /*
2088 * AID for this association will be same as the peer Index used in DPH
2089 * table. Assign unused/least recently used peer Index from perStaDs.
2090 * NOTE: lim_assign_peer_idx() assigns AID values ranging between
2091 * 1 - cfg_item(WNI_CFG_ASSOC_STA_LIMIT)
2092 */
2093
2094 peer_idx = lim_assign_peer_idx(mac_ctx, session);
2095
2096 if (!peer_idx) {
2097 /* Could not assign AID. Reject association */
2098 pe_err("PeerIdx not avaialble. Reject associaton");
2099 lim_reject_association(mac_ctx, hdr->sa, sub_type,
2100 true, auth_type, peer_idx, false,
2101 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2102 session);
2103 return false;
2104 }
2105
2106 /* Add an entry to hash table maintained by DPH module */
2107
2108 sta_ds = dph_add_hash_entry(mac_ctx, hdr->sa, peer_idx,
2109 &session->dph.dphHashTable);
2110
2111 if (!sta_ds) {
2112 /* Could not add hash table entry at DPH */
2113 pe_err("couldn't add hash entry at DPH for aid: %d MacAddr:"
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002114 QDF_MAC_ADDR_FMT, peer_idx, QDF_MAC_ADDR_REF(hdr->sa));
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302115
2116 /* Release AID */
2117 lim_release_peer_idx(mac_ctx, peer_idx, session);
2118
2119 lim_reject_association(mac_ctx, hdr->sa, sub_type,
2120 true, auth_type, peer_idx, false,
2121 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2122 session);
2123 return false;
2124 }
2125
Rajasekaran Kalidossf4e187c2020-04-20 14:46:06 +05302126 if (LIM_IS_AP_ROLE(session)) {
2127 if ((assoc_req->wpaPresent || assoc_req->rsnPresent) &&
2128 !session->privacy) {
2129 lim_reject_association(mac_ctx, hdr->sa, sub_type,
2130 true, auth_type, peer_idx,
2131 true,
2132 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2133 session);
2134 return false;
2135 }
2136 }
2137
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302138send_ind_to_sme:
2139 if (!lim_update_sta_ds(mac_ctx, hdr, session, assoc_req,
Min Liuddd23302018-12-05 16:17:48 +08002140 sub_type, sta_ds, auth_type, akm_type,
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302141 assoc_req_copied, peer_idx, qos_mode,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05302142 pmf_connection, force_1x1))
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302143 return false;
2144
2145 /* BTAMP: Storing the parsed assoc request in the session array */
2146 if (session->parsedAssocReq)
2147 session->parsedAssocReq[sta_ds->assocId] = assoc_req;
2148 *assoc_req_copied = true;
2149
2150 /* If it is duplicate entry wait till the peer is deleted */
2151 if (!dup_entry) {
2152 if (!lim_update_sta_ctx(mac_ctx, session, assoc_req,
2153 sub_type, sta_ds, update_ctx))
2154 return false;
2155 }
2156
2157 /* AddSta is success here */
2158 if (LIM_IS_AP_ROLE(session) && IS_DOT11_MODE_HT(session->dot11mode) &&
2159 assoc_req->HTCaps.present && assoc_req->wmeInfoPresent) {
2160 /*
2161 * Update in the HAL Sta Table for the Update of the Protection
2162 * Mode
2163 */
Yeshwanth Sriram Guntukad2a22912019-07-16 15:44:52 +05302164 lim_post_sm_state_update(mac_ctx,
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302165 sta_ds->htMIMOPSState, sta_ds->staAddr,
2166 session->smeSessionId);
2167 }
2168
2169 return true;
2170}
2171
2172/**
Abhishek Singh594d0332020-07-02 11:14:05 +05302173 * lim_peer_present_on_any_sta() - Check if Same MAC is connected with STA, i.e.
2174 * duplicate mac detection.
2175 * @mac_ctx: Pointer to Global MAC structure
2176 * @peer_addr: peer address to check
2177 *
2178 * This function will return true if a peer STA and AP are using same mac
2179 * address.
2180 *
2181 * @Return: bool
2182 */
2183static bool
2184lim_peer_present_on_any_sta(struct mac_context *mac_ctx, uint8_t *peer_addr)
2185{
2186 struct wlan_objmgr_peer *peer;
2187 bool sta_peer_present = false;
2188 enum QDF_OPMODE mode;
2189 uint8_t peer_vdev_id;
2190
2191 peer = wlan_objmgr_get_peer_by_mac(mac_ctx->psoc, peer_addr,
2192 WLAN_LEGACY_MAC_ID);
2193 if (!peer)
2194 return sta_peer_present;
2195
2196 peer_vdev_id = wlan_vdev_get_id(wlan_peer_get_vdev(peer));
2197 mode = wlan_vdev_mlme_get_opmode(wlan_peer_get_vdev(peer));
2198 if (mode == QDF_STA_MODE || mode == QDF_P2P_CLIENT_MODE) {
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002199 pe_debug("duplicate mac detected!!! Peer " QDF_MAC_ADDR_FMT " present on STA vdev %d",
2200 QDF_MAC_ADDR_REF(peer_addr), peer_vdev_id);
Abhishek Singh594d0332020-07-02 11:14:05 +05302201 sta_peer_present = true;
2202 }
2203
2204 wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_MAC_ID);
2205
2206 return sta_peer_present;
2207}
2208
2209/**
Krunal Soni99752a12016-04-12 17:44:45 -07002210 * lim_process_assoc_req_frame() - Process RE/ASSOC Request frame.
2211 * @mac_ctx: Pointer to Global MAC structure
2212 * @rx_pkt_info: A pointer to Buffer descriptor + associated PDUs
2213 * @sub_type: Indicates whether it is Association Request(=0) or Reassociation
2214 * Request(=1) frame
2215 * @session: pe session entry
2216 *
2217 * This function is called to process RE/ASSOC Request frame.
2218 *
2219 * @Return: void
2220 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002221void lim_process_assoc_req_frame(struct mac_context *mac_ctx, uint8_t *rx_pkt_info,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08002222 uint8_t sub_type, struct pe_session *session)
Krunal Soni99752a12016-04-12 17:44:45 -07002223{
2224 bool pmf_connection = false, assoc_req_copied = false;
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302225 uint8_t *frm_body;
2226 uint16_t assoc_id = 0;
Krishna Kumaar Natarajandb582ec2016-03-08 17:37:04 -08002227 uint32_t frame_len;
Krunal Soni99752a12016-04-12 17:44:45 -07002228 uint32_t phy_mode;
2229 tHalBitVal qos_mode;
2230 tpSirMacMgmtHdr hdr;
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302231 struct tLimPreAuthNode *sta_pre_auth_ctx;
Min Liuddd23302018-12-05 16:17:48 +08002232 enum ani_akm_type akm_type = ANI_AKM_TYPE_NONE;
Krunal Soni99752a12016-04-12 17:44:45 -07002233 tSirMacCapabilityInfo local_cap;
2234 tpDphHashNode sta_ds = NULL;
Abhishek Singh61084982016-12-13 17:24:07 +05302235 tpSirAssocReq assoc_req;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05302236 bool dup_entry = false, force_1x1 = false;
Jianmin Zhufc2cef12019-01-14 21:23:51 +08002237 QDF_STATUS status;
bings186fdd22019-07-30 10:05:08 +08002238 struct wlan_objmgr_vdev *vdev;
Krunal Soni99752a12016-04-12 17:44:45 -07002239
2240 lim_get_phy_mode(mac_ctx, &phy_mode, session);
2241
2242 limGetQosMode(session, &qos_mode);
2243
2244 hdr = WMA_GET_RX_MAC_HEADER(rx_pkt_info);
2245 frame_len = WMA_GET_RX_PAYLOAD_LEN(rx_pkt_info);
2246
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002247 pe_nofl_debug("Assoc req RX: subtype %d vdev %d sys role %d lim state %d rssi %d from " QDF_MAC_ADDR_FMT,
Abhishek Singh78800962020-02-17 14:40:57 +05302248 sub_type, session->vdev_id, GET_LIM_SYSTEM_ROLE(session),
2249 session->limMlmState,
2250 WMA_GET_RX_RSSI_NORMALIZED(rx_pkt_info),
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002251 QDF_MAC_ADDR_REF(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -07002252
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07002253 if (LIM_IS_STA_ROLE(session)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302254 pe_err("Rcvd unexpected ASSOC REQ, sessionid: %d sys sub_type: %d for role: %d from: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002255 QDF_MAC_ADDR_FMT,
Krunal Soni99752a12016-04-12 17:44:45 -07002256 session->peSessionId, sub_type,
2257 GET_LIM_SYSTEM_ROLE(session),
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002258 QDF_MAC_ADDR_REF(hdr->sa));
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002259 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
2260 WMA_GET_RX_MPDU_DATA(rx_pkt_info),
2261 frame_len);
Krunal Soni99752a12016-04-12 17:44:45 -07002262 return;
2263 }
Liangwei Dong9028d752016-10-17 02:00:17 -04002264 if (session->limMlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302265 pe_err("drop ASSOC REQ on sessionid: %d "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002266 "role: %d from: "QDF_MAC_ADDR_FMT" in limMlmState: %d",
Liangwei Dong9028d752016-10-17 02:00:17 -04002267 session->peSessionId,
2268 GET_LIM_SYSTEM_ROLE(session),
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002269 QDF_MAC_ADDR_REF(hdr->sa),
Liangwei Dong9028d752016-10-17 02:00:17 -04002270 eLIM_MLM_WT_DEL_BSS_RSP_STATE);
2271 return;
2272 }
bings186fdd22019-07-30 10:05:08 +08002273 vdev = session->vdev;
2274 if (!vdev) {
2275 pe_err("vdev is NULL");
2276 return;
2277 }
2278
sheenam mongaf1655e12020-05-21 18:33:30 +05302279 if (wlan_vdev_mlme_get_state(vdev) != WLAN_VDEV_S_UP) {
bings186fdd22019-07-30 10:05:08 +08002280 pe_err("SAP is not up, drop ASSOC REQ on sessionid: %d",
2281 session->peSessionId);
2282
2283 return;
2284 }
Krunal Soni99752a12016-04-12 17:44:45 -07002285
Abhishek Singh594d0332020-07-02 11:14:05 +05302286 if (lim_peer_present_on_any_sta(mac_ctx, hdr->sa))
2287 /*
2288 * This mean a AP and STA have same mac address and device STA
2289 * is already connected to the AP, and STA is now trying to
2290 * connect to device SAP. So ignore association.
2291 */
2292 return;
2293
Krunal Soni99752a12016-04-12 17:44:45 -07002294 /*
2295 * If a STA is already present in DPH and it is initiating a Assoc
2296 * re-transmit, do not process it. This can happen when first Assoc Req
2297 * frame is received but ACK lost at STA side. The ACK for this dropped
2298 * Assoc Req frame should be sent by HW. Host simply does not process it
2299 * once the entry for the STA is already present in DPH.
2300 */
2301 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa, &assoc_id,
2302 &session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002303 if (sta_ds) {
Krunal Soni99752a12016-04-12 17:44:45 -07002304 if (hdr->fc.retry > 0) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302305 pe_err("STA is initiating Assoc Req after ACK lost. Do not process sessionid: %d sys sub_type=%d for role=%d from: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002306 QDF_MAC_ADDR_FMT, session->peSessionId,
Krunal Soni99752a12016-04-12 17:44:45 -07002307 sub_type, GET_LIM_SYSTEM_ROLE(session),
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002308 QDF_MAC_ADDR_REF(hdr->sa));
Abhishek Singha0b4dc12017-03-09 15:29:31 +05302309 return;
Krunal Soni17184262017-06-07 16:42:38 -07002310 } else if (!sta_ds->rmfEnabled && (sub_type == LIM_REASSOC)) {
2311 /*
2312 * SAP should send reassoc response with reject code
2313 * to avoid IOT issues. as per the specification SAP
2314 * should do 4-way handshake after reassoc response and
2315 * some STA doesn't like 4way handshake after reassoc
2316 * where some STA does expect 4-way handshake.
2317 */
bings85512332019-09-04 17:46:37 +08002318 lim_send_assoc_rsp_mgmt_frame(
2319 mac_ctx, eSIR_MAC_OUTSIDE_SCOPE_OF_SPEC_STATUS,
2320 sta_ds->assocId, sta_ds->staAddr,
2321 sub_type, sta_ds, session, false);
Krunal Soni17184262017-06-07 16:42:38 -07002322 pe_err("Rejecting reassoc req from STA");
2323 return;
Krunal Soni99752a12016-04-12 17:44:45 -07002324 } else if (!sta_ds->rmfEnabled) {
2325 /*
2326 * Do this only for non PMF case.
2327 * STA might have missed the assoc response, so it is
2328 * sending assoc request frame again.
2329 */
bings85512332019-09-04 17:46:37 +08002330 lim_send_assoc_rsp_mgmt_frame(
2331 mac_ctx, QDF_STATUS_SUCCESS,
2332 sta_ds->assocId, sta_ds->staAddr,
2333 sub_type,
2334 sta_ds, session, false);
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302335 pe_err("DUT already received an assoc request frame and STA is sending another assoc req.So, do not Process sessionid: %d sys sub_type: %d for role: %d from: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002336 QDF_MAC_ADDR_FMT,
Krunal Soni99752a12016-04-12 17:44:45 -07002337 session->peSessionId, sub_type,
2338 session->limSystemRole,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002339 QDF_MAC_ADDR_REF(hdr->sa));
Abhishek Singha0b4dc12017-03-09 15:29:31 +05302340 return;
Krunal Soni99752a12016-04-12 17:44:45 -07002341 }
Krunal Soni99752a12016-04-12 17:44:45 -07002342 }
2343
Jianmin Zhufc2cef12019-01-14 21:23:51 +08002344 status = lim_check_sta_in_pe_entries(mac_ctx, hdr, session->peSessionId,
2345 &dup_entry);
2346 if (QDF_IS_STATUS_ERROR(status)) {
2347 pe_err("Reject assoc as duplicate entry is present and is already being deleted, assoc will be accepted once deletion is completed");
2348 /*
2349 * This mean that the duplicate entry is present on other vdev
2350 * and is already being deleted, so reject the assoc and lets
2351 * peer try again to connect, once peer is deleted from
2352 * other vdev.
2353 */
2354 lim_send_assoc_rsp_mgmt_frame(
bings85512332019-09-04 17:46:37 +08002355 mac_ctx,
2356 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2357 1, hdr->sa,
2358 sub_type, 0, session, false);
Jianmin Zhufc2cef12019-01-14 21:23:51 +08002359 return;
2360 }
Krunal Soni99752a12016-04-12 17:44:45 -07002361
2362 /* Get pointer to Re/Association Request frame body */
2363 frm_body = WMA_GET_RX_MPDU_DATA(rx_pkt_info);
2364
Srinivas Girigowdab971ba22019-03-04 15:56:28 -08002365 if (IEEE80211_IS_MULTICAST(hdr->sa)) {
Krunal Soni99752a12016-04-12 17:44:45 -07002366 /*
2367 * Rcvd Re/Assoc Req frame from BC/MC address Log error and
2368 * ignore it
2369 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302370 pe_err("Rcvd: %s Req, sessionid: %d from a BC/MC address"
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002371 QDF_MAC_ADDR_FMT,
Krunal Soni99752a12016-04-12 17:44:45 -07002372 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002373 session->peSessionId, QDF_MAC_ADDR_REF(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -07002374 return;
2375 }
2376
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002377 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
2378 (uint8_t *) frm_body, frame_len);
Krunal Soni99752a12016-04-12 17:44:45 -07002379
2380 if (false == lim_chk_sa_da(mac_ctx, hdr, session, sub_type))
2381 return;
2382
2383 if (false == lim_chk_tkip(mac_ctx, hdr, session, sub_type))
2384 return;
2385
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05302386 /* check for the presence of vendor IE */
2387 if ((session->access_policy_vendor_ie) &&
2388 (session->access_policy ==
2389 LIM_ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT)) {
Abhinav Kumardb3c6f52018-06-20 15:02:00 +05302390 if (frame_len <= LIM_ASSOC_REQ_IE_OFFSET) {
2391 pe_debug("Received action frame of invalid len %d",
2392 frame_len);
2393 return;
2394 }
Naveen Rawat08db88f2017-09-08 15:07:48 -07002395 if (!wlan_get_vendor_ie_ptr_from_oui(
2396 &session->access_policy_vendor_ie[2],
2397 3, frm_body + LIM_ASSOC_REQ_IE_OFFSET,
Yeshwanth Sriram Guntuka9dea24e2018-06-14 18:44:41 +05302398 frame_len - LIM_ASSOC_REQ_IE_OFFSET)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302399 pe_err("Vendor ie not present and access policy is %x, Rejected association",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05302400 session->access_policy);
bings85512332019-09-04 17:46:37 +08002401 lim_send_assoc_rsp_mgmt_frame(
2402 mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2403 1, hdr->sa, sub_type, 0, session, false);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05302404 return;
2405 }
2406 }
Krunal Soni99752a12016-04-12 17:44:45 -07002407 /* Allocate memory for the Assoc Request frame */
2408 assoc_req = qdf_mem_malloc(sizeof(*assoc_req));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002409 if (!assoc_req)
Krunal Soni99752a12016-04-12 17:44:45 -07002410 return;
Krunal Soni99752a12016-04-12 17:44:45 -07002411
2412 /* Parse Assoc Request frame */
2413 if (false == lim_chk_assoc_req_parse_error(mac_ctx, hdr, session,
2414 assoc_req, sub_type, frm_body, frame_len))
2415 goto error;
2416
2417 assoc_req->assocReqFrame = qdf_mem_malloc(frame_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002418 if (!assoc_req->assocReqFrame)
Krunal Soni99752a12016-04-12 17:44:45 -07002419 goto error;
Krunal Soni99752a12016-04-12 17:44:45 -07002420
2421 qdf_mem_copy((uint8_t *) assoc_req->assocReqFrame,
2422 (uint8_t *) frm_body, frame_len);
2423 assoc_req->assocReqFrameLength = frame_len;
2424
2425 if (false == lim_chk_capab(mac_ctx, hdr, session, assoc_req,
2426 sub_type, &local_cap))
2427 goto error;
2428
Krunal Soni99752a12016-04-12 17:44:45 -07002429 if (false == lim_chk_ssid(mac_ctx, hdr, session, assoc_req, sub_type))
2430 goto error;
2431
2432 if (false == lim_chk_rates(mac_ctx, hdr, session, assoc_req, sub_type))
2433 goto error;
2434
2435 if (false == lim_chk_11g_only(mac_ctx, hdr, session, assoc_req,
2436 sub_type))
2437 goto error;
2438
2439 if (false == lim_chk_11n_only(mac_ctx, hdr, session, assoc_req,
2440 sub_type))
2441 goto error;
2442
2443 if (false == lim_chk_11ac_only(mac_ctx, hdr, session, assoc_req,
2444 sub_type))
2445 goto error;
2446
Naveen Rawat441bc872017-12-11 17:25:27 -08002447 if (false == lim_chk_11ax_only(mac_ctx, hdr, session, assoc_req,
2448 sub_type))
2449 goto error;
2450
2451 if (false == lim_check_11ax_basic_mcs(mac_ctx, hdr, session, assoc_req,
2452 sub_type))
2453 goto error;
2454
Krunal Soni99752a12016-04-12 17:44:45 -07002455 /* Spectrum Management (11h) specific checks */
2456 lim_process_for_spectrum_mgmt(mac_ctx, hdr, session,
2457 assoc_req, sub_type, local_cap);
2458
2459 if (false == lim_chk_mcs(mac_ctx, hdr, session, assoc_req, sub_type))
2460 goto error;
2461
2462 if (false == lim_chk_is_11b_sta_supported(mac_ctx, hdr, session,
2463 assoc_req, sub_type, phy_mode))
2464 goto error;
2465
2466 /*
2467 * Check for 802.11n HT caps compatibility; are HT Capabilities
2468 * turned on in lim?
2469 */
2470 lim_print_ht_cap(mac_ctx, session, assoc_req);
2471
2472 if (false == lim_chk_n_process_wpa_rsn_ie(mac_ctx, hdr, session,
Min Liuddd23302018-12-05 16:17:48 +08002473 assoc_req, sub_type,
2474 &pmf_connection,
2475 &akm_type))
Krunal Soni99752a12016-04-12 17:44:45 -07002476 goto error;
2477
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302478 /* Extract pre-auth context for the STA, if any. */
2479 sta_pre_auth_ctx = lim_search_pre_auth_list(mac_ctx, hdr->sa);
2480
2481 /* SAE authentication is offloaded to hostapd. Hostapd sends
2482 * authentication status to driver after completing SAE
2483 * authentication (after sending out 4/4 SAE auth frame).
2484 * There is a possible race condition where driver gets
2485 * assoc request from SAE station before getting authentication
2486 * status from hostapd. Don't reject the association in such
2487 * cases and defer the processing of assoc request frame by caching
2488 * the frame and process it when the auth status is received.
2489 */
2490 if (sta_pre_auth_ctx &&
2491 sta_pre_auth_ctx->authType == eSIR_AUTH_TYPE_SAE &&
2492 sta_pre_auth_ctx->mlmState == eLIM_MLM_WT_SAE_AUTH_STATE) {
2493 pe_debug("Received assoc request frame while SAE authentication is in progress; Defer association request handling till SAE auth status is received");
2494 lim_defer_sme_indication(mac_ctx, session, sub_type, hdr,
2495 assoc_req, pmf_connection,
2496 assoc_req_copied, dup_entry, sta_ds);
2497 return;
2498 }
2499
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05302500 if (session->opmode == QDF_P2P_GO_MODE) {
2501 /*
2502 * WAR: In P2P GO mode, if the P2P client device
2503 * is only HT capable and not VHT capable, but the P2P
2504 * GO device is VHT capable and advertises 2x2 NSS with
2505 * HT capablity client device, which results in IOT
2506 * issues.
2507 * When GO is operating in DBS mode, GO beacons
2508 * advertise 2x2 capability but include OMN IE to
2509 * indicate current operating mode of 1x1. But here
2510 * peer device is only HT capable and will not
2511 * understand OMN IE.
2512 */
2513 force_1x1 = wlan_p2p_check_oui_and_force_1x1(
2514 frm_body + LIM_ASSOC_REQ_IE_OFFSET,
2515 frame_len - LIM_ASSOC_REQ_IE_OFFSET);
2516 }
2517
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302518 /* Send assoc indication to SME */
2519 if (!lim_send_assoc_ind_to_sme(mac_ctx, session, sub_type, hdr,
Min Liuddd23302018-12-05 16:17:48 +08002520 assoc_req, akm_type, pmf_connection,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05302521 &assoc_req_copied, dup_entry, force_1x1))
Krunal Soni99752a12016-04-12 17:44:45 -07002522 goto error;
2523
Krunal Soni99752a12016-04-12 17:44:45 -07002524 return;
2525
2526error:
Krunal Soni99752a12016-04-12 17:44:45 -07002527 lim_process_assoc_cleanup(mac_ctx, session, assoc_req, sta_ds,
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302528 assoc_req_copied);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529 return;
Naveen Rawatada5fac2016-01-28 16:24:32 -08002530}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531
2532#ifdef FEATURE_WLAN_WAPI
2533/**
2534 * lim_fill_assoc_ind_wapi_info()- Updates WAPI data in assoc indication
2535 * @mac_ctx: Global Mac context
2536 * @assoc_req: pointer to association request
2537 * @assoc_ind: Pointer to association indication
2538 * @wpsie: WPS IE
2539 *
2540 * This function updates WAPI meta data in association indication message
2541 * sent to SME.
2542 *
2543 * Return: None
2544 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002545static void lim_fill_assoc_ind_wapi_info(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546 tpSirAssocReq assoc_req, tpLimMlmAssocInd assoc_ind,
Naveen Rawat08db88f2017-09-08 15:07:48 -07002547 const uint8_t *wpsie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548{
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002549 if (assoc_req->wapiPresent && (!wpsie)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302550 pe_debug("Received WAPI IE length in Assoc Req is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551 assoc_req->wapi.length);
Srinivas Girigowda61771262019-04-01 11:55:19 -07002552 assoc_ind->wapiIE.wapiIEdata[0] = WLAN_ELEMID_WAPI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553 assoc_ind->wapiIE.wapiIEdata[1] = assoc_req->wapi.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302554 qdf_mem_copy(&assoc_ind->wapiIE.wapiIEdata[2],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 assoc_req->wapi.info, assoc_req->wapi.length);
2556 assoc_ind->wapiIE.length =
2557 2 + assoc_req->wapi.length;
2558 }
2559 return;
2560}
bings85512332019-09-04 17:46:37 +08002561#else
2562static void lim_fill_assoc_ind_wapi_info(
2563 struct mac_context *mac_ctx,
2564 tpSirAssocReq assoc_req, tpLimMlmAssocInd assoc_ind,
2565 const uint8_t *wpsie)
2566{
2567}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568#endif
2569
2570/**
2571 * lim_fill_assoc_ind_vht_info() - Updates VHT information in assoc indication
2572 * @mac_ctx: Global Mac context
2573 * @assoc_req: pointer to association request
2574 * @session_entry: PE session entry
2575 * @assoc_ind: Pointer to association indication
2576 *
2577 * This function updates VHT information in association indication message
2578 * sent to SME.
2579 *
2580 * Return: None
2581 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002582static void lim_fill_assoc_ind_vht_info(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08002583 struct pe_session *session_entry,
Naveen Rawat6186ff92015-10-12 14:33:53 -07002584 tpSirAssocReq assoc_req,
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302585 tpLimMlmAssocInd assoc_ind,
2586 tpDphHashNode sta_ds)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587{
2588 uint8_t chan;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302589 uint8_t i;
2590 bool nw_type_11b = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591
Amruta Kulkarni453c4e22019-11-20 10:59:21 -08002592 if (session_entry->limRFBand == REG_BAND_2G) {
Naveen Rawat6186ff92015-10-12 14:33:53 -07002593 if (session_entry->vhtCapability && assoc_req->VHTCaps.present)
Krishna Kumaar Natarajan294da812016-04-28 14:39:30 -07002594 assoc_ind->chan_info.info = MODE_11AC_VHT20_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 else if (session_entry->htCapability
Naveen Rawat6186ff92015-10-12 14:33:53 -07002596 && assoc_req->HTCaps.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 assoc_ind->chan_info.info = MODE_11NG_HT20;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302598 else {
2599 for (i = 0; i < SIR_NUM_11A_RATES; i++) {
2600 if (sirIsArate(sta_ds->
2601 supportedRates.llaRates[i]
2602 & 0x7F)) {
2603 assoc_ind->chan_info.info = MODE_11G;
2604 nw_type_11b = false;
2605 break;
2606 }
2607 }
2608 if (nw_type_11b)
2609 assoc_ind->chan_info.info = MODE_11B;
2610 }
Naveen Rawat6186ff92015-10-12 14:33:53 -07002611 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 }
Naveen Rawat6186ff92015-10-12 14:33:53 -07002613
2614 if (session_entry->vhtCapability && assoc_req->VHTCaps.present) {
2615 if ((session_entry->ch_width > CH_WIDTH_40MHZ)
2616 && assoc_req->HTCaps.supportedChannelWidthSet) {
2617 chan = session_entry->ch_center_freq_seg0;
2618 assoc_ind->chan_info.band_center_freq1 =
2619 cds_chan_to_freq(chan);
2620 assoc_ind->chan_info.info = MODE_11AC_VHT80;
2621 return;
2622 }
2623
2624 if ((session_entry->ch_width == CH_WIDTH_40MHZ)
2625 && assoc_req->HTCaps.supportedChannelWidthSet) {
2626 assoc_ind->chan_info.info = MODE_11AC_VHT40;
2627 if (session_entry->htSecondaryChannelOffset ==
2628 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
2629 assoc_ind->chan_info.band_center_freq1 += 10;
2630 else
2631 assoc_ind->chan_info.band_center_freq1 -= 10;
2632 return;
2633 }
2634
2635 assoc_ind->chan_info.info = MODE_11AC_VHT20;
2636 return;
2637 }
2638
2639 if (session_entry->htCapability && assoc_req->HTCaps.present) {
2640 if ((session_entry->ch_width == CH_WIDTH_40MHZ)
2641 && assoc_req->HTCaps.supportedChannelWidthSet) {
2642 assoc_ind->chan_info.info = MODE_11NA_HT40;
2643 if (session_entry->htSecondaryChannelOffset ==
2644 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
2645 assoc_ind->chan_info.band_center_freq1 += 10;
2646 else
2647 assoc_ind->chan_info.band_center_freq1 -= 10;
2648 return;
2649 }
2650
2651 assoc_ind->chan_info.info = MODE_11NA_HT20;
2652 return;
2653 }
2654
2655 assoc_ind->chan_info.info = MODE_11A;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 return;
2657}
2658
Will Huang558f8082017-05-31 16:22:24 +08002659static uint8_t lim_get_max_rate_idx(tSirMacRateSet *rateset)
2660{
2661 uint8_t maxidx;
2662 int i;
2663
2664 maxidx = rateset->rate[0] & 0x7f;
2665 for (i = 1; i < rateset->numRates; i++) {
2666 if ((rateset->rate[i] & 0x7f) > maxidx)
2667 maxidx = rateset->rate[i] & 0x7f;
2668 }
2669
2670 return maxidx;
2671}
2672
2673static void fill_mlm_assoc_ind_vht(tpSirAssocReq assocreq,
2674 tpDphHashNode stads,
2675 tpLimMlmAssocInd assocind)
2676{
2677 if (stads->mlmStaContext.vhtCapability) {
2678 /* ampdu */
2679 assocind->ampdu = true;
2680
2681 /* sgi */
2682 if (assocreq->VHTCaps.shortGI80MHz ||
2683 assocreq->VHTCaps.shortGI160and80plus80MHz)
2684 assocind->sgi_enable = true;
2685
2686 /* stbc */
2687 assocind->tx_stbc = assocreq->VHTCaps.txSTBC;
2688 assocind->rx_stbc = assocreq->VHTCaps.rxSTBC;
2689
2690 /* ch width */
2691 assocind->ch_width = stads->vhtSupportedChannelWidthSet ?
2692 eHT_CHANNEL_WIDTH_80MHZ :
2693 stads->htSupportedChannelWidthSet ?
2694 eHT_CHANNEL_WIDTH_40MHZ : eHT_CHANNEL_WIDTH_20MHZ;
2695
2696 /* mode */
2697 assocind->mode = SIR_SME_PHY_MODE_VHT;
2698 assocind->rx_mcs_map = assocreq->VHTCaps.rxMCSMap & 0xff;
2699 assocind->tx_mcs_map = assocreq->VHTCaps.txMCSMap & 0xff;
2700 }
2701}
2702
Gururaj Pandurangib518d6d2020-04-08 17:17:06 -07002703/**
2704 *lim_convert_channel_width_enum() - map between two channel width enums
2705 *@ch_width: channel width of enum type phy_ch_width
2706 *
2707 *Return: channel width of enum type tSirMacHTChannelWidth
2708 */
2709static tSirMacHTChannelWidth
2710lim_convert_channel_width_enum(enum phy_ch_width ch_width)
2711{
2712 switch (ch_width) {
2713 case CH_WIDTH_20MHZ:
2714 return eHT_CHANNEL_WIDTH_20MHZ;
2715 case CH_WIDTH_40MHZ:
2716 return eHT_CHANNEL_WIDTH_40MHZ;
2717 case CH_WIDTH_80MHZ:
2718 return eHT_CHANNEL_WIDTH_80MHZ;
2719 case CH_WIDTH_160MHZ:
2720 return eHT_CHANNEL_WIDTH_160MHZ;
2721 case CH_WIDTH_80P80MHZ:
2722 return eHT_CHANNEL_WIDTH_80P80MHZ;
2723 case CH_WIDTH_MAX:
2724 return eHT_MAX_CHANNEL_WIDTH;
2725 case CH_WIDTH_5MHZ:
2726 break;
2727 case CH_WIDTH_10MHZ:
2728 break;
2729 case CH_WIDTH_INVALID:
2730 break;
2731 }
2732 pe_debug("invalid enum: %d", ch_width);
2733 return eHT_CHANNEL_WIDTH_20MHZ;
2734}
2735
bings85512332019-09-04 17:46:37 +08002736bool lim_fill_lim_assoc_ind_params(
2737 tpLimMlmAssocInd assoc_ind,
2738 struct mac_context *mac_ctx,
2739 tpDphHashNode sta_ds,
2740 struct pe_session *session_entry)
2741{
2742 tpSirAssocReq assoc_req;
2743 uint16_t rsn_len;
2744 uint32_t phy_mode;
2745 const uint8_t *wpsie = NULL;
2746 uint8_t maxidx, i;
2747 bool wme_enable;
2748
2749 if (!session_entry->parsedAssocReq) {
2750 pe_err(" Parsed Assoc req is NULL");
2751 return false;
2752 }
2753
2754 /* Get a copy of the already parsed Assoc Request */
2755 assoc_req =
2756 (tpSirAssocReq)session_entry->parsedAssocReq[sta_ds->assocId];
2757
2758 if (!assoc_req) {
2759 pe_err("assoc req for assoc_id:%d is NULL", sta_ds->assocId);
2760 return false;
2761 }
2762
2763 /* Get the phy_mode */
2764 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
2765
2766 qdf_mem_copy((uint8_t *)assoc_ind->peerMacAddr,
2767 (uint8_t *)sta_ds->staAddr, sizeof(tSirMacAddr));
2768 assoc_ind->aid = sta_ds->assocId;
2769 qdf_mem_copy((uint8_t *)&assoc_ind->ssId,
2770 (uint8_t *)&assoc_req->ssId,
2771 assoc_req->ssId.length + 1);
2772 assoc_ind->sessionId = session_entry->peSessionId;
2773 assoc_ind->authType = sta_ds->mlmStaContext.authType;
2774 assoc_ind->akm_type = sta_ds->mlmStaContext.akm_type;
2775 assoc_ind->capabilityInfo = assoc_req->capabilityInfo;
2776
2777 /* Fill in RSN IE information */
2778 assoc_ind->rsnIE.length = 0;
2779 /* if WPS IE is present, ignore RSN IE */
2780 if (assoc_req->addIEPresent && assoc_req->addIE.length) {
2781 wpsie = limGetWscIEPtr(
2782 mac_ctx,
2783 assoc_req->addIE.addIEdata,
2784 assoc_req->addIE.length);
2785 }
2786 if (assoc_req->rsnPresent && !wpsie) {
2787 pe_debug("Assoc Req RSN IE len: %d",
2788 assoc_req->rsn.length);
2789 assoc_ind->rsnIE.length = 2 + assoc_req->rsn.length;
2790 assoc_ind->rsnIE.rsnIEdata[0] = WLAN_ELEMID_RSN;
2791 assoc_ind->rsnIE.rsnIEdata[1] =
2792 assoc_req->rsn.length;
2793 qdf_mem_copy(
2794 &assoc_ind->rsnIE.rsnIEdata[2],
2795 assoc_req->rsn.info,
2796 assoc_req->rsn.length);
2797 }
2798 /* Fill in 802.11h related info */
2799 if (assoc_req->powerCapabilityPresent &&
2800 assoc_req->supportedChannelsPresent) {
2801 assoc_ind->spectrumMgtIndicator = true;
2802 assoc_ind->powerCap.minTxPower =
2803 assoc_req->powerCapability.minTxPower;
2804 assoc_ind->powerCap.maxTxPower =
2805 assoc_req->powerCapability.maxTxPower;
2806 lim_convert_supported_channels(
2807 mac_ctx, assoc_ind,
2808 assoc_req);
2809 } else {
2810 assoc_ind->spectrumMgtIndicator = false;
2811 }
2812
2813 /* This check is to avoid extra Sec IEs present incase of WPS */
2814 if (assoc_req->wpaPresent && !wpsie) {
2815 rsn_len = assoc_ind->rsnIE.length;
2816 if ((rsn_len + assoc_req->wpa.length)
2817 >= WLAN_MAX_IE_LEN) {
2818 pe_err("rsnIEdata index out of bounds: %d",
2819 rsn_len);
2820 return false;
2821 }
2822 assoc_ind->rsnIE.rsnIEdata[rsn_len] =
2823 SIR_MAC_WPA_EID;
2824 assoc_ind->rsnIE.rsnIEdata[rsn_len + 1]
2825 = assoc_req->wpa.length;
2826 qdf_mem_copy(
2827 &assoc_ind->rsnIE.rsnIEdata[rsn_len + 2],
2828 assoc_req->wpa.info, assoc_req->wpa.length);
2829 assoc_ind->rsnIE.length += 2 + assoc_req->wpa.length;
2830 }
2831 lim_fill_assoc_ind_wapi_info(mac_ctx, assoc_req, assoc_ind, wpsie);
2832
2833 assoc_ind->addIE.length = 0;
2834 if (assoc_req->addIEPresent) {
2835 qdf_mem_copy(
2836 &assoc_ind->addIE.addIEdata,
2837 assoc_req->addIE.addIEdata,
2838 assoc_req->addIE.length);
2839 assoc_ind->addIE.length = assoc_req->addIE.length;
2840 }
2841 /*
2842 * Add HT Capabilities into addIE for OBSS
2843 * processing in hostapd
2844 */
2845 if (assoc_req->HTCaps.present) {
2846 qdf_mem_copy(&assoc_ind->ht_caps, &assoc_req->HTCaps,
2847 sizeof(tDot11fIEHTCaps));
2848 rsn_len = assoc_ind->addIE.length;
2849 if (assoc_ind->addIE.length + DOT11F_IE_HTCAPS_MIN_LEN
2850 + 2 < WLAN_MAX_IE_LEN) {
2851 assoc_ind->addIE.addIEdata[rsn_len] =
2852 WLAN_ELEMID_HTCAP_ANA;
2853 assoc_ind->addIE.addIEdata[rsn_len + 1] =
2854 DOT11F_IE_HTCAPS_MIN_LEN;
2855 qdf_mem_copy(
2856 &assoc_ind->addIE.addIEdata[rsn_len + 2],
2857 ((uint8_t *)&assoc_req->HTCaps) + 1,
2858 DOT11F_IE_HTCAPS_MIN_LEN);
2859 assoc_ind->addIE.length +=
2860 2 + DOT11F_IE_HTCAPS_MIN_LEN;
2861 } else {
2862 pe_err("Fail:HT capabilities IE to addIE");
2863 }
2864 }
2865
2866 if (assoc_req->wmeInfoPresent) {
2867 /* Set whether AP is enabled with WMM or not */
2868 wme_enable = mac_ctx->mlme_cfg->wmm_params.wme_enabled;
2869 assoc_ind->WmmStaInfoPresent = wme_enable;
2870 /*
2871 * Note: we are not rejecting association here
2872 * because IOT will fail
2873 */
2874 }
2875 /* Required for indicating the frames to upper layer */
2876 assoc_ind->assocReqLength = assoc_req->assocReqFrameLength;
2877 assoc_ind->assocReqPtr = assoc_req->assocReqFrame;
2878 assoc_ind->beaconPtr = session_entry->beacon;
2879 assoc_ind->beaconLength = session_entry->bcnLen;
2880
2881 assoc_ind->chan_info.mhz = session_entry->curr_op_freq;
2882 assoc_ind->chan_info.band_center_freq1 =
2883 session_entry->curr_op_freq;
2884 assoc_ind->chan_info.band_center_freq2 = 0;
2885 assoc_ind->chan_info.reg_info_1 =
2886 (session_entry->maxTxPower << 16);
2887 assoc_ind->chan_info.reg_info_2 =
2888 (session_entry->maxTxPower << 8);
2889 assoc_ind->chan_info.nss = sta_ds->nss;
2890 assoc_ind->chan_info.rate_flags =
2891 lim_get_max_rate_flags(mac_ctx, sta_ds);
2892 assoc_ind->ampdu = false;
2893 assoc_ind->sgi_enable = false;
2894 assoc_ind->tx_stbc = false;
2895 assoc_ind->rx_stbc = false;
2896 assoc_ind->ch_width = eHT_CHANNEL_WIDTH_20MHZ;
2897 assoc_ind->mode = SIR_SME_PHY_MODE_LEGACY;
2898 assoc_ind->max_supp_idx = 0xff;
2899 assoc_ind->max_ext_idx = 0xff;
2900 assoc_ind->max_mcs_idx = 0xff;
2901 assoc_ind->rx_mcs_map = 0xff;
2902 assoc_ind->tx_mcs_map = 0xff;
2903
2904 if (assoc_req->supportedRates.numRates)
2905 assoc_ind->max_supp_idx =
2906 lim_get_max_rate_idx(&assoc_req->supportedRates);
2907 if (assoc_req->extendedRates.numRates)
2908 assoc_ind->max_ext_idx =
2909 lim_get_max_rate_idx(&assoc_req->extendedRates);
2910
2911 if (sta_ds->mlmStaContext.htCapability) {
2912 /* ampdu */
2913 assoc_ind->ampdu = true;
2914
2915 /* sgi */
2916 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
2917 assoc_ind->sgi_enable = true;
2918
2919 /* stbc */
2920 assoc_ind->tx_stbc = assoc_req->HTCaps.txSTBC;
2921 assoc_ind->rx_stbc = assoc_req->HTCaps.rxSTBC;
2922
2923 /* ch width */
2924 assoc_ind->ch_width =
2925 sta_ds->htSupportedChannelWidthSet ?
2926 eHT_CHANNEL_WIDTH_40MHZ :
2927 eHT_CHANNEL_WIDTH_20MHZ;
2928 /* mode */
2929 assoc_ind->mode = SIR_SME_PHY_MODE_HT;
2930 maxidx = 0;
2931 for (i = 0; i < 8; i++) {
2932 if (assoc_req->HTCaps.supportedMCSSet[0] &
2933 (1 << i))
2934 maxidx = i;
2935 }
2936 assoc_ind->max_mcs_idx = maxidx;
2937 }
2938 fill_mlm_assoc_ind_vht(assoc_req, sta_ds, assoc_ind);
2939 if (assoc_req->ExtCap.present)
2940 assoc_ind->ecsa_capable =
2941 ((struct s_ext_cap *)assoc_req->ExtCap.bytes)->ext_chan_switch;
2942 /* updates VHT information in assoc indication */
Ashish Kumar Dhanotiya50a104b2020-03-05 21:25:09 +05302943 if (assoc_req->VHTCaps.present)
2944 qdf_mem_copy(&assoc_ind->vht_caps, &assoc_req->VHTCaps,
2945 sizeof(tDot11fIEVHTCaps));
2946 else if (assoc_req->vendor_vht_ie.VHTCaps.present)
2947 qdf_mem_copy(&assoc_ind->vht_caps,
2948 &assoc_req->vendor_vht_ie.VHTCaps,
2949 sizeof(tDot11fIEVHTCaps));
2950
bings85512332019-09-04 17:46:37 +08002951 lim_fill_assoc_ind_vht_info(mac_ctx, session_entry, assoc_req,
2952 assoc_ind, sta_ds);
2953 assoc_ind->he_caps_present = assoc_req->he_cap.present;
2954 assoc_ind->is_sae_authenticated =
2955 assoc_req->is_sae_authenticated;
Gururaj Pandurangib518d6d2020-04-08 17:17:06 -07002956 /* updates HE bandwidth in assoc indication */
2957 if (wlan_reg_is_6ghz_chan_freq(session_entry->curr_op_freq))
2958 assoc_ind->ch_width =
2959 lim_convert_channel_width_enum(sta_ds->ch_width);
bings85512332019-09-04 17:46:37 +08002960 return true;
2961}
2962
Gu xiaocong6dbe3ba2021-07-06 13:20:58 +08002963void lim_send_mlm_assoc_ind(struct mac_context *mac_ctx,
Srinivas Dasari6e9b8132020-12-16 16:57:12 +05302964 tpDphHashNode sta_ds,
2965 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966{
bings85512332019-09-04 17:46:37 +08002967 tpLimMlmAssocInd assoc_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 tpSirAssocReq assoc_req;
bings85512332019-09-04 17:46:37 +08002969 uint16_t temp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 uint32_t phy_mode;
2971 uint8_t sub_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972
Pragaspathi Thilagarajaba1b5d2018-11-13 14:29:44 +05302973 if (!session_entry->parsedAssocReq) {
2974 pe_err(" Parsed Assoc req is NULL");
Gu xiaocong6dbe3ba2021-07-06 13:20:58 +08002975 return;
Pragaspathi Thilagarajaba1b5d2018-11-13 14:29:44 +05302976 }
2977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978 /* Get a copy of the already parsed Assoc Request */
2979 assoc_req =
2980 (tpSirAssocReq) session_entry->parsedAssocReq[sta_ds->assocId];
2981
Pragaspathi Thilagarajaba1b5d2018-11-13 14:29:44 +05302982 if (!assoc_req) {
2983 pe_err("assoc req for assoc_id:%d is NULL", sta_ds->assocId);
Gu xiaocong6dbe3ba2021-07-06 13:20:58 +08002984 return;
Pragaspathi Thilagarajaba1b5d2018-11-13 14:29:44 +05302985 }
2986
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987 /* Get the phy_mode */
2988 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
2989
2990 /* Determine if its Assoc or ReAssoc Request */
2991 if (assoc_req->reassocRequest == 1)
2992 sub_type = LIM_REASSOC;
2993 else
2994 sub_type = LIM_ASSOC;
2995
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302996 pe_debug("Sessionid: %d ssid: %s sub_type: %d Associd: %d staAddr: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002997 QDF_MAC_ADDR_FMT, session_entry->peSessionId,
bings85512332019-09-04 17:46:37 +08002998 assoc_req->ssId.ssId, sub_type, sta_ds->assocId,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002999 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000
3001 if (sub_type == LIM_ASSOC || sub_type == LIM_REASSOC) {
3002 temp = sizeof(tLimMlmAssocInd);
3003
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303004 assoc_ind = qdf_mem_malloc(temp);
Arif Hussainf5b6c412018-10-10 19:41:09 -07003005 if (!assoc_ind) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006 lim_release_peer_idx(mac_ctx, sta_ds->assocId,
bings85512332019-09-04 17:46:37 +08003007 session_entry);
Gu xiaocong6dbe3ba2021-07-06 13:20:58 +08003008 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003009 }
bings85512332019-09-04 17:46:37 +08003010 if (!lim_fill_lim_assoc_ind_params(assoc_ind, mac_ctx,
3011 sta_ds, session_entry)) {
3012 qdf_mem_free(assoc_ind);
Gu xiaocong6dbe3ba2021-07-06 13:20:58 +08003013 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_IND,
bings85512332019-09-04 17:46:37 +08003016 (uint32_t *)assoc_ind);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303017 qdf_mem_free(assoc_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 }
bings85512332019-09-04 17:46:37 +08003019
Gu xiaocong6dbe3ba2021-07-06 13:20:58 +08003020 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021}