sch_netem: replace magic numbers with enumerate in GE model
authorYang Yingliang <yangyingliang@huawei.com>
Fri, 14 Feb 2014 02:30:43 +0000 (10:30 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 14 Feb 2014 05:15:20 +0000 (00:15 -0500)
Replace some magic numbers which describe states of GE model
loss generator with enumerate.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_netem.c

index 4a5eb2841351cb5ce630c16ba6b0cd587d649bfa..4fced67e94c8ee9cd703a02e125e551bc0c38fd8 100644 (file)
@@ -117,6 +117,11 @@ struct netem_sched_data {
                LOST_IN_BURST_PERIOD,
        } _4_state_model;
 
+       enum {
+               GOOD_STATE = 1,
+               BAD_STATE,
+       } GE_state_model;
+
        /* Correlated Loss Generation models */
        struct clgstate {
                /* state of the Markov chain */
@@ -272,15 +277,15 @@ static bool loss_gilb_ell(struct netem_sched_data *q)
        struct clgstate *clg = &q->clg;
 
        switch (clg->state) {
-       case 1:
+       case GOOD_STATE:
                if (prandom_u32() < clg->a1)
-                       clg->state = 2;
+                       clg->state = BAD_STATE;
                if (prandom_u32() < clg->a4)
                        return true;
                break;
-       case 2:
+       case BAD_STATE:
                if (prandom_u32() < clg->a2)
-                       clg->state = 1;
+                       clg->state = GOOD_STATE;
                if (prandom_u32() > clg->a3)
                        return true;
        }