2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
|
2014-12-19 06:59:46 +00:00
|
|
|
*
|
2013-05-08 21:45:39 +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_WLAN_UTIL_C_
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#include <drv_conf.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <osdep_service.h>
|
|
|
|
#include <drv_types.h>
|
|
|
|
#include <wifi.h>
|
2014-12-15 05:08:37 +00:00
|
|
|
#include <rtw_mlme_ext.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef CONFIG_WOWLAN
|
|
|
|
#include <linux/inetdevice.h>
|
|
|
|
#endif
|
|
|
|
|
2014-12-15 05:08:37 +00:00
|
|
|
static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f};
|
|
|
|
static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74};
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-15 05:08:37 +00:00
|
|
|
static unsigned char BROADCOM_OUI1[] = {0x00, 0x10, 0x18};
|
|
|
|
static unsigned char BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7};
|
|
|
|
static unsigned char BROADCOM_OUI3[] = {0x00, 0x05, 0xb5};
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-15 05:08:37 +00:00
|
|
|
static unsigned char CISCO_OUI[] = {0x00, 0x40, 0x96};
|
|
|
|
static unsigned char MARVELL_OUI[] = {0x00, 0x50, 0x43};
|
|
|
|
static unsigned char RALINK_OUI[] = {0x00, 0x0c, 0x43};
|
|
|
|
static unsigned char REALTEK_OUI[] = {0x00, 0xe0, 0x4c};
|
|
|
|
static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5};
|
|
|
|
static unsigned char EPIGRAM_OUI[] = {0x00, 0x90, 0x4c};
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20};
|
|
|
|
|
|
|
|
#define R2T_PHY_DELAY (0)
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* define WAIT_FOR_BCN_TO_MIN (3000) */
|
2013-05-08 21:45:39 +00:00
|
|
|
#define WAIT_FOR_BCN_TO_MIN (6000)
|
|
|
|
#define WAIT_FOR_BCN_TO_MAX (20000)
|
|
|
|
|
|
|
|
static u8 rtw_basic_rate_cck[4] = {
|
|
|
|
IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK,
|
|
|
|
IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK
|
|
|
|
};
|
|
|
|
|
|
|
|
static u8 rtw_basic_rate_ofdm[3] = {
|
|
|
|
IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK,
|
|
|
|
IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK
|
|
|
|
};
|
|
|
|
|
|
|
|
static u8 rtw_basic_rate_mix[7] = {
|
|
|
|
IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK,
|
|
|
|
IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK,
|
|
|
|
IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK,
|
|
|
|
IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK
|
|
|
|
};
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
int cckrates_included(unsigned char *rate, int ratelen)
|
|
|
|
{
|
|
|
|
int i;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i = 0; i < ratelen; i++)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
if ( (((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
|
|
|
|
(((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22) )
|
2015-03-10 16:18:03 +00:00
|
|
|
return true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int cckratesonly_included(unsigned char *rate, int ratelen)
|
|
|
|
{
|
|
|
|
int i;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i = 0; i < ratelen; i++)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
if ( (((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
|
|
|
|
(((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22) )
|
2015-03-10 16:18:03 +00:00
|
|
|
return false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char networktype_to_raid(unsigned char network_type)
|
|
|
|
{
|
|
|
|
unsigned char raid;
|
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (network_type)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
case WIRELESS_11B:
|
|
|
|
raid = RATR_INX_WIRELESS_B;
|
|
|
|
break;
|
|
|
|
case WIRELESS_11A:
|
|
|
|
case WIRELESS_11G:
|
|
|
|
raid = RATR_INX_WIRELESS_G;
|
|
|
|
break;
|
|
|
|
case WIRELESS_11BG:
|
|
|
|
raid = RATR_INX_WIRELESS_GB;
|
|
|
|
break;
|
|
|
|
case WIRELESS_11_24N:
|
|
|
|
case WIRELESS_11_5N:
|
|
|
|
raid = RATR_INX_WIRELESS_N;
|
|
|
|
break;
|
|
|
|
case WIRELESS_11A_5N:
|
|
|
|
case WIRELESS_11G_24N:
|
|
|
|
raid = RATR_INX_WIRELESS_NG;
|
|
|
|
break;
|
|
|
|
case WIRELESS_11BG_24N:
|
|
|
|
raid = RATR_INX_WIRELESS_NGB;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
raid = RATR_INX_WIRELESS_GB;
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return raid;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int ratelen)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 network_type = 0;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmeext->cur_channel > 14)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pmlmeinfo->HT_enable)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type = WIRELESS_11_5N;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type |= WIRELESS_11A;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pmlmeinfo->HT_enable)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type = WIRELESS_11_24N;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ((cckratesonly_included(rate, ratelen)) == true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type |= WIRELESS_11B;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if ((cckrates_included(rate, ratelen)) == true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type |= WIRELESS_11BG;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type |= WIRELESS_11G;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
return network_type;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
unsigned char ratetbl_val_2wifirate(unsigned char rate);
|
|
|
|
unsigned char ratetbl_val_2wifirate(unsigned char rate)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned char val = 0;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
switch (rate & 0x7f)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
val = IEEE80211_CCK_RATE_1MB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
val = IEEE80211_CCK_RATE_2MB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
val = IEEE80211_CCK_RATE_5MB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
val = IEEE80211_CCK_RATE_11MB;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case 4:
|
|
|
|
val = IEEE80211_OFDM_RATE_6MB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
val = IEEE80211_OFDM_RATE_9MB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
val = IEEE80211_OFDM_RATE_12MB;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case 7:
|
|
|
|
val = IEEE80211_OFDM_RATE_18MB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
val = IEEE80211_OFDM_RATE_24MB;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case 9:
|
|
|
|
val = IEEE80211_OFDM_RATE_36MB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 10:
|
|
|
|
val = IEEE80211_OFDM_RATE_48MB;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case 11:
|
|
|
|
val = IEEE80211_OFDM_RATE_54MB;
|
|
|
|
break;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return val;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
int is_basicrate(struct adapter *padapter, unsigned char rate);
|
|
|
|
int is_basicrate(struct adapter *padapter, unsigned char rate)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned char val;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i = 0; i < NumRates; i++)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
val = pmlmeext->basicrate[i];
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if ((val != 0xff) && (val != 0xfe))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
if (rate == ratetbl_val_2wifirate(val))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rateset);
|
|
|
|
unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rateset)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned char rate;
|
|
|
|
unsigned int len = 0;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = 0; i < NumRates; i++)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rate = pmlmeext->datarate[i];
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch (rate)
|
|
|
|
{
|
|
|
|
case 0xff:
|
|
|
|
return len;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case 0xfe:
|
|
|
|
continue;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
default:
|
|
|
|
rate = ratetbl_val_2wifirate(rate);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (is_basicrate(padapter, rate) == true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
rate |= IEEE80211_BASIC_RATE_MASK;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
rateset[len] = rate;
|
|
|
|
len++;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrate_len)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned char supportedrates[NumRates];
|
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(supportedrates, 0, NumRates);
|
2013-05-08 21:45:39 +00:00
|
|
|
*bssrate_len = ratetbl2rateset(padapter, supportedrates);
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pbssrate, supportedrates, *bssrate_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
void UpdateBrateTbl(
|
2015-03-13 17:06:38 +00:00
|
|
|
struct adapter * Adapter,
|
|
|
|
u8 *mBratesOS
|
2014-12-11 21:15:04 +00:00
|
|
|
)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 rate;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* 1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */
|
2015-08-15 18:19:16 +00:00
|
|
|
for (i =0;i<NDIS_802_11_LENGTH_RATES_EX;i++)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
rate = mBratesOS[i] & 0x7f;
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (rate)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
case IEEE80211_CCK_RATE_1MB:
|
|
|
|
case IEEE80211_CCK_RATE_2MB:
|
|
|
|
case IEEE80211_CCK_RATE_5MB:
|
|
|
|
case IEEE80211_CCK_RATE_11MB:
|
|
|
|
case IEEE80211_OFDM_RATE_6MB:
|
|
|
|
case IEEE80211_OFDM_RATE_12MB:
|
|
|
|
case IEEE80211_OFDM_RATE_24MB:
|
|
|
|
mBratesOS[i] |= IEEE80211_BASIC_RATE_MASK;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 rate;
|
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
for (i =0;i<bssratelen;i++)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rate = bssrateset[i] & 0x7f;
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (rate)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
case IEEE80211_CCK_RATE_1MB:
|
|
|
|
case IEEE80211_CCK_RATE_2MB:
|
|
|
|
case IEEE80211_CCK_RATE_5MB:
|
|
|
|
case IEEE80211_CCK_RATE_11MB:
|
|
|
|
bssrateset[i] |= IEEE80211_BASIC_RATE_MASK;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void Save_DM_Func_Flag(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
u8 bSaveFlag = true;
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void Restore_DM_Func_Flag(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
u8 bSaveFlag = false;
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (enable == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode));
|
|
|
|
else
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode));
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void Set_NETYPE1_MSR(struct adapter *padapter, u8 type)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_MEDIA_STATUS1, (u8 *)(&type));
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void Set_NETYPE0_MSR(struct adapter *padapter, u8 type)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type));
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void Set_MSR(struct adapter *padapter, u8 type)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-15 20:31:30 +00:00
|
|
|
Set_NETYPE0_MSR(padapter, type);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
inline u8 rtw_get_oper_ch(struct adapter *adapter)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
return adapter_to_dvobj(adapter)->oper_channel;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
if (adapter_to_dvobj(adapter)->oper_channel != ch)
|
|
|
|
adapter_to_dvobj(adapter)->on_oper_ch_time = rtw_get_current_time();
|
|
|
|
|
|
|
|
adapter_to_dvobj(adapter)->oper_channel = ch;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
inline u8 rtw_get_oper_bw(struct adapter *adapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
return adapter_to_dvobj(adapter)->oper_bwmode;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
inline void rtw_set_oper_bw(struct adapter *adapter, u8 bw)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
adapter_to_dvobj(adapter)->oper_bwmode = bw;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
inline u8 rtw_get_oper_choffset(struct adapter *adapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
return adapter_to_dvobj(adapter)->oper_ch_offset;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
inline void rtw_set_oper_choffset(struct adapter *adapter, u8 offset)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
adapter_to_dvobj(adapter)->oper_ch_offset = offset;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
inline u32 rtw_get_on_oper_ch_time(struct adapter *adapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
return adapter_to_dvobj(adapter)->on_oper_ch_time;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
inline u32 rtw_get_on_cur_ch_time(struct adapter *adapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
if (adapter->mlmeextpriv.cur_channel == adapter_to_dvobj(adapter)->oper_channel)
|
|
|
|
return adapter_to_dvobj(adapter)->on_oper_ch_time;
|
|
|
|
else
|
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void SelectChannel(struct adapter *padapter, unsigned char channel)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
_enter_critical_mutex(&(adapter_to_dvobj(padapter)->setch_mutex), NULL);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* saved channel info */
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_set_oper_ch(padapter, channel);
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_set_chan(padapter, channel);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
_exit_critical_mutex(&(adapter_to_dvobj(padapter)->setch_mutex), NULL);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void SetBWMode(struct adapter *padapter, unsigned short bwmode, unsigned char channel_offset)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
|
|
|
|
_enter_critical_mutex(&(adapter_to_dvobj(padapter)->setbw_mutex), NULL);
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* saved bw info */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_set_oper_bw(padapter, bwmode);
|
|
|
|
rtw_set_oper_choffset(padapter, channel_offset);
|
|
|
|
|
2015-03-15 17:43:37 +00:00
|
|
|
rtw_hal_set_bwmode(padapter, (enum HT_CHANNEL_WIDTH)bwmode, channel_offset);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
_exit_critical_mutex(&(adapter_to_dvobj(padapter)->setbw_mutex), NULL);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 center_ch;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if ( padapter->bNotifyChannelChange )
|
|
|
|
{
|
|
|
|
DBG_871X( "[%s] ch = %d, offset = %d, bwmode = %d\n", __FUNCTION__, channel, channel_offset, bwmode );
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((bwmode == HT_CHANNEL_WIDTH_20)||(channel_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* SelectChannel(padapter, channel); */
|
2013-05-08 21:45:39 +00:00
|
|
|
center_ch = channel;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* switch to the proper channel */
|
2014-12-11 21:15:04 +00:00
|
|
|
if (channel_offset == HAL_PRIME_CHNL_OFFSET_LOWER)
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* SelectChannel(padapter, channel + 2); */
|
2013-05-08 21:45:39 +00:00
|
|
|
center_ch = channel + 2;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* SelectChannel(padapter, channel - 2); */
|
2013-05-08 21:45:39 +00:00
|
|
|
center_ch = channel - 2;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* set Channel */
|
2014-12-11 21:15:04 +00:00
|
|
|
_enter_critical_mutex(&(adapter_to_dvobj(padapter)->setch_mutex), NULL);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* saved channel/bw info */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_set_oper_ch(padapter, channel);
|
|
|
|
rtw_set_oper_bw(padapter, bwmode);
|
|
|
|
rtw_set_oper_choffset(padapter, channel_offset);
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
rtw_hal_set_chan(padapter, center_ch); /* set center channel */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
_exit_critical_mutex(&(adapter_to_dvobj(padapter)->setch_mutex), NULL);
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
SetBWMode(padapter, bwmode, channel_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
int get_bsstype(unsigned short capability)
|
|
|
|
{
|
|
|
|
if (capability & BIT(0))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
return WIFI_FW_AP_STATE;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else if (capability & BIT(1))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
return WIFI_FW_ADHOC_STATE;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return 0;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-07 00:26:23 +00:00
|
|
|
__inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
|
|
|
return (pnetwork->MacAddress);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-07 00:26:23 +00:00
|
|
|
u16 get_beacon_interval(struct wlan_bssid_ex *bss)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-15 05:08:37 +00:00
|
|
|
__le16 le_val;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-15 05:08:37 +00:00
|
|
|
memcpy(&le_val, rtw_get_beacon_interval_from_ie(bss->IEs), 2);
|
2014-12-19 06:59:46 +00:00
|
|
|
return le16_to_cpu(le_val);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
int is_client_associated_to_ap(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct mlme_ext_priv *pmlmeext;
|
|
|
|
struct mlme_ext_info *pmlmeinfo;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
|
|
|
|
pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
int is_client_associated_to_ibss(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
int is_IBSS_empty(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = IBSS_START_MAC_ID; i < NUM_STA; i++)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pmlmeinfo->FW_sta_info[i].status == 1)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval)
|
|
|
|
{
|
|
|
|
if ((bcn_interval << 2) < WAIT_FOR_BCN_TO_MIN)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
return WAIT_FOR_BCN_TO_MIN;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else if ((bcn_interval << 2) > WAIT_FOR_BCN_TO_MAX)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
return WAIT_FOR_BCN_TO_MAX;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
return ((bcn_interval << 2));
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
void CAM_empty_entry(
|
2014-12-19 06:59:46 +00:00
|
|
|
struct adapter * Adapter,
|
|
|
|
u8 ucIndex
|
2014-12-11 21:15:04 +00:00
|
|
|
)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
rtw_hal_set_hwreg(Adapter, HW_VAR_CAM_EMPTY_ENTRY, (u8 *)(&ucIndex));
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void invalidate_cam_all(struct adapter *padapter)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-15 05:08:37 +00:00
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
void read_cam(struct adapter *padapter , u8 entry)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-08-15 18:19:16 +00:00
|
|
|
u32 j, count = 0, addr;
|
2015-02-19 21:34:32 +00:00
|
|
|
u32 cam_val[2]; /* cam_val[0] is read_val, cam_val[1] is the address */
|
2014-12-11 21:15:04 +00:00
|
|
|
addr = entry << 3;
|
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
DBG_8192C("********* DUMP CAM Entry_#%02d***************\n", entry);
|
2014-12-11 21:15:04 +00:00
|
|
|
for (j = 0; j < 6; j++)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-08-15 18:19:16 +00:00
|
|
|
/* cmd = _ReadCAM(padapter , addr+j); */
|
2015-02-19 21:34:32 +00:00
|
|
|
/* HW_VAR_CAM_READ */
|
2014-12-11 21:15:04 +00:00
|
|
|
cam_val[1]=addr+j;
|
|
|
|
rtw_hal_get_hwreg(padapter, HW_VAR_CAM_READ, (u8 *)cam_val);
|
2015-08-15 18:19:16 +00:00
|
|
|
DBG_8192C("offset:0x%02x => 0x%08x\n", addr+j, cam_val[0]);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
DBG_8192C("*********************************\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned int i, val, addr;
|
|
|
|
int j;
|
|
|
|
u32 cam_val[2];
|
|
|
|
|
|
|
|
addr = entry << 3;
|
|
|
|
|
2015-01-30 03:41:53 +00:00
|
|
|
for (j = 5; j >= 0; j--) {
|
|
|
|
switch (j) {
|
|
|
|
case 0:
|
|
|
|
val = (ctrl | (mac[0] << 16) | (mac[1] << 24) );
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
val = (mac[2] | ( mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
i = (j - 2) << 2;
|
|
|
|
val = (key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24));
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cam_val[0] = val;
|
|
|
|
cam_val[1] = addr + (unsigned int)j;
|
|
|
|
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_CAM_WRITE, (u8 *)cam_val);
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void clear_cam_entry(struct adapter *padapter, u8 entry)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
2015-08-15 18:19:16 +00:00
|
|
|
unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
write_cam(padapter, entry, 0, null_sta, null_key);
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
int allocate_fw_sta_entry(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned int mac_id;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-30 03:41:53 +00:00
|
|
|
for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) {
|
|
|
|
if (pmlmeinfo->FW_sta_info[mac_id].status == 0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->FW_sta_info[mac_id].status = 1;
|
|
|
|
pmlmeinfo->FW_sta_info[mac_id].retry = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return mac_id;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void flush_all_cam_entry(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL);
|
2015-01-30 03:41:53 +00:00
|
|
|
memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 04:48:40 +00:00
|
|
|
#if defined(CONFIG_P2P) && defined(CONFIG_P2P)
|
2015-03-14 23:14:05 +00:00
|
|
|
int WFD_info_handler(struct adapter *padapter, struct ndis_802_11_variable_ies * pIE)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
struct registry_priv *pregpriv = &padapter->registrypriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct wifidirect_info *pwdinfo;
|
2014-12-11 21:15:04 +00:00
|
|
|
u8 wfd_ie[ 128 ] = { 0x00 };
|
|
|
|
u32 wfd_ielen = 0;
|
|
|
|
|
|
|
|
|
|
|
|
pwdinfo = &padapter->wdinfo;
|
|
|
|
if ( rtw_get_wfd_ie( ( u8* ) pIE, pIE->Length, wfd_ie, &wfd_ielen ) )
|
|
|
|
{
|
|
|
|
u8 attr_content[ 10 ] = { 0x00 };
|
|
|
|
u32 attr_contentlen = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X( "[%s] Found WFD IE\n", __FUNCTION__ );
|
|
|
|
rtw_get_wfd_attr_content( wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen);
|
|
|
|
if ( attr_contentlen )
|
|
|
|
{
|
|
|
|
pwdinfo->wfd_info->peer_rtsp_ctrlport = RTW_GET_BE16( attr_content + 2 );
|
|
|
|
DBG_8192C( "[%s] Peer PORT NUM = %d\n", __FUNCTION__, pwdinfo->wfd_info->peer_rtsp_ctrlport );
|
2014-12-29 02:13:24 +00:00
|
|
|
return( true );
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_871X( "[%s] NO WFD IE\n", __FUNCTION__ );
|
|
|
|
|
|
|
|
}
|
|
|
|
return( _FAIL );
|
|
|
|
}
|
|
|
|
#endif
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_variable_ies * pIE)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* struct registry_priv *pregpriv = &padapter->registrypriv; */
|
2014-12-11 21:15:04 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if (pmlmepriv->qospriv.qos_option == 0)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->WMM_enable = 0;
|
|
|
|
return _FAIL;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pmlmeinfo->WMM_enable = 1;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&(pmlmeinfo->WMM_param), (pIE->data + 6), sizeof(struct WMM_para_element));
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void WMMOnAssocRsp(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime;
|
|
|
|
u8 acm_mask;
|
|
|
|
u16 TXOP;
|
|
|
|
u32 acParm, i;
|
|
|
|
u32 edca[4], inx[4];
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
struct registry_priv *pregpriv = &padapter->registrypriv;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pmlmeinfo->WMM_enable == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->mlmepriv.acm_mask = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
acm_mask = 0;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( pmlmeext->cur_wireless_mode == WIRELESS_11B)
|
2013-05-08 21:45:39 +00:00
|
|
|
aSifsTime = 10;
|
|
|
|
else
|
|
|
|
aSifsTime = 16;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ACI = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 5) & 0x03;
|
|
|
|
ACM = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 4) & 0x01;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* AIFS = AIFSN * slot time + SIFS - r2t phy delay */
|
2013-05-08 21:45:39 +00:00
|
|
|
AIFS = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN & 0x0f) * pmlmeinfo->slotTime + aSifsTime;
|
|
|
|
|
|
|
|
ECWMin = (pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f);
|
|
|
|
ECWMax = (pmlmeinfo->WMM_param.ac_param[i].CW & 0xf0) >> 4;
|
|
|
|
TXOP = le16_to_cpu(pmlmeinfo->WMM_param.ac_param[i].TXOP_limit);
|
|
|
|
|
|
|
|
acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch (ACI)
|
|
|
|
{
|
|
|
|
case 0x0:
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm));
|
|
|
|
acm_mask |= (ACM? BIT(1):0);
|
|
|
|
edca[XMIT_BE_QUEUE] = acParm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x1:
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm));
|
2015-02-19 21:34:32 +00:00
|
|
|
/* acm_mask |= (ACM? BIT(0):0); */
|
2014-12-11 21:15:04 +00:00
|
|
|
edca[XMIT_BK_QUEUE] = acParm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x2:
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm));
|
|
|
|
acm_mask |= (ACM? BIT(2):0);
|
|
|
|
edca[XMIT_VI_QUEUE] = acParm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x3:
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm));
|
|
|
|
acm_mask |= (ACM? BIT(3):0);
|
|
|
|
edca[XMIT_VO_QUEUE] = acParm;
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("WMM(%x): %x, %x\n", ACI, ACM, acParm);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (padapter->registrypriv.acm_method == 1)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask));
|
|
|
|
else
|
|
|
|
padapter->mlmepriv.acm_mask = acm_mask;
|
|
|
|
|
|
|
|
inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3;
|
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
if (pregpriv->wifi_spec ==1)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
u32 j, tmp, change_inx;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */
|
2015-08-15 18:19:16 +00:00
|
|
|
for (i =0; i<4; i++)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-08-15 18:19:16 +00:00
|
|
|
for (j =i+1; j<4; j++)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* compare CW and AIFS */
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
change_inx = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* compare TXOP */
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((edca[j] >> 16) > (edca[i] >> 16))
|
2014-12-29 02:13:24 +00:00
|
|
|
change_inx = true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (change_inx)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
tmp = edca[i];
|
|
|
|
edca[i] = edca[j];
|
|
|
|
edca[j] = tmp;
|
|
|
|
|
|
|
|
tmp = inx[i];
|
|
|
|
inx[i] = inx[j];
|
|
|
|
inx[j] = tmp;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
change_inx = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
for (i =0; i<4; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->wmm_para_seq[i] = inx[i];
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_variable_ies * pIE)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned char new_bwmode;
|
|
|
|
unsigned char new_ch_offset;
|
|
|
|
struct HT_info_element *pHT_info;
|
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
struct registry_priv *pregistrypriv = &padapter->registrypriv;
|
|
|
|
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!pIE)
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (phtpriv->ht_option == false) return;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pIE->Length > sizeof(struct HT_info_element))
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pHT_info = (struct HT_info_element *)pIE->data;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((pHT_info->infos[0] & BIT(2)) && pregistrypriv->cbw40_enable )
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
new_bwmode = HT_CHANNEL_WIDTH_40;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch (pHT_info->infos[0] & 0x3)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
new_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case 3:
|
|
|
|
new_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
default:
|
|
|
|
new_bwmode = HT_CHANNEL_WIDTH_20;
|
|
|
|
new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
new_bwmode = HT_CHANNEL_WIDTH_20;
|
|
|
|
new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((new_bwmode!= pmlmeext->cur_bwmode) || (new_ch_offset!=pmlmeext->cur_ch_offset))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pmlmeinfo->bwmode_updated = true;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeext->cur_bwmode = new_bwmode;
|
|
|
|
pmlmeext->cur_ch_offset = new_ch_offset;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* update HT info also */
|
2013-05-08 21:45:39 +00:00
|
|
|
HT_info_handler(padapter, pIE);
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pmlmeinfo->bwmode_updated = false;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (true == pmlmeinfo->bwmode_updated)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta;
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* update ap's stainfo */
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (psta)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
struct ht_priv *phtpriv_sta = &psta->htpriv;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (phtpriv_sta->ht_option)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* bwmode */
|
2013-05-08 21:45:39 +00:00
|
|
|
phtpriv_sta->bwmode = pmlmeext->cur_bwmode;
|
2014-12-19 06:59:46 +00:00
|
|
|
phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20;
|
|
|
|
phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_variable_ies * pIE)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
u8 rf_type;
|
|
|
|
u8 max_AMPDU_len, min_MPDU_spacing;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct registry_priv *pregistrypriv = &padapter->registrypriv;
|
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if (pIE == NULL) return;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (phtpriv->ht_option == false) return;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pmlmeinfo->HT_caps_enable = 1;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = 0; i < (pIE->Length); i++)
|
|
|
|
{
|
|
|
|
if (i != 2)
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Commented by Albert 2010/07/12 */
|
|
|
|
/* Got the endian issue here. */
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* modify from fw by Thomas 2010/11/17 */
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (pIE->data[i] & 0x3))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
max_AMPDU_len = (pIE->data[i] & 0x3);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
max_AMPDU_len = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) > (pIE->data[i] & 0x1c))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
min_MPDU_spacing = (pIE->data[i] & 0x1c);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = max_AMPDU_len | min_MPDU_spacing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Commented by Albert 2010/07/12 */
|
|
|
|
/* Have to handle the endian issue after copying. */
|
|
|
|
/* HT_ext_caps didn't be used yet. */
|
2015-01-28 05:14:58 +00:00
|
|
|
pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info = pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info;
|
|
|
|
pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps = pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* update the MCS rates */
|
2015-03-11 18:41:12 +00:00
|
|
|
for (i = 0; i < 16; i++) {
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R))
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R[i];
|
2013-07-19 21:41:41 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R[i];
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
void HT_info_handler(struct adapter *padapter, struct ndis_802_11_variable_ies * pIE)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
|
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if (pIE == NULL) return;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (phtpriv->ht_option == false) return;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pIE->Length > sizeof(struct HT_info_element))
|
2014-12-11 21:15:04 +00:00
|
|
|
return;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->HT_info_enable = 1;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->Length);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void HTOnAssocRsp(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned char max_AMPDU_len;
|
|
|
|
unsigned char min_MPDU_spacing;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* struct registry_priv *pregpriv = &padapter->registrypriv; */
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s\n", __FUNCTION__);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->HT_enable = 1;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->HT_enable = 0;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* handle A-MPDU parameter field */
|
2014-12-19 06:59:46 +00:00
|
|
|
/*
|
2013-05-08 21:45:39 +00:00
|
|
|
AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
|
2014-12-19 06:59:46 +00:00
|
|
|
AMPDU_para [4:2]:Min MPDU Start Spacing
|
2013-05-08 21:45:39 +00:00
|
|
|
*/
|
2014-12-19 06:59:46 +00:00
|
|
|
max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03;
|
|
|
|
|
|
|
|
min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing));
|
|
|
|
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len));
|
|
|
|
}
|
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_variable_ies * pIE)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pIE->Length>1)
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->ERP_enable = 1;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&(pmlmeinfo->ERP_IE), pIE->data, pIE->Length);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void VCS_update(struct adapter *padapter, struct sta_info *psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct registry_priv *pregpriv = &padapter->registrypriv;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch (pregpriv->vrtl_carrier_sense)/* 0:off 1:on 2:auto */
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
case 0: /* off */
|
2013-08-02 17:12:37 +00:00
|
|
|
psta->rtsen = 0;
|
2014-12-11 21:15:04 +00:00
|
|
|
psta->cts2self = 0;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
case 1: /* on */
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pregpriv->vcs_type == 1) /* 1:RTS/CTS 2:CTS to self */
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->rtsen = 1;
|
|
|
|
psta->cts2self = 0;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->rtsen = 0;
|
|
|
|
psta->cts2self = 1;
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
case 2: /* auto */
|
2014-12-11 21:15:04 +00:00
|
|
|
default:
|
|
|
|
if ((pmlmeinfo->ERP_enable) && (pmlmeinfo->ERP_IE & BIT(1)))
|
|
|
|
{
|
|
|
|
if (pregpriv->vcs_type == 1)
|
|
|
|
{
|
|
|
|
psta->rtsen = 1;
|
|
|
|
psta->cts2self = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
psta->rtsen = 0;
|
|
|
|
psta->cts2self = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
psta->rtsen = 0;
|
|
|
|
psta->cts2self = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned int len;
|
|
|
|
unsigned char *p;
|
|
|
|
unsigned short val16, subtype;
|
|
|
|
struct wlan_network *cur_network = &(Adapter->mlmepriv.cur_network);
|
2015-08-15 18:19:16 +00:00
|
|
|
/* u8 wpa_ie[255], rsn_ie[255]; */
|
|
|
|
u16 wpa_len =0, rsn_len =0;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 encryp_protocol = 0;
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *bssid;
|
2013-05-08 21:45:39 +00:00
|
|
|
int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0;
|
|
|
|
unsigned char *pbuf;
|
|
|
|
u32 wpa_ielen = 0;
|
|
|
|
u8 *pbssid = GetAddr3Ptr(pframe);
|
|
|
|
u32 hidden_ssid = 0;
|
2015-08-15 18:19:16 +00:00
|
|
|
u8 cur_network_type, network_type =0;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct HT_info_element *pht_info = NULL;
|
2015-04-08 18:43:40 +00:00
|
|
|
struct ieee80211_ht_cap *pht_cap = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 bcn_channel;
|
2014-12-19 06:59:46 +00:00
|
|
|
unsigned short ht_cap_info;
|
2013-05-08 21:45:39 +00:00
|
|
|
unsigned char ht_info_infos_0;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (is_client_associated_to_ap(Adapter) == false)
|
|
|
|
return true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
len = packet_len - sizeof(struct rtw_ieee80211_hdr_3addr);
|
|
|
|
|
|
|
|
if (len > MAX_IE_SZ) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s IE too long for survey event\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (_rtw_memcmp(cur_network->network.MacAddress, pbssid, 6) == false) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n" MAC_FMT MAC_FMT,
|
|
|
|
MAC_ARG(pbssid), MAC_ARG(cur_network->network.MacAddress));
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-07 00:26:23 +00:00
|
|
|
bssid = (struct wlan_bssid_ex *)rtw_zmalloc(sizeof(struct wlan_bssid_ex));
|
2015-01-26 22:01:30 +00:00
|
|
|
if (!bssid)
|
|
|
|
return _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
subtype = GetFrameSubType(pframe) >> 4;
|
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
if (subtype ==WIFI_BEACON)
|
2013-05-08 21:45:39 +00:00
|
|
|
bssid->Reserved[0] = 1;
|
|
|
|
|
2015-03-07 00:26:23 +00:00
|
|
|
bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/* below is to copy the information element */
|
|
|
|
bssid->IELength = len;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(bssid->IEs, (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)), bssid->IELength);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/* check bw and channel offset */
|
|
|
|
/* parsing HT_CAP_IE */
|
|
|
|
p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (p && len>0) {
|
2015-04-08 18:43:40 +00:00
|
|
|
pht_cap = (struct ieee80211_ht_cap *)(p + 2);
|
2015-01-28 05:14:58 +00:00
|
|
|
ht_cap_info = le16_to_cpu(pht_cap->cap_info);
|
2013-05-08 21:45:39 +00:00
|
|
|
} else {
|
2014-12-11 21:15:04 +00:00
|
|
|
ht_cap_info = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
/* parsing HT_INFO_IE */
|
|
|
|
p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (p && len>0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pht_info = (struct HT_info_element *)(p + 2);
|
|
|
|
ht_info_infos_0 = pht_info->infos[0];
|
|
|
|
} else {
|
|
|
|
ht_info_infos_0 = 0;
|
|
|
|
}
|
|
|
|
if (ht_cap_info != cur_network->BcnInfo.ht_cap_info ||
|
2014-12-11 21:15:04 +00:00
|
|
|
((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) {
|
|
|
|
DBG_871X("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", __func__,
|
2014-12-19 06:59:46 +00:00
|
|
|
ht_cap_info, ht_info_infos_0);
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", __func__,
|
2014-12-19 06:59:46 +00:00
|
|
|
cur_network->BcnInfo.ht_cap_info, cur_network->BcnInfo.ht_info_infos_0);
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s bw mode change, disconnect\n", __func__);
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* bcn_info_update */
|
2014-12-11 21:15:04 +00:00
|
|
|
cur_network->BcnInfo.ht_cap_info = ht_cap_info;
|
|
|
|
cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* to do : need to check that whether modify related register of BB or not */
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
/* goto _mismatch; */
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Checking for channel */
|
|
|
|
p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _DSSET_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
|
|
|
|
if (p) {
|
|
|
|
bcn_channel = *(p + 2);
|
|
|
|
} else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */
|
|
|
|
p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pht_info) {
|
2013-05-08 21:45:39 +00:00
|
|
|
bcn_channel = pht_info->primary_channel;
|
|
|
|
} else { /* we don't find channel IE, so don't check it */
|
2015-08-15 18:00:19 +00:00
|
|
|
DBG_871X("Oops: %s we don't find channel IE, so don't check it\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
bcn_channel = Adapter->mlmeextpriv.cur_channel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bcn_channel != Adapter->mlmeextpriv.cur_channel) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s beacon channel:%d cur channel:%d disconnect\n", __func__,
|
|
|
|
bcn_channel, Adapter->mlmeextpriv.cur_channel);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto _mismatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checking SSID */
|
2014-12-11 21:15:04 +00:00
|
|
|
if ((p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_)) == NULL) {
|
|
|
|
DBG_871X("%s marc: cannot find SSID for survey event\n", __func__);
|
2014-12-29 02:13:24 +00:00
|
|
|
hidden_ssid = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
} else {
|
2014-12-29 02:13:24 +00:00
|
|
|
hidden_ssid = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((NULL != p) && (false == hidden_ssid && (*(p + 1)))) {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1));
|
2013-05-08 21:45:39 +00:00
|
|
|
bssid->Ssid.SsidLength = *(p + 1);
|
|
|
|
} else {
|
|
|
|
bssid->Ssid.SsidLength = 0;
|
|
|
|
bssid->Ssid.Ssid[0] = '\0';
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d "
|
2013-05-08 21:45:39 +00:00
|
|
|
"cur_network->network.Ssid.Ssid:%s len:%d\n", __func__, bssid->Ssid.Ssid,
|
|
|
|
bssid->Ssid.SsidLength, cur_network->network.Ssid.Ssid,
|
|
|
|
cur_network->network.Ssid.SsidLength));
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (_rtw_memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) == false ||
|
2014-12-11 21:15:04 +00:00
|
|
|
bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0) { /* not hidden ssid */
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s(), SSID is not match return FAIL\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto _mismatch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check encryption info */
|
2015-03-07 00:26:23 +00:00
|
|
|
val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (val16 & BIT(4))
|
|
|
|
bssid->Privacy = 1;
|
|
|
|
else
|
|
|
|
bssid->Privacy = 0;
|
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
|
2014-12-11 21:15:04 +00:00
|
|
|
("%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n",
|
2015-08-15 18:19:16 +00:00
|
|
|
__func__, cur_network->network.Privacy, bssid->Privacy));
|
2013-05-08 21:45:39 +00:00
|
|
|
if (cur_network->network.Privacy != bssid->Privacy) {
|
2015-08-15 18:19:16 +00:00
|
|
|
DBG_871X("%s(), privacy is not match return FAIL\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto _mismatch;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
rtw_get_sec_ie(bssid->IEs, bssid->IELength, NULL,&rsn_len, NULL,&wpa_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (rsn_len > 0) {
|
|
|
|
encryp_protocol = ENCRYP_PROTOCOL_WPA2;
|
|
|
|
} else if (wpa_len > 0) {
|
|
|
|
encryp_protocol = ENCRYP_PROTOCOL_WPA;
|
|
|
|
} else {
|
|
|
|
if (bssid->Privacy)
|
|
|
|
encryp_protocol = ENCRYP_PROTOCOL_WEP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) {
|
2015-08-15 18:19:16 +00:00
|
|
|
DBG_871X("%s(): enctyp is not match , return FAIL\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto _mismatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) {
|
|
|
|
pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pbuf && (wpa_ielen>0)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) {
|
2015-08-15 18:19:16 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
|
2014-12-11 21:15:04 +00:00
|
|
|
("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__,
|
|
|
|
pairwise_cipher, group_cipher, is_8021x));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pbuf && (wpa_ielen>0)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) {
|
2015-08-15 18:19:16 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
|
2014-12-11 21:15:04 +00:00
|
|
|
("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n",
|
|
|
|
__func__, pairwise_cipher, group_cipher, is_8021x));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
|
|
|
|
("%s cur_network->group_cipher is %d: %d\n", __func__, cur_network->BcnInfo.group_cipher, group_cipher));
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) {
|
2015-08-15 18:19:16 +00:00
|
|
|
DBG_871X("%s pairwise_cipher(%x:%x) or group_cipher(%x:%x) is not match , return FAIL\n", __func__,
|
2014-12-11 21:15:04 +00:00
|
|
|
pairwise_cipher, cur_network->BcnInfo.pairwise_cipher,
|
|
|
|
group_cipher, cur_network->BcnInfo.group_cipher);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto _mismatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_8021x != cur_network->BcnInfo.is_8021x) {
|
2015-08-15 18:19:16 +00:00
|
|
|
DBG_871X("%s authentication is not match , return FAIL\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto _mismatch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-07 00:26:23 +00:00
|
|
|
rtw_mfree((u8 *)bssid, sizeof(struct wlan_bssid_ex));
|
2013-05-08 21:45:39 +00:00
|
|
|
return _SUCCESS;
|
|
|
|
|
|
|
|
_mismatch:
|
2015-03-07 00:26:23 +00:00
|
|
|
rtw_mfree((u8 *)bssid, sizeof(struct wlan_bssid_ex));
|
2013-11-29 22:10:20 +00:00
|
|
|
return _FAIL;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, struct sta_info *psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int len;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_variable_ies * pIE;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
len = pkt_len - (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = 0; i < len;)
|
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
pIE = (struct ndis_802_11_variable_ies *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:00:11 +00:00
|
|
|
switch (pIE->ElementID) {
|
2015-02-19 21:34:32 +00:00
|
|
|
case _HT_EXTRA_INFO_IE_: /* HT info */
|
|
|
|
/* HT_info_handler(padapter, pIE); */
|
2014-12-29 02:00:11 +00:00
|
|
|
bwmode_update_check(padapter, pIE);
|
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-29 02:00:11 +00:00
|
|
|
case _ERPINFO_IE_:
|
|
|
|
ERP_IE_handler(padapter, pIE);
|
|
|
|
VCS_update(padapter, psta);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
i += (pIE->Length + 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef CONFIG_DFS
|
2014-12-17 23:13:53 +00:00
|
|
|
void process_csa_ie(struct adapter *padapter, u8 *pframe, uint pkt_len)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int len;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_variable_ies * pIE;
|
2014-12-19 06:59:46 +00:00
|
|
|
u8 new_ch_no = 0;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
len = pkt_len - (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = 0; i < len;)
|
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
pIE = (struct ndis_802_11_variable_ies *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch (pIE->ElementID)
|
|
|
|
{
|
|
|
|
case _CH_SWTICH_ANNOUNCE_:
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&new_ch_no, pIE->data+1, 1);
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_set_csa_cmd(padapter, new_ch_no);
|
2013-08-02 17:12:37 +00:00
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-08-02 17:12:37 +00:00
|
|
|
default:
|
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
i += (pIE->Length + 2);
|
|
|
|
}
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
#endif /* CONFIG_DFS */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
unsigned int is_ap_in_tkip(struct adapter *padapter)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
u32 i;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_variable_ies * pIE;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-03-07 00:26:23 +00:00
|
|
|
if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
for (i = sizeof(struct ndis_802_11_fixed_ies); i < pmlmeinfo->network.IELength;)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
pIE = (struct ndis_802_11_variable_ies *)(pmlmeinfo->network.IEs + i);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch (pIE->ElementID)
|
|
|
|
{
|
|
|
|
case _VENDOR_SPECIFIC_IE_:
|
2014-12-19 06:59:46 +00:00
|
|
|
if ((_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4)) && (_rtw_memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4)))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case _RSN_IE_2_:
|
2014-12-19 06:59:46 +00:00
|
|
|
if (_rtw_memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
i += (pIE->Length + 2);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
unsigned int should_forbid_n_rate(struct adapter * padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u32 i;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_variable_ies * pIE;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *cur_network = &pmlmepriv->cur_network.network;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-03-07 00:26:23 +00:00
|
|
|
if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
for (i = sizeof(struct ndis_802_11_fixed_ies); i < cur_network->IELength;)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
pIE = (struct ndis_802_11_variable_ies *)(cur_network->IEs + i);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
switch (pIE->ElementID)
|
|
|
|
{
|
|
|
|
case _VENDOR_SPECIFIC_IE_:
|
|
|
|
if (_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4) &&
|
|
|
|
((_rtw_memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP, 4)) ||
|
|
|
|
(_rtw_memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP, 4))))
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case _RSN_IE_2_:
|
2015-03-10 16:18:03 +00:00
|
|
|
if ((_rtw_memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) ||
|
|
|
|
(_rtw_memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4)))
|
|
|
|
return false;
|
2014-12-11 21:15:04 +00:00
|
|
|
default:
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
i += (pIE->Length + 2);
|
|
|
|
}
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2015-03-10 16:18:03 +00:00
|
|
|
return false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
unsigned int is_ap_in_wep(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u32 i;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_variable_ies * pIE;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-03-07 00:26:23 +00:00
|
|
|
if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
for (i = sizeof(struct ndis_802_11_fixed_ies); i < pmlmeinfo->network.IELength;)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
pIE = (struct ndis_802_11_variable_ies *)(pmlmeinfo->network.IEs + i);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
switch (pIE->ElementID)
|
|
|
|
{
|
|
|
|
case _VENDOR_SPECIFIC_IE_:
|
|
|
|
if (_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4))
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case _RSN_IE_2_:
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
i += (pIE->Length + 2);
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
int wifirate2_ratetbl_inx(unsigned char rate);
|
2013-05-08 21:45:39 +00:00
|
|
|
int wifirate2_ratetbl_inx(unsigned char rate)
|
|
|
|
{
|
|
|
|
int inx = 0;
|
|
|
|
rate = rate & 0x7f;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
switch (rate)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
case 54*2:
|
|
|
|
inx = 11;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 48*2:
|
|
|
|
inx = 10;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 36*2:
|
|
|
|
inx = 9;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24*2:
|
|
|
|
inx = 8;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case 18*2:
|
|
|
|
inx = 7;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 12*2:
|
|
|
|
inx = 6;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 9*2:
|
|
|
|
inx = 5;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case 6*2:
|
|
|
|
inx = 4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 11*2:
|
|
|
|
inx = 3;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
inx = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2*2:
|
|
|
|
inx = 1;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case 1*2:
|
|
|
|
inx = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
return inx;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz)
|
|
|
|
{
|
|
|
|
unsigned int i, num_of_rate;
|
|
|
|
unsigned int mask = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
num_of_rate = (ptn_sz > NumRates)? NumRates: ptn_sz;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = 0; i < num_of_rate; i++)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((*(ptn + i)) & 0x80)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i));
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz)
|
|
|
|
{
|
|
|
|
unsigned int i, num_of_rate;
|
|
|
|
unsigned int mask = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
num_of_rate = (ptn_sz > NumRates)? NumRates: ptn_sz;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
for (i = 0; i < num_of_rate; i++)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i));
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps)
|
|
|
|
{
|
|
|
|
unsigned int mask = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
mask = ((pHT_caps->u.HT_cap_element.MCS_rate[0] << 12) | (pHT_caps->u.HT_cap_element.MCS_rate[1] << 20));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned char bit_offset;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (!(pmlmeinfo->HT_enable))
|
|
|
|
return _FAIL;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK))
|
|
|
|
return _FAIL;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
bit_offset = (pmlmeext->cur_bwmode & HT_CHANNEL_WIDTH_40)? 6: 5;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-28 05:14:58 +00:00
|
|
|
if (le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info) & (0x1 << bit_offset))
|
2013-05-08 21:45:39 +00:00
|
|
|
return _SUCCESS;
|
|
|
|
else
|
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char get_highest_rate_idx(u32 mask)
|
|
|
|
{
|
|
|
|
int i;
|
2015-08-15 18:19:16 +00:00
|
|
|
unsigned char rate_idx =0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:19:16 +00:00
|
|
|
for (i =27; i>=0; i--)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (mask & BIT(i))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rate_idx = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return rate_idx;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
unsigned char get_highest_mcs_rate(struct HT_caps_element *pHT_caps);
|
|
|
|
unsigned char get_highest_mcs_rate(struct HT_caps_element *pHT_caps)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
int i, mcs_rate;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
mcs_rate = (pHT_caps->u.HT_cap_element.MCS_rate[0] | (pHT_caps->u.HT_cap_element.MCS_rate[1] << 8));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = 15; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (mcs_rate & (0x1 << i))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
return i;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void Update_RA_Entry(struct adapter *padapter, struct sta_info *psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_hal_update_ra_mask(psta, 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void enable_rate_adaptive(struct adapter *padapter, struct sta_info *psta);
|
|
|
|
void enable_rate_adaptive(struct adapter *padapter, struct sta_info *psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
Update_RA_Entry(padapter, psta);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void set_sta_rate(struct adapter *padapter, struct sta_info *psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* rate adaptive */
|
2014-12-11 21:15:04 +00:00
|
|
|
enable_rate_adaptive(padapter, psta);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Update RRSR and Rate for USERATE */
|
2014-12-17 23:13:53 +00:00
|
|
|
void update_tx_basic_rate(struct adapter *padapter, u8 wirelessmode)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
u8 supported_rates[NDIS_802_11_LENGTH_RATES_EX];
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
struct wifidirect_info* pwdinfo = &padapter->wdinfo;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Added by Albert 2011/03/22 */
|
|
|
|
/* In the P2P mode, the driver should not support the b mode. */
|
|
|
|
/* So, the Tx packet shouldn't use the CCK rate */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
|
2014-12-11 21:15:04 +00:00
|
|
|
return;
|
2015-02-19 21:34:32 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if ((wirelessmode & WIRELESS_11B) && (wirelessmode == WIRELESS_11B)) {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(supported_rates, rtw_basic_rate_cck, 4);
|
2014-12-11 21:15:04 +00:00
|
|
|
} else if (wirelessmode & WIRELESS_11B) {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(supported_rates, rtw_basic_rate_mix, 7);
|
2014-12-11 21:15:04 +00:00
|
|
|
} else {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(supported_rates, rtw_basic_rate_ofdm, 3);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-11-29 22:10:20 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (wirelessmode & WIRELESS_11B)
|
|
|
|
update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB);
|
|
|
|
else
|
|
|
|
update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB);
|
|
|
|
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, supported_rates);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char check_assoc_AP(u8 *pframe, uint len)
|
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
unsigned int i;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_variable_ies * pIE;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 epigram_vendor_flag;
|
|
|
|
u8 ralink_vendor_flag;
|
|
|
|
epigram_vendor_flag = 0;
|
|
|
|
ralink_vendor_flag = 0;
|
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
for (i = sizeof(struct ndis_802_11_fixed_ies); i < len;)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
pIE = (struct ndis_802_11_variable_ies *)(pframe + i);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch (pIE->ElementID)
|
|
|
|
{
|
|
|
|
case _VENDOR_SPECIFIC_IE_:
|
|
|
|
if ((_rtw_memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (_rtw_memcmp(pIE->data, ARTHEROS_OUI2, 3)))
|
|
|
|
{
|
|
|
|
DBG_871X("link to Artheros AP\n");
|
|
|
|
return HT_IOT_PEER_ATHEROS;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else if ((_rtw_memcmp(pIE->data, BROADCOM_OUI1, 3))
|
|
|
|
|| (_rtw_memcmp(pIE->data, BROADCOM_OUI2, 3))
|
|
|
|
|| (_rtw_memcmp(pIE->data, BROADCOM_OUI2, 3)))
|
|
|
|
{
|
|
|
|
DBG_871X("link to Broadcom AP\n");
|
|
|
|
return HT_IOT_PEER_BROADCOM;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else if (_rtw_memcmp(pIE->data, MARVELL_OUI, 3))
|
|
|
|
{
|
|
|
|
DBG_871X("link to Marvell AP\n");
|
|
|
|
return HT_IOT_PEER_MARVELL;
|
|
|
|
}
|
|
|
|
else if (_rtw_memcmp(pIE->data, RALINK_OUI, 3))
|
|
|
|
{
|
|
|
|
if (!ralink_vendor_flag) {
|
|
|
|
ralink_vendor_flag = 1;
|
|
|
|
} else {
|
|
|
|
DBG_871X("link to Ralink AP\n");
|
|
|
|
return HT_IOT_PEER_RALINK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (_rtw_memcmp(pIE->data, CISCO_OUI, 3))
|
|
|
|
{
|
|
|
|
DBG_871X("link to Cisco AP\n");
|
|
|
|
return HT_IOT_PEER_CISCO;
|
|
|
|
}
|
|
|
|
else if (_rtw_memcmp(pIE->data, REALTEK_OUI, 3))
|
|
|
|
{
|
|
|
|
DBG_871X("link to Realtek 96B\n");
|
|
|
|
return HT_IOT_PEER_REALTEK;
|
|
|
|
}
|
2015-08-15 18:19:16 +00:00
|
|
|
else if (_rtw_memcmp(pIE->data, AIRGOCAP_OUI, 3))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
DBG_871X("link to Airgo Cap\n");
|
|
|
|
return HT_IOT_PEER_AIRGO;
|
|
|
|
}
|
|
|
|
else if (_rtw_memcmp(pIE->data, EPIGRAM_OUI, 3))
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
epigram_vendor_flag = 1;
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ralink_vendor_flag) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("link to Tenda W311R AP\n");
|
2015-03-10 16:18:03 +00:00
|
|
|
return HT_IOT_PEER_TENDA;
|
2014-12-11 21:15:04 +00:00
|
|
|
} else {
|
|
|
|
DBG_871X("Capture EPIGRAM_OUI\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
default:
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2013-08-02 17:12:37 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
i += (pIE->Length + 2);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (ralink_vendor_flag && !epigram_vendor_flag) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("link to Ralink AP\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
return HT_IOT_PEER_RALINK;
|
2015-08-15 18:24:16 +00:00
|
|
|
} else if (ralink_vendor_flag && epigram_vendor_flag) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("link to Tenda W311R AP\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
return HT_IOT_PEER_TENDA;
|
|
|
|
} else {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("link to new AP\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
return HT_IOT_PEER_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void update_IOT_info(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch (pmlmeinfo->assoc_AP_vendor)
|
|
|
|
{
|
|
|
|
case HT_IOT_PEER_MARVELL:
|
|
|
|
pmlmeinfo->turboMode_cts2self = 1;
|
|
|
|
pmlmeinfo->turboMode_rtsen = 0;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case HT_IOT_PEER_RALINK:
|
|
|
|
pmlmeinfo->turboMode_cts2self = 0;
|
|
|
|
pmlmeinfo->turboMode_rtsen = 1;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* disable high power */
|
2014-12-29 02:13:24 +00:00
|
|
|
Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false);
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
|
|
|
case HT_IOT_PEER_REALTEK:
|
2015-02-19 21:34:32 +00:00
|
|
|
/* rtw_write16(padapter, 0x4cc, 0xffff); */
|
|
|
|
/* rtw_write16(padapter, 0x546, 0x01c0); */
|
|
|
|
/* disable high power */
|
2014-12-29 02:13:24 +00:00
|
|
|
Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false);
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pmlmeinfo->turboMode_cts2self = 0;
|
|
|
|
pmlmeinfo->turboMode_rtsen = 1;
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void update_capinfo(struct adapter *Adapter, u16 updateCap)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2015-03-02 23:21:23 +00:00
|
|
|
bool ShortPreamble;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Check preamble mode, 2005.01.06, by rcnjko. */
|
|
|
|
/* Mark to update preamble value forever, 2008.03.18 by lanhsin */
|
2015-08-15 18:02:34 +00:00
|
|
|
/* if ( pMgntInfo->RegPreambleMode == PREAMBLE_AUTO ) */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (updateCap & cShortPreamble)
|
2015-02-19 21:34:32 +00:00
|
|
|
{ /* Short Preamble */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) /* PREAMBLE_LONG or PREAMBLE_AUTO */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
ShortPreamble = true;
|
2014-12-11 21:15:04 +00:00
|
|
|
pmlmeinfo->preamble_mode = PREAMBLE_SHORT;
|
|
|
|
rtw_hal_set_hwreg( Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble );
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else
|
2015-02-19 21:34:32 +00:00
|
|
|
{ /* Long Preamble */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) /* PREAMBLE_SHORT or PREAMBLE_AUTO */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
ShortPreamble = false;
|
2014-12-11 21:15:04 +00:00
|
|
|
pmlmeinfo->preamble_mode = PREAMBLE_LONG;
|
|
|
|
rtw_hal_set_hwreg( Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble );
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if ( updateCap & cIBSS ) {
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Filen: See 802.11-2007 p.91 */
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Filen: See 802.11-2007 p.90 */
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( pmlmeext->cur_wireless_mode & (WIRELESS_11G | WIRELESS_11_24N))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( (updateCap & cShortSlotTime) /* && (!(pMgntInfo->pHTInfo->RT2RT_HT_Mode & RT_HT_CAP_USE_LONG_PREAMBLE)) */)
|
2015-02-19 21:34:32 +00:00
|
|
|
{ /* Short Slot Time */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmeinfo->slotTime != SHORT_SLOT_TIME)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->slotTime = SHORT_SLOT_TIME;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2015-02-19 21:34:32 +00:00
|
|
|
{ /* Long Slot Time */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmeinfo->slotTime != NON_SHORT_SLOT_TIME)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if ( pmlmeext->cur_wireless_mode & (WIRELESS_11A | WIRELESS_11_5N))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->slotTime = SHORT_SLOT_TIME;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* B Mode */
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_hal_set_hwreg( Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime );
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void update_wireless_mode(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int ratelen, network_type = 0;
|
|
|
|
u32 SIFS_Timer;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
|
2014-12-11 21:15:04 +00:00
|
|
|
unsigned char *rate = cur_network->SupportedRates;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
ratelen = rtw_get_rateset_len(cur_network->SupportedRates);
|
|
|
|
|
|
|
|
if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeinfo->HT_enable = 1;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmeext->cur_channel > 14)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pmlmeinfo->HT_enable)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type = WIRELESS_11_5N;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
network_type |= WIRELESS_11A;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pmlmeinfo->HT_enable)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type = WIRELESS_11_24N;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ((cckratesonly_included(rate, ratelen)) == true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type |= WIRELESS_11B;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if ((cckrates_included(rate, ratelen)) == true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type |= WIRELESS_11BG;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
network_type |= WIRELESS_11G;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode;
|
2015-02-19 21:34:32 +00:00
|
|
|
SIFS_Timer = 0x0a0a0808; /* 0x0808 -> for CCK, 0x0a0a -> for OFDM */
|
|
|
|
/* change this value if having IOT issues. */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
padapter->HalFunc.SetHwRegHandler( padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (pmlmeext->cur_wireless_mode & WIRELESS_11B)
|
|
|
|
update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB);
|
|
|
|
else
|
|
|
|
update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB);
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmeext->cur_wireless_mode & WIRELESS_11B)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Only B, B/G, and B/G/N AP could use CCK rate */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_cck, 4);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_ofdm, 4);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
int update_sta_support_rate(struct adapter *padapter, u8* pvar_ie, uint var_ie_len, int cam_idx)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
unsigned int ie_len;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_variable_ies * pIE;
|
2013-05-08 21:45:39 +00:00
|
|
|
int supportRateNum = 0;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
pIE = (struct ndis_802_11_variable_ies *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pIE == NULL)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
supportRateNum = ie_len;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
pIE = (struct ndis_802_11_variable_ies *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pIE)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return _SUCCESS;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct sta_info *psta;
|
2014-12-19 06:59:46 +00:00
|
|
|
u16 tid, start_seq, param;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct recv_reorder_ctrl *preorder_ctrl;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct ADDBA_request *preq = (struct ADDBA_request*)paddba_req;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
|
|
|
|
psta = rtw_get_stainfo(pstapriv, addr);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (psta) {
|
2014-12-11 21:15:04 +00:00
|
|
|
start_seq = le16_to_cpu(preq->BA_starting_seqctrl) >> 4;
|
2013-05-08 21:45:39 +00:00
|
|
|
param = le16_to_cpu(preq->BA_para_set);
|
|
|
|
tid = (param>>2)&0x0f;
|
|
|
|
preorder_ctrl = &psta->recvreorder_ctrl[tid];
|
|
|
|
preorder_ctrl->indicate_seq = 0xffff;
|
2014-12-29 02:13:24 +00:00
|
|
|
preorder_ctrl->enable =(pmlmeinfo->bAcceptAddbaReq == true)? true :false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
u8* pIE;
|
2015-01-28 05:14:58 +00:00
|
|
|
__le32 *pbuf;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pIE = pframe + sizeof(struct rtw_ieee80211_hdr_3addr);
|
2015-01-28 05:14:58 +00:00
|
|
|
pbuf = (__le32 *)pIE;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pmlmeext->TSFValue = le32_to_cpu(*(pbuf+1));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmeext->TSFValue = pmlmeext->TSFValue << 32;
|
|
|
|
|
|
|
|
pmlmeext->TSFValue |= le32_to_cpu(*pbuf);
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-01-28 05:14:58 +00:00
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_CORRECT_TSF, NULL);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void beacon_timing_control(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
rtw_hal_bcn_related_reg_setting(padapter);
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static struct adapter *pbuddy_padapter = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
int rtw_handle_dualmac(struct adapter *adapter, bool init)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int status = _SUCCESS;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (init) {
|
|
|
|
if (pbuddy_padapter == NULL) {
|
|
|
|
pbuddy_padapter = adapter;
|
2015-08-15 18:19:16 +00:00
|
|
|
DBG_871X("%s(): pbuddy_padapter == NULL, Set pbuddy_padapter\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
} else {
|
|
|
|
adapter->pbuddy_adapter = pbuddy_padapter;
|
|
|
|
pbuddy_padapter->pbuddy_adapter = adapter;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* clear global value */
|
2013-05-08 21:45:39 +00:00
|
|
|
pbuddy_padapter = NULL;
|
2015-08-15 18:19:16 +00:00
|
|
|
DBG_871X("%s(): pbuddy_padapter exist, Exchange Information\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
}else {
|
2013-05-08 21:45:39 +00:00
|
|
|
pbuddy_padapter = NULL;
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
exit:
|
2013-05-08 21:45:39 +00:00
|
|
|
return status;
|
|
|
|
}
|