From d6fe5161fd7cf9eba292fdd0799f1deaa32df55e Mon Sep 17 00:00:00 2001 From: kimocoder Date: Tue, 24 Jul 2018 17:26:16 +0200 Subject: [PATCH 01/16] enable USB3 mode switch, this also enables VHT SS3 --- dkms.conf | 2 +- os_dep/linux/os_intfs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dkms.conf b/dkms.conf index 435ad1b..fe09b6b 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="realtek-rtl88xxau" -PACKAGE_VERSION="5.2.20.2~20180717" +PACKAGE_VERSION="5.2.20.2~20180724" BUILT_MODULE_NAME[0]="8812au" PROCS_NUM=`nproc` [ $PROCS_NUM -gt 16 ] && PROCS_NUM=16 diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 2788e24..cb97b85 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -306,7 +306,7 @@ int rtw_drv_ant_band_switch = 1; /* 0:OFF , 1:ON, Driver control antenna band sw int rtw_single_ant_path; /*0:main ant , 1:aux ant , Fixed single antenna path, default main ant*/ /* 0: doesn't switch, 1: switch from usb2.0 to usb 3.0 2: switch from usb3.0 to usb 2.0 */ -int rtw_switch_usb_mode = 0; +int rtw_switch_usb_mode = 1; #ifdef CONFIG_USB_AUTOSUSPEND int rtw_enusbss = 1;/* 0:disable,1:enable */ From d6e2f9c1be0424ad618e482bc15a320a4346860c Mon Sep 17 00:00:00 2001 From: kimocoder Date: Tue, 24 Jul 2018 20:32:19 +0200 Subject: [PATCH 02/16] More iw link output --- os_dep/linux/ioctl_cfg80211.c | 87 +++++++++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 14 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index b7713c5..e3df4a4 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -22,10 +22,24 @@ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) #define STATION_INFO_SIGNAL BIT(NL80211_STA_INFO_SIGNAL) #define STATION_INFO_TX_BITRATE BIT(NL80211_STA_INFO_TX_BITRATE) +#define STATION_INFO_TX_BITRATE_BW_5 BIT(RATE_INFO_BW_5) +#define STATION_INFO_TX_BITRATE_BW_10 BIT(RATE_INFO_BW_10) +#define STATION_INFO_TX_BITRATE_BW_20 BIT(RATE_INFO_BW_20) +#define STATION_INFO_TX_BITRATE_BW_40 BIT(RATE_INFO_BW_40) +#define STATION_INFO_TX_BITRATE_BW_80 BIT(RATE_INFO_BW_80) +#define STATION_INFO_TX_BITRATE_BW_160 BIT(RATE_INFO_BW_160) #define STATION_INFO_RX_PACKETS BIT(NL80211_STA_INFO_RX_PACKETS) #define STATION_INFO_TX_PACKETS BIT(NL80211_STA_INFO_TX_PACKETS) #define STATION_INFO_TX_FAILED BIT(NL80211_STA_INFO_TX_FAILED) +#define STATION_INFO_RX_BYTES BIT(NL80211_STA_INFO_RX_BYTES) +#define STATION_INFO_TX_BYTES BIT(NL80211_STA_INFO_TX_BYTES) #define STATION_INFO_ASSOC_REQ_IES 0 +#define STATION_INFO_BSS_PARAM BIT(NL80211_STA_INFO_BSS_PARAM) +#define STATION_INFO_BSS_PARAM_CTS_PROT BIT(NL80211_STA_BSS_PARAM_CTS_PROT) +#define STATION_INFO_BSS_PARAM_SHORT_PREAMBLE BIT(NL80211_STA_BSS_PARAM_SHORT_PREAMBLE) +#define STATION_INFO_BSS_PARAM_SHORT_SLOT_TIME BIT(NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME) +#define STATION_INFO_BSS_PARAM_DTIM_PERIOD BIT(NL80211_STA_BSS_PARAM_DTIM_PERIOD) +#define STATION_INFO_BSS_PARAM_BEACON_INTERVAL BIT(NL80211_STA_BSS_PARAM_BEACON_INTERVAL) #endif /* Linux kernel >= 4.0.0 */ #include @@ -1922,33 +1936,78 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, RTW_INFO(FUNC_NDEV_FMT" mac="MAC_FMT"\n", FUNC_NDEV_ARG(ndev), MAC_ARG(mac)); #endif - /* for infra./P2PClient mode */ +/* for infra./P2PClient mode */ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED) ) { struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); - if (_rtw_memcmp((u8 *)mac, cur_network->network.MacAddress, ETH_ALEN) == _FALSE) { - RTW_INFO("%s, mismatch bssid="MAC_FMT"\n", __func__, MAC_ARG(cur_network->network.MacAddress)); - ret = -ENOENT; - goto exit; - } + if (_rtw_memcmp((u8 *)mac, cur_network->network.MacAddress, ETH_ALEN) == _FALSE) { + RTW_INFO("%s, mismatch bssid="MAC_FMT"\n", __func__, MAC_ARG(cur_network->network.MacAddress)); + ret = -ENOENT; + goto exit; + } - sinfo->filled |= STATION_INFO_SIGNAL; - sinfo->signal = translate_percentage_to_dbm(padapter->recvpriv.signal_strength); + sinfo->filled |= STATION_INFO_SIGNAL; + sinfo->signal = translate_percentage_to_dbm(padapter->recvpriv.signal_strength); - sinfo->filled |= STATION_INFO_TX_BITRATE; - sinfo->txrate.legacy = rtw_get_cur_max_rate(padapter); + sinfo->filled |= STATION_INFO_TX_BITRATE; + sinfo->txrate.legacy = rtw_get_cur_max_rate(padapter); - sinfo->filled |= STATION_INFO_RX_PACKETS; - sinfo->rx_packets = sta_rx_data_pkts(psta); + /* to-do set the txrate flags */ + // for example something like: + //sinfo->txrate.flags |= NL80211_RATE_INFO_VHT_NSS; + //sinfo->txrate.nss = rtw_vht_mcsmap_to_nss(psta->vhtpriv.vht_mcs_map); - sinfo->filled |= STATION_INFO_TX_PACKETS; - sinfo->tx_packets = psta->sta_stats.tx_pkts; + + /* bw_mode is more delicate + sinfo->txrate.bw is flagged + psta->bw_mode */ + + /* + sinfo->txrate.bw = psta->bw_mode; + sinfo->txrate.flags |= psta->bw_mode; + printk("rtw_get_current_tx_sgi: %i", rtw_get_current_tx_sgi(padapter, mac)); + printk("NSS: %i", rtw_vht_mcsmap_to_nss(psta->vhtpriv.vht_mcs_map)); + printk("BW MODE: %i", psta->bw_mode); + printk("5 10 20 40 80 160: %i %i %i %i %i %i", STATION_INFO_TX_BITRATE_BW_5, STATION_INFO_TX_BITRATE_BW_10, STATION_INFO_TX_BITRATE_BW_20, STATION_INFO_TX_BITRATE_BW_40, STATION_INFO_TX_BITRATE_BW_80, STATION_INFO_TX_BITRATE_BW_160); + printk("5 10 20 40 80 160: %i %i %i %i %i %i", RATE_INFO_BW_5, RATE_INFO_BW_10, RATE_INFO_BW_20, RATE_INFO_BW_40, RATE_INFO_BW_80, RATE_INFO_BW_160); + */ + + sinfo->filled |= STATION_INFO_RX_BYTES; + sinfo->rx_bytes = psta->sta_stats.rx_bytes; + + sinfo->filled |= STATION_INFO_TX_BYTES; + sinfo->tx_bytes = psta->sta_stats.tx_bytes; + + sinfo->filled |= STATION_INFO_RX_PACKETS; + sinfo->rx_packets = sta_rx_data_pkts(psta); + + sinfo->filled |= STATION_INFO_TX_PACKETS; + sinfo->tx_packets = psta->sta_stats.tx_pkts; sinfo->filled |= STATION_INFO_TX_FAILED; sinfo->tx_failed = psta->sta_stats.tx_fail_cnt; + sinfo->filled |= STATION_INFO_BSS_PARAM; + + if (!psta->no_short_preamble_set) + sinfo->bss_param.flags |= STATION_INFO_BSS_PARAM_SHORT_PREAMBLE; + + if (!psta->no_short_slot_time_set) + sinfo->bss_param.flags |= STATION_INFO_BSS_PARAM_SHORT_SLOT_TIME; + + /* no idea how to check this yet */ + if (0) + sinfo->bss_param.flags |= STATION_INFO_BSS_PARAM_CTS_PROT; + + /* is this actually the dtim_period? */ + sinfo->bss_param.flags |= STATION_INFO_BSS_PARAM_DTIM_PERIOD; + sinfo->bss_param.dtim_period = pwrctl->dtim; + + sinfo->bss_param.beacon_interval = get_beacon_interval(&cur_network->network); + } /* for Ad-Hoc/AP mode */ From dd62a2f36a5056e595761f94ccc7d3265587107d Mon Sep 17 00:00:00 2001 From: kimocoder Date: Tue, 24 Jul 2018 20:45:13 +0200 Subject: [PATCH 03/16] Added HT Greenfield capabilities --- os_dep/linux/ioctl_cfg80211.c | 88 ++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index e3df4a4..ee7f16a 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -6958,7 +6958,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); @@ -7131,6 +7137,86 @@ static void rtw_cfg80211_init_vht_capab(_adapter *padapter, struct ieee80211_sta } #endif //CONFIG_VHT_EXTRAS +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; From 3aee436bf506aca8fd1a01fe08dea81ccd8df83c Mon Sep 17 00:00:00 2001 From: kimocoder Date: Tue, 24 Jul 2018 20:54:20 +0200 Subject: [PATCH 04/16] Some VHT fixes --- os_dep/linux/ioctl_cfg80211.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index ee7f16a..3a6da0d 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -7076,15 +7076,24 @@ static void rtw_cfg80211_init_vht_capab(_adapter *padapter, struct ieee80211_sta } /* B8 B9 B10 Rx STBC */ - if(TEST_FLAG(pvhtpriv->stbc_cap, STBC_VHT_ENABLE_RX)) { - rtw_hal_get_def_var(padapter, HAL_DEF_RX_STBC, (u8 *)(&rx_stbc_nss)); - - if (rx_stbc_nss == 1) - vht_cap->cap |= IEEE80211_VHT_CAP_RXSTBC_1; - else if (rx_stbc_nss == 2) - vht_cap->cap |= IEEE80211_VHT_CAP_RXSTBC_2; - else if (rx_stbc_nss == 3) - vht_cap->cap |= IEEE80211_VHT_CAP_RXSTBC_3; + 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; + } } /* B11 SU Beamformer Capable */ @@ -7121,18 +7130,17 @@ static void rtw_cfg80211_init_vht_capab(_adapter *padapter, struct ieee80211_sta else vht_cap->cap |= 7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT; - // Link Adaptation not supported /* B26 27 VHT Link Adaptation Capable */ - /* find the largest bw supported by both registry and hal */ + /* this is taken from core/rtw_vht.c */ bw = hal_largest_bw(padapter, REGSTY_BW_5G(pregistrypriv)); - HighestRate = VHT_MCS_DATA_RATE[bw][pvhtpriv->sgi_80m][((pvhtpriv->vht_highest_rate - MGN_VHT1SS_MCS0)&0x3f)]; + HighestRate = rtw_vht_mcs_to_data_rate(bw, pvhtpriv->sgi_80m, pvhtpriv->vht_highest_rate); HighestRate = (HighestRate+1) >> 1; - vht_cap->vht_mcs.tx_highest = HighestRate; vht_cap->vht_mcs.rx_highest = HighestRate; + RTW_INFO("[VHT] Highest rate value: %d\n", HighestRate); } #endif //CONFIG_VHT_EXTRAS From 2b876b6e7351d4dc7318f32a1286204721a16706 Mon Sep 17 00:00:00 2001 From: kimocoder Date: Tue, 24 Jul 2018 20:55:33 +0200 Subject: [PATCH 05/16] Set correct number of hardcoded streams 8812/8821 --- hal/rtl8812a/rtl8812a_hal_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/rtl8812a/rtl8812a_hal_init.c b/hal/rtl8812a/rtl8812a_hal_init.c index d98b258..8bbaf66 100644 --- a/hal/rtl8812a/rtl8812a_hal_init.c +++ b/hal/rtl8812a/rtl8812a_hal_init.c @@ -5891,7 +5891,7 @@ u8 GetHalDefVar8812A(PADAPTER padapter, HAL_DEF_VARIABLE variable, void *pval) break; case HAL_DEF_RX_STBC: - *(u8 *)pval = 1; + *(u8 *)pval = 2; break; case HAL_DEF_EXPLICIT_BEAMFORMER: From cfdf854042c6b7fe73627413d143eac68b9b30ab Mon Sep 17 00:00:00 2001 From: kimocoder Date: Tue, 24 Jul 2018 21:00:22 +0200 Subject: [PATCH 06/16] Fix USB3 modeswitch --- os_dep/linux/usb_intf.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index 0a9ae1a..6a5a50d 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -693,7 +693,25 @@ static int usb_reprobe_switch_usb_mode(PADAPTER Adapter) if (registry_par->switch_usb_mode == 0) goto exit; +#if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) || defined(CONFIG_RTL8814A) + if (IS_HIGH_SPEED_USB(Adapter)) { + if ((rtw_read8(Adapter, 0x74) & (BIT(2)|BIT(3))) != BIT(3)) { + rtw_write8(Adapter, 0x74, 0x8); + rtw_write8(Adapter, 0x70, 0x2); + rtw_write8(Adapter, 0x3e, 0x1); + rtw_write8(Adapter, 0x3d, 0x3); + /* usb disconnect */ + rtw_write8(Adapter, 0x5, 0x80); + ret = _TRUE; + } + + } else if (IS_SUPER_SPEED_USB(Adapter)) { + rtw_write8(Adapter, 0x70, rtw_read8(Adapter, 0x70) & (~BIT(1))); + rtw_write8(Adapter, 0x3e, rtw_read8(Adapter, 0x3e) & (~BIT(0))); + } +#else rtw_hal_set_hwreg(Adapter, HW_VAR_USB_MODE, &ret); +#endif exit: return ret; From da104137e8979a9831cafb63d258e667b933f3e9 Mon Sep 17 00:00:00 2001 From: kimocoder Date: Tue, 24 Jul 2018 21:21:14 +0200 Subject: [PATCH 07/16] Fix compile warnings (brackets) --- hal/phydm/txbf/halcomtxbf.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hal/phydm/txbf/halcomtxbf.c b/hal/phydm/txbf/halcomtxbf.c index 94a432c..d2cd09a 100644 --- a/hal/phydm/txbf/halcomtxbf.c +++ b/hal/phydm/txbf/halcomtxbf.c @@ -325,13 +325,13 @@ hal_com_txbf_rate_work_item_callback( PHYDM_DBG(p_dm, DBG_TXBF, ("[%s] Start!\n", __func__)); - if (p_dm->support_ic_type & ODM_RTL8812) + if (p_dm->support_ic_type & ODM_RTL8812) { hal_txbf_8812a_set_ndpa_rate(p_dm, BW, rate); - else if (p_dm->support_ic_type & ODM_RTL8192E) + } else if (p_dm->support_ic_type & ODM_RTL8192E) { hal_txbf_8192e_set_ndpa_rate(p_dm, BW, rate); - else if (p_dm->support_ic_type & ODM_RTL8814A) + } else if (p_dm->support_ic_type & ODM_RTL8814A) { hal_txbf_8814a_set_ndpa_rate(p_dm, BW, rate); - + } } @@ -410,9 +410,9 @@ hal_com_txbf_reset_tx_path_work_item_callback( u8 idx = p_txbf_info->txbf_idx; - if (p_dm->support_ic_type & ODM_RTL8814A) + if (p_dm->support_ic_type & ODM_RTL8814A) { hal_txbf_8814a_reset_tx_path(p_dm, idx); - + } } void @@ -431,8 +431,9 @@ hal_com_txbf_get_tx_rate_work_item_callback( struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; #endif - if (p_dm->support_ic_type & ODM_RTL8814A) + if (p_dm->support_ic_type & ODM_RTL8814A) { hal_txbf_8814a_get_tx_rate(p_dm); + } } From 200880abd02e7d086c5127c3e34f6b7586482aaa Mon Sep 17 00:00:00 2001 From: Christian B Date: Sun, 29 Jul 2018 13:21:55 +0200 Subject: [PATCH 08/16] Increased standard txpower used --- hal/rtl8812a/rtl8812a_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/rtl8812a/rtl8812a_dm.c b/hal/rtl8812a/rtl8812a_dm.c index d40d9b4..b6f83d4 100644 --- a/hal/rtl8812a/rtl8812a_dm.c +++ b/hal/rtl8812a/rtl8812a_dm.c @@ -344,7 +344,7 @@ void rtl8812_init_dm_priv(IN PADAPTER Adapter) Init_ODM_ComInfo_8812(Adapter); odm_init_all_timers(podmpriv); - pHalData->CurrentTxPwrIdx = 13; + pHalData->CurrentTxPwrIdx = 18; } void rtl8812_deinit_dm_priv(IN PADAPTER Adapter) From af62fe43377f5181b51f00797c216e1ac4a96e5b Mon Sep 17 00:00:00 2001 From: kimocoder Date: Sun, 29 Jul 2018 18:04:28 +0200 Subject: [PATCH 09/16] Fix interface rename error --- os_dep/linux/os_intfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index cb97b85..1bb7292 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1352,6 +1352,7 @@ static u8 is_rtw_ndev(struct net_device *ndev) static int rtw_ndev_notifier_call(struct notifier_block *nb, unsigned long state, void *ptr) { struct net_device *ndev; + _adapter *adapter = rtw_netdev_priv(ndev); if (ptr == NULL) return NOTIFY_DONE; @@ -1373,6 +1374,8 @@ static int rtw_ndev_notifier_call(struct notifier_block *nb, unsigned long state switch (state) { case NETDEV_CHANGENAME: rtw_adapter_proc_replace(ndev); + strncpy(adapter->old_ifname, ndev->name, IFNAMSIZ); + adapter->old_ifname[IFNAMSIZ-1] = 0; break; } From 4d896a9145a9b251e67ac4e47e5ce1bc31ba92f3 Mon Sep 17 00:00:00 2001 From: kimocoder Date: Sun, 29 Jul 2018 18:12:29 +0200 Subject: [PATCH 10/16] Fix compilation error under kernel v3.13 --- dkms.conf | 2 +- os_dep/linux/wifi_regd.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dkms.conf b/dkms.conf index fe09b6b..2e47ecd 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="realtek-rtl88xxau" -PACKAGE_VERSION="5.2.20.2~20180724" +PACKAGE_VERSION="5.2.20.2~20180730" BUILT_MODULE_NAME[0]="8812au" PROCS_NUM=`nproc` [ $PROCS_NUM -gt 16 ] && PROCS_NUM=16 diff --git a/os_dep/linux/wifi_regd.c b/os_dep/linux/wifi_regd.c index 796d27b..03a6fff 100644 --- a/os_dep/linux/wifi_regd.c +++ b/os_dep/linux/wifi_regd.c @@ -334,8 +334,13 @@ static void _rtw_reg_apply_flags(struct wiphy *wiphy) if (ch) ch->flags &= ~(IEEE80211_CHAN_DISABLED|IEEE80211_CHAN_NO_HT40PLUS| IEEE80211_CHAN_NO_HT40MINUS|IEEE80211_CHAN_NO_80MHZ| - IEEE80211_CHAN_NO_160MHZ); - //ch->flags = IEEE80211_CHAN_DISABLED; + IEEE80211_CHAN_NO_160MHZ| +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)) + IEEE80211_CHAN_NO_IBSS|IEEE80211_CHAN_PASSIVE_SCAN); +#else + IEEE80211_CHAN_NO_IR); +#endif + //ch->flags = IEEE80211_CHAN_DISABLED; } } } From 6a056e6c7203c3fa9a8a1b5fd4317c4a7ab4585b Mon Sep 17 00:00:00 2001 From: kimocoder Date: Sun, 29 Jul 2018 18:15:08 +0200 Subject: [PATCH 11/16] Compile on kernel v4.11 --- include/osdep_service_linux.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/osdep_service_linux.h b/include/osdep_service_linux.h index a80a64b..efe0f2b 100644 --- a/include/osdep_service_linux.h +++ b/include/osdep_service_linux.h @@ -65,6 +65,10 @@ #include #endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) + #include +#endif + #ifdef RTK_DMP_PLATFORM #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12)) #include From e225f57f52a758e1f39bc187a5cbd82b0b216f1e Mon Sep 17 00:00:00 2001 From: kimocoder Date: Sun, 29 Jul 2018 18:16:48 +0200 Subject: [PATCH 12/16] Add support for kernels >= 4.7 --- include/rtw_wifi_regd.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/rtw_wifi_regd.h b/include/rtw_wifi_regd.h index f56008c..5355ff8 100644 --- a/include/rtw_wifi_regd.h +++ b/include/rtw_wifi_regd.h @@ -31,4 +31,11 @@ enum country_code_type_t { int rtw_regd_init(_adapter *padapter); void rtw_reg_notify_by_driver(_adapter *adapter); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) +#define ieee80211_band nl80211_band +#define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ +#define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ +#define IEEE80211_NUM_BANDS NUM_NL80211_BANDS +#endif + #endif /* __RTW_WIFI_REGD_H__ */ From 8132170418095e4815348b6cee4eb92d5182cf60 Mon Sep 17 00:00:00 2001 From: kimocoder Date: Sun, 29 Jul 2018 18:28:40 +0200 Subject: [PATCH 13/16] Added get channel function --- os_dep/linux/ioctl_cfg80211.c | 111 ++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 3a6da0d..0f0adc9 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -4806,6 +4806,116 @@ static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev, } +static int cfg80211_rtw_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, struct cfg80211_chan_def *chandef){ + _adapter *padapter= wiphy_to_adapter(wiphy); + int channel; + int control_freq; + int center_freq; + int center_freq2=0; + int width; + int band; + int bandWidth; + int offset; + + struct dvobj_priv *dvobj; + struct net_device *ndev = wdev->netdev; + HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); + if (!ndev) + return -ENODEV; + + offset = rtw_get_oper_choffset(padapter); + channel = adapter_to_dvobj(padapter)->oper_channel; + if (channel >= 1) { + switch (pHalData->current_band_type) { + case 0: + band = NL80211_BAND_2GHZ; + break; + case 1: + band = NL80211_BAND_5GHZ; + break; + default: + return -EINVAL; + + } + control_freq = ieee80211_channel_to_frequency(channel, band); + + dvobj=adapter_to_dvobj(padapter); + if (dvobj!=NULL) { + bandWidth = adapter_to_dvobj(padapter)->oper_bwmode; + //DBG_871X("%s bw %d\n", __func__,adapter_to_dvobj(padapter)->oper_bwmode); + } else { + bandWidth = pHalData->current_channel; + //DBG_871X("%s dvobj null\n", __func__); + } + switch(pHalData->current_channel){ + case CHANNEL_WIDTH_20: + //DBG_871X("%s width 20\n", __func__); + width = NL80211_CHAN_WIDTH_20; + center_freq = control_freq; + break; + case CHANNEL_WIDTH_40: + //DBG_871X("%s width 40\n", __func__); + width = NL80211_CHAN_WIDTH_40; + if (offset==HAL_PRIME_CHNL_OFFSET_LOWER) { + center_freq = control_freq +10; + } else { + center_freq = control_freq -10; + } + break; + case CHANNEL_WIDTH_80: + //DBG_871X("%s width 80\n", __func__); + width = NL80211_CHAN_WIDTH_80; + if (offset==HAL_PRIME_CHNL_OFFSET_LOWER) { + center_freq = control_freq +30; + } else { + center_freq = control_freq -30; + } + break; + case CHANNEL_WIDTH_160: + //DBG_871X("%s width 160\n", __func__); + width = NL80211_CHAN_WIDTH_160; + if (offset==HAL_PRIME_CHNL_OFFSET_LOWER) { + center_freq = control_freq +50; + } else { + center_freq = control_freq -50; + } + break; + case CHANNEL_WIDTH_80_80: + //DBG_871X("%s width 80x80\n", __func__); + width = NL80211_CHAN_WIDTH_80P80; + if (offset==HAL_PRIME_CHNL_OFFSET_LOWER) { + center_freq = control_freq +30; + center_freq2=center_freq+80; + } else { + center_freq = control_freq -30; + center_freq2=center_freq-80; + } + break; + case CHANNEL_WIDTH_MAX: + //DBG_871X("%s width max\n", __func__); + width = NL80211_CHAN_WIDTH_160; + break; + } + chandef->chan = ieee80211_get_channel(wiphy, control_freq); + if (chandef->chan == NULL) { + chandef->chan = ieee80211_get_channel(wiphy, ieee80211_channel_to_frequency(channel, band)); + //DBG_871X("%s chan null\n", __func__); + if (chandef->chan == NULL) { + //DBG_871X("%s chan null\n", __func__); + return -EINVAL; + } + } + chandef->width = width; + chandef->center_freq1 = center_freq; + chandef->center_freq2 = center_freq2; + //DBG_871X("%s : channel %d width %d freq1 %d freq2 %d center_freq %d offset %d\n", __func__, channel, width, chandef->center_freq1, chandef->center_freq2, chandef->chan->center_freq,rtw_get_oper_choffset(padapter)); + } else { + return -EINVAL; + } + return 0; + +} + static int cfg80211_rtw_set_channel(struct wiphy *wiphy #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) , struct net_device *ndev @@ -7677,6 +7787,7 @@ static struct cfg80211_ops rtw_cfg80211_ops = { .suspend = cfg80211_rtw_suspend, .resume = cfg80211_rtw_resume, #endif /* CONFIG_PNO_SUPPORT */ + .get_channel = cfg80211_rtw_get_channel, #ifdef CONFIG_RFKILL_POLL .rfkill_poll = cfg80211_rtw_rfkill_poll, #endif From 1105ad72950a6504350fb89a775d1d1c4d6b3807 Mon Sep 17 00:00:00 2001 From: fariouche Date: Sat, 4 Aug 2018 12:56:55 +0200 Subject: [PATCH 14/16] Fixed crash because of stupid bug in led function with 8814 --- hal/led/hal_usb_led.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hal/led/hal_usb_led.c b/hal/led/hal_usb_led.c index 68fd21b..54d02b2 100644 --- a/hal/led/hal_usb_led.c +++ b/hal/led/hal_usb_led.c @@ -28,7 +28,8 @@ rtw_led_control( { do { - (adapter)->ledpriv.LedControlHandler((adapter), (LedAction)); + if((adapter)->ledpriv.LedControlHandler) + (adapter)->ledpriv.LedControlHandler((adapter), (LedAction)); } while(0); } From 53c7dd44ed90982eb72e421463a7c893022fd6e2 Mon Sep 17 00:00:00 2001 From: kimocoder Date: Sat, 4 Aug 2018 13:23:18 +0200 Subject: [PATCH 15/16] README.md update --- Makefile | 2 +- README.md | 2 +- dkms.conf | 2 +- hal/rtl8814a/usb/.rtl8814au_xmit.c.swp | Bin 0 -> 1024 bytes 4 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 hal/rtl8814a/usb/.rtl8814au_xmit.c.swp diff --git a/Makefile b/Makefile index 5910267..1911446 100755 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ CONFIG_RTL8812A = y CONFIG_RTL8821A = y CONFIG_RTL8192E = n CONFIG_RTL8723B = n -CONFIG_RTL8814A = n +CONFIG_RTL8814A = y CONFIG_RTL8723C = n CONFIG_RTL8188F = n CONFIG_RTL8822B = n diff --git a/README.md b/README.md index e8b40ff..ad2cab1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Realtek 8812AU driver v5.2.20.2 with monitor mode and frame injection -This driver supports 8812au & 8821au chipsets, not the 8814au chipset at this moment. +This driver supports 8812au / 8821au and 8814au chipsets. ### Building / Installing diff --git a/dkms.conf b/dkms.conf index 2e47ecd..011695b 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="realtek-rtl88xxau" -PACKAGE_VERSION="5.2.20.2~20180730" +PACKAGE_VERSION="5.2.20.2~20180804" BUILT_MODULE_NAME[0]="8812au" PROCS_NUM=`nproc` [ $PROCS_NUM -gt 16 ] && PROCS_NUM=16 diff --git a/hal/rtl8814a/usb/.rtl8814au_xmit.c.swp b/hal/rtl8814a/usb/.rtl8814au_xmit.c.swp new file mode 100644 index 0000000000000000000000000000000000000000..7b41a0671dcd73b0cc953d5e4b2f54be30a91d1d GIT binary patch literal 1024 zcmYc?$V<%2S1{7E)U#kf0;={53`P0*B}hUznc0asnK&hpBr+0n^ovSzEG!I767@@q bli-}v_=?=j61`+3wWG|@5Eu;s+J^uDc5@PH literal 0 HcmV?d00001 From f2119aedd711c677f87bdbb5f7cfca77be95f290 Mon Sep 17 00:00:00 2001 From: kimocoder Date: Sat, 4 Aug 2018 17:13:04 +0200 Subject: [PATCH 16/16] Fix DKMS to include 8814au chipset --- Makefile | 18 ++-- README.md | 127 +++++++++++-------------- dkms.conf | 9 +- hal/rtl8814a/usb/.rtl8814au_xmit.c.swp | Bin 1024 -> 0 bytes 4 files changed, 65 insertions(+), 89 deletions(-) delete mode 100644 hal/rtl8814a/usb/.rtl8814au_xmit.c.swp diff --git a/Makefile b/Makefile index 1911446..b4324ad 100755 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ CONFIG_RTL8812A = y CONFIG_RTL8821A = y CONFIG_RTL8192E = n CONFIG_RTL8723B = n -CONFIG_RTL8814A = y +CONFIG_RTL8814A = n CONFIG_RTL8723C = n CONFIG_RTL8188F = n CONFIG_RTL8822B = n @@ -196,17 +196,11 @@ ifeq ($(CONFIG_PCI_HCI), y) HCI_NAME = pci endif -#ifeq ($(RTL8814), 1) -#CONFIG_RTL8812A = n -#CONFIG_RTL8821A = n -#CONFIG_RTL8814A = y -#endif - -#ifeq ($(RTL8821), 1) -#CONFIG_RTL8812A = y -#CONFIG_RTL8821A = y -#CONFIG_RTL8814A = n -#endif +ifeq ($(RTL8814), 1) +CONFIG_RTL8812A = y +CONFIG_RTL8821A = y +CONFIG_RTL8814A = y +endif ifeq ($(CONFIG_USB2_EXTERNAL_POWER), y) EXTRA_CFLAGS += -DCONFIG_USE_EXTERNAL_POWER diff --git a/README.md b/README.md index ad2cab1..c0a632d 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,37 @@ -# rtl8812au +# RTL8812AU/21AU and RTL8814AU drivers +# with monitor mode and frame injection -## Realtek 8812AU driver v5.2.20.2 with monitor mode and frame injection - -This driver supports 8812au / 8821au and 8814au chipsets. - -### Building / Installing - -To build and install module manually: +## DKMS +This driver can be installed using [DKMS]. This is a system which will automatically recompile and install a kernel module when a new kernel gets installed or updated. To make use of DKMS, install the `dkms` package, which on Debian (based) systems is done like this: ``` -$ sudo make -$ sudo make install +sudo apt install dkms ``` -To use DKMS install: - +## Installation of Driver +In order to install the driver open a terminal in the directory with the source code and execute the following command: ``` -$ sudo ./dkms-install.sh +sudo ./dkms-install.sh ``` -To use DKMS uninstall and remove: - +## Removal of Driver +In order to remove the driver from your system open a terminal in the directory with the source code and execute the following command: ``` -$ sudo ./dkms-remove.sh +sudo ./dkms-remove.sh ``` -### Notes +## Make +For building & installing the rtl8812au/rtl8821au driver with 'make' use +``` +make +make install +``` +and for building & installing the rtl8814au driver with 'make' use +``` +make RTL8814=1 +make install RTL8814=1 +``` + +## Notes Download ``` git clone -b v5.2.20 https://github.com/aircrack-ng/rtl8812au.git @@ -35,72 +42,45 @@ Package / Build dependencies (Kali) sudo apt-get install build-essential sudo apt-get install bc sudo apt-get install libelf-dev -sudo apt-get install dkms sudo apt-get install linux-headers-`uname -r` ``` -Building for Raspberry (RPI) also needs +For Raspberry (RPI) ``` sudo apt install raspberrypi-kernel-headers ``` - -### For setting monitor mode -1. Fix problematic interference in monitor mode. +For setting monitor mode + 1. Fix problematic interference in monitor mode. + ``` + airmon-ng check kill + ``` + You may also uncheck the box "Automatically connect to this network when it is avaiable" in nm-connection-editor. This only works if you have a saved wifi connection. + + 2. Set interface down + ``` + sudo ip link set wlan0 down + ``` + 3. Set monitor mode + ``` + sudo iw dev wlan0 set type monitor + ``` + 4. Set interface up + ``` + sudo ip link set wlan0 up + ``` +For setting TX power ``` -airmon-ng check kill -``` -You may also uncheck the box "Automatically connect to this network when it is avaiable" in nm-connection-editor. This only works if you have a saved wifi connection. - -2. Set interface down -``` -sudo ip link set wlan0 down -``` -3. Set monitor mode -``` -sudo iw dev wlan0 set type monitor -``` -4. Set interface up -``` -sudo ip link set wlan0 up +sudo iw wlan0 set txpower fixed 3000 ``` -### TX Power Control - -The txpower may be adjusted with these commands -``` -ifconfig down -iwconfig txpower 30 +## LED Parameter ``` +We've added the "realtek-leds.conf" in build directory, +with this you may change the leds to +"2: Allways On", "1: Normal" or "0: Allways Off" with placing the file in "/etc/modprobe.d/ -### LED control - -#### You can now control LED behaviour statically by Makefile, for example: - -```sh -CONFIG_LED_ENABLE = n -``` -value can be y or n - -#### statically by module parameter in /etc/modprobe.d/8812au.conf or wherever, for example: - -```sh -options 8812au rtw_led_enable=0 -``` -value can be 0 or 1 - -#### or dynamically by writing to /proc/net/rtl8812au/$(your interface name)/led_enable, for example: - -```sh -$ echo "0" > /proc/net/rtl8812au/$(your interface name)/led_enable -``` -value can be 0 or 1 - -#### check current value: - -```sh -$ cat /proc/net/rtl8812au/$(your interface name)/led_enable -``` - -### NetworkManager +Manual modprobe will override this file if option value also included at the command line, e.g., +$ sudo modprobe -r 8812au +$ sudo modprobe 8812au rtw_led_ctrl=1 Newer versions of NetworkManager switches to random MAC address. Some users would prefer to use a fixed address. Simply add these lines below @@ -111,3 +91,4 @@ wifi.scan-rand-mac-address=no at the end of file /etc/NetworkManager/NetworkManager.conf and restart NetworkManager with the command: ``` sudo service NetworkManager restart +``` diff --git a/dkms.conf b/dkms.conf index 011695b..a8c9005 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,10 +1,11 @@ PACKAGE_NAME="realtek-rtl88xxau" PACKAGE_VERSION="5.2.20.2~20180804" -BUILT_MODULE_NAME[0]="8812au" +CLEAN="make clean" +BUILT_MODULE_NAME[0]=8812au PROCS_NUM=`nproc` [ $PROCS_NUM -gt 16 ] && PROCS_NUM=16 -MAKE="'make' -j$PROCS_NUM KVER=${kernelver} KSRC=/lib/modules/${kernelver}/build" -CLEAN="'make' clean" DEST_MODULE_LOCATION[0]="/updates" +MAKE[0]="'make' -j$PROCS_NUM KVER=${kernelver} && 'make' -j$PROCS_NUM RTL8814=1 KVER=${kernelver}" +BUILT_MODULE_NAME[1]=8814au +DEST_MODULE_LOCATION[1]="/updates" AUTOINSTALL="yes" -REMAKE_INITRD=no diff --git a/hal/rtl8814a/usb/.rtl8814au_xmit.c.swp b/hal/rtl8814a/usb/.rtl8814au_xmit.c.swp deleted file mode 100644 index 7b41a0671dcd73b0cc953d5e4b2f54be30a91d1d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{7E)U#kf0;={53`P0*B}hUznc0asnK&hpBr+0n^ovSzEG!I767@@q bli-}v_=?=j61`+3wWG|@5Eu;s+J^uDc5@PH