Commit c045a734 authored by Yang Yingliang's avatar Yang Yingliang Committed by David S. Miller

sch_netem: replace magic numbers with enumerate in GE model

Replace some magic numbers which describe states of GE model
loss generator with enumerate.
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 49545a77
...@@ -117,6 +117,11 @@ struct netem_sched_data { ...@@ -117,6 +117,11 @@ struct netem_sched_data {
LOST_IN_BURST_PERIOD, LOST_IN_BURST_PERIOD,
} _4_state_model; } _4_state_model;
enum {
GOOD_STATE = 1,
BAD_STATE,
} GE_state_model;
/* Correlated Loss Generation models */ /* Correlated Loss Generation models */
struct clgstate { struct clgstate {
/* state of the Markov chain */ /* state of the Markov chain */
...@@ -272,15 +277,15 @@ static bool loss_gilb_ell(struct netem_sched_data *q) ...@@ -272,15 +277,15 @@ static bool loss_gilb_ell(struct netem_sched_data *q)
struct clgstate *clg = &q->clg; struct clgstate *clg = &q->clg;
switch (clg->state) { switch (clg->state) {
case 1: case GOOD_STATE:
if (prandom_u32() < clg->a1) if (prandom_u32() < clg->a1)
clg->state = 2; clg->state = BAD_STATE;
if (prandom_u32() < clg->a4) if (prandom_u32() < clg->a4)
return true; return true;
break; break;
case 2: case BAD_STATE:
if (prandom_u32() < clg->a2) if (prandom_u32() < clg->a2)
clg->state = 1; clg->state = GOOD_STATE;
if (prandom_u32() > clg->a3) if (prandom_u32() > clg->a3)
return true; return true;
} }
......
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