staging: vt6656: Get wireless stats qual.qual directly from s_uCalculateLinkQual
authorMalcolm Priestley <tvboxspy@gmail.com>
Mon, 9 Dec 2013 22:25:48 +0000 (22:25 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 11 Dec 2013 07:14:26 +0000 (23:14 -0800)
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 <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vt6656/bssdb.c
drivers/staging/vt6656/iwctl.c

index 1c3cbc5..4c32b12 100644 (file)
@@ -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;
index 183c5a2..058df65 100644 (file)
@@ -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;