From 854f775a12d387bcd203b70b62b4feb4aeb3c5eb Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 9 Dec 2013 22:25:48 +0000 Subject: [PATCH] staging: vt6656: Get wireless stats qual.qual directly from s_uCalculateLinkQual Calculate the qual from the tx_packets and wstats.discard.retries and apply to wstats.qual.qual Discard pDevice->scStatistic.LinkQuality. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/bssdb.c | 59 ++++++++++++++++++---------------- drivers/staging/vt6656/iwctl.c | 3 -- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index 1c3cbc54ce18..4c32b12f5e66 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -1384,39 +1384,44 @@ static void s_vCheckSensitivity(struct vnt_private *pDevice) static void s_uCalculateLinkQual(struct vnt_private *pDevice) { + struct net_device_stats *stats = &pDevice->stats; unsigned long TxOkRatio, TxCnt; unsigned long RxOkRatio, RxCnt; unsigned long RssiRatio; + unsigned long qual; long ldBm; -TxCnt = pDevice->scStatistic.TxNoRetryOkCount + - pDevice->scStatistic.TxRetryOkCount + - pDevice->scStatistic.TxFailCount; -RxCnt = pDevice->scStatistic.RxFcsErrCnt + + TxCnt = stats->tx_packets + pDevice->wstats.discard.retries; + + RxCnt = pDevice->scStatistic.RxFcsErrCnt + pDevice->scStatistic.RxOkCnt; -TxOkRatio = (TxCnt < 6) ? 4000:((pDevice->scStatistic.TxNoRetryOkCount * 4000) / TxCnt); -RxOkRatio = (RxCnt < 6) ? 2000:((pDevice->scStatistic.RxOkCnt * 2000) / RxCnt); -//decide link quality -if(pDevice->bLinkPass !=true) -{ - pDevice->scStatistic.LinkQuality = 0; - pDevice->scStatistic.SignalStren = 0; -} -else -{ - RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); - if(-ldBm < 50) { - RssiRatio = 4000; - } - else if(-ldBm > 90) { - RssiRatio = 0; - } - else { - RssiRatio = (40-(-ldBm-50))*4000/40; - } - pDevice->scStatistic.SignalStren = RssiRatio/40; - pDevice->scStatistic.LinkQuality = (RssiRatio+TxOkRatio+RxOkRatio)/100; -} + + TxOkRatio = (TxCnt < 6) ? 4000:((stats->tx_packets * 4000) / TxCnt); + + RxOkRatio = (RxCnt < 6) ? 2000 : + ((pDevice->scStatistic.RxOkCnt * 2000) / RxCnt); + + /* decide link quality */ + if (pDevice->bLinkPass != true) { + pDevice->wstats.qual.qual = 0; + pDevice->scStatistic.SignalStren = 0; + } else { + RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); + if (-ldBm < 50) + RssiRatio = 4000; + else if (-ldBm > 90) + RssiRatio = 0; + else + RssiRatio = (40-(-ldBm-50)) * 4000 / 40; + + pDevice->scStatistic.SignalStren = RssiRatio / 40; + qual = (RssiRatio + TxOkRatio + RxOkRatio) / 100; + if (qual < 100) + pDevice->wstats.qual.qual = (u8)qual; + else + pDevice->wstats.qual.qual = 100; + } + pDevice->scStatistic.RxFcsErrCnt = 0; pDevice->scStatistic.RxOkCnt = 0; pDevice->scStatistic.TxFailCount = 0; diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index 183c5a2f57e1..058df6516784 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -58,9 +58,6 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) long ldBm; pDevice->wstats.status = pDevice->eOPMode; - if (pDevice->scStatistic.LinkQuality > 100) - pDevice->scStatistic.LinkQuality = 100; - pDevice->wstats.qual.qual = (u8)pDevice->scStatistic.LinkQuality; RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); pDevice->wstats.qual.level = ldBm; pDevice->wstats.qual.noise = 0; -- 2.20.1