diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-27 18:35:03 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-27 18:35:03 -0700 |
commit | 5d80f8e5a9dc9c9a94d4aeaa567e219a808b8a4a (patch) | |
tree | 357258d77e2153ef7409926773655c5f8775a1f3 /drivers/net/benet | |
parent | 7b616c8a2f5c8507b4aed6907336ec5b85803a39 (diff) | |
parent | 0870352bc6e0dee485c86a0c99dd60e7089c8917 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (166 commits)
Revert "ax25: zero length frame filtering in AX25"
Revert "netrom: zero length frame filtering in NetRom"
cfg80211: default CONFIG_WIRELESS_OLD_REGULATORY to n
mac80211/iwlwifi: move virtual A-MDPU queue bookkeeping to iwlwifi
mac80211: fix aggregation to not require queue stop
mac80211: add skb length sanity checking
mac80211: unify and fix TX aggregation start
mac80211: clean up __ieee80211_tx args
mac80211: rework the pending packets code
mac80211: fix A-MPDU queue assignment
mac80211: rewrite fragmentation
iwlwifi: show current driver status in user readable format
b43: Add BCM4307 PCI-ID
cfg80211: fix locking in nl80211_set_wiphy
mac80211: fix RX path
ath5k: properly drop packets from ops->tx
ar9170: single module build
ath9k: fix dma mapping leak of rx buffer upon rmmod
rt2x00: New USB ID for rt73usb
ath5k: warn and correct rate for unknown hw rate indexes
...
Diffstat (limited to 'drivers/net/benet')
-rw-r--r-- | drivers/net/benet/be_main.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index f901fee79a2..9b75aa63006 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c @@ -16,6 +16,7 @@ */ #include "be.h" +#include <asm/div64.h> MODULE_VERSION(DRV_VER); MODULE_DEVICE_TABLE(pci, be_dev_ids); @@ -290,6 +291,17 @@ static struct net_device_stats *be_get_stats(struct net_device *dev) return &adapter->stats.net_stats; } +static u32 be_calc_rate(u64 bytes, unsigned long ticks) +{ + u64 rate = bytes; + + do_div(rate, ticks / HZ); + rate <<= 3; /* bytes/sec -> bits/sec */ + do_div(rate, 1000000ul); /* MB/Sec */ + + return rate; +} + static void be_tx_rate_update(struct be_adapter *adapter) { struct be_drvr_stats *stats = drvr_stats(adapter); @@ -303,11 +315,9 @@ static void be_tx_rate_update(struct be_adapter *adapter) /* Update tx rate once in two seconds */ if ((now - stats->be_tx_jiffies) > 2 * HZ) { - u32 r; - r = (stats->be_tx_bytes - stats->be_tx_bytes_prev) / - ((now - stats->be_tx_jiffies) / HZ); - r = r / 1000000; /* M bytes/s */ - stats->be_tx_rate = r * 8; /* M bits/s */ + stats->be_tx_rate = be_calc_rate(stats->be_tx_bytes + - stats->be_tx_bytes_prev, + now - stats->be_tx_jiffies); stats->be_tx_jiffies = now; stats->be_tx_bytes_prev = stats->be_tx_bytes; } @@ -599,7 +609,6 @@ static void be_rx_rate_update(struct be_adapter *adapter) { struct be_drvr_stats *stats = drvr_stats(adapter); ulong now = jiffies; - u32 rate; /* Wrapped around */ if (time_before(now, stats->be_rx_jiffies)) { @@ -611,10 +620,9 @@ static void be_rx_rate_update(struct be_adapter *adapter) if ((now - stats->be_rx_jiffies) < 2 * HZ) return; - rate = (stats->be_rx_bytes - stats->be_rx_bytes_prev) / - ((now - stats->be_rx_jiffies) / HZ); - rate = rate / 1000000; /* MB/Sec */ - stats->be_rx_rate = rate * 8; /* Mega Bits/Sec */ + stats->be_rx_rate = be_calc_rate(stats->be_rx_bytes + - stats->be_rx_bytes_prev, + now - stats->be_rx_jiffies); stats->be_rx_jiffies = now; stats->be_rx_bytes_prev = stats->be_rx_bytes; } |