2016-03-27 17:56:02 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
2017-04-07 11:39:45 +00:00
|
|
|
*
|
2016-03-27 17:56:02 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
#define _RTW_MLME_C_
|
|
|
|
|
|
|
|
#include <hal_data.h>
|
|
|
|
|
|
|
|
extern void indicate_wx_scan_complete_event(_adapter *padapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
extern u8 rtw_do_join(_adapter *padapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
sint _rtw_init_mlme_priv(_adapter *padapter)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
sint i;
|
|
|
|
u8 *pbuf;
|
|
|
|
struct wlan_network *pnetwork;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
sint res = _SUCCESS;
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */
|
|
|
|
/* _rtw_memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); */
|
|
|
|
|
|
|
|
|
|
|
|
/*qos_priv*/
|
|
|
|
/*pmlmepriv->qospriv.qos_option = pregistrypriv->wmm_enable;*/
|
|
|
|
|
|
|
|
/*ht_priv*/
|
|
|
|
#ifdef CONFIG_80211N_HT
|
|
|
|
pmlmepriv->htpriv.ampdu_enable = _FALSE;/*set to disabled*/
|
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
pmlmepriv->nic_hdl = (u8 *)padapter;
|
|
|
|
|
|
|
|
pmlmepriv->pscanned = NULL;
|
2017-04-07 11:39:45 +00:00
|
|
|
/*pmlmepriv->fw_state = WIFI_STATION_STATE; */ /*Must sync with rtw_wdev_alloc()*/
|
|
|
|
/*init_fwstate(pmlmepriv, WIFI_STATION_STATE);*/
|
|
|
|
init_fwstate(pmlmepriv, WIFI_NULL_STATE);/*assigned interface role(STA/AP) must after execute set_opmode*/
|
|
|
|
|
|
|
|
/* wdev->iftype = NL80211_IFTYPE_STATION*/
|
2016-03-27 17:56:02 +00:00
|
|
|
pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown;
|
2017-04-07 11:39:45 +00:00
|
|
|
pmlmepriv->scan_mode = SCAN_ACTIVE; /* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
_rtw_spinlock_init(&(pmlmepriv->lock));
|
2016-03-27 17:56:02 +00:00
|
|
|
_rtw_init_queue(&(pmlmepriv->free_bss_pool));
|
|
|
|
_rtw_init_queue(&(pmlmepriv->scanned_queue));
|
|
|
|
|
|
|
|
set_scanned_network_val(pmlmepriv, 0);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
_rtw_memset(&pmlmepriv->assoc_ssid, 0, sizeof(NDIS_802_11_SSID));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
pbuf = rtw_zvmalloc(MAX_BSS_CNT * (sizeof(struct wlan_network)));
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
if (pbuf == NULL) {
|
|
|
|
res = _FAIL;
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
pmlmepriv->free_bss_buf = pbuf;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork = (struct wlan_network *)pbuf;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_BSS_CNT; i++) {
|
2016-03-27 17:56:02 +00:00
|
|
|
_rtw_init_listhead(&(pnetwork->list));
|
|
|
|
|
|
|
|
rtw_list_insert_tail(&(pnetwork->list), &(pmlmepriv->free_bss_pool.queue));
|
|
|
|
|
|
|
|
pnetwork++;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
rtw_clear_scan_deny(padapter);
|
|
|
|
#ifdef CONFIG_ARP_KEEP_ALIVE
|
|
|
|
pmlmepriv->bGetGateway = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_LAYER2_ROAMING
|
2017-04-07 11:39:45 +00:00
|
|
|
#define RTW_ROAM_SCAN_RESULT_EXP_MS (5*1000)
|
|
|
|
#define RTW_ROAM_RSSI_DIFF_TH 10
|
|
|
|
#define RTW_ROAM_SCAN_INTERVAL_MS (10*1000)
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
pmlmepriv->roam_flags = 0
|
2017-04-07 11:39:45 +00:00
|
|
|
| RTW_ROAM_ON_EXPIRED
|
|
|
|
#ifdef CONFIG_LAYER2_ROAMING_RESUME
|
|
|
|
| RTW_ROAM_ON_RESUME
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_LAYER2_ROAMING_ACTIVE
|
|
|
|
| RTW_ROAM_ACTIVE
|
|
|
|
#endif
|
|
|
|
;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
pmlmepriv->roam_scanr_exp_ms = RTW_ROAM_SCAN_RESULT_EXP_MS;
|
|
|
|
pmlmepriv->roam_rssi_diff_th = RTW_ROAM_RSSI_DIFF_TH;
|
|
|
|
pmlmepriv->roam_scan_int_ms = RTW_ROAM_SCAN_INTERVAL_MS;
|
|
|
|
#endif /* CONFIG_LAYER2_ROAMING */
|
|
|
|
|
|
|
|
rtw_init_mlme_timer(padapter);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_mfree_mlme_priv_lock(struct mlme_priv *pmlmepriv);
|
|
|
|
void rtw_mfree_mlme_priv_lock(struct mlme_priv *pmlmepriv)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
_rtw_spinlock_free(&pmlmepriv->lock);
|
|
|
|
_rtw_spinlock_free(&(pmlmepriv->free_bss_pool.lock));
|
|
|
|
_rtw_spinlock_free(&(pmlmepriv->scanned_queue.lock));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
if (*ppie) {
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_mfree(*ppie, *plen);
|
|
|
|
*plen = 0;
|
2017-04-07 11:39:45 +00:00
|
|
|
*ppie = NULL;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
#if defined(CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len);
|
|
|
|
rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, &pmlmepriv->wps_assoc_resp_ie_len);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, &pmlmepriv->p2p_beacon_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, &pmlmepriv->p2p_probe_req_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, &pmlmepriv->p2p_probe_resp_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len);
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_resp_ie, &pmlmepriv->p2p_assoc_resp_ie_len);
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#if defined(CONFIG_WFD) && defined(CONFIG_IOCTL_CFG80211)
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie, &pmlmepriv->wfd_beacon_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie, &pmlmepriv->wfd_probe_req_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie, &pmlmepriv->wfd_probe_resp_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->wfd_go_probe_resp_ie, &pmlmepriv->wfd_go_probe_resp_ie_len);
|
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->wfd_assoc_req_ie, &pmlmepriv->wfd_assoc_req_ie_len);
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_free_mlme_ie_data(&pmlmepriv->wfd_assoc_resp_ie, &pmlmepriv->wfd_assoc_resp_ie_len);
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#if defined(CONFIG_WFD) && defined(CONFIG_IOCTL_CFG80211)
|
|
|
|
int rtw_mlme_update_wfd_ie_data(struct mlme_priv *mlme, u8 type, u8 *ie, u32 ie_len)
|
|
|
|
{
|
|
|
|
_adapter *adapter = mlme_to_adapter(mlme);
|
|
|
|
struct wifi_display_info *wfd_info = &adapter->wfd_info;
|
|
|
|
u8 clear = 0;
|
|
|
|
u8 **t_ie = NULL;
|
|
|
|
u32 *t_ie_len = NULL;
|
|
|
|
int ret = _FAIL;
|
|
|
|
|
|
|
|
if (!hal_chk_wl_func(adapter, WL_FUNC_MIRACAST))
|
|
|
|
goto success;
|
|
|
|
|
|
|
|
if (wfd_info->wfd_enable == _TRUE)
|
|
|
|
goto success; /* WFD IE is build by self */
|
|
|
|
|
|
|
|
if (!ie && !ie_len)
|
|
|
|
clear = 1;
|
|
|
|
else if (!ie || !ie_len) {
|
|
|
|
RTW_PRINT(FUNC_ADPT_FMT" type:%u, ie:%p, ie_len:%u"
|
|
|
|
, FUNC_ADPT_ARG(adapter), type, ie, ie_len);
|
|
|
|
rtw_warn_on(1);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case MLME_BEACON_IE:
|
|
|
|
t_ie = &mlme->wfd_beacon_ie;
|
|
|
|
t_ie_len = &mlme->wfd_beacon_ie_len;
|
|
|
|
break;
|
|
|
|
case MLME_PROBE_REQ_IE:
|
|
|
|
t_ie = &mlme->wfd_probe_req_ie;
|
|
|
|
t_ie_len = &mlme->wfd_probe_req_ie_len;
|
|
|
|
break;
|
|
|
|
case MLME_PROBE_RESP_IE:
|
|
|
|
t_ie = &mlme->wfd_probe_resp_ie;
|
|
|
|
t_ie_len = &mlme->wfd_probe_resp_ie_len;
|
|
|
|
break;
|
|
|
|
case MLME_GO_PROBE_RESP_IE:
|
|
|
|
t_ie = &mlme->wfd_go_probe_resp_ie;
|
|
|
|
t_ie_len = &mlme->wfd_go_probe_resp_ie_len;
|
|
|
|
break;
|
|
|
|
case MLME_ASSOC_REQ_IE:
|
|
|
|
t_ie = &mlme->wfd_assoc_req_ie;
|
|
|
|
t_ie_len = &mlme->wfd_assoc_req_ie_len;
|
|
|
|
break;
|
|
|
|
case MLME_ASSOC_RESP_IE:
|
|
|
|
t_ie = &mlme->wfd_assoc_resp_ie;
|
|
|
|
t_ie_len = &mlme->wfd_assoc_resp_ie_len;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RTW_PRINT(FUNC_ADPT_FMT" unsupported type:%u"
|
|
|
|
, FUNC_ADPT_ARG(adapter), type);
|
|
|
|
rtw_warn_on(1);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*t_ie) {
|
|
|
|
u32 free_len = *t_ie_len;
|
|
|
|
*t_ie_len = 0;
|
|
|
|
rtw_mfree(*t_ie, free_len);
|
|
|
|
*t_ie = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!clear) {
|
|
|
|
*t_ie = rtw_malloc(ie_len);
|
|
|
|
if (*t_ie == NULL) {
|
|
|
|
RTW_ERR(FUNC_ADPT_FMT" type:%u, rtw_malloc() fail\n"
|
|
|
|
, FUNC_ADPT_ARG(adapter), type);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
_rtw_memcpy(*t_ie, ie, ie_len);
|
|
|
|
*t_ie_len = ie_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*t_ie && *t_ie_len) {
|
|
|
|
u8 *attr_content;
|
|
|
|
u32 attr_contentlen = 0;
|
|
|
|
|
|
|
|
attr_content = rtw_get_wfd_attr_content(*t_ie, *t_ie_len, WFD_ATTR_DEVICE_INFO, NULL, &attr_contentlen);
|
|
|
|
if (attr_content && attr_contentlen) {
|
|
|
|
if (RTW_GET_BE16(attr_content + 2) != wfd_info->rtsp_ctrlport) {
|
|
|
|
wfd_info->rtsp_ctrlport = RTW_GET_BE16(attr_content + 2);
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT" type:%u, RTSP CTRL port = %u\n"
|
|
|
|
, FUNC_ADPT_ARG(adapter), type, wfd_info->rtsp_ctrlport);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
success:
|
|
|
|
ret = _SUCCESS;
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif /* defined(CONFIG_WFD) && defined(CONFIG_IOCTL_CFG80211) */
|
|
|
|
|
|
|
|
void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
if (NULL == pmlmepriv) {
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_warn_on(1);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
rtw_free_mlme_priv_ie_data(pmlmepriv);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pmlmepriv) {
|
|
|
|
rtw_mfree_mlme_priv_lock(pmlmepriv);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pmlmepriv->free_bss_buf)
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_vmfree(pmlmepriv->free_bss_buf, MAX_BSS_CNT * sizeof(struct wlan_network));
|
|
|
|
}
|
|
|
|
exit:
|
2017-04-07 11:39:45 +00:00
|
|
|
return;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sint _rtw_enqueue_network(_queue *queue, struct wlan_network *pnetwork)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
|
|
|
|
|
|
|
|
if (pnetwork == NULL)
|
|
|
|
goto exit;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_enter_critical_bh(&queue->lock, &irqL);
|
|
|
|
|
|
|
|
rtw_list_insert_tail(&pnetwork->list, &queue->queue);
|
|
|
|
|
|
|
|
_exit_critical_bh(&queue->lock, &irqL);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
exit:
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
struct wlan_network *_rtw_dequeue_network(_queue *queue)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
|
|
|
|
struct wlan_network *pnetwork;
|
|
|
|
|
|
|
|
|
|
|
|
_enter_critical_bh(&queue->lock, &irqL);
|
|
|
|
|
|
|
|
if (_rtw_queue_empty(queue) == _TRUE)
|
|
|
|
|
|
|
|
pnetwork = NULL;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pnetwork = LIST_CONTAINOR(get_next(&queue->queue), struct wlan_network, list);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_list_delete(&(pnetwork->list));
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_exit_critical_bh(&queue->lock, &irqL);
|
|
|
|
|
|
|
|
|
|
|
|
return pnetwork;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv) /* (_queue *free_queue) */
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
_irqL irqL;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct wlan_network *pnetwork;
|
2016-03-27 17:56:02 +00:00
|
|
|
_queue *free_queue = &pmlmepriv->free_bss_pool;
|
2017-04-07 11:39:45 +00:00
|
|
|
_list *plist = NULL;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_enter_critical_bh(&free_queue->lock, &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
if (_rtw_queue_empty(free_queue) == _TRUE) {
|
2017-04-07 11:39:45 +00:00
|
|
|
pnetwork = NULL;
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
plist = get_next(&(free_queue->queue));
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork = LIST_CONTAINOR(plist , struct wlan_network, list);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_list_delete(&pnetwork->list);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork->network_type = 0;
|
|
|
|
pnetwork->fixed = _FALSE;
|
|
|
|
pnetwork->last_scanned = rtw_get_current_time();
|
2017-04-07 11:39:45 +00:00
|
|
|
pnetwork->aid = 0;
|
|
|
|
pnetwork->join_res = 0;
|
|
|
|
|
|
|
|
pmlmepriv->num_of_scanned++;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
_exit_critical_bh(&free_queue->lock, &irqL);
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
return pnetwork;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void _rtw_free_network(struct mlme_priv *pmlmepriv , struct wlan_network *pnetwork, u8 isfreeall)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
u32 delta_time;
|
|
|
|
u32 lifetime = SCANQUEUE_LIFETIME;
|
2017-04-07 11:39:45 +00:00
|
|
|
_irqL irqL;
|
2016-03-27 17:56:02 +00:00
|
|
|
_queue *free_queue = &(pmlmepriv->free_bss_pool);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if (pnetwork == NULL)
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
if (pnetwork->fixed == _TRUE)
|
|
|
|
goto exit;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE))
|
2016-03-27 17:56:02 +00:00
|
|
|
lifetime = 1;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (!isfreeall) {
|
2016-03-27 17:56:02 +00:00
|
|
|
delta_time = (u32) rtw_get_passing_time_ms(pnetwork->last_scanned);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (delta_time < lifetime) /* unit:msec */
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
_enter_critical_bh(&free_queue->lock, &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_list_delete(&(pnetwork->list));
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_list_insert_tail(&(pnetwork->list), &(free_queue->queue));
|
|
|
|
|
|
|
|
pmlmepriv->num_of_scanned--;
|
|
|
|
|
|
|
|
|
|
|
|
/* RTW_INFO("_rtw_free_network:SSID=%s\n", pnetwork->network.Ssid.Ssid); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_exit_critical_bh(&free_queue->lock, &irqL);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
exit:
|
|
|
|
return;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork)
|
|
|
|
{
|
|
|
|
|
|
|
|
_queue *free_queue = &(pmlmepriv->free_bss_pool);
|
|
|
|
|
|
|
|
|
|
|
|
if (pnetwork == NULL)
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
if (pnetwork->fixed == _TRUE)
|
|
|
|
goto exit;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _enter_critical(&free_queue->lock, &irqL); */
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_list_delete(&(pnetwork->list));
|
|
|
|
|
|
|
|
rtw_list_insert_tail(&(pnetwork->list), get_list_head(free_queue));
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
pmlmepriv->num_of_scanned--;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _exit_critical(&free_queue->lock, &irqL); */
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
return the wlan_network with the matching addr
|
|
|
|
|
|
|
|
Shall be calle under atomic context... to avoid possible racing condition...
|
|
|
|
*/
|
|
|
|
struct wlan_network *_rtw_find_network(_queue *scanned_queue, u8 *addr)
|
|
|
|
{
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _irqL irqL; */
|
2016-03-27 17:56:02 +00:00
|
|
|
_list *phead, *plist;
|
|
|
|
struct wlan_network *pnetwork = NULL;
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (_rtw_memcmp(zero_addr, addr, ETH_ALEN)) {
|
|
|
|
pnetwork = NULL;
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
/* _enter_critical_bh(&scanned_queue->lock, &irqL); */
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
phead = get_list_head(scanned_queue);
|
|
|
|
plist = get_next(phead);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
while (plist != phead) {
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network , list);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if (_rtw_memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN) == _TRUE)
|
2017-04-07 11:39:45 +00:00
|
|
|
break;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
plist = get_next(plist);
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (plist == phead)
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork = NULL;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _exit_critical_bh(&scanned_queue->lock, &irqL); */
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
return pnetwork;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _rtw_free_network_queue(_adapter *padapter, u8 isfreeall)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
_list *phead, *plist;
|
|
|
|
struct wlan_network *pnetwork;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
_queue *scanned_queue = &pmlmepriv->scanned_queue;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_enter_critical_bh(&scanned_queue->lock, &irqL);
|
|
|
|
|
|
|
|
phead = get_list_head(scanned_queue);
|
|
|
|
plist = get_next(phead);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
while (rtw_end_of_queue_search(phead, plist) == _FALSE) {
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
|
|
|
|
|
|
|
plist = get_next(plist);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
_rtw_free_network(pmlmepriv, pnetwork, isfreeall);
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_exit_critical_bh(&scanned_queue->lock, &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
sint rtw_if_up(_adapter *padapter)
|
|
|
|
{
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
sint res;
|
|
|
|
|
|
|
|
if (RTW_CANNOT_RUN(padapter) ||
|
2017-04-07 11:39:45 +00:00
|
|
|
(check_fwstate(&padapter->mlmepriv, _FW_LINKED) == _FALSE)) {
|
|
|
|
res = _FALSE;
|
|
|
|
} else
|
|
|
|
res = _TRUE;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_generate_random_ibss(u8 *pibss)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
*((u32 *)(&pibss[2])) = rtw_random32();
|
|
|
|
pibss[0] = 0x02; /* in ad-hoc mode local bit must set to 1 */
|
2016-03-27 17:56:02 +00:00
|
|
|
pibss[1] = 0x11;
|
|
|
|
pibss[2] = 0x87;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 *rtw_get_capability_from_ie(u8 *ie)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
return ie + 8 + 2;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
u16 rtw_get_capability(WLAN_BSSID_EX *bss)
|
|
|
|
{
|
|
|
|
u16 val;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
_rtw_memcpy((u8 *)&val, rtw_get_capability_from_ie(bss->IEs), 2);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
return le16_to_cpu(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 *rtw_get_timestampe_from_ie(u8 *ie)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
return ie + 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 *rtw_get_beacon_interval_from_ie(u8 *ie)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
return ie + 8;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
int rtw_init_mlme_priv(_adapter *padapter) /* (struct mlme_priv *pmlmepriv) */
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
int res;
|
2017-04-07 11:39:45 +00:00
|
|
|
res = _rtw_init_mlme_priv(padapter);/* (pmlmepriv); */
|
2016-03-27 17:56:02 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
_rtw_free_mlme_priv(pmlmepriv);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int rtw_enqueue_network(_queue *queue, struct wlan_network *pnetwork);
|
|
|
|
int rtw_enqueue_network(_queue *queue, struct wlan_network *pnetwork)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
res = _rtw_enqueue_network(queue, pnetwork);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
static struct wlan_network *rtw_dequeue_network(_queue *queue)
|
|
|
|
{
|
|
|
|
struct wlan_network *pnetwork;
|
|
|
|
pnetwork = _rtw_dequeue_network(queue);
|
|
|
|
return pnetwork;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv);
|
|
|
|
struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) /* (_queue *free_queue) */
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
struct wlan_network *pnetwork;
|
|
|
|
pnetwork = _rtw_alloc_network(pmlmepriv);
|
|
|
|
return pnetwork;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 is_freeall);
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 is_freeall)/* (struct wlan_network *pnetwork, _queue *free_queue) */
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
_rtw_free_network(pmlmepriv, pnetwork, is_freeall);
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_free_network_nolock(_adapter *padapter, struct wlan_network *pnetwork);
|
|
|
|
void rtw_free_network_nolock(_adapter *padapter, struct wlan_network *pnetwork)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
_rtw_free_network_nolock(&(padapter->mlmepriv), pnetwork);
|
|
|
|
#ifdef CONFIG_IOCTL_CFG80211
|
|
|
|
rtw_cfg80211_unlink_bss(padapter, pnetwork);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_IOCTL_CFG80211 */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_free_network_queue(_adapter *dev, u8 isfreeall)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
_rtw_free_network_queue(dev, isfreeall);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
return the wlan_network with the matching addr
|
|
|
|
|
|
|
|
Shall be calle under atomic context... to avoid possible racing condition...
|
|
|
|
*/
|
|
|
|
struct wlan_network *rtw_find_network(_queue *scanned_queue, u8 *addr)
|
|
|
|
{
|
|
|
|
struct wlan_network *pnetwork = _rtw_find_network(scanned_queue, addr);
|
|
|
|
|
|
|
|
return pnetwork;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rtw_is_same_ibss(_adapter *adapter, struct wlan_network *pnetwork)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
int ret = _TRUE;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct security_priv *psecuritypriv = &adapter->securitypriv;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) &&
|
|
|
|
(pnetwork->network.Privacy == 0))
|
|
|
|
ret = _FALSE;
|
|
|
|
else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) &&
|
|
|
|
(pnetwork->network.Privacy == 1))
|
|
|
|
ret = _FALSE;
|
2016-03-27 17:56:02 +00:00
|
|
|
else
|
2017-04-07 11:39:45 +00:00
|
|
|
ret = _TRUE;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
return ret;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int is_same_ess(WLAN_BSSID_EX *a, WLAN_BSSID_EX *b)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
return (a->Ssid.SsidLength == b->Ssid.SsidLength)
|
|
|
|
&& _rtw_memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength) == _TRUE;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int is_same_network(WLAN_BSSID_EX *src, WLAN_BSSID_EX *dst, u8 feature)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
u16 s_cap, d_cap;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
if (rtw_bug_check(dst, src, &s_cap, &d_cap) == _FALSE)
|
|
|
|
return _FALSE;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_rtw_memcpy((u8 *)&s_cap, rtw_get_capability_from_ie(src->IEs), 2);
|
|
|
|
_rtw_memcpy((u8 *)&d_cap, rtw_get_capability_from_ie(dst->IEs), 2);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
s_cap = le16_to_cpu(s_cap);
|
|
|
|
d_cap = le16_to_cpu(d_cap);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_P2P
|
2017-04-07 11:39:45 +00:00
|
|
|
if ((feature == 1) && /* 1: P2P supported */
|
|
|
|
(_rtw_memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN) == _TRUE)
|
|
|
|
)
|
2016-03-27 17:56:02 +00:00
|
|
|
return _TRUE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ((src->Ssid.SsidLength == dst->Ssid.SsidLength) &&
|
2017-04-07 11:39:45 +00:00
|
|
|
/* (src->Configuration.DSConfig == dst->Configuration.DSConfig) && */
|
|
|
|
((_rtw_memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) == _TRUE) &&
|
|
|
|
((_rtw_memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) == _TRUE) &&
|
|
|
|
((s_cap & WLAN_CAPABILITY_IBSS) ==
|
|
|
|
(d_cap & WLAN_CAPABILITY_IBSS)) &&
|
|
|
|
((s_cap & WLAN_CAPABILITY_BSS) ==
|
|
|
|
(d_cap & WLAN_CAPABILITY_BSS)));
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct wlan_network *_rtw_find_same_network(_queue *scanned_queue, struct wlan_network *network)
|
|
|
|
{
|
|
|
|
_list *phead, *plist;
|
|
|
|
struct wlan_network *found = NULL;
|
|
|
|
|
|
|
|
phead = get_list_head(scanned_queue);
|
|
|
|
plist = get_next(phead);
|
|
|
|
|
|
|
|
while (plist != phead) {
|
2017-04-07 11:39:45 +00:00
|
|
|
found = LIST_CONTAINOR(plist, struct wlan_network , list);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (is_same_network(&network->network, &found->network, 0))
|
2016-03-27 17:56:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
plist = get_next(plist);
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (plist == phead)
|
2016-03-27 17:56:02 +00:00
|
|
|
found = NULL;
|
2017-04-07 11:39:45 +00:00
|
|
|
exit:
|
2016-03-27 17:56:02 +00:00
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wlan_network *rtw_find_same_network(_queue *scanned_queue, struct wlan_network *network)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
struct wlan_network *found = NULL;
|
|
|
|
|
|
|
|
if (scanned_queue == NULL || network == NULL)
|
2017-04-07 11:39:45 +00:00
|
|
|
goto exit;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_enter_critical_bh(&scanned_queue->lock, &irqL);
|
|
|
|
found = _rtw_find_same_network(scanned_queue, network);
|
|
|
|
_exit_critical_bh(&scanned_queue->lock, &irqL);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
struct wlan_network *rtw_get_oldest_wlan_network(_queue *scanned_queue)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
_list *plist, *phead;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
struct wlan_network *pwlan = NULL;
|
|
|
|
struct wlan_network *oldest = NULL;
|
|
|
|
phead = get_list_head(scanned_queue);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
plist = get_next(phead);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
while (1) {
|
|
|
|
|
|
|
|
if (rtw_end_of_queue_search(phead, plist) == _TRUE)
|
2016-03-27 17:56:02 +00:00
|
|
|
break;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
pwlan = LIST_CONTAINOR(plist, struct wlan_network, list);
|
|
|
|
|
|
|
|
if (pwlan->fixed != _TRUE) {
|
|
|
|
if (oldest == NULL || time_after(oldest->last_scanned, pwlan->last_scanned))
|
2016-03-27 17:56:02 +00:00
|
|
|
oldest = pwlan;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
plist = get_next(plist);
|
|
|
|
}
|
|
|
|
return oldest;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void update_network(WLAN_BSSID_EX *dst, WLAN_BSSID_EX *src,
|
2017-04-07 11:39:45 +00:00
|
|
|
_adapter *padapter, bool update_ie)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
u8 ss_ori = dst->PhyInfo.SignalStrength;
|
|
|
|
u8 sq_ori = dst->PhyInfo.SignalQuality;
|
|
|
|
long rssi_ori = dst->Rssi;
|
|
|
|
|
|
|
|
u8 ss_smp = src->PhyInfo.SignalStrength;
|
|
|
|
u8 sq_smp = src->PhyInfo.SignalQuality;
|
|
|
|
long rssi_smp = src->Rssi;
|
|
|
|
|
|
|
|
u8 ss_final;
|
|
|
|
u8 sq_final;
|
|
|
|
long rssi_final;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ANTENNA_DIVERSITY
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_hal_antdiv_rssi_compared(padapter, dst, src); /* this will update src.Rssi, need consider again */
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#if defined(DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) && 1
|
|
|
|
if (strcmp(dst->Ssid.Ssid, DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) == 0) {
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT" %s("MAC_FMT", ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n"
|
|
|
|
, FUNC_ADPT_ARG(padapter)
|
2016-03-27 17:56:02 +00:00
|
|
|
, src->Ssid.Ssid, MAC_ARG(src->MacAddress), src->Configuration.DSConfig
|
2017-04-07 11:39:45 +00:00
|
|
|
, ss_ori, sq_ori, rssi_ori
|
|
|
|
, ss_smp, sq_smp, rssi_smp
|
|
|
|
);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
/* The rule below is 1/5 for sample value, 4/5 for history value */
|
|
|
|
if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network(&(padapter->mlmepriv.cur_network.network), src, 0)) {
|
|
|
|
/* Take the recvpriv's value for the connected AP*/
|
|
|
|
ss_final = padapter->recvpriv.signal_strength;
|
|
|
|
sq_final = padapter->recvpriv.signal_qual;
|
|
|
|
/* the rssi value here is undecorated, and will be used for antenna diversity */
|
2017-04-07 11:39:45 +00:00
|
|
|
if (sq_smp != 101) /* from the right channel */
|
|
|
|
rssi_final = (src->Rssi + dst->Rssi * 4) / 5;
|
2016-03-27 17:56:02 +00:00
|
|
|
else
|
|
|
|
rssi_final = rssi_ori;
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
|
|
|
if (sq_smp != 101) { /* from the right channel */
|
|
|
|
ss_final = ((u32)(src->PhyInfo.SignalStrength) + (u32)(dst->PhyInfo.SignalStrength) * 4) / 5;
|
|
|
|
sq_final = ((u32)(src->PhyInfo.SignalQuality) + (u32)(dst->PhyInfo.SignalQuality) * 4) / 5;
|
|
|
|
rssi_final = (src->Rssi + dst->Rssi * 4) / 5;
|
2016-03-27 17:56:02 +00:00
|
|
|
} else {
|
|
|
|
/* bss info not receving from the right channel, use the original RX signal infos */
|
|
|
|
ss_final = dst->PhyInfo.SignalStrength;
|
|
|
|
sq_final = dst->PhyInfo.SignalQuality;
|
|
|
|
rssi_final = dst->Rssi;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (update_ie) {
|
|
|
|
dst->Reserved[0] = src->Reserved[0];
|
|
|
|
dst->Reserved[1] = src->Reserved[1];
|
|
|
|
_rtw_memcpy((u8 *)dst, (u8 *)src, get_WLAN_BSSID_EX_sz(src));
|
|
|
|
}
|
|
|
|
|
|
|
|
dst->PhyInfo.SignalStrength = ss_final;
|
|
|
|
dst->PhyInfo.SignalQuality = sq_final;
|
|
|
|
dst->Rssi = rssi_final;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#if defined(DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) && 1
|
|
|
|
if (strcmp(dst->Ssid.Ssid, DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) == 0) {
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT" %s("MAC_FMT"), SignalStrength:%u, SignalQuality:%u, RawRSSI:%ld\n"
|
|
|
|
, FUNC_ADPT_ARG(padapter)
|
2016-03-27 17:56:02 +00:00
|
|
|
, dst->Ssid.Ssid, MAC_ARG(dst->MacAddress), dst->PhyInfo.SignalStrength, dst->PhyInfo.SignalQuality, dst->Rssi);
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#if 0 /* old codes, may be useful one day...
|
|
|
|
* RTW_INFO("update_network: rssi=0x%lx dst->Rssi=%d ,dst->Rssi=0x%lx , src->Rssi=0x%lx",(dst->Rssi+src->Rssi)/2,dst->Rssi,dst->Rssi,src->Rssi); */
|
|
|
|
if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network(&(padapter->mlmepriv.cur_network.network), src)) {
|
|
|
|
|
|
|
|
/* RTW_INFO("b:ssid=%s update_network: src->rssi=0x%d padapter->recvpriv.ui_rssi=%d\n",src->Ssid.Ssid,src->Rssi,padapter->recvpriv.signal); */
|
|
|
|
if (padapter->recvpriv.signal_qual_data.total_num++ >= PHY_LINKQUALITY_SLID_WIN_MAX) {
|
|
|
|
padapter->recvpriv.signal_qual_data.total_num = PHY_LINKQUALITY_SLID_WIN_MAX;
|
|
|
|
last_evm = padapter->recvpriv.signal_qual_data.elements[padapter->recvpriv.signal_qual_data.index];
|
|
|
|
padapter->recvpriv.signal_qual_data.total_val -= last_evm;
|
|
|
|
}
|
|
|
|
padapter->recvpriv.signal_qual_data.total_val += query_rx_pwr_percentage(src->Rssi);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
padapter->recvpriv.signal_qual_data.elements[padapter->recvpriv.signal_qual_data.index++] = query_rx_pwr_percentage(src->Rssi);
|
|
|
|
if (padapter->recvpriv.signal_qual_data.index >= PHY_LINKQUALITY_SLID_WIN_MAX)
|
|
|
|
padapter->recvpriv.signal_qual_data.index = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* RTW_INFO("Total SQ=%d pattrib->signal_qual= %d\n", padapter->recvpriv.signal_qual_data.total_val, src->Rssi); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* <1> Showed on UI for user,in percentage. */
|
|
|
|
tmpVal = padapter->recvpriv.signal_qual_data.total_val / padapter->recvpriv.signal_qual_data.total_num;
|
|
|
|
padapter->recvpriv.signal = (u8)tmpVal; /* Link quality */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
src->Rssi = translate_percentage_to_dbm(padapter->recvpriv.signal) ;
|
|
|
|
} else {
|
|
|
|
/* RTW_INFO("ELSE:ssid=%s update_network: src->rssi=0x%d dst->rssi=%d\n",src->Ssid.Ssid,src->Rssi,dst->Rssi); */
|
|
|
|
src->Rssi = (src->Rssi + dst->Rssi) / 2; /* dBM */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* RTW_INFO("a:update_network: src->rssi=0x%d padapter->recvpriv.ui_rssi=%d\n",src->Rssi,padapter->recvpriv.signal); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_current_network(_adapter *adapter, WLAN_BSSID_EX *pnetwork)
|
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_bug_check(&(pmlmepriv->cur_network.network),
|
|
|
|
&(pmlmepriv->cur_network.network),
|
|
|
|
&(pmlmepriv->cur_network.network),
|
|
|
|
&(pmlmepriv->cur_network.network));
|
|
|
|
|
|
|
|
if ((check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) && (is_same_network(&(pmlmepriv->cur_network.network), pnetwork, 0))) {
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* if(pmlmepriv->cur_network.network.IELength<= pnetwork->IELength) */
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, _TRUE);
|
|
|
|
rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof(NDIS_802_11_FIXED_IEs),
|
|
|
|
pmlmepriv->cur_network.network.IELength);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Caller must hold pmlmepriv->lock first.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
void rtw_update_scanned_network(_adapter *adapter, WLAN_BSSID_EX *target)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
_list *plist, *phead;
|
|
|
|
ULONG bssid_ex_sz;
|
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &(adapter->mlmeextpriv);
|
|
|
|
#ifdef CONFIG_P2P
|
2017-04-07 11:39:45 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &(adapter->wdinfo);
|
|
|
|
#endif /* CONFIG_P2P */
|
2016-03-27 17:56:02 +00:00
|
|
|
_queue *queue = &(pmlmepriv->scanned_queue);
|
|
|
|
struct wlan_network *pnetwork = NULL;
|
|
|
|
struct wlan_network *oldest = NULL;
|
|
|
|
int target_find = 0;
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 feature = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
_enter_critical_bh(&queue->lock, &irqL);
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
|
|
|
|
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
|
2017-04-07 11:39:45 +00:00
|
|
|
feature = 1; /* p2p enable */
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
while (1) {
|
|
|
|
if (rtw_end_of_queue_search(phead, plist) == _TRUE)
|
2016-03-27 17:56:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
|
|
|
|
|
|
|
rtw_bug_check(pnetwork, pnetwork, pnetwork, pnetwork);
|
|
|
|
|
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) &&
|
2017-04-07 11:39:45 +00:00
|
|
|
(_rtw_memcmp(pnetwork->network.MacAddress, target->MacAddress, ETH_ALEN) == _TRUE)) {
|
2016-03-27 17:56:02 +00:00
|
|
|
target_find = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (is_same_network(&(pnetwork->network), target, feature)) {
|
2016-03-27 17:56:02 +00:00
|
|
|
target_find = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rtw_roam_flags(adapter)) {
|
|
|
|
/* TODO: don't select netowrk in the same ess as oldest if it's new enough*/
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldest == NULL || time_after(oldest->last_scanned, pnetwork->last_scanned))
|
|
|
|
oldest = pnetwork;
|
|
|
|
|
|
|
|
plist = get_next(plist);
|
|
|
|
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
/* If we didn't find a match, then get a new network slot to initialize
|
|
|
|
* with this beacon's information */
|
2017-04-07 11:39:45 +00:00
|
|
|
/* if (rtw_end_of_queue_search(phead,plist)== _TRUE) { */
|
|
|
|
if (!target_find) {
|
2016-03-27 17:56:02 +00:00
|
|
|
if (_rtw_queue_empty(&(pmlmepriv->free_bss_pool)) == _TRUE) {
|
|
|
|
/* If there are no more slots, expire the oldest */
|
2017-04-07 11:39:45 +00:00
|
|
|
/* list_del_init(&oldest->list); */
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork = oldest;
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pnetwork == NULL) {
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
#ifdef CONFIG_ANTENNA_DIVERSITY
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_hal_get_odm_var(adapter, HAL_ODM_ANTDIV_SELECT, &(target->PhyInfo.Optimum_antenna), NULL);
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
|
|
|
_rtw_memcpy(&(pnetwork->network), target, get_WLAN_BSSID_EX_sz(target));
|
2017-04-07 11:39:45 +00:00
|
|
|
/* pnetwork->last_scanned = rtw_get_current_time(); */
|
|
|
|
/* variable initialize */
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork->fixed = _FALSE;
|
|
|
|
pnetwork->last_scanned = rtw_get_current_time();
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
pnetwork->network_type = 0;
|
|
|
|
pnetwork->aid = 0;
|
|
|
|
pnetwork->join_res = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
/* bss info not receving from the right channel */
|
|
|
|
if (pnetwork->network.PhyInfo.SignalQuality == 101)
|
|
|
|
pnetwork->network.PhyInfo.SignalQuality = 0;
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
2016-03-27 17:56:02 +00:00
|
|
|
/* Otherwise just pull from the free list */
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pnetwork == NULL) {
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
bssid_ex_sz = get_WLAN_BSSID_EX_sz(target);
|
|
|
|
target->Length = bssid_ex_sz;
|
|
|
|
#ifdef CONFIG_ANTENNA_DIVERSITY
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_hal_get_odm_var(adapter, HAL_ODM_ANTDIV_SELECT, &(target->PhyInfo.Optimum_antenna), NULL);
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
2017-04-07 11:39:45 +00:00
|
|
|
_rtw_memcpy(&(pnetwork->network), target, bssid_ex_sz);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
pnetwork->last_scanned = rtw_get_current_time();
|
|
|
|
|
|
|
|
/* bss info not receving from the right channel */
|
|
|
|
if (pnetwork->network.PhyInfo.SignalQuality == 101)
|
|
|
|
pnetwork->network.PhyInfo.SignalQuality = 0;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_list_insert_tail(&(pnetwork->list), &(queue->queue));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
2016-03-27 17:56:02 +00:00
|
|
|
/* we have an entry and we are going to update it. But this entry may
|
2017-04-07 11:39:45 +00:00
|
|
|
* be already expired. In this case we do the same as we found a new
|
2016-03-27 17:56:02 +00:00
|
|
|
* net and call the new_net handler
|
|
|
|
*/
|
|
|
|
bool update_ie = _TRUE;
|
|
|
|
|
|
|
|
pnetwork->last_scanned = rtw_get_current_time();
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* target.Reserved[0]==1, means that scaned network is a bcn frame. */
|
|
|
|
if ((pnetwork->network.IELength > target->IELength) && (target->Reserved[0] == 1))
|
2016-03-27 17:56:02 +00:00
|
|
|
update_ie = _FALSE;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* probe resp(3) > beacon(1) > probe req(2) */
|
2016-03-27 17:56:02 +00:00
|
|
|
if ((target->Reserved[0] != 2) &&
|
2017-04-07 11:39:45 +00:00
|
|
|
(target->Reserved[0] >= pnetwork->network.Reserved[0])
|
|
|
|
)
|
2016-03-27 17:56:02 +00:00
|
|
|
update_ie = _TRUE;
|
2017-04-07 11:39:45 +00:00
|
|
|
else
|
2016-03-27 17:56:02 +00:00
|
|
|
update_ie = _FALSE;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
update_network(&(pnetwork->network), target, adapter, update_ie);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
_exit_critical_bh(&queue->lock, &irqL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_add_network(_adapter *adapter, WLAN_BSSID_EX *pnetwork);
|
|
|
|
void rtw_add_network(_adapter *adapter, WLAN_BSSID_EX *pnetwork)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
struct mlme_priv *pmlmepriv = &(((_adapter *)adapter)->mlmepriv);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _queue *queue = &(pmlmepriv->scanned_queue); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _enter_critical_bh(&queue->lock, &irqL); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#if defined(CONFIG_P2P) && defined(CONFIG_P2P_REMOVE_GROUP_INFO)
|
2016-03-27 17:56:02 +00:00
|
|
|
if (adapter->registrypriv.wifi_spec == 0)
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_bss_ex_del_p2p_attr(pnetwork, P2P_ATTR_GROUP_INFO);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!hal_chk_wl_func(adapter, WL_FUNC_MIRACAST))
|
|
|
|
rtw_bss_ex_del_wfd_ie(pnetwork);
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
update_current_network(adapter, pnetwork);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_update_scanned_network(adapter, pnetwork);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _exit_critical_bh(&queue->lock, &irqL); */
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* select the desired network based on the capability of the (i)bss.
|
|
|
|
* check items: (1) security
|
|
|
|
* (2) network_type
|
|
|
|
* (3) WMM
|
|
|
|
* (4) HT
|
|
|
|
* (5) others */
|
2016-03-27 17:56:02 +00:00
|
|
|
int rtw_is_desired_network(_adapter *adapter, struct wlan_network *pnetwork);
|
|
|
|
int rtw_is_desired_network(_adapter *adapter, struct wlan_network *pnetwork)
|
|
|
|
{
|
|
|
|
struct security_priv *psecuritypriv = &adapter->securitypriv;
|
|
|
|
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
|
|
|
u32 desired_encmode;
|
|
|
|
u32 privacy;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* u8 wps_ie[512]; */
|
2016-03-27 17:56:02 +00:00
|
|
|
uint wps_ielen;
|
|
|
|
|
|
|
|
int bselected = _TRUE;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
desired_encmode = psecuritypriv->ndisencryptstatus;
|
|
|
|
privacy = pnetwork->network.Privacy;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
|
|
|
|
if (rtw_get_wps_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, pnetwork->network.IELength - _FIXED_IE_LENGTH_, NULL, &wps_ielen) != NULL)
|
2016-03-27 17:56:02 +00:00
|
|
|
return _TRUE;
|
|
|
|
else
|
|
|
|
return _FALSE;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
if (adapter->registrypriv.wifi_spec == 1) { /* for correct flow of 8021X to do.... */
|
|
|
|
u8 *p = NULL;
|
|
|
|
uint ie_len = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if ((desired_encmode == Ndis802_11EncryptionDisabled) && (privacy != 0))
|
2017-04-07 11:39:45 +00:00
|
|
|
bselected = _FALSE;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) {
|
2016-03-27 17:56:02 +00:00
|
|
|
p = rtw_get_ie(pnetwork->network.IEs + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pnetwork->network.IELength - _BEACON_IE_OFFSET_));
|
2017-04-07 11:39:45 +00:00
|
|
|
if (p && ie_len > 0)
|
2016-03-27 17:56:02 +00:00
|
|
|
bselected = _TRUE;
|
2017-04-07 11:39:45 +00:00
|
|
|
else
|
2016-03-27 17:56:02 +00:00
|
|
|
bselected = _FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) {
|
|
|
|
RTW_INFO("desired_encmode: %d, privacy: %d\n", desired_encmode, privacy);
|
2016-03-27 17:56:02 +00:00
|
|
|
bselected = _FALSE;
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE) {
|
|
|
|
if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode)
|
2016-03-27 17:56:02 +00:00
|
|
|
bselected = _FALSE;
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
return bselected;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: Perry : For Power Management */
|
|
|
|
void rtw_atimdone_event_callback(_adapter *adapter , u8 *pbuf)
|
|
|
|
{
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
return;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void rtw_survey_event_callback(_adapter *adapter, u8 *pbuf)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
u32 len;
|
|
|
|
WLAN_BSSID_EX *pnetwork;
|
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
|
|
|
|
|
|
|
|
|
|
|
pnetwork = (WLAN_BSSID_EX *)pbuf;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8712
|
2017-04-07 11:39:45 +00:00
|
|
|
/* endian_convert */
|
|
|
|
pnetwork->Length = le32_to_cpu(pnetwork->Length);
|
|
|
|
pnetwork->Ssid.SsidLength = le32_to_cpu(pnetwork->Ssid.SsidLength);
|
|
|
|
pnetwork->Privacy = le32_to_cpu(pnetwork->Privacy);
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork->Rssi = le32_to_cpu(pnetwork->Rssi);
|
2017-04-07 11:39:45 +00:00
|
|
|
pnetwork->NetworkTypeInUse = le32_to_cpu(pnetwork->NetworkTypeInUse);
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork->Configuration.ATIMWindow = le32_to_cpu(pnetwork->Configuration.ATIMWindow);
|
|
|
|
pnetwork->Configuration.BeaconPeriod = le32_to_cpu(pnetwork->Configuration.BeaconPeriod);
|
2017-04-07 11:39:45 +00:00
|
|
|
pnetwork->Configuration.DSConfig = le32_to_cpu(pnetwork->Configuration.DSConfig);
|
|
|
|
pnetwork->Configuration.FHConfig.DwellTime = le32_to_cpu(pnetwork->Configuration.FHConfig.DwellTime);
|
|
|
|
pnetwork->Configuration.FHConfig.HopPattern = le32_to_cpu(pnetwork->Configuration.FHConfig.HopPattern);
|
|
|
|
pnetwork->Configuration.FHConfig.HopSet = le32_to_cpu(pnetwork->Configuration.FHConfig.HopSet);
|
|
|
|
pnetwork->Configuration.FHConfig.Length = le32_to_cpu(pnetwork->Configuration.FHConfig.Length);
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork->Configuration.Length = le32_to_cpu(pnetwork->Configuration.Length);
|
|
|
|
pnetwork->InfrastructureMode = le32_to_cpu(pnetwork->InfrastructureMode);
|
|
|
|
pnetwork->IELength = le32_to_cpu(pnetwork->IELength);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
len = get_WLAN_BSSID_EX_sz(pnetwork);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (len > (sizeof(WLAN_BSSID_EX))) {
|
2016-03-27 17:56:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* update IBSS_network 's timestamp */
|
|
|
|
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == _TRUE) {
|
|
|
|
if (_rtw_memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) {
|
|
|
|
struct wlan_network *ibss_wlan = NULL;
|
2016-03-27 17:56:02 +00:00
|
|
|
_irqL irqL;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_rtw_memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8);
|
|
|
|
_enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->MacAddress);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (ibss_wlan) {
|
|
|
|
_rtw_memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8);
|
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* lock pmlmepriv->lock when you accessing network_q */
|
|
|
|
if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == _FALSE) {
|
|
|
|
if (pnetwork->Ssid.Ssid[0] == 0)
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork->Ssid.SsidLength = 0;
|
|
|
|
rtw_add_network(adapter, pnetwork);
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
return;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_surveydone_event_callback(_adapter *adapter, u8 *pbuf)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
u8 timer_cancelled;
|
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
|
|
|
|
|
|
|
#ifdef CONFIG_MLME_EXT
|
|
|
|
mlmeext_surveydone_event_callback(adapter);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
if (pmlmepriv->wps_probe_req_ie) {
|
|
|
|
u32 free_len = pmlmepriv->wps_probe_req_ie_len;
|
|
|
|
pmlmepriv->wps_probe_req_ie_len = 0;
|
|
|
|
rtw_mfree(pmlmepriv->wps_probe_req_ie, free_len);
|
|
|
|
pmlmepriv->wps_probe_req_ie = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == _FALSE) {
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT" fw_state:0x%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv));
|
|
|
|
/* rtw_warn_on(1); */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
|
|
|
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
|
|
|
|
_cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled);
|
|
|
|
|
|
|
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_set_signal_stat_timer(&adapter->recvpriv);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pmlmepriv->to_join == _TRUE) {
|
|
|
|
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE)) {
|
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED) == _FALSE) {
|
|
|
|
set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
|
|
|
|
|
|
|
|
if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS)
|
2016-03-27 17:56:02 +00:00
|
|
|
_set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
|
2017-04-07 11:39:45 +00:00
|
|
|
else {
|
|
|
|
WLAN_BSSID_EX *pdev_network = &(adapter->registrypriv.dev_network);
|
2016-03-27 17:56:02 +00:00
|
|
|
u8 *pibss = adapter->registrypriv.dev_network.MacAddress;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* pmlmepriv->fw_state ^= _FW_UNDER_SURVEY; */ /* because don't set assoc_timer */
|
2016-03-27 17:56:02 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_rtw_memset(&pdev_network->Ssid, 0, sizeof(NDIS_802_11_SSID));
|
|
|
|
_rtw_memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(NDIS_802_11_SSID));
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_update_registrypriv_dev_network(adapter);
|
|
|
|
rtw_generate_random_ibss(pibss);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/*pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;*/
|
|
|
|
init_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
if (rtw_create_ibss_cmd(adapter, 0) != _SUCCESS)
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_ERR("rtw_create_ibss_cmd FAIL\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
pmlmepriv->to_join = _FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2016-03-27 17:56:02 +00:00
|
|
|
int s_ret;
|
|
|
|
set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
|
|
|
|
pmlmepriv->to_join = _FALSE;
|
2017-04-07 11:39:45 +00:00
|
|
|
s_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv);
|
|
|
|
if (_SUCCESS == s_ret)
|
|
|
|
_set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
|
|
|
|
else if (s_ret == 2) { /* there is no need to wait for join */
|
2016-03-27 17:56:02 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
|
|
|
|
rtw_indicate_connect(adapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
|
|
|
RTW_INFO("try_to_join, but select scanning queue fail, to_roam:%d\n", rtw_to_roam(adapter));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if (rtw_to_roam(adapter) != 0) {
|
2017-04-07 11:39:45 +00:00
|
|
|
if (rtw_dec_to_roam(adapter) == 0
|
|
|
|
|| _SUCCESS != rtw_sitesurvey_cmd(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0)
|
|
|
|
) {
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_set_to_roam(adapter, 0);
|
|
|
|
rtw_free_assoc_resources(adapter, 1);
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_indicate_disconnect(adapter, 0, _FALSE);
|
|
|
|
} else
|
2016-03-27 17:56:02 +00:00
|
|
|
pmlmepriv->to_join = _TRUE;
|
2017-04-07 11:39:45 +00:00
|
|
|
} else
|
|
|
|
rtw_indicate_disconnect(adapter, 0, _FALSE);
|
2016-03-27 17:56:02 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (rtw_chk_roam_flags(adapter, RTW_ROAM_ACTIVE)) {
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)
|
2017-04-07 11:39:45 +00:00
|
|
|
&& check_fwstate(pmlmepriv, _FW_LINKED)) {
|
2016-03-27 17:56:02 +00:00
|
|
|
if (rtw_select_roaming_candidate(pmlmepriv) == _SUCCESS) {
|
|
|
|
receive_disconnect(adapter, pmlmepriv->cur_network.network.MacAddress
|
2017-04-07 11:39:45 +00:00
|
|
|
, WLAN_REASON_ACTIVE_ROAM, _FALSE);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
/* RTW_INFO("scan complete in %dms\n",rtw_get_passing_time_ms(pmlmepriv->scan_start_time)); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
|
|
|
|
#ifdef CONFIG_P2P_PS
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE)
|
2016-03-27 17:56:02 +00:00
|
|
|
p2p_ps_wk_cmd(adapter, P2P_PS_SCAN_DONE, 0);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_P2P_PS */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_mi_os_xmit_schedule(adapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_DRVEXT_MODULE_WSC
|
|
|
|
drvext_surveydone_callback(&adapter->drvextpriv);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DBG_CONFIG_ERROR_DETECT
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
|
|
|
|
if (pmlmeext->sitesurvey_res.bss_cnt == 0) {
|
|
|
|
/* rtw_hal_sreset_reset(adapter); */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_IOCTL_CFG80211
|
|
|
|
rtw_cfg80211_surveydone_event_callback(adapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_IOCTL_CFG80211 */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
rtw_indicate_scan_done(adapter, _FALSE);
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_CONCURRENT_MODE
|
|
|
|
rtw_mi_buddy_indicate_scan_done(adapter, _FALSE);/*scanning_via_buddy_intf*/
|
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_dummy_event_callback(_adapter *adapter , u8 *pbuf)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_fwdbg_event_callback(_adapter *adapter , u8 *pbuf)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_scanqueue(struct mlme_priv *pmlmepriv)
|
|
|
|
{
|
|
|
|
_irqL irqL, irqL0;
|
|
|
|
_queue *free_queue = &pmlmepriv->free_bss_pool;
|
|
|
|
_queue *scan_queue = &pmlmepriv->scanned_queue;
|
|
|
|
_list *plist, *phead, *ptemp;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_enter_critical_bh(&scan_queue->lock, &irqL0);
|
|
|
|
_enter_critical_bh(&free_queue->lock, &irqL);
|
|
|
|
|
|
|
|
phead = get_list_head(scan_queue);
|
|
|
|
plist = get_next(phead);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
while (plist != phead) {
|
2016-03-27 17:56:02 +00:00
|
|
|
ptemp = get_next(plist);
|
|
|
|
rtw_list_delete(plist);
|
|
|
|
rtw_list_insert_tail(plist, &free_queue->queue);
|
2017-04-07 11:39:45 +00:00
|
|
|
plist = ptemp;
|
|
|
|
pmlmepriv->num_of_scanned--;
|
|
|
|
}
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_exit_critical_bh(&free_queue->lock, &irqL);
|
|
|
|
_exit_critical_bh(&scan_queue->lock, &irqL0);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_reset_rx_info(struct debug_priv *pdbgpriv)
|
|
|
|
{
|
2016-03-27 17:56:02 +00:00
|
|
|
pdbgpriv->dbg_rx_ampdu_drop_count = 0;
|
|
|
|
pdbgpriv->dbg_rx_ampdu_forced_indicate_count = 0;
|
|
|
|
pdbgpriv->dbg_rx_ampdu_loss_count = 0;
|
|
|
|
pdbgpriv->dbg_rx_dup_mgt_frame_drop_count = 0;
|
|
|
|
pdbgpriv->dbg_rx_ampdu_window_shift_cnt = 0;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
/*
|
|
|
|
*rtw_free_assoc_resources: the caller has to lock pmlmepriv->lock
|
|
|
|
*/
|
|
|
|
void rtw_free_assoc_resources(_adapter *adapter, int lock_scanned_queue)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct wlan_network *pwlan = NULL;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
|
|
|
struct sta_priv *pstapriv = &adapter->stapriv;
|
|
|
|
struct wlan_network *tgt_network = &pmlmepriv->cur_network;
|
|
|
|
struct dvobj_priv *psdpriv = adapter->dvobj;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_TDLS
|
|
|
|
struct tdls_info *ptdlsinfo = &adapter->tdlsinfo;
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_TDLS */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
RTW_INFO("%s-"ADPT_FMT" tgt_network MacAddress=" MAC_FMT"ssid=%s\n",
|
|
|
|
__func__, ADPT_ARG(adapter), MAC_ARG(tgt_network->network.MacAddress), tgt_network->network.Ssid.Ssid);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
|
2017-04-07 11:39:45 +00:00
|
|
|
struct sta_info *psta;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.MacAddress);
|
|
|
|
|
|
|
|
#ifdef CONFIG_TDLS
|
|
|
|
if (ptdlsinfo->link_established == _TRUE) {
|
|
|
|
rtw_tdls_cmd(adapter, NULL, TDLS_RS_RCR);
|
|
|
|
rtw_reset_tdls_info(adapter);
|
|
|
|
rtw_free_all_stainfo(adapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */
|
|
|
|
} else
|
|
|
|
#endif /* CONFIG_TDLS */
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_free_stainfo(adapter, psta);
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) {
|
|
|
|
struct sta_info *psta;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_free_all_stainfo(adapter);
|
|
|
|
|
|
|
|
psta = rtw_get_bcmc_stainfo(adapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_free_stainfo(adapter, psta);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_init_bcmc_stainfo(adapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (lock_scanned_queue)
|
2016-03-27 17:56:02 +00:00
|
|
|
_enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pwlan = _rtw_find_same_network(&pmlmepriv->scanned_queue, tgt_network);
|
2017-04-07 11:39:45 +00:00
|
|
|
if ((pwlan) && (!check_fwstate(pmlmepriv, WIFI_UNDER_WPS))) {
|
2016-03-27 17:56:02 +00:00
|
|
|
pwlan->fixed = _FALSE;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("free disconnecting network of scanned_queue\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_free_network_nolock(adapter, pwlan);
|
|
|
|
#ifdef CONFIG_P2P
|
2017-04-07 11:39:45 +00:00
|
|
|
if (!rtw_p2p_chk_state(&adapter->wdinfo, P2P_STATE_NONE)) {
|
|
|
|
rtw_mi_set_scan_deny(adapter, 2000);
|
|
|
|
/* rtw_clear_scan_deny(adapter); */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
|
|
|
} else {
|
|
|
|
if (pwlan == NULL)
|
|
|
|
RTW_INFO("free disconnecting network of scanned_queue failed due to pwlan== NULL\n\n");
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS))
|
|
|
|
RTW_INFO("donot free disconnecting network of scanned_queue when WIFI_UNDER_WPS\n\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1))
|
|
|
|
/*||check_fwstate(pmlmepriv, WIFI_STATION_STATE)*/) {
|
2016-03-27 17:56:02 +00:00
|
|
|
if (pwlan)
|
|
|
|
rtw_free_network_nolock(adapter, pwlan);
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (lock_scanned_queue)
|
2016-03-27 17:56:02 +00:00
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
adapter->securitypriv.key_mask = 0;
|
|
|
|
|
|
|
|
rtw_reset_rx_info(pdbgpriv);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*rtw_indicate_connect: the caller has to lock pmlmepriv->lock
|
|
|
|
*/
|
|
|
|
void rtw_indicate_connect(_adapter *padapter)
|
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
pmlmepriv->to_join = _FALSE;
|
|
|
|
|
|
|
|
if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
set_fwstate(pmlmepriv, _FW_LINKED);
|
|
|
|
|
|
|
|
rtw_led_control(padapter, LED_CTL_LINK);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
#ifdef CONFIG_DRVEXT_MODULE
|
2017-04-07 11:39:45 +00:00
|
|
|
if (padapter->drvextpriv.enable_wpa)
|
2016-03-27 17:56:02 +00:00
|
|
|
indicate_l2_connect(padapter);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
rtw_os_indicate_connect(padapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rtw_set_to_roam(padapter, 0);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (!check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))
|
|
|
|
rtw_mi_set_scan_deny(padapter, 3000);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*rtw_indicate_disconnect: the caller has to lock pmlmepriv->lock
|
|
|
|
*/
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_indicate_disconnect(_adapter *padapter, u16 reason, u8 locally_generated)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
WLAN_BSSID_EX *cur_network = &(pmlmeinfo->network);
|
|
|
|
struct sta_info *psta;
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 *wps_ie = NULL;
|
|
|
|
uint wpsie_len = 0;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING | WIFI_UNDER_WPS);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* force to clear cur_network_scanned's SELECTED REGISTRAR */
|
2016-03-27 17:56:02 +00:00
|
|
|
if (pmlmepriv->cur_network_scanned) {
|
|
|
|
WLAN_BSSID_EX *current_joined_bss = &(pmlmepriv->cur_network_scanned->network);
|
|
|
|
if (current_joined_bss) {
|
2017-04-07 11:39:45 +00:00
|
|
|
wps_ie = rtw_get_wps_ie(current_joined_bss->IEs + _FIXED_IE_LENGTH_,
|
|
|
|
current_joined_bss->IELength - _FIXED_IE_LENGTH_, NULL, &wpsie_len);
|
|
|
|
if (wps_ie && wpsie_len > 0) {
|
2016-03-27 17:56:02 +00:00
|
|
|
u8 *attr = NULL;
|
|
|
|
u32 attr_len;
|
2017-04-07 11:39:45 +00:00
|
|
|
attr = rtw_get_wps_attr(wps_ie, wpsie_len, WPS_ATTR_SELECTED_REGISTRAR,
|
|
|
|
NULL, &attr_len);
|
2016-03-27 17:56:02 +00:00
|
|
|
if (attr)
|
|
|
|
*(attr + 4) = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
/* RTW_INFO("clear wps when %s\n", __func__); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (rtw_to_roam(padapter) > 0)
|
2016-03-27 17:56:02 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_LINKED);
|
|
|
|
|
|
|
|
#ifdef CONFIG_WAPI_SUPPORT
|
2017-04-07 11:39:45 +00:00
|
|
|
psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress);
|
2016-03-27 17:56:02 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
|
|
|
|
rtw_wapi_return_one_sta_info(padapter, psta->hwaddr);
|
|
|
|
else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
|
2017-04-07 11:39:45 +00:00
|
|
|
check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_wapi_return_all_sta_info(padapter);
|
|
|
|
#endif
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)
|
|
|
|
|| (rtw_to_roam(padapter) <= 0)
|
|
|
|
) {
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_os_indicate_disconnect(padapter, reason, locally_generated);
|
|
|
|
|
|
|
|
/* set ips_deny_time to avoid enter IPS before LPS leave */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_set_ips_deny(padapter, 3000);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_LINKED);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
rtw_led_control(padapter, LED_CTL_NO_LINK);
|
|
|
|
|
|
|
|
rtw_clear_scan_deny(padapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_P2P_PS
|
|
|
|
p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_P2P_PS */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_LPS
|
|
|
|
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_BEAMFORMING
|
|
|
|
beamforming_wk_cmd(padapter, BEAMFORMING_CTRL_LEAVE, cur_network->MacAddress, ETH_ALEN, 1);
|
|
|
|
#endif /*CONFIG_BEAMFORMING*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
inline void rtw_indicate_scan_done(_adapter *padapter, bool aborted)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
rtw_os_indicate_scan_done(padapter, aborted);
|
|
|
|
|
|
|
|
#ifdef CONFIG_IPS
|
|
|
|
if (is_primary_adapter(padapter)
|
2017-04-07 11:39:45 +00:00
|
|
|
&& (_FALSE == adapter_to_pwrctl(padapter)->bInSuspend)
|
|
|
|
&& (check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE | WIFI_UNDER_LINKING) == _FALSE)) {
|
2016-03-27 17:56:02 +00:00
|
|
|
struct pwrctrl_priv *pwrpriv;
|
|
|
|
|
|
|
|
pwrpriv = adapter_to_pwrctl(padapter);
|
|
|
|
rtw_set_ips_deny(padapter, 0);
|
|
|
|
#ifdef CONFIG_IPS_CHECK_IN_WD
|
2017-04-07 11:39:45 +00:00
|
|
|
_set_timer(&adapter_to_dvobj(padapter)->dynamic_chk_timer, 1);
|
|
|
|
#else /* !CONFIG_IPS_CHECK_IN_WD */
|
2016-03-27 17:56:02 +00:00
|
|
|
_rtw_set_pwr_state_check_timer(pwrpriv, 1);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* !CONFIG_IPS_CHECK_IN_WD */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_IPS */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u32 _rtw_wait_scan_done(_adapter *adapter, u8 abort, u32 timeout_ms)
|
|
|
|
{
|
|
|
|
u32 start;
|
|
|
|
u32 pass_ms;
|
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &(adapter->mlmeextpriv);
|
|
|
|
|
|
|
|
start = rtw_get_current_time();
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pmlmeext->scan_abort = abort;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)
|
2017-04-07 11:39:45 +00:00
|
|
|
&& rtw_get_passing_time_ms(start) <= timeout_ms) {
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if (RTW_CANNOT_RUN(adapter))
|
|
|
|
break;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO(FUNC_NDEV_FMT"fw_state=_FW_UNDER_SURVEY!\n", FUNC_NDEV_ARG(adapter->pnetdev));
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_msleep_os(20);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_TRUE == abort) {
|
|
|
|
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
|
|
|
|
if (!RTW_CANNOT_RUN(adapter))
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev));
|
|
|
|
#ifdef CONFIG_PLATFORM_MSTAR
|
2016-03-27 17:56:02 +00:00
|
|
|
/*_clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);*/
|
|
|
|
set_survey_timer(pmlmeext, 0);
|
|
|
|
mlme_set_scan_to_timer(pmlmepriv, 50);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_indicate_scan_done(adapter, _TRUE);
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pmlmeext->scan_abort = _FALSE;
|
|
|
|
pass_ms = rtw_get_passing_time_ms(start);
|
|
|
|
|
|
|
|
return pass_ms;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_scan_wait_completed(_adapter *adapter)
|
|
|
|
{
|
|
|
|
u32 scan_to = SCANNING_TIMEOUT;
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCAN_BACKOP
|
2017-04-07 11:39:45 +00:00
|
|
|
if (IsSupported5G(adapter->registrypriv.wireless_mode)
|
|
|
|
&& IsSupported24G(adapter->registrypriv.wireless_mode)) /*dual band*/
|
2016-03-27 17:56:02 +00:00
|
|
|
scan_to = CONC_SCANNING_TIMEOUT_DUAL_BAND;
|
|
|
|
else /*single band*/
|
|
|
|
scan_to = CONC_SCANNING_TIMEOUT_SINGLE_BAND;
|
|
|
|
#endif /* CONFIG_SCAN_BACKOP */
|
|
|
|
|
|
|
|
_rtw_wait_scan_done(adapter, _FALSE, scan_to);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 rtw_scan_abort_timeout(_adapter *adapter, u32 timeout_ms)
|
|
|
|
{
|
|
|
|
return _rtw_wait_scan_done(adapter, _TRUE, timeout_ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_scan_abort_no_wait(_adapter *adapter)
|
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &(adapter->mlmeextpriv);
|
|
|
|
|
|
|
|
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
|
|
|
|
pmlmeext->scan_abort = _TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_scan_abort(_adapter *adapter)
|
|
|
|
{
|
|
|
|
rtw_scan_abort_timeout(adapter, 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sta_info *rtw_joinbss_update_stainfo(_adapter *padapter, struct wlan_network *pnetwork)
|
|
|
|
{
|
|
|
|
int i;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct sta_info *bmc_sta, *psta = NULL;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct recv_reorder_ctrl *preorder_ctrl;
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
|
|
|
|
psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (psta == NULL)
|
2016-03-27 17:56:02 +00:00
|
|
|
psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (psta) { /* update ptarget_sta */
|
|
|
|
RTW_INFO("%s\n", __FUNCTION__);
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
psta->aid = pnetwork->join_res;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#if 0 /* alloc macid when call rtw_alloc_stainfo(), and release macid when call rtw_free_stainfo() */
|
|
|
|
#ifdef CONFIG_CONCURRENT_MODE
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (PRIMARY_ADAPTER == padapter->adapter_type)
|
|
|
|
psta->mac_id = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
else
|
2017-04-07 11:39:45 +00:00
|
|
|
psta->mac_id = 2;
|
2016-03-27 17:56:02 +00:00
|
|
|
#else
|
2017-04-07 11:39:45 +00:00
|
|
|
psta->mac_id = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* removed */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
update_sta_info(padapter, psta);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* update station supportRate */
|
2016-03-27 17:56:02 +00:00
|
|
|
psta->bssratelen = rtw_get_rateset_len(pnetwork->network.SupportedRates);
|
|
|
|
_rtw_memcpy(psta->bssrateset, pnetwork->network.SupportedRates, psta->bssratelen);
|
|
|
|
rtw_hal_update_sta_rate_mask(padapter, psta);
|
|
|
|
|
|
|
|
psta->wireless_mode = pmlmeext->cur_wireless_mode;
|
2017-04-07 11:39:45 +00:00
|
|
|
psta->raid = rtw_hal_networktype_to_raid(padapter, psta);
|
|
|
|
|
|
|
|
|
|
|
|
/* sta mode */
|
|
|
|
rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, _TRUE);
|
|
|
|
|
|
|
|
/* security related */
|
|
|
|
if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
|
|
|
|
padapter->securitypriv.binstallGrpkey = _FALSE;
|
|
|
|
padapter->securitypriv.busetkipkey = _FALSE;
|
|
|
|
padapter->securitypriv.bgrpkey_handshake = _FALSE;
|
|
|
|
|
|
|
|
psta->ieee8021x_blocked = _TRUE;
|
|
|
|
psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
|
|
|
|
|
|
|
|
_rtw_memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof(union Keytype));
|
|
|
|
|
|
|
|
_rtw_memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof(union Keytype));
|
|
|
|
_rtw_memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof(union Keytype));
|
|
|
|
|
|
|
|
_rtw_memset((u8 *)&psta->dot11txpn, 0, sizeof(union pn48));
|
2016-03-27 17:56:02 +00:00
|
|
|
psta->dot11txpn.val = psta->dot11txpn.val + 1;
|
|
|
|
#ifdef CONFIG_IEEE80211W
|
2017-04-07 11:39:45 +00:00
|
|
|
_rtw_memset((u8 *)&psta->dot11wtxpn, 0, sizeof(union pn48));
|
|
|
|
#endif /* CONFIG_IEEE80211W */
|
|
|
|
_rtw_memset((u8 *)&psta->dot11rxpn, 0, sizeof(union pn48));
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* Commented by Albert 2012/07/21 */
|
|
|
|
/* When doing the WPS, the wps_ie_len won't equal to 0 */
|
|
|
|
/* And the Wi-Fi driver shouldn't allow the data packet to be tramsmitted. */
|
|
|
|
if (padapter->securitypriv.wps_ie_len != 0) {
|
|
|
|
psta->ieee8021x_blocked = _TRUE;
|
2016-03-27 17:56:02 +00:00
|
|
|
padapter->securitypriv.wps_ie_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */
|
|
|
|
/* if A-MPDU Rx is enabled, reseting rx_ordering_ctrl wstart_b(indicate_seq) to default value=0xffff */
|
|
|
|
/* todo: check if AP can send A-MPDU packets */
|
|
|
|
for (i = 0; i < 16 ; i++) {
|
|
|
|
/* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */
|
2016-03-27 17:56:02 +00:00
|
|
|
preorder_ctrl = &psta->recvreorder_ctrl[i];
|
|
|
|
preorder_ctrl->enable = _FALSE;
|
|
|
|
preorder_ctrl->indicate_seq = 0xffff;
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef DBG_RX_SEQ
|
|
|
|
RTW_INFO("DBG_RX_SEQ %s:%d indicate_seq:%u\n", __FUNCTION__, __LINE__,
|
|
|
|
preorder_ctrl->indicate_seq);
|
|
|
|
#endif
|
|
|
|
preorder_ctrl->wend_b = 0xffff;
|
|
|
|
preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; */ /* ex. 32(kbytes) -> wsize_b=32 */
|
2016-03-27 17:56:02 +00:00
|
|
|
preorder_ctrl->ampdu_size = RX_AMPDU_SIZE_INVALID;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
bmc_sta = rtw_get_bcmc_stainfo(padapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (bmc_sta) {
|
|
|
|
for (i = 0; i < 16 ; i++) {
|
|
|
|
/* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */
|
2016-03-27 17:56:02 +00:00
|
|
|
preorder_ctrl = &bmc_sta->recvreorder_ctrl[i];
|
|
|
|
preorder_ctrl->enable = _FALSE;
|
|
|
|
preorder_ctrl->indicate_seq = 0xffff;
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef DBG_RX_SEQ
|
|
|
|
RTW_INFO("DBG_RX_SEQ %s:%d indicate_seq:%u\n", __FUNCTION__, __LINE__,
|
|
|
|
preorder_ctrl->indicate_seq);
|
|
|
|
#endif
|
|
|
|
preorder_ctrl->wend_b = 0xffff;
|
|
|
|
preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; */ /* ex. 32(kbytes) -> wsize_b=32 */
|
2016-03-27 17:56:02 +00:00
|
|
|
preorder_ctrl->ampdu_size = RX_AMPDU_SIZE_INVALID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
return psta;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* pnetwork : returns from rtw_joinbss_event_callback
|
|
|
|
* ptarget_wlan: found from scanned_queue */
|
2016-03-27 17:56:02 +00:00
|
|
|
static void rtw_joinbss_update_network(_adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network *pnetwork)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2016-03-27 17:56:02 +00:00
|
|
|
struct wlan_network *cur_network = &(pmlmepriv->cur_network);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("%s\n", __FUNCTION__);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* why not use ptarget_wlan?? */
|
2016-03-27 17:56:02 +00:00
|
|
|
_rtw_memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */
|
2016-03-27 17:56:02 +00:00
|
|
|
cur_network->network.IELength = ptarget_wlan->network.IELength;
|
|
|
|
_rtw_memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], MAX_IE_SZ);
|
|
|
|
|
|
|
|
cur_network->aid = pnetwork->join_res;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
#ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
|
|
|
|
rtw_set_signal_stat_timer(&padapter->recvpriv);
|
|
|
|
#endif
|
|
|
|
padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength;
|
|
|
|
padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality;
|
2017-04-07 11:39:45 +00:00
|
|
|
/* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */
|
2016-03-27 17:56:02 +00:00
|
|
|
padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength);
|
2017-04-07 11:39:45 +00:00
|
|
|
#if defined(DBG_RX_SIGNAL_DISPLAY_PROCESSING) && 1
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT" signal_strength:%3u, rssi:%3d, signal_qual:%3u"
|
|
|
|
"\n"
|
|
|
|
, FUNC_ADPT_ARG(padapter)
|
|
|
|
, padapter->recvpriv.signal_strength
|
|
|
|
, padapter->recvpriv.rssi
|
|
|
|
, padapter->recvpriv.signal_qual
|
|
|
|
);
|
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
#ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
|
|
|
|
rtw_set_signal_stat_timer(&padapter->recvpriv);
|
|
|
|
#endif
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
/* update fw_state */ /* will clr _FW_UNDER_LINKING here indirectly */
|
|
|
|
|
|
|
|
switch (pnetwork->network.InfrastructureMode) {
|
|
|
|
case Ndis802_11Infrastructure:
|
|
|
|
|
|
|
|
if (pmlmepriv->fw_state & WIFI_UNDER_WPS)
|
|
|
|
/*pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS;*/
|
|
|
|
init_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_UNDER_WPS);
|
|
|
|
else
|
|
|
|
/*pmlmepriv->fw_state = WIFI_STATION_STATE;*/
|
|
|
|
init_fwstate(pmlmepriv, WIFI_STATION_STATE);
|
|
|
|
break;
|
|
|
|
case Ndis802_11IBSS:
|
|
|
|
/*pmlmepriv->fw_state = WIFI_ADHOC_STATE;*/
|
|
|
|
init_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/*pmlmepriv->fw_state = WIFI_NULL_STATE;*/
|
|
|
|
init_fwstate(pmlmepriv, WIFI_NULL_STATE);
|
|
|
|
break;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_update_protection(padapter, (cur_network->network.IEs) + sizeof(NDIS_802_11_FIXED_IEs),
|
|
|
|
(cur_network->network.IELength));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_80211N_HT
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_update_ht_cap(padapter, cur_network->network.IEs, cur_network->network.IELength, (u8) cur_network->network.Configuration.DSConfig);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* Notes: the fucntion could be > passive_level (the same context as Rx tasklet)
|
|
|
|
* pnetwork : returns from rtw_joinbss_event_callback
|
|
|
|
* ptarget_wlan: found from scanned_queue
|
|
|
|
* if join_res > 0, for (fw_state==WIFI_STATION_STATE), we check if "ptarget_sta" & "ptarget_wlan" exist.
|
|
|
|
* if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), we only check if "ptarget_wlan" exist.
|
|
|
|
* if join_res > 0, update "cur_network->network" from "pnetwork->network" if (ptarget_wlan !=NULL).
|
|
|
|
*/
|
|
|
|
/* #define REJOIN */
|
2016-03-27 17:56:02 +00:00
|
|
|
void rtw_joinbss_event_prehandle(_adapter *adapter, u8 *pbuf)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
_irqL irqL, irqL2;
|
|
|
|
static u8 retry = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
u8 timer_cancelled;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL;
|
|
|
|
struct sta_priv *pstapriv = &adapter->stapriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
2017-04-07 11:39:45 +00:00
|
|
|
struct wlan_network *pnetwork = (struct wlan_network *)pbuf;
|
|
|
|
struct wlan_network *cur_network = &(pmlmepriv->cur_network);
|
2016-03-27 17:56:02 +00:00
|
|
|
struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL;
|
2017-04-07 11:39:45 +00:00
|
|
|
unsigned int the_same_macaddr = _FALSE;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8712
|
2017-04-07 11:39:45 +00:00
|
|
|
/* endian_convert */
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork->join_res = le32_to_cpu(pnetwork->join_res);
|
|
|
|
pnetwork->network_type = le32_to_cpu(pnetwork->network_type);
|
|
|
|
pnetwork->network.Length = le32_to_cpu(pnetwork->network.Length);
|
|
|
|
pnetwork->network.Ssid.SsidLength = le32_to_cpu(pnetwork->network.Ssid.SsidLength);
|
2017-04-07 11:39:45 +00:00
|
|
|
pnetwork->network.Privacy = le32_to_cpu(pnetwork->network.Privacy);
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork->network.Rssi = le32_to_cpu(pnetwork->network.Rssi);
|
2017-04-07 11:39:45 +00:00
|
|
|
pnetwork->network.NetworkTypeInUse = le32_to_cpu(pnetwork->network.NetworkTypeInUse) ;
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork->network.Configuration.ATIMWindow = le32_to_cpu(pnetwork->network.Configuration.ATIMWindow);
|
|
|
|
pnetwork->network.Configuration.BeaconPeriod = le32_to_cpu(pnetwork->network.Configuration.BeaconPeriod);
|
|
|
|
pnetwork->network.Configuration.DSConfig = le32_to_cpu(pnetwork->network.Configuration.DSConfig);
|
2017-04-07 11:39:45 +00:00
|
|
|
pnetwork->network.Configuration.FHConfig.DwellTime = le32_to_cpu(pnetwork->network.Configuration.FHConfig.DwellTime);
|
|
|
|
pnetwork->network.Configuration.FHConfig.HopPattern = le32_to_cpu(pnetwork->network.Configuration.FHConfig.HopPattern);
|
|
|
|
pnetwork->network.Configuration.FHConfig.HopSet = le32_to_cpu(pnetwork->network.Configuration.FHConfig.HopSet);
|
|
|
|
pnetwork->network.Configuration.FHConfig.Length = le32_to_cpu(pnetwork->network.Configuration.FHConfig.Length);
|
2016-03-27 17:56:02 +00:00
|
|
|
pnetwork->network.Configuration.Length = le32_to_cpu(pnetwork->network.Configuration.Length);
|
|
|
|
pnetwork->network.InfrastructureMode = le32_to_cpu(pnetwork->network.InfrastructureMode);
|
2017-04-07 11:39:45 +00:00
|
|
|
pnetwork->network.IELength = le32_to_cpu(pnetwork->network.IELength);
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
rtw_get_encrypt_decrypt_from_registrypriv(adapter);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
the_same_macaddr = _rtw_memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN);
|
|
|
|
|
|
|
|
pnetwork->network.Length = get_WLAN_BSSID_EX_sz(&pnetwork->network);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pnetwork->network.Length > sizeof(WLAN_BSSID_EX)) {
|
2016-03-27 17:56:02 +00:00
|
|
|
goto ignore_joinbss_callback;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 0;
|
|
|
|
pmlmepriv->LinkDetectInfo.LowPowerTransitionCount = 0;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
if (pnetwork->join_res > 0) {
|
2016-03-27 17:56:02 +00:00
|
|
|
_enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
retry = 0;
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
|
|
|
|
/* s1. find ptarget_wlan */
|
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
|
|
|
|
if (the_same_macaddr == _TRUE)
|
|
|
|
ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
|
|
|
|
else {
|
2016-03-27 17:56:02 +00:00
|
|
|
pcur_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pcur_wlan)
|
|
|
|
pcur_wlan->fixed = _FALSE;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
pcur_sta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pcur_sta) {
|
|
|
|
/* _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL2); */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_free_stainfo(adapter, pcur_sta);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL2); */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) {
|
|
|
|
if (ptarget_wlan)
|
|
|
|
ptarget_wlan->fixed = _TRUE;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
2016-03-27 17:56:02 +00:00
|
|
|
ptarget_wlan = _rtw_find_same_network(&pmlmepriv->scanned_queue, pnetwork);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) {
|
|
|
|
if (ptarget_wlan)
|
|
|
|
ptarget_wlan->fixed = _TRUE;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
/* s2. update cur_network */
|
|
|
|
if (ptarget_wlan)
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_joinbss_update_network(adapter, ptarget_wlan, pnetwork);
|
2017-04-07 11:39:45 +00:00
|
|
|
else {
|
|
|
|
RTW_PRINT("Can't find ptarget_wlan when joinbss_event callback\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
goto ignore_joinbss_callback;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) {
|
2016-03-27 17:56:02 +00:00
|
|
|
ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (ptarget_sta == NULL) {
|
|
|
|
RTW_ERR("Can't update stainfo when joinbss_event callback\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
goto ignore_joinbss_callback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* s4. indicate connect */
|
|
|
|
if (MLME_IS_STA(adapter) || MLME_IS_ADHOC(adapter)) {
|
2016-03-27 17:56:02 +00:00
|
|
|
pmlmepriv->cur_network_scanned = ptarget_wlan;
|
|
|
|
rtw_indicate_connect(adapter);
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* s5. Cancle assoc_timer */
|
2016-03-27 17:56:02 +00:00
|
|
|
_cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
} else {
|
2016-03-27 17:56:02 +00:00
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
goto ignore_joinbss_callback;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
|
|
|
|
} else if (pnetwork->join_res == -4) {
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_reset_securitypriv(adapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
_set_timer(&pmlmepriv->assoc_timer, 1);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* rtw_free_assoc_resources(adapter, 1); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == _TRUE) {
|
2016-03-27 17:56:02 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else { /* if join_res < 0 (join fails), then try again */
|
|
|
|
|
|
|
|
#ifdef REJOIN
|
2016-03-27 17:56:02 +00:00
|
|
|
res = _FAIL;
|
2017-04-07 11:39:45 +00:00
|
|
|
if (retry < 2) {
|
2016-03-27 17:56:02 +00:00
|
|
|
res = rtw_select_and_join_from_scanned_queue(pmlmepriv);
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (res == _SUCCESS) {
|
|
|
|
/* extend time of assoc_timer */
|
2016-03-27 17:56:02 +00:00
|
|
|
_set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
|
|
|
|
retry++;
|
2017-04-07 11:39:45 +00:00
|
|
|
} else if (res == 2) { /* there is no need to wait for join */
|
2016-03-27 17:56:02 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
|
|
|
|
rtw_indicate_connect(adapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
|
|
|
#endif
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_set_timer(&pmlmepriv->assoc_timer, 1);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* rtw_free_assoc_resources(adapter, 1); */
|
2016-03-27 17:56:02 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
#ifdef REJOIN
|
|
|
|
retry = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ignore_joinbss_callback:
|
|
|
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_joinbss_event_callback(_adapter *adapter, u8 *pbuf)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct wlan_network *pnetwork = (struct wlan_network *)pbuf;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
mlmeext_joinbss_event_callback(adapter, pnetwork->join_res);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_mi_os_xmit_schedule(adapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_sta_media_status_rpt(_adapter *adapter, struct sta_info *sta, bool connected)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct macid_ctl_t *macid_ctl = &adapter->dvobj->macid_ctl;
|
|
|
|
bool miracast_enabled = 0;
|
|
|
|
bool miracast_sink = 0;
|
|
|
|
u8 role = H2C_MSR_ROLE_RSVD;
|
|
|
|
|
|
|
|
if (sta == NULL) {
|
|
|
|
RTW_PRINT(FUNC_ADPT_FMT" sta is NULL\n"
|
|
|
|
, FUNC_ADPT_ARG(adapter));
|
|
|
|
rtw_warn_on(1);
|
|
|
|
return;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (sta->mac_id >= macid_ctl->num) {
|
|
|
|
RTW_PRINT(FUNC_ADPT_FMT" invalid macid:%u\n"
|
|
|
|
, FUNC_ADPT_ARG(adapter), sta->mac_id);
|
|
|
|
rtw_warn_on(1);
|
|
|
|
return;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (!rtw_macid_is_used(macid_ctl, sta->mac_id)) {
|
|
|
|
RTW_PRINT(FUNC_ADPT_FMT" macid:%u not is used, set connected to 0\n"
|
|
|
|
, FUNC_ADPT_ARG(adapter), sta->mac_id);
|
|
|
|
connected = 0;
|
|
|
|
rtw_warn_on(1);
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (connected && !rtw_macid_is_bmc(macid_ctl, sta->mac_id)) {
|
|
|
|
miracast_enabled = STA_OP_WFD_MODE(sta) != 0 && is_miracast_enabled(adapter);
|
|
|
|
miracast_sink = miracast_enabled && (STA_OP_WFD_MODE(sta) & MIRACAST_SINK);
|
|
|
|
|
|
|
|
#ifdef CONFIG_TDLS
|
|
|
|
if (sta->tdls_sta_state & TDLS_LINKED_STATE)
|
|
|
|
role = H2C_MSR_ROLE_TDLS;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (MLME_IS_STA(adapter)) {
|
|
|
|
if (MLME_IS_GC(adapter))
|
|
|
|
role = H2C_MSR_ROLE_GO;
|
|
|
|
else
|
|
|
|
role = H2C_MSR_ROLE_AP;
|
|
|
|
} else if (MLME_IS_AP(adapter)) {
|
|
|
|
if (MLME_IS_GO(adapter))
|
|
|
|
role = H2C_MSR_ROLE_GC;
|
|
|
|
else
|
|
|
|
role = H2C_MSR_ROLE_STA;
|
|
|
|
} else if (MLME_IS_ADHOC(adapter) || MLME_IS_ADHOC_MASTER(adapter))
|
|
|
|
role = H2C_MSR_ROLE_ADHOC;
|
|
|
|
|
|
|
|
#ifdef CONFIG_WFD
|
|
|
|
if (role == H2C_MSR_ROLE_GC
|
|
|
|
|| role == H2C_MSR_ROLE_GO
|
|
|
|
|| role == H2C_MSR_ROLE_TDLS
|
|
|
|
) {
|
|
|
|
if (adapter->wfd_info.rtsp_ctrlport
|
|
|
|
|| adapter->wfd_info.tdls_rtsp_ctrlport
|
|
|
|
|| adapter->wfd_info.peer_rtsp_ctrlport)
|
|
|
|
rtw_wfd_st_switch(sta, 1);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
rtw_hal_set_FwMediaStatusRpt_single_cmd(adapter
|
|
|
|
, connected
|
|
|
|
, miracast_enabled
|
|
|
|
, miracast_sink
|
|
|
|
, role
|
|
|
|
, sta->mac_id
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 rtw_sta_media_status_rpt_cmd(_adapter *adapter, struct sta_info *sta, bool connected)
|
|
|
|
{
|
|
|
|
struct cmd_priv *cmdpriv = &adapter->cmdpriv;
|
|
|
|
struct cmd_obj *cmdobj;
|
|
|
|
struct drvextra_cmd_parm *cmd_parm;
|
|
|
|
struct sta_media_status_rpt_cmd_parm *rpt_parm;
|
|
|
|
u8 res = _SUCCESS;
|
|
|
|
|
|
|
|
cmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
|
|
|
|
if (cmdobj == NULL) {
|
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
|
|
|
|
if (cmd_parm == NULL) {
|
|
|
|
rtw_mfree((u8 *)cmdobj, sizeof(struct cmd_obj));
|
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rpt_parm = (struct sta_media_status_rpt_cmd_parm *)rtw_zmalloc(sizeof(struct sta_media_status_rpt_cmd_parm));
|
|
|
|
if (rpt_parm == NULL) {
|
|
|
|
rtw_mfree((u8 *)cmdobj, sizeof(struct cmd_obj));
|
|
|
|
rtw_mfree((u8 *)cmd_parm, sizeof(struct drvextra_cmd_parm));
|
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rpt_parm->sta = sta;
|
|
|
|
rpt_parm->connected = connected;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
cmd_parm->ec_id = STA_MSTATUS_RPT_WK_CID;
|
|
|
|
cmd_parm->type = 0;
|
|
|
|
cmd_parm->size = sizeof(struct sta_media_status_rpt_cmd_parm);
|
|
|
|
cmd_parm->pbuf = (u8 *)rpt_parm;
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(cmdobj, cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
res = rtw_enqueue_cmd(cmdpriv, cmdobj);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
exit:
|
|
|
|
return res;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
inline void rtw_sta_media_status_rpt_cmd_hdl(_adapter *adapter, struct sta_media_status_rpt_cmd_parm *parm)
|
|
|
|
{
|
|
|
|
rtw_sta_media_status_rpt(adapter, parm->sta, parm->connected);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_stassoc_event_callback(_adapter *adapter, u8 *pbuf)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
_irqL irqL;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct sta_info *psta;
|
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
2017-04-07 11:39:45 +00:00
|
|
|
struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf;
|
|
|
|
struct wlan_network *cur_network = &(pmlmepriv->cur_network);
|
2016-03-27 17:56:02 +00:00
|
|
|
struct wlan_network *ptarget_wlan = NULL;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
#if CONFIG_RTW_MACADDR_ACL
|
|
|
|
if (rtw_access_ctrl(adapter, pstassoc->macaddr) == _FALSE)
|
2016-03-27 17:56:02 +00:00
|
|
|
return;
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#if defined(CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
|
|
|
|
psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr);
|
|
|
|
if (psta) {
|
2016-03-27 17:56:02 +00:00
|
|
|
u8 *passoc_req = NULL;
|
|
|
|
u32 assoc_req_len = 0;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_sta_media_status_rpt(adapter, psta, 1);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
#ifndef CONFIG_AUTO_AP_MODE
|
|
|
|
|
|
|
|
ap_sta_info_defer_update(adapter, psta);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* report to upper layer */
|
|
|
|
RTW_INFO("indicate_sta_assoc_event to upper layer - hostapd\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
#ifdef CONFIG_IOCTL_CFG80211
|
|
|
|
_enter_critical_bh(&psta->lock, &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (psta->passoc_req && psta->assoc_req_len > 0) {
|
2016-03-27 17:56:02 +00:00
|
|
|
passoc_req = rtw_zmalloc(psta->assoc_req_len);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (passoc_req) {
|
2016-03-27 17:56:02 +00:00
|
|
|
assoc_req_len = psta->assoc_req_len;
|
|
|
|
_rtw_memcpy(passoc_req, psta->passoc_req, assoc_req_len);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_mfree(psta->passoc_req , psta->assoc_req_len);
|
|
|
|
psta->passoc_req = NULL;
|
|
|
|
psta->assoc_req_len = 0;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
_exit_critical_bh(&psta->lock, &irqL);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (passoc_req && assoc_req_len > 0) {
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_cfg80211_indicate_sta_assoc(adapter, passoc_req, assoc_req_len);
|
|
|
|
|
|
|
|
rtw_mfree(passoc_req, assoc_req_len);
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
|
|
|
#else /* !CONFIG_IOCTL_CFG80211 */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_indicate_sta_assoc_event(adapter, psta);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* !CONFIG_IOCTL_CFG80211 */
|
|
|
|
#endif /* !CONFIG_AUTO_AP_MODE */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_BEAMFORMING
|
|
|
|
beamforming_wk_cmd(adapter, BEAMFORMING_CTRL_ENTER, (u8 *)psta, sizeof(struct sta_info), 0);
|
|
|
|
#endif/*CONFIG_BEAMFORMING*/
|
2017-04-07 11:39:45 +00:00
|
|
|
if (is_wep_enc(adapter->securitypriv.dot11PrivacyAlgrthm))
|
|
|
|
rtw_ap_wep_pk_setting(adapter, psta);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_mi_update_iface_status(pmlmepriv, WIFI_AP_STATE);
|
|
|
|
}
|
|
|
|
goto exit;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* defined (CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME) */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* for AD-HOC mode */
|
|
|
|
psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr);
|
2016-03-27 17:56:02 +00:00
|
|
|
if (psta == NULL) {
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_ERR(FUNC_ADPT_FMT" get no sta_info with "MAC_FMT"\n"
|
|
|
|
, FUNC_ADPT_ARG(adapter), MAC_ARG(pstassoc->macaddr));
|
|
|
|
rtw_warn_on(1);
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rtw_hal_set_odm_var(adapter, HAL_ODM_STA_INFO, psta, _TRUE);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
rtw_sta_media_status_rpt(adapter, psta, 1);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)
|
2016-03-27 17:56:02 +00:00
|
|
|
psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
psta->ieee8021x_blocked = _FALSE;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE)) {
|
|
|
|
if (adapter->stapriv.asoc_sta_count == 2) {
|
2016-03-27 17:56:02 +00:00
|
|
|
_enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
|
|
|
|
pmlmepriv->cur_network_scanned = ptarget_wlan;
|
2017-04-07 11:39:45 +00:00
|
|
|
if (ptarget_wlan)
|
|
|
|
ptarget_wlan->fixed = _TRUE;
|
2016-03-27 17:56:02 +00:00
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* a sta + bc/mc_stainfo (not Ibss_stainfo) */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_indicate_connect(adapter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
|
|
|
|
|
|
|
|
mlmeext_sta_add_event_callback(adapter, psta);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
#ifdef CONFIG_RTL8711
|
2017-04-07 11:39:45 +00:00
|
|
|
/* submit SetStaKey_cmd to tell fw, fw will allocate an CAM entry for this sta */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_setstakey_cmd(adapter, psta, GROUP_KEY, _TRUE);
|
|
|
|
#endif
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
exit:
|
|
|
|
return;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_IEEE80211W
|
|
|
|
void rtw_sta_timeout_event_callback(_adapter *adapter, u8 *pbuf)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
struct sta_info *psta;
|
|
|
|
struct stadel_event *pstadel = (struct stadel_event *)pbuf;
|
|
|
|
struct sta_priv *pstapriv = &adapter->stapriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr);
|
|
|
|
|
|
|
|
if (psta) {
|
|
|
|
u8 updated = _FALSE;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_enter_critical_bh(&pstapriv->asoc_list_lock, &irqL);
|
|
|
|
if (rtw_is_list_empty(&psta->asoc_list) == _FALSE) {
|
|
|
|
rtw_list_delete(&psta->asoc_list);
|
|
|
|
pstapriv->asoc_list_cnt--;
|
|
|
|
updated = ap_free_sta(adapter, psta, _TRUE, WLAN_REASON_PREV_AUTH_NOT_VALID, _TRUE);
|
|
|
|
}
|
|
|
|
_exit_critical_bh(&pstapriv->asoc_list_lock, &irqL);
|
|
|
|
|
|
|
|
associated_clients_update(adapter, updated, STA_INFO_UPDATE_ALL);
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_IEEE80211W */
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_sta_mstatus_disc_rpt(_adapter *adapter, u8 mac_id)
|
|
|
|
{
|
|
|
|
struct macid_ctl_t *macid_ctl = &adapter->dvobj->macid_ctl;
|
|
|
|
|
|
|
|
RTW_INFO("%s "ADPT_FMT" - mac_id=%d\n", __func__, ADPT_ARG(adapter), mac_id);
|
|
|
|
|
|
|
|
if (mac_id >= 0 && mac_id < macid_ctl->num) {
|
|
|
|
rtw_hal_set_FwMediaStatusRpt_single_cmd(adapter, 0, 0, 0, 0, mac_id);
|
|
|
|
/*
|
|
|
|
* For safety, prevent from keeping macid sleep.
|
|
|
|
* If we can sure all power mode enter/leave are paired,
|
|
|
|
* this check can be removed.
|
|
|
|
* Lucas@20131113
|
|
|
|
*/
|
|
|
|
/* wakeup macid after disconnect. */
|
|
|
|
/*if (MLME_IS_STA(adapter))*/
|
|
|
|
rtw_hal_macid_wakeup(adapter, mac_id);
|
|
|
|
} else {
|
|
|
|
RTW_PRINT(FUNC_ADPT_FMT" invalid macid:%u\n"
|
|
|
|
, FUNC_ADPT_ARG(adapter), mac_id);
|
|
|
|
rtw_warn_on(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void rtw_sta_mstatus_report(_adapter *adapter)
|
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
|
|
|
struct wlan_network *tgt_network = &pmlmepriv->cur_network;
|
|
|
|
struct sta_info *psta = NULL;
|
|
|
|
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
|
|
|
|
psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.MacAddress);
|
|
|
|
if (psta)
|
|
|
|
rtw_sta_mstatus_disc_rpt(adapter, psta->mac_id);
|
|
|
|
else {
|
|
|
|
RTW_INFO("%s "ADPT_FMT" - mac_addr: "MAC_FMT" psta == NULL\n", __func__, ADPT_ARG(adapter), MAC_ARG(tgt_network->network.MacAddress));
|
|
|
|
rtw_warn_on(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
void rtw_stadel_event_callback(_adapter *adapter, u8 *pbuf)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
_irqL irqL, irqL2;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
struct sta_info *psta;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct wlan_network *pwlan = NULL;
|
|
|
|
WLAN_BSSID_EX *pdev_network = NULL;
|
|
|
|
u8 *pibss = NULL;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
2017-04-07 11:39:45 +00:00
|
|
|
struct stadel_event *pstadel = (struct stadel_event *)pbuf;
|
|
|
|
struct sta_priv *pstapriv = &adapter->stapriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct wlan_network *tgt_network = &(pmlmepriv->cur_network);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
RTW_INFO("%s(mac_id=%d)=" MAC_FMT "\n", __func__, pstadel->mac_id, MAC_ARG(pstadel->macaddr));
|
|
|
|
rtw_sta_mstatus_disc_rpt(adapter, pstadel->mac_id);
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (psta == NULL) {
|
|
|
|
RTW_INFO("%s(mac_id=%d)=" MAC_FMT " psta == NULL\n", __func__, pstadel->mac_id, MAC_ARG(pstadel->macaddr));
|
|
|
|
/*rtw_warn_on(1);*/
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (psta)
|
|
|
|
rtw_wfd_st_switch(psta, 0);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* if(check_fwstate(pmlmepriv, WIFI_AP_STATE)) */
|
|
|
|
if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
|
2016-03-27 17:56:02 +00:00
|
|
|
#ifdef CONFIG_IOCTL_CFG80211
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef COMPAT_KERNEL_RELEASE
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)) || defined(CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER)
|
|
|
|
rtw_cfg80211_indicate_sta_disassoc(adapter, pstadel->macaddr, *(u16 *)pstadel->rsvd);
|
|
|
|
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)) || defined(CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER) */
|
|
|
|
#endif /* CONFIG_IOCTL_CFG80211 */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mlmeext_sta_del_event_callback(adapter);
|
|
|
|
|
|
|
|
_enter_critical_bh(&pmlmepriv->lock, &irqL2);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
|
2016-03-27 17:56:02 +00:00
|
|
|
u16 reason = *((unsigned short *)(pstadel->rsvd));
|
|
|
|
bool roam = _FALSE;
|
|
|
|
struct wlan_network *roam_target = NULL;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_LAYER2_ROAMING
|
|
|
|
if (adapter->registrypriv.wifi_spec == 1)
|
2016-03-27 17:56:02 +00:00
|
|
|
roam = _FALSE;
|
2017-04-07 11:39:45 +00:00
|
|
|
else if (reason == WLAN_REASON_EXPIRATION_CHK && rtw_chk_roam_flags(adapter, RTW_ROAM_ON_EXPIRED))
|
2016-03-27 17:56:02 +00:00
|
|
|
roam = _TRUE;
|
2017-04-07 11:39:45 +00:00
|
|
|
else if (reason == WLAN_REASON_ACTIVE_ROAM && rtw_chk_roam_flags(adapter, RTW_ROAM_ACTIVE)) {
|
2016-03-27 17:56:02 +00:00
|
|
|
roam = _TRUE;
|
|
|
|
roam_target = pmlmepriv->roam_network;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (roam == _TRUE) {
|
|
|
|
if (rtw_to_roam(adapter) > 0)
|
|
|
|
rtw_dec_to_roam(adapter); /* this stadel_event is caused by roaming, decrease to_roam */
|
|
|
|
else if (rtw_to_roam(adapter) == 0)
|
|
|
|
rtw_set_to_roam(adapter, adapter->registrypriv.max_roaming_times);
|
2017-04-07 11:39:45 +00:00
|
|
|
} else
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_set_to_roam(adapter, 0);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_LAYER2_ROAMING */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
rtw_free_uc_swdec_pending_queue(adapter);
|
|
|
|
|
|
|
|
rtw_free_assoc_resources(adapter, 1);
|
|
|
|
rtw_free_mlme_priv_ie_data(pmlmepriv);
|
|
|
|
|
|
|
|
_enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* remove the network entry in scanned_queue */
|
|
|
|
pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress);
|
|
|
|
if ((pwlan) && (!check_fwstate(pmlmepriv, WIFI_UNDER_WPS))) {
|
2016-03-27 17:56:02 +00:00
|
|
|
pwlan->fixed = _FALSE;
|
|
|
|
rtw_free_network_nolock(adapter, pwlan);
|
|
|
|
}
|
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_indicate_disconnect(adapter, *(u16 *)pstadel->rsvd, pstadel->locally_generated);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_rtw_roaming(adapter, roam_target);
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
|
|
|
|
check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
|
|
|
|
|
|
|
|
/* _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_free_stainfo(adapter, psta);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */
|
|
|
|
|
|
|
|
if (adapter->stapriv.asoc_sta_count == 1) { /* a sta + bc/mc_stainfo (not Ibss_stainfo) */
|
|
|
|
/* rtw_indicate_disconnect(adapter); */ /* removed@20091105 */
|
2016-03-27 17:56:02 +00:00
|
|
|
_enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* free old ibss network */
|
|
|
|
/* pwlan = rtw_find_network(&pmlmepriv->scanned_queue, pstadel->macaddr); */
|
2016-03-27 17:56:02 +00:00
|
|
|
pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pwlan) {
|
2016-03-27 17:56:02 +00:00
|
|
|
pwlan->fixed = _FALSE;
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_free_network_nolock(adapter, pwlan);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* re-create ibss */
|
|
|
|
pdev_network = &(adapter->registrypriv.dev_network);
|
2016-03-27 17:56:02 +00:00
|
|
|
pibss = adapter->registrypriv.dev_network.MacAddress;
|
|
|
|
|
|
|
|
_rtw_memcpy(pdev_network, &tgt_network->network, get_WLAN_BSSID_EX_sz(&tgt_network->network));
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_rtw_memset(&pdev_network->Ssid, 0, sizeof(NDIS_802_11_SSID));
|
|
|
|
_rtw_memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(NDIS_802_11_SSID));
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
rtw_update_registrypriv_dev_network(adapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
rtw_generate_random_ibss(pibss);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
|
2016-03-27 17:56:02 +00:00
|
|
|
set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
|
|
|
|
_clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rtw_create_ibss_cmd(adapter, 0) != _SUCCESS)
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_ERR("rtw_create_ibss_cmd FAIL\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_exit_critical_bh(&pmlmepriv->lock, &irqL2);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void rtw_cpwm_event_callback(PADAPTER padapter, u8 *pbuf)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_LPS_LCLK
|
|
|
|
struct reportpwrstate_parm *preportpwrstate;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_LPS_LCLK
|
2017-04-07 11:39:45 +00:00
|
|
|
preportpwrstate = (struct reportpwrstate_parm *)pbuf;
|
2016-03-27 17:56:02 +00:00
|
|
|
preportpwrstate->state |= (u8)(adapter_to_pwrctl(padapter)->cpwm_tog + 0x80);
|
|
|
|
cpwm_int_hdl(padapter, preportpwrstate);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void rtw_wmm_event_callback(PADAPTER padapter, u8 *pbuf)
|
|
|
|
{
|
|
|
|
|
|
|
|
WMMOnAssocRsp(padapter);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _rtw_join_timeout_handler - Timeout/faliure handler for CMD JoinBss
|
|
|
|
* @adapter: pointer to _adapter structure
|
|
|
|
*/
|
2017-04-07 11:39:45 +00:00
|
|
|
void _rtw_join_timeout_handler(_adapter *adapter)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (rtw_is_drv_stopped(adapter)) {
|
|
|
|
_rtw_up_sema(&pmlmepriv->assoc_terminate);
|
|
|
|
return;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("%s, fw_state=%x\n", __FUNCTION__, get_fwstate(pmlmepriv));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if (RTW_CANNOT_RUN(adapter))
|
|
|
|
return;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_LAYER2_ROAMING
|
2016-03-27 17:56:02 +00:00
|
|
|
if (rtw_to_roam(adapter) > 0) { /* join timeout caused by roaming */
|
2017-04-07 11:39:45 +00:00
|
|
|
while (1) {
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_dec_to_roam(adapter);
|
|
|
|
if (rtw_to_roam(adapter) != 0) { /* try another */
|
|
|
|
int do_join_r;
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("%s try another roaming\n", __FUNCTION__);
|
|
|
|
do_join_r = rtw_do_join(adapter);
|
|
|
|
if (_SUCCESS != do_join_r) {
|
|
|
|
RTW_INFO("%s roaming do_join return %d\n", __FUNCTION__ , do_join_r);
|
2016-03-27 17:56:02 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else {
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("%s We've try roaming but fail\n", __FUNCTION__);
|
|
|
|
rtw_indicate_disconnect(adapter, 0, _FALSE);
|
2016-03-27 17:56:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
} else
|
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_indicate_disconnect(adapter, 0, _FALSE);
|
|
|
|
free_scanqueue(pmlmepriv);/* ??? */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_IOCTL_CFG80211
|
2017-04-07 11:39:45 +00:00
|
|
|
/* indicate disconnect for the case that join_timeout and check_fwstate != FW_LINKED */
|
|
|
|
rtw_cfg80211_indicate_disconnect(adapter, 0, _FALSE);
|
|
|
|
#endif /* CONFIG_IOCTL_CFG80211 */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_DRVEXT_MODULE_WSC
|
|
|
|
drvext_assoc_fail_indicate(&adapter->drvextpriv);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* rtw_scan_timeout_handler - Timeout/Faliure handler for CMD SiteSurvey
|
|
|
|
* @adapter: pointer to _adapter structure
|
|
|
|
*/
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_scan_timeout_handler(_adapter *adapter)
|
|
|
|
{
|
2016-03-27 17:56:02 +00:00
|
|
|
_irqL irqL;
|
|
|
|
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
#ifdef CONFIG_IOCTL_CFG80211
|
|
|
|
rtw_cfg80211_surveydone_event_callback(adapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_IOCTL_CFG80211 */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_indicate_scan_done(adapter, _TRUE);
|
|
|
|
#ifdef CONFIG_CONCURRENT_MODE
|
|
|
|
rtw_mi_buddy_indicate_scan_done(adapter, _TRUE);/*scanning_via_buddy_intf */
|
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_mlme_reset_auto_scan_int(_adapter *adapter, u8 *reason)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
struct mlme_priv *mlme = &adapter->mlmepriv;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 u_ch;
|
|
|
|
u32 interval_ms = 0xffffffff; /* 0xffffffff: special value to make min() works well, also means no auto scan */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
*reason = RTW_AUTO_SCAN_REASON_UNSPECIFIED;
|
|
|
|
rtw_mi_get_ch_setting_union(adapter, &u_ch, NULL, NULL);
|
|
|
|
|
|
|
|
if (hal_chk_bw_cap(adapter, BW_CAP_40M)
|
|
|
|
&& is_client_associated_to_ap(adapter) == _TRUE
|
|
|
|
&& u_ch >= 1 && u_ch <= 14
|
|
|
|
&& adapter->registrypriv.wifi_spec
|
|
|
|
/* TODO: AP Connected is 40MHz capability? */
|
|
|
|
) {
|
|
|
|
interval_ms = rtw_min(interval_ms, 60 * 1000);
|
|
|
|
*reason |= RTW_AUTO_SCAN_REASON_2040_BSS;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
#ifdef CONFIG_LAYER2_ROAMING
|
2017-04-07 11:39:45 +00:00
|
|
|
if (rtw_chk_roam_flags(adapter, RTW_ROAM_ACTIVE)
|
|
|
|
&& is_client_associated_to_ap(adapter) == _TRUE
|
|
|
|
) {
|
|
|
|
interval_ms = rtw_min(interval_ms, mlme->roam_scan_int_ms);
|
|
|
|
*reason |= RTW_AUTO_SCAN_REASON_ROAM;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
exit:
|
2017-04-07 11:39:45 +00:00
|
|
|
if (interval_ms == 0xffffffff)
|
|
|
|
interval_ms = 0;
|
|
|
|
|
|
|
|
rtw_mlme_set_auto_scan_int(adapter, interval_ms);
|
2016-03-27 17:56:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_drv_scan_by_self(_adapter *padapter, u8 reason)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct rtw_ieee80211_channel ch_for_2040_bss[14] = {
|
|
|
|
{1, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{2, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{3, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{4, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{5, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{6, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{7, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{8, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{9, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{10, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{11, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{12, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{13, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
{14, RTW_IEEE80211_CHAN_PASSIVE_SCAN},
|
|
|
|
};
|
|
|
|
struct rtw_ieee80211_channel *ch_sel = NULL;
|
|
|
|
int ch_num = 0;
|
|
|
|
|
|
|
|
if (rtw_is_scan_deny(padapter))
|
|
|
|
goto exit;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (!rtw_is_adapter_up(padapter))
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
if (rtw_mi_busy_traffic_check(padapter, _FALSE)) {
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT" exit due to BusyTraffic\n", FUNC_ADPT_ARG(padapter));
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) && check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT" WIFI_AP_STATE && WIFI_UNDER_WPS\n", FUNC_ADPT_ARG(padapter));
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY | _FW_UNDER_LINKING)) == _TRUE) {
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT" _FW_UNDER_SURVEY|_FW_UNDER_LINKING\n", FUNC_ADPT_ARG(padapter));
|
|
|
|
goto exit;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_CONCURRENT_MODE
|
2017-04-07 11:39:45 +00:00
|
|
|
if (rtw_mi_buddy_check_fwstate(padapter, (_FW_UNDER_SURVEY | _FW_UNDER_LINKING | WIFI_UNDER_WPS))) {
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT", but buddy_intf is under scanning or linking or wps_phase\n", FUNC_ADPT_ARG(padapter));
|
|
|
|
goto exit;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT" reason:0x%02x\n", FUNC_ADPT_ARG(padapter), reason);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* only for 20/40 BSS */
|
|
|
|
if (reason == RTW_AUTO_SCAN_REASON_2040_BSS) {
|
|
|
|
ch_sel = ch_for_2040_bss;
|
|
|
|
ch_num = 14;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_set_802_11_bssid_list_scan(padapter, NULL, 0, ch_sel, ch_num);
|
2016-03-27 17:56:02 +00:00
|
|
|
exit:
|
2017-04-07 11:39:45 +00:00
|
|
|
return;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rtw_auto_scan_handler(_adapter *padapter)
|
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 reason = RTW_AUTO_SCAN_REASON_UNSPECIFIED;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_mlme_reset_auto_scan_int(padapter, &reason);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE))
|
|
|
|
goto exit;
|
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_TDLS
|
|
|
|
if (padapter->tdlsinfo.link_established == _TRUE)
|
|
|
|
goto exit;
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pmlmepriv->auto_scan_int_ms == 0
|
|
|
|
|| rtw_get_passing_time_ms(pmlmepriv->scan_start_time) < pmlmepriv->auto_scan_int_ms)
|
|
|
|
goto exit;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_drv_scan_by_self(padapter, reason);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
exit:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
static u8 is_drv_in_lps(_adapter *adapter)
|
|
|
|
{
|
|
|
|
u8 is_in_lps = _FALSE;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_LPS_LCLK_WD_TIMER /* to avoid leaving lps 32k frequently*/
|
|
|
|
if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode == _TRUE)
|
|
|
|
#ifdef CONFIG_BT_COEXIST
|
|
|
|
&& (rtw_btcoex_IsBtControlLps(adapter) == _FALSE)
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
is_in_lps = _TRUE;
|
|
|
|
#endif /* CONFIG_LPS_LCLK_WD_TIMER*/
|
|
|
|
return is_in_lps;
|
|
|
|
}
|
|
|
|
void rtw_iface_dynamic_check_timer_handlder(_adapter *adapter)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_AP_MODE
|
|
|
|
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
|
|
|
#endif /* CONFIG_AP_MODE */
|
|
|
|
|
|
|
|
if (adapter->net_closed == _TRUE)
|
2016-03-27 17:56:02 +00:00
|
|
|
return;
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_LPS_LCLK_WD_TIMER /* to avoid leaving lps 32k frequently*/
|
|
|
|
if (is_drv_in_lps(adapter)) {
|
|
|
|
u8 bEnterPS;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
linked_status_chk(adapter, 1);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
bEnterPS = traffic_status_watchdog(adapter, 1);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (bEnterPS) {
|
|
|
|
/* rtw_lps_ctrl_wk_cmd(adapter, LPS_CTRL_ENTER, 1); */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_hal_dm_watchdog_in_lps(adapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
|
|
|
/* call rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, 1) in traffic_status_watchdog() */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_LPS_LCLK_WD_TIMER */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
/* auto site survey */
|
|
|
|
rtw_auto_scan_handler(adapter);
|
|
|
|
|
|
|
|
#ifndef CONFIG_ACTIVE_KEEP_ALIVE_CHECK
|
|
|
|
#ifdef CONFIG_AP_MODE
|
2017-04-07 11:39:45 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE)
|
2016-03-27 17:56:02 +00:00
|
|
|
expire_timeout_chk(adapter);
|
|
|
|
#endif
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* !CONFIG_ACTIVE_KEEP_ALIVE_CHECK */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_BR_EXT
|
|
|
|
|
|
|
|
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35))
|
|
|
|
rcu_read_lock();
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35)) */
|
|
|
|
|
|
|
|
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
|
|
|
|
if (adapter->pnetdev->br_port
|
|
|
|
#else /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) */
|
|
|
|
if (rcu_dereference(adapter->pnetdev->rx_handler_data)
|
|
|
|
#endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) */
|
|
|
|
&& (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE) == _TRUE)) {
|
|
|
|
/* expire NAT2.5 entry */
|
2016-03-27 17:56:02 +00:00
|
|
|
void nat25_db_expire(_adapter *priv);
|
|
|
|
nat25_db_expire(adapter);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (adapter->pppoe_connection_in_progress > 0)
|
2016-03-27 17:56:02 +00:00
|
|
|
adapter->pppoe_connection_in_progress--;
|
2017-04-07 11:39:45 +00:00
|
|
|
/* due to rtw_dynamic_check_timer_handlder() is called every 2 seconds */
|
|
|
|
if (adapter->pppoe_connection_in_progress > 0)
|
2016-03-27 17:56:02 +00:00
|
|
|
adapter->pppoe_connection_in_progress--;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35))
|
|
|
|
rcu_read_unlock();
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35)) */
|
|
|
|
|
|
|
|
#endif /* CONFIG_BR_EXT */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*#define DBG_TRAFFIC_STATISTIC*/
|
|
|
|
static void collect_traffic_statistics(_adapter *padapter)
|
|
|
|
{
|
|
|
|
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
|
|
|
|
|
|
|
|
/*_rtw_memset(&pdvobjpriv->traffic_stat, 0, sizeof(struct rtw_traffic_statistics));*/
|
|
|
|
|
|
|
|
/* Tx bytes reset*/
|
|
|
|
pdvobjpriv->traffic_stat.tx_bytes = 0;
|
|
|
|
pdvobjpriv->traffic_stat.tx_pkts = 0;
|
|
|
|
pdvobjpriv->traffic_stat.tx_drop = 0;
|
|
|
|
|
|
|
|
/* Rx bytes reset*/
|
|
|
|
pdvobjpriv->traffic_stat.rx_bytes = 0;
|
|
|
|
pdvobjpriv->traffic_stat.rx_pkts = 0;
|
|
|
|
pdvobjpriv->traffic_stat.rx_drop = 0;
|
|
|
|
|
|
|
|
rtw_mi_traffic_statistics(padapter);
|
|
|
|
|
|
|
|
/* Calculate throughput in last interval */
|
|
|
|
pdvobjpriv->traffic_stat.cur_tx_bytes = pdvobjpriv->traffic_stat.tx_bytes - pdvobjpriv->traffic_stat.last_tx_bytes;
|
|
|
|
pdvobjpriv->traffic_stat.cur_rx_bytes = pdvobjpriv->traffic_stat.rx_bytes - pdvobjpriv->traffic_stat.last_rx_bytes;
|
|
|
|
pdvobjpriv->traffic_stat.last_tx_bytes = pdvobjpriv->traffic_stat.tx_bytes;
|
|
|
|
pdvobjpriv->traffic_stat.last_rx_bytes = pdvobjpriv->traffic_stat.rx_bytes;
|
|
|
|
|
|
|
|
pdvobjpriv->traffic_stat.cur_tx_tp = (u32)(pdvobjpriv->traffic_stat.cur_tx_bytes * 8 / 2 / 1024 / 1024);
|
|
|
|
pdvobjpriv->traffic_stat.cur_rx_tp = (u32)(pdvobjpriv->traffic_stat.cur_rx_bytes * 8 / 2 / 1024 / 1024);
|
|
|
|
|
|
|
|
#ifdef DBG_TRAFFIC_STATISTIC
|
|
|
|
RTW_INFO("\n========================\n");
|
|
|
|
RTW_INFO("cur_tx_bytes:%lld\n", pdvobjpriv->traffic_stat.cur_tx_bytes);
|
|
|
|
RTW_INFO("cur_rx_bytes:%lld\n", pdvobjpriv->traffic_stat.cur_rx_bytes);
|
|
|
|
|
|
|
|
RTW_INFO("last_tx_bytes:%lld\n", pdvobjpriv->traffic_stat.last_tx_bytes);
|
|
|
|
RTW_INFO("last_rx_bytes:%lld\n", pdvobjpriv->traffic_stat.last_rx_bytes);
|
|
|
|
|
|
|
|
RTW_INFO("cur_tx_tp:%d\n", pdvobjpriv->traffic_stat.cur_tx_tp);
|
|
|
|
RTW_INFO("cur_rx_tp:%d\n", pdvobjpriv->traffic_stat.cur_rx_tp);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_dynamic_check_timer_handlder(_adapter *adapter)
|
|
|
|
{
|
|
|
|
if (!adapter)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!rtw_is_hw_init_completed(adapter))
|
|
|
|
return;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (RTW_CANNOT_RUN(adapter))
|
|
|
|
return;
|
|
|
|
|
|
|
|
collect_traffic_statistics(adapter);
|
|
|
|
|
|
|
|
rtw_mi_dynamic_check_timer_handlder(adapter);
|
|
|
|
|
|
|
|
if (!is_drv_in_lps(adapter))
|
|
|
|
rtw_dynamic_chk_wk_cmd(adapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_SET_SCAN_DENY_TIMER
|
|
|
|
inline bool rtw_is_scan_deny(_adapter *adapter)
|
|
|
|
{
|
|
|
|
struct mlme_priv *mlmepriv = &adapter->mlmepriv;
|
|
|
|
return (ATOMIC_READ(&mlmepriv->set_scan_deny) != 0) ? _TRUE : _FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void rtw_clear_scan_deny(_adapter *adapter)
|
|
|
|
{
|
|
|
|
struct mlme_priv *mlmepriv = &adapter->mlmepriv;
|
|
|
|
ATOMIC_SET(&mlmepriv->set_scan_deny, 0);
|
|
|
|
if (0)
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter));
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_set_scan_deny_timer_hdl(_adapter *adapter)
|
|
|
|
{
|
|
|
|
rtw_clear_scan_deny(adapter);
|
|
|
|
}
|
|
|
|
void rtw_set_scan_deny(_adapter *adapter, u32 ms)
|
|
|
|
{
|
|
|
|
struct mlme_priv *mlmepriv = &adapter->mlmepriv;
|
|
|
|
if (0)
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter));
|
2016-03-27 17:56:02 +00:00
|
|
|
ATOMIC_SET(&mlmepriv->set_scan_deny, 1);
|
|
|
|
_set_timer(&mlmepriv->set_scan_deny_timer, ms);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_LAYER2_ROAMING
|
|
|
|
/*
|
|
|
|
* Select a new roaming candidate from the original @param candidate and @param competitor
|
|
|
|
* @return _TRUE: candidate is updated
|
|
|
|
* @return _FALSE: candidate is not updated
|
|
|
|
*/
|
|
|
|
static int rtw_check_roaming_candidate(struct mlme_priv *mlme
|
|
|
|
, struct wlan_network **candidate, struct wlan_network *competitor)
|
|
|
|
{
|
|
|
|
int updated = _FALSE;
|
|
|
|
_adapter *adapter = container_of(mlme, _adapter, mlmepriv);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (is_same_ess(&competitor->network, &mlme->cur_network.network) == _FALSE)
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (rtw_is_desired_network(adapter, competitor) == _FALSE)
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("roam candidate:%s %s("MAC_FMT", ch%3u) rssi:%d, age:%5d\n",
|
|
|
|
(competitor == mlme->cur_network_scanned) ? "*" : " " ,
|
|
|
|
competitor->network.Ssid.Ssid,
|
|
|
|
MAC_ARG(competitor->network.MacAddress),
|
|
|
|
competitor->network.Configuration.DSConfig,
|
|
|
|
(int)competitor->network.Rssi,
|
|
|
|
rtw_get_passing_time_ms(competitor->last_scanned)
|
|
|
|
);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
/* got specific addr to roam */
|
|
|
|
if (!is_zero_mac_addr(mlme->roam_tgt_addr)) {
|
2017-04-07 11:39:45 +00:00
|
|
|
if (_rtw_memcmp(mlme->roam_tgt_addr, competitor->network.MacAddress, ETH_ALEN) == _TRUE)
|
2016-03-27 17:56:02 +00:00
|
|
|
goto update;
|
|
|
|
else
|
|
|
|
goto exit;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#if 1
|
|
|
|
if (rtw_get_passing_time_ms((u32)competitor->last_scanned) >= mlme->roam_scanr_exp_ms)
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
|
|
|
|
if (competitor->network.Rssi - mlme->cur_network_scanned->network.Rssi < mlme->roam_rssi_diff_th)
|
|
|
|
goto exit;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (*candidate != NULL && (*candidate)->network.Rssi >= competitor->network.Rssi)
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
2017-04-07 11:39:45 +00:00
|
|
|
#else
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
update:
|
|
|
|
*candidate = competitor;
|
|
|
|
updated = _TRUE;
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return updated;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rtw_select_roaming_candidate(struct mlme_priv *mlme)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
int ret = _FAIL;
|
|
|
|
_list *phead;
|
2017-04-07 11:39:45 +00:00
|
|
|
_adapter *adapter;
|
2016-03-27 17:56:02 +00:00
|
|
|
_queue *queue = &(mlme->scanned_queue);
|
|
|
|
struct wlan_network *pnetwork = NULL;
|
|
|
|
struct wlan_network *candidate = NULL;
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 bSupportAntDiv = _FALSE;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (mlme->cur_network_scanned == NULL) {
|
|
|
|
rtw_warn_on(1);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
_enter_critical_bh(&(mlme->scanned_queue.lock), &irqL);
|
2017-04-07 11:39:45 +00:00
|
|
|
phead = get_list_head(queue);
|
2016-03-27 17:56:02 +00:00
|
|
|
adapter = (_adapter *)mlme->nic_hdl;
|
|
|
|
|
|
|
|
mlme->pscanned = get_next(phead);
|
|
|
|
|
|
|
|
while (!rtw_end_of_queue_search(phead, mlme->pscanned)) {
|
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(mlme->pscanned, struct wlan_network, list);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pnetwork == NULL) {
|
2016-03-27 17:56:02 +00:00
|
|
|
ret = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
mlme->pscanned = get_next(mlme->pscanned);
|
|
|
|
|
|
|
|
if (0)
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("%s("MAC_FMT", ch%u) rssi:%d\n"
|
|
|
|
, pnetwork->network.Ssid.Ssid
|
|
|
|
, MAC_ARG(pnetwork->network.MacAddress)
|
|
|
|
, pnetwork->network.Configuration.DSConfig
|
|
|
|
, (int)pnetwork->network.Rssi);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
rtw_check_roaming_candidate(mlme, &candidate, pnetwork);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (candidate == NULL) {
|
|
|
|
RTW_INFO("%s: return _FAIL(candidate == NULL)\n", __FUNCTION__);
|
2016-03-27 17:56:02 +00:00
|
|
|
ret = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
} else {
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("%s: candidate: %s("MAC_FMT", ch:%u)\n", __FUNCTION__,
|
2016-03-27 17:56:02 +00:00
|
|
|
candidate->network.Ssid.Ssid, MAC_ARG(candidate->network.MacAddress),
|
2017-04-07 11:39:45 +00:00
|
|
|
candidate->network.Configuration.DSConfig);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
mlme->roam_network = candidate;
|
|
|
|
|
|
|
|
if (_rtw_memcmp(candidate->network.MacAddress, mlme->roam_tgt_addr, ETH_ALEN) == _TRUE)
|
2017-04-07 11:39:45 +00:00
|
|
|
_rtw_memset(mlme->roam_tgt_addr, 0, ETH_ALEN);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = _SUCCESS;
|
|
|
|
exit:
|
|
|
|
_exit_critical_bh(&(mlme->scanned_queue.lock), &irqL);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_LAYER2_ROAMING */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Select a new join candidate from the original @param candidate and @param competitor
|
|
|
|
* @return _TRUE: candidate is updated
|
|
|
|
* @return _FALSE: candidate is not updated
|
|
|
|
*/
|
|
|
|
static int rtw_check_join_candidate(struct mlme_priv *mlme
|
2017-04-07 11:39:45 +00:00
|
|
|
, struct wlan_network **candidate, struct wlan_network *competitor)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
int updated = _FALSE;
|
|
|
|
_adapter *adapter = container_of(mlme, _adapter, mlmepriv);
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* check bssid, if needed */
|
|
|
|
if (mlme->assoc_by_bssid == _TRUE) {
|
|
|
|
if (_rtw_memcmp(competitor->network.MacAddress, mlme->assoc_bssid, ETH_ALEN) == _FALSE)
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* check ssid, if needed */
|
|
|
|
if (mlme->assoc_ssid.Ssid[0] && mlme->assoc_ssid.SsidLength) {
|
|
|
|
if (competitor->network.Ssid.SsidLength != mlme->assoc_ssid.SsidLength
|
|
|
|
|| _rtw_memcmp(competitor->network.Ssid.Ssid, mlme->assoc_ssid.Ssid, mlme->assoc_ssid.SsidLength) == _FALSE
|
|
|
|
)
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (rtw_is_desired_network(adapter, competitor) == _FALSE)
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_LAYER2_ROAMING
|
|
|
|
if (rtw_to_roam(adapter) > 0) {
|
|
|
|
if (rtw_get_passing_time_ms((u32)competitor->last_scanned) >= mlme->roam_scanr_exp_ms
|
|
|
|
|| is_same_ess(&competitor->network, &mlme->cur_network.network) == _FALSE
|
|
|
|
)
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
#endif
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
if (*candidate == NULL || (*candidate)->network.Rssi < competitor->network.Rssi) {
|
2016-03-27 17:56:02 +00:00
|
|
|
*candidate = competitor;
|
|
|
|
updated = _TRUE;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (updated) {
|
|
|
|
RTW_INFO("[by_bssid:%u][assoc_ssid:%s][to_roam:%u] "
|
|
|
|
"new candidate: %s("MAC_FMT", ch%u) rssi:%d\n",
|
|
|
|
mlme->assoc_by_bssid,
|
|
|
|
mlme->assoc_ssid.Ssid,
|
|
|
|
rtw_to_roam(adapter),
|
|
|
|
(*candidate)->network.Ssid.Ssid,
|
|
|
|
MAC_ARG((*candidate)->network.MacAddress),
|
|
|
|
(*candidate)->network.Configuration.DSConfig,
|
|
|
|
(int)(*candidate)->network.Rssi
|
|
|
|
);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return updated;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Calling context:
|
|
|
|
The caller of the sub-routine will be in critical section...
|
|
|
|
|
|
|
|
The caller must hold the following spinlock
|
|
|
|
|
|
|
|
pmlmepriv->lock
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
int ret;
|
|
|
|
_list *phead;
|
2017-04-07 11:39:45 +00:00
|
|
|
_adapter *adapter;
|
2016-03-27 17:56:02 +00:00
|
|
|
_queue *queue = &(pmlmepriv->scanned_queue);
|
|
|
|
struct wlan_network *pnetwork = NULL;
|
|
|
|
struct wlan_network *candidate = NULL;
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 bSupportAntDiv = _FALSE;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
adapter = (_adapter *)pmlmepriv->nic_hdl;
|
|
|
|
|
|
|
|
_enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_LAYER2_ROAMING
|
2016-03-27 17:56:02 +00:00
|
|
|
if (pmlmepriv->roam_network) {
|
|
|
|
candidate = pmlmepriv->roam_network;
|
|
|
|
pmlmepriv->roam_network = NULL;
|
|
|
|
goto candidate_exist;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
pmlmepriv->pscanned = get_next(phead);
|
|
|
|
|
|
|
|
while (!rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) {
|
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pnetwork == NULL) {
|
2016-03-27 17:56:02 +00:00
|
|
|
ret = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pmlmepriv->pscanned = get_next(pmlmepriv->pscanned);
|
|
|
|
|
|
|
|
if (0)
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("%s("MAC_FMT", ch%u) rssi:%d\n"
|
|
|
|
, pnetwork->network.Ssid.Ssid
|
|
|
|
, MAC_ARG(pnetwork->network.MacAddress)
|
|
|
|
, pnetwork->network.Configuration.DSConfig
|
|
|
|
, (int)pnetwork->network.Rssi);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (candidate == NULL) {
|
|
|
|
RTW_INFO("%s: return _FAIL(candidate == NULL)\n", __FUNCTION__);
|
2016-03-27 17:56:02 +00:00
|
|
|
#ifdef CONFIG_WOWLAN
|
2017-04-07 11:39:45 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_LINKED | _FW_UNDER_LINKING);
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
|
|
|
ret = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
} else {
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("%s: candidate: %s("MAC_FMT", ch:%u)\n", __FUNCTION__,
|
2016-03-27 17:56:02 +00:00
|
|
|
candidate->network.Ssid.Ssid, MAC_ARG(candidate->network.MacAddress),
|
2017-04-07 11:39:45 +00:00
|
|
|
candidate->network.Configuration.DSConfig);
|
2016-03-27 17:56:02 +00:00
|
|
|
goto candidate_exist;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
candidate_exist:
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* check for situation of _FW_LINKED */
|
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) {
|
|
|
|
RTW_INFO("%s: _FW_LINKED while ask_for_joinbss!!!\n", __FUNCTION__);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#if 0 /* for WPA/WPA2 authentication, wpa_supplicant will expect authentication from AP, it is needed to reconnect AP... */
|
|
|
|
if (is_same_network(&pmlmepriv->cur_network.network, &candidate->network)) {
|
|
|
|
RTW_INFO("%s: _FW_LINKED and is same network, it needn't join again\n", __FUNCTION__);
|
|
|
|
|
|
|
|
rtw_indicate_connect(adapter);/* rtw_indicate_connect again */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
ret = 2;
|
|
|
|
goto exit;
|
2017-04-07 11:39:45 +00:00
|
|
|
} else
|
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
rtw_disassoc_cmd(adapter, 0, _TRUE);
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_indicate_disconnect(adapter, 0, _FALSE);
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_free_assoc_resources(adapter, 0);
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_ANTENNA_DIVERSITY
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_hal_get_def_var(adapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &(bSupportAntDiv));
|
2017-04-07 11:39:45 +00:00
|
|
|
if (_TRUE == bSupportAntDiv) {
|
2016-03-27 17:56:02 +00:00
|
|
|
u8 CurrentAntenna;
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_hal_get_odm_var(adapter, HAL_ODM_ANTDIV_SELECT, &(CurrentAntenna), NULL);
|
|
|
|
RTW_INFO("#### Opt_Ant_(%s) , cur_Ant(%s)\n",
|
|
|
|
(MAIN_ANT == candidate->network.PhyInfo.Optimum_antenna) ? "MAIN_ANT" : "AUX_ANT",
|
|
|
|
(MAIN_ANT == CurrentAntenna) ? "MAIN_ANT" : "AUX_ANT"
|
|
|
|
);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
|
|
|
|
ret = rtw_joinbss_cmd(adapter, candidate);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
exit:
|
|
|
|
_exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL);
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
sint rtw_set_auth(_adapter *adapter, struct security_priv *psecuritypriv)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct cmd_obj *pcmd;
|
|
|
|
struct setauth_parm *psetauthparm;
|
|
|
|
struct cmd_priv *pcmdpriv = &(adapter->cmdpriv);
|
|
|
|
sint res = _SUCCESS;
|
|
|
|
|
|
|
|
|
|
|
|
pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
|
|
|
|
if (pcmd == NULL) {
|
|
|
|
res = _FAIL; /* try again */
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm));
|
|
|
|
if (psetauthparm == NULL) {
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_mfree((unsigned char *)pcmd, sizeof(struct cmd_obj));
|
2017-04-07 11:39:45 +00:00
|
|
|
res = _FAIL;
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
_rtw_memset(psetauthparm, 0, sizeof(struct setauth_parm));
|
2017-04-07 11:39:45 +00:00
|
|
|
psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pcmd->cmdcode = _SetAuth_CMD_;
|
2017-04-07 11:39:45 +00:00
|
|
|
pcmd->parmbuf = (unsigned char *)psetauthparm;
|
|
|
|
pcmd->cmdsz = (sizeof(struct setauth_parm));
|
2016-03-27 17:56:02 +00:00
|
|
|
pcmd->rsp = NULL;
|
|
|
|
pcmd->rspsz = 0;
|
|
|
|
|
|
|
|
|
|
|
|
_rtw_init_listhead(&pcmd->list);
|
|
|
|
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, pcmd);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
sint rtw_set_key(_adapter *adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
u8 keylen;
|
|
|
|
struct cmd_obj *pcmd;
|
|
|
|
struct setkey_parm *psetkeyparm;
|
|
|
|
struct cmd_priv *pcmdpriv = &(adapter->cmdpriv);
|
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
2017-04-07 11:39:45 +00:00
|
|
|
sint res = _SUCCESS;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm));
|
|
|
|
if (psetkeyparm == NULL) {
|
|
|
|
res = _FAIL;
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
_rtw_memset(psetkeyparm, 0, sizeof(struct setkey_parm));
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
|
|
|
|
psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy;
|
|
|
|
} else {
|
|
|
|
psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
psetkeyparm->keyid = (u8)keyid;/* 0~3 */
|
2016-03-27 17:56:02 +00:00
|
|
|
psetkeyparm->set_tx = set_tx;
|
|
|
|
if (is_wep_enc(psetkeyparm->algorithm))
|
|
|
|
adapter->securitypriv.key_mask |= BIT(psetkeyparm->keyid);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("==> rtw_set_key algorithm(%x),keyid(%x),key_mask(%x)\n", psetkeyparm->algorithm, psetkeyparm->keyid, adapter->securitypriv.key_mask);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
switch (psetkeyparm->algorithm) {
|
|
|
|
|
|
|
|
case _WEP40_:
|
|
|
|
keylen = 5;
|
|
|
|
_rtw_memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen);
|
|
|
|
break;
|
|
|
|
case _WEP104_:
|
|
|
|
keylen = 13;
|
|
|
|
_rtw_memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen);
|
|
|
|
break;
|
|
|
|
case _TKIP_:
|
|
|
|
keylen = 16;
|
|
|
|
_rtw_memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen);
|
|
|
|
psetkeyparm->grpkey = 1;
|
|
|
|
break;
|
|
|
|
case _AES_:
|
|
|
|
keylen = 16;
|
|
|
|
_rtw_memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen);
|
|
|
|
psetkeyparm->grpkey = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = _FAIL;
|
|
|
|
rtw_mfree((unsigned char *)psetkeyparm, sizeof(struct setkey_parm));
|
|
|
|
goto exit;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (enqueue) {
|
|
|
|
pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
|
|
|
|
if (pcmd == NULL) {
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_mfree((unsigned char *)psetkeyparm, sizeof(struct setkey_parm));
|
2017-04-07 11:39:45 +00:00
|
|
|
res = _FAIL; /* try again */
|
2016-03-27 17:56:02 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pcmd->cmdcode = _SetKey_CMD_;
|
2017-04-07 11:39:45 +00:00
|
|
|
pcmd->parmbuf = (u8 *)psetkeyparm;
|
|
|
|
pcmd->cmdsz = (sizeof(struct setkey_parm));
|
2016-03-27 17:56:02 +00:00
|
|
|
pcmd->rsp = NULL;
|
|
|
|
pcmd->rspsz = 0;
|
|
|
|
|
|
|
|
_rtw_init_listhead(&pcmd->list);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* _rtw_init_sema(&(pcmd->cmd_sem), 0); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, pcmd);
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
2016-03-27 17:56:02 +00:00
|
|
|
setkey_hdl(adapter, (u8 *)psetkeyparm);
|
|
|
|
rtw_mfree((u8 *) psetkeyparm, sizeof(struct setkey_parm));
|
|
|
|
}
|
|
|
|
exit:
|
|
|
|
return res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* adjust IEs for rtw_joinbss_cmd in WMM */
|
2016-03-27 17:56:02 +00:00
|
|
|
int rtw_restruct_wmm_ie(_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
unsigned int ielength = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
unsigned int i, j;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
i = 12; /* after the fixed IE */
|
|
|
|
while (i < in_len) {
|
|
|
|
ielength = initial_out_len;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (in_ie[i] == 0xDD && in_ie[i + 2] == 0x00 && in_ie[i + 3] == 0x50 && in_ie[i + 4] == 0xF2 && in_ie[i + 5] == 0x02 && i + 5 < in_len) { /* WMM element ID and OUI */
|
|
|
|
|
|
|
|
/* Append WMM IE to the last index of out_ie */
|
|
|
|
#if 0
|
|
|
|
for (j = i; j < i + (in_ie[i + 1] + 2); j++) {
|
|
|
|
out_ie[ielength] = in_ie[j];
|
|
|
|
ielength++;
|
|
|
|
}
|
|
|
|
out_ie[initial_out_len + 8] = 0x00; /* force the QoS Info Field to be zero */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (j = i; j < i + 9; j++) {
|
|
|
|
out_ie[ielength] = in_ie[j];
|
2016-03-27 17:56:02 +00:00
|
|
|
ielength++;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
out_ie[initial_out_len + 1] = 0x07;
|
|
|
|
out_ie[initial_out_len + 6] = 0x00;
|
|
|
|
out_ie[initial_out_len + 8] = 0x00;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
i += (in_ie[i + 1] + 2); /* to the next IE element */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
return ielength;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/*
|
|
|
|
* Ported from 8185: IsInPreAuthKeyList(). (Renamed from SecIsInPreAuthKeyList(), 2006-10-13.)
|
|
|
|
* Added by Annie, 2006-05-07.
|
|
|
|
*
|
|
|
|
* Search by BSSID,
|
|
|
|
* Return Value:
|
|
|
|
* -1 :if there is no pre-auth key in the table
|
|
|
|
* >=0 :if there is pre-auth key, and return the entry id
|
|
|
|
*
|
|
|
|
* */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
static int SecIsInPMKIDList(_adapter *Adapter, u8 *bssid)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct security_priv *psecuritypriv = &Adapter->securitypriv;
|
|
|
|
int i = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
do {
|
|
|
|
if ((psecuritypriv->PMKIDList[i].bUsed) &&
|
|
|
|
(_rtw_memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN) == _TRUE))
|
2016-03-27 17:56:02 +00:00
|
|
|
break;
|
2017-04-07 11:39:45 +00:00
|
|
|
else {
|
2016-03-27 17:56:02 +00:00
|
|
|
i++;
|
2017-04-07 11:39:45 +00:00
|
|
|
/* continue; */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
} while (i < NUM_PMKID_CACHE);
|
|
|
|
|
|
|
|
if (i == NUM_PMKID_CACHE) {
|
|
|
|
i = -1;/* Could not find. */
|
|
|
|
} else {
|
|
|
|
/* There is one Pre-Authentication Key for the specific BSSID. */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
return i;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/*
|
|
|
|
* Check the RSN IE length
|
|
|
|
* If the RSN IE length <= 20, the RSN IE didn't include the PMKID information
|
|
|
|
* 0-11th element in the array are the fixed IE
|
|
|
|
* 12th element in the array is the IE
|
|
|
|
* 13th element in the array is the IE length
|
|
|
|
* */
|
|
|
|
|
|
|
|
static int rtw_append_pmkid(_adapter *adapter, int iEntry, u8 *ie, uint ie_len)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct security_priv *sec = &adapter->securitypriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if (ie[13] > 20) {
|
|
|
|
int i;
|
2017-04-07 11:39:45 +00:00
|
|
|
u16 pmkid_cnt = RTW_GET_LE16(ie + 14 + 20);
|
|
|
|
if (pmkid_cnt == 1 && _rtw_memcmp(ie + 14 + 20 + 2, &sec->PMKIDList[iEntry].PMKID, 16)) {
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT" has carried the same PMKID:"KEY_FMT"\n"
|
2016-03-27 17:56:02 +00:00
|
|
|
, FUNC_ADPT_ARG(adapter), KEY_ARG(&sec->PMKIDList[iEntry].PMKID));
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT" remove original PMKID, count:%u\n"
|
|
|
|
, FUNC_ADPT_ARG(adapter), pmkid_cnt);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
for (i = 0; i < pmkid_cnt; i++)
|
|
|
|
RTW_INFO(" "KEY_FMT"\n", KEY_ARG(ie + 14 + 20 + 2 + i * 16));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
ie_len -= 2 + pmkid_cnt * 16;
|
2016-03-27 17:56:02 +00:00
|
|
|
ie[13] = 20;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (ie[13] <= 20) {
|
2016-03-27 17:56:02 +00:00
|
|
|
/* The RSN IE didn't include the PMK ID, append the PMK information */
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT" append PMKID:"KEY_FMT"\n"
|
|
|
|
, FUNC_ADPT_ARG(adapter), KEY_ARG(&sec->PMKIDList[iEntry].PMKID));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
RTW_PUT_LE16(&ie[ie_len], 1);
|
|
|
|
ie_len += 2;
|
|
|
|
|
|
|
|
_rtw_memcpy(&ie[ie_len], &sec->PMKIDList[iEntry].PMKID, 16);
|
|
|
|
ie_len += 16;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
ie[13] += 18;/* PMKID length = 2+16 */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2017-04-07 11:39:45 +00:00
|
|
|
return ie_len;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_remove_pmkid(_adapter *adapter, u8 *ie, uint ie_len)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct security_priv *sec = &adapter->securitypriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
int i;
|
2017-04-07 11:39:45 +00:00
|
|
|
u16 pmkid_cnt = RTW_GET_LE16(ie + 14 + 20);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if (ie[13] <= 20)
|
|
|
|
goto exit;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT" remove original PMKID, count:%u\n"
|
|
|
|
, FUNC_ADPT_ARG(adapter), pmkid_cnt);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
for (i = 0; i < pmkid_cnt; i++)
|
|
|
|
RTW_INFO(" "KEY_FMT"\n", KEY_ARG(ie + 14 + 20 + 2 + i * 16));
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
ie_len -= 2 + pmkid_cnt * 16;
|
2016-03-27 17:56:02 +00:00
|
|
|
ie[13] = 20;
|
|
|
|
|
|
|
|
exit:
|
2017-04-07 11:39:45 +00:00
|
|
|
return ie_len;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
sint rtw_restruct_sec_ie(_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 authmode = 0x0, securitytype, match;
|
2016-03-27 17:56:02 +00:00
|
|
|
u8 sec_ie[255], uncst_oui[4], bkup_ie[255];
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01};
|
|
|
|
uint ielength, cnt, remove_cnt;
|
2016-03-27 17:56:02 +00:00
|
|
|
int iEntry;
|
|
|
|
|
|
|
|
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct security_priv *psecuritypriv = &adapter->securitypriv;
|
|
|
|
uint ndisauthmode = psecuritypriv->ndisauthtype;
|
2016-03-27 17:56:02 +00:00
|
|
|
uint ndissecuritytype = psecuritypriv->ndisencryptstatus;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* copy fixed ie only */
|
|
|
|
_rtw_memcpy(out_ie, in_ie, 12);
|
|
|
|
ielength = 12;
|
|
|
|
if ((ndisauthmode == Ndis802_11AuthModeWPA) || (ndisauthmode == Ndis802_11AuthModeWPAPSK))
|
|
|
|
authmode = _WPA_IE_ID_;
|
|
|
|
if ((ndisauthmode == Ndis802_11AuthModeWPA2) || (ndisauthmode == Ndis802_11AuthModeWPA2PSK))
|
|
|
|
authmode = _WPA2_IE_ID_;
|
|
|
|
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
|
|
|
|
_rtw_memcpy(out_ie + ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len);
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
ielength += psecuritypriv->wps_ie_len;
|
2017-04-07 11:39:45 +00:00
|
|
|
} else if ((authmode == _WPA_IE_ID_) || (authmode == _WPA2_IE_ID_)) {
|
|
|
|
/* copy RSN or SSN */
|
|
|
|
_rtw_memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2);
|
2016-03-27 17:56:02 +00:00
|
|
|
/* debug for CONFIG_IEEE80211W
|
|
|
|
{
|
|
|
|
int jj;
|
|
|
|
printk("supplicant_ie_length=%d &&&&&&&&&&&&&&&&&&&\n", psecuritypriv->supplicant_ie[1]+2);
|
|
|
|
for(jj=0; jj < psecuritypriv->supplicant_ie[1]+2; jj++)
|
|
|
|
printk(" %02x ", psecuritypriv->supplicant_ie[jj]);
|
|
|
|
printk("\n");
|
|
|
|
}*/
|
2017-04-07 11:39:45 +00:00
|
|
|
ielength += psecuritypriv->supplicant_ie[1] + 2;
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_report_sec_ie(adapter, authmode, psecuritypriv->supplicant_ie);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
#ifdef CONFIG_DRVEXT_MODULE
|
2017-04-07 11:39:45 +00:00
|
|
|
drvext_report_sec_ie(&adapter->drvextpriv, authmode, sec_ie);
|
2016-03-27 17:56:02 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (iEntry < 0) {
|
|
|
|
if (authmode == _WPA2_IE_ID_)
|
2016-03-27 17:56:02 +00:00
|
|
|
ielength = rtw_remove_pmkid(adapter, out_ie, ielength);
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
|
|
|
if (authmode == _WPA2_IE_ID_)
|
|
|
|
ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
return ielength;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_init_registrypriv_dev_network(_adapter *adapter)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct registry_priv *pregistrypriv = &adapter->registrypriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
WLAN_BSSID_EX *pdev_network = &pregistrypriv->dev_network;
|
|
|
|
u8 *myhwaddr = adapter_mac_addr(adapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
_rtw_memcpy(pdev_network->MacAddress, myhwaddr, ETH_ALEN);
|
|
|
|
|
|
|
|
_rtw_memcpy(&pdev_network->Ssid, &pregistrypriv->ssid, sizeof(NDIS_802_11_SSID));
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
pdev_network->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
|
|
|
|
pdev_network->Configuration.BeaconPeriod = 100;
|
2016-03-27 17:56:02 +00:00
|
|
|
pdev_network->Configuration.FHConfig.Length = 0;
|
|
|
|
pdev_network->Configuration.FHConfig.HopPattern = 0;
|
|
|
|
pdev_network->Configuration.FHConfig.HopSet = 0;
|
|
|
|
pdev_network->Configuration.FHConfig.DwellTime = 0;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_update_registrypriv_dev_network(_adapter *adapter)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
int sz = 0;
|
|
|
|
struct registry_priv *pregistrypriv = &adapter->registrypriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
WLAN_BSSID_EX *pdev_network = &pregistrypriv->dev_network;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct security_priv *psecuritypriv = &adapter->securitypriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct wlan_network *cur_network = &adapter->mlmepriv.cur_network;
|
2017-04-07 11:39:45 +00:00
|
|
|
/* struct xmit_priv *pxmitpriv = &adapter->xmitpriv; */
|
2016-03-27 17:56:02 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense;
|
|
|
|
pxmitpriv->vcs = pregistrypriv->vcs_type;
|
|
|
|
pxmitpriv->vcs_type = pregistrypriv->vcs_type;
|
2017-04-07 11:39:45 +00:00
|
|
|
/* pxmitpriv->rts_thresh = pregistrypriv->rts_thresh; */
|
2016-03-27 17:56:02 +00:00
|
|
|
pxmitpriv->frag_len = pregistrypriv->frag_thresh;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
adapter->qospriv.qos_option = pregistrypriv->wmm_enable;
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
pdev_network->Privacy = (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0) ; /* adhoc no 802.1x */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
pdev_network->Rssi = 0;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
switch (pregistrypriv->wireless_mode) {
|
|
|
|
case WIRELESS_11B:
|
|
|
|
pdev_network->NetworkTypeInUse = (Ndis802_11DS);
|
|
|
|
break;
|
|
|
|
case WIRELESS_11G:
|
|
|
|
case WIRELESS_11BG:
|
|
|
|
case WIRELESS_11_24N:
|
|
|
|
case WIRELESS_11G_24N:
|
|
|
|
case WIRELESS_11BG_24N:
|
|
|
|
pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24);
|
|
|
|
break;
|
|
|
|
case WIRELESS_11A:
|
|
|
|
case WIRELESS_11A_5N:
|
|
|
|
pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5);
|
|
|
|
break;
|
|
|
|
case WIRELESS_11ABGN:
|
|
|
|
if (pregistrypriv->channel > 14)
|
2016-03-27 17:56:02 +00:00
|
|
|
pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5);
|
2017-04-07 11:39:45 +00:00
|
|
|
else
|
|
|
|
pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* TODO */
|
|
|
|
break;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
pdev_network->Configuration.DSConfig = (pregistrypriv->channel);
|
|
|
|
|
|
|
|
if (cur_network->network.InfrastructureMode == Ndis802_11IBSS) {
|
|
|
|
pdev_network->Configuration.ATIMWindow = (0);
|
|
|
|
|
|
|
|
if (pmlmeext->cur_channel != 0)
|
|
|
|
pdev_network->Configuration.DSConfig = pmlmeext->cur_channel;
|
2017-04-07 11:39:45 +00:00
|
|
|
else
|
2016-03-27 17:56:02 +00:00
|
|
|
pdev_network->Configuration.DSConfig = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdev_network->InfrastructureMode = (cur_network->network.InfrastructureMode);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* 1. Supported rates */
|
|
|
|
/* 2. IE */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* rtw_set_supported_rate(pdev_network->SupportedRates, pregistrypriv->wireless_mode) ; */ /* will be called in rtw_generate_ie */
|
2016-03-27 17:56:02 +00:00
|
|
|
sz = rtw_generate_ie(pregistrypriv);
|
|
|
|
|
|
|
|
pdev_network->IELength = sz;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
pdev_network->Length = get_WLAN_BSSID_EX_sz((WLAN_BSSID_EX *)pdev_network);
|
|
|
|
|
|
|
|
/* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */
|
|
|
|
/* pdev_network->IELength = cpu_to_le32(sz); */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
void rtw_get_encrypt_decrypt_from_registrypriv(_adapter *adapter)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* the fucntion is at passive_level */
|
2016-03-27 17:56:02 +00:00
|
|
|
void rtw_joinbss_reset(_adapter *padapter)
|
|
|
|
{
|
|
|
|
u8 threshold;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
/* todo: if you want to do something io/reg/hw setting before join_bss, please add code here */
|
|
|
|
|
|
|
|
#ifdef CONFIG_80211N_HT
|
|
|
|
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
pmlmepriv->num_FortyMHzIntolerant = 0;
|
|
|
|
|
|
|
|
pmlmepriv->num_sta_no_ht = 0;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
phtpriv->ampdu_enable = _FALSE;/* reset to disabled */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI)
|
|
|
|
/* TH=1 => means that invalidate usb rx aggregation */
|
|
|
|
/* TH=0 => means that validate usb rx aggregation, use init value. */
|
|
|
|
if (phtpriv->ht_option) {
|
|
|
|
if (padapter->registrypriv.wifi_spec == 1)
|
2016-03-27 17:56:02 +00:00
|
|
|
threshold = 1;
|
|
|
|
else
|
2017-04-07 11:39:45 +00:00
|
|
|
threshold = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold));
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
2016-03-27 17:56:02 +00:00
|
|
|
threshold = 1;
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold));
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif/* #if defined( CONFIG_USB_HCI) || defined (CONFIG_SDIO_HCI) */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif/* #ifdef CONFIG_80211N_HT */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_80211N_HT
|
|
|
|
void rtw_ht_use_default_setting(_adapter *padapter)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
|
|
|
|
struct registry_priv *pregistrypriv = &padapter->registrypriv;
|
|
|
|
BOOLEAN bHwLDPCSupport = _FALSE, bHwSTBCSupport = _FALSE;
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_BEAMFORMING
|
2016-03-27 17:56:02 +00:00
|
|
|
BOOLEAN bHwSupportBeamformer = _FALSE, bHwSupportBeamformee = _FALSE;
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_BEAMFORMING */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if (pregistrypriv->wifi_spec)
|
|
|
|
phtpriv->bss_coexist = 1;
|
|
|
|
else
|
|
|
|
phtpriv->bss_coexist = 0;
|
|
|
|
|
|
|
|
phtpriv->sgi_40m = TEST_FLAG(pregistrypriv->short_gi, BIT1) ? _TRUE : _FALSE;
|
|
|
|
phtpriv->sgi_20m = TEST_FLAG(pregistrypriv->short_gi, BIT0) ? _TRUE : _FALSE;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* LDPC support */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_RX_LDPC, (u8 *)&bHwLDPCSupport);
|
|
|
|
CLEAR_FLAGS(phtpriv->ldpc_cap);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (bHwLDPCSupport) {
|
|
|
|
if (TEST_FLAG(pregistrypriv->ldpc_cap, BIT4))
|
2016-03-27 17:56:02 +00:00
|
|
|
SET_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_RX);
|
|
|
|
}
|
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_TX_LDPC, (u8 *)&bHwLDPCSupport);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (bHwLDPCSupport) {
|
|
|
|
if (TEST_FLAG(pregistrypriv->ldpc_cap, BIT5))
|
2016-03-27 17:56:02 +00:00
|
|
|
SET_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_TX);
|
|
|
|
}
|
|
|
|
if (phtpriv->ldpc_cap)
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("[HT] HAL Support LDPC = 0x%02X\n", phtpriv->ldpc_cap);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* STBC */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_TX_STBC, (u8 *)&bHwSTBCSupport);
|
|
|
|
CLEAR_FLAGS(phtpriv->stbc_cap);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (bHwSTBCSupport) {
|
|
|
|
if (TEST_FLAG(pregistrypriv->stbc_cap, BIT5))
|
2016-03-27 17:56:02 +00:00
|
|
|
SET_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX);
|
|
|
|
}
|
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_RX_STBC, (u8 *)&bHwSTBCSupport);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (bHwSTBCSupport) {
|
|
|
|
if (TEST_FLAG(pregistrypriv->stbc_cap, BIT4))
|
2016-03-27 17:56:02 +00:00
|
|
|
SET_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_RX);
|
|
|
|
}
|
|
|
|
if (phtpriv->stbc_cap)
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("[HT] HAL Support STBC = 0x%02X\n", phtpriv->stbc_cap);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* Beamforming setting */
|
|
|
|
CLEAR_FLAGS(phtpriv->beamform_cap);
|
|
|
|
#ifdef CONFIG_BEAMFORMING
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_EXPLICIT_BEAMFORMER, (u8 *)&bHwSupportBeamformer);
|
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_EXPLICIT_BEAMFORMEE, (u8 *)&bHwSupportBeamformee);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (TEST_FLAG(pregistrypriv->beamform_cap, BIT4) && bHwSupportBeamformer) {
|
2016-03-27 17:56:02 +00:00
|
|
|
SET_FLAG(phtpriv->beamform_cap, BEAMFORMING_HT_BEAMFORMER_ENABLE);
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("[HT] HAL Support Beamformer\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
if (TEST_FLAG(pregistrypriv->beamform_cap, BIT5) && bHwSupportBeamformee) {
|
2016-03-27 17:56:02 +00:00
|
|
|
SET_FLAG(phtpriv->beamform_cap, BEAMFORMING_HT_BEAMFORMEE_ENABLE);
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("[HT] HAL Support Beamformee\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_BEAMFORMING */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
void rtw_build_wmm_ie_ht(_adapter *padapter, u8 *out_ie, uint *pout_len)
|
|
|
|
{
|
|
|
|
unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
|
|
|
|
int out_len;
|
|
|
|
u8 *pframe;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (padapter->mlmepriv.qospriv.qos_option == 0) {
|
2016-03-27 17:56:02 +00:00
|
|
|
out_len = *pout_len;
|
2017-04-07 11:39:45 +00:00
|
|
|
pframe = rtw_set_ie(out_ie + out_len, _VENDOR_SPECIFIC_IE_,
|
|
|
|
_WMM_IE_Length_, WMM_IE, pout_len);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
padapter->mlmepriv.qospriv.qos_option = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the fucntion is >= passive_level */
|
|
|
|
unsigned int rtw_restructure_ht_ie(_adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len, u8 channel)
|
|
|
|
{
|
|
|
|
u32 ielen, out_len;
|
2017-04-07 11:39:45 +00:00
|
|
|
u32 rx_packet_offset, max_recvbuf_sz;
|
2016-03-27 17:56:02 +00:00
|
|
|
HT_CAP_AMPDU_FACTOR max_rx_ampdu_factor;
|
|
|
|
HT_CAP_AMPDU_DENSITY best_ampdu_density;
|
|
|
|
unsigned char *p, *pframe;
|
|
|
|
struct rtw_ieee80211_ht_cap ht_capie;
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 cbw40_enable = 0, rf_type = 0, operation_bw = 0, rf_num = 0, rx_stbc_nss = 0;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct registry_priv *pregistrypriv = &padapter->registrypriv;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
|
|
|
|
phtpriv->ht_option = _FALSE;
|
|
|
|
|
|
|
|
out_len = *pout_len;
|
|
|
|
|
|
|
|
_rtw_memset(&ht_capie, 0, sizeof(struct rtw_ieee80211_ht_cap));
|
|
|
|
|
|
|
|
ht_capie.cap_info = IEEE80211_HT_CAP_DSSSCCK40;
|
|
|
|
|
|
|
|
if (phtpriv->sgi_20m)
|
|
|
|
ht_capie.cap_info |= IEEE80211_HT_CAP_SGI_20;
|
|
|
|
|
|
|
|
/* Get HT BW */
|
|
|
|
if (in_ie == NULL) {
|
|
|
|
/* TDLS: TODO 20/40 issue */
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
|
|
|
|
operation_bw = padapter->mlmeextpriv.cur_bwmode;
|
|
|
|
if (operation_bw > CHANNEL_WIDTH_40)
|
|
|
|
operation_bw = CHANNEL_WIDTH_40;
|
|
|
|
} else
|
|
|
|
/* TDLS: TODO 40? */
|
|
|
|
operation_bw = CHANNEL_WIDTH_40;
|
|
|
|
} else {
|
|
|
|
p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len);
|
|
|
|
if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) {
|
2017-04-07 11:39:45 +00:00
|
|
|
struct HT_info_element *pht_info = (struct HT_info_element *)(p + 2);
|
2016-03-27 17:56:02 +00:00
|
|
|
if (pht_info->infos[0] & BIT(2)) {
|
|
|
|
switch (pht_info->infos[0] & 0x3) {
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
operation_bw = CHANNEL_WIDTH_40;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
operation_bw = CHANNEL_WIDTH_20;
|
|
|
|
break;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
} else
|
2016-03-27 17:56:02 +00:00
|
|
|
operation_bw = CHANNEL_WIDTH_20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* to disable 40M Hz support while gd_bw_40MHz_en = 0 */
|
|
|
|
if (hal_chk_bw_cap(padapter, BW_CAP_40M)) {
|
|
|
|
if (channel > 14) {
|
|
|
|
if (REGSTY_IS_BW_5G_SUPPORT(pregistrypriv, CHANNEL_WIDTH_40))
|
|
|
|
cbw40_enable = 1;
|
|
|
|
} else {
|
|
|
|
if (REGSTY_IS_BW_2G_SUPPORT(pregistrypriv, CHANNEL_WIDTH_40))
|
|
|
|
cbw40_enable = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((cbw40_enable == 1) && (operation_bw == CHANNEL_WIDTH_40)) {
|
|
|
|
ht_capie.cap_info |= IEEE80211_HT_CAP_SUP_WIDTH;
|
|
|
|
if (phtpriv->sgi_40m)
|
|
|
|
ht_capie.cap_info |= IEEE80211_HT_CAP_SGI_40;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* todo: disable SM power save mode */
|
|
|
|
ht_capie.cap_info |= IEEE80211_HT_CAP_SM_PS;
|
|
|
|
|
|
|
|
/* RX LDPC */
|
|
|
|
if (TEST_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_RX)) {
|
|
|
|
ht_capie.cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("[HT] Declare supporting RX LDPC\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* TX STBC */
|
|
|
|
if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX)) {
|
|
|
|
ht_capie.cap_info |= IEEE80211_HT_CAP_TX_STBC;
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("[HT] Declare supporting TX STBC\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* RX STBC */
|
|
|
|
if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_RX)) {
|
2017-04-07 11:39:45 +00:00
|
|
|
if ((pregistrypriv->rx_stbc == 0x3) || /* enable for 2.4/5 GHz */
|
|
|
|
((channel <= 14) && (pregistrypriv->rx_stbc == 0x1)) || /* enable for 2.4GHz */
|
|
|
|
((channel > 14) && (pregistrypriv->rx_stbc == 0x2)) || /* enable for 5GHz */
|
|
|
|
(pregistrypriv->wifi_spec == 1)) {
|
|
|
|
/* HAL_DEF_RX_STBC means STBC RX spatial stream, todo: VHT 4 streams */
|
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_RX_STBC, (u8 *)(&rx_stbc_nss));
|
|
|
|
SET_HT_CAP_ELE_RX_STBC(&ht_capie, rx_stbc_nss);
|
|
|
|
RTW_INFO("[HT] Declare supporting RX STBC = %d\n", rx_stbc_nss);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* fill default supported_mcs_set */
|
2016-03-27 17:56:02 +00:00
|
|
|
_rtw_memcpy(ht_capie.supp_mcs_set, pmlmeext->default_supported_mcs_set, 16);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* update default supported_mcs_set */
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
switch (rf_type) {
|
2016-03-27 17:56:02 +00:00
|
|
|
case RF_1T1R:
|
2017-04-07 11:39:45 +00:00
|
|
|
set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_1R);
|
|
|
|
break;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
case RF_2T2R:
|
|
|
|
case RF_1T2R:
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef CONFIG_DISABLE_MCS13TO15
|
|
|
|
if (((cbw40_enable == 1) && (operation_bw == CHANNEL_WIDTH_40)) && (pregistrypriv->wifi_spec != 1))
|
|
|
|
set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_2R_13TO15_OFF);
|
2016-03-27 17:56:02 +00:00
|
|
|
else
|
|
|
|
set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_2R);
|
2017-04-07 11:39:45 +00:00
|
|
|
#else /* CONFIG_DISABLE_MCS13TO15 */
|
|
|
|
set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_2R);
|
|
|
|
#endif /* CONFIG_DISABLE_MCS13TO15 */
|
2016-03-27 17:56:02 +00:00
|
|
|
break;
|
|
|
|
case RF_3T3R:
|
|
|
|
set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_3R);
|
|
|
|
break;
|
|
|
|
default:
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("[warning] rf_type %d is not expected\n", rf_type);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_RX_PACKET_OFFSET, &rx_packet_offset);
|
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_MAX_RECVBUF_SZ, &max_recvbuf_sz);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (max_recvbuf_sz - rx_packet_offset >= (8191 - 256)) {
|
|
|
|
RTW_INFO("%s IEEE80211_HT_CAP_MAX_AMSDU is set\n", __FUNCTION__);
|
|
|
|
ht_capie.cap_info = ht_capie.cap_info | IEEE80211_HT_CAP_MAX_AMSDU;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
/*
|
2016-03-27 17:56:02 +00:00
|
|
|
AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
|
2017-04-07 11:39:45 +00:00
|
|
|
AMPDU_para [4:2]:Min MPDU Start Spacing
|
2016-03-27 17:56:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-04-07 11:39:45 +00:00
|
|
|
#if defined(CONFIG_RTL8188E) && defined(CONFIG_SDIO_HCI)
|
2016-03-27 17:56:02 +00:00
|
|
|
ht_capie.ampdu_params_info = 2;
|
|
|
|
#else
|
|
|
|
ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR&0x03);
|
|
|
|
#endif
|
|
|
|
*/
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (padapter->driver_rx_ampdu_factor != 0xFF)
|
2016-03-27 17:56:02 +00:00
|
|
|
max_rx_ampdu_factor = (HT_CAP_AMPDU_FACTOR)padapter->driver_rx_ampdu_factor;
|
|
|
|
else
|
|
|
|
rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); */
|
|
|
|
ht_capie.ampdu_params_info = (max_rx_ampdu_factor & 0x03);
|
|
|
|
|
|
|
|
if (padapter->driver_rx_ampdu_spacing != 0xFF)
|
|
|
|
ht_capie.ampdu_params_info |= ((padapter->driver_rx_ampdu_spacing & 0x07) << 2);
|
|
|
|
else {
|
2016-03-27 17:56:02 +00:00
|
|
|
if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) {
|
|
|
|
/*
|
|
|
|
* Todo : Each chip must to ask DD , this chip best ampdu_density setting
|
|
|
|
* By yiwei.sun
|
|
|
|
*/
|
|
|
|
rtw_hal_get_def_var(padapter, HW_VAR_BEST_AMPDU_DENSITY, &best_ampdu_density);
|
|
|
|
|
|
|
|
ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY & (best_ampdu_density << 2));
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
} else
|
|
|
|
ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
#ifdef CONFIG_BEAMFORMING
|
|
|
|
ht_capie.tx_BF_cap_info = 0;
|
|
|
|
|
|
|
|
/* HT Beamformer*/
|
|
|
|
if (TEST_FLAG(phtpriv->beamform_cap, BEAMFORMING_HT_BEAMFORMER_ENABLE)) {
|
|
|
|
/* Transmit NDP Capable */
|
|
|
|
SET_HT_CAP_TXBF_TRANSMIT_NDP_CAP(&ht_capie, 1);
|
|
|
|
/* Explicit Compressed Steering Capable */
|
|
|
|
SET_HT_CAP_TXBF_EXPLICIT_COMP_STEERING_CAP(&ht_capie, 1);
|
|
|
|
/* Compressed Steering Number Antennas */
|
|
|
|
SET_HT_CAP_TXBF_COMP_STEERING_NUM_ANTENNAS(&ht_capie, 1);
|
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_BEAMFORMER_CAP, (u8 *)&rf_num);
|
|
|
|
SET_HT_CAP_TXBF_CHNL_ESTIMATION_NUM_ANTENNAS(&ht_capie, rf_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* HT Beamformee */
|
|
|
|
if (TEST_FLAG(phtpriv->beamform_cap, BEAMFORMING_HT_BEAMFORMEE_ENABLE)) {
|
|
|
|
/* Receive NDP Capable */
|
|
|
|
SET_HT_CAP_TXBF_RECEIVE_NDP_CAP(&ht_capie, 1);
|
|
|
|
/* Explicit Compressed Beamforming Feedback Capable */
|
|
|
|
SET_HT_CAP_TXBF_EXPLICIT_COMP_FEEDBACK_CAP(&ht_capie, 2);
|
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_BEAMFORMEE_CAP, (u8 *)&rf_num);
|
|
|
|
SET_HT_CAP_TXBF_COMP_STEERING_NUM_ANTENNAS(&ht_capie, rf_num);
|
|
|
|
}
|
|
|
|
#endif/*CONFIG_BEAMFORMING*/
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
pframe = rtw_set_ie(out_ie + out_len, _HT_CAPABILITY_IE_,
|
|
|
|
sizeof(struct rtw_ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
phtpriv->ht_option = _TRUE;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (in_ie != NULL) {
|
2016-03-27 17:56:02 +00:00
|
|
|
p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) {
|
|
|
|
out_len = *pout_len;
|
|
|
|
pframe = rtw_set_ie(out_ie + out_len, _HT_ADD_INFO_IE_, ielen, p + 2 , pout_len);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
return phtpriv->ht_option;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* the fucntion is > passive_level (in critical_section) */
|
2016-03-27 17:56:02 +00:00
|
|
|
void rtw_update_ht_cap(_adapter *padapter, u8 *pie, uint ie_len, u8 channel)
|
2017-04-07 11:39:45 +00:00
|
|
|
{
|
2016-03-27 17:56:02 +00:00
|
|
|
u8 *p, max_ampdu_sz;
|
2017-04-07 11:39:45 +00:00
|
|
|
int len;
|
|
|
|
/* struct sta_info *bmc_sta, *psta; */
|
2016-03-27 17:56:02 +00:00
|
|
|
struct rtw_ieee80211_ht_cap *pht_capie;
|
|
|
|
struct ieee80211_ht_addt_info *pht_addtinfo;
|
2017-04-07 11:39:45 +00:00
|
|
|
/* struct recv_reorder_ctrl *preorder_ctrl; */
|
2016-03-27 17:56:02 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
/* struct recv_priv *precvpriv = &padapter->recvpriv; */
|
2016-03-27 17:56:02 +00:00
|
|
|
struct registry_priv *pregistrypriv = &padapter->registrypriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
/* struct wlan_network *pcur_network = &(pmlmepriv->cur_network);; */
|
2016-03-27 17:56:02 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 cbw40_enable = 0;
|
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (!phtpriv->ht_option)
|
2016-03-27 17:56:02 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ((!pmlmeinfo->HT_info_enable) || (!pmlmeinfo->HT_caps_enable))
|
|
|
|
return;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("+rtw_update_ht_cap()\n");
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* maybe needs check if ap supports rx ampdu. */
|
|
|
|
if ((phtpriv->ampdu_enable == _FALSE) && (pregistrypriv->ampdu_enable == 1)) {
|
|
|
|
if (pregistrypriv->wifi_spec == 1) {
|
|
|
|
/* remove this part because testbed AP should disable RX AMPDU */
|
|
|
|
/* phtpriv->ampdu_enable = _FALSE; */
|
2016-03-27 17:56:02 +00:00
|
|
|
phtpriv->ampdu_enable = _TRUE;
|
2017-04-07 11:39:45 +00:00
|
|
|
} else
|
2016-03-27 17:56:02 +00:00
|
|
|
phtpriv->ampdu_enable = _TRUE;
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
/* check Max Rx A-MPDU Size */
|
2016-03-27 17:56:02 +00:00
|
|
|
len = 0;
|
2017-04-07 11:39:45 +00:00
|
|
|
p = rtw_get_ie(pie + sizeof(NDIS_802_11_FIXED_IEs), _HT_CAPABILITY_IE_, &len, ie_len - sizeof(NDIS_802_11_FIXED_IEs));
|
|
|
|
if (p && len > 0) {
|
|
|
|
pht_capie = (struct rtw_ieee80211_ht_cap *)(p + 2);
|
2016-03-27 17:56:02 +00:00
|
|
|
max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR);
|
2017-04-07 11:39:45 +00:00
|
|
|
max_ampdu_sz = 1 << (max_ampdu_sz + 3); /* max_ampdu_sz (kbytes); */
|
|
|
|
|
|
|
|
/* RTW_INFO("rtw_update_ht_cap(): max_ampdu_sz=%d\n", max_ampdu_sz); */
|
2016-03-27 17:56:02 +00:00
|
|
|
phtpriv->rx_ampdu_maxlen = max_ampdu_sz;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
len = 0;
|
|
|
|
p = rtw_get_ie(pie + sizeof(NDIS_802_11_FIXED_IEs), _HT_ADD_INFO_IE_, &len, ie_len - sizeof(NDIS_802_11_FIXED_IEs));
|
|
|
|
if (p && len > 0) {
|
|
|
|
pht_addtinfo = (struct ieee80211_ht_addt_info *)(p + 2);
|
|
|
|
/* todo: */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hal_chk_bw_cap(padapter, BW_CAP_40M)) {
|
|
|
|
if (channel > 14) {
|
|
|
|
if (REGSTY_IS_BW_5G_SUPPORT(pregistrypriv, CHANNEL_WIDTH_40))
|
|
|
|
cbw40_enable = 1;
|
|
|
|
} else {
|
|
|
|
if (REGSTY_IS_BW_2G_SUPPORT(pregistrypriv, CHANNEL_WIDTH_40))
|
|
|
|
cbw40_enable = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* update cur_bwmode & cur_ch_offset */
|
2016-03-27 17:56:02 +00:00
|
|
|
if ((cbw40_enable) &&
|
2017-04-07 11:39:45 +00:00
|
|
|
(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) &&
|
|
|
|
(pmlmeinfo->HT_info.infos[0] & BIT(2))) {
|
2016-03-27 17:56:02 +00:00
|
|
|
int i;
|
|
|
|
u8 rf_type = RF_1T1R;
|
|
|
|
|
|
|
|
rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* update the MCS set */
|
2016-03-27 17:56:02 +00:00
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= pmlmeext->default_supported_mcs_set[i];
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* update the MCS rates */
|
|
|
|
switch (rf_type) {
|
|
|
|
case RF_1T1R:
|
|
|
|
case RF_1T2R:
|
|
|
|
set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_1R);
|
|
|
|
break;
|
|
|
|
case RF_2T2R:
|
|
|
|
#ifdef CONFIG_DISABLE_MCS13TO15
|
|
|
|
if (pmlmeext->cur_bwmode == CHANNEL_WIDTH_40 && pregistrypriv->wifi_spec != 1)
|
|
|
|
set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R_13TO15_OFF);
|
|
|
|
else
|
2016-03-27 17:56:02 +00:00
|
|
|
set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
|
2017-04-07 11:39:45 +00:00
|
|
|
#else /* CONFIG_DISABLE_MCS13TO15 */
|
|
|
|
set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
|
|
|
|
#endif /* CONFIG_DISABLE_MCS13TO15 */
|
|
|
|
break;
|
|
|
|
case RF_3T3R:
|
|
|
|
set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_3R);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RTW_INFO("[warning] rf_type %d is not expected\n", rf_type);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* switch to the 40M Hz mode accoring to the AP */
|
|
|
|
/* pmlmeext->cur_bwmode = CHANNEL_WIDTH_40; */
|
|
|
|
switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) {
|
|
|
|
case EXTCHNL_OFFSET_UPPER:
|
|
|
|
pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EXTCHNL_OFFSET_LOWER:
|
|
|
|
pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
|
|
|
|
break;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* */
|
|
|
|
/* Config SM Power Save setting */
|
|
|
|
/* */
|
2016-03-27 17:56:02 +00:00
|
|
|
pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & 0x0C) >> 2;
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) {
|
|
|
|
#if 0
|
|
|
|
u8 i;
|
|
|
|
/* update the MCS rates */
|
2016-03-27 17:56:02 +00:00
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
pmlmeinfo->HT_caps.HT_cap_element.MCS_rate[i] &= MCS_rate_1R[i];
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
|
|
|
RTW_INFO("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __FUNCTION__);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* */
|
|
|
|
/* Config current HT Protection mode. */
|
|
|
|
/* */
|
2016-03-27 17:56:02 +00:00
|
|
|
pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
#if 0 /* move to rtw_update_sta_info_client() */
|
|
|
|
/* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */
|
|
|
|
/* if A-MPDU Rx is enabled, reseting rx_ordering_ctrl wstart_b(indicate_seq) to default value=0xffff */
|
|
|
|
/* todo: check if AP can send A-MPDU packets */
|
2016-03-27 17:56:02 +00:00
|
|
|
bmc_sta = rtw_get_bcmc_stainfo(padapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (bmc_sta) {
|
|
|
|
for (i = 0; i < 16 ; i++) {
|
|
|
|
/* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */
|
2016-03-27 17:56:02 +00:00
|
|
|
preorder_ctrl = &bmc_sta->recvreorder_ctrl[i];
|
|
|
|
preorder_ctrl->enable = _FALSE;
|
|
|
|
preorder_ctrl->indicate_seq = 0xffff;
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef DBG_RX_SEQ
|
|
|
|
RTW_INFO("DBG_RX_SEQ %s:%d indicate_seq:%u\n", __FUNCTION__, __LINE__,
|
|
|
|
preorder_ctrl->indicate_seq);
|
|
|
|
#endif
|
|
|
|
preorder_ctrl->wend_b = 0xffff;
|
|
|
|
preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; */ /* ex. 32(kbytes) -> wsize_b=32 */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
psta = rtw_get_stainfo(&padapter->stapriv, pcur_network->network.MacAddress);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (psta) {
|
|
|
|
for (i = 0; i < 16 ; i++) {
|
|
|
|
/* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */
|
2016-03-27 17:56:02 +00:00
|
|
|
preorder_ctrl = &psta->recvreorder_ctrl[i];
|
|
|
|
preorder_ctrl->enable = _FALSE;
|
|
|
|
preorder_ctrl->indicate_seq = 0xffff;
|
2017-04-07 11:39:45 +00:00
|
|
|
#ifdef DBG_RX_SEQ
|
|
|
|
RTW_INFO("DBG_RX_SEQ %s:%d indicate_seq:%u\n", __FUNCTION__, __LINE__,
|
|
|
|
preorder_ctrl->indicate_seq);
|
|
|
|
#endif
|
|
|
|
preorder_ctrl->wend_b = 0xffff;
|
|
|
|
preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; */ /* ex. 32(kbytes) -> wsize_b=32 */
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_TDLS
|
|
|
|
void rtw_issue_addbareq_cmd_tdls(_adapter *padapter, struct xmit_frame *pxmitframe)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct sta_info *ptdls_sta = NULL;
|
|
|
|
u8 issued;
|
|
|
|
int priority;
|
|
|
|
struct ht_priv *phtpriv;
|
|
|
|
|
|
|
|
priority = pattrib->priority;
|
|
|
|
|
|
|
|
if (pattrib->direct_link == _TRUE) {
|
|
|
|
ptdls_sta = rtw_get_stainfo(&padapter->stapriv, pattrib->dst);
|
|
|
|
if ((ptdls_sta != NULL) && (ptdls_sta->tdls_sta_state & TDLS_LINKED_STATE)) {
|
|
|
|
phtpriv = &ptdls_sta->htpriv;
|
|
|
|
|
|
|
|
if ((phtpriv->ht_option == _TRUE) && (phtpriv->ampdu_enable == _TRUE)) {
|
2017-04-07 11:39:45 +00:00
|
|
|
issued = (phtpriv->agg_enable_bitmap >> priority) & 0x1;
|
|
|
|
issued |= (phtpriv->candidate_tid_bitmap >> priority) & 0x1;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
if (0 == issued) {
|
2017-04-07 11:39:45 +00:00
|
|
|
RTW_INFO("[%s], p=%d\n", __FUNCTION__, priority);
|
2016-03-27 17:56:02 +00:00
|
|
|
ptdls_sta->htpriv.candidate_tid_bitmap |= BIT((u8)priority);
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_addbareq_cmd(padapter, (u8)priority, pattrib->dst);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_TDLS */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
void rtw_issue_addbareq_cmd(_adapter *padapter, struct xmit_frame *pxmitframe)
|
|
|
|
{
|
|
|
|
u8 issued;
|
|
|
|
int priority;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct sta_info *psta = NULL;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct ht_priv *phtpriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
2016-03-27 17:56:02 +00:00
|
|
|
s32 bmcst = IS_MCAST(pattrib->ra);
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* if(bmcst || (padapter->mlmepriv.LinkDetectInfo.bTxBusyTraffic == _FALSE)) */
|
|
|
|
if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100))
|
2016-03-27 17:56:02 +00:00
|
|
|
return;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
priority = pattrib->priority;
|
|
|
|
|
|
|
|
#ifdef CONFIG_TDLS
|
|
|
|
rtw_issue_addbareq_cmd_tdls(padapter, pxmitframe);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_TDLS */
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pattrib->psta != psta) {
|
|
|
|
RTW_INFO("%s, pattrib->psta(%p) != psta(%p)\n", __func__, pattrib->psta, psta);
|
2016-03-27 17:56:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
if (psta == NULL) {
|
|
|
|
RTW_INFO("%s, psta==NUL\n", __func__);
|
2016-03-27 17:56:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (!(psta->state & _FW_LINKED)) {
|
|
|
|
RTW_INFO("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
|
2016-03-27 17:56:02 +00:00
|
|
|
return;
|
2017-04-07 11:39:45 +00:00
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
phtpriv = &psta->htpriv;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if ((phtpriv->ht_option == _TRUE) && (phtpriv->ampdu_enable == _TRUE)) {
|
|
|
|
issued = (phtpriv->agg_enable_bitmap >> priority) & 0x1;
|
|
|
|
issued |= (phtpriv->candidate_tid_bitmap >> priority) & 0x1;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (0 == issued) {
|
|
|
|
RTW_INFO("rtw_issue_addbareq_cmd, p=%d\n", priority);
|
2016-03-27 17:56:02 +00:00
|
|
|
psta->htpriv.candidate_tid_bitmap |= BIT((u8)priority);
|
2017-04-07 11:39:45 +00:00
|
|
|
rtw_addbareq_cmd(padapter, (u8) priority, pattrib->ra);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_append_exented_cap(_adapter *padapter, u8 *out_ie, uint *pout_len)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2016-03-27 17:56:02 +00:00
|
|
|
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
|
|
|
|
#ifdef CONFIG_80211AC_VHT
|
|
|
|
struct vht_priv *pvhtpriv = &pmlmepriv->vhtpriv;
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_80211AC_VHT */
|
2016-03-27 17:56:02 +00:00
|
|
|
u8 cap_content[8] = { 0 };
|
|
|
|
u8 *pframe;
|
|
|
|
u8 null_content[8] = {0};
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (phtpriv->bss_coexist)
|
2016-03-27 17:56:02 +00:00
|
|
|
SET_EXT_CAPABILITY_ELE_BSS_COEXIST(cap_content, 1);
|
|
|
|
|
|
|
|
#ifdef CONFIG_80211AC_VHT
|
2017-04-07 11:39:45 +00:00
|
|
|
if (pvhtpriv->vht_option)
|
2016-03-27 17:56:02 +00:00
|
|
|
SET_EXT_CAPABILITY_ELE_OP_MODE_NOTIF(cap_content, 1);
|
2017-04-07 11:39:45 +00:00
|
|
|
#endif /* CONFIG_80211AC_VHT */
|
2016-03-27 17:56:02 +00:00
|
|
|
/*
|
|
|
|
From 802.11 specification,if a STA does not support any of capabilities defined
|
2017-04-07 11:39:45 +00:00
|
|
|
in the Extended Capabilities element, then the STA is not required to
|
|
|
|
transmit the Extended Capabilities element.
|
2016-03-27 17:56:02 +00:00
|
|
|
*/
|
|
|
|
if (_FALSE == _rtw_memcmp(cap_content, null_content, 8))
|
|
|
|
pframe = rtw_set_ie(out_ie + *pout_len, EID_EXTCapability, 8, cap_content , pout_len);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_LAYER2_ROAMING
|
|
|
|
inline void rtw_set_to_roam(_adapter *adapter, u8 to_roam)
|
|
|
|
{
|
|
|
|
if (to_roam == 0)
|
|
|
|
adapter->mlmepriv.to_join = _FALSE;
|
|
|
|
adapter->mlmepriv.to_roam = to_roam;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline u8 rtw_dec_to_roam(_adapter *adapter)
|
|
|
|
{
|
|
|
|
adapter->mlmepriv.to_roam--;
|
|
|
|
return adapter->mlmepriv.to_roam;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline u8 rtw_to_roam(_adapter *adapter)
|
|
|
|
{
|
|
|
|
return adapter->mlmepriv.to_roam;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_roaming(_adapter *padapter, struct wlan_network *tgt_network)
|
|
|
|
{
|
|
|
|
_irqL irqL;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
|
|
|
|
_enter_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
_rtw_roaming(padapter, tgt_network);
|
|
|
|
_exit_critical_bh(&pmlmepriv->lock, &irqL);
|
|
|
|
}
|
|
|
|
void _rtw_roaming(_adapter *padapter, struct wlan_network *tgt_network)
|
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct wlan_network *cur_network = &pmlmepriv->cur_network;
|
|
|
|
int do_join_r;
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
if (0 < rtw_to_roam(padapter)) {
|
|
|
|
RTW_INFO("roaming from %s("MAC_FMT"), length:%d\n",
|
|
|
|
cur_network->network.Ssid.Ssid, MAC_ARG(cur_network->network.MacAddress),
|
|
|
|
cur_network->network.Ssid.SsidLength);
|
2016-03-27 17:56:02 +00:00
|
|
|
_rtw_memcpy(&pmlmepriv->assoc_ssid, &cur_network->network.Ssid, sizeof(NDIS_802_11_SSID));
|
|
|
|
|
|
|
|
pmlmepriv->assoc_by_bssid = _FALSE;
|
|
|
|
|
|
|
|
#ifdef CONFIG_WAPI_SUPPORT
|
|
|
|
rtw_wapi_return_all_sta_info(padapter);
|
|
|
|
#endif
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
while (1) {
|
|
|
|
do_join_r = rtw_do_join(padapter);
|
|
|
|
if (_SUCCESS == do_join_r)
|
2016-03-27 17:56:02 +00:00
|
|
|
break;
|
2017-04-07 11:39:45 +00:00
|
|
|
else {
|
|
|
|
RTW_INFO("roaming do_join return %d\n", do_join_r);
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_dec_to_roam(padapter);
|
2017-04-07 11:39:45 +00:00
|
|
|
|
|
|
|
if (rtw_to_roam(padapter) > 0)
|
2016-03-27 17:56:02 +00:00
|
|
|
continue;
|
2017-04-07 11:39:45 +00:00
|
|
|
else {
|
|
|
|
RTW_INFO("%s(%d) -to roaming fail, indicate_disconnect\n", __FUNCTION__, __LINE__);
|
|
|
|
rtw_indicate_disconnect(padapter, 0, _FALSE);
|
2016-03-27 17:56:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_LAYER2_ROAMING */
|
|
|
|
|
|
|
|
bool rtw_adjust_chbw(_adapter *adapter, u8 req_ch, u8 *req_bw, u8 *req_offset)
|
|
|
|
{
|
|
|
|
struct registry_priv *regsty = adapter_to_regsty(adapter);
|
|
|
|
u8 allowed_bw;
|
|
|
|
|
|
|
|
if (req_ch <= 14)
|
|
|
|
allowed_bw = REGSTY_BW_2G(regsty);
|
|
|
|
else
|
|
|
|
allowed_bw = REGSTY_BW_5G(regsty);
|
|
|
|
|
|
|
|
allowed_bw = hal_largest_bw(adapter, allowed_bw);
|
|
|
|
|
|
|
|
if (allowed_bw == CHANNEL_WIDTH_80 && *req_bw > CHANNEL_WIDTH_80)
|
|
|
|
*req_bw = CHANNEL_WIDTH_80;
|
|
|
|
else if (allowed_bw == CHANNEL_WIDTH_40 && *req_bw > CHANNEL_WIDTH_40)
|
|
|
|
*req_bw = CHANNEL_WIDTH_40;
|
|
|
|
else if (allowed_bw == CHANNEL_WIDTH_20 && *req_bw > CHANNEL_WIDTH_20) {
|
|
|
|
*req_bw = CHANNEL_WIDTH_20;
|
|
|
|
*req_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
|
|
|
|
} else
|
|
|
|
return _FALSE;
|
|
|
|
|
|
|
|
return _TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
sint rtw_linked_check(_adapter *padapter)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
if ((check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == _TRUE) ||
|
|
|
|
(check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE) == _TRUE)) {
|
|
|
|
if (padapter->stapriv.asoc_sta_count > 2)
|
2016-03-27 17:56:02 +00:00
|
|
|
return _TRUE;
|
2017-04-07 11:39:45 +00:00
|
|
|
} else {
|
|
|
|
/* Station mode */
|
|
|
|
if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == _TRUE)
|
2016-03-27 17:56:02 +00:00
|
|
|
return _TRUE;
|
|
|
|
}
|
|
|
|
return _FALSE;
|
|
|
|
}
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 rtw_is_adapter_up(_adapter *padapter)
|
|
|
|
{
|
|
|
|
if (padapter == NULL)
|
|
|
|
return _FALSE;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (RTW_CANNOT_RUN(padapter)) {
|
|
|
|
RTW_INFO(FUNC_ADPT_FMT "-(bSurpriseRemoved == _TRUE) || ( bDriverStopped == _TRUE)\n", FUNC_ADPT_ARG(padapter));
|
|
|
|
return _FALSE;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (!rtw_is_hw_init_completed(padapter)) {
|
|
|
|
/*RTW_INFO(FUNC_ADPT_FMT "-(hw_init_completed == _FALSE)\n", FUNC_ADPT_ARG(padapter));*/
|
|
|
|
return _FALSE;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (padapter->bup == _FALSE) {
|
|
|
|
/*RTW_INFO(FUNC_ADPT_FMT "-(bup == _FALSE)\n", FUNC_ADPT_ARG(padapter));*/
|
|
|
|
return _FALSE;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
return _TRUE;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
bool is_miracast_enabled(_adapter *adapter)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
bool enabled = 0;
|
|
|
|
#ifdef CONFIG_WFD
|
|
|
|
struct wifi_display_info *wfdinfo = &adapter->wfd_info;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
enabled = (wfdinfo->stack_wfd_mode & (MIRACAST_SOURCE | MIRACAST_SINK))
|
|
|
|
|| (wfdinfo->op_wfd_mode & (MIRACAST_SOURCE | MIRACAST_SINK));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return enabled;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
bool rtw_chk_miracast_mode(_adapter *adapter, u8 mode)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
bool ret = 0;
|
|
|
|
#ifdef CONFIG_WFD
|
|
|
|
struct wifi_display_info *wfdinfo = &adapter->wfd_info;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
ret = (wfdinfo->stack_wfd_mode & mode) || (wfdinfo->op_wfd_mode & mode);
|
|
|
|
#endif
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
const char *get_miracast_mode_str(int mode)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
if (mode == MIRACAST_SOURCE)
|
|
|
|
return "SOURCE";
|
|
|
|
else if (mode == MIRACAST_SINK)
|
|
|
|
return "SINK";
|
|
|
|
else if (mode == (MIRACAST_SOURCE | MIRACAST_SINK))
|
|
|
|
return "SOURCE&SINK";
|
|
|
|
else if (mode == MIRACAST_DISABLED)
|
|
|
|
return "DISABLED";
|
|
|
|
else
|
|
|
|
return "INVALID";
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_WFD
|
|
|
|
static bool wfd_st_match_rule(_adapter *adapter, u8 *local_naddr, u8 *local_port, u8 *remote_naddr, u8 *remote_port)
|
|
|
|
{
|
|
|
|
struct wifi_display_info *wfdinfo = &adapter->wfd_info;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
if (ntohs(*((u16 *)local_port)) == wfdinfo->rtsp_ctrlport
|
|
|
|
|| ntohs(*((u16 *)local_port)) == wfdinfo->tdls_rtsp_ctrlport
|
|
|
|
|| ntohs(*((u16 *)remote_port)) == wfdinfo->peer_rtsp_ctrlport)
|
|
|
|
return _TRUE;
|
|
|
|
return _FALSE;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
static struct st_register wfd_st_reg = {
|
|
|
|
.s_proto = 0x06,
|
|
|
|
.rule = wfd_st_match_rule,
|
|
|
|
};
|
|
|
|
#endif /* CONFIG_WFD */
|
|
|
|
|
|
|
|
inline void rtw_wfd_st_switch(struct sta_info *sta, bool on)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_WFD
|
|
|
|
if (on)
|
|
|
|
rtw_st_ctl_register(&sta->st_ctl, SESSION_TRACKER_REG_ID_WFD, &wfd_st_reg);
|
|
|
|
else
|
|
|
|
rtw_st_ctl_unregister(&sta->st_ctl, SESSION_TRACKER_REG_ID_WFD);
|
|
|
|
#endif
|
|
|
|
}
|