aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2007-03-22 15:16:21 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:27:20 -0400
commitb407621c35ed5f9a0734e57472e9539117963768 (patch)
treeff38bcb206b20ebbc3c3f289bdce8ff7eb42f2f4 /net/sched
parenta362e0a7890c735a3ef63aab12d71ecfc6e6f4a5 (diff)
[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: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/sch_netem.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 791c615e3aad..4ac6df0a5b35 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -57,19 +57,20 @@ struct netem_sched_data {
57 struct Qdisc *qdisc; 57 struct Qdisc *qdisc;
58 struct qdisc_watchdog watchdog; 58 struct qdisc_watchdog watchdog;
59 59
60 u32 latency; 60 psched_tdiff_t latency;
61 psched_tdiff_t jitter;
62
61 u32 loss; 63 u32 loss;
62 u32 limit; 64 u32 limit;
63 u32 counter; 65 u32 counter;
64 u32 gap; 66 u32 gap;
65 u32 jitter;
66 u32 duplicate; 67 u32 duplicate;
67 u32 reorder; 68 u32 reorder;
68 u32 corrupt; 69 u32 corrupt;
69 70
70 struct crndstate { 71 struct crndstate {
71 unsigned long last; 72 u32 last;
72 unsigned long rho; 73 u32 rho;
73 } delay_cor, loss_cor, dup_cor, reorder_cor, corrupt_cor; 74 } delay_cor, loss_cor, dup_cor, reorder_cor, corrupt_cor;
74 75
75 struct disttable { 76 struct disttable {
@@ -96,7 +97,7 @@ static void init_crandom(struct crndstate *state, unsigned long rho)
96 * Next number depends on last value. 97 * Next number depends on last value.
97 * rho is scaled to avoid floating point. 98 * rho is scaled to avoid floating point.
98 */ 99 */
99static unsigned long get_crandom(struct crndstate *state) 100static u32 get_crandom(struct crndstate *state)
100{ 101{
101 u64 value, rho; 102 u64 value, rho;
102 unsigned long answer; 103 unsigned long answer;
@@ -115,11 +116,13 @@ static unsigned long get_crandom(struct crndstate *state)
115 * std deviation sigma. Uses table lookup to approximate the desired 116 * std deviation sigma. Uses table lookup to approximate the desired
116 * distribution, and a uniformly-distributed pseudo-random source. 117 * distribution, and a uniformly-distributed pseudo-random source.
117 */ 118 */
118static long tabledist(unsigned long mu, long sigma, 119static psched_tdiff_t tabledist(psched_tdiff_t mu, psched_tdiff_t sigma,
119 struct crndstate *state, const struct disttable *dist) 120 struct crndstate *state,
121 const struct disttable *dist)
120{ 122{
121 long t, x; 123 psched_tdiff_t x;
122 unsigned long rnd; 124 long t;
125 u32 rnd;
123 126
124 if (sigma == 0) 127 if (sigma == 0)
125 return mu; 128 return mu;