diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-27 21:35:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-27 21:35:03 -0400 |
commit | 5d80f8e5a9dc9c9a94d4aeaa567e219a808b8a4a (patch) | |
tree | 357258d77e2153ef7409926773655c5f8775a1f3 /drivers/net/benet/be_main.c | |
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/be_main.c')
-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 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 | ||
20 | MODULE_VERSION(DRV_VER); | 21 | MODULE_VERSION(DRV_VER); |
21 | MODULE_DEVICE_TABLE(pci, be_dev_ids); | 22 | MODULE_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 | ||
294 | static 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 | |||
293 | static void be_tx_rate_update(struct be_adapter *adapter) | 305 | static 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 | } |