/*
* NXP Wireless LAN device driver: station event handling
*
* Copyright 2011-2020 NXP
*
* This software file (the "File") is distributed by NXP
* under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
#include "decl.h"
#include "ioctl.h"
#include "util.h"
#include "fw.h"
#include "main.h"
#include "wmm.h"
#include "11n.h"
#define MWIFIEX_IBSS_CONNECT_EVT_FIX_SIZE 12
static int mwifiex_check_ibss_peer_capabilities(struct mwifiex_private *priv,
struct mwifiex_sta_node *sta_ptr,
struct sk_buff *event)
{
int evt_len, ele_len;
u8 *curr;
struct ieee_types_header *ele_hdr;
struct mwifiex_ie_types_mgmt_frame *tlv_mgmt_frame;
const struct ieee80211_ht_cap *ht_cap;
const struct ieee80211_vht_cap *vht_cap;
skb_pull(event, MWIFIEX_IBSS_CONNECT_EVT_FIX_SIZE);
evt_len = event->len;
curr = event->data;
mwifiex_dbg_dump(priv->adapter, EVT_D, "ibss peer capabilities:",
event->data, event->len);
skb_push(event, MWIFIEX_IBSS_CONNECT_EVT_FIX_SIZE);
tlv_mgmt_frame = (void *)curr;
if (evt_len >= sizeof(*tlv_mgmt_frame) &&
le16_to_cpu(tlv_mgmt_frame->header.type) ==
TLV_TYPE_UAP_MGMT_FRAME) {
/* Locate curr pointer to the start of beacon tlv,
* timestamp 8 bytes, beacon intervel 2 bytes,
* capability info 2 bytes, totally 12 byte beacon header
*/
evt_len = le16_to_cpu(tlv_mgmt_frame->header.len);
curr += (sizeof(*tlv_mgmt_frame) + 12);
} else {
mwifiex_dbg(priv->adapter, MSG,
"management frame tlv not found!\n");
return 0;
}
while (evt_len >= sizeof(*ele_hdr)) {
ele_hdr = (struct ieee_types_header *)curr;
ele_len = ele_hdr->len;
if (evt_len < ele_len + sizeof(*ele_hdr))
break;
switch (ele_hdr->element_id) {
case WLAN_EID_HT_CAPABILITY:
sta_ptr->is_11n_enabled = true;
ht_cap = (void *)(ele_hdr + 2);
sta_ptr->max_amsdu = le16_to_cpu(ht_cap->cap_info) &
IEEE80211_HT_CAP_MAX_AMSDU ?
MWIFIEX_TX_DATA_BUF_SIZE_8K :
MWIFIEX_TX_DATA_BUF_SIZE_4K;
mwifiex_dbg(priv->adapter, INFO,
"11n enabled!, max_amsdu : %d\n",
sta_ptr->max_amsdu);
break;
case WLAN_EID_VHT_CAPABILITY:
sta_ptr->is_11ac_enabled = true;
vht_cap = (void *)(ele_hdr + 2);
/* check VHT MAXMPDU capability */
switch (le32_to_cpu(vht_cap->vht_cap_info) & 0x3) {
case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454:
sta_ptr->max_amsdu =
MWIFIEX_TX_DATA_BUF_SIZE_12K;
break;
case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991:
sta_ptr->max_amsdu =
MWIFIEX_TX_DATA_BUF_SIZE_8K;
break;
case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895:
sta_ptr->max_amsdu =
MWIFIEX_TX_DATA_BUF_SIZE_4K;
break;
default:
break;
}
mwifiex_dbg(priv->adapter, INFO,
"11ac enabled!, max_amsdu : %d\n",
sta_ptr->max_amsdu);
break;
default:
break;
}
curr += (ele_len + sizeof(*ele_hdr));
evt_len -= (ele_len + sizeof(*ele_hdr));
}
return 0;
}
/*
* This function resets the connection state.
*
* The function is invoked after receiving a disconnect event from firmware,
* and performs the following actions -
* - Set media status to disconnected
* - Clean up Tx and Rx packets
* - Resets SNR/NF/RSSI value in driver
* - Resets security configurations in driver
* - Enables auto data rate
* - Saves the previous SSID and BSSID so that they can
* be used for re-association, if required
* - Erases current SSID and BSSID information
* - Sends a disconnect event to upper layers/applications.
*/
void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code,
bool f