aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/benet
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2009-03-27 03:25:24 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-27 03:25:24 -0400
commit65f71b8bd2651e6d6ca9b09fe53a8db2da22b85c (patch)
treed42820964a817c43ff9330711576816540a01ad0 /drivers/net/benet
parent7d0b591c655ca0d72ebcbd242cf659a20a8995c5 (diff)
benet: use do_div() for 64 bit divide
The benet driver is doing a 64 bit divide, which is not supported in Linux kernel on 32 bit architectures. The correct way to do this is to use do_div(). Compile tested on i386 only. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Acked-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/benet')
-rw-r--r--drivers/net/benet/be_main.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index f901fee79a20..9b75aa630062 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include "be.h" 18#include "be.h"
19#include <asm/div64.h>
19 20
20MODULE_VERSION(DRV_VER); 21MODULE_VERSION(DRV_VER);
21MODULE_DEVICE_TABLE(pci, be_dev_ids); 22MODULE_DEVICE_TABLE(pci, be_dev_ids);
@@ -290,6 +291,17 @@ static struct net_device_stats *be_get_stats(struct net_device *dev)
290 return &adapter->stats.net_stats; 291 return &adapter->stats.net_stats;
291} 292}
292 293
294static u32 be_calc_rate(u64 bytes, unsigned long ticks)
295{
296 u64 rate = bytes;
297
298 do_div(rate, ticks / HZ);
299 rate <<= 3; /* bytes/sec -> bits/sec */
300 do_div(rate, 1000000ul); /* MB/Sec */
301
302 return rate;
303}
304
293static void be_tx_rate_update(struct be_adapter *adapter) 305static void be_tx_rate_update(struct be_adapter *adapter)
294{ 306{
295 struct be_drvr_stats *stats = drvr_stats(adapter); 307 struct be_drvr_stats *stats = drvr_stats(adapter);
@@ -303,11 +315,9 @@ static void be_tx_rate_update(struct be_adapter *adapter)
303 315
304 /* Update tx rate once in two seconds */ 316 /* Update tx rate once in two seconds */
305 if ((now - stats->be_tx_jiffies) > 2 * HZ) { 317 if ((now - stats->be_tx_jiffies) > 2 * HZ) {
306 u32 r; 318 stats->be_tx_rate = be_calc_rate(stats->be_tx_bytes
307 r = (stats->be_tx_bytes - stats->be_tx_bytes_prev) / 319 - stats->be_tx_bytes_prev,
308 ((now - stats->be_tx_jiffies) / HZ); 320 now - stats->be_tx_jiffies);
309 r = r / 1000000; /* M bytes/s */
310 stats->be_tx_rate = r * 8; /* M bits/s */
311 stats->be_tx_jiffies = now; 321 stats->be_tx_jiffies = now;
312 stats->be_tx_bytes_prev = stats->be_tx_bytes; 322 stats->be_tx_bytes_prev = stats->be_tx_bytes;
313 } 323 }
@@ -599,7 +609,6 @@ static void be_rx_rate_update(struct be_adapter *adapter)
599{ 609{
600 struct be_drvr_stats *stats = drvr_stats(adapter); 610 struct be_drvr_stats *stats = drvr_stats(adapter);
601 ulong now = jiffies; 611 ulong now = jiffies;
602 u32 rate;
603 612
604 /* Wrapped around */ 613 /* Wrapped around */
605 if (time_before(now, stats->be_rx_jiffies)) { 614 if (time_before(now, stats->be_rx_jiffies)) {
@@ -611,10 +620,9 @@ static void be_rx_rate_update(struct be_adapter *adapter)
611 if ((now - stats->be_rx_jiffies) < 2 * HZ) 620 if ((now - stats->be_rx_jiffies) < 2 * HZ)
612 return; 621 return;
613 622
614 rate = (stats->be_rx_bytes - stats->be_rx_bytes_prev) / 623 stats->be_rx_rate = be_calc_rate(stats->be_rx_bytes
615 ((now - stats->be_rx_jiffies) / HZ); 624 - stats->be_rx_bytes_prev,
616 rate = rate / 1000000; /* MB/Sec */ 625 now - stats->be_rx_jiffies);
617 stats->be_rx_rate = rate * 8; /* Mega Bits/Sec */
618 stats->be_rx_jiffies = now; 626 stats->be_rx_jiffies = now;
619 stats->be_rx_bytes_prev = stats->be_rx_bytes; 627 stats->be_rx_bytes_prev = stats->be_rx_bytes;
620} 628}