18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * NXP Wireless LAN device driver: 802.11ac
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright 2011-2020 NXP
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This software file (the "File") is distributed by NXP
78c2ecf20Sopenharmony_ci * under the terms of the GNU General Public License Version 2, June 1991
88c2ecf20Sopenharmony_ci * (the "License").  You may use, redistribute and/or modify this File in
98c2ecf20Sopenharmony_ci * accordance with the terms and conditions of the License, a copy of which
108c2ecf20Sopenharmony_ci * is available by writing to the Free Software Foundation, Inc.,
118c2ecf20Sopenharmony_ci * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
128c2ecf20Sopenharmony_ci * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
158c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
168c2ecf20Sopenharmony_ci * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
178c2ecf20Sopenharmony_ci * this warranty disclaimer.
188c2ecf20Sopenharmony_ci */
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#include "decl.h"
218c2ecf20Sopenharmony_ci#include "ioctl.h"
228c2ecf20Sopenharmony_ci#include "fw.h"
238c2ecf20Sopenharmony_ci#include "main.h"
248c2ecf20Sopenharmony_ci#include "11ac.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* Tables of the MCS map to the highest data rate (in Mbps) supported
278c2ecf20Sopenharmony_ci * for long GI.
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_cistatic const u16 max_rate_lgi_80MHZ[8][3] = {
308c2ecf20Sopenharmony_ci	{0x124, 0x15F, 0x186},	/* NSS = 1 */
318c2ecf20Sopenharmony_ci	{0x249, 0x2BE, 0x30C},  /* NSS = 2 */
328c2ecf20Sopenharmony_ci	{0x36D, 0x41D, 0x492},  /* NSS = 3 */
338c2ecf20Sopenharmony_ci	{0x492, 0x57C, 0x618},  /* NSS = 4 */
348c2ecf20Sopenharmony_ci	{0x5B6, 0x6DB, 0x79E},  /* NSS = 5 */
358c2ecf20Sopenharmony_ci	{0x6DB, 0x83A, 0x0},    /* NSS = 6 */
368c2ecf20Sopenharmony_ci	{0x7FF, 0x999, 0xAAA},  /* NSS = 7 */
378c2ecf20Sopenharmony_ci	{0x924, 0xAF8, 0xC30}   /* NSS = 8 */
388c2ecf20Sopenharmony_ci};
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistatic const u16 max_rate_lgi_160MHZ[8][3] = {
418c2ecf20Sopenharmony_ci	{0x249, 0x2BE, 0x30C},   /* NSS = 1 */
428c2ecf20Sopenharmony_ci	{0x492, 0x57C, 0x618},   /* NSS = 2 */
438c2ecf20Sopenharmony_ci	{0x6DB, 0x83A, 0x0},     /* NSS = 3 */
448c2ecf20Sopenharmony_ci	{0x924, 0xAF8, 0xC30},   /* NSS = 4 */
458c2ecf20Sopenharmony_ci	{0xB6D, 0xDB6, 0xF3C},   /* NSS = 5 */
468c2ecf20Sopenharmony_ci	{0xDB6, 0x1074, 0x1248}, /* NSS = 6 */
478c2ecf20Sopenharmony_ci	{0xFFF, 0x1332, 0x1554}, /* NSS = 7 */
488c2ecf20Sopenharmony_ci	{0x1248, 0x15F0, 0x1860} /* NSS = 8 */
498c2ecf20Sopenharmony_ci};
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/* This function converts the 2-bit MCS map to the highest long GI
528c2ecf20Sopenharmony_ci * VHT data rate.
538c2ecf20Sopenharmony_ci */
548c2ecf20Sopenharmony_cistatic u16
558c2ecf20Sopenharmony_cimwifiex_convert_mcsmap_to_maxrate(struct mwifiex_private *priv,
568c2ecf20Sopenharmony_ci				  u8 bands, u16 mcs_map)
578c2ecf20Sopenharmony_ci{
588c2ecf20Sopenharmony_ci	u8 i, nss, mcs;
598c2ecf20Sopenharmony_ci	u16 max_rate = 0;
608c2ecf20Sopenharmony_ci	u32 usr_vht_cap_info = 0;
618c2ecf20Sopenharmony_ci	struct mwifiex_adapter *adapter = priv->adapter;
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	if (bands & BAND_AAC)
648c2ecf20Sopenharmony_ci		usr_vht_cap_info = adapter->usr_dot_11ac_dev_cap_a;
658c2ecf20Sopenharmony_ci	else
668c2ecf20Sopenharmony_ci		usr_vht_cap_info = adapter->usr_dot_11ac_dev_cap_bg;
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	/* find the max NSS supported */
698c2ecf20Sopenharmony_ci	nss = 1;
708c2ecf20Sopenharmony_ci	for (i = 1; i <= 8; i++) {
718c2ecf20Sopenharmony_ci		mcs = GET_VHTNSSMCS(mcs_map, i);
728c2ecf20Sopenharmony_ci		if (mcs < IEEE80211_VHT_MCS_NOT_SUPPORTED)
738c2ecf20Sopenharmony_ci			nss = i;
748c2ecf20Sopenharmony_ci	}
758c2ecf20Sopenharmony_ci	mcs = GET_VHTNSSMCS(mcs_map, nss);
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	/* if mcs is 3, nss must be 1 (NSS = 1). Default mcs to MCS 0~9 */
788c2ecf20Sopenharmony_ci	if (mcs == IEEE80211_VHT_MCS_NOT_SUPPORTED)
798c2ecf20Sopenharmony_ci		mcs = IEEE80211_VHT_MCS_SUPPORT_0_9;
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	if (GET_VHTCAP_CHWDSET(usr_vht_cap_info)) {
828c2ecf20Sopenharmony_ci		/* support 160 MHz */
838c2ecf20Sopenharmony_ci		max_rate = max_rate_lgi_160MHZ[nss - 1][mcs];
848c2ecf20Sopenharmony_ci		if (!max_rate)
858c2ecf20Sopenharmony_ci			/* MCS9 is not supported in NSS6 */
868c2ecf20Sopenharmony_ci			max_rate = max_rate_lgi_160MHZ[nss - 1][mcs - 1];
878c2ecf20Sopenharmony_ci	} else {
888c2ecf20Sopenharmony_ci		max_rate = max_rate_lgi_80MHZ[nss - 1][mcs];
898c2ecf20Sopenharmony_ci		if (!max_rate)
908c2ecf20Sopenharmony_ci			/* MCS9 is not supported in NSS3 */
918c2ecf20Sopenharmony_ci			max_rate = max_rate_lgi_80MHZ[nss - 1][mcs - 1];
928c2ecf20Sopenharmony_ci	}
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	return max_rate;
958c2ecf20Sopenharmony_ci}
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_cistatic void
988c2ecf20Sopenharmony_cimwifiex_fill_vht_cap_info(struct mwifiex_private *priv,
998c2ecf20Sopenharmony_ci			  struct ieee80211_vht_cap *vht_cap, u8 bands)
1008c2ecf20Sopenharmony_ci{
1018c2ecf20Sopenharmony_ci	struct mwifiex_adapter *adapter = priv->adapter;
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	if (bands & BAND_A)
1048c2ecf20Sopenharmony_ci		vht_cap->vht_cap_info =
1058c2ecf20Sopenharmony_ci				cpu_to_le32(adapter->usr_dot_11ac_dev_cap_a);
1068c2ecf20Sopenharmony_ci	else
1078c2ecf20Sopenharmony_ci		vht_cap->vht_cap_info =
1088c2ecf20Sopenharmony_ci				cpu_to_le32(adapter->usr_dot_11ac_dev_cap_bg);
1098c2ecf20Sopenharmony_ci}
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_civoid mwifiex_fill_vht_cap_tlv(struct mwifiex_private *priv,
1128c2ecf20Sopenharmony_ci			      struct ieee80211_vht_cap *vht_cap, u8 bands)
1138c2ecf20Sopenharmony_ci{
1148c2ecf20Sopenharmony_ci	struct mwifiex_adapter *adapter = priv->adapter;
1158c2ecf20Sopenharmony_ci	u16 mcs_map_user, mcs_map_resp, mcs_map_result;
1168c2ecf20Sopenharmony_ci	u16 mcs_user, mcs_resp, nss, tmp;
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci	/* Fill VHT cap info */
1198c2ecf20Sopenharmony_ci	mwifiex_fill_vht_cap_info(priv, vht_cap, bands);
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci	/* rx MCS Set: find the minimum of the user rx mcs and ap rx mcs */
1228c2ecf20Sopenharmony_ci	mcs_map_user = GET_DEVRXMCSMAP(adapter->usr_dot_11ac_mcs_support);
1238c2ecf20Sopenharmony_ci	mcs_map_resp = le16_to_cpu(vht_cap->supp_mcs.rx_mcs_map);
1248c2ecf20Sopenharmony_ci	mcs_map_result = 0;
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	for (nss = 1; nss <= 8; nss++) {
1278c2ecf20Sopenharmony_ci		mcs_user = GET_VHTNSSMCS(mcs_map_user, nss);
1288c2ecf20Sopenharmony_ci		mcs_resp = GET_VHTNSSMCS(mcs_map_resp, nss);
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci		if ((mcs_user == IEEE80211_VHT_MCS_NOT_SUPPORTED) ||
1318c2ecf20Sopenharmony_ci		    (mcs_resp == IEEE80211_VHT_MCS_NOT_SUPPORTED))
1328c2ecf20Sopenharmony_ci			SET_VHTNSSMCS(mcs_map_result, nss,
1338c2ecf20Sopenharmony_ci				      IEEE80211_VHT_MCS_NOT_SUPPORTED);
1348c2ecf20Sopenharmony_ci		else
1358c2ecf20Sopenharmony_ci			SET_VHTNSSMCS(mcs_map_result, nss,
1368c2ecf20Sopenharmony_ci				      min(mcs_user, mcs_resp));
1378c2ecf20Sopenharmony_ci	}
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci	vht_cap->supp_mcs.rx_mcs_map = cpu_to_le16(mcs_map_result);
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	tmp = mwifiex_convert_mcsmap_to_maxrate(priv, bands, mcs_map_result);
1428c2ecf20Sopenharmony_ci	vht_cap->supp_mcs.rx_highest = cpu_to_le16(tmp);
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci	/* tx MCS Set: find the minimum of the user tx mcs and ap tx mcs */
1458c2ecf20Sopenharmony_ci	mcs_map_user = GET_DEVTXMCSMAP(adapter->usr_dot_11ac_mcs_support);
1468c2ecf20Sopenharmony_ci	mcs_map_resp = le16_to_cpu(vht_cap->supp_mcs.tx_mcs_map);
1478c2ecf20Sopenharmony_ci	mcs_map_result = 0;
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci	for (nss = 1; nss <= 8; nss++) {
1508c2ecf20Sopenharmony_ci		mcs_user = GET_VHTNSSMCS(mcs_map_user, nss);
1518c2ecf20Sopenharmony_ci		mcs_resp = GET_VHTNSSMCS(mcs_map_resp, nss);
1528c2ecf20Sopenharmony_ci		if ((mcs_user == IEEE80211_VHT_MCS_NOT_SUPPORTED) ||
1538c2ecf20Sopenharmony_ci		    (mcs_resp == IEEE80211_VHT_MCS_NOT_SUPPORTED))
1548c2ecf20Sopenharmony_ci			SET_VHTNSSMCS(mcs_map_result, nss,
1558c2ecf20Sopenharmony_ci				      IEEE80211_VHT_MCS_NOT_SUPPORTED);
1568c2ecf20Sopenharmony_ci		else
1578c2ecf20Sopenharmony_ci			SET_VHTNSSMCS(mcs_map_result, nss,
1588c2ecf20Sopenharmony_ci				      min(mcs_user, mcs_resp));
1598c2ecf20Sopenharmony_ci	}
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci	vht_cap->supp_mcs.tx_mcs_map = cpu_to_le16(mcs_map_result);
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci	tmp = mwifiex_convert_mcsmap_to_maxrate(priv, bands, mcs_map_result);
1648c2ecf20Sopenharmony_ci	vht_cap->supp_mcs.tx_highest = cpu_to_le16(tmp);
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci	return;
1678c2ecf20Sopenharmony_ci}
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ciint mwifiex_cmd_append_11ac_tlv(struct mwifiex_private *priv,
1708c2ecf20Sopenharmony_ci			     struct mwifiex_bssdescriptor *bss_desc,
1718c2ecf20Sopenharmony_ci			     u8 **buffer)
1728c2ecf20Sopenharmony_ci{
1738c2ecf20Sopenharmony_ci	struct mwifiex_ie_types_vhtcap *vht_cap;
1748c2ecf20Sopenharmony_ci	struct mwifiex_ie_types_oper_mode_ntf *oper_ntf;
1758c2ecf20Sopenharmony_ci	struct ieee_types_oper_mode_ntf *ieee_oper_ntf;
1768c2ecf20Sopenharmony_ci	struct mwifiex_ie_types_vht_oper *vht_op;
1778c2ecf20Sopenharmony_ci	struct mwifiex_adapter *adapter = priv->adapter;
1788c2ecf20Sopenharmony_ci	u8 supp_chwd_set;
1798c2ecf20Sopenharmony_ci	u32 usr_vht_cap_info;
1808c2ecf20Sopenharmony_ci	int ret_len = 0;
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	if (bss_desc->bss_band & BAND_A)
1838c2ecf20Sopenharmony_ci		usr_vht_cap_info = adapter->usr_dot_11ac_dev_cap_a;
1848c2ecf20Sopenharmony_ci	else
1858c2ecf20Sopenharmony_ci		usr_vht_cap_info = adapter->usr_dot_11ac_dev_cap_bg;
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci	/* VHT Capabilities IE */
1888c2ecf20Sopenharmony_ci	if (bss_desc->bcn_vht_cap) {
1898c2ecf20Sopenharmony_ci		vht_cap = (struct mwifiex_ie_types_vhtcap *)*buffer;
1908c2ecf20Sopenharmony_ci		memset(vht_cap, 0, sizeof(*vht_cap));
1918c2ecf20Sopenharmony_ci		vht_cap->header.type = cpu_to_le16(WLAN_EID_VHT_CAPABILITY);
1928c2ecf20Sopenharmony_ci		vht_cap->header.len  =
1938c2ecf20Sopenharmony_ci				cpu_to_le16(sizeof(struct ieee80211_vht_cap));
1948c2ecf20Sopenharmony_ci		memcpy((u8 *)vht_cap + sizeof(struct mwifiex_ie_types_header),
1958c2ecf20Sopenharmony_ci		       (u8 *)bss_desc->bcn_vht_cap,
1968c2ecf20Sopenharmony_ci		       le16_to_cpu(vht_cap->header.len));
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci		mwifiex_fill_vht_cap_tlv(priv, &vht_cap->vht_cap,
1998c2ecf20Sopenharmony_ci					 bss_desc->bss_band);
2008c2ecf20Sopenharmony_ci		*buffer += sizeof(*vht_cap);
2018c2ecf20Sopenharmony_ci		ret_len += sizeof(*vht_cap);
2028c2ecf20Sopenharmony_ci	}
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	/* VHT Operation IE */
2058c2ecf20Sopenharmony_ci	if (bss_desc->bcn_vht_oper) {
2068c2ecf20Sopenharmony_ci		if (priv->bss_mode == NL80211_IFTYPE_STATION) {
2078c2ecf20Sopenharmony_ci			vht_op = (struct mwifiex_ie_types_vht_oper *)*buffer;
2088c2ecf20Sopenharmony_ci			memset(vht_op, 0, sizeof(*vht_op));
2098c2ecf20Sopenharmony_ci			vht_op->header.type =
2108c2ecf20Sopenharmony_ci					cpu_to_le16(WLAN_EID_VHT_OPERATION);
2118c2ecf20Sopenharmony_ci			vht_op->header.len  = cpu_to_le16(sizeof(*vht_op) -
2128c2ecf20Sopenharmony_ci				      sizeof(struct mwifiex_ie_types_header));
2138c2ecf20Sopenharmony_ci			memcpy((u8 *)vht_op +
2148c2ecf20Sopenharmony_ci				sizeof(struct mwifiex_ie_types_header),
2158c2ecf20Sopenharmony_ci			       (u8 *)bss_desc->bcn_vht_oper,
2168c2ecf20Sopenharmony_ci			       le16_to_cpu(vht_op->header.len));
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci			/* negotiate the channel width and central freq
2198c2ecf20Sopenharmony_ci			 * and keep the central freq as the peer suggests
2208c2ecf20Sopenharmony_ci			 */
2218c2ecf20Sopenharmony_ci			supp_chwd_set = GET_VHTCAP_CHWDSET(usr_vht_cap_info);
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci			switch (supp_chwd_set) {
2248c2ecf20Sopenharmony_ci			case 0:
2258c2ecf20Sopenharmony_ci				vht_op->chan_width =
2268c2ecf20Sopenharmony_ci				     min_t(u8, IEEE80211_VHT_CHANWIDTH_80MHZ,
2278c2ecf20Sopenharmony_ci					   bss_desc->bcn_vht_oper->chan_width);
2288c2ecf20Sopenharmony_ci				break;
2298c2ecf20Sopenharmony_ci			case 1:
2308c2ecf20Sopenharmony_ci				vht_op->chan_width =
2318c2ecf20Sopenharmony_ci				     min_t(u8, IEEE80211_VHT_CHANWIDTH_160MHZ,
2328c2ecf20Sopenharmony_ci					   bss_desc->bcn_vht_oper->chan_width);
2338c2ecf20Sopenharmony_ci				break;
2348c2ecf20Sopenharmony_ci			case 2:
2358c2ecf20Sopenharmony_ci				vht_op->chan_width =
2368c2ecf20Sopenharmony_ci				     min_t(u8, IEEE80211_VHT_CHANWIDTH_80P80MHZ,
2378c2ecf20Sopenharmony_ci					   bss_desc->bcn_vht_oper->chan_width);
2388c2ecf20Sopenharmony_ci				break;
2398c2ecf20Sopenharmony_ci			default:
2408c2ecf20Sopenharmony_ci				vht_op->chan_width =
2418c2ecf20Sopenharmony_ci				     IEEE80211_VHT_CHANWIDTH_USE_HT;
2428c2ecf20Sopenharmony_ci				break;
2438c2ecf20Sopenharmony_ci			}
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci			*buffer += sizeof(*vht_op);
2468c2ecf20Sopenharmony_ci			ret_len += sizeof(*vht_op);
2478c2ecf20Sopenharmony_ci		}
2488c2ecf20Sopenharmony_ci	}
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci	/* Operating Mode Notification IE */
2518c2ecf20Sopenharmony_ci	if (bss_desc->oper_mode) {
2528c2ecf20Sopenharmony_ci		ieee_oper_ntf = bss_desc->oper_mode;
2538c2ecf20Sopenharmony_ci		oper_ntf = (void *)*buffer;
2548c2ecf20Sopenharmony_ci		memset(oper_ntf, 0, sizeof(*oper_ntf));
2558c2ecf20Sopenharmony_ci		oper_ntf->header.type = cpu_to_le16(WLAN_EID_OPMODE_NOTIF);
2568c2ecf20Sopenharmony_ci		oper_ntf->header.len = cpu_to_le16(sizeof(u8));
2578c2ecf20Sopenharmony_ci		oper_ntf->oper_mode = ieee_oper_ntf->oper_mode;
2588c2ecf20Sopenharmony_ci		*buffer += sizeof(*oper_ntf);
2598c2ecf20Sopenharmony_ci		ret_len += sizeof(*oper_ntf);
2608c2ecf20Sopenharmony_ci	}
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	return ret_len;
2638c2ecf20Sopenharmony_ci}
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ciint mwifiex_cmd_11ac_cfg(struct mwifiex_private *priv,
2668c2ecf20Sopenharmony_ci			 struct host_cmd_ds_command *cmd, u16 cmd_action,
2678c2ecf20Sopenharmony_ci			 struct mwifiex_11ac_vht_cfg *cfg)
2688c2ecf20Sopenharmony_ci{
2698c2ecf20Sopenharmony_ci	struct host_cmd_11ac_vht_cfg *vhtcfg = &cmd->params.vht_cfg;
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	cmd->command = cpu_to_le16(HostCmd_CMD_11AC_CFG);
2728c2ecf20Sopenharmony_ci	cmd->size = cpu_to_le16(sizeof(struct host_cmd_11ac_vht_cfg) +
2738c2ecf20Sopenharmony_ci				S_DS_GEN);
2748c2ecf20Sopenharmony_ci	vhtcfg->action = cpu_to_le16(cmd_action);
2758c2ecf20Sopenharmony_ci	vhtcfg->band_config = cfg->band_config;
2768c2ecf20Sopenharmony_ci	vhtcfg->misc_config = cfg->misc_config;
2778c2ecf20Sopenharmony_ci	vhtcfg->cap_info = cpu_to_le32(cfg->cap_info);
2788c2ecf20Sopenharmony_ci	vhtcfg->mcs_tx_set = cpu_to_le32(cfg->mcs_tx_set);
2798c2ecf20Sopenharmony_ci	vhtcfg->mcs_rx_set = cpu_to_le32(cfg->mcs_rx_set);
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	return 0;
2828c2ecf20Sopenharmony_ci}
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci/* This function initializes the BlockACK setup information for given
2858c2ecf20Sopenharmony_ci * mwifiex_private structure for 11ac enabled networks.
2868c2ecf20Sopenharmony_ci */
2878c2ecf20Sopenharmony_civoid mwifiex_set_11ac_ba_params(struct mwifiex_private *priv)
2888c2ecf20Sopenharmony_ci{
2898c2ecf20Sopenharmony_ci	priv->add_ba_param.timeout = MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT;
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci	if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
2928c2ecf20Sopenharmony_ci		priv->add_ba_param.tx_win_size =
2938c2ecf20Sopenharmony_ci					   MWIFIEX_11AC_UAP_AMPDU_DEF_TXWINSIZE;
2948c2ecf20Sopenharmony_ci		priv->add_ba_param.rx_win_size =
2958c2ecf20Sopenharmony_ci					   MWIFIEX_11AC_UAP_AMPDU_DEF_RXWINSIZE;
2968c2ecf20Sopenharmony_ci	} else {
2978c2ecf20Sopenharmony_ci		priv->add_ba_param.tx_win_size =
2988c2ecf20Sopenharmony_ci					   MWIFIEX_11AC_STA_AMPDU_DEF_TXWINSIZE;
2998c2ecf20Sopenharmony_ci		priv->add_ba_param.rx_win_size =
3008c2ecf20Sopenharmony_ci					   MWIFIEX_11AC_STA_AMPDU_DEF_RXWINSIZE;
3018c2ecf20Sopenharmony_ci	}
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	return;
3048c2ecf20Sopenharmony_ci}
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_cibool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv)
3078c2ecf20Sopenharmony_ci{
3088c2ecf20Sopenharmony_ci	struct mwifiex_bssdescriptor *bss_desc;
3098c2ecf20Sopenharmony_ci	struct ieee80211_vht_operation *vht_oper;
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci	bss_desc = &priv->curr_bss_params.bss_descriptor;
3128c2ecf20Sopenharmony_ci	vht_oper = bss_desc->bcn_vht_oper;
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_ci	if (!bss_desc->bcn_vht_cap || !vht_oper)
3158c2ecf20Sopenharmony_ci		return false;
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	if (vht_oper->chan_width == IEEE80211_VHT_CHANWIDTH_USE_HT)
3188c2ecf20Sopenharmony_ci		return false;
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci	return true;
3218c2ecf20Sopenharmony_ci}
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ciu8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
3248c2ecf20Sopenharmony_ci				 u32 pri_chan, u8 chan_bw)
3258c2ecf20Sopenharmony_ci{
3268c2ecf20Sopenharmony_ci	u8 center_freq_idx = 0;
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	if (band & BAND_AAC) {
3298c2ecf20Sopenharmony_ci		switch (pri_chan) {
3308c2ecf20Sopenharmony_ci		case 36:
3318c2ecf20Sopenharmony_ci		case 40:
3328c2ecf20Sopenharmony_ci		case 44:
3338c2ecf20Sopenharmony_ci		case 48:
3348c2ecf20Sopenharmony_ci			if (chan_bw == IEEE80211_VHT_CHANWIDTH_80MHZ)
3358c2ecf20Sopenharmony_ci				center_freq_idx = 42;
3368c2ecf20Sopenharmony_ci			break;
3378c2ecf20Sopenharmony_ci		case 52:
3388c2ecf20Sopenharmony_ci		case 56:
3398c2ecf20Sopenharmony_ci		case 60:
3408c2ecf20Sopenharmony_ci		case 64:
3418c2ecf20Sopenharmony_ci			if (chan_bw == IEEE80211_VHT_CHANWIDTH_80MHZ)
3428c2ecf20Sopenharmony_ci				center_freq_idx = 58;
3438c2ecf20Sopenharmony_ci			else if (chan_bw == IEEE80211_VHT_CHANWIDTH_160MHZ)
3448c2ecf20Sopenharmony_ci				center_freq_idx = 50;
3458c2ecf20Sopenharmony_ci			break;
3468c2ecf20Sopenharmony_ci		case 100:
3478c2ecf20Sopenharmony_ci		case 104:
3488c2ecf20Sopenharmony_ci		case 108:
3498c2ecf20Sopenharmony_ci		case 112:
3508c2ecf20Sopenharmony_ci			if (chan_bw == IEEE80211_VHT_CHANWIDTH_80MHZ)
3518c2ecf20Sopenharmony_ci				center_freq_idx = 106;
3528c2ecf20Sopenharmony_ci			break;
3538c2ecf20Sopenharmony_ci		case 116:
3548c2ecf20Sopenharmony_ci		case 120:
3558c2ecf20Sopenharmony_ci		case 124:
3568c2ecf20Sopenharmony_ci		case 128:
3578c2ecf20Sopenharmony_ci			if (chan_bw == IEEE80211_VHT_CHANWIDTH_80MHZ)
3588c2ecf20Sopenharmony_ci				center_freq_idx = 122;
3598c2ecf20Sopenharmony_ci			else if (chan_bw == IEEE80211_VHT_CHANWIDTH_160MHZ)
3608c2ecf20Sopenharmony_ci				center_freq_idx = 114;
3618c2ecf20Sopenharmony_ci			break;
3628c2ecf20Sopenharmony_ci		case 132:
3638c2ecf20Sopenharmony_ci		case 136:
3648c2ecf20Sopenharmony_ci		case 140:
3658c2ecf20Sopenharmony_ci		case 144:
3668c2ecf20Sopenharmony_ci			if (chan_bw == IEEE80211_VHT_CHANWIDTH_80MHZ)
3678c2ecf20Sopenharmony_ci				center_freq_idx = 138;
3688c2ecf20Sopenharmony_ci			break;
3698c2ecf20Sopenharmony_ci		case 149:
3708c2ecf20Sopenharmony_ci		case 153:
3718c2ecf20Sopenharmony_ci		case 157:
3728c2ecf20Sopenharmony_ci		case 161:
3738c2ecf20Sopenharmony_ci			if (chan_bw == IEEE80211_VHT_CHANWIDTH_80MHZ)
3748c2ecf20Sopenharmony_ci				center_freq_idx = 155;
3758c2ecf20Sopenharmony_ci			break;
3768c2ecf20Sopenharmony_ci		default:
3778c2ecf20Sopenharmony_ci			center_freq_idx = 42;
3788c2ecf20Sopenharmony_ci		}
3798c2ecf20Sopenharmony_ci	}
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci	return center_freq_idx;
3828c2ecf20Sopenharmony_ci}
383