diff --git a/Makefile b/Makefile index e61e515..b6f82b9 100755 --- a/Makefile +++ b/Makefile @@ -87,6 +87,7 @@ CONFIG_RTW_NAPI = y CONFIG_RTW_GRO = y CONFIG_RTW_IPCAM_APPLICATION = n CONFIG_RTW_REPEATER_SON = n +CONFIG_RTW_WIFI_HAL = y CONFIG_VHT_EXTRAS = y CONFIG_LED_CONTROL = y CONFIG_LED_ENABLE = y @@ -470,7 +471,7 @@ endif EXTRA_CFLAGS += -DCONFIG_RTL8821A _HAL_INTFS_FILES += hal/rtl8812a/hal8821a_fw.o - + endif endif @@ -978,6 +979,12 @@ EXTRA_CFLAGS += -DCONFIG_WIFI_MONITOR endif endif +ifeq ($(CONFIG_RTW_WIFI_HAL), y) +#EXTRA_CFLAGS += -DCONFIG_RTW_WIFI_HAL_DEBUG +EXTRA_CFLAGS += -DCONFIG_RTW_WIFI_HAL +EXTRA_CFLAGS += -DCONFIG_RTW_CFGVEDNOR_LLSTATS +endif + ifeq ($(CONFIG_VHT_EXTRAS), y) EXTRA_CFLAGS += -DCONFIG_VHT_EXTRAS endif @@ -1836,7 +1843,7 @@ rtk_core := core/rtw_cmd.o \ core/rtw_btcoex.o \ core/rtw_beamforming.o \ core/rtw_odm.o \ - core/efuse/rtw_efuse.o + core/efuse/rtw_efuse.o ifeq ($(CONFIG_SDIO_HCI), y) rtk_core += core/rtw_sdio.o @@ -1926,17 +1933,18 @@ config_r: clean: #$(MAKE) -C $(KSRC) M=$(shell pwd) clean - cd hal ; rm -fr */*/*/*.mod.c */*/*/*.mod */*/*/*.o */*/*/.*.cmd */*/*/*.ko - cd hal ; rm -fr */*/*.mod.c */*/*.mod */*/*.o */*/.*.cmd */*/*.ko - cd hal ; rm -fr */*.mod.c */*.mod */*.o */.*.cmd */*.ko - cd hal ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko - cd core/efuse ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko - cd core ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko - cd os_dep/linux ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko .rtw_radiotap.o.d - cd os_dep ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko - cd platform ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko + cd hal ; rm -fr */*/*/*.mod.c */*/*/*.mod */*/*/*.o */*/*/*.o.* */*/*/.*.cmd */*/*/*.ko + cd hal ; rm -fr */*/*.mod.c */*/*.mod */*/*.o */*/*.o.* */*/.*.cmd */*/*.ko + cd hal ; rm -fr */*.mod.c */*.mod */*.o */*.o.* */.*.cmd */*.ko + cd hal ; rm -fr *.mod.c *.mod *.o *.o.* .*.cmd *.ko + cd core/efuse ; rm -fr *.mod.c *.mod *.o *.o.* .*.cmd *.ko + cd core ; rm -fr *.mod.c *.mod *.o *.o.* .*.cmd *.ko + cd os_dep/linux ; rm -fr *.mod.c *.mod *.o *.o.* .*.cmd *.ko .rtw_radiotap.o.d + cd os_dep ; rm -fr *.mod.c *.mod *.o *.o.* .*.cmd *.ko + cd platform ; rm -fr *.mod.c *.mod *.o *.o.* .*.cmd *.ko rm -fr Module.symvers ; rm -fr Module.markers ; rm -fr modules.order - rm -fr *.mod.c *.mod *.o .*.cmd *.ko *~ + rm -fr *.mod.c *.mod *.o *.o.* .*.cmd *.ko *~ rm -fr .tmp_versions rm -fr .cache.mk endif + diff --git a/README.md b/README.md index c5bf331..c09936a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # rtl8812au -## Realtek 8812AU driver v5.2.20 with monitor mode and frame injection +## Realtek 8812AU driver v5.2.20.2 with monitor mode and frame injection Only supports 8812AU chipset, not the 8814AU or the 8821AU at this point. @@ -31,7 +31,7 @@ $ sudo ./dkms-remove.sh ### Notes Download ``` -git clone -b v5.1.5 https://github.com/aircrack-ng/rtl8812au.git +git clone -b v5.2.20 https://github.com/aircrack-ng/rtl8812au.git cd rtl* ``` Package / Build dependencies (Kali) @@ -39,6 +39,7 @@ 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` ``` For Raspberry (RPI) also diff --git a/docs/Realtek_Changelog.txt b/Realtek_Changelog.txt similarity index 93% rename from docs/Realtek_Changelog.txt rename to Realtek_Changelog.txt index 6c099a1..7f7672f 100644 --- a/docs/Realtek_Changelog.txt +++ b/Realtek_Changelog.txt @@ -1,8 +1,16 @@ Product: RTL8812A USB Software Package - Linux Driver -Version: v5.2.20_25672.20171213 +Version: v5.2.20.2_28373.20180619 Release History: +v5.2.20.2_28373.20180619 + + Update phydm to improve TP stability + +v5.2.20.1_27761.20180508 + + Support WiFi-HAL for Android 8 + v5.2.20_25672.20171213 Update PHYDM setting diff --git a/core/rtw_ap.c b/core/rtw_ap.c index 96de6f6..75c52cf 100644 --- a/core/rtw_ap.c +++ b/core/rtw_ap.c @@ -1368,7 +1368,7 @@ static void rtw_ap_check_scan(_adapter *padapter) if (_FALSE == ATOMIC_READ(&pmlmepriv->olbc_ht)) ATOMIC_SET(&pmlmepriv->olbc_ht, _TRUE); - + if (padapter->registrypriv.wifi_spec) RTW_INFO("%s: %s is a/b/g ap\n", __func__, pnetwork->network.Ssid.Ssid); } @@ -1538,7 +1538,7 @@ chbw_decision: #ifdef CONFIG_MCC_MODE if (MCC_EN(padapter)) { - /* + /* * due to check under rtw_ap_chbw_decision * if under MCC mode, means req channel setting is the same as current channel setting * if not under MCC mode, mean req channel setting is not the same as current channel setting @@ -3991,7 +3991,7 @@ bool rtw_ap_chbw_decision(_adapter *adapter, s16 req_ch, s8 req_bw, s8 req_offse rtw_hal_set_mcc_setting_disconnect(adapter); } - } + } } #endif /* CONFIG_MCC_MODE */ @@ -4097,16 +4097,16 @@ bool rtw_ap_chbw_decision(_adapter *adapter, s16 req_ch, s8 req_bw, s8 req_offse goto exit; } - /* if (rtw_odm_dfs_domain_unknown(adapter) && rtw_is_dfs_chbw(dec_ch, dec_bw, dec_offset)) { */ - /* if (req_ch >= 0) */ - /* RTW_WARN(FUNC_ADPT_FMT" DFS channel %u,%u,%u can't be used\n", FUNC_ADPT_ARG(adapter), dec_ch, dec_bw, dec_offset); */ - /* if (req_ch > 0) { */ - /* /\* specific channel and not from IE => don't change channel setting *\/ */ - /* *chbw_allow = _FALSE; */ - /* goto exit; */ - /* } */ - /* goto choose_chbw; */ - /* } */ + //if (rtw_odm_dfs_domain_unknown(adapter) && rtw_is_dfs_chbw(dec_ch, dec_bw, dec_offset)) { + // if (req_ch >= 0) + // RTW_WARN(FUNC_ADPT_FMT" DFS channel %u,%u,%u can't be used\n", FUNC_ADPT_ARG(adapter), dec_ch, dec_bw, dec_offset); + // if (req_ch > 0) { + // /* specific channel and not from IE => don't change channel setting */ + // *chbw_allow = _FALSE; + // goto exit; + // } + // goto choose_chbw; + //} if (rtw_chset_is_ch_non_ocp(adapter_to_chset(adapter), dec_ch, dec_bw, dec_offset) == _FALSE) goto update_bss_chbw; diff --git a/core/rtw_debug.c b/core/rtw_debug.c index d01c7d0..cc78334 100644 --- a/core/rtw_debug.c +++ b/core/rtw_debug.c @@ -129,6 +129,10 @@ void dump_drv_cfg(void *sel) RTW_PRINT_SEL(sel, "CONFIG_RTW_80211R\n"); #endif +#ifdef CONFIG_RTW_WIFI_HAL + RTW_PRINT_SEL(sel, "CONFIG_RTW_WIFI_HAL\n"); +#endif + #ifdef CONFIG_USB_HCI #ifdef CONFIG_SUPPORT_USB_INT RTW_PRINT_SEL(sel, "CONFIG_SUPPORT_USB_INT\n"); diff --git a/core/rtw_mp.c b/core/rtw_mp.c index 564be07..078d13c 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -539,7 +539,10 @@ static void PHY_SetRFPathSwitch(PADAPTER padapter , BOOLEAN bMain) { #endif } else if (IS_HARDWARE_TYPE_8812(padapter) || IS_HARDWARE_TYPE_8821(padapter)) { #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) - phy_set_rf_path_switch_8812a(padapter, bMain); + HAL_DATA_TYPE *hal_data = GET_HAL_DATA(padapter); + struct PHY_DM_STRUCT *dm = &hal_data->odmpriv; + + phy_set_rf_path_switch_8812a(dm, bMain); #endif } else if (IS_HARDWARE_TYPE_8192E(padapter)) { #ifdef CONFIG_RTL8192E diff --git a/core/rtw_pwrctrl.c b/core/rtw_pwrctrl.c index a902396..0bb4d76 100644 --- a/core/rtw_pwrctrl.c +++ b/core/rtw_pwrctrl.c @@ -85,6 +85,10 @@ void _ips_enter(_adapter *padapter) if (pwrpriv->ips_mode == IPS_LEVEL_2) pwrpriv->bkeepfwalive = _TRUE; +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS + pwrpriv->pwr_saving_start_time = rtw_get_current_time(); +#endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ + rtw_ips_pwr_down(padapter); pwrpriv->rf_pwrstate = rf_off; } @@ -120,6 +124,11 @@ int _ips_leave(_adapter *padapter) result = rtw_ips_pwr_up(padapter); if (result == _SUCCESS) pwrpriv->rf_pwrstate = rf_on; + +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS + pwrpriv->pwr_saving_time += rtw_get_passing_time_ms(pwrpriv->pwr_saving_start_time); +#endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ + RTW_PRINT("nolinked power save leave\n"); RTW_INFO("==> ips_leave.....LED(0x%08x)...\n", rtw_read32(padapter, 0x4c)); @@ -1109,6 +1118,11 @@ void LPS_Enter(PADAPTER padapter, const char *msg) sprintf(buf, "WIFI-%s", msg); pwrpriv->bpower_saving = _TRUE; + +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS + pwrpriv->pwr_saving_start_time = rtw_get_current_time(); +#endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ + rtw_set_ps_mode(padapter, pwrpriv->power_mgnt, padapter->registrypriv.smart_ps, 0, buf); } } else @@ -1153,6 +1167,10 @@ void LPS_Leave(PADAPTER padapter, const char *msg) sprintf(buf, "WIFI-%s", msg); rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, buf); +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS + pwrpriv->pwr_saving_time += rtw_get_passing_time_ms(pwrpriv->pwr_saving_start_time); +#endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ + if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) LPS_RF_ON_check(padapter, LPS_LEAVE_TIMEOUT_MS); } diff --git a/core/rtw_recv.c b/core/rtw_recv.c index 56bdf4b..1b08ce8 100644 --- a/core/rtw_recv.c +++ b/core/rtw_recv.c @@ -2255,8 +2255,9 @@ sint validate_recv_frame(_adapter *adapter, union recv_frame *precv_frame) #endif } else { DBG_COUNTER(adapter->rx_logs.core_rx_pre_data_handled); - } break; + } + default: DBG_COUNTER(adapter->rx_logs.core_rx_pre_unknown); #ifdef DBG_RX_DROP_FRAME diff --git a/dkms-install.sh b/dkms-install.sh index 5cfa452..41d7113 100755 --- a/dkms-install.sh +++ b/dkms-install.sh @@ -9,7 +9,7 @@ fi DRV_DIR=rtl8812au DRV_NAME=rtl8812au -DRV_VERSION=5.2.20 +DRV_VERSION=5.2.20.2 cp -r ../${DRV_DIR} /usr/src/${DRV_NAME}-${DRV_VERSION} diff --git a/dkms-remove.sh b/dkms-remove.sh index d873c30..1364281 100755 --- a/dkms-remove.sh +++ b/dkms-remove.sh @@ -9,7 +9,7 @@ fi DRV_DIR=rtl8812au DRV_NAME=rtl8812au -DRV_VERSION=5.2.20 +DRV_VERSION=5.2.20.2 dkms remove ${DRV_NAME}/${DRV_VERSION} --all rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION} diff --git a/dkms.conf b/dkms.conf index 6b96c7c..51ace44 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="realtek-rtl8812au" -PACKAGE_VERSION="5.2.20~20180701" +PACKAGE_VERSION="5.2.20.2~20180702" BUILT_MODULE_NAME[0]="8812au" PROCS_NUM=`nproc` [ $PROCS_NUM -gt 16 ] && PROCS_NUM=16 diff --git a/docs/kimocoder_Changelog.txt b/docs/kimocoder_Changelog.txt deleted file mode 100644 index 5d901e2..0000000 --- a/docs/kimocoder_Changelog.txt +++ /dev/null @@ -1,57 +0,0 @@ - - kimocoder's changelog (goes beyond the Realtek changelog) - ---------------------------------------------------------------------------------------- - - TODO: - - Fix count for frames in RadioTap header (add to stats) - - Place signal quality and per antenna rssi into radiotap header - - Calculate signal quality in the monitor mode - - Add channels 151 and 153 - - Unmask all available channels - - Switch channels to 80 MHz widt in monitor mode - - Enable channel 14 and 80 MHz width in the regdom - - Switch channel in monitor mode - - Fix error switching to 80MHz channels under certain conditions - - Use configured driver name - - Disable driver debug output by default - - Fix is_compat_task() issue - - Use in_compat_syscall() instead of is_compat_task() if available - - Add support mode more adapters - - Add a more informational README - - +++ And propably alot more. We'll see. - - [2018.07.01] - - Fixed compilation warnings (brackets missing etc) - - [2018.06.26] - - Enable TX queue in the monitor mode - - Add support for namespaces (CONFIG_NET_NS) - - [2018.06.25] - - Fix injected frames drop - - Fixed compilation on some ARM platforms - - Added support for PPC platform - - Minor cleanups - - [2018.06.23] - - Added more VID/PID's + moved 1 to correct place - - Moved changelogs into "docs/" folder - - [2018.06.22] - - Enabled monitor mode - - Parse radiotap headers for proper frame injection - - RadioTap iterator from kernel 4.9 was added due to VHT field bug in kernels before 4.6 - - Disabled DFS - - Enable DBG_TX_POWER_IDX and DBG_PG_TXPWR_READ, added extra logging for these - - Disabled AP mode channel switching due to DFS checks - - Tweaked & optimized Makefile to compile with all cores available. Decreasing the compile time. - - Added switch to turn ON/OFF regdomain settings (Makefile) - - Added ODROID-C2 support - - Added 2 more VID/PID's - - Fixed dkms.conf and added dkms-install.sh and dkms-remove.sh - - Cleaned up some files & execution permissions. - - - - diff --git a/hal/hal_com_phycfg.c b/hal/hal_com_phycfg.c index ccdb569..bbc82d4 100644 --- a/hal/hal_com_phycfg.c +++ b/hal/hal_com_phycfg.c @@ -2662,7 +2662,6 @@ PHY_SetTxPowerByRate( RTW_INFO("Invalid RateIndex %d in %s\n", rateIndex, __FUNCTION__); return; } - if (DBG_TX_POWER_IDX) RTW_INFO( "TXPWR: by-rate-base [%sG][%c] Rate:%s = %d\n", (Band == BAND_ON_2_4G) ? "2.4" : "5", rf_path_char(RFPath), @@ -2722,6 +2721,7 @@ PHY_SetTxPowerIndexByRateArray( for (i = 0; i < RateArraySize; ++i) { #if DBG_TX_POWER_IDX struct txpwr_idx_comp tic; + powerIndex = rtw_hal_get_tx_power_index(pAdapter, RFPath, Rates[i], BandWidth, Channel, &tic); RTW_INFO("TXPWR: [%c][%s]ch:%u, %s %uT, pwr_idx:%u = %u + (%d=%d:%d) + (%d) + (%d)\n" , rf_path_char(RFPath), ch_width_str(BandWidth), Channel, MGN_RATE_STR(Rates[i]), tic.ntx_idx + 1 diff --git a/hal/phydm/halrf/halrf.c b/hal/phydm/halrf/halrf.c index 33cdaf4..068d483 100644 --- a/hal/phydm/halrf/halrf.c +++ b/hal/phydm/halrf/halrf.c @@ -1006,6 +1006,20 @@ halrf_cmn_info_set( case HALRF_CMNINFO_RATE_INDEX: p_rf->p_rate_index = (u32)value; break; +#if (DM_ODM_SUPPORT_TYPE & ODM_WIN) + case HALRF_CMNINFO_MP_PSD_POINT: + p_rf->halrf_psd_data.point = (u32)value; + break; + case HALRF_CMNINFO_MP_PSD_START_POINT: + p_rf->halrf_psd_data.start_point = (u32)value; + break; + case HALRF_CMNINFO_MP_PSD_STOP_POINT: + p_rf->halrf_psd_data.stop_point = (u32)value; + break; + case HALRF_CMNINFO_MP_PSD_AVERAGE: + p_rf->halrf_psd_data.average = (u32)value; + break; +#endif default: /* do nothing */ break; diff --git a/hal/phydm/halrf/halrf.h b/hal/phydm/halrf/halrf.h index 8ff3393..6def2ed 100644 --- a/hal/phydm/halrf/halrf.h +++ b/hal/phydm/halrf/halrf.h @@ -20,7 +20,7 @@ /*============================================================*/ /*include files*/ /*============================================================*/ - +#include "halrf/halrf_psd.h" /*============================================================*/ @@ -30,29 +30,29 @@ #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN)) #define IQK_VERSION_8188E "0x14" #define IQK_VERSION_8192E "0x01" -#define IQK_VERSION_8723B "0x1d" +#define IQK_VERSION_8723B "0x1e" #define IQK_VERSION_8812A "0x01" #define IQK_VERSION_8821A "0x01" #elif (DM_ODM_SUPPORT_TYPE & (ODM_CE)) #define IQK_VERSION_8188E "0x01" #define IQK_VERSION_8192E "0x01" -#define IQK_VERSION_8723B "0x19" +#define IQK_VERSION_8723B "0x1e" #define IQK_VERSION_8812A "0x01" #define IQK_VERSION_8821A "0x01" #elif (DM_ODM_SUPPORT_TYPE & (ODM_AP)) #define IQK_VERSION_8188E "0x01" #define IQK_VERSION_8192E "0x01" -#define IQK_VERSION_8723B "0x01" +#define IQK_VERSION_8723B "0x1e" #define IQK_VERSION_8812A "0x01" #define IQK_VERSION_8821A "0x01" #endif #define IQK_VERSION_8814A "0x0f" #define IQK_VERSION_8188F "0x01" #define IQK_VERSION_8197F "0x01" -#define IQK_VERSION_8703B "0x04" +#define IQK_VERSION_8703B "0x05" #define IQK_VERSION_8710B "0x01" -#define IQK_VERSION_8723D "0x01" -#define IQK_VERSION_8822B "0x2e" +#define IQK_VERSION_8723D "0x02" +#define IQK_VERSION_8822B "0x2f" #define IQK_VERSION_8821C "0x23" /*LCK version*/ @@ -123,7 +123,11 @@ enum halrf_cmninfo_init_e { HALRF_CMNINFO_FW_VER, HALRF_CMNINFO_RFK_FORBIDDEN, HALRF_CMNINFO_IQK_SEGMENT, - HALRF_CMNINFO_RATE_INDEX + HALRF_CMNINFO_RATE_INDEX, + HALRF_CMNINFO_MP_PSD_POINT, + HALRF_CMNINFO_MP_PSD_START_POINT, + HALRF_CMNINFO_MP_PSD_STOP_POINT, + HALRF_CMNINFO_MP_PSD_AVERAGE }; enum halrf_cmninfo_hook_e { @@ -161,6 +165,9 @@ struct _hal_rf_ { u8 *p_mp_rate_index; u32 p_rate_index; +#if (DM_ODM_SUPPORT_TYPE & ODM_WIN) + struct _halrf_psd_data halrf_psd_data; +#endif }; /*============================================================*/ diff --git a/hal/phydm/halrf/halrf_kfree.c b/hal/phydm/halrf/halrf_kfree.c index 1a127cf..5501325 100644 --- a/hal/phydm/halrf/halrf_kfree.c +++ b/hal/phydm/halrf/halrf_kfree.c @@ -259,8 +259,6 @@ phydm_clear_kfree_to_rf_8821c( )); } - - void phydm_get_thermal_trim_offset_8822b( void *p_dm_void @@ -560,6 +558,104 @@ phydm_clear_kfree_to_rf_8822b( )); } +void +phydm_get_thermal_trim_offset_8710b( +void *p_dm_void) +{ + struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; + struct odm_power_trim_data *p_power_trim_info = &(p_dm->power_trim_data); + + u8 pg_therm = 0xff; + + odm_efuse_one_byte_read(p_dm, 0x0EF, &pg_therm, false); + + if (pg_therm != 0xff) { + pg_therm = pg_therm & 0x1f; + if ((pg_therm & BIT(0)) == 0) + p_power_trim_info->thermal = (-1 * (pg_therm >> 1)); + else + p_power_trim_info->thermal = (pg_therm >> 1); + + p_power_trim_info->flag |= KFREE_FLAG_THERMAL_K_ON; + } + + ODM_RT_TRACE(p_dm, ODM_COMP_MP, ODM_DBG_LOUD, ("[kfree] 8710b thermal trim flag:0x%02x\n", p_power_trim_info->flag)); + + if (p_power_trim_info->flag & KFREE_FLAG_THERMAL_K_ON) + ODM_RT_TRACE(p_dm, ODM_COMP_MP, ODM_DBG_LOUD, ("[kfree] 8710b thermal:%d\n", p_power_trim_info->thermal)); + +} + +void +phydm_get_power_trim_offset_8710b( + void *p_dm_void +) +{ + struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; + struct odm_power_trim_data *p_power_trim_info = &(p_dm->power_trim_data); + struct odm_rf_calibration_structure *p_rf_calibrate_info = &(p_dm->rf_calibrate_info); + + u8 pg_power = 0xff; + + odm_efuse_one_byte_read(p_dm, 0xEE, &pg_power, false); + + if (pg_power != 0xff) { + /*Path A*/ + odm_efuse_one_byte_read(p_dm, 0xEE, &pg_power, false); + p_power_trim_info->bb_gain[0][0] = (pg_power & 0xf); + + p_power_trim_info->flag |= KFREE_FLAG_ON_2G; + p_power_trim_info->flag |= KFREE_FLAG_ON; + } + + + ODM_RT_TRACE(p_dm, ODM_COMP_MP, ODM_DBG_LOUD, ("[kfree] 8710b power trim flag:0x%02x\n", p_power_trim_info->flag)); + + if (p_power_trim_info->flag & KFREE_FLAG_ON) + + ODM_RT_TRACE(p_dm, ODM_COMP_MP, ODM_DBG_LOUD, ("[kfree] 8710b power_trim_data->bb_gain[0][0]=0x%X\n", p_power_trim_info->bb_gain[0][0])); + +} +void +phydm_set_kfree_to_rf_8710b( + void *p_dm_void, + u8 e_rf_path, + u8 data +) +{ + struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; + struct odm_rf_calibration_structure *p_rf_calibrate_info = &(p_dm->rf_calibrate_info); + + odm_set_rf_reg(p_dm, e_rf_path, 0x55, BIT(19), (data & BIT(0))); + odm_set_rf_reg(p_dm, e_rf_path, 0x55, (BIT(18) | BIT(17) | BIT(16) | BIT(15)), ((data & 0xf) >> 1)); + + ODM_RT_TRACE(p_dm, ODM_COMP_MP, ODM_DBG_LOUD, + ("[kfree] 8710b 0x55[19:14]=0x%X path=%d\n", + odm_get_rf_reg(p_dm, e_rf_path, 0x55, (BIT(19) | BIT(18) | BIT(17) | BIT(16) | BIT(15) | BIT(14))), + e_rf_path + )); +} + +void +phydm_clear_kfree_to_rf_8710b( + void *p_dm_void, + u8 e_rf_path, + u8 data +) +{ + struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; + struct odm_rf_calibration_structure *p_rf_calibrate_info = &(p_dm->rf_calibrate_info); + + odm_set_rf_reg(p_dm, e_rf_path, 0x55, BIT(19), (data & BIT(0))); + odm_set_rf_reg(p_dm, e_rf_path, 0x55, (BIT(18) | BIT(17) | BIT(16) | BIT(15) | BIT(14)), ((data & 0x1f) >> 1)); + + ODM_RT_TRACE(p_dm, ODM_COMP_MP, ODM_DBG_LOUD, + ("[kfree] 8710b clear power trim 0x55[19:14]=0x%X path=%d\n", + odm_get_rf_reg(p_dm, e_rf_path, 0x55, (BIT(19) | BIT(18) | BIT(17) | BIT(16) | BIT(15) | BIT(14))), + e_rf_path + )); +} + void @@ -581,6 +677,9 @@ phydm_set_kfree_to_rf( if (p_dm->support_ic_type & ODM_RTL8822B) phydm_set_kfree_to_rf_8822b(p_dm, e_rf_path, data); + + if (p_dm->support_ic_type & ODM_RTL8710B) + phydm_set_kfree_to_rf_8710b(p_dm, e_rf_path, data); } @@ -599,6 +698,9 @@ phydm_clear_kfree_to_rf( if (p_dm->support_ic_type & ODM_RTL8821C) phydm_clear_kfree_to_rf_8821c(p_dm, e_rf_path, 1); + + if (p_dm->support_ic_type & ODM_RTL8710B) + phydm_clear_kfree_to_rf_8710b(p_dm, e_rf_path, 1); } @@ -625,6 +727,8 @@ phydm_get_thermal_trim_offset( phydm_get_thermal_trim_offset_8821c(p_dm_void); else if (p_dm->support_ic_type & ODM_RTL8822B) phydm_get_thermal_trim_offset_8822b(p_dm_void); + else if (p_dm->support_ic_type & ODM_RTL8710B) + phydm_get_thermal_trim_offset_8710b(p_dm_void); } @@ -650,6 +754,8 @@ phydm_get_power_trim_offset( phydm_get_power_trim_offset_8821c(p_dm_void); else if (p_dm->support_ic_type & ODM_RTL8822B) phydm_get_power_trim_offset_8822b(p_dm_void); + else if (p_dm->support_ic_type & ODM_RTL8710B) + phydm_get_power_trim_offset_8710b(p_dm_void); } @@ -710,7 +816,7 @@ phydm_config_kfree( max_rf_path = 4; /*0~3*/ else if (p_dm->support_ic_type & (ODM_RTL8812 | ODM_RTL8192E | ODM_RTL8822B)) max_rf_path = 2; /*0~1*/ - else if (p_dm->support_ic_type & ODM_RTL8821C) + else if (p_dm->support_ic_type & (ODM_RTL8821C |ODM_RTL8710B)) max_rf_path = 1; ODM_RT_TRACE(p_dm, ODM_COMP_MP, ODM_DBG_LOUD, ("===>[kfree] phy_ConfigKFree()\n")); @@ -723,12 +829,14 @@ phydm_config_kfree( /*Make sure the targetval is defined*/ if (p_power_trim_info->flag & KFREE_FLAG_ON) { /*if kfree_table[0] == 0xff, means no Kfree*/ - + if (p_dm->support_ic_type &ODM_RTL8710B) + ODM_RT_TRACE(p_dm, ODM_COMP_MP, ODM_DBG_LOUD, ("[kfree] power_trim_data->bb_gain[0][0]=0x%X\n", p_power_trim_info->bb_gain[0][0])); + else if (p_dm->support_ic_type & (ODM_RTL8812 | ODM_RTL8192E | ODM_RTL8822B |ODM_RTL8821C | ODM_RTL8814A)){ for (i = 0; i < KFREE_BAND_NUM; i++) { for (j = 0; j < max_rf_path; j++) ODM_RT_TRACE(p_dm, ODM_COMP_MP, ODM_DBG_LOUD, ("[kfree] power_trim_data->bb_gain[%d][%d]=0x%X\n", i, j, p_power_trim_info->bb_gain[i][j])); + } } - if (*p_dm->p_band_type == ODM_BAND_2_4G && p_power_trim_info->flag & KFREE_FLAG_ON_2G) { if (channel_to_sw >= 1 && channel_to_sw <= 14) diff --git a/hal/phydm/halrf/halrf_powertracking_win.h b/hal/phydm/halrf/halrf_powertracking_win.h index 89816b1..3d129b5 100644 --- a/hal/phydm/halrf/halrf_powertracking_win.h +++ b/hal/phydm/halrf/halrf_powertracking_win.h @@ -296,8 +296,6 @@ struct odm_rf_calibration_structure { /*Add by Yuchen for Kfree Phydm*/ u8 reg_rf_kfree_enable; /*for registry*/ u8 rf_kfree_enable; /*for efuse enable check*/ - - HALMAC_PWR_TRACKING_OPTION HALMAC_PWR_TRACKING_INFO; }; diff --git a/hal/phydm/halrf/halrf_psd.c b/hal/phydm/halrf/halrf_psd.c new file mode 100644 index 0000000..4baf4d0 --- /dev/null +++ b/hal/phydm/halrf/halrf_psd.c @@ -0,0 +1,328 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2017 Realtek Corporation. + * + * 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. + * + *****************************************************************************/ + +//============================================================ +// include files +//============================================================ +#include "mp_precomp.h" +#include "phydm_precomp.h" + + +#if (DM_ODM_SUPPORT_TYPE & ODM_WIN) + +#if 0 +u32 _sqrt(u64 n) +{ + u64 ans = 0, q = 0; + s64 i; + + /*for (i = sizeof(n) * 8 - 2; i > -1; i = i - 2) {*/ + for (i = 8 * 8 - 2; i > -1; i = i - 2) { + q = (q << 2) | ((n & (3 << i)) >> i); + if (q >= ((ans << 2) | 1)) + { + q = q - ((ans << 2) | 1); + ans = (ans << 1) | 1; + } + else + ans = ans << 1; + } + DbgPrint("ans=0x%x\n", ans); + + return (u32)ans; +} +#endif + + + +u64 _sqrt(u64 x) +{ + u64 i = 0; + u64 j = x / 2 + 1; + + while (i <= j) { + u64 mid = (i + j) / 2; + + u64 sq = mid * mid; + + if (sq == x) + return mid; + else if (sq < x) + i = mid + 1; + else + j = mid - 1; + } + + return j; +} + + + +u32 +halrf_get_psd_data( + void *p_dm_void, + u32 point + ) +{ + struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; + struct _hal_rf_ *p_rf = &(p_dm->rf_table); + struct _halrf_psd_data *p_psd = &(p_rf->halrf_psd_data); + u32 psd_val = 0, psd_reg, psd_report, psd_point, psd_start, i, delay_time; + +#if (DEV_BUS_TYPE == RT_USB_INTERFACE) || (DEV_BUS_TYPE == RT_SDIO_INTERFACE) + if (p_psd->average == 0) + delay_time = 100; + else + delay_time = 0; +#else + if (p_psd->average == 0) + delay_time = 1000; + else + delay_time = 100; +#endif + + if (p_dm->support_ic_type & (ODM_RTL8812 | ODM_RTL8821 | ODM_RTL8814A | ODM_RTL8822B | ODM_RTL8821C)) { + psd_reg = 0x910; + psd_report = 0xf44; + } else { + psd_reg = 0x808; + psd_report = 0x8b4; + } + + if (p_dm->support_ic_type & ODM_RTL8710B) { + psd_point = 0xeffffc00; + psd_start = 0x10000000; + } else { + psd_point = 0xffbffc00; + psd_start = 0x00400000; + } + + psd_val = odm_get_bb_reg(p_dm, psd_reg, MASKDWORD); + + psd_val &= psd_point; + psd_val |= point; + + odm_set_bb_reg(p_dm, psd_reg, MASKDWORD, psd_val); + + psd_val |= psd_start; + + odm_set_bb_reg(p_dm, psd_reg, MASKDWORD, psd_val); + + for (i = 0; i < delay_time; i++) + ODM_delay_us(1); + + psd_val = odm_get_bb_reg(p_dm, psd_report, MASKDWORD); + + if (p_dm->support_ic_type & (ODM_RTL8821C | ODM_RTL8710B)) { + psd_val &= MASKL3BYTES; + psd_val = psd_val / 32; + } else + psd_val &= MASKLWORD; + + return psd_val; +} + + + +void +halrf_psd( + void *p_dm_void, + u32 point, + u32 start_point, + u32 stop_point, + u32 average + ) +{ + struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; + struct _hal_rf_ *p_rf = &(p_dm->rf_table); + struct _halrf_psd_data *p_psd = &(p_rf->halrf_psd_data); + + u32 i = 0, j = 0, k = 0; + u32 psd_reg, avg_org, point_temp, average_tmp; + u64 data_tatal = 0, data_temp[64] = {0}; + + p_psd->buf_size = 256; + + if (average == 0) + average_tmp = 1; + else + average_tmp = average; + + if (p_dm->support_ic_type & (ODM_RTL8812 | ODM_RTL8821 | ODM_RTL8814A | ODM_RTL8822B | ODM_RTL8821C)) + psd_reg = 0x910; + else + psd_reg = 0x808; + +#if 0 + dbg_print("[PSD]point=%d, start_point=%d, stop_point=%d, average=%d, average_tmp=%d, buf_size=%d\n", + point, start_point, stop_point, average, average_tmp, p_psd->buf_size); +#endif + + for (i = 0; i < p_psd->buf_size; i++) + p_psd->psd_data[i] = 0; + + if (p_dm->support_ic_type & ODM_RTL8710B) + avg_org = odm_get_bb_reg(p_dm, psd_reg, 0x30000); + else + avg_org = odm_get_bb_reg(p_dm, psd_reg, 0x3000); + + if (average != 0) + { + if (p_dm->support_ic_type & ODM_RTL8710B) + odm_set_bb_reg(p_dm, psd_reg, 0x30000, 0x1); + else + odm_set_bb_reg(p_dm, psd_reg, 0x3000, 0x1); + } + +#if 0 + if (avg_temp == 0) + avg = 1; + else if (avg_temp == 1) + avg = 8; + else if (avg_temp == 2) + avg = 16; + else if (avg_temp == 3) + avg = 32; +#endif + + i = start_point; + while (i < stop_point) { + data_tatal = 0; + + if (i >= point) + point_temp = i - point; + else + point_temp = i; + + for (k = 0; k < average_tmp; k++) { + data_temp[k] = halrf_get_psd_data(p_dm, point_temp); + data_tatal = data_tatal + (data_temp[k] * data_temp[k]); + +#if 0 + if ((k % 20) == 0) + dbg_print("\n "); + + dbg_print("0x%x ", data_temp[k]); +#endif + } + /*dbg_print("\n");*/ + + data_tatal = ((data_tatal * 100) / average_tmp); + p_psd->psd_data[j] = (u32)_sqrt(data_tatal); + + i++; + j++; + } + +#if 0 + for (i = 0; i < p_psd->buf_size; i++) { + if ((i % 20) == 0) + dbg_print("\n "); + + dbg_print("0x%x ", p_psd->psd_data[i]); + } + dbg_print("\n\n"); +#endif + + if (p_dm->support_ic_type & ODM_RTL8710B) + odm_set_bb_reg(p_dm, psd_reg, 0x30000, avg_org); + else + odm_set_bb_reg(p_dm, psd_reg, 0x3000, avg_org); +} + + + +enum rt_status +halrf_psd_init( + void *p_dm_void + ) +{ + enum rt_status ret_status = RT_STATUS_SUCCESS; + struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; + struct _hal_rf_ *p_rf = &(p_dm->rf_table); + struct _halrf_psd_data *p_psd = &(p_rf->halrf_psd_data); + + if (p_psd->psd_progress) + ret_status = RT_STATUS_PENDING; + else { + p_psd->psd_progress = 1; + halrf_psd(p_dm, p_psd->point, p_psd->start_point, p_psd->stop_point, p_psd->average); + p_psd->psd_progress = 0; + } + + return ret_status; +} + + + +enum rt_status +halrf_psd_query( + void *p_dm_void, + u32 *outbuf, + u32 buf_size + ) +{ + enum rt_status ret_status = RT_STATUS_SUCCESS; + struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; + struct _hal_rf_ *p_rf = &(p_dm->rf_table); + struct _halrf_psd_data *p_psd = &(p_rf->halrf_psd_data); + + if (p_psd->psd_progress) + ret_status = RT_STATUS_PENDING; + else + PlatformMoveMemory(outbuf, p_psd->psd_data, 0x400); + + return ret_status; +} + + + +enum rt_status +halrf_psd_init_query( + void *p_dm_void, + u32 *outbuf, + u32 point, + u32 start_point, + u32 stop_point, + u32 average, + u32 buf_size + ) +{ + enum rt_status ret_status = RT_STATUS_SUCCESS; + struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; + struct _hal_rf_ *p_rf = &(p_dm->rf_table); + struct _halrf_psd_data *p_psd = &(p_rf->halrf_psd_data); + + p_psd->point = point; + p_psd->start_point = start_point; + p_psd->stop_point = stop_point; + p_psd->average = average; + + if (p_psd->psd_progress) + ret_status = RT_STATUS_PENDING; + else { + p_psd->psd_progress = 1; + halrf_psd(p_dm, p_psd->point, p_psd->start_point, p_psd->stop_point, p_psd->average); + PlatformMoveMemory(outbuf, p_psd->psd_data, 0x400); + p_psd->psd_progress = 0; + } + + return ret_status; +} + + + +#endif /*#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)*/ + diff --git a/hal/phydm/halrf/halrf_psd.h b/hal/phydm/halrf/halrf_psd.h new file mode 100644 index 0000000..3c5f9ed --- /dev/null +++ b/hal/phydm/halrf/halrf_psd.h @@ -0,0 +1,60 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2017 Realtek Corporation. + * + * 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. + * + *****************************************************************************/ + +#ifndef __HALRF_PSD_H__ +#define __HALRF_PSD_H__ + +#if (DM_ODM_SUPPORT_TYPE & ODM_WIN) + +struct _halrf_psd_data { + u32 point; + u32 start_point; + u32 stop_point; + u32 average; + u32 buf_size; + u32 psd_data[256]; + u32 psd_progress; +}; + + + +enum rt_status +halrf_psd_init ( + void *p_dm_void + ); + + + +enum rt_status +halrf_psd_query ( + void *p_dm_void, + u32 *outbuf, + u32 buf_size +); + +enum rt_status +halrf_psd_init_query( + void *p_dm_void, + u32 *outbuf, + u32 point, + u32 start_point, + u32 stop_point, + u32 average, + u32 buf_size +); + +#endif /*#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)*/ +#endif /*#ifndef __HALRF_PSD_H__*/ + diff --git a/hal/phydm/halrf/rtl8812a/halrf_8812a_ce.c b/hal/phydm/halrf/rtl8812a/halrf_8812a_ce.c index 9aadf9f..95acaf0 100644 --- a/hal/phydm/halrf/rtl8812a/halrf_8812a_ce.c +++ b/hal/phydm/halrf/rtl8812a/halrf_8812a_ce.c @@ -114,7 +114,7 @@ odm_tx_pwr_track_set_pwr8812a( u8 final_cck_swing_index = 0; u8 i = 0; struct odm_rf_calibration_structure *p_rf_calibrate_info = &(p_dm->rf_calibrate_info); - struct _hal_rf_ *p_rf = &(p_dm->rf_table); + struct _hal_rf_ *p_rf = &(p_dm->rf_table); if (*(p_dm->p_mp_mode) == true) { #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE)) @@ -328,7 +328,7 @@ get_delta_swing_table_8812a( struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; struct _ADAPTER *adapter = p_dm->adapter; struct odm_rf_calibration_structure *p_rf_calibrate_info = &(p_dm->rf_calibrate_info); - struct _hal_rf_ *p_rf = &(p_dm->rf_table); + struct _hal_rf_ *p_rf = &(p_dm->rf_table); HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(adapter); u8 tx_rate = 0xFF; u8 channel = *p_dm->p_channel; @@ -442,6 +442,10 @@ void _iqk_rx_fill_iqc_8812a( odm_set_bb_reg(p_dm, 0xc10, 0x03ff0000, 0); ODM_RT_TRACE(p_dm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("RX_X = %x;;RX_Y = %x ====>fill to IQC\n", RX_X >> 1 & 0x000003ff, RX_Y >> 1 & 0x000003ff)); } else { + if (RX_X >= 0x20c) + RX_X = 0x20c; + else if (RX_X <= 0x1f4) + RX_X = 0x1f4; odm_set_bb_reg(p_dm, 0xc10, 0x000003ff, RX_X >> 1); odm_set_bb_reg(p_dm, 0xc10, 0x03ff0000, RX_Y >> 1); ODM_RT_TRACE(p_dm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("RX_X = %x;;RX_Y = %x ====>fill to IQC\n", RX_X >> 1 & 0x000003ff, RX_Y >> 1 & 0x000003ff)); @@ -457,6 +461,10 @@ void _iqk_rx_fill_iqc_8812a( odm_set_bb_reg(p_dm, 0xe10, 0x03ff0000, 0); ODM_RT_TRACE(p_dm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("RX_X = %x;;RX_Y = %x ====>fill to IQC\n", RX_X >> 1 & 0x000003ff, RX_Y >> 1 & 0x000003ff)); } else { + if (RX_X >= 0x20c) + RX_X = 0x20c; + else if (RX_X <= 0x1f4) + RX_X = 0x1f4; odm_set_bb_reg(p_dm, 0xe10, 0x000003ff, RX_X >> 1); odm_set_bb_reg(p_dm, 0xe10, 0x03ff0000, RX_Y >> 1); ODM_RT_TRACE(p_dm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("RX_X = %x;;RX_Y = %x====>fill to IQC\n ", RX_X >> 1 & 0x000003ff, RX_Y >> 1 & 0x000003ff)); @@ -958,7 +966,8 @@ void _iqk_tx_8812a( odm_set_bb_reg(p_dm, 0x978, 0x03FF8000, (TX_IQC[0]) & 0x000007ff); odm_set_bb_reg(p_dm, 0x978, 0x000007FF, (TX_IQC[1]) & 0x000007ff); odm_set_bb_reg(p_dm, 0x82c, BIT(31), 0x1); /* [31] = 1 --> Page C1 */ - if (p_dm->rfe_type == 1) + /*pathA RXIQK gain setting*/ + if ((p_dm->rfe_type == 1) && (p_dm->ext_pa_5g)) odm_write_4byte(p_dm, 0xc8c, 0x28161500); else odm_write_4byte(p_dm, 0xc8c, 0x28160cc0); @@ -973,7 +982,8 @@ void _iqk_tx_8812a( odm_set_bb_reg(p_dm, 0x978, 0x03FF8000, (TX_IQC[2]) & 0x000007ff); odm_set_bb_reg(p_dm, 0x978, 0x000007FF, (TX_IQC[3]) & 0x000007ff); odm_set_bb_reg(p_dm, 0x82c, BIT(31), 0x1); /* [31] = 1 --> Page C1 */ - if (p_dm->rfe_type == 1) + /*pathB RXIQK gain setting*/ + if ((p_dm->rfe_type == 1) && (p_dm->ext_pa_5g)) odm_write_4byte(p_dm, 0xe8c, 0x28161500); else odm_write_4byte(p_dm, 0xe8c, 0x28160ca0); @@ -1340,6 +1350,9 @@ _phy_iq_calibrate_by_fw_8812a( // rtl8812_iqk_wait(p_adapter, 500); } +/*IQK version:0x2*/ +/*1. add RX IQK boundary*/ +/*2. fine tune RXIQK loop gain*/ void phy_iq_calibrate_8812a( void *p_dm_void, @@ -1371,7 +1384,7 @@ phy_lc_calibrate_8812a( } void _phy_set_rf_path_switch_8812a( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) +#if ((DM_ODM_SUPPORT_TYPE & ODM_AP) || (DM_ODM_SUPPORT_TYPE == ODM_CE)) struct PHY_DM_STRUCT *p_dm, #else struct _ADAPTER *p_adapter, @@ -1381,13 +1394,13 @@ void _phy_set_rf_path_switch_8812a( ) { #if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(p_adapter); #if (DM_ODM_SUPPORT_TYPE == ODM_CE) - struct PHY_DM_STRUCT *p_dm = &p_hal_data->odmpriv; -#elif (DM_ODM_SUPPORT_TYPE == ODM_WIN) + struct _ADAPTER *p_adapter = p_dm->adapter; +#endif + HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(p_adapter); +#if (DM_ODM_SUPPORT_TYPE == ODM_WIN) struct PHY_DM_STRUCT *p_dm = &p_hal_data->DM_OutSrc; #endif - #endif if (IS_HARDWARE_TYPE_8821(p_adapter)) { @@ -1412,7 +1425,7 @@ void _phy_set_rf_path_switch_8812a( } void phy_set_rf_path_switch_8812a( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) +#if ((DM_ODM_SUPPORT_TYPE & ODM_AP) || (DM_ODM_SUPPORT_TYPE == ODM_CE)) struct PHY_DM_STRUCT *p_dm, #else struct _ADAPTER *p_adapter, @@ -1426,9 +1439,11 @@ void phy_set_rf_path_switch_8812a( #endif #if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - +#if (DM_ODM_SUPPORT_TYPE == ODM_CE) + _phy_set_rf_path_switch_8812a(p_dm, is_main, true); +#else _phy_set_rf_path_switch_8812a(p_adapter, is_main, true); - +#endif #endif } diff --git a/hal/phydm/halrf/rtl8812a/halrf_8812a_ce.h b/hal/phydm/halrf/rtl8812a/halrf_8812a_ce.h index 7176ca5..386798c 100644 --- a/hal/phydm/halrf/rtl8812a/halrf_8812a_ce.h +++ b/hal/phydm/halrf/rtl8812a/halrf_8812a_ce.h @@ -87,7 +87,7 @@ halrf_rf_lna_setting_8812a( void phy_set_rf_path_switch_8812a( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) +#if ((DM_ODM_SUPPORT_TYPE & ODM_AP) || (DM_ODM_SUPPORT_TYPE == ODM_CE)) struct PHY_DM_STRUCT *p_dm, #else struct _ADAPTER *p_adapter, diff --git a/hal/phydm/halrf/rtl8812a/halrf_8812a_win.c b/hal/phydm/halrf/rtl8812a/halrf_8812a_win.c index 2e6a2bb..21f13ba 100644 --- a/hal/phydm/halrf/rtl8812a/halrf_8812a_win.c +++ b/hal/phydm/halrf/rtl8812a/halrf_8812a_win.c @@ -438,6 +438,10 @@ void _iqk_rx_fill_iqc_8812a( odm_set_bb_reg(p_dm, 0xc10, 0x03ff0000, 0); ODM_RT_TRACE(p_dm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("RX_X = %x;;RX_Y = %x ====>fill to IQC\n", RX_X >> 1 & 0x000003ff, RX_Y >> 1 & 0x000003ff)); } else { + if (RX_X >= 0x20c) + RX_X = 0x20c; + else if (RX_X <= 0x1f4) + RX_X = 0x1f4; odm_set_bb_reg(p_dm, 0xc10, 0x000003ff, RX_X >> 1); odm_set_bb_reg(p_dm, 0xc10, 0x03ff0000, RX_Y >> 1); ODM_RT_TRACE(p_dm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("RX_X = %x;;RX_Y = %x ====>fill to IQC\n", RX_X >> 1 & 0x000003ff, RX_Y >> 1 & 0x000003ff)); @@ -453,6 +457,10 @@ void _iqk_rx_fill_iqc_8812a( odm_set_bb_reg(p_dm, 0xe10, 0x03ff0000, 0); ODM_RT_TRACE(p_dm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("RX_X = %x;;RX_Y = %x ====>fill to IQC\n", RX_X >> 1 & 0x000003ff, RX_Y >> 1 & 0x000003ff)); } else { + if (RX_X >= 0x20c) + RX_X = 0x20c; + else if (RX_X <= 0x1f4) + RX_X = 0x1f4; odm_set_bb_reg(p_dm, 0xe10, 0x000003ff, RX_X >> 1); odm_set_bb_reg(p_dm, 0xe10, 0x03ff0000, RX_Y >> 1); ODM_RT_TRACE(p_dm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("RX_X = %x;;RX_Y = %x====>fill to IQC\n ", RX_X >> 1 & 0x000003ff, RX_Y >> 1 & 0x000003ff)); @@ -947,7 +955,8 @@ void _iqk_tx_8812a( odm_set_bb_reg(p_dm, 0x978, 0x03FF8000, (TX_IQC[0]) & 0x000007ff); odm_set_bb_reg(p_dm, 0x978, 0x000007FF, (TX_IQC[1]) & 0x000007ff); odm_set_bb_reg(p_dm, 0x82c, BIT(31), 0x1); /* [31] = 1 --> Page C1 */ - if (p_dm->rfe_type == 1) + /*pathA RXIQK gain setting*/ + if ((p_dm->rfe_type == 1) && (p_dm->ext_pa_5g)) odm_write_4byte(p_dm, 0xc8c, 0x28161500); else odm_write_4byte(p_dm, 0xc8c, 0x28160cc0); @@ -962,7 +971,8 @@ void _iqk_tx_8812a( odm_set_bb_reg(p_dm, 0x978, 0x03FF8000, (TX_IQC[2]) & 0x000007ff); odm_set_bb_reg(p_dm, 0x978, 0x000007FF, (TX_IQC[3]) & 0x000007ff); odm_set_bb_reg(p_dm, 0x82c, BIT(31), 0x1); /* [31] = 1 --> Page C1 */ - if (p_dm->rfe_type == 1) + /*pathB RXIQK gain setting*/ + if ((p_dm->rfe_type == 1) && (p_dm->ext_pa_5g)) odm_write_4byte(p_dm, 0xe8c, 0x28161500); else odm_write_4byte(p_dm, 0xe8c, 0x28160ca0); @@ -1343,6 +1353,10 @@ _phy_iq_calibrate_by_fw_8812a( odm_fill_h2c_cmd(p_dm, ODM_H2C_IQ_CALIBRATION, 3, iqk_cmd); } +/*IQK version:0x2*/ +/*1. add RX IQK boundary*/ +/*2. fine tune RXIQK loop gain*/ + void phy_iq_calibrate_8812a( void *p_dm_void, diff --git a/hal/phydm/phydm.c b/hal/phydm/phydm.c index 63a1194..cc7ba31 100644 --- a/hal/phydm/phydm.c +++ b/hal/phydm/phydm.c @@ -476,7 +476,7 @@ phydm_supportability_init_win( /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR | + /*ODM_BB_ENV_MONITOR |*/ ODM_BB_PRIMARY_CCA; break; #endif @@ -493,7 +493,7 @@ phydm_supportability_init_win( /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR | + /*ODM_BB_ENV_MONITOR |*/ ODM_BB_PRIMARY_CCA; break; #endif @@ -510,7 +510,7 @@ phydm_supportability_init_win( /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR | + /*ODM_BB_ENV_MONITOR |*/ ODM_BB_PRIMARY_CCA; break; #endif @@ -526,8 +526,8 @@ phydm_supportability_init_win( ODM_BB_CCK_PD | /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | - ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR; + ODM_BB_CFO_TRACKING; + /*ODM_BB_ENV_MONITOR;*/ break; #endif @@ -542,8 +542,8 @@ phydm_supportability_init_win( ODM_BB_CCK_PD | /* ODM_BB_PWR_TRAIN | */ ODM_BB_RATE_ADAPTIVE | - ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR; + ODM_BB_CFO_TRACKING; + /*ODM_BB_ENV_MONITOR;*/ break; #endif @@ -558,8 +558,8 @@ phydm_supportability_init_win( ODM_BB_CCK_PD | /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | - ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR; + ODM_BB_CFO_TRACKING; + /*ODM_BB_ENV_MONITOR;*/ break; #endif @@ -574,8 +574,8 @@ phydm_supportability_init_win( ODM_BB_CCK_PD | /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | - ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR; + ODM_BB_CFO_TRACKING; + /*ODM_BB_ENV_MONITOR;*/ break; #endif @@ -593,8 +593,8 @@ phydm_supportability_init_win( ODM_BB_CCK_PD | /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | - ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR; + ODM_BB_CFO_TRACKING; + /*ODM_BB_ENV_MONITOR;*/ break; #endif @@ -609,8 +609,8 @@ phydm_supportability_init_win( ODM_BB_CCK_PD | /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | - ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR; + ODM_BB_CFO_TRACKING; + /*ODM_BB_ENV_MONITOR;*/ break; #endif @@ -625,8 +625,8 @@ phydm_supportability_init_win( ODM_BB_CCK_PD | /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | - ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR; + ODM_BB_CFO_TRACKING; + /*ODM_BB_ENV_MONITOR;*/ break; #endif @@ -642,7 +642,7 @@ phydm_supportability_init_win( /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR | + /*ODM_BB_ENV_MONITOR |*/ ODM_BB_ADAPTIVE_SOML; break; #endif @@ -658,8 +658,8 @@ phydm_supportability_init_win( ODM_BB_CCK_PD | /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | - ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR; + ODM_BB_CFO_TRACKING; + /*ODM_BB_ENV_MONITOR;*/ break; #endif @@ -673,22 +673,14 @@ phydm_supportability_init_win( ODM_BB_CCK_PD | /*ODM_BB_PWR_TRAIN |*/ ODM_BB_RATE_ADAPTIVE | - ODM_BB_CFO_TRACKING | - ODM_BB_ENV_MONITOR; + ODM_BB_CFO_TRACKING; + /*ODM_BB_ENV_MONITOR;*/ dbg_print("[Warning] Supportability Init Warning !!!\n"); break; } - /*[Config Antenna Diveristy]*/ - if (*(p_dm->p_enable_antdiv)) - support_ability |= ODM_BB_ANT_DIV; - - /*[Config Adaptivity]*/ - if (*(p_dm->p_enable_adaptivity)) - support_ability |= ODM_BB_ADAPTIVITY; - return support_ability; } #endif @@ -920,15 +912,7 @@ phydm_supportability_init_ce( break; } - - /*[Config Antenna Diveristy]*/ - if (*(p_dm->p_enable_antdiv)) - support_ability |= ODM_BB_ANT_DIV; - - /*[Config Adaptivity]*/ - if (*(p_dm->p_enable_adaptivity)) - support_ability |= ODM_BB_ADAPTIVITY; - + return support_ability; } #endif @@ -1181,15 +1165,7 @@ phydm_supportability_init_iot( break; } - - /*[Config Antenna Diveristy]*/ - if (*(p_dm->p_enable_antdiv)) - support_ability |= ODM_BB_ANT_DIV; - - /*[Config Adaptivity]*/ - if (*(p_dm->p_enable_adaptivity)) - support_ability |= ODM_BB_ADAPTIVITY; - + return support_ability; } #endif @@ -1274,6 +1250,18 @@ phydm_supportability_init( #elif(DM_ODM_SUPPORT_TYPE & (ODM_IOT)) support_ability = phydm_supportability_init_iot(p_dm); #endif + + /*[Config Antenna Diveristy]*/ + if (IS_FUNC_EN(p_dm->p_enable_antdiv)) + support_ability |= ODM_BB_ANT_DIV; + + /*[Config Adaptive SOML]*/ + if (IS_FUNC_EN(p_dm->en_adap_soml)) + support_ability |= ODM_BB_ADAPTIVE_SOML; + + /*[Config Adaptivity]*/ + if (IS_FUNC_EN(p_dm->p_enable_adaptivity)) + support_ability |= ODM_BB_ADAPTIVITY; } odm_cmn_info_init(p_dm, ODM_CMNINFO_ABILITY, support_ability); PHYDM_DBG(p_dm, ODM_COMP_INIT, ("IC = ((0x%x)), Supportability Init = ((0x%llx))\n", p_dm->support_ic_type, p_dm->support_ability)); @@ -2129,6 +2117,9 @@ odm_cmn_info_hook( case ODM_CMNINFO_ANT_DIV: p_dm->p_enable_antdiv = (u8 *)p_value; break; + case ODM_CMNINFO_ADAPTIVE_SOML: + p_dm->en_adap_soml = (u8 *)p_value; + break; case ODM_CMNINFO_ADAPTIVITY: p_dm->p_enable_adaptivity = (u8 *)p_value; break; diff --git a/hal/phydm/phydm.h b/hal/phydm/phydm.h index e7abfb3..cb0f77c 100644 --- a/hal/phydm/phydm.h +++ b/hal/phydm/phydm.h @@ -80,12 +80,16 @@ extern const u16 phy_rate_table[28]; #define MAX_2(_x_, _y_) (((_x_)>(_y_))? (_x_) : (_y_)) #define MIN_2(_x_, _y_) (((_x_)<(_y_))? (_x_) : (_y_)) +#define IS_FUNC_EN(name) ((name) && (*name)) + #if (DM_ODM_SUPPORT_TYPE == ODM_AP) #define PHYDM_WATCH_DOG_PERIOD 1 /*second*/ #else #define PHYDM_WATCH_DOG_PERIOD 2 /*second*/ #endif +#define PHY_HIST_SIZE 12 + /*============================================================*/ /*structure and define*/ /*============================================================*/ @@ -103,17 +107,23 @@ struct phydm_phystatus_statistic { u32 rssi_ofdm_cnt; u32 evm_ofdm_sum; u32 snr_ofdm_sum; + u16 evm_ofdm_hist[PHY_HIST_SIZE]; + u16 snr_ofdm_hist[PHY_HIST_SIZE]; /*[1SS]*/ u32 rssi_1ss_cnt; u32 rssi_1ss_sum; u32 evm_1ss_sum; u32 snr_1ss_sum; + u16 evm_1ss_hist[PHY_HIST_SIZE]; + u16 snr_1ss_hist[PHY_HIST_SIZE]; /*[2SS]*/ #if (defined(PHYDM_COMPILE_ABOVE_2SS)) u32 rssi_2ss_cnt; u32 rssi_2ss_sum[2]; u32 evm_2ss_sum[2]; u32 snr_2ss_sum[2]; + u16 evm_2ss_hist[2][PHY_HIST_SIZE]; + u16 snr_2ss_hist[2][PHY_HIST_SIZE]; #endif /*[3SS]*/ #if (defined(PHYDM_COMPILE_ABOVE_3SS)) @@ -121,6 +131,8 @@ struct phydm_phystatus_statistic { u32 rssi_3ss_sum[3]; u32 evm_3ss_sum[3]; u32 snr_3ss_sum[3]; + u16 evm_3ss_hist[3][PHY_HIST_SIZE]; + u16 snr_3ss_hist[3][PHY_HIST_SIZE]; #endif /*[4SS]*/ #if (defined(PHYDM_COMPILE_ABOVE_4SS)) @@ -128,6 +140,8 @@ struct phydm_phystatus_statistic { u32 rssi_4ss_sum[4]; u32 evm_4ss_sum[4]; u32 snr_4ss_sum[4]; + u16 evm_4ss_hist[4][PHY_HIST_SIZE]; + u16 snr_4ss_hist[4][PHY_HIST_SIZE]; #endif }; @@ -189,6 +203,8 @@ struct _odm_phy_dbg_info_ { u16 num_qry_vht_pkt[VHT_RATE_NUM]; u8 vht_pkt_not_zero; #endif + u16 snr_hist_th[PHY_HIST_SIZE - 1]; + u16 evm_hist_th[PHY_HIST_SIZE - 1]; struct phydm_phystatus_statistic phystatus_statistic_info; struct phydm_phystatus_avg phystatus_statistic_avg; }; @@ -253,6 +269,7 @@ enum odm_cmninfo_e { ODM_CMNINFO_CHNL, ODM_CMNINFO_FORCED_RATE, ODM_CMNINFO_ANT_DIV, + ODM_CMNINFO_ADAPTIVE_SOML, ODM_CMNINFO_ADAPTIVITY, ODM_CMNINFO_SCAN, ODM_CMNINFO_POWER_SAVING, @@ -616,6 +633,7 @@ struct phydm_iot_center { u16 *p_forced_data_rate; u8 *p_enable_antdiv; + u8 *en_adap_soml; u8 *p_enable_adaptivity; u8 *hub_usb_mode; /*1: USB 2.0, 2: USB 3.0*/ boolean *p_is_fw_dw_rsvd_page_in_progress; @@ -722,6 +740,8 @@ struct phydm_iot_center { u8 path_select; u8 antdiv_evm_en; u8 bdc_holdstate; + u8 antdiv_counter; + /*---------------------------*/ u8 ndpa_period; diff --git a/hal/phydm/phydm.mk b/hal/phydm/phydm.mk index 15bdad8..4f3b22b 100644 --- a/hal/phydm/phydm.mk +++ b/hal/phydm/phydm.mk @@ -109,6 +109,15 @@ _PHYDM_FILES += hal/phydm/$(RTL871X)/halhwimg8814a_bb.o\ hal/phydm/txbf/haltxbf8814a.o endif +ifeq ($(CONFIG_RTL8710B), y) +RTL871X = rtl8710b +_PHYDM_FILES += hal/phydm/$(RTL871X)/halhwimg8710b_bb.o\ + hal/phydm/$(RTL871X)/halhwimg8710b_mac.o\ + hal/phydm/$(RTL871X)/halhwimg8710b_rf.o\ + hal/phydm/$(RTL871X)/phydm_regconfig8710b.o\ + hal/phydm/$(RTL871X)/phydm_rtl8710b.o\ + hal/phydm/halrf/$(RTL871X)/halrf_8710b.o +endif ifeq ($(CONFIG_RTL8723C), y) RTL871X = rtl8703b diff --git a/hal/phydm/phydm_antdiv.c b/hal/phydm/phydm_antdiv.c index b11390b..60399d4 100644 --- a/hal/phydm/phydm_antdiv.c +++ b/hal/phydm/phydm_antdiv.c @@ -1190,6 +1190,43 @@ odm_trx_hw_ant_div_init_8723d( } /*Mingzhi 2017-05-08*/ +void +odm_s0s1_sw_ant_div_init_8723d( + void *p_dm_void +) +{ + struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; + struct _sw_antenna_switch_ *p_dm_swat_table = &p_dm->dm_swat_table; + struct phydm_fat_struct *p_dm_fat_table = &p_dm->dm_fat_table; + + PHYDM_DBG(p_dm, DBG_ANT_DIV, ("***8723D AntDiv_Init => ant_div_type=[ S0S1_SW_AntDiv]\n")); + + /*keep antsel_map when GNT_BT = 1*/ + odm_set_bb_reg(p_dm, 0x864, BIT(12), 1); + + /* Disable antsw when GNT_BT=1 */ + odm_set_bb_reg(p_dm, 0x874, BIT(23), 0); + + /* Mapping Table */ + odm_set_bb_reg(p_dm, 0x914, MASKBYTE0, 0); + odm_set_bb_reg(p_dm, 0x914, MASKBYTE1, 1); + + /* Output Pin Settings */ + /* odm_set_bb_reg(p_dm, R_0x948, BIT6, 0x1); */ + odm_set_bb_reg(p_dm, 0x870, BIT(8), 1); + odm_set_bb_reg(p_dm, 0x870, BIT(9), 1); + + p_dm_fat_table->is_become_linked = false; + p_dm_swat_table->try_flag = SWAW_STEP_INIT; + p_dm_swat_table->double_chk_flag = 0; + p_dm_swat_table->cur_antenna = MAIN_ANT; + p_dm_swat_table->pre_antenna = MAIN_ANT; + p_dm->antdiv_counter = CONFIG_ANTENNA_DIVERSITY_PERIOD; + + /* 2 [--For HW Bug setting] */ + odm_set_bb_reg(p_dm, 0x80c, BIT(21), 0); /* TX ant by Reg */ +} + void odm_update_rx_idle_ant_8723d( void *p_dm_void, @@ -1203,13 +1240,28 @@ odm_update_rx_idle_ant_8723d( struct _ADAPTER *p_adapter = p_dm->adapter; u8 count = 0; +#if (DM_ODM_SUPPORT_TYPE & (ODM_CE)) + /*score board to BT ,a002:WL to do ant-div*/ + odm_set_mac_reg(p_dm, 0xa8, MASKHWORD, 0xa002); + ODM_delay_us(50); +#endif /* odm_set_bb_reg(p_dm, 0x948, BIT(6), 0x1); */ - odm_set_bb_reg(p_dm, 0x948, BIT(7), default_ant); + if (p_dm->ant_div_type == S0S1_SW_ANTDIV) { + odm_set_bb_reg(p_dm, 0x860, BIT(8), default_ant); + odm_set_bb_reg(p_dm, 0x860, BIT(9), default_ant); + } odm_set_bb_reg(p_dm, 0x864, BIT(5) | BIT(4) | BIT(3), default_ant); /*Default RX*/ odm_set_bb_reg(p_dm, 0x864, BIT(8) | BIT(7) | BIT(6), optional_ant); /*Optional RX*/ odm_set_bb_reg(p_dm, 0x860, BIT(14) | BIT(13) | BIT(12), default_ant); /*Default TX*/ p_dm_fat_table->rx_idle_ant = ant; +#if (DM_ODM_SUPPORT_TYPE & (ODM_CE)) + /*score board to BT ,a000:WL@S1 a001:WL@S0*/ + if (default_ant == ANT1_2G) + odm_set_mac_reg(p_dm, 0xa8, MASKHWORD, 0xa000); + else + odm_set_mac_reg(p_dm, 0xa8, MASKHWORD, 0xa001); +#endif } @@ -2557,6 +2609,16 @@ odm_s0s1_sw_ant_div( PHYDM_DBG(p_dm, DBG_ANT_DIV, ("8723B: First link! Force antenna to %s\n", (value32 == 0x0 ? "MAIN" : "AUX"))); } + if (p_dm->support_ic_type == ODM_RTL8723D) { + value32 = odm_get_bb_reg(p_dm, 0x864, BIT(5) | BIT(4) | BIT(3)); +#if (RTL8723D_SUPPORT == 1) + if (value32 == 0x0) + odm_update_rx_idle_ant_8723d(p_dm, MAIN_ANT, ANT1_2G, ANT2_2G); + else if (value32 == 0x1) + odm_update_rx_idle_ant_8723d(p_dm, AUX_ANT, ANT2_2G, ANT1_2G); +#endif + PHYDM_DBG(p_dm, DBG_ANT_DIV, ("8723D: First link! Force antenna to %s\n", (value32 == 0x0 ? "MAIN" : "AUX"))); + } p_dm_fat_table->is_become_linked = p_dm->is_linked; } } @@ -2699,7 +2761,7 @@ odm_s0s1_sw_ant_div( p_dm_swat_table->rssi_trying = 0; PHYDM_DBG(p_dm, DBG_ANT_DIV, ("Test the current ant for (( %d )) ms again\n", p_dm_swat_table->train_time)); - odm_update_rx_idle_ant(p_dm, p_dm_fat_table->rx_idle_ant); + odm_update_rx_idle_ant(p_dm, p_dm_fat_table->rx_idle_ant); odm_set_timer(p_dm, &(p_dm_swat_table->phydm_sw_antenna_switch_timer), p_dm_swat_table->train_time); /*ms*/ return; } @@ -2732,7 +2794,7 @@ odm_s0s1_sw_ant_div( p_entry = p_dm->p_phydm_sta_info[i]; if (is_sta_active(p_entry)) { /* 2 Caculate RSSI per Antenna */ - + /* main_ant_sum = (u32)p_dm_fat_table->main_ant_sum[i] + (u32)p_dm_fat_table->main_ant_sum_cck[i]; aux_ant_sum = (u32)p_dm_fat_table->aux_ant_sum[i] + (u32)p_dm_fat_table->aux_ant_sum_cck[i]; main_ant_cnt = (u32)p_dm_fat_table->main_ant_cnt[i] + (u32)p_dm_fat_table->main_ant_cnt_cck[i]; @@ -2745,9 +2807,41 @@ odm_s0s1_sw_ant_div( main_rssi = 0; if (p_dm_fat_table->aux_ant_cnt[i] <= 1 && p_dm_fat_table->aux_ant_cnt_cck[i] >= 1) - aux_rssi = 0; - - target_ant = (main_rssi == aux_rssi) ? p_dm_swat_table->pre_antenna : ((main_rssi >= aux_rssi) ? MAIN_ANT : AUX_ANT); + aux_rssi = 0;*/ + if ((p_dm_fat_table->main_ant_cnt[i] != 0) || (p_dm_fat_table->aux_ant_cnt[i] != 0)) { + main_ant_cnt = (u32)p_dm_fat_table->main_ant_cnt[i]; + aux_ant_cnt = (u32)p_dm_fat_table->aux_ant_cnt[i]; + main_rssi = (main_ant_cnt != 0) ? (p_dm_fat_table->main_ant_sum[i] / main_ant_cnt) : 0; + aux_rssi = (aux_ant_cnt != 0) ? (p_dm_fat_table->aux_ant_sum[i] / aux_ant_cnt) : 0; + if (p_dm->support_ic_type == ODM_RTL8723D) { + if (p_dm_swat_table->pre_antenna == MAIN_ANT) { + if (main_ant_cnt == 0) { + target_ant = (aux_ant_cnt != 0) ? AUX_ANT : p_dm_swat_table->pre_antenna; + } else { + target_ant = ((aux_ant_cnt > main_ant_cnt) && ((main_rssi - aux_rssi < 5) || (aux_rssi > main_rssi))) ? AUX_ANT : p_dm_swat_table->pre_antenna; + } + } else { + if (aux_ant_cnt == 0) { + target_ant = (main_ant_cnt != 0) ? MAIN_ANT : p_dm_swat_table->pre_antenna; + } else { + target_ant = ((main_ant_cnt > aux_ant_cnt) && ((aux_rssi - main_rssi < 5) || (main_rssi > aux_rssi))) ? MAIN_ANT : p_dm_swat_table->pre_antenna; + } + } + } else { + if (p_dm_swat_table->pre_antenna == MAIN_ANT) { + target_ant = ((aux_ant_cnt > 20) && (aux_rssi >= main_rssi)) ? AUX_ANT : p_dm_swat_table->pre_antenna; + } else { + target_ant = ((main_ant_cnt > 20) && (main_rssi >= aux_rssi)) ? MAIN_ANT : p_dm_swat_table->pre_antenna; + } + } + } else { /*CCK only case*/ + main_ant_cnt = p_dm_fat_table->main_ant_cnt_cck[i]; + aux_ant_cnt = p_dm_fat_table->aux_ant_cnt_cck[i]; + main_rssi = (main_ant_cnt != 0) ? (p_dm_fat_table->main_ant_sum_cck[i] / main_ant_cnt) : 0; + aux_rssi = (aux_ant_cnt != 0) ? (p_dm_fat_table->aux_ant_sum_cck[i] / aux_ant_cnt) : 0; + target_ant = (main_rssi == aux_rssi) ? p_dm_fat_table->rx_idle_ant : ((main_rssi >= aux_rssi) ? MAIN_ANT : AUX_ANT); /*Use RSSI for CCK only case*/ + } + /*target_ant = (main_rssi == aux_rssi) ? p_dm_swat_table->pre_antenna : ((main_rssi >= aux_rssi) ? MAIN_ANT : AUX_ANT);*/ local_max_rssi = (main_rssi >= aux_rssi) ? main_rssi : aux_rssi; local_min_rssi = (main_rssi >= aux_rssi) ? aux_rssi : main_rssi; @@ -2885,6 +2979,20 @@ odm_s0s1_sw_ant_div( /* 1 5.Reset Statistics */ p_dm_fat_table->rx_idle_ant = next_ant; + + if (p_dm->support_ic_type == ODM_RTL8723D) { + if (p_dm_fat_table->rx_idle_ant == MAIN_ANT) { + p_dm_fat_table->main_ant_sum[0] = 0; + p_dm_fat_table->main_ant_cnt[0] = 0; + p_dm_fat_table->main_ant_sum_cck[0] = 0; + p_dm_fat_table->main_ant_cnt_cck[0] = 0; + } else { + p_dm_fat_table->aux_ant_sum[0] = 0; + p_dm_fat_table->aux_ant_cnt[0] = 0; + p_dm_fat_table->aux_ant_sum_cck[0] = 0; + p_dm_fat_table->aux_ant_cnt_cck[0] = 0; + } + } if (p_dm->support_ic_type == ODM_RTL8188F) { if (p_dm->support_interface == ODM_ITRF_SDIO) { @@ -3526,6 +3634,8 @@ odm_ant_div_init( if (p_dm->ant_div_type == S0S1_TRX_HW_ANTDIV) odm_trx_hw_ant_div_init_8723d(p_dm); + else if (p_dm->ant_div_type == S0S1_SW_ANTDIV) + odm_s0s1_sw_ant_div_init_8723d(p_dm); else { PHYDM_DBG(p_dm, DBG_ANT_DIV, ("[Return!!!] 8723D Not Supprrt This AntDiv type\n")); p_dm->support_ability &= ~(ODM_BB_ANT_DIV); @@ -3730,6 +3840,8 @@ odm_ant_div( p_dm_fat_table->fix_ant_bfee = 0; } } + }else { + odm_ant_div_on_off(p_dm, ANTDIV_ON); } #endif } @@ -3854,9 +3966,19 @@ odm_ant_div( /*8723D*/ #if (RTL8723D_SUPPORT == 1) else if (p_dm->support_ic_type == ODM_RTL8723D) { - - odm_hw_ant_div(p_dm); - /**/ + if (p_dm->ant_div_type == S0S1_SW_ANTDIV) { +#ifdef CONFIG_S0S1_SW_ANTENNA_DIVERSITY + if (p_dm->antdiv_counter == CONFIG_ANTENNA_DIVERSITY_PERIOD) { + odm_s0s1_sw_ant_div(p_dm, SWAW_STEP_PEEK); + p_dm->antdiv_counter--; + } else { + p_dm->antdiv_counter--; + } + if (p_dm->antdiv_counter == 0) + p_dm->antdiv_counter = CONFIG_ANTENNA_DIVERSITY_PERIOD; +#endif + } else if (p_dm->ant_div_type == CG_TRX_HW_ANTDIV) + odm_hw_ant_div(p_dm); } #endif @@ -4461,7 +4583,8 @@ odm_ant_div_config( if (p_dm->support_ic_type == ODM_RTL8723B) p_dm->ant_div_type = S0S1_SW_ANTDIV; - + if (p_dm->support_ic_type == ODM_RTL8723D) + p_dm->ant_div_type = S0S1_SW_ANTDIV; #elif (DM_ODM_SUPPORT_TYPE & (ODM_AP)) diff --git a/hal/phydm/phydm_antdiv.h b/hal/phydm/phydm_antdiv.h index 9eb11e8..544c63e 100644 --- a/hal/phydm/phydm_antdiv.h +++ b/hal/phydm/phydm_antdiv.h @@ -131,6 +131,12 @@ /*Hong Lin Smart antenna*/ #define HL_SMTANT_2WIRE_DATA_LEN 24 +#if (RTL8723D_SUPPORT == 1) + #ifndef CONFIG_ANTENNA_DIVERSITY_PERIOD + #define CONFIG_ANTENNA_DIVERSITY_PERIOD 1 + #endif +#endif + /* 1 ============================================================ * 1 structure * 1 ============================================================ */ diff --git a/hal/phydm/phydm_cck_pd.c b/hal/phydm/phydm_cck_pd.c index 1f1eba9..652e8c5 100644 --- a/hal/phydm/phydm_cck_pd.c +++ b/hal/phydm/phydm_cck_pd.c @@ -201,6 +201,7 @@ phydm_cckpd_new_cs_ratio( u8 pd_th = 0, cs_ration = 0, cs_2r_offset = 0; u8 igi_curr = p_dig_t->cur_ig_value; u8 en_2rcca; + boolean is_update = true; PHYDM_DBG(p_dm, DBG_CCKPD, ("%s ======>\n", __func__)); @@ -230,6 +231,7 @@ phydm_cckpd_new_cs_ratio( cs_ration = p_dig_t->aaa_default; pd_th = 0x3; } else { + is_update = false; cs_ration = p_cckpd_t->cck_cca_th_aaa; pd_th = p_cckpd_t->cur_cck_cca_thres; } @@ -244,6 +246,7 @@ phydm_cckpd_new_cs_ratio( cs_ration = p_dig_t->aaa_default; pd_th = 0x3; } else { + is_update = false; cs_ration = p_cckpd_t->cck_cca_th_aaa; pd_th = p_cckpd_t->cur_cck_cca_thres; } @@ -252,15 +255,15 @@ phydm_cckpd_new_cs_ratio( if (en_2rcca) cs_ration = (cs_ration >= cs_2r_offset) ? (cs_ration - cs_2r_offset) : 0; - p_cckpd_t->cur_cck_cca_thres = pd_th; - p_cckpd_t->cck_cca_th_aaa = cs_ration; - PHYDM_DBG(p_dm, DBG_CCKPD, ("[New] cs_ratio=0x%x, pd_th=0x%x\n", cs_ration, pd_th)); - odm_set_bb_reg(p_dm, 0xa08, 0xf0000, pd_th); - odm_set_bb_reg(p_dm, 0xaa8, 0x1f0000, cs_ration); - + if (is_update) { + p_cckpd_t->cur_cck_cca_thres = pd_th; + p_cckpd_t->cck_cca_th_aaa = cs_ration; + odm_set_bb_reg(p_dm, 0xa08, 0xf0000, pd_th); + odm_set_bb_reg(p_dm, 0xaa8, 0x1f0000, cs_ration); + } /*phydm_write_cck_cca_th_new_cs_ratio(p_dm, pd_th, cs_ration);*/ } @@ -445,8 +448,15 @@ phydm_cck_pd_init( p_cckpd_t->pause_bitmap = 0; - if (p_dm->support_ic_type & EXTEND_CCK_CCATH_AAA_IC) + if (p_dm->support_ic_type & EXTEND_CCK_CCATH_AAA_IC) { p_dig_t->aaa_default = odm_read_1byte(p_dm, 0xaaa) & 0x1f; + p_dig_t->a0a_default = (u8)odm_get_bb_reg(p_dm, 0xa08, 0xff0000); + p_cckpd_t->cck_cca_th_aaa = p_dig_t->aaa_default; + p_cckpd_t->cur_cck_cca_thres = p_dig_t->a0a_default; + } else { + p_dig_t->a0a_default = (u8)odm_get_bb_reg(p_dm, 0xa08, 0xff0000); + p_cckpd_t->cur_cck_cca_thres = p_dig_t->a0a_default; + } odm_memory_set(p_dm, p_cckpd_t->pause_cckpd_value, 0, PHYDM_PAUSE_MAX_NUM); #endif diff --git a/hal/phydm/phydm_cfotracking.c b/hal/phydm/phydm_cfotracking.c index 161fafd..375181f 100644 --- a/hal/phydm/phydm_cfotracking.c +++ b/hal/phydm/phydm_cfotracking.c @@ -72,7 +72,7 @@ phydm_set_crystal_cap( #if (RTL8710B_SUPPORT == 1) else if (p_dm->support_ic_type & (ODM_RTL8710B)) { - #if (DM_ODM_SUPPORT_TYPE & ODM_WIN) + #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) /* write 0x60[29:24] = 0x60[23:18] = crystal_cap */ HAL_SetSYSOnReg(p_dm->adapter, REG_SYS_XTAL_CTRL0, 0x3FFC0000, (crystal_cap | (crystal_cap << 6))); #endif diff --git a/hal/phydm/phydm_debug.c b/hal/phydm/phydm_debug.c index 8bb4faf..fc6f1eb 100644 --- a/hal/phydm/phydm_debug.c +++ b/hal/phydm/phydm_debug.c @@ -72,6 +72,7 @@ phydm_init_debug_setting( p_dm->fw_buff_is_enpty = true; p_dm->pre_c2h_seq = 0; p_dm->c2h_cmd_start = 0; + phydm_reset_rx_rate_distribution(p_dm); } void @@ -955,6 +956,114 @@ phydm_rx_rate_distribution } + +void phydm_print_hist_2_buf(void *dm_void, u16 *val, u16 len, char *buf, + u16 buf_size) +{ + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + + if (len == PHY_HIST_SIZE) { + PHYDM_PRINT2BUF(buf, buf_size, + "[%.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d]", + val[0], val[1], val[2], val[3], val[4], + val[5], val[6], val[7], val[8], val[9], + val[10], val[11]); + } else if (len == (PHY_HIST_SIZE - 1)) { + PHYDM_PRINT2BUF(buf, buf_size, + "[%.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d, %.2d]", + val[0], val[1], val[2], val[3], val[4], + val[5], val[6], val[7], val[8], val[9], + val[10]); + } +} + +void phydm_nss_hitogram(void *dm_void, enum PDM_RATE_TYPE rate_type) +{ + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + struct _odm_phy_dbg_info_ *dbg_i = &dm->phy_dbg_info; + struct phydm_phystatus_statistic *dbg_s = &dbg_i->phystatus_statistic_info; + char buf[PHYDM_SNPRINT_SIZE] = {0}; + u16 buf_size = PHYDM_SNPRINT_SIZE; + u16 h_size = PHY_HIST_SIZE; + u16 *evm_hist = NULL, *snr_hist = NULL; + u8 i = 0; + u8 ss = phydm_rate_type_2_num_ss(dm, rate_type); + + for (i = 0; i < ss; i++) { + if (rate_type == PDM_1SS) { + evm_hist = &dbg_s->evm_1ss_hist[0]; + snr_hist = &dbg_s->snr_1ss_hist[0]; + } else if (rate_type == PDM_2SS) { + #if (defined(PHYDM_COMPILE_ABOVE_2SS)) + evm_hist = &dbg_s->evm_2ss_hist[i][0]; + snr_hist = &dbg_s->snr_2ss_hist[i][0]; + #endif + } else if (rate_type == PDM_3SS) { + #if (defined(PHYDM_COMPILE_ABOVE_3SS)) + evm_hist = &dbg_s->evm_3ss_hist[i][0]; + snr_hist = &dbg_s->snr_3ss_hist[i][0]; + #endif + } else if (rate_type == PDM_4SS) { + #if (defined(PHYDM_COMPILE_ABOVE_4SS)) + evm_hist = &dbg_s->evm_4ss_hist[i][0]; + snr_hist = &dbg_s->snr_4ss_hist[i][0]; + #endif + } + + phydm_print_hist_2_buf(dm, evm_hist, h_size, buf, buf_size); + PHYDM_DBG(dm, ODM_COMP_COMMON, ("[%d-SS][EVM][%d]=%s\n", ss, i, buf)); + phydm_print_hist_2_buf(dm, snr_hist, h_size, buf, buf_size); + PHYDM_DBG(dm, ODM_COMP_COMMON, ("[%d-SS][SNR][%d]=%s\n", ss, i, buf)); + } +} + +void phydm_show_phy_hitogram(void *dm_void) +{ + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + struct _odm_phy_dbg_info_ *dbg_i = &dm->phy_dbg_info; + struct phydm_phystatus_statistic *dbg_s = &dbg_i->phystatus_statistic_info; + char buf[PHYDM_SNPRINT_SIZE] = {0}; + u16 buf_size = PHYDM_SNPRINT_SIZE; + u16 th_size = PHY_HIST_SIZE - 1; + u8 i = 0; + + PHYDM_DBG(dm, ODM_COMP_COMMON, ("[PHY Histogram] ==============>\n")); +/*===[Threshold]==============================================================*/ + phydm_print_hist_2_buf(dm, dbg_i->evm_hist_th, th_size, buf, buf_size); + PHYDM_DBG(dm, ODM_COMP_COMMON, ("%-16s=%s\n", "[EVM_TH]", buf)); + + phydm_print_hist_2_buf(dm, dbg_i->snr_hist_th, th_size, buf, buf_size); + PHYDM_DBG(dm, ODM_COMP_COMMON, ("%-16s=%s\n", "[SNR_TH]", buf)); +/*===[OFDM]===================================================================*/ + if (dbg_s->rssi_ofdm_cnt) { + phydm_print_hist_2_buf(dm, dbg_s->evm_ofdm_hist, PHY_HIST_SIZE, + buf, buf_size); + PHYDM_DBG(dm, ODM_COMP_COMMON, ("%-14s=%s\n", "[OFDM][EVM]", buf)); + + phydm_print_hist_2_buf(dm, dbg_s->snr_ofdm_hist, PHY_HIST_SIZE, + buf, buf_size); + PHYDM_DBG(dm, ODM_COMP_COMMON, ("%-14s=%s\n", "[OFDM][SNR]", buf)); + } +/*===[1-SS]===================================================================*/ + if (dbg_s->rssi_1ss_cnt) + phydm_nss_hitogram(dm, PDM_1SS); +/*===[2-SS]===================================================================*/ + #if (defined(PHYDM_COMPILE_ABOVE_2SS)) + if ((dm->support_ic_type & PHYDM_IC_ABOVE_2SS) && dbg_s->rssi_2ss_cnt) + phydm_nss_hitogram(dm, PDM_2SS); + #endif +/*===[3-SS]===================================================================*/ + #if (defined(PHYDM_COMPILE_ABOVE_3SS)) + if ((dm->support_ic_type & PHYDM_IC_ABOVE_3SS) && dbg_s->rssi_3ss_cnt) + phydm_nss_hitogram(dm, PDM_3SS); + #endif +/*===[4-SS]===================================================================*/ + #if (defined(PHYDM_COMPILE_ABOVE_4SS)) + if (dm->support_ic_type & PHYDM_IC_ABOVE_4SS && dbg_s->rssi_4ss_cnt) + phydm_nss_hitogram(dm, PDM_4SS); + #endif +} + void phydm_get_avg_phystatus_val ( @@ -1081,6 +1190,7 @@ phydm_get_phy_statistic( phydm_rx_rate_distribution(p_dm); phydm_reset_rx_rate_distribution(p_dm); + phydm_show_phy_hitogram(p_dm); phydm_get_avg_phystatus_val(p_dm); phydm_reset_phystatus_statistic(p_dm); }; @@ -1102,8 +1212,8 @@ phydm_basic_dbg_message s32 tmp_val = 0; u8 tmp_val_u1 = 0; - if (!(p_dm->debug_components & ODM_COMP_COMMON)) - return; + /* if (!(p_dm->debug_components & ODM_COMP_COMMON)) */ + /* return; */ PHYDM_DBG(p_dm, ODM_COMP_COMMON, ("[PHYDM Common MSG] System up time: ((%d sec))----->\n", p_dm->phydm_sys_up_time)); diff --git a/hal/phydm/phydm_debug.h b/hal/phydm/phydm_debug.h index dbe86a2..500aa93 100644 --- a/hal/phydm/phydm_debug.h +++ b/hal/phydm/phydm_debug.h @@ -73,6 +73,8 @@ #define RA_H2C BIT(5) #define F_RATE_AP_RPT BIT(7) +#define PHYDM_SNPRINT_SIZE 64 + /* ----------------------------------------------------------------------------- * Define the tracing components * @@ -95,20 +97,24 @@ #define dcmd_printf DCMD_Printf #define dcmd_scanf DCMD_Scanf #define RT_PRINTK dbg_print + #define PHYDM_PRINT2BUF RT_SPRINTF #elif (DM_ODM_SUPPORT_TYPE == ODM_CE) && defined(DM_ODM_CE_MAC80211) #define dbg_print(args...) #define RT_PRINTK(fmt, args...) \ RT_TRACE(((struct rtl_priv *)p_dm->adapter), \ COMP_PHYDM, DBG_DMESG, fmt, ## args) #define RT_DISP(dbgtype, dbgflag, printstr) + #define PHYDM_PRINT2BUF snprintf #elif (DM_ODM_SUPPORT_TYPE == ODM_CE) #define dbg_print printk #define RT_PRINTK(fmt, args...) dbg_print(fmt, ## args) #define RT_DISP(dbgtype, dbgflag, printstr) + #define PHYDM_PRINT2BUF snprintf #else #define dbg_print panic_printk /*#define RT_PRINTK(fmt, args...) dbg_print("%s(): " fmt, __FUNCTION__, ## args);*/ #define RT_PRINTK(args...) dbg_print(args) + #define PHYDM_PRINT2BUF snprintf #endif #ifndef ASSERT @@ -214,27 +220,45 @@ #define PHYDM_SSCANF(x, y, z) sscanf(x, y, z) -#define PHYDM_VAST_INFO_SNPRINTF(msg)\ +#if (DM_ODM_SUPPORT_TYPE == ODM_CE) + #define PHYDM_VAST_INFO_SNPRINTF(msg)\ + do {\ + snprintf msg;\ + dbg_print("%s\n", output);\ + } while (0) +#else + #define PHYDM_VAST_INFO_SNPRINTF(msg)\ do {\ snprintf msg;\ dbg_print(output);\ } while (0) +#endif #if (PHYDM_DBGPRINT == 1) -#define PHYDM_SNPRINTF(msg)\ - do {\ - snprintf msg;\ - dbg_print(output);\ - } while (0) + #if (DM_ODM_SUPPORT_TYPE == ODM_CE) + #define PHYDM_SNPRINTF(msg)\ + do {\ + snprintf msg;\ + dbg_print("%s\n", output);\ + } while (0) + #else + #define PHYDM_SNPRINTF(msg)\ + do {\ + snprintf msg;\ + dbg_print(output);\ + } while (0) + #endif #else -#define PHYDM_SNPRINTF(msg)\ - do {\ - if (out_len > used)\ - used += snprintf msg;\ - } while (0) -#endif + #define PHYDM_SNPRINTF(msg)\ + do {\ + if (out_len > used)\ + used += snprintf msg;\ + } while (0) +#endif /*#if (PHYDM_DBGPRINT == 1)*/ #endif +void phydm_show_phy_hitogram(void *dm_void); + void phydm_init_debug_setting( struct PHY_DM_STRUCT *p_dm diff --git a/hal/phydm/phydm_dfs.c b/hal/phydm/phydm_dfs.c index 53f0080..e5acd07 100644 --- a/hal/phydm/phydm_dfs.c +++ b/hal/phydm/phydm_dfs.c @@ -480,6 +480,8 @@ phydm_radar_detect_dm_check( } } fa_flag = 1; + } else { + p_dfs->radar_det_mask_hist[index] = 0; } if (p_dfs->det_print) { @@ -494,7 +496,7 @@ phydm_radar_detect_dm_check( for (i=0; i<5; i++) PHYDM_DBG(p_dm, DBG_DFS, ("%d ", p_dfs->fa_inc_hist[i])); PHYDM_DBG(p_dm, DBG_DFS, - ("\nmax_fa_in_hist: %d pre_post_now_acc_fa_in_hist: %d ", max_fa_in_hist, pre_post_now_acc_fa_in_hist)); + ("\nfa_mask_th: %d max_fa_in_hist: %d total_fa_in_hist: %d pre_post_now_acc_fa_in_hist: %d ", fa_mask_th, max_fa_in_hist, total_fa_in_hist, pre_post_now_acc_fa_in_hist)); } sum = 0; @@ -547,7 +549,7 @@ phydm_radar_detect_dm_check( odm_set_bb_reg(p_dm, 0x918, 0x00001f00, p_dfs->pwdb_th); } - if (p_dfs->det_print2) { + if (p_dfs->det_print) { PHYDM_DBG(p_dm, DBG_DFS, ("fault_flag_det[%d], fault_flag_psd[%d], DFS_detected [%d]\n", fault_flag_det, fault_flag_psd, radar_detected)); } diff --git a/hal/phydm/phydm_dig.c b/hal/phydm/phydm_dig.c index 90165ac..7136837 100644 --- a/hal/phydm/phydm_dig.c +++ b/hal/phydm/phydm_dig.c @@ -99,11 +99,21 @@ odm_fa_threshold_check( struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; struct phydm_dig_struct *p_dig_t = &p_dm->dm_dig_table; - if (p_dig_t->is_dbg_fa_th == true) - return; + if (p_dig_t->is_dbg_fa_th) { + + PHYDM_DBG(p_dm, DBG_DIG, ("Manual Fix FA_th\n")); + + //if (p_dig_t->is_dbg_fa_th == true) + //return; + + } else if (p_dm->is_linked && (is_performance || is_dfs_band)) { + if (p_dm->rssi_min < 20) { /*[PHYDM-252]*/ + p_dig_t->fa_th[0] = 500; + p_dig_t->fa_th[1] = 750; + p_dig_t->fa_th[2] = 1000; - if (p_dm->is_linked && (is_performance || is_dfs_band)) { - if ((p_dm->rx_tp >> 2) > p_dm->tx_tp && p_dm->rx_tp < 10 && p_dm->rx_tp > 1) { /*10Mbps & 1Mbps*/ + //if (p_dm->is_linked && (is_performance || is_dfs_band)) { + } else if ((p_dm->rx_tp >> 2) > p_dm->tx_tp && p_dm->rx_tp < 10 && p_dm->rx_tp > 1) { /*10Mbps & 1Mbps*/ p_dig_t->fa_th[0] = 125; p_dig_t->fa_th[1] = 250; p_dig_t->fa_th[2] = 500; @@ -579,6 +589,7 @@ phydm_dig_dym_boundary_decision( { struct phydm_dig_struct *p_dig_t = &p_dm->dm_dig_table; u8 offset = 15, tmp_max = 0; + u8 max_of_rssi_min = 0; PHYDM_DBG(p_dm, DBG_DIG, ("Offset=((%d))\n", offset)); @@ -593,7 +604,11 @@ phydm_dig_dym_boundary_decision( /* DIG upper bound */ tmp_max = p_dig_t->rx_gain_range_min + offset; - + if (p_dig_t->rx_gain_range_min != p_dm->rssi_min) { + max_of_rssi_min = p_dm->rssi_min + offset; + if (tmp_max > max_of_rssi_min) + tmp_max = max_of_rssi_min; + } if (tmp_max > p_dig_t->dm_dig_max) p_dig_t->rx_gain_range_max = p_dig_t->dm_dig_max; else diff --git a/hal/phydm/phydm_dig.h b/hal/phydm/phydm_dig.h index 17e25da..7eda5cf 100644 --- a/hal/phydm/phydm_dig.h +++ b/hal/phydm/phydm_dig.h @@ -39,7 +39,7 @@ #define DIG_MAX_OF_MIN_BALANCE_MODE 0x2a #define DIG_MAX_PERFORMANCE_MODE 0x5a -#define DIG_MAX_OF_MIN_PERFORMANCE_MODE 0x2a /*from 3E -> 2A, refine by YuChen 2017/04/18*/ +#define DIG_MAX_OF_MIN_PERFORMANCE_MODE 0x40 /*from 3E -> 2A, refine by YuChen 2017/04/18*/ #define DIG_MIN_PERFORMANCE 0x20 @@ -109,6 +109,7 @@ struct phydm_dig_struct { u8 pause_dig_value[PHYDM_PAUSE_MAX_NUM]; enum dig_goupcheck_level dig_go_up_check_level; u8 aaa_default; + u8 a0a_default; u16 fa_th[3]; #if (RTL8822B_SUPPORT == 1 || RTL8197F_SUPPORT == 1 || RTL8821C_SUPPORT == 1) u8 rf_gain_idx; @@ -146,6 +147,7 @@ struct phydm_fa_struct { u32 cnt_ofdm_fail_pre; /* For RTL8881A */ u32 cnt_cck_fail; u32 cnt_all; + u32 cnt_all_accumulated; /*accumulate cnt_all*/ u32 cnt_all_pre; u32 cnt_fast_fsync; u32 cnt_sb_search_fail; diff --git a/hal/phydm/phydm_features_ce.h b/hal/phydm/phydm_features_ce.h index befed45..d606df7 100644 --- a/hal/phydm/phydm_features_ce.h +++ b/hal/phydm/phydm_features_ce.h @@ -40,7 +40,7 @@ #endif #if (RTL8822B_SUPPORT == 1 || RTL8197F_SUPPORT == 1) - /*#define CONFIG_ADAPTIVE_SOML*/ + #define CONFIG_ADAPTIVE_SOML #endif @@ -61,7 +61,7 @@ #ifdef CONFIG_PHYDM_ANTENNA_DIVERSITY - #if (RTL8723B_SUPPORT == 1) || (RTL8821A_SUPPORT == 1) || (RTL8188F_SUPPORT == 1) || (RTL8821C_SUPPORT == 1) + #if (RTL8723B_SUPPORT == 1) || (RTL8821A_SUPPORT == 1) || (RTL8188F_SUPPORT == 1) || (RTL8821C_SUPPORT == 1) || (RTL8723D_SUPPORT == 1) #define CONFIG_S0S1_SW_ANTENNA_DIVERSITY #endif @@ -72,6 +72,7 @@ #if (RTL8822B_SUPPORT == 1) /*#define CONFIG_HL_SMART_ANTENNA_TYPE2*/ #endif + #endif #endif diff --git a/hal/phydm/phydm_hwconfig.c b/hal/phydm/phydm_hwconfig.c index 09cd218..9ec2efd 100644 --- a/hal/phydm/phydm_hwconfig.c +++ b/hal/phydm/phydm_hwconfig.c @@ -348,13 +348,11 @@ odm_config_rf_with_tx_pwr_track_header_file( /* JJ ADD 20161014 */ #if RTL8710B_SUPPORT if (p_dm->support_ic_type == ODM_RTL8710B) { - if (p_dm->support_interface == ODM_ITRF_PCIE) - READ_AND_CONFIG_MP(8710b, _txpowertrack_pcie); - else if (p_dm->support_interface == ODM_ITRF_USB) - READ_AND_CONFIG_MP(8710b, _txpowertrack_usb); - else if (p_dm->support_interface == ODM_ITRF_SDIO) - READ_AND_CONFIG_MP(8710b, _txpowertrack_sdio); - + if (p_dm->package_type == 1) + READ_AND_CONFIG_MP(8710b, _txpowertrack_qfn48m_smic); + else if (p_dm->package_type == 5) + READ_AND_CONFIG_MP(8710b, _txpowertrack_qfn48m_umc); + READ_AND_CONFIG_MP(8710b, _txxtaltrack); } #endif diff --git a/hal/phydm/phydm_math_lib.c b/hal/phydm/phydm_math_lib.c index 85e747d..c2767b3 100644 --- a/hal/phydm/phydm_math_lib.c +++ b/hal/phydm/phydm_math_lib.c @@ -75,7 +75,28 @@ odm_sign_conversion( return value; } - + +/*threshold must form low to high*/ +u16 phydm_find_intrvl(void *dm_void, u16 val, u16 *threshold, u16 th_len) +{ + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + u16 i = 0; + u16 ret_val = 0; + u16 max_th = threshold[th_len - 1]; + + for (i = 0; i < th_len; i++) { + if (val < threshold[i]) { + ret_val = i; + break; + } else if (val >= max_th) { + ret_val = th_len; + break; + } + } + + return ret_val; +} + void phydm_seq_sorting( void *p_dm_void, diff --git a/hal/phydm/phydm_math_lib.h b/hal/phydm/phydm_math_lib.h index a8fb773..c3fd731 100644 --- a/hal/phydm/phydm_math_lib.h +++ b/hal/phydm/phydm_math_lib.h @@ -55,6 +55,8 @@ odm_sign_conversion( u32 total_bit ); +u16 phydm_find_intrvl(void *dm_void, u16 val, u16 *threshold, u16 th_len); + void phydm_seq_sorting( void *p_dm_void, diff --git a/hal/phydm/phydm_phystatus.c b/hal/phydm/phydm_phystatus.c index 02f9be7..b3b6645 100644 --- a/hal/phydm/phydm_phystatus.c +++ b/hal/phydm/phydm_phystatus.c @@ -91,97 +91,162 @@ phydm_reset_phystatus_statistic( void phydm_avg_phystatus_index( - struct PHY_DM_STRUCT *p_dm, + void *dm_void, struct phydm_phyinfo_struct *p_phy_info, struct phydm_perpkt_info_struct *p_pktinfo ) { - u8 rate_ss = phydm_rate_to_num_ss(p_dm, p_pktinfo->data_rate); - struct phydm_phystatus_statistic *p_dbg_statistic = &(p_dm->phy_dbg_info.phystatus_statistic_info); + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + struct _odm_phy_dbg_info_ *dbg_i = &dm->phy_dbg_info; + struct phydm_phystatus_statistic *dbg_s = &dbg_i->phystatus_statistic_info; + u8 rssi[PHYSTS_PATH_NUM] = {0}; + u8 evm[PHYSTS_PATH_NUM] = {0}; + s8 snr[PHYSTS_PATH_NUM] = {0}; + u32 size = PHYSTS_PATH_NUM; /*size of path=4*/ + u16 size_th = PHY_HIST_SIZE - 1; /*size of threshold*/ + u16 val = 0, intvl = 0; + u8 i = 0; + + odm_move_memory(dm, rssi, p_phy_info->rx_mimo_signal_strength, size); + odm_move_memory(dm, evm, p_phy_info->rx_mimo_evm_dbm, size); + odm_move_memory(dm, snr, p_phy_info->rx_snr, size); if (p_pktinfo->data_rate <= ODM_RATE11M) { - /*RSSI*/ - p_dbg_statistic->rssi_cck_sum += p_phy_info->rx_mimo_signal_strength[0]; - p_dbg_statistic->rssi_cck_cnt++; + dbg_s->rssi_cck_sum += rssi[0]; + dbg_s->rssi_cck_cnt++; + return; } else if (p_pktinfo->data_rate <= ODM_RATE54M) { - /*evm*/ - p_dbg_statistic->evm_ofdm_sum += p_phy_info->rx_mimo_evm_dbm[0]; + dbg_s->evm_ofdm_sum += evm[0]; /*SNR*/ - p_dbg_statistic->snr_ofdm_sum += p_phy_info->rx_snr[0]; + dbg_s->snr_ofdm_sum += snr[0]; /*RSSI*/ - p_dbg_statistic->rssi_ofdm_sum += p_phy_info->rx_mimo_signal_strength[0]; - p_dbg_statistic->rssi_ofdm_cnt++; - } else if (rate_ss == 1) { + dbg_s->rssi_ofdm_sum += rssi[0]; + dbg_s->rssi_ofdm_cnt++; + val = (u16)evm[0]; + intvl = phydm_find_intrvl(dm, val, dbg_i->evm_hist_th, size_th); + dbg_s->evm_ofdm_hist[intvl]++; + + val = (u16)snr[0]; + intvl = phydm_find_intrvl(dm, val, dbg_i->snr_hist_th, size_th); + dbg_s->snr_ofdm_hist[intvl]++; + + } else if (p_pktinfo->rate_ss == 1) { +/*===[1-SS]===================================================================*/ /*evm*/ - p_dbg_statistic->evm_1ss_sum += p_phy_info->rx_mimo_evm_dbm[0]; + dbg_s->evm_1ss_sum += evm[0]; /*SNR*/ - p_dbg_statistic->snr_1ss_sum += p_phy_info->rx_snr[0]; + dbg_s->snr_1ss_sum += snr[0]; - p_dbg_statistic->rssi_1ss_sum += p_phy_info->rx_mimo_signal_strength[0]; - p_dbg_statistic->rssi_1ss_cnt++; - } else if (rate_ss == 2) { + /*RSSI*/ + dbg_s->rssi_1ss_sum += rssi[0]; + + /*EVM Histogram*/ + val = (u16)evm[0]; + intvl = phydm_find_intrvl(dm, val, dbg_i->evm_hist_th, size_th); + dbg_s->evm_1ss_hist[intvl]++; + + /*SNR Histogram*/ + val = (u16)snr[0]; + intvl = phydm_find_intrvl(dm, val, dbg_i->snr_hist_th, size_th); + dbg_s->snr_1ss_hist[intvl]++; + + dbg_s->rssi_1ss_cnt++; + } else if (p_pktinfo->rate_ss == 2) { +/*===[2-SS]===================================================================*/ #if (defined(PHYDM_COMPILE_ABOVE_2SS)) - /*evm*/ - p_dbg_statistic->evm_2ss_sum[0] += p_phy_info->rx_mimo_evm_dbm[0]; - p_dbg_statistic->evm_2ss_sum[1] += p_phy_info->rx_mimo_evm_dbm[1]; + for (i = 0; i < p_pktinfo->rate_ss; i++) { + /*evm*/ + dbg_s->evm_2ss_sum[i] += evm[i]; + /*SNR*/ + dbg_s->snr_2ss_sum[i] += snr[i]; + /*RSSI*/ + dbg_s->rssi_2ss_sum[i] += rssi[i]; + /*EVM Histogram*/ + val = (u16)evm[i]; + intvl = phydm_find_intrvl(dm, val, dbg_i->evm_hist_th, + size_th); + dbg_s->evm_2ss_hist[i][intvl]++; - /*SNR*/ - p_dbg_statistic->snr_2ss_sum[0] += p_phy_info->rx_snr[0]; - p_dbg_statistic->snr_2ss_sum[1] += p_phy_info->rx_snr[1]; - - /*RSSI*/ - p_dbg_statistic->rssi_2ss_sum[0] += p_phy_info->rx_mimo_signal_strength[0]; - p_dbg_statistic->rssi_2ss_sum[1] += p_phy_info->rx_mimo_signal_strength[1]; - p_dbg_statistic->rssi_2ss_cnt++; + /*SNR Histogram*/ + val = (u16)snr[i]; + intvl = phydm_find_intrvl(dm, val, dbg_i->snr_hist_th, + size_th); + dbg_s->snr_2ss_hist[i][intvl]++; + } + dbg_s->rssi_2ss_cnt++; #endif - } else if (rate_ss == 3) { + } else if (p_pktinfo->rate_ss == 3) { +/*===[3-SS]===================================================================*/ #if (defined(PHYDM_COMPILE_ABOVE_3SS)) - /*evm*/ - p_dbg_statistic->evm_3ss_sum[0] += p_phy_info->rx_mimo_evm_dbm[0]; - p_dbg_statistic->evm_3ss_sum[1] += p_phy_info->rx_mimo_evm_dbm[1]; - p_dbg_statistic->evm_3ss_sum[2] += p_phy_info->rx_mimo_evm_dbm[2]; + for (i = 0; i < p_pktinfo->rate_ss; i++) { + /*evm*/ + dbg_s->evm_3ss_sum[i] += evm[i]; + /*SNR*/ + dbg_s->snr_3ss_sum[i] += snr[i]; + /*RSSI*/ + dbg_s->rssi_3ss_sum[i] += rssi[i]; + /*EVM Histogram*/ + val = (u16)evm[i]; + intvl = phydm_find_intrvl(dm, val, dbg_i->evm_hist_th, + size_th); + dbg_s->evm_3ss_hist[i][intvl]++; - /*SNR*/ - p_dbg_statistic->snr_3ss_sum[0] += p_phy_info->rx_snr[0]; - p_dbg_statistic->snr_3ss_sum[1] += p_phy_info->rx_snr[1]; - p_dbg_statistic->snr_3ss_sum[2] += p_phy_info->rx_snr[2]; - - /*RSSI*/ - p_dbg_statistic->rssi_3ss_sum[0] += p_phy_info->rx_mimo_signal_strength[0]; - p_dbg_statistic->rssi_3ss_sum[1] += p_phy_info->rx_mimo_signal_strength[1]; - p_dbg_statistic->rssi_3ss_sum[2] += p_phy_info->rx_mimo_signal_strength[2]; - p_dbg_statistic->rssi_3ss_cnt++; + /*SNR Histogram*/ + val = (u16)snr[i]; + intvl = phydm_find_intrvl(dm, val, dbg_i->snr_hist_th, + size_th); + dbg_s->snr_3ss_hist[i][intvl]++; + } + dbg_s->rssi_3ss_cnt++; #endif - } else if (rate_ss == 4) { + } else if (p_pktinfo->rate_ss == 4) { +/*===[4-SS]===================================================================*/ #if (defined(PHYDM_COMPILE_ABOVE_4SS)) - /*evm*/ - p_dbg_statistic->evm_4ss_sum[0] += p_phy_info->rx_mimo_evm_dbm[0]; - p_dbg_statistic->evm_4ss_sum[1] += p_phy_info->rx_mimo_evm_dbm[1]; - p_dbg_statistic->evm_4ss_sum[2] += p_phy_info->rx_mimo_evm_dbm[2]; - p_dbg_statistic->evm_4ss_sum[3] += p_phy_info->rx_mimo_evm_dbm[3]; + for (i = 0; i < p_pktinfo->rate_ss; i++) { + /*evm*/ + dbg_s->evm_4ss_sum[i] += evm[i]; + /*SNR*/ + dbg_s->snr_4ss_sum[i] += snr[i]; + /*RSSI*/ + dbg_s->rssi_4ss_sum[i] += rssi[i]; + /*EVM Histogram*/ + val = (u16)evm[i]; + intvl = phydm_find_intrvl(dm, val, dbg_i->evm_hist_th, + size_th); + dbg_s->evm_4ss_hist[i][intvl]++; - /*SNR*/ - p_dbg_statistic->snr_4ss_sum[0] += p_phy_info->rx_snr[0]; - p_dbg_statistic->snr_4ss_sum[1] += p_phy_info->rx_snr[1]; - p_dbg_statistic->snr_4ss_sum[2] += p_phy_info->rx_snr[2]; - p_dbg_statistic->snr_4ss_sum[3] += p_phy_info->rx_snr[3]; - - /*RSSI*/ - p_dbg_statistic->rssi_4ss_sum[0] += p_phy_info->rx_mimo_signal_strength[0]; - p_dbg_statistic->rssi_4ss_sum[1] += p_phy_info->rx_mimo_signal_strength[1]; - p_dbg_statistic->rssi_4ss_sum[2] += p_phy_info->rx_mimo_signal_strength[2]; - p_dbg_statistic->rssi_4ss_sum[3] += p_phy_info->rx_mimo_signal_strength[3]; - p_dbg_statistic->rssi_4ss_cnt++; + /*SNR Histogram*/ + val = (u16)snr[i]; + intvl = phydm_find_intrvl(dm, val, dbg_i->snr_hist_th, + size_th); + dbg_s->snr_4ss_hist[i][intvl]++; + } + dbg_s->rssi_4ss_cnt++; #endif } } +void phydm_avg_phystatus_init(void *dm_void) +{ + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + struct _odm_phy_dbg_info_ *dbg_i = &dm->phy_dbg_info; + u16 snr_hist_th[PHY_HIST_SIZE - 1] = {5, 8, 11, 14, 17, 20, 23, 26, + 29, 32, 35}; + u16 evm_hist_th[PHY_HIST_SIZE - 1] = {5, 8, 11, 14, 17, 20, 23, 26, + 29, 32, 35}; + u32 size = (PHY_HIST_SIZE - 1) * 2; + + odm_move_memory(dm, dbg_i->snr_hist_th, snr_hist_th, size); + odm_move_memory(dm, dbg_i->evm_hist_th, evm_hist_th, size); +} + + u8 phydm_get_signal_quality( struct phydm_phyinfo_struct *p_phy_info, struct PHY_DM_STRUCT *p_dm, @@ -773,7 +838,8 @@ phydm_rx_phy_status92c_series_parsing( is_cck_rate = (p_pktinfo->data_rate <= ODM_RATE11M) ? true : false; p_dm->rate_ss = phydm_rate_to_num_ss(p_dm, p_pktinfo->data_rate); - + p_pktinfo->rate_ss = p_dm->rate_ss; + if (p_pktinfo->is_to_self) p_dm->curr_station_id = p_pktinfo->station_id; @@ -1094,6 +1160,7 @@ phydm_rx_phy_status_jaguar_series_parsing( is_cck_rate = (p_pktinfo->data_rate <= ODM_RATE11M) ? true : false; p_dm->rate_ss = phydm_rate_to_num_ss(p_dm, p_pktinfo->data_rate); + p_pktinfo->rate_ss = p_dm->rate_ss; if (p_pktinfo->is_to_self) p_dm->curr_station_id = p_pktinfo->station_id; @@ -2492,6 +2559,7 @@ phydm_rx_phy_status_new_type( /* Memory reset */ phydm_reset_phy_info(p_dm, p_phy_info); p_dm->rate_ss = phydm_rate_to_num_ss(p_dm, p_pktinfo->data_rate); + p_pktinfo->rate_ss = p_dm->rate_ss; /* Phy status parsing */ switch (phy_status_type) { @@ -2563,8 +2631,9 @@ phydm_rx_phy_status_init( void *p_dm_void ) { -#ifdef PHYDM_PHYSTAUS_SMP_MODE struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; +#ifdef PHYDM_PHYSTAUS_SMP_MODE + struct pkt_process_info *p_pkt_process = &(p_dm->pkt_proc_struct); if (p_dm->support_ic_type == ODM_RTL8822B) { @@ -2578,4 +2647,5 @@ phydm_rx_phy_status_init( odm_set_bb_reg(p_dm, 0x9e4, 0xfc00, 0x0); /*Update Sampling time*/ } #endif + phydm_avg_phystatus_init(p_dm); } diff --git a/hal/phydm/phydm_phystatus.h b/hal/phydm/phydm_phystatus.h index ce8f6c5..c1a5b44 100644 --- a/hal/phydm/phydm_phystatus.h +++ b/hal/phydm/phydm_phystatus.h @@ -28,6 +28,8 @@ #define CFO_HW_RPT_2_MHZ(val) ((val<<1) + (val>>1)) /* ((X* 3125) / 10)>>7 = (X*10)>>2 = X*2.5 = X<<1 + X>>1 */ +#define PHYSTS_PATH_NUM 4 + /* ************************************************************ * structure and define * ************************************************************ */ diff --git a/hal/phydm/phydm_pre_define.h b/hal/phydm/phydm_pre_define.h index 17e2285..f9e4ad1 100644 --- a/hal/phydm/phydm_pre_define.h +++ b/hal/phydm/phydm_pre_define.h @@ -76,6 +76,15 @@ #define RX_SMOOTH_FACTOR 20 #endif +enum PDM_RATE_TYPE { + PDM_1SS = 1, /*VHT/HT 1SS*/ + PDM_2SS = 2, /*VHT/HT 2SS*/ + PDM_3SS = 3, /*VHT/HT 3SS*/ + PDM_4SS = 4, /*VHT/HT 4SS*/ + PDM_CCK = 11, /*B*/ + PDM_OFDM = 12 /*G*/ +}; + /* -----MGN rate--------------------------------- */ enum ODM_MGN_RATE { diff --git a/hal/phydm/phydm_precomp.h b/hal/phydm/phydm_precomp.h index c8c7c56..3040f66 100644 --- a/hal/phydm/phydm_precomp.h +++ b/hal/phydm/phydm_precomp.h @@ -109,7 +109,7 @@ rtw_phydm_cfg_phy_para( #endif /* JJ ADD 20161014 */ -#if (DM_ODM_SUPPORT_TYPE & (ODM_CE|ODM_AP|ODM_IOT)) +#if (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_IOT)) #define RTL8710B_SUPPORT 0 #endif diff --git a/hal/phydm/phydm_rainfo.c b/hal/phydm/phydm_rainfo.c index 9b953b7..45bd955 100644 --- a/hal/phydm/phydm_rainfo.c +++ b/hal/phydm/phydm_rainfo.c @@ -19,6 +19,32 @@ #include "mp_precomp.h" #include "phydm_precomp.h" +u8 phydm_rate_type_2_num_ss(void *dm_void, enum PDM_RATE_TYPE type) +{ + u8 num_ss = 1; + + switch (type) { + case PDM_CCK: + case PDM_OFDM: + case PDM_1SS: + num_ss = 1; + break; + case PDM_2SS: + num_ss = 2; + break; + case PDM_3SS: + num_ss = 3; + break; + case PDM_4SS: + num_ss = 4; + break; + default: + break; + } + + return num_ss; +} + void phydm_h2C_debug( void *p_dm_void, @@ -890,17 +916,17 @@ phydm_get_bb_mod_ra_mask( if (wireless_mode != WIRELESS_CCK) { if (rssi_lv == 0) - ra_mask_bitmap &= 0xffffffff; + ra_mask_bitmap &= 0xffffffffffffffff; else if (rssi_lv == 1) - ra_mask_bitmap &= 0xfffffff0; + ra_mask_bitmap &= 0xfffffffffffffff0; else if (rssi_lv == 2) - ra_mask_bitmap &= 0xffffefe0; + ra_mask_bitmap &= 0xffffffffffffefe0; else if (rssi_lv == 3) - ra_mask_bitmap &= 0xffffcfc0; + ra_mask_bitmap &= 0xffffffffffffcfc0; else if (rssi_lv == 4) - ra_mask_bitmap &= 0xffff8f80; + ra_mask_bitmap &= 0xffffffffffff8f80; else if (rssi_lv >= 5) - ra_mask_bitmap &= 0xffff0f00; + ra_mask_bitmap &= 0xffffffffffff0f00; } PHYDM_DBG(p_dm, DBG_RA, ("Mod by RSSI=0x%llx\n", ra_mask_bitmap)); @@ -1098,7 +1124,7 @@ phydm_ra_registed( #if (RTL8188E_SUPPORT == 1) && (RATE_ADAPTIVE_SUPPORT == 1) if (p_dm->support_ic_type == ODM_RTL8188E) - phydm_get_rate_id_88e(p_dm, macid); + p_ra->rate_id = phydm_get_rate_id_88e(p_dm, macid); else #endif { diff --git a/hal/phydm/phydm_rainfo.h b/hal/phydm/phydm_rainfo.h index ba8008b..6f102ea 100644 --- a/hal/phydm/phydm_rainfo.h +++ b/hal/phydm/phydm_rainfo.h @@ -214,6 +214,8 @@ struct _rate_adaptive_table_ { void (*record_ra_info)(void *p_dm_void, u8 macid, struct cmn_sta_info *p_sta, u64 ra_mask); }; +u8 phydm_rate_type_2_num_ss(void *dm_void, enum PDM_RATE_TYPE type); + void phydm_h2C_debug( void *p_dm_void, diff --git a/hal/phydm/phydm_soml.c b/hal/phydm/phydm_soml.c index 9c312a9..04827a4 100644 --- a/hal/phydm/phydm_soml.c +++ b/hal/phydm/phydm_soml.c @@ -20,6 +20,7 @@ #include "mp_precomp.h" #include "phydm_precomp.h" +#ifdef NEVER void phydm_dynamicsoftmletting( struct PHY_DM_STRUCT *p_dm @@ -54,6 +55,7 @@ phydm_dynamicsoftmletting( #endif } +#endif #ifdef CONFIG_ADAPTIVE_SOML void @@ -126,6 +128,37 @@ phydm_adaptive_soml_workitem_callback( #endif } +#elif (DM_ODM_SUPPORT_TYPE == ODM_CE) +void +phydm_adaptive_soml_callback( + void *dm_void +) +{ + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + void *padapter = dm->adapter; + + if (*dm->p_is_net_closed) + return; + if (dm->support_interface == ODM_ITRF_PCIE) { + phydm_adsl(dm); + } else { + /* Can't do I/O in timer callback*/ + rtw_run_in_thread_cmd(padapter, phydm_adaptive_soml_workitem_callback, padapter); + } +} + +void +phydm_adaptive_soml_workitem_callback( + void *context +) +{ + void *adapter = (void *)context; + HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter)); + struct PHY_DM_STRUCT *dm = &hal_data->odmpriv; + + /*dbg_print("phydm_adaptive_soml-phydm_adaptive_soml_workitem_callback\n");*/ + phydm_adsl(dm); +} #else void @@ -202,32 +235,34 @@ phydm_soml_statistics( u8 i; u32 num_bytes_diff; - if (p_dm->support_ic_type == ODM_RTL8197F) { - if (on_off_state == SOML_ON) { - for (i = 0; i < HT_RATE_IDX; i++) { - num_bytes_diff = p_dm_soml_table->num_ht_bytes[i] - p_dm_soml_table->pre_num_ht_bytes[i]; - p_dm_soml_table->num_ht_bytes_on[i] += num_bytes_diff; - p_dm_soml_table->pre_num_ht_bytes[i] = p_dm_soml_table->num_ht_bytes[i]; - } - } else if (on_off_state == SOML_OFF) { - for (i = 0; i < HT_RATE_IDX; i++) { - num_bytes_diff = p_dm_soml_table->num_ht_bytes[i] - p_dm_soml_table->pre_num_ht_bytes[i]; - p_dm_soml_table->num_ht_bytes_off[i] += num_bytes_diff; - p_dm_soml_table->pre_num_ht_bytes[i] = p_dm_soml_table->num_ht_bytes[i]; + if (on_off_state == SOML_ON) { + if (*p_dm->p_channel <= 14) { + for (i = ODM_RATEMCS0; i <= ODM_RATEMCS15; i++) { + num_bytes_diff = p_dm_soml_table->num_ht_bytes[i - ODM_RATEMCS0] - p_dm_soml_table->pre_num_ht_bytes[i - ODM_RATEMCS0]; + p_dm_soml_table->num_ht_bytes_on[i - ODM_RATEMCS0] += num_bytes_diff; + p_dm_soml_table->pre_num_ht_bytes[i - ODM_RATEMCS0] = p_dm_soml_table->num_ht_bytes[i - ODM_RATEMCS0]; } } - } else if (p_dm->support_ic_type == ODM_RTL8822B) { - if (on_off_state == SOML_ON) { - for (i = 0; i < VHT_RATE_IDX; i++) { - num_bytes_diff = p_dm_soml_table->num_vht_bytes[i] - p_dm_soml_table->pre_num_vht_bytes[i]; - p_dm_soml_table->num_vht_bytes_on[i] += num_bytes_diff; - p_dm_soml_table->pre_num_vht_bytes[i] = p_dm_soml_table->num_vht_bytes[i]; + if (p_dm->support_ic_type == ODM_RTL8822B) { + for (i = ODM_RATEVHTSS1MCS0; i <= ODM_RATEVHTSS2MCS9; i++) { + num_bytes_diff = p_dm_soml_table->num_vht_bytes[i - ODM_RATEVHTSS1MCS0] - p_dm_soml_table->pre_num_vht_bytes[i - ODM_RATEVHTSS1MCS0]; + p_dm_soml_table->num_vht_bytes_on[i - ODM_RATEVHTSS1MCS0] += num_bytes_diff; + p_dm_soml_table->pre_num_vht_bytes[i - ODM_RATEVHTSS1MCS0] = p_dm_soml_table->num_vht_bytes[i - ODM_RATEVHTSS1MCS0]; } - } else if (on_off_state == SOML_OFF) { - for (i = 0; i < VHT_RATE_IDX; i++) { - num_bytes_diff = p_dm_soml_table->num_vht_bytes[i] - p_dm_soml_table->pre_num_vht_bytes[i]; - p_dm_soml_table->num_vht_bytes_off[i] += num_bytes_diff; - p_dm_soml_table->pre_num_vht_bytes[i] = p_dm_soml_table->num_vht_bytes[i]; + } + } else if (on_off_state == SOML_OFF) { + if (*p_dm->p_channel <= 14) { + for (i = ODM_RATEMCS0; i <= ODM_RATEMCS15; i++) { + num_bytes_diff = p_dm_soml_table->num_ht_bytes[i - ODM_RATEMCS0] - p_dm_soml_table->pre_num_ht_bytes[i - ODM_RATEMCS0]; + p_dm_soml_table->num_ht_bytes_off[i - ODM_RATEMCS0] += num_bytes_diff; + p_dm_soml_table->pre_num_ht_bytes[i - ODM_RATEMCS0] = p_dm_soml_table->num_ht_bytes[i - ODM_RATEMCS0]; + } + } + if (p_dm->support_ic_type == ODM_RTL8822B) { + for (i = ODM_RATEVHTSS1MCS0; i <= ODM_RATEVHTSS2MCS9; i++) { + num_bytes_diff = p_dm_soml_table->num_vht_bytes[i - ODM_RATEVHTSS1MCS0] - p_dm_soml_table->pre_num_vht_bytes[i - ODM_RATEVHTSS1MCS0]; + p_dm_soml_table->num_vht_bytes_off[i - ODM_RATEVHTSS1MCS0] += num_bytes_diff; + p_dm_soml_table->pre_num_vht_bytes[i - ODM_RATEVHTSS1MCS0] = p_dm_soml_table->num_vht_bytes[i - ODM_RATEVHTSS1MCS0]; } } } @@ -255,152 +290,127 @@ phydm_adsl( else if (p_dm->support_ic_type & ODM_IC_2SS) rate_num = 2; - if ((p_dm->support_ic_type & ODM_ADAPTIVE_SOML_SUPPORT_IC)) { - if (p_dm->number_active_client == 1) { - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("rssi_min =%d\n", p_dm->rssi_min)); - if ((p_dm->rssi_min >= SOML_RSSI_TH_HIGH) || (p_dm_soml_table->is_soml_method_enable == 1)) { + if (!(p_dm->support_ic_type & ODM_ADAPTIVE_SOML_SUPPORT_IC)) + return; + + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("rssi_min =%d\n", p_dm->rssi_min)); + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("soml_state_cnt =((%d))\n", p_dm_soml_table->soml_state_cnt)); + /*Traning state: 0(alt) 1(ori) 2(alt) 3(ori)============================================================*/ + if (p_dm_soml_table->soml_state_cnt < (p_dm_soml_table->soml_train_num << 1)) { - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("> TH_H || is_soml_method_enable==1\n")); + if (p_dm_soml_table->soml_state_cnt == 0) { - if (p_dm->rssi_min >= SOML_RSSI_TH_LOW) { - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("> TH_L, soml_state_cnt =((%d))\n", p_dm_soml_table->soml_state_cnt)); - /*Traning state: 0(alt) 1(ori) 2(alt) 3(ori)============================================================*/ - if (p_dm_soml_table->soml_state_cnt < ((p_dm_soml_table->soml_train_num)<<1)) { + odm_move_memory(p_dm, p_dm_soml_table->num_ht_bytes, ht_reset, HT_RATE_IDX * size); + odm_move_memory(p_dm, p_dm_soml_table->num_ht_bytes_on, ht_reset, HT_RATE_IDX * size); + odm_move_memory(p_dm, p_dm_soml_table->num_ht_bytes_off, ht_reset, HT_RATE_IDX * size); + odm_move_memory(p_dm, p_dm_soml_table->num_vht_bytes, vht_reset, VHT_RATE_IDX * size); + odm_move_memory(p_dm, p_dm_soml_table->num_vht_bytes_on, vht_reset, VHT_RATE_IDX * size); + odm_move_memory(p_dm, p_dm_soml_table->num_vht_bytes_off, vht_reset, VHT_RATE_IDX * size); - if (p_dm_soml_table->soml_state_cnt == 0) { + p_dm_soml_table->is_soml_method_enable = 1; + p_dm_soml_table->soml_state_cnt++; + next_on_off = (p_dm_soml_table->soml_on_off == SOML_ON) ? SOML_ON : SOML_OFF; + phydm_soml_on_off(p_dm, next_on_off); + odm_set_timer(p_dm, &p_dm_soml_table->phydm_adaptive_soml_timer, p_dm_soml_table->soml_delay_time); /*ms*/ + } else if ((p_dm_soml_table->soml_state_cnt % 2) != 0) { - if (p_dm->support_ic_type == ODM_RTL8197F) { + p_dm_soml_table->soml_state_cnt++; + odm_move_memory(p_dm, p_dm_soml_table->pre_num_ht_bytes, p_dm_soml_table->num_ht_bytes, HT_RATE_IDX * size); + odm_move_memory(p_dm, p_dm_soml_table->pre_num_vht_bytes, p_dm_soml_table->num_vht_bytes, VHT_RATE_IDX * size); + odm_set_timer(p_dm, &p_dm_soml_table->phydm_adaptive_soml_timer, p_dm_soml_table->soml_intvl); /*ms*/ + } else if ((p_dm_soml_table->soml_state_cnt % 2) == 0) { - odm_move_memory(p_dm, p_dm_soml_table->num_ht_bytes, ht_reset, HT_RATE_IDX*size); - odm_move_memory(p_dm, p_dm_soml_table->num_ht_bytes_on, ht_reset, HT_RATE_IDX*size); - odm_move_memory(p_dm, p_dm_soml_table->num_ht_bytes_off, ht_reset, HT_RATE_IDX*size); - } else if (p_dm->support_ic_type == ODM_RTL8822B) { - - odm_move_memory(p_dm, p_dm_soml_table->num_vht_bytes, vht_reset, VHT_RATE_IDX*size); - odm_move_memory(p_dm, p_dm_soml_table->num_vht_bytes_on, vht_reset, VHT_RATE_IDX*size); - odm_move_memory(p_dm, p_dm_soml_table->num_vht_bytes_off, vht_reset, VHT_RATE_IDX*size); - } - - p_dm_soml_table->is_soml_method_enable = 1; - p_dm_soml_table->soml_state_cnt++; - next_on_off = (p_dm_soml_table->soml_on_off == SOML_ON) ? SOML_ON : SOML_OFF; - phydm_soml_on_off(p_dm, next_on_off); - odm_set_timer(p_dm, &p_dm_soml_table->phydm_adaptive_soml_timer, p_dm_soml_table->soml_delay_time); /*ms*/ - } else if ((p_dm_soml_table->soml_state_cnt % 2) != 0) { - - p_dm_soml_table->soml_state_cnt++; - if (p_dm->support_ic_type == ODM_RTL8197F) - odm_move_memory(p_dm, p_dm_soml_table->pre_num_ht_bytes, p_dm_soml_table->num_ht_bytes, HT_RATE_IDX*size); - else if (p_dm->support_ic_type == ODM_RTL8822B) - odm_move_memory(p_dm, p_dm_soml_table->pre_num_vht_bytes, p_dm_soml_table->num_vht_bytes, VHT_RATE_IDX*size); - odm_set_timer(p_dm, &p_dm_soml_table->phydm_adaptive_soml_timer, p_dm_soml_table->soml_intvl); /*ms*/ - } else if ((p_dm_soml_table->soml_state_cnt % 2) == 0) { - - p_dm_soml_table->soml_state_cnt++; - phydm_soml_statistics(p_dm, p_dm_soml_table->soml_on_off); - next_on_off = (p_dm_soml_table->soml_on_off == SOML_ON) ? SOML_OFF : SOML_ON; - phydm_soml_on_off(p_dm, next_on_off); - odm_set_timer(p_dm, &p_dm_soml_table->phydm_adaptive_soml_timer, p_dm_soml_table->soml_delay_time); /*ms*/ - } - } - /*Decision state: ==============================================================*/ - else { - - p_dm_soml_table->soml_state_cnt = 0; - phydm_soml_statistics(p_dm, p_dm_soml_table->soml_on_off); - - /* [Search 1st and 2ed rate by counter] */ - if (p_dm->support_ic_type == ODM_RTL8197F) { - - for (i = 0; i < rate_num; i++) { - rate_ss_shift = (i << 3); - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("*num_ht_bytes_on HT MCS[%d :%d ] = {%d, %d, %d, %d, %d, %d, %d, %d}\n", - (rate_ss_shift), (rate_ss_shift+7), - p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 0], p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 1], - p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 2], p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 3], - p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 4], p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 5], - p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 6], p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 7])); - } - - for (i = 0; i < rate_num; i++) { - rate_ss_shift = (i << 3); - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("*num_ht_bytes_off HT MCS[%d :%d ] = {%d, %d, %d, %d, %d, %d, %d, %d}\n", - (rate_ss_shift), (rate_ss_shift+7), - p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 0], p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 1], - p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 2], p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 3], - p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 4], p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 5], - p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 6], p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 7])); - } - - for (i = 0; i < HT_RATE_IDX; i++) { - - byte_total_on += p_dm_soml_table->num_vht_bytes_on[i]; - byte_total_off += p_dm_soml_table->num_vht_bytes_off[i]; - } - - } else if (p_dm->support_ic_type == ODM_RTL8822B) { - - for (i = 0; i < rate_num; i++) { - rate_ss_shift = 10 * i; - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("* num_vht_bytes_on VHT-%d ss MCS[0:9] = {%d, %d, %d, %d, %d, %d, %d, %d, %d, %d}\n", - (i + 1), - p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 0], p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 1], - p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 2], p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 3], - p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 4], p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 5], - p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 6], p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 7], - p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 8], p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 9])); - } - - for (i = 0; i < rate_num; i++) { - rate_ss_shift = 10 * i; - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("* num_vht_bytes_off VHT-%d ss MCS[0:9] = {%d, %d, %d, %d, %d, %d, %d, %d, %d, %d}\n", - (i + 1), - p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 0], p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 1], - p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 2], p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 3], - p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 4], p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 5], - p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 6], p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 7], - p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 8], p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 9])); - } - for (i = 0; i < VHT_RATE_IDX; i++) { - byte_total_on += p_dm_soml_table->num_vht_bytes_on[i]; - byte_total_off += p_dm_soml_table->num_vht_bytes_off[i]; - } - } - - /* [Decision] */ - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ byte_total_on = %d ; byte_total_off = %d ]\n", byte_total_on, byte_total_off)); - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[Decisoin state ]\n")); - if (byte_total_on > byte_total_off) { - next_on_off = SOML_ON; - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ byte_total_on > byte_total_off ==> SOML_ON ]\n")); - } else if (byte_total_on < byte_total_off) { - next_on_off = SOML_OFF; - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ byte_total_on < byte_total_off ==> SOML_OFF ]\n")); - } else { - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ stay at soml_last_state ]\n")); - next_on_off = p_dm_soml_table->soml_last_state; - } - - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ Final decisoin ] : ")); - phydm_soml_on_off(p_dm, next_on_off); - p_dm_soml_table->soml_last_state = next_on_off; - } - } else { /* RSSI< = SOML_RSSI_TH_LOW */ - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ TH_L ]\n")); - phydm_adaptive_soml_reset(p_dm); - phydm_soml_on_off(p_dm, SOML_ON); - } - } else { - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[escape from > TH_H || is_soml_method_enable==1]\n")); - phydm_adaptive_soml_reset(p_dm); - phydm_soml_on_off(p_dm, SOML_ON); - } - } else { - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[multi-Client]\n")); - phydm_adaptive_soml_reset(p_dm); - phydm_soml_on_off(p_dm, SOML_ON); + p_dm_soml_table->soml_state_cnt++; + phydm_soml_statistics(p_dm, p_dm_soml_table->soml_on_off); + next_on_off = (p_dm_soml_table->soml_on_off == SOML_ON) ? SOML_OFF : SOML_ON; + phydm_soml_on_off(p_dm, next_on_off); + odm_set_timer(p_dm, &p_dm_soml_table->phydm_adaptive_soml_timer, p_dm_soml_table->soml_delay_time); /*ms*/ } } + /*Decision state: ==============================================================*/ + else { + + p_dm_soml_table->soml_state_cnt = 0; + phydm_soml_statistics(p_dm, p_dm_soml_table->soml_on_off); + + /* [Search 1st and 2ed rate by counter] */ + if (*p_dm->p_channel <= 14) { + + for (i = 0; i < rate_num; i++) { + rate_ss_shift = (i << 3); + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("*num_ht_bytes_on HT MCS[%d :%d ] = {%d, %d, %d, %d, %d, %d, %d, %d}\n", + (rate_ss_shift), + (rate_ss_shift + 7), + p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 0], p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 1], + p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 2], p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 3], + p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 4], p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 5], + p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 6], p_dm_soml_table->num_ht_bytes_on[rate_ss_shift + 7])); + } + + for (i = 0; i < rate_num; i++) { + rate_ss_shift = (i << 3); + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("*num_ht_bytes_off HT MCS[%d :%d ] = {%d, %d, %d, %d, %d, %d, %d, %d}\n", + (rate_ss_shift), (rate_ss_shift + 7), + p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 0], p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 1], + p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 2], p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 3], + p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 4], p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 5], + p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 6], p_dm_soml_table->num_ht_bytes_off[rate_ss_shift + 7])); + } + + for (i = ODM_RATEMCS8; i <= ODM_RATEMCS15; i++) { + + byte_total_on += p_dm_soml_table->num_ht_bytes_on[i - ODM_RATEMCS0]; + byte_total_off += p_dm_soml_table->num_ht_bytes_off[i - ODM_RATEMCS0]; + } + + } else if (p_dm->support_ic_type == ODM_RTL8822B) { + + for (i = 0; i < rate_num; i++) { + rate_ss_shift = 10 * i; + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("* num_vht_bytes_on VHT-%d ss MCS[0:9] = {%d, %d, %d, %d, %d, %d, %d, %d, %d, %d}\n", + (i + 1), + p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 0], p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 1], + p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 2], p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 3], + p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 4], p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 5], + p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 6], p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 7], + p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 8], p_dm_soml_table->num_vht_bytes_on[rate_ss_shift + 9])); + } + + for (i = 0; i < rate_num; i++) { + rate_ss_shift = 10 * i; + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("* num_vht_bytes_off VHT-%d ss MCS[0:9] = {%d, %d, %d, %d, %d, %d, %d, %d, %d, %d}\n", + (i + 1), + p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 0], p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 1], + p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 2], p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 3], + p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 4], p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 5], + p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 6], p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 7], + p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 8], p_dm_soml_table->num_vht_bytes_off[rate_ss_shift + 9])); + } + for (i = ODM_RATEVHTSS2MCS0; i <= ODM_RATEVHTSS2MCS9; i++) { + byte_total_on += p_dm_soml_table->num_vht_bytes_on[i - ODM_RATEVHTSS1MCS0]; + byte_total_off += p_dm_soml_table->num_vht_bytes_off[i - ODM_RATEVHTSS1MCS0]; + } + } + + /* [Decision] */ + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ byte_total_on = %d ; byte_total_off = %d ]\n", byte_total_on, byte_total_off)); + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[Decisoin state ]\n")); + if (byte_total_on > byte_total_off) { + next_on_off = SOML_ON; + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ byte_total_on > byte_total_off ==> SOML_ON ]\n")); + } else if (byte_total_on < byte_total_off) { + next_on_off = SOML_OFF; + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ byte_total_on < byte_total_off ==> SOML_OFF ]\n")); + } else { + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ stay at soml_last_state ]\n")); + next_on_off = p_dm_soml_table->soml_last_state; + } + + PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[ Final decisoin ] : ")); + phydm_soml_on_off(p_dm, next_on_off); + p_dm_soml_table->soml_last_state = next_on_off; + } + } void @@ -417,6 +427,24 @@ phydm_adaptive_soml_reset( } #endif /* end of CONFIG_ADAPTIVE_SOML*/ +void +phydm_soml_bytes_acq( + void *dm_void, + u8 rate_id, + u32 length +) +{ +#ifdef CONFIG_ADAPTIVE_SOML + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + struct adaptive_soml *dm_soml_table = &dm->dm_soml_table; + + if ((rate_id >= ODM_RATEMCS0) && (rate_id <= ODM_RATEMCS31)) + dm_soml_table->num_ht_bytes[rate_id - ODM_RATEMCS0] += length; + else if ((rate_id >= ODM_RATEVHTSS1MCS0) && (rate_id <= ODM_RATEVHTSS4MCS9)) + dm_soml_table->num_vht_bytes[rate_id - ODM_RATEVHTSS1MCS0] += length; + +#endif +} void phydm_adaptive_soml_timers( @@ -448,10 +476,6 @@ phydm_adaptive_soml_init( struct PHY_DM_STRUCT *p_dm = (struct PHY_DM_STRUCT *)p_dm_void; struct adaptive_soml *p_dm_soml_table = &p_dm->dm_soml_table; - if (!(p_dm->support_ability & ODM_BB_ADAPTIVE_SOML)) { - PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("[Return] Not Support Adaptive SOML\n")); - return; - } PHYDM_DBG(p_dm, DBG_ADPTV_SOML, ("phydm_adaptive_soml_init\n")); p_dm_soml_table->soml_state_cnt = 0; @@ -462,6 +486,8 @@ phydm_adaptive_soml_init( p_dm_soml_table->soml_counter = 0; p_dm_soml_table->soml_period = 4; p_dm_soml_table->soml_select = 0; + if (p_dm->support_ic_type & (ODM_RTL8197F | ODM_RTL8192F)) + odm_set_bb_reg(p_dm, 0x988, BIT(25), 1); #endif } @@ -498,9 +524,58 @@ phydm_adaptive_soml( phydm_soml_on_off(p_dm, SOML_OFF); return; } + if (p_dm->support_ic_type & ODM_ADAPTIVE_SOML_SUPPORT_IC) + phydm_adsl(p_dm); - phydm_adsl(p_dm); +#endif +} +void +phydm_enable_adaptive_soml( + void *dm_void +) +{ +#ifdef CONFIG_ADAPTIVE_SOML + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + + PHYDM_DBG(dm, DBG_ADPTV_SOML, ("[%s][Return!!!] enable Adaptive SOML\n\n", __func__)); + dm->support_ability |= ODM_BB_ADAPTIVE_SOML; + phydm_soml_on_off(dm, SOML_ON); +#endif +} + +void +phydm_stop_adaptive_soml( + void *dm_void +) +{ +#ifdef CONFIG_ADAPTIVE_SOML + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + + PHYDM_DBG(dm, DBG_ADPTV_SOML, ("[%s][Return!!!] Stop Adaptive SOML\n\n", __func__)); + dm->support_ability &= ~ODM_BB_ADAPTIVE_SOML; + phydm_soml_on_off(dm, SOML_ON); + +#endif +} + +void +phydm_adaptive_soml_para_set( + void *dm_void, + u8 train_num, + u8 intvl, + u8 period, + u8 delay_time +) +{ +#ifdef CONFIG_ADAPTIVE_SOML + struct PHY_DM_STRUCT *dm = (struct PHY_DM_STRUCT *)dm_void; + struct adaptive_soml *dm_soml_table = &dm->dm_soml_table; + + dm_soml_table->soml_train_num = train_num; + dm_soml_table->soml_intvl = intvl; + dm_soml_table->soml_period = period; + dm_soml_table->soml_delay_time = delay_time; #endif } diff --git a/hal/phydm/phydm_soml.h b/hal/phydm/phydm_soml.h index da86bd4..dcbf362 100644 --- a/hal/phydm/phydm_soml.h +++ b/hal/phydm/phydm_soml.h @@ -49,12 +49,10 @@ struct adaptive_soml { u32 pre_num_ht_bytes[HT_RATE_IDX]; u32 num_ht_bytes_on[HT_RATE_IDX]; u32 num_ht_bytes_off[HT_RATE_IDX]; - #if ODM_IC_11AC_SERIES_SUPPORT u32 num_vht_bytes[VHT_RATE_IDX]; u32 pre_num_vht_bytes[VHT_RATE_IDX]; u32 num_vht_bytes_on[VHT_RATE_IDX]; u32 num_vht_bytes_off[VHT_RATE_IDX]; - #endif #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) #if USE_WORKITEM @@ -62,14 +60,8 @@ struct adaptive_soml { #endif #endif struct timer_list phydm_adaptive_soml_timer; - }; -void -phydm_dynamicsoftmletting( - struct PHY_DM_STRUCT *p_dm -); - void phydm_soml_on_off( void *p_dm_void, @@ -87,6 +79,17 @@ phydm_adaptive_soml_workitem_callback( void *p_context ); +#elif (DM_ODM_SUPPORT_TYPE == ODM_CE) +void +phydm_adaptive_soml_callback( + void *dm_void +); + +void +phydm_adaptive_soml_workitem_callback( + void *context +); + #else void @@ -123,6 +126,19 @@ phydm_adaptive_soml_reset( ); #endif +#ifdef NEVER +void +phydm_dynamicsoftmletting( + struct PHY_DM_STRUCT *p_dm +); +#endif + +void +phydm_soml_bytes_acq( + void *dm_void, + u8 rate_id, + u32 length +); void phydm_adaptive_soml_timers( @@ -140,6 +156,25 @@ phydm_adaptive_soml( void *p_dm_void ); +void +phydm_enable_adaptive_soml( + void *dm_void +); + +void +phydm_stop_adaptive_soml( + void *dm_void +); + +void +phydm_adaptive_soml_para_set( + void *dm_void, + u8 train_num, + u8 intvl, + u8 period, + u8 delay_time +); + void phydm_init_soft_ml_setting( void *p_dm_void diff --git a/hal/phydm/txbf/halcomtxbf.c b/hal/phydm/txbf/halcomtxbf.c index 82844db..940f964 100644 --- a/hal/phydm/txbf/halcomtxbf.c +++ b/hal/phydm/txbf/halcomtxbf.c @@ -307,8 +307,9 @@ hal_com_txbf_clk_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_jaguar_clk_8812a(p_dm); + } } @@ -343,7 +344,6 @@ hal_com_txbf_rate_work_item_callback( else if (p_dm->support_ic_type & ODM_RTL8814A) { hal_txbf_8814a_set_ndpa_rate(p_dm, BW, rate); } - } diff --git a/hal/phydm/txbf/phydm_hal_txbf_api.h b/hal/phydm/txbf/phydm_hal_txbf_api.h index 96809e8..501c84d 100644 --- a/hal/phydm/txbf/phydm_hal_txbf_api.h +++ b/hal/phydm/txbf/phydm_hal_txbf_api.h @@ -55,7 +55,7 @@ phydm_get_mu_bfee_snding_decision( ); #else -#define phydm_get_beamforming_sounding_info(p_dm_void, troughput, total_bfee_num, tx_rate) +#define phydm_get_beamforming_sounding_info(p_dm_void, troughput, total_bfee_num, tx_rate) 0 #define phydm_get_ndpa_rate(p_dm_void) #define phydm_get_mu_bfee_snding_decision(p_dm_void, troughput) diff --git a/include/Hal8812PhyCfg.h b/include/Hal8812PhyCfg.h index bdd1e34..3fab1f2 100644 --- a/include/Hal8812PhyCfg.h +++ b/include/Hal8812PhyCfg.h @@ -135,7 +135,7 @@ PHY_SetSwChnlBWMode8812( VOID phy_set_rf_path_switch_8812a( - IN PADAPTER pAdapter, + IN struct PHY_DM_STRUCT *phydm, IN bool bMain ); diff --git a/include/autoconf.h b/include/autoconf.h index 7d87711..f377706 100644 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -349,8 +349,6 @@ #define DBG_TX_POWER_IDX 1 #define DBG_PG_TXPWR_READ 1 - - /* #define DBG_SHOW_MCUFWDL_BEFORE_51_ENABLE */ /* #define DBG_ROAMING_TEST */ diff --git a/include/cmn_info/rtw_sta_info.h b/include/cmn_info/rtw_sta_info.h index 4ad7b6c..790568d 100644 --- a/include/cmn_info/rtw_sta_info.h +++ b/include/cmn_info/rtw_sta_info.h @@ -106,7 +106,7 @@ enum bb_path { BB_PATH_ACD = (BB_PATH_A | BB_PATH_C | BB_PATH_D), BB_PATH_BCD = (BB_PATH_B | BB_PATH_C | BB_PATH_D), - BB_PATH_ABCD = (BB_PATH_A | BB_PATH_B | BB_PATH_D | BB_PATH_D), + BB_PATH_ABCD = (BB_PATH_A | BB_PATH_B | BB_PATH_C | BB_PATH_D), }; enum rf_path { @@ -155,6 +155,7 @@ struct rssi_info { u16 cck_sum_power; u8 is_send_rssi; u8 valid_bit; + s16 rssi_acc; /*accumulate RSSI for per packet MA sum*/ }; struct ra_sta_info { @@ -178,6 +179,12 @@ struct ra_sta_info { u64 ramask; }; +struct dtp_info { + u8 dyn_tx_power; /*Dynamic Tx power offset*/ + u8 sta_tx_high_power_lvl; + u8 sta_last_dtp_lvl; +}; + struct cmn_sta_info { u16 dm_ctrl; enum channel_width bw_mode; /*max bandwidth*/ @@ -196,6 +203,9 @@ struct cmn_sta_info { struct bf_cmn_info bf_info; #endif u8 sm_ps:2; + struct dtp_info dtp_stat; /*Dynamic Tx power offset*/ + u8 pw2cca_over_TH_cnt; + u8 total_pw2cca_cnt; }; struct phydm_phyinfo_struct { @@ -219,12 +229,16 @@ struct phydm_phyinfo_struct { u8 channel; /* channel number---*/ u8 is_mu_packet:1; /* is MU packet or not---boolean*/ u8 is_beamformed:1; /* BF packet---boolean*/ + u8 cnt_pw2cca; + u8 cnt_cca2agc_rdy; /*ODM_PHY_STATUS_NEW_TYPE_SUPPORT*/ }; struct phydm_perpkt_info_struct { u8 data_rate; u8 station_id; + u8 is_cck_rate: 1; + u8 rate_ss:3; /*spatial stream of data rate*/ u8 is_packet_match_bssid:1; /*boolean*/ u8 is_packet_to_self:1; /*boolean*/ u8 is_packet_beacon:1; /*boolean*/ diff --git a/include/rtw_pwrctrl.h b/include/rtw_pwrctrl.h index 85b3ea8..696ff70 100644 --- a/include/rtw_pwrctrl.h +++ b/include/rtw_pwrctrl.h @@ -463,6 +463,16 @@ struct pwrctrl_priv { u8 blpspg_info_up; #endif u8 current_lps_hw_port_id; + +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS + systime radio_on_start_time; + systime pwr_saving_start_time; + u32 pwr_saving_time; + u32 on_time; + u32 tx_time; + u32 rx_time; +#endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ + }; #define rtw_get_ips_mode_req(pwrctl) \ diff --git a/include/rtw_version.h b/include/rtw_version.h index 2f423f1..1780abe 100644 --- a/include/rtw_version.h +++ b/include/rtw_version.h @@ -1 +1 @@ -#define DRIVERVERSION "v5.2.20_25672.20171213" +#define DRIVERVERSION "v5.2.20.2_28373.20180619" diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index e2fa44e..9cbd901 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -7190,9 +7190,6 @@ static void rtw_cfg80211_preinit_wiphy(_adapter *adapter, struct wiphy *wiphy) #endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0)) -#if defined(CONFIG_NET_NS) - wiphy->flags |= WIPHY_FLAG_NETNS_OK; -#endif //CONFIG_NET_NS wiphy->flags |= WIPHY_FLAG_SUPPORTS_SEPARATE_DEFAULT_KEYS; #endif diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index b20ba44..ccba940 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1605,9 +1605,6 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name) rtw_init_netdev_name(ndev, name); _rtw_memcpy(ndev->dev_addr, adapter_mac_addr(adapter), ETH_ALEN); -#if defined(CONFIG_NET_NS) - dev_net_set(ndev, wiphy_net(adapter_to_wiphy(adapter))); -#endif //defined(CONFIG_NET_NS) /* Tell the network stack we exist */ @@ -3244,6 +3241,15 @@ netdev_open_normal_process: } #endif +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS + pwrctrlpriv->radio_on_start_time = rtw_get_current_time(); + pwrctrlpriv->pwr_saving_start_time = rtw_get_current_time(); + pwrctrlpriv->pwr_saving_time = 0; + pwrctrlpriv->on_time = 0; + pwrctrlpriv->tx_time = 0; + pwrctrlpriv->rx_time = 0; +#endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ + RTW_INFO("-871x_drv - drv_open, bup=%d\n", padapter->bup); return 0; diff --git a/os_dep/linux/rtw_cfgvendor.c b/os_dep/linux/rtw_cfgvendor.c index 79e3f98..c8ff983 100644 --- a/os_dep/linux/rtw_cfgvendor.c +++ b/os_dep/linux/rtw_cfgvendor.c @@ -209,22 +209,34 @@ static int rtw_cfgvendor_send_cmd_reply(struct wiphy *wiphy, return rtw_cfg80211_vendor_cmd_reply(skb); } -#define WIFI_FEATURE_INFRA 0x0001 /* Basic infrastructure mode */ -#define WIFI_FEATURE_INFRA_5G 0x0002 /* Support for 5 GHz Band */ -#define WIFI_FEATURE_HOTSPOT 0x0004 /* Support for GAS/ANQP */ -#define WIFI_FEATURE_P2P 0x0008 /* Wifi-Direct */ -#define WIFI_FEATURE_SOFT_AP 0x0010 /* Soft AP */ -#define WIFI_FEATURE_GSCAN 0x0020 /* Google-Scan APIs */ -#define WIFI_FEATURE_NAN 0x0040 /* Neighbor Awareness Networking */ -#define WIFI_FEATURE_D2D_RTT 0x0080 /* Device-to-device RTT */ -#define WIFI_FEATURE_D2AP_RTT 0x0100 /* Device-to-AP RTT */ -#define WIFI_FEATURE_BATCH_SCAN 0x0200 /* Batched Scan (legacy) */ -#define WIFI_FEATURE_PNO 0x0400 /* Preferred network offload */ -#define WIFI_FEATURE_ADDITIONAL_STA 0x0800 /* Support for two STAs */ -#define WIFI_FEATURE_TDLS 0x1000 /* Tunnel directed link setup */ -#define WIFI_FEATURE_TDLS_OFFCHANNEL 0x2000 /* Support for TDLS off channel */ -#define WIFI_FEATURE_EPR 0x4000 /* Enhanced power reporting */ -#define WIFI_FEATURE_AP_STA 0x8000 /* Support for AP STA Concurrency */ +/* Feature enums */ +#define WIFI_FEATURE_INFRA 0x0001 // Basic infrastructure mode +#define WIFI_FEATURE_INFRA_5G 0x0002 // Support for 5 GHz Band +#define WIFI_FEATURE_HOTSPOT 0x0004 // Support for GAS/ANQP +#define WIFI_FEATURE_P2P 0x0008 // Wifi-Direct +#define WIFI_FEATURE_SOFT_AP 0x0010 // Soft AP +#define WIFI_FEATURE_GSCAN 0x0020 // Google-Scan APIs +#define WIFI_FEATURE_NAN 0x0040 // Neighbor Awareness Networking +#define WIFI_FEATURE_D2D_RTT 0x0080 // Device-to-device RTT +#define WIFI_FEATURE_D2AP_RTT 0x0100 // Device-to-AP RTT +#define WIFI_FEATURE_BATCH_SCAN 0x0200 // Batched Scan (legacy) +#define WIFI_FEATURE_PNO 0x0400 // Preferred network offload +#define WIFI_FEATURE_ADDITIONAL_STA 0x0800 // Support for two STAs +#define WIFI_FEATURE_TDLS 0x1000 // Tunnel directed link setup +#define WIFI_FEATURE_TDLS_OFFCHANNEL 0x2000 // Support for TDLS off channel +#define WIFI_FEATURE_EPR 0x4000 // Enhanced power reporting +#define WIFI_FEATURE_AP_STA 0x8000 // Support for AP STA Concurrency +#define WIFI_FEATURE_LINK_LAYER_STATS 0x10000 // Link layer stats collection +#define WIFI_FEATURE_LOGGER 0x20000 // WiFi Logger +#define WIFI_FEATURE_HAL_EPNO 0x40000 // WiFi PNO enhanced +#define WIFI_FEATURE_RSSI_MONITOR 0x80000 // RSSI Monitor +#define WIFI_FEATURE_MKEEP_ALIVE 0x100000 // WiFi mkeep_alive +#define WIFI_FEATURE_CONFIG_NDO 0x200000 // ND offload configure +#define WIFI_FEATURE_TX_TRANSMIT_POWER 0x400000 // Capture Tx transmit power levels +#define WIFI_FEATURE_CONTROL_ROAMING 0x800000 // Enable/Disable firmware roaming +#define WIFI_FEATURE_IE_WHITELIST 0x1000000 // Support Probe IE white listing +#define WIFI_FEATURE_SCAN_RAND 0x2000000 // Support MAC & Probe Sequence Number randomization +// Add more features here #define MAX_FEATURE_SET_CONCURRRENT_GROUPS 3 @@ -239,14 +251,18 @@ int rtw_dev_get_feature_set(struct net_device *dev) feature_set |= WIFI_FEATURE_INFRA; - if (IS_8814A_SERIES(*hal_ver) || IS_8812_SERIES(*hal_ver) || - IS_8821_SERIES(*hal_ver)) +#ifdef CONFIG_IEEE80211_BAND_5GHZ + if (is_supported_5g(adapter_to_regsty(adapter)->wireless_mode)) feature_set |= WIFI_FEATURE_INFRA_5G; +#endif feature_set |= WIFI_FEATURE_P2P; feature_set |= WIFI_FEATURE_SOFT_AP; feature_set |= WIFI_FEATURE_ADDITIONAL_STA; +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS + feature_set |= WIFI_FEATURE_LINK_LAYER_STATS; +#endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ return feature_set; } @@ -362,8 +378,8 @@ exit: } #if defined(GSCAN_SUPPORT) && 0 -int wl_cfgvendor_send_hotlist_event(struct wiphy *wiphy, - struct net_device *dev, void *data, int len, wl_vendor_event_t event) +int rtw_cfgvendor_send_hotlist_event(struct wiphy *wiphy, + struct net_device *dev, void *data, int len, rtw_vendor_event_t event) { u16 kflags; const void *ptr; @@ -413,7 +429,7 @@ int wl_cfgvendor_send_hotlist_event(struct wiphy *wiphy, } -static int wl_cfgvendor_gscan_get_capabilities(struct wiphy *wiphy, +static int rtw_cfgvendor_gscan_get_capabilities(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; @@ -440,7 +456,7 @@ static int wl_cfgvendor_gscan_get_capabilities(struct wiphy *wiphy, return err; } -static int wl_cfgvendor_gscan_get_channel_list(struct wiphy *wiphy, +static int rtw_cfgvendor_gscan_get_channel_list(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0, type, band; @@ -487,7 +503,7 @@ exit: return err; } -static int wl_cfgvendor_gscan_get_batch_results(struct wiphy *wiphy, +static int rtw_cfgvendor_gscan_get_batch_results(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; @@ -571,7 +587,7 @@ static int wl_cfgvendor_gscan_get_batch_results(struct wiphy *wiphy, return rtw_cfg80211_vendor_cmd_reply(skb); } -static int wl_cfgvendor_initiate_gscan(struct wiphy *wiphy, +static int rtw_cfgvendor_initiate_gscan(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; @@ -601,7 +617,7 @@ static int wl_cfgvendor_initiate_gscan(struct wiphy *wiphy, } -static int wl_cfgvendor_enable_full_scan_result(struct wiphy *wiphy, +static int rtw_cfgvendor_enable_full_scan_result(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; @@ -625,7 +641,7 @@ static int wl_cfgvendor_enable_full_scan_result(struct wiphy *wiphy, return err; } -static int wl_cfgvendor_set_scan_cfg(struct wiphy *wiphy, +static int rtw_cfgvendor_set_scan_cfg(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; @@ -717,7 +733,7 @@ static int wl_cfgvendor_set_scan_cfg(struct wiphy *wiphy, } -static int wl_cfgvendor_hotlist_cfg(struct wiphy *wiphy, +static int rtw_cfgvendor_hotlist_cfg(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; @@ -783,7 +799,7 @@ exit: kfree(hotlist_params); return err; } -static int wl_cfgvendor_set_batch_scan_cfg(struct wiphy *wiphy, +static int rtw_cfgvendor_set_batch_scan_cfg(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0, tmp, type; @@ -820,7 +836,7 @@ static int wl_cfgvendor_set_batch_scan_cfg(struct wiphy *wiphy, return err; } -static int wl_cfgvendor_significant_change_cfg(struct wiphy *wiphy, +static int rtw_cfgvendor_significant_change_cfg(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; @@ -894,7 +910,7 @@ exit: #endif /* GSCAN_SUPPORT */ #if defined(RTT_SUPPORT) && 0 -void wl_cfgvendor_rtt_evt(void *ctx, void *rtt_data) +void rtw_cfgvendor_rtt_evt(void *ctx, void *rtt_data) { struct wireless_dev *wdev = (struct wireless_dev *)ctx; struct wiphy *wiphy; @@ -958,7 +974,7 @@ exit: return; } -static int wl_cfgvendor_rtt_set_config(struct wiphy *wiphy, struct wireless_dev *wdev, +static int rtw_cfgvendor_rtt_set_config(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0, rem, rem1, rem2, type; @@ -1045,7 +1061,7 @@ exit: return err; } -static int wl_cfgvendor_rtt_cancel_config(struct wiphy *wiphy, struct wireless_dev *wdev, +static int rtw_cfgvendor_rtt_cancel_config(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0, rem, type, target_cnt = 0; @@ -1085,7 +1101,7 @@ exit: kfree(mac_list); return err; } -static int wl_cfgvendor_rtt_get_capability(struct wiphy *wiphy, struct wireless_dev *wdev, +static int rtw_cfgvendor_rtt_get_capability(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; @@ -1107,57 +1123,174 @@ exit: } #endif /* RTT_SUPPORT */ -static int wl_cfgvendor_priv_string_handler(struct wiphy *wiphy, - struct wireless_dev *wdev, const void *data, int len) + +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS +enum { + LSTATS_SUBCMD_GET_INFO = ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START, + LSTATS_SUBCMD_SET_INFO, + LSTATS_SUBCMD_CLEAR_INFO, +}; +static void LinkLayerStats(_adapter *padapter) { - int err = 0; - u8 resp[1] = {'\0'}; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct recv_priv *precvpriv = &(padapter->recvpriv); + struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); + u32 ps_time, trx_total_time; + u64 tx_bytes, rx_bytes, trx_total_bytes = 0; + u64 tmp = 0; + + RTW_DBG("%s adapter type : %u\n", __func__, padapter->adapter_type); - RTW_PRINT(FUNC_NDEV_FMT" %s\n", FUNC_NDEV_ARG(wdev_to_ndev(wdev)), (char *)data); - err = rtw_cfgvendor_send_cmd_reply(wiphy, wdev_to_ndev(wdev), resp, 1); - if (unlikely(err)) - RTW_ERR(FUNC_NDEV_FMT"Vendor Command reply failed ret:%d\n" - , FUNC_NDEV_ARG(wdev_to_ndev(wdev)), err); + tx_bytes = 0; + rx_bytes = 0; + ps_time = 0; + trx_total_time = 0; - return err; -#if 0 - struct bcm_cfg80211 *cfg = wiphy_priv(wiphy); - int err = 0; - int data_len = 0; + if ( padapter->netif_up == _TRUE ) { - bzero(cfg->ioctl_buf, WLC_IOCTL_MAXLEN); + pwrpriv->on_time = rtw_get_passing_time_ms(pwrpriv->radio_on_start_time); - if (strncmp((char *)data, BRCM_VENDOR_SCMD_CAPA, strlen(BRCM_VENDOR_SCMD_CAPA)) == 0) { - err = wldev_iovar_getbuf(bcmcfg_to_prmry_ndev(cfg), "cap", NULL, 0, - cfg->ioctl_buf, WLC_IOCTL_MAXLEN, &cfg->ioctl_buf_sync); - if (unlikely(err)) { - WL_ERR(("error (%d)\n", err)); - return err; + if (rtw_mi_check_fwstate(padapter, _FW_LINKED)) { + if ( pwrpriv->bpower_saving == _TRUE ) { + pwrpriv->pwr_saving_time += rtw_get_passing_time_ms(pwrpriv->pwr_saving_start_time); + pwrpriv->pwr_saving_start_time = rtw_get_current_time(); + } + } else { +#ifdef CONFIG_IPS + if ( pwrpriv->bpower_saving == _TRUE ) { + pwrpriv->pwr_saving_time += rtw_get_passing_time_ms(pwrpriv->pwr_saving_start_time); + pwrpriv->pwr_saving_start_time = rtw_get_current_time(); + } +#else + pwrpriv->pwr_saving_time = pwrpriv->on_time; +#endif } - data_len = strlen(cfg->ioctl_buf); - cfg->ioctl_buf[data_len] = '\0'; + + ps_time = pwrpriv->pwr_saving_time; + + /* Deviation caused by caculation start time */ + if ( ps_time > pwrpriv->on_time ) + ps_time = pwrpriv->on_time; + + tx_bytes = pdvobjpriv->traffic_stat.last_tx_bytes; + rx_bytes = pdvobjpriv->traffic_stat.last_rx_bytes; + trx_total_bytes = tx_bytes + rx_bytes; + + trx_total_time = pwrpriv->on_time - ps_time; + + if ( trx_total_bytes == 0) { + pwrpriv->tx_time = 0; + pwrpriv->rx_time = 0; + } else { + + /* tx_time = (trx_total_time * tx_total_bytes) / trx_total_bytes; */ + /* rx_time = (trx_total_time * rx_total_bytes) / trx_total_bytes; */ + + tmp = (tx_bytes * trx_total_time); + tmp = rtw_division64(tmp, trx_total_bytes); + pwrpriv->tx_time = tmp; + + tmp = (rx_bytes * trx_total_time); + tmp = rtw_division64(tmp, trx_total_bytes); + pwrpriv->rx_time = tmp; + + } + + } + else { + pwrpriv->on_time = 0; + pwrpriv->tx_time = 0; + pwrpriv->rx_time = 0; } - err = rtw_cfgvendor_send_cmd_reply(wiphy, bcmcfg_to_prmry_ndev(cfg), - cfg->ioctl_buf, data_len + 1); - if (unlikely(err)) - WL_ERR(("Vendor Command reply failed ret:%d\n", err)); - else - WL_INFORM(("Vendor Command reply sent successfully!\n")); +#ifdef CONFIG_RTW_WIFI_HAL_DEBUG + RTW_INFO("- tx_bytes : %llu rx_bytes : %llu total bytes : %llu\n", tx_bytes, rx_bytes, trx_total_bytes); + RTW_INFO("- netif_up=%s, on_time : %u ms\n", padapter->netif_up ? "1":"0", pwrpriv->on_time); + RTW_INFO("- pwr_saving_time : %u (%u) ms\n", pwrpriv->pwr_saving_time, ps_time); + RTW_INFO("- trx_total_time : %u ms\n", trx_total_time); + RTW_INFO("- tx_time : %u ms\n", pwrpriv->tx_time); + RTW_INFO("- rx_time : %u ms\n", pwrpriv->rx_time); +#endif /* CONFIG_RTW_WIFI_HAL_DEBUG */ - return err; -#endif } +#define DUMMY_TIME_STATICS 99 +static int rtw_cfgvendor_lstats_get_info(struct wiphy *wiphy, + struct wireless_dev *wdev, const void *data, int len) +{ + int err = 0; + _adapter *padapter = GET_PRIMARY_ADAPTER(wiphy_to_adapter(wiphy)); + struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); + wifi_radio_stat *radio; + wifi_iface_stat *iface; + char *output; + + output = rtw_malloc(sizeof(wifi_radio_stat) + sizeof(wifi_iface_stat)+1); + if (output == NULL) { + RTW_DBG("Allocate lstats info buffer fail!\n"); +} + + radio = (wifi_radio_stat *)output; + + radio->num_channels = 0; + radio->radio = 1; + + /* to get on_time, tx_time, rx_time */ + LinkLayerStats(padapter); + + radio->on_time = pwrpriv->on_time; + radio->tx_time = pwrpriv->tx_time; + radio->rx_time = pwrpriv->rx_time; + + radio->num_tx_levels = 1; + radio->tx_time_per_levels = NULL; + radio->tx_time_per_levels = (u32*)(output+sizeof(wifi_radio_stat) + sizeof(wifi_iface_stat)); + *(radio->tx_time_per_levels) = DUMMY_TIME_STATICS; + + radio->on_time_scan = 0; + radio->on_time_nbd = 0; + radio->on_time_gscan = 0; + radio->on_time_pno_scan = 0; + radio->on_time_hs20 = 0; + #ifdef CONFIG_RTW_WIFI_HAL_DEBUG + RTW_INFO("==== %s ====\n", __func__); + RTW_INFO("radio->radio : %d\n", (radio->radio)); + RTW_INFO("pwrpriv->on_time : %u ms\n", (pwrpriv->on_time)); + RTW_INFO("pwrpriv->tx_time : %u ms\n", (pwrpriv->tx_time)); + RTW_INFO("pwrpriv->rx_time : %u ms\n", (pwrpriv->rx_time)); + RTW_INFO("radio->on_time : %u ms\n", (radio->on_time)); + RTW_INFO("radio->tx_time : %u ms\n", (radio->tx_time)); + RTW_INFO("radio->rx_time : %u ms\n", (radio->rx_time)); + RTW_INFO("radio->tx_time_per_levels value : %u ms\n", *(radio->tx_time_per_levels)); + #endif /* CONFIG_RTW_WIFI_HAL_DEBUG */ + + RTW_DBG(FUNC_NDEV_FMT" %s\n", FUNC_NDEV_ARG(wdev_to_ndev(wdev)), (char*)data); + err = rtw_cfgvendor_send_cmd_reply(wiphy, wdev_to_ndev(wdev), + output, sizeof(wifi_iface_stat) + sizeof(wifi_radio_stat)+1); + if (unlikely(err)) + RTW_ERR(FUNC_NDEV_FMT"Vendor Command reply failed ret:%d \n" + , FUNC_NDEV_ARG(wdev_to_ndev(wdev)), err); + rtw_mfree(output, sizeof(wifi_iface_stat) + sizeof(wifi_radio_stat)+1); + return err; +} +static int rtw_cfgvendor_lstats_set_info(struct wiphy *wiphy, + struct wireless_dev *wdev, const void *data, int len) +{ + int err = 0; + RTW_INFO("%s\n", __func__); + return err; +} +static int rtw_cfgvendor_lstats_clear_info(struct wiphy *wiphy, + struct wireless_dev *wdev, const void *data, int len) +{ + int err = 0; + RTW_INFO("%s\n", __func__); + return err; +} +#endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ + static const struct wiphy_vendor_command rtw_vendor_cmds[] = { - { - { - .vendor_id = OUI_BRCM, - .subcmd = BRCM_VENDOR_SCMD_PRIV_STR - }, - .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_priv_string_handler - }, #if defined(GSCAN_SUPPORT) && 0 { { @@ -1165,7 +1298,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = GSCAN_SUBCMD_GET_CAPABILITIES }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_gscan_get_capabilities + .doit = rtw_cfgvendor_gscan_get_capabilities }, { { @@ -1173,7 +1306,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = GSCAN_SUBCMD_SET_CONFIG }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_set_scan_cfg + .doit = rtw_cfgvendor_set_scan_cfg }, { { @@ -1181,7 +1314,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = GSCAN_SUBCMD_SET_SCAN_CONFIG }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_set_batch_scan_cfg + .doit = rtw_cfgvendor_set_batch_scan_cfg }, { { @@ -1189,7 +1322,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = GSCAN_SUBCMD_ENABLE_GSCAN }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_initiate_gscan + .doit = rtw_cfgvendor_initiate_gscan }, { { @@ -1197,7 +1330,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_enable_full_scan_result + .doit = rtw_cfgvendor_enable_full_scan_result }, { { @@ -1205,7 +1338,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = GSCAN_SUBCMD_SET_HOTLIST }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_hotlist_cfg + .doit = rtw_cfgvendor_hotlist_cfg }, { { @@ -1213,7 +1346,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_significant_change_cfg + .doit = rtw_cfgvendor_significant_change_cfg }, { { @@ -1221,7 +1354,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = GSCAN_SUBCMD_GET_SCAN_RESULTS }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_gscan_get_batch_results + .doit = rtw_cfgvendor_gscan_get_batch_results }, { { @@ -1229,7 +1362,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = GSCAN_SUBCMD_GET_CHANNEL_LIST }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_gscan_get_channel_list + .doit = rtw_cfgvendor_gscan_get_channel_list }, #endif /* GSCAN_SUPPORT */ #if defined(RTT_SUPPORT) && 0 @@ -1239,7 +1372,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = RTT_SUBCMD_SET_CONFIG }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_rtt_set_config + .doit = rtw_cfgvendor_rtt_set_config }, { { @@ -1247,7 +1380,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = RTT_SUBCMD_CANCEL_CONFIG }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_rtt_cancel_config + .doit = rtw_cfgvendor_rtt_cancel_config }, { { @@ -1255,13 +1388,39 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { .subcmd = RTT_SUBCMD_GETCAPABILITY }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, - .doit = wl_cfgvendor_rtt_get_capability + .doit = rtw_cfgvendor_rtt_get_capability }, #endif /* RTT_SUPPORT */ +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS { { .vendor_id = OUI_GOOGLE, - .subcmd = ANDR_WIFI_SUBCMD_GET_FEATURE_SET + .subcmd = LSTATS_SUBCMD_GET_INFO + }, + .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, + .doit = rtw_cfgvendor_lstats_get_info + }, + { + { + .vendor_id = OUI_GOOGLE, + .subcmd = LSTATS_SUBCMD_SET_INFO + }, + .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, + .doit = rtw_cfgvendor_lstats_set_info + }, + { + { + .vendor_id = OUI_GOOGLE, + .subcmd = LSTATS_SUBCMD_CLEAR_INFO + }, + .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, + .doit = rtw_cfgvendor_lstats_clear_info + }, +#endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ + { + { + .vendor_id = OUI_GOOGLE, + .subcmd = WIFI_SUBCMD_GET_FEATURE_SET }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, .doit = rtw_cfgvendor_get_feature_set @@ -1269,7 +1428,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { { { .vendor_id = OUI_GOOGLE, - .subcmd = ANDR_WIFI_SUBCMD_GET_FEATURE_SET_MATRIX + .subcmd = WIFI_SUBCMD_GET_FEATURE_SET_MATRIX }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, .doit = rtw_cfgvendor_get_feature_set_matrix @@ -1277,20 +1436,18 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { }; static const struct nl80211_vendor_cmd_info rtw_vendor_events[] = { - { OUI_BRCM, BRCM_VENDOR_EVENT_UNSPEC }, - { OUI_BRCM, BRCM_VENDOR_EVENT_PRIV_STR }, #if defined(GSCAN_SUPPORT) && 0 - { OUI_GOOGLE, GOOGLE_GSCAN_SIGNIFICANT_EVENT }, - { OUI_GOOGLE, GOOGLE_GSCAN_GEOFENCE_FOUND_EVENT }, - { OUI_GOOGLE, GOOGLE_GSCAN_BATCH_SCAN_EVENT }, - { OUI_GOOGLE, GOOGLE_SCAN_FULL_RESULTS_EVENT }, + { OUI_GOOGLE, GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS }, + { OUI_GOOGLE, GSCAN_EVENT_HOTLIST_RESULTS_FOUND }, + { OUI_GOOGLE, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE }, + { OUI_GOOGLE, GSCAN_EVENT_FULL_SCAN_RESULTS }, #endif /* GSCAN_SUPPORT */ #if defined(RTT_SUPPORT) && 0 - { OUI_GOOGLE, GOOGLE_RTT_COMPLETE_EVENT }, + { OUI_GOOGLE, RTT_EVENT_COMPLETE }, #endif /* RTT_SUPPORT */ #if defined(GSCAN_SUPPORT) && 0 - { OUI_GOOGLE, GOOGLE_SCAN_COMPLETE_EVENT }, - { OUI_GOOGLE, GOOGLE_GSCAN_GEOFENCE_LOST_EVENT } + { OUI_GOOGLE, GSCAN_EVENT_COMPLETE_SCAN }, + { OUI_GOOGLE, GSCAN_EVENT_HOTLIST_RESULTS_LOST } #endif /* GSCAN_SUPPORT */ }; diff --git a/os_dep/linux/rtw_cfgvendor.h b/os_dep/linux/rtw_cfgvendor.h index 9f36e9f..d5157b3 100644 --- a/os_dep/linux/rtw_cfgvendor.h +++ b/os_dep/linux/rtw_cfgvendor.h @@ -16,9 +16,7 @@ #ifndef _RTW_CFGVENDOR_H_ #define _RTW_CFGVENDOR_H_ -#define OUI_BRCM 0x001018 #define OUI_GOOGLE 0x001A11 -#define BRCM_VENDOR_SUBCMD_PRIV_STR 1 #define ATTRIBUTE_U32_LEN (NLA_HDRLEN + 4) #define VENDOR_ID_OVERHEAD ATTRIBUTE_U32_LEN #define VENDOR_SUBCMD_OVERHEAD ATTRIBUTE_U32_LEN @@ -39,54 +37,91 @@ VENDOR_SUBCMD_OVERHEAD + \ VENDOR_DATA_OVERHEAD) typedef enum { - /* don't use 0 as a valid subcommand */ - VENDOR_NL80211_SUBCMD_UNSPECIFIED, + /* don't use 0 as a valid subcommand */ + VENDOR_NL80211_SUBCMD_UNSPECIFIED, - /* define all vendor startup commands between 0x0 and 0x0FFF */ - VENDOR_NL80211_SUBCMD_RANGE_START = 0x0001, - VENDOR_NL80211_SUBCMD_RANGE_END = 0x0FFF, + /* define all vendor startup commands between 0x0 and 0x0FFF */ + VENDOR_NL80211_SUBCMD_RANGE_START = 0x0001, + VENDOR_NL80211_SUBCMD_RANGE_END = 0x0FFF, - /* define all GScan related commands between 0x1000 and 0x10FF */ - ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START = 0x1000, - ANDROID_NL80211_SUBCMD_GSCAN_RANGE_END = 0x10FF, + /* define all GScan related commands between 0x1000 and 0x10FF */ + ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START = 0x1000, + ANDROID_NL80211_SUBCMD_GSCAN_RANGE_END = 0x10FF, - /* define all NearbyDiscovery related commands between 0x1100 and 0x11FF */ - ANDROID_NL80211_SUBCMD_NBD_RANGE_START = 0x1100, - ANDROID_NL80211_SUBCMD_NBD_RANGE_END = 0x11FF, + /* define all NearbyDiscovery related commands between 0x1100 and 0x11FF */ + ANDROID_NL80211_SUBCMD_NBD_RANGE_START = 0x1100, + ANDROID_NL80211_SUBCMD_NBD_RANGE_END = 0x11FF, - /* define all RTT related commands between 0x1100 and 0x11FF */ - ANDROID_NL80211_SUBCMD_RTT_RANGE_START = 0x1100, - ANDROID_NL80211_SUBCMD_RTT_RANGE_END = 0x11FF, + /* define all RTT related commands between 0x1100 and 0x11FF */ + ANDROID_NL80211_SUBCMD_RTT_RANGE_START = 0x1100, + ANDROID_NL80211_SUBCMD_RTT_RANGE_END = 0x11FF, - ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START = 0x1200, - ANDROID_NL80211_SUBCMD_LSTATS_RANGE_END = 0x12FF, + ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START = 0x1200, + ANDROID_NL80211_SUBCMD_LSTATS_RANGE_END = 0x12FF, - ANDROID_NL80211_SUBCMD_TDLS_RANGE_START = 0x1300, - ANDROID_NL80211_SUBCMD_TDLS_RANGE_END = 0x13FF, - /* This is reserved for future usage */ + /* define all Logger related commands between 0x1400 and 0x14FF */ + ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START = 0x1400, + ANDROID_NL80211_SUBCMD_DEBUG_RANGE_END = 0x14FF, + + /* define all wifi offload related commands between 0x1600 and 0x16FF */ + ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START = 0x1600, + ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_END = 0x16FF, + + /* define all NAN related commands between 0x1700 and 0x17FF */ + ANDROID_NL80211_SUBCMD_NAN_RANGE_START = 0x1700, + ANDROID_NL80211_SUBCMD_NAN_RANGE_END = 0x17FF, + + /* define all Android Packet Filter related commands between 0x1800 and 0x18FF */ + ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START = 0x1800, + ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_END = 0x18FF, + + /* This is reserved for future usage */ } ANDROID_VENDOR_SUB_COMMAND; -enum wl_vendor_subcmd { - BRCM_VENDOR_SCMD_UNSPEC, - BRCM_VENDOR_SCMD_PRIV_STR, - GSCAN_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START, - GSCAN_SUBCMD_SET_CONFIG, - GSCAN_SUBCMD_SET_SCAN_CONFIG, - GSCAN_SUBCMD_ENABLE_GSCAN, - GSCAN_SUBCMD_GET_SCAN_RESULTS, - GSCAN_SUBCMD_SCAN_RESULTS, - GSCAN_SUBCMD_SET_HOTLIST, - GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG, - GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS, - GSCAN_SUBCMD_GET_CHANNEL_LIST, - ANDR_WIFI_SUBCMD_GET_FEATURE_SET, - ANDR_WIFI_SUBCMD_GET_FEATURE_SET_MATRIX, +enum rtw_vendor_subcmd { + GSCAN_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START, + + GSCAN_SUBCMD_SET_CONFIG, /* 0x1001 */ + + GSCAN_SUBCMD_SET_SCAN_CONFIG, /* 0x1002 */ + GSCAN_SUBCMD_ENABLE_GSCAN, /* 0x1003 */ + GSCAN_SUBCMD_GET_SCAN_RESULTS, /* 0x1004 */ + GSCAN_SUBCMD_SCAN_RESULTS, /* 0x1005 */ + + GSCAN_SUBCMD_SET_HOTLIST, /* 0x1006 */ + + GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG, /* 0x1007 */ + GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS, /* 0x1008 */ + GSCAN_SUBCMD_GET_CHANNEL_LIST, /* 0x1009 */ + + WIFI_SUBCMD_GET_FEATURE_SET, /* 0x100A */ + WIFI_SUBCMD_GET_FEATURE_SET_MATRIX, /* 0x100B */ + WIFI_SUBCMD_SET_PNO_RANDOM_MAC_OUI, /* 0x100C */ + WIFI_SUBCMD_NODFS_SET, /* 0x100D */ + WIFI_SUBCMD_SET_COUNTRY_CODE, /* 0x100E */ + /* Add more sub commands here */ + GSCAN_SUBCMD_SET_EPNO_SSID, /* 0x100F */ + + WIFI_SUBCMD_SET_SSID_WHITE_LIST, /* 0x1010 */ + WIFI_SUBCMD_SET_ROAM_PARAMS, /* 0x1011 */ + WIFI_SUBCMD_ENABLE_LAZY_ROAM, /* 0x1012 */ + WIFI_SUBCMD_SET_BSSID_PREF, /* 0x1013 */ + WIFI_SUBCMD_SET_BSSID_BLACKLIST, /* 0x1014 */ + + GSCAN_SUBCMD_ANQPO_CONFIG, /* 0x1015 */ + WIFI_SUBCMD_SET_RSSI_MONITOR, /* 0x1016 */ + WIFI_SUBCMD_CONFIG_ND_OFFLOAD, /* 0x1017 */ + /* Add more sub commands here */ + + GSCAN_SUBCMD_MAX, + RTT_SUBCMD_SET_CONFIG = ANDROID_NL80211_SUBCMD_RTT_RANGE_START, RTT_SUBCMD_CANCEL_CONFIG, RTT_SUBCMD_GETCAPABILITY, - /* Add more sub commands here */ - VENDOR_SUBCMD_MAX + + APF_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START, + APF_SUBCMD_SET_FILTER, }; enum gscan_attributes { @@ -178,24 +213,29 @@ enum rtt_attributes { RTT_ATTRIBUTE_TARGET_NUM_RETRY }; -typedef enum wl_vendor_event { - BRCM_VENDOR_EVENT_UNSPEC, - BRCM_VENDOR_EVENT_PRIV_STR, - GOOGLE_GSCAN_SIGNIFICANT_EVENT, - GOOGLE_GSCAN_GEOFENCE_FOUND_EVENT, - GOOGLE_GSCAN_BATCH_SCAN_EVENT, - GOOGLE_SCAN_FULL_RESULTS_EVENT, - GOOGLE_RTT_COMPLETE_EVENT, - GOOGLE_SCAN_COMPLETE_EVENT, - GOOGLE_GSCAN_GEOFENCE_LOST_EVENT -} wl_vendor_event_t; +typedef enum rtw_vendor_event { + RTK_RESERVED1, + RTK_RESERVED2, + GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS , + GSCAN_EVENT_HOTLIST_RESULTS_FOUND, + GSCAN_EVENT_SCAN_RESULTS_AVAILABLE, + GSCAN_EVENT_FULL_SCAN_RESULTS, + RTT_EVENT_COMPLETE, + GSCAN_EVENT_COMPLETE_SCAN, + GSCAN_EVENT_HOTLIST_RESULTS_LOST, + GSCAN_EVENT_EPNO_EVENT, + GOOGLE_DEBUG_RING_EVENT, + GOOGLE_DEBUG_MEM_DUMP_EVENT, + GSCAN_EVENT_ANQPO_HOTSPOT_MATCH, + GOOGLE_RSSI_MONITOR_EVENT +} rtw_vendor_event_t; enum andr_wifi_feature_set_attr { ANDR_WIFI_ATTRIBUTE_NUM_FEATURE_SET, ANDR_WIFI_ATTRIBUTE_FEATURE_SET }; -typedef enum wl_vendor_gscan_attribute { +typedef enum rtw_vendor_gscan_attribute { ATTR_START_GSCAN, ATTR_STOP_GSCAN, ATTR_SET_SCAN_BATCH_CFG_ID, /* set batch scan params */ @@ -205,7 +245,7 @@ typedef enum wl_vendor_gscan_attribute { ATTR_GET_GSCAN_CAPABILITIES_ID, /* Add more sub commands here */ ATTR_GSCAN_MAX -} wl_vendor_gscan_attribute_t; +} rtw_vendor_gscan_attribute_t; typedef enum gscan_batch_attribute { ATTR_GSCAN_BATCH_BESTN, @@ -222,9 +262,288 @@ typedef enum gscan_complete_event { WIFI_SCAN_BUFFER_FULL, WIFI_SCAN_COMPLETE } gscan_complete_event_t; +/* wifi_hal.h */ +/* WiFi Common definitions */ +typedef unsigned char byte; +typedef int wifi_request_id; +typedef int wifi_channel; // indicates channel frequency in MHz +typedef int wifi_rssi; +typedef byte mac_addr[6]; +typedef byte oui[3]; +typedef int64_t wifi_timestamp; // In microseconds (us) +typedef int64_t wifi_timespan; // In picoseconds (ps) + +struct wifi_info; +struct wifi_interface_info; +typedef struct wifi_info *wifi_handle; +typedef struct wifi_interface_info *wifi_interface_handle; + +/* channel operating width */ +typedef enum { + WIFI_CHAN_WIDTH_20 = 0, + WIFI_CHAN_WIDTH_40 = 1, + WIFI_CHAN_WIDTH_80 = 2, + WIFI_CHAN_WIDTH_160 = 3, + WIFI_CHAN_WIDTH_80P80 = 4, + WIFI_CHAN_WIDTH_5 = 5, + WIFI_CHAN_WIDTH_10 = 6, + WIFI_CHAN_WIDTH_INVALID = -1 +} wifi_channel_width; + +typedef int wifi_radio; + +typedef struct { + wifi_channel_width width; + int center_frequency0; + int center_frequency1; + int primary_frequency; +} wifi_channel_spec; + +typedef enum { + WIFI_SUCCESS = 0, + WIFI_ERROR_NONE = 0, + WIFI_ERROR_UNKNOWN = -1, + WIFI_ERROR_UNINITIALIZED = -2, + WIFI_ERROR_NOT_SUPPORTED = -3, + WIFI_ERROR_NOT_AVAILABLE = -4, // Not available right now, but try later + WIFI_ERROR_INVALID_ARGS = -5, + WIFI_ERROR_INVALID_REQUEST_ID = -6, + WIFI_ERROR_TIMED_OUT = -7, + WIFI_ERROR_TOO_MANY_REQUESTS = -8, // Too many instances of this request + WIFI_ERROR_OUT_OF_MEMORY = -9, + WIFI_ERROR_BUSY = -10, +} wifi_error; + +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS +#define STATS_MAJOR_VERSION 1 +#define STATS_MINOR_VERSION 0 +#define STATS_MICRO_VERSION 0 + +typedef enum { + WIFI_DISCONNECTED = 0, + WIFI_AUTHENTICATING = 1, + WIFI_ASSOCIATING = 2, + WIFI_ASSOCIATED = 3, + WIFI_EAPOL_STARTED = 4, // if done by firmware/driver + WIFI_EAPOL_COMPLETED = 5, // if done by firmware/driver +} wifi_connection_state; + +typedef enum { + WIFI_ROAMING_IDLE = 0, + WIFI_ROAMING_ACTIVE = 1, +} wifi_roam_state; + +typedef enum { + WIFI_INTERFACE_STA = 0, + WIFI_INTERFACE_SOFTAP = 1, + WIFI_INTERFACE_IBSS = 2, + WIFI_INTERFACE_P2P_CLIENT = 3, + WIFI_INTERFACE_P2P_GO = 4, + WIFI_INTERFACE_NAN = 5, + WIFI_INTERFACE_MESH = 6, + WIFI_INTERFACE_UNKNOWN = -1 + } wifi_interface_mode; + +#define WIFI_CAPABILITY_QOS 0x00000001 // set for QOS association +#define WIFI_CAPABILITY_PROTECTED 0x00000002 // set for protected association (802.11 beacon frame control protected bit set) +#define WIFI_CAPABILITY_INTERWORKING 0x00000004 // set if 802.11 Extended Capabilities element interworking bit is set +#define WIFI_CAPABILITY_HS20 0x00000008 // set for HS20 association +#define WIFI_CAPABILITY_SSID_UTF8 0x00000010 // set is 802.11 Extended Capabilities element UTF-8 SSID bit is set +#define WIFI_CAPABILITY_COUNTRY 0x00000020 // set is 802.11 Country Element is present + +typedef struct { + wifi_interface_mode mode; // interface mode + u8 mac_addr[6]; // interface mac address (self) + wifi_connection_state state; // connection state (valid for STA, CLI only) + wifi_roam_state roaming; // roaming state + u32 capabilities; // WIFI_CAPABILITY_XXX (self) + u8 ssid[33]; // null terminated SSID + u8 bssid[6]; // bssid + u8 ap_country_str[3]; // country string advertised by AP + u8 country_str[3]; // country string for this association +} wifi_interface_link_layer_info; + +/* channel information */ +typedef struct { + wifi_channel_width width; // channel width (20, 40, 80, 80+80, 160) + wifi_channel center_freq; // primary 20 MHz channel + wifi_channel center_freq0; // center frequency (MHz) first segment + wifi_channel center_freq1; // center frequency (MHz) second segment +} wifi_channel_info; + +/* wifi rate */ +typedef struct { + u32 preamble :3; // 0: OFDM, 1:CCK, 2:HT 3:VHT 4..7 reserved + u32 nss :2; // 0:1x1, 1:2x2, 3:3x3, 4:4x4 + u32 bw :3; // 0:20MHz, 1:40Mhz, 2:80Mhz, 3:160Mhz + u32 rateMcsIdx :8; // OFDM/CCK rate code would be as per ieee std in the units of 0.5mbps + // HT/VHT it would be mcs index + u32 reserved :16; // reserved + u32 bitrate; // units of 100 Kbps +} wifi_rate; + +/* channel statistics */ +typedef struct { + wifi_channel_info channel; // channel + u32 on_time; // msecs the radio is awake (32 bits number accruing over time) + u32 cca_busy_time; // msecs the CCA register is busy (32 bits number accruing over time) +} wifi_channel_stat; + +// Max number of tx power levels. The actual number vary per device and is specified by |num_tx_levels| +#define RADIO_STAT_MAX_TX_LEVELS 256 + +/* radio statistics */ +typedef struct { + wifi_radio radio; // wifi radio (if multiple radio supported) + u32 on_time; // msecs the radio is awake (32 bits number accruing over time) + u32 tx_time; // msecs the radio is transmitting (32 bits number accruing over time) + u32 num_tx_levels; // number of radio transmit power levels + u32* tx_time_per_levels; // pointer to an array of radio transmit per power levels in + // msecs accured over time + u32 rx_time; // msecs the radio is in active receive (32 bits number accruing over time) + u32 on_time_scan; // msecs the radio is awake due to all scan (32 bits number accruing over time) + u32 on_time_nbd; // msecs the radio is awake due to NAN (32 bits number accruing over time) + u32 on_time_gscan; // msecs the radio is awake due to G?scan (32 bits number accruing over time) + u32 on_time_roam_scan; // msecs the radio is awake due to roam?scan (32 bits number accruing over time) + u32 on_time_pno_scan; // msecs the radio is awake due to PNO scan (32 bits number accruing over time) + u32 on_time_hs20; // msecs the radio is awake due to HS2.0 scans and GAS exchange (32 bits number accruing over time) + u32 num_channels; // number of channels + wifi_channel_stat channels[]; // channel statistics +} wifi_radio_stat; + +/** + * Packet statistics reporting by firmware is performed on MPDU basi (i.e. counters increase by 1 for each MPDU) + * As well, "data packet" in associated comments, shall be interpreted as 802.11 data packet, + * that is, 802.11 frame control subtype == 2 and excluding management and control frames. + * + * As an example, in the case of transmission of an MSDU fragmented in 16 MPDUs which are transmitted + * OTA in a 16 units long a-mpdu, for which a block ack is received with 5 bits set: + * tx_mpdu : shall increase by 5 + * retries : shall increase by 16 + * tx_ampdu : shall increase by 1 + * data packet counters shall not increase regardless of the number of BAR potentially sent by device for this a-mpdu + * data packet counters shall not increase regardless of the number of BA received by device for this a-mpdu + * + * For each subsequent retransmission of the 11 remaining non ACK'ed mpdus + * (regardless of the fact that they are transmitted in a-mpdu or not) + * retries : shall increase by 1 + * + * If no subsequent BA or ACK are received from AP, until packet lifetime expires for those 11 packet that were not ACK'ed + * mpdu_lost : shall increase by 11 + */ + +/* per rate statistics */ +typedef struct { + wifi_rate rate; // rate information + u32 tx_mpdu; // number of successfully transmitted data pkts (ACK rcvd) + u32 rx_mpdu; // number of received data pkts + u32 mpdu_lost; // number of data packet losses (no ACK) + u32 retries; // total number of data pkt retries + u32 retries_short; // number of short data pkt retries + u32 retries_long; // number of long data pkt retries +} wifi_rate_stat; + +/* access categories */ +typedef enum { + WIFI_AC_VO = 0, + WIFI_AC_VI = 1, + WIFI_AC_BE = 2, + WIFI_AC_BK = 3, + WIFI_AC_MAX = 4, +} wifi_traffic_ac; + +/* wifi peer type */ +typedef enum +{ + WIFI_PEER_STA, + WIFI_PEER_AP, + WIFI_PEER_P2P_GO, + WIFI_PEER_P2P_CLIENT, + WIFI_PEER_NAN, + WIFI_PEER_TDLS, + WIFI_PEER_INVALID, +} wifi_peer_type; + +/* per peer statistics */ +typedef struct { + wifi_peer_type type; // peer type (AP, TDLS, GO etc.) + u8 peer_mac_address[6]; // mac address + u32 capabilities; // peer WIFI_CAPABILITY_XXX + u32 num_rate; // number of rates + wifi_rate_stat rate_stats[]; // per rate statistics, number of entries = num_rate +} wifi_peer_info; + +/* Per access category statistics */ +typedef struct { + wifi_traffic_ac ac; // access category (VI, VO, BE, BK) + u32 tx_mpdu; // number of successfully transmitted unicast data pkts (ACK rcvd) + u32 rx_mpdu; // number of received unicast data packets + u32 tx_mcast; // number of succesfully transmitted multicast data packets + // STA case: implies ACK received from AP for the unicast packet in which mcast pkt was sent + u32 rx_mcast; // number of received multicast data packets + u32 rx_ampdu; // number of received unicast a-mpdus; support of this counter is optional + u32 tx_ampdu; // number of transmitted unicast a-mpdus; support of this counter is optional + u32 mpdu_lost; // number of data pkt losses (no ACK) + u32 retries; // total number of data pkt retries + u32 retries_short; // number of short data pkt retries + u32 retries_long; // number of long data pkt retries + u32 contention_time_min; // data pkt min contention time (usecs) + u32 contention_time_max; // data pkt max contention time (usecs) + u32 contention_time_avg; // data pkt avg contention time (usecs) + u32 contention_num_samples; // num of data pkts used for contention statistics +} wifi_wmm_ac_stat; + +/* interface statistics */ +typedef struct { + wifi_interface_handle iface; // wifi interface + wifi_interface_link_layer_info info; // current state of the interface + u32 beacon_rx; // access point beacon received count from connected AP + u64 average_tsf_offset; // average beacon offset encountered (beacon_TSF - TBTT) + // The average_tsf_offset field is used so as to calculate the + // typical beacon contention time on the channel as well may be + // used to debug beacon synchronization and related power consumption issue + u32 leaky_ap_detected; // indicate that this AP typically leaks packets beyond the driver guard time. + u32 leaky_ap_avg_num_frames_leaked; // average number of frame leaked by AP after frame with PM bit set was ACK'ed by AP + u32 leaky_ap_guard_time; // guard time currently in force (when implementing IEEE power management based on + // frame control PM bit), How long driver waits before shutting down the radio and + // after receiving an ACK for a data frame with PM bit set) + u32 mgmt_rx; // access point mgmt frames received count from connected AP (including Beacon) + u32 mgmt_action_rx; // action frames received count + u32 mgmt_action_tx; // action frames transmit count + wifi_rssi rssi_mgmt; // access Point Beacon and Management frames RSSI (averaged) + wifi_rssi rssi_data; // access Point Data Frames RSSI (averaged) from connected AP + wifi_rssi rssi_ack; // access Point ACK RSSI (averaged) from connected AP + wifi_wmm_ac_stat ac[WIFI_AC_MAX]; // per ac data packet statistics + u32 num_peers; // number of peers + wifi_peer_info peer_info[]; // per peer statistics +} wifi_iface_stat; + +/* configuration params */ +typedef struct { + u32 mpdu_size_threshold; // threshold to classify the pkts as short or long + // packet size < mpdu_size_threshold => short + u32 aggressive_statistics_gathering; // set for field debug mode. Driver should collect all statistics regardless of performance impact. +} wifi_link_layer_params; + +/* callback for reporting link layer stats */ +typedef struct { + void (*on_link_stats_results) (wifi_request_id id, wifi_iface_stat *iface_stat, + int num_radios, wifi_radio_stat *radio_stat); +} wifi_stats_result_handler; + + +/* wifi statistics bitmap */ +#define WIFI_STATS_RADIO 0x00000001 // all radio statistics +#define WIFI_STATS_RADIO_CCA 0x00000002 // cca_busy_time (within radio statistics) +#define WIFI_STATS_RADIO_CHANNELS 0x00000004 // all channel statistics (within radio statistics) +#define WIFI_STATS_RADIO_SCAN 0x00000008 // all scan statistics (within radio statistics) +#define WIFI_STATS_IFACE 0x00000010 // all interface statistics +#define WIFI_STATS_IFACE_TXRATE 0x00000020 // all tx rate statistics (within interface statistics) +#define WIFI_STATS_IFACE_AC 0x00000040 // all ac statistics (within interface statistics) +#define WIFI_STATS_IFACE_CONTENTION 0x00000080 // all contention (min, max, avg) statistics (within ac statisctics) + +#endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ -/* Capture the BRCM_VENDOR_SUBCMD_PRIV_STRINGS* here */ -#define BRCM_VENDOR_SCMD_CAPA "cap" #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(RTW_VENDOR_EXT_SUPPORT) extern int rtw_cfgvendor_attach(struct wiphy *wiphy); @@ -232,8 +551,8 @@ extern int rtw_cfgvendor_detach(struct wiphy *wiphy); extern int rtw_cfgvendor_send_async_event(struct wiphy *wiphy, struct net_device *dev, int event_id, const void *data, int len); #if defined(GSCAN_SUPPORT) && 0 -extern int wl_cfgvendor_send_hotlist_event(struct wiphy *wiphy, - struct net_device *dev, void *data, int len, wl_vendor_event_t event); +extern int rtw_cfgvendor_send_hotlist_event(struct wiphy *wiphy, + struct net_device *dev, void *data, int len, rtw_vendor_event_t event); #endif #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(RTW_VENDOR_EXT_SUPPORT) */ diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index c07c1fe..2878d68 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -160,39 +160,39 @@ static struct usb_device_id rtw_usb_id_tbl[] = { {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x881B), .driver_info = RTL8812}, /* Default ID */ {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x881C), .driver_info = RTL8812}, /* Default ID */ /*=== Customer ID ===*/ - {USB_DEVICE(0x0409, 0x0408), .driver_info = RTL8812}, /* NEC - */ - {USB_DEVICE(0x0411, 0x025D), .driver_info = RTL8812}, /* Buffalo - WI-U3-866D */ - {USB_DEVICE(0x04BB, 0x0952), .driver_info = RTL8812}, /* I-O DATA - Edimax */ - {USB_DEVICE(0x050D, 0x1106), .driver_info = RTL8812}, /* Belkin - Sercomm */ - {USB_DEVICE(0x050D, 0x1109), .driver_info = RTL8812}, /* Belkin - SerComm F9L1109 */ - {USB_DEVICE(0x0586, 0x3426), .driver_info = RTL8812}, /* ZyXEL - */ - {USB_DEVICE(0x0789, 0x016E), .driver_info = RTL8812}, /* Logitec - Edimax */ - {USB_DEVICE(0x07B8, 0x8812), .driver_info = RTL8812}, /* Abocom - Abocom */ - {USB_DEVICE(0x0846, 0x9051), .driver_info = RTL8812}, /* Netgear A6200 v2 */ - {USB_DEVICE(0x0B05, 0x17D2), .driver_info = RTL8812}, /* ASUS - Edimax */ - {USB_DEVICE(0x0BDA, 0x8812), .driver_info = RTL8812}, /* KOOTEK */ - {USB_DEVICE(0x0BDA, 0x881A), .driver_info = RTL8812}, /* Unex DAUK-W8812 */ - {USB_DEVICE(0x0DF6, 0x0074), .driver_info = RTL8812}, /* Sitecom - Edimax */ - {USB_DEVICE(0x0E66, 0x0022), .driver_info = RTL8812}, /* HAWKING - Edimax */ - {USB_DEVICE(0x1058, 0x0632), .driver_info = RTL8812}, /* WD - Cybertan */ - {USB_DEVICE(0x13B1, 0x003F), .driver_info = RTL8812}, /* Linksys - WUSB6300 */ - {USB_DEVICE(0x148F, 0x9097), .driver_info = RTL8812}, /* Amped Wireless - ACA1 */ - {USB_DEVICE(0x1740, 0x0100), .driver_info = RTL8812}, /* EnGenius - EnGenius */ - {USB_DEVICE(0x2001, 0x330E), .driver_info = RTL8812}, /* D-Link - ALPHA */ - {USB_DEVICE(0x2001, 0x3313), .driver_info = RTL8812}, /* D-Link - ALPHA */ - {USB_DEVICE(0x2001, 0x3315), .driver_info = RTL8812}, /* D-Link - Cameo */ - {USB_DEVICE(0x2001, 0x3316), .driver_info = RTL8812}, /* D-Link - Cameo */ - {USB_DEVICE(0x2019, 0xAB30), .driver_info = RTL8812}, /* Planex - Abocom */ - {USB_DEVICE(0x20F4, 0x805B), .driver_info = RTL8812}, /* TRENDnet - Cameo */ - {USB_DEVICE(0x2357, 0x0101), .driver_info = RTL8812}, /* TP-Link - Archer T4U AC1200 */ - {USB_DEVICE(0x2357, 0x0103), .driver_info = RTL8812}, /* TP-Link - T4UH */ - {USB_DEVICE(0x2357, 0x010D), .driver_info = RTL8812}, /* TP-Link - Archer T4U AC1300 */ - {USB_DEVICE(0x2357, 0x010E), .driver_info = RTL8812}, /* TP-Link - Archer T4UH AC1300 */ - {USB_DEVICE(0x2357, 0x010F), .driver_info = RTL8812}, /* TP-Link - T4UHP */ - {USB_DEVICE(0x2357, 0x0122), .driver_info = RTL8812}, /* TP-Link - T4UHP (other) */ - {USB_DEVICE(0x2604, 0x0012), .driver_info = RTL8812}, /* Tenda - U12 */ - {USB_DEVICE(0x7392, 0xA812), .driver_info = RTL8812}, /* Edimax - EW-7811UTC */ - {USB_DEVICE(0x7392, 0xA822), .driver_info = RTL8812}, /* Edimax - Edimax */ + {USB_DEVICE(0x050D, 0x1106), .driver_info = RTL8812}, /* Belkin - sercomm */ + {USB_DEVICE(0x7392, 0xA822), .driver_info = RTL8812}, /* Edimax - Edimax */ + {USB_DEVICE(0x0DF6, 0x0074), .driver_info = RTL8812}, /* Sitecom - Edimax */ + {USB_DEVICE(0x04BB, 0x0952), .driver_info = RTL8812}, /* I-O DATA - Edimax */ + {USB_DEVICE(0x0789, 0x016E), .driver_info = RTL8812}, /* Logitec - Edimax */ + {USB_DEVICE(0x0409, 0x0408), .driver_info = RTL8812}, /* NEC - */ + {USB_DEVICE(0x0B05, 0x17D2), .driver_info = RTL8812}, /* ASUS - Edimax */ + {USB_DEVICE(0x0E66, 0x0022), .driver_info = RTL8812}, /* HAWKING - Edimax */ + {USB_DEVICE(0x0586, 0x3426), .driver_info = RTL8812}, /* ZyXEL - */ + {USB_DEVICE(0x2001, 0x3313), .driver_info = RTL8812}, /* D-Link - ALPHA */ + {USB_DEVICE(0x1058, 0x0632), .driver_info = RTL8812}, /* WD - Cybertan */ + {USB_DEVICE(0x1740, 0x0100), .driver_info = RTL8812}, /* EnGenius - EnGenius */ + {USB_DEVICE(0x2019, 0xAB30), .driver_info = RTL8812}, /* Planex - Abocom */ + {USB_DEVICE(0x07B8, 0x8812), .driver_info = RTL8812}, /* Abocom - Abocom */ + {USB_DEVICE(0x0846, 0x9051), .driver_info = RTL8812}, /* Netgear A6200 v2 */ + {USB_DEVICE(0x2001, 0x330E), .driver_info = RTL8812}, /* D-Link - ALPHA */ + {USB_DEVICE(0x2001, 0x3313), .driver_info = RTL8812}, /* D-Link - ALPHA */ + {USB_DEVICE(0x2001, 0x3315), .driver_info = RTL8812}, /* D-Link - Cameo */ + {USB_DEVICE(0x2001, 0x3316), .driver_info = RTL8812}, /* D-Link - Cameo */ + {USB_DEVICE(0x13B1, 0x003F), .driver_info = RTL8812}, /* Linksys - WUSB6300 */ + {USB_DEVICE(0x2357, 0x0101), .driver_info = RTL8812}, /* TP-Link - Archer T4U AC1200 */ + {USB_DEVICE(0x2357, 0x0103), .driver_info = RTL8812}, /* TP-Link - T4UH */ + {USB_DEVICE(0x2357, 0x010D), .driver_info = RTL8812}, /* TP-Link - Archer T4U AC1300 */ + {USB_DEVICE(0x2357, 0x010E), .driver_info = RTL8812}, /* TP-Link - Archer T4UH AC1300 */ + {USB_DEVICE(0x2357, 0x010F), .driver_info = RTL8812}, /* TP-Link - T4UHP */ + {USB_DEVICE(0x2357, 0x0122), .driver_info = RTL8812}, /* TP-Link - T4UHP (other) */ + {USB_DEVICE(0x20F4, 0x805B), .driver_info = RTL8812}, /* TRENDnet - */ + {USB_DEVICE(0x0411, 0x025D), .driver_info = RTL8812}, /* Buffalo - WI-U3-866D */ + {USB_DEVICE(0x050D, 0x1109), .driver_info = RTL8812}, /* Belkin F9L1109 - SerComm */ + {USB_DEVICE(0x148F, 0x9097), .driver_info = RTL8812}, /* Amped Wireless ACA1 */ + {USB_DEVICE(0x0BDA, 0x8812), .driver_info = RTL8812}, /* Alfa - AWUS036AC, AWUS036ACH & AWUS036EAC */ + {USB_DEVICE(0x2604, 0x0012), .driver_info = RTL8812}, /* Tenda U12 */ + {USB_DEVICE(0x0BDA, 0x881A), .driver_info = RTL8812}, /* Unex DAUK-W8812 */ #endif #ifdef CONFIG_RTL8821A @@ -200,26 +200,23 @@ static struct usb_device_id rtw_usb_id_tbl[] = { {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0811), .driver_info = RTL8821}, /* Default ID */ {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0821), .driver_info = RTL8821}, /* Default ID */ {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8822), .driver_info = RTL8821}, /* Default ID */ - {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xA811), .driver_info = RTL8821},/* Default ID */ + {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xA811) , .driver_info = RTL8821},/* Default ID */ {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0x0820, 0xff, 0xff, 0xff), .driver_info = RTL8821}, /* 8821AU */ {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0x0823, 0xff, 0xff, 0xff), .driver_info = RTL8821}, /* 8821AU */ /*=== Customer ID ===*/ {USB_DEVICE(0x7392, 0xA811), .driver_info = RTL8821}, /* Edimax - Edimax */ - {USB_DEVICE(0x7392, 0xA812), .driver_info = RTL8821}, /* Edimax - EW-7811UTC */ + {USB_DEVICE(0x7392, 0xA812), .driver_info = RTL8821}, /* Edimax - EW-7811UTC */ {USB_DEVICE(0x7392, 0xA813), .driver_info = RTL8821}, /* Edimax - EW-7811UAC */ - {USB_DEVICE(0x0BDA, 0xA811), .driver_info = RTL8821}, /* OUTLINK - Edimax */ {USB_DEVICE(0x04BB, 0x0953), .driver_info = RTL8821}, /* I-O DATA - Edimax */ {USB_DEVICE(0x2001, 0x3314), .driver_info = RTL8821}, /* D-Link - Cameo */ {USB_DEVICE(0x2001, 0x3318), .driver_info = RTL8821}, /* D-Link - Cameo */ {USB_DEVICE(0x0E66, 0x0023), .driver_info = RTL8821}, /* HAWKING - Edimax */ {USB_DEVICE(0x056E, 0x400E), .driver_info = RTL8821}, /* ELECOM - ELECOM */ {USB_DEVICE(0x056E, 0x400F), .driver_info = RTL8821}, /* ELECOM - ELECOM */ - {USB_DEVICE(0x0846, 0x9052), .driver_info = RTL8821}, /* Netgear - A6100 */ + {USB_DEVICE(0x0411, 0x0242), .driver_info = RTL8821}, /* ELECOM - WDC-433DU2H */ {USB_DEVICE(0x2019, 0xAB32), .driver_info = RTL8821}, /* Planex - GW-450S */ - {USB_DEVICE(0x0411, 0x0242), .driver_info = RTL8821}, /* BUFFALO - Edimax */ - {USB_DEVICE(0x0411, 0x025D), .driver_info = RTL8821}, /* BUFFALO - WI-U3-866D */ - {USB_DEVICE(0x0411, 0x029B), .driver_info = RTL8821}, /* BUFFALO - WI-U2-433DHP */ - {USB_DEVICE(0x0BDA, 0xA811), .driver_info = RTL8821}, /* Comfast - CF-915AC, CF-916AC */ + {USB_DEVICE(0x0846, 0x9052), .driver_info = RTL8821}, /* Netgear - A6100 */ + {USB_DEVICE(0x0411, 0x029B), .driver_info = RTL8821}, /* Buffalo - WI-U2-433DHP */ {USB_DEVICE(0x056E, 0x4007), .driver_info = RTL8821}, /* Elecom - WDC-433DU2HBK */ #endif @@ -242,6 +239,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = { #endif /* CONFIG_RTL8703B */ #ifdef CONFIG_RTL8814A + {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8813), .driver_info = RTL8814A}, {USB_DEVICE(0x2001, 0x331A), .driver_info = RTL8814A}, /* D-Link - D-Link */ {USB_DEVICE(0x0B05, 0x1817), .driver_info = RTL8814A}, /* ASUS - ASUSTeK */ @@ -256,7 +254,6 @@ static struct usb_device_id rtw_usb_id_tbl[] = { {USB_DEVICE(0x20F4, 0x809A), .driver_info = RTL8814A}, /* TRENDnet - TRENDnet */ {USB_DEVICE(0x20F4, 0x809B), .driver_info = RTL8814A}, /* TRENDnet TEW-809UB */ {USB_DEVICE(0x0846, 0x9054), .driver_info = RTL8814A}, /* Netgear A7000 */ - {USB_DEVICE(0x0E66, 0x0026), .driver_info = RTL8814A}, /* Hawking HW17ACU 1750AC */ #endif /* CONFIG_RTL8814A */ #ifdef CONFIG_RTL8188F