diff options
author | Michael Brown | 2017-01-25 21:59:15 +0100 |
---|---|---|
committer | Michael Brown | 2017-01-26 09:17:37 +0100 |
commit | 302f1eeb80706fb10067efedb1279fa3f85ddda2 (patch) | |
tree | 90e58309094b20a26cedc8244fabf72d96fe6135 /src/net | |
parent | [cpuid] Provide cpuid_supported() to test for supported functions (diff) | |
download | ipxe-302f1eeb80706fb10067efedb1279fa3f85ddda2.tar.gz ipxe-302f1eeb80706fb10067efedb1279fa3f85ddda2.tar.xz ipxe-302f1eeb80706fb10067efedb1279fa3f85ddda2.zip |
[time] Allow timer to be selected at runtime
Allow the active timer (providing udelay() and currticks()) to be
selected at runtime based on probing during the INIT_EARLY stage of
initialisation.
TICKS_PER_SEC is now a fixed compile-time constant for all builds, and
is independent of the underlying clock tick rate. We choose the value
1024 to allow multiplications and divisions on seconds to be converted
to bit shifts.
TICKS_PER_MS is defined as 1, allowing multiplications and divisions
on milliseconds to be omitted entirely. The 2% inaccuracy in this
definition is negligible when using the standard BIOS timer (running
at around 18.2Hz).
TIMER_RDTSC now checks for a constant TSC before claiming to be a
usable timer. (This timer can be tested in KVM via the command-line
option "-cpu host,+invtsc".)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/80211/net80211.c | 8 | ||||
-rw-r--r-- | src/net/fcoe.c | 2 | ||||
-rw-r--r-- | src/net/stp.c | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/src/net/80211/net80211.c b/src/net/80211/net80211.c index d4970ad5..62912741 100644 --- a/src/net/80211/net80211.c +++ b/src/net/80211/net80211.c @@ -1321,7 +1321,7 @@ struct net80211_probe_ctx * net80211_probe_start ( struct net80211_device *dev, ctx->ticks_start = currticks(); ctx->ticks_beacon = 0; ctx->ticks_channel = currticks(); - ctx->hop_time = ticks_per_sec() / ( active ? 2 : 6 ); + ctx->hop_time = TICKS_PER_SEC / ( active ? 2 : 6 ); /* * Channels on 2.4GHz overlap, and the most commonly used @@ -1363,8 +1363,8 @@ struct net80211_probe_ctx * net80211_probe_start ( struct net80211_device *dev, int net80211_probe_step ( struct net80211_probe_ctx *ctx ) { struct net80211_device *dev = ctx->dev; - u32 start_timeout = NET80211_PROBE_TIMEOUT * ticks_per_sec(); - u32 gather_timeout = ticks_per_sec(); + u32 start_timeout = NET80211_PROBE_TIMEOUT * TICKS_PER_SEC; + u32 gather_timeout = TICKS_PER_SEC; u32 now = currticks(); struct io_buffer *iob; int signal; @@ -2606,7 +2606,7 @@ static void net80211_rx_frag ( struct net80211_device *dev, /* start a frag cache entry */ int i, newest = -1; u32 curr_ticks = currticks(), newest_ticks = 0; - u32 timeout = ticks_per_sec() * NET80211_FRAG_TIMEOUT; + u32 timeout = TICKS_PER_SEC * NET80211_FRAG_TIMEOUT; for ( i = 0; i < NET80211_NR_CONCURRENT_FRAGS; i++ ) { if ( dev->frags[i].in_use == 0 ) diff --git a/src/net/fcoe.c b/src/net/fcoe.c index c3258f15..f910eeea 100644 --- a/src/net/fcoe.c +++ b/src/net/fcoe.c @@ -1094,7 +1094,7 @@ static void fcoe_expired ( struct retry_timer *timer, int over __unused ) { /* Send keepalive */ start_timer_fixed ( &fcoe->timer, - ( ( fcoe->keepalive * TICKS_PER_SEC ) / 1000 ) ); + ( fcoe->keepalive * TICKS_PER_MS ) ); fcoe_fip_tx_keepalive ( fcoe ); /* Abandon FCF if we have not seen its advertisements */ diff --git a/src/net/stp.c b/src/net/stp.c index defdaed9..3d78400a 100644 --- a/src/net/stp.c +++ b/src/net/stp.c @@ -110,7 +110,7 @@ static int stp_rx ( struct io_buffer *iobuf, struct net_device *netdev, "forwarding\n", netdev->name, eth_ntoa ( stp->sender.mac ), ntohs ( stp->port ), stp->flags ); - hello = ( ( ntohs ( stp->hello ) * TICKS_PER_SEC ) / 256 ); + hello = ( ntohs ( stp->hello ) * ( TICKS_PER_SEC / 256 ) ); netdev_link_block ( netdev, ( hello * 2 ) ); rc = -ENETUNREACH; goto done; |