1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2025-01-03 21:04:05 +00:00

Merge pull request #3 from aircrack-ng/v5.1.5

Add HT Greenfield & Kernel v4.14 support
This commit is contained in:
evilphish 2017-10-23 10:10:39 +02:00 committed by GitHub
commit 853da002c1
6 changed files with 147 additions and 27 deletions

View File

@ -2566,7 +2566,11 @@ u32 rtw_read_efuse_from_file(const char *path, u8 *buf)
set_fs(KERNEL_DS);
for (i = 0 ; i < HWSET_MAX_SIZE ; i++) {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0))
kernel_read(fp, temp, 2, &pos);
#else
vfs_read(fp, temp, 2, &pos);
#endif
if (sscanf(temp, "%hhx", &buf[i]) != 1) {
if (0)
RTW_ERR("%s sscanf fail\n", __func__);
@ -2574,10 +2578,18 @@ u32 rtw_read_efuse_from_file(const char *path, u8 *buf)
}
if ((i % EFUSE_FILE_COLUMN_NUM) == (EFUSE_FILE_COLUMN_NUM - 1)) {
/* Filter the lates space char. */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0))
kernel_read(fp, temp, 1, &pos);
#else
vfs_read(fp, temp, 1, &pos);
#endif
if (strchr(temp, ' ') == NULL) {
pos--;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0))
kernel_read(fp, temp, 2, &pos);
#else
vfs_read(fp, temp, 2, &pos);
#endif
}
} else {
pos += 1; /* Filter the space character */
@ -2634,7 +2646,11 @@ u32 rtw_read_macaddr_from_file(const char *path, u8 *buf)
fs = get_fs();
set_fs(KERNEL_DS);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0))
kernel_read(fp, source_addr, 18, &pos);
#else
vfs_read(fp, source_addr, 18, &pos);
#endif
source_addr[17] = ':';
head = end = source_addr;

View File

@ -4475,7 +4475,11 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t *ssid,
source = rtw_zmalloc(2048);
if (source != NULL) {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0))
len = kernel_read(fp, source, len, &pos);
#else
len = vfs_read(fp, source, len, &pos);
#endif
rtw_parse_cipher_list(nlo_info, source);
rtw_mfree(source, 2048);
}

View File

@ -990,6 +990,42 @@ typedef enum _HT_CAP_AMPDU_DENSITY {
#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
/* 802.11ac VHT Capabilities */
#define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000
#define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001
#define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 0x00000002
#define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ 0x00000004
#define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ 0x00000008
#define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK 0x0000000C
#define IEEE80211_VHT_CAP_RXLDPC 0x00000010
#define IEEE80211_VHT_CAP_SHORT_GI_80 0x00000020
#define IEEE80211_VHT_CAP_SHORT_GI_160 0x00000040
#define IEEE80211_VHT_CAP_TXSTBC 0x00000080
#define IEEE80211_VHT_CAP_RXSTBC_1 0x00000100
#define IEEE80211_VHT_CAP_RXSTBC_2 0x00000200
#define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
#define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
#define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
#define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
#define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
#define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13
#define IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK \
(7 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT)
#define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
#define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK \
(7 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
#define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000
#define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000
#define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000
#define IEEE80211_VHT_CAP_HTC_VHT 0x00400000
#define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT 23
#define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
(7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT)
#define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB 0x08000000
#define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000
#define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN 0x10000000
#define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN 0x20000000
/* block-ack parameters */
#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C

View File

@ -6119,7 +6119,13 @@ static void rtw_cfg80211_init_ht_capab(_adapter *padapter, struct ieee80211_sta_
ht_cap->ht_supported = _TRUE;
ht_cap->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
/* According to the comment in rtw_ap.c:
* "Note: currently we switch to the MIXED op mode if HT non-greenfield
* station is associated. Probably it's a theoretical case, since
* it looks like all known HT STAs support greenfield."
* Therefore Greenfield is added to ht_cap
*/
ht_cap->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_GRN_FLD |
IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20 |
IEEE80211_HT_CAP_DSSSCCK40 | IEEE80211_HT_CAP_MAX_AMSDU;
rtw_cfg80211_init_ht_capab_ex(padapter, ht_cap, band, rf_type);
@ -6320,6 +6326,86 @@ static void rtw_cfg80211_create_vht_cap(_adapter *padapter, struct ieee80211_sta
#endif
}
static void rtw_cfg80211_init_vht_capab_ex(_adapter *padapter, struct ieee80211_sta_vht_cap *vht_cap, u8 rf_type)
{
//todo: Support for other bandwidths
/* NSS = Number of Spatial Streams */
#define MAX_BIT_RATE_80MHZ_NSS3 1300 /* Mbps */
#define MAX_BIT_RATE_80MHZ_NSS2 867 /* Mbps */
#define MAX_BIT_RATE_80MHZ_NSS1 434 /* Mbps */
struct registry_priv *pregistrypriv = &padapter->registrypriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct vht_priv *pvhtpriv = &pmlmepriv->vhtpriv;
rtw_vht_use_default_setting(padapter);
/* RX LDPC */
if (TEST_FLAG(pvhtpriv->ldpc_cap, LDPC_VHT_ENABLE_RX))
vht_cap->cap |= IEEE80211_VHT_CAP_RXLDPC;
/* TX STBC */
if (TEST_FLAG(pvhtpriv->stbc_cap, STBC_VHT_ENABLE_TX))
vht_cap->cap |= IEEE80211_VHT_CAP_TXSTBC;
/* RX STBC */
if (TEST_FLAG(pvhtpriv->stbc_cap, STBC_VHT_ENABLE_RX)) {
switch (rf_type) {
case RF_1T1R:
vht_cap->cap |= IEEE80211_VHT_CAP_RXSTBC_1;/*RX STBC One spatial stream*/
break;
case RF_2T2R:
case RF_1T2R:
vht_cap->cap |= IEEE80211_VHT_CAP_RXSTBC_2;/*RX STBC Two spatial streams*/
break;
case RF_3T3R:
case RF_3T4R:
case RF_4T4R:
vht_cap->cap |= IEEE80211_VHT_CAP_RXSTBC_3;/*RX STBC Three spatial streams*/
break;
default:
/* DBG_871X("[warning] rf_type %d is not expected\n", rf_type); */
break;
}
}
/* switch (rf_type) {
case RF_1T1R:
vht_cap->vht_mcs.tx_highest = MAX_BIT_RATE_80MHZ_NSS1;
vht_cap->vht_mcs.rx_highest = MAX_BIT_RATE_80MHZ_NSS1;
break;
case RF_2T2R:
case RF_1T2R:
vht_cap->vht_mcs.tx_highest = MAX_BIT_RATE_80MHZ_NSS2;
vht_cap->vht_mcs.rx_highest = MAX_BIT_RATE_80MHZ_NSS2;
break;
case RF_3T3R:
case RF_3T4R:
case RF_4T4R:
vht_cap->vht_mcs.tx_highest = MAX_BIT_RATE_80MHZ_NSS3;
vht_cap->vht_mcs.rx_highest = MAX_BIT_RATE_80MHZ_NSS3;
break;
default:
DBG_871X("[warning] rf_type %d is not expected\n", rf_type);
break;
} */
/* MCS map */
vht_cap->vht_mcs.tx_mcs_map = pvhtpriv->vht_mcs_map[0] | (pvhtpriv->vht_mcs_map[1] << 8);
vht_cap->vht_mcs.rx_mcs_map = vht_cap->vht_mcs.tx_mcs_map;
if (rf_type == RF_1T1R) {
vht_cap->vht_mcs.tx_highest = MAX_BIT_RATE_80MHZ_NSS1;
vht_cap->vht_mcs.rx_highest = MAX_BIT_RATE_80MHZ_NSS1;
}
if (pvhtpriv->sgi_80m)
vht_cap->cap |= IEEE80211_VHT_CAP_SHORT_GI_80;
vht_cap->cap |= (pvhtpriv->ampdu_len << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT);
}
void rtw_cfg80211_init_wiphy(_adapter *padapter)
{
u8 rf_type;

View File

@ -18,20 +18,16 @@
*
******************************************************************************/
#define _MLME_OSDEP_C_
#include <drv_types.h>
#ifdef RTK_DMP_PLATFORM
void Linkup_workitem_callback(struct work_struct *work)
{
struct mlme_priv *pmlmepriv = container_of(work, struct mlme_priv, Linkup_workitem);
_adapter *padapter = container_of(pmlmepriv, _adapter, mlmepriv);
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12))
kobject_uevent(&padapter->pnetdev->dev.kobj, KOBJ_LINKUP);
#else
@ -45,8 +41,6 @@ void Linkdown_workitem_callback(struct work_struct *work)
struct mlme_priv *pmlmepriv = container_of(work, struct mlme_priv, Linkdown_workitem);
_adapter *padapter = container_of(pmlmepriv, _adapter, mlmepriv);
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12))
kobject_uevent(&padapter->pnetdev->dev.kobj, KOBJ_LINKDOWN);
#else
@ -56,7 +50,6 @@ void Linkdown_workitem_callback(struct work_struct *work)
}
#endif
/*
void sitesurvey_ctrl_handler(void *FunctionContext)
{
@ -74,14 +67,12 @@ void rtw_join_timeout_handler(void *FunctionContext)
_rtw_join_timeout_handler(adapter);
}
void _rtw_scan_timeout_handler(void *FunctionContext)
{
_adapter *adapter = (_adapter *)FunctionContext;
rtw_scan_timeout_handler(adapter);
}
void _dynamic_check_timer_handlder(void *FunctionContext)
{
struct dvobj_priv *pdvobj = (struct dvobj_priv *)FunctionContext;
@ -108,7 +99,6 @@ void _rtw_set_scan_deny_timer_hdl(void *FunctionContext)
}
#endif
void rtw_init_mlme_timer(_adapter *padapter)
{
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@ -157,7 +147,6 @@ void rtw_os_indicate_connect(_adapter *adapter)
_set_workitem(&adapter->mlmepriv.Linkup_workitem);
#endif
}
extern void indicate_wx_scan_complete_event(_adapter *padapter);
@ -237,7 +226,6 @@ void rtw_os_indicate_disconnect(_adapter *adapter, u16 reason, u8 locally_gener
{
/* RT_PMKID_LIST backupPMKIDList[NUM_PMKID_CACHE]; */
netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */
#ifdef CONFIG_IOCTL_CFG80211
@ -252,7 +240,6 @@ void rtw_os_indicate_disconnect(_adapter *adapter, u16 reason, u8 locally_gener
/* modify for CONFIG_IEEE80211W, none 11w also can use the same command */
rtw_reset_securitypriv_cmd(adapter);
}
void rtw_report_sec_ie(_adapter *adapter, u8 authmode, u8 *sec_ie)
@ -261,8 +248,6 @@ void rtw_report_sec_ie(_adapter *adapter, u8 authmode, u8 *sec_ie)
u8 *buff, *p, i;
union iwreq_data wrqu;
buff = NULL;
if (authmode == _WPA_IE_ID_) {
@ -297,7 +282,6 @@ void rtw_report_sec_ie(_adapter *adapter, u8 authmode, u8 *sec_ie)
rtw_mfree(buff, IW_CUSTOM_MAX);
}
}
void _survey_timer_hdl(void *FunctionContext)
@ -384,7 +368,6 @@ void rtw_indicate_sta_assoc_event(_adapter *padapter, struct sta_info *psta)
if (pstapriv->sta_aid[psta->aid - 1] != psta)
return;
wrqu.addr.sa_family = ARPHRD_ETHER;
_rtw_memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
@ -411,7 +394,6 @@ void rtw_indicate_sta_disassoc_event(_adapter *padapter, struct sta_info *psta)
if (pstapriv->sta_aid[psta->aid - 1] != psta)
return;
wrqu.addr.sa_family = ARPHRD_ETHER;
_rtw_memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
@ -424,7 +406,6 @@ void rtw_indicate_sta_disassoc_event(_adapter *padapter, struct sta_info *psta)
}
#ifdef CONFIG_HOSTAPD_MLME
static int mgnt_xmit_entry(struct sk_buff *skb, struct net_device *pnetdev)
@ -443,7 +424,6 @@ static int mgnt_netdev_open(struct net_device *pnetdev)
RTW_INFO("mgnt_netdev_open: MAC Address:" MAC_FMT "\n", MAC_ARG(pnetdev->dev_addr));
init_usb_anchor(&phostapdpriv->anchored);
rtw_netif_wake_queue(pnetdev);
@ -536,15 +516,11 @@ int hostapd_mode_init(_adapter *padapter)
pnetdev->features |= NETIF_F_IP_CSUM;
#endif
if (dev_alloc_name(pnetdev, "mgnt.wlan%d") < 0)
RTW_INFO("hostapd_mode_init(): dev_alloc_name, fail!\n");
/* SET_NETDEV_DEV(pnetdev, pintfpriv->udev); */
mac[0] = 0x00;
mac[1] = 0xe0;
mac[2] = 0x4c;
@ -554,10 +530,8 @@ int hostapd_mode_init(_adapter *padapter)
_rtw_memcpy(pnetdev->dev_addr, mac, ETH_ALEN);
netif_carrier_off(pnetdev);
/* Tell the network stack we exist */
if (register_netdev(pnetdev) != 0) {
RTW_INFO("hostapd_mode_init(): register_netdev fail!\n");

View File

@ -1920,7 +1920,11 @@ static int readFile(struct file *fp, char *buf, int len)
while (sum < len) {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0))
rlen = kernel_read(fp, buf + sum, len - sum, &fp->f_pos);
#else
rlen = __vfs_read(fp, buf + sum, len - sum, &fp->f_pos);
#endif
#else
rlen = fp->f_op->read(fp, buf + sum, len - sum, &fp->f_pos);
#endif