From 85119ae2279066dc748b0c2b46ceb90700d14c37 Mon Sep 17 00:00:00 2001 From: mtaylor Date: Wed, 9 Apr 2008 20:30:34 +0000 Subject: [PATCH] Some cleanup for jiffies rollover problems. Use of time_before/time_after macros and correct units for storing jiffies. On some distributions Jiffies rollover after 5m. git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3483 0192ed92-7a03-0410-a25b-9323aeb14dbd --- ath_rate/onoe/onoe.c | 2 +- ath_rate/onoe/onoe.h | 2 +- ath_rate/sample/sample.c | 5 +++-- ath_rate/sample/sample.h | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ath_rate/onoe/onoe.c b/ath_rate/onoe/onoe.c index 744c0c3..3f6a673 100644 --- a/ath_rate/onoe/onoe.c +++ b/ath_rate/onoe/onoe.c @@ -160,7 +160,7 @@ ath_rate_tx_complete(struct ath_softc *sc, on->on_tx_err++; on->on_tx_retr += ts->ts_shortretry + ts->ts_longretry; - if (jiffies >= on->on_nextcheck) { + if (time_after(jiffies, on->on_nextcheck)) { ath_rate_ctl(sc, &an->an_node); /* XXX halve rate for station mode */ on->on_nextcheck = jiffies + (ath_rateinterval * HZ) / 1000; diff --git a/ath_rate/onoe/onoe.h b/ath_rate/onoe/onoe.h index bb14909..6fa9919 100644 --- a/ath_rate/onoe/onoe.h +++ b/ath_rate/onoe/onoe.h @@ -63,7 +63,7 @@ struct onoe_node { u_int8_t on_tx_rate1sp; /* series 1 short preamble h/w rate */ u_int8_t on_tx_rate2sp; /* series 2 short preamble h/w rate */ u_int8_t on_tx_rate3sp; /* series 3 short preamble h/w rate */ - int on_nextcheck; /* time of next check for rate drop */ + long unsigned int on_nextcheck; /* time of next check for rate drop */ }; #define ATH_NODE_ONOE(an) ((struct onoe_node *)&an[1]) #endif /* _DEV_ATH_RATE_ONOE_H */ diff --git a/ath_rate/sample/sample.c b/ath_rate/sample/sample.c index ff67819..923ee14 100644 --- a/ath_rate/sample/sample.c +++ b/ath_rate/sample/sample.c @@ -344,7 +344,7 @@ pick_sample_ndx(struct sample_node *sn, int size_bin) continue; /* rarely sample bit-rates that fail a lot */ - if (jiffies - sn->stats[size_bin][ndx].last_tx < ((HZ * STALE_FAILURE_TIMEOUT_MS) / 1000) && + if (time_before(jiffies, sn->stats[size_bin][ndx].last_tx + ((HZ * STALE_FAILURE_TIMEOUT_MS) / 1000)) && sn->stats[size_bin][ndx].successive_failures > 3) continue; @@ -447,7 +447,8 @@ ath_rate_findrate(struct ath_softc *sc, struct ath_node *an, } else if (sn->packets_sent[size_bin] < 20) { /* let the bit-rate switch quickly during the first few packets */ change_rates = 1; - } else if (jiffies - ((HZ * MIN_SWITCH_MS) / 1000) > sn->jiffies_since_switch[size_bin]) { + } else if (time_after(jiffies, sn->jiffies_since_switch[size_bin] + + ((HZ * MIN_SWITCH_MS) / 1000))) { /* 2 seconds have gone by */ change_rates = 1; } else if (average_tx_time * 2 < sn->stats[size_bin][sn->current_rate[size_bin]].average_tx_time) { diff --git a/ath_rate/sample/sample.h b/ath_rate/sample/sample.h index 7883fe4..29ff8d3 100644 --- a/ath_rate/sample/sample.h +++ b/ath_rate/sample/sample.h @@ -65,7 +65,7 @@ struct rate_stats { int total_packets; int packets_acked; unsigned perfect_tx_time; /* transmit time for 0 retries */ - int last_tx; + unsigned long int last_tx; }; @@ -91,7 +91,7 @@ struct sample_node { int current_rate[NUM_PACKET_SIZE_BINS]; int packets_since_switch[NUM_PACKET_SIZE_BINS]; - unsigned jiffies_since_switch[NUM_PACKET_SIZE_BINS]; + unsigned long int jiffies_since_switch[NUM_PACKET_SIZE_BINS]; int packets_since_sample[NUM_PACKET_SIZE_BINS]; unsigned sample_tt[NUM_PACKET_SIZE_BINS]; -- 2.35.1