From 295bb23ffee601f1ae001e09b9cf3132c225bb07 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 30 Dec 2013 21:18:17 -0600 Subject: [PATCH] rtl8188eu: Fix reporting of signal strength and quality Signed-off-by: Larry Finger --- core/rtw_mlme.c | 22 +++++++++++----------- hal/odm_HWConfig.c | 15 ++++++++++----- hal/rtl8188e_rxdesc.c | 2 +- include/drv_types.h | 2 ++ include/odm_HWConfig.h | 3 ++- os_dep/ioctl_linux.c | 14 +++++++------- 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/core/rtw_mlme.c b/core/rtw_mlme.c index ac3535d..60b1544 100644 --- a/core/rtw_mlme.c +++ b/core/rtw_mlme.c @@ -548,20 +548,20 @@ _func_enter_; sq_final = padapter->recvpriv.signal_qual; /* the rssi value here is undecorated, and will be used for antenna diversity */ if (sq_smp != 101) /* from the right channel */ - rssi_final = (src->Rssi+dst->Rssi*4)/5; + rssi_final = dst->Rssi; //(src->Rssi+dst->Rssi*4)/5; else rssi_final = rssi_ori; } else { - if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; - } else { - /* bss info not receiving from the right channel, use the original RX signal infos */ - ss_final = dst->PhyInfo.SignalStrength; - sq_final = dst->PhyInfo.SignalQuality; - rssi_final = dst->Rssi; - } +// if (sq_smp != 101) { /* from the right channel */ + ss_final = (u32)dst->PhyInfo.SignalStrength; //((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; + sq_final = (u32)dst->PhyInfo.SignalQuality; //((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; + rssi_final = dst->Rssi; //(src->Rssi+dst->Rssi*4)/5; +// } else { +// /* bss info not receiving from the right channel, use the original RX signal infos */ +// ss_final = dst->PhyInfo.SignalStrength; +// sq_final = dst->PhyInfo.SignalQuality; +// rssi_final = dst->Rssi; +// } } if (update_ie) memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); diff --git a/hal/odm_HWConfig.c b/hal/odm_HWConfig.c index 19c509a..4c6b6c2 100644 --- a/hal/odm_HWConfig.c +++ b/hal/odm_HWConfig.c @@ -119,7 +119,8 @@ static u8 odm_EVMdbToPercentage(s8 Value) static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, struct odm_phy_status_info *pPhyInfo, u8 *pPhyStatus, - struct odm_per_pkt_info *pPktinfo) + struct odm_per_pkt_info *pPktinfo, + struct adapter *adapt) { struct sw_ant_switch *pDM_SWAT_Table = &dm_odm->DM_SWAT_Table; u8 i, Max_spatial_stream; @@ -298,6 +299,8 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, rf_rx_num++; rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain & 0x3F)*2) - 110; + if (i == RF_PATH_A) + adapt->signal_strength = rx_pwr[i]; pPhyInfo->RxPwr[i] = rx_pwr[i]; @@ -526,10 +529,11 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, static void ODM_PhyStatusQuery_92CSeries(struct odm_dm_struct *dm_odm, struct odm_phy_status_info *pPhyInfo, u8 *pPhyStatus, - struct odm_per_pkt_info *pPktinfo) + struct odm_per_pkt_info *pPktinfo, + struct adapter *adapt) { odm_RxPhyStatus92CSeries_Parsing(dm_odm, pPhyInfo, pPhyStatus, - pPktinfo); + pPktinfo, adapt); if (dm_odm->RSSI_test) { /* Select the packets to do RSSI checking for antenna switching. */ if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) @@ -541,9 +545,10 @@ static void ODM_PhyStatusQuery_92CSeries(struct odm_dm_struct *dm_odm, void ODM_PhyStatusQuery(struct odm_dm_struct *dm_odm, struct odm_phy_status_info *pPhyInfo, - u8 *pPhyStatus, struct odm_per_pkt_info *pPktinfo) + u8 *pPhyStatus, struct odm_per_pkt_info *pPktinfo, + struct adapter *adapt) { - ODM_PhyStatusQuery_92CSeries(dm_odm, pPhyInfo, pPhyStatus, pPktinfo); + ODM_PhyStatusQuery_92CSeries(dm_odm, pPhyInfo, pPhyStatus, pPktinfo, adapt); } /* For future use. */ diff --git a/hal/rtl8188e_rxdesc.c b/hal/rtl8188e_rxdesc.c index 05e2475..b076fe3 100644 --- a/hal/rtl8188e_rxdesc.c +++ b/hal/rtl8188e_rxdesc.c @@ -183,7 +183,7 @@ void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat pkt_info.StationID = psta->mac_id; pkt_info.Rate = pattrib->mcs_rate; - ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info)); + ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info), padapter); precvframe->u.hdr.psta = NULL; if (pkt_info.bPacketMatchBSSID && diff --git a/include/drv_types.h b/include/drv_types.h index ad073c8..c920288 100644 --- a/include/drv_types.h +++ b/include/drv_types.h @@ -192,6 +192,7 @@ struct dvobj_priv { struct usb_device *pusbdev; ATOMIC_T continual_urb_error; + u8 signal_strength; }; static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj) @@ -266,6 +267,7 @@ struct adapter { u8 bDriverIsGoingToUnload; u8 init_adpt_in_progress; u8 bHaltInProgress; + s8 signal_strength; void *cmdThread; void *evtThread; diff --git a/include/odm_HWConfig.h b/include/odm_HWConfig.h index df52722..2c48abf 100644 --- a/include/odm_HWConfig.h +++ b/include/odm_HWConfig.h @@ -111,7 +111,8 @@ void odm_Init_RSSIForDM(struct odm_dm_struct *pDM_Odm); void ODM_PhyStatusQuery(struct odm_dm_struct *pDM_Odm, struct odm_phy_status_info *pPhyInfo, u8 *pPhyStatus, - struct odm_per_pkt_info *pPktinfo); + struct odm_per_pkt_info *pPktinfo, + struct adapter *adapt); void ODM_MacStatusQuery(struct odm_dm_struct *pDM_Odm, u8 *pMacStatus, diff --git a/os_dep/ioctl_linux.c b/os_dep/ioctl_linux.c index ae54587..eb05efb 100644 --- a/os_dep/ioctl_linux.c +++ b/os_dep/ioctl_linux.c @@ -7832,24 +7832,24 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_statistics *piwstats = &padapter->iwstats; - int tmp_level = 0; - int tmp_qual = 0; int tmp_noise = 0; + int tmp; if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { piwstats->qual.qual = 0; piwstats->qual.level = 0; piwstats->qual.noise = 0; } else { - tmp_level = padapter->recvpriv.signal_strength; - tmp_qual = padapter->recvpriv.signal_qual; tmp_noise = padapter->recvpriv.noise; - piwstats->qual.level = tmp_level; - piwstats->qual.qual = tmp_qual; + piwstats->qual.level = padapter->signal_strength; + tmp = 219 + 3 * padapter->signal_strength; + tmp = min(100, tmp); + tmp = max(0, tmp); + piwstats->qual.qual = tmp; piwstats->qual.noise = tmp_noise; } - piwstats->qual.updated = IW_QUAL_ALL_UPDATED;/* IW_QUAL_DBM; */ + piwstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; return &padapter->iwstats; }