Commit b407621c authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

[NETEM]: use better types for time values

The random number generator always generates 32 bit values.
The time values are limited by psched_tdiff_t
Signed-off-by: default avatarStephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a362e0a7
...@@ -57,19 +57,20 @@ struct netem_sched_data { ...@@ -57,19 +57,20 @@ struct netem_sched_data {
struct Qdisc *qdisc; struct Qdisc *qdisc;
struct qdisc_watchdog watchdog; struct qdisc_watchdog watchdog;
u32 latency; psched_tdiff_t latency;
psched_tdiff_t jitter;
u32 loss; u32 loss;
u32 limit; u32 limit;
u32 counter; u32 counter;
u32 gap; u32 gap;
u32 jitter;
u32 duplicate; u32 duplicate;
u32 reorder; u32 reorder;
u32 corrupt; u32 corrupt;
struct crndstate { struct crndstate {
unsigned long last; u32 last;
unsigned long rho; u32 rho;
} delay_cor, loss_cor, dup_cor, reorder_cor, corrupt_cor; } delay_cor, loss_cor, dup_cor, reorder_cor, corrupt_cor;
struct disttable { struct disttable {
...@@ -96,7 +97,7 @@ static void init_crandom(struct crndstate *state, unsigned long rho) ...@@ -96,7 +97,7 @@ static void init_crandom(struct crndstate *state, unsigned long rho)
* Next number depends on last value. * Next number depends on last value.
* rho is scaled to avoid floating point. * rho is scaled to avoid floating point.
*/ */
static unsigned long get_crandom(struct crndstate *state) static u32 get_crandom(struct crndstate *state)
{ {
u64 value, rho; u64 value, rho;
unsigned long answer; unsigned long answer;
...@@ -115,11 +116,13 @@ static unsigned long get_crandom(struct crndstate *state) ...@@ -115,11 +116,13 @@ static unsigned long get_crandom(struct crndstate *state)
* std deviation sigma. Uses table lookup to approximate the desired * std deviation sigma. Uses table lookup to approximate the desired
* distribution, and a uniformly-distributed pseudo-random source. * distribution, and a uniformly-distributed pseudo-random source.
*/ */
static long tabledist(unsigned long mu, long sigma, static psched_tdiff_t tabledist(psched_tdiff_t mu, psched_tdiff_t sigma,
struct crndstate *state, const struct disttable *dist) struct crndstate *state,
const struct disttable *dist)
{ {
long t, x; psched_tdiff_t x;
unsigned long rnd; long t;
u32 rnd;
if (sigma == 0) if (sigma == 0)
return mu; return mu;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment