Fixed frame statistics.
authorFlorian Pose <fp@igh-essen.com>
Mon, 08 Mar 2010 07:40:54 +0100
changeset 1852 1ec9f781f3ef
parent 1851 a56bd34e20a1
child 1853 e0b9c4611f0a
Fixed frame statistics.
master/device.c
--- a/master/device.c	Sun Mar 07 23:55:51 2010 +0100
+++ b/master/device.c	Mon Mar 08 07:40:54 2010 +0100
@@ -324,21 +324,20 @@
     // frame statistics
     if (unlikely(jiffies - device->stats_jiffies >= HZ)) {
         unsigned int i;
-        unsigned int tx_rate = device->tx_count - device->last_tx_count;
+        unsigned int tx_rate =
+            (device->tx_count - device->last_tx_count) * 1000;
         int loss = device->tx_count - device->rx_count;
         int loss_rate = (loss - device->last_loss) * 1000;
         for (i = 0; i < EC_RATE_COUNT; i++) {
             unsigned int n = rate_intervals[i];
             device->tx_rates[i] =
-                device->tx_rates[i] * (n - 1) +
-                tx_rate * n;
+                (device->tx_rates[i] * (n - 1) + tx_rate) / n;
             device->loss_rates[i] =
-                device->loss_rates[i] * (n - 1) +
-                loss_rate * n;
+                (device->loss_rates[i] * (n - 1) + loss_rate) / n;
         }
         device->last_tx_count = device->tx_count;
         device->last_loss = loss;
-        device->stats_jiffies += HZ;
+        device->stats_jiffies = jiffies;
     }
 
     if (unlikely(!device->link_state)) // Link down