sch_red: generalize accurate MAX_P support to RED/GRED/CHOKE
Now RED uses a Q0.32 number to store max_p (max probability), allow RED/GRED/CHOKE to use/report full resolution at config/dump time. Old tc binaries are non aware of new attributes, and still set/get Plog. New tc binary set/get both Plog and max_p for backward compatibility, they display "probability value" if they get max_p from new kernels. # tc -d qdisc show dev ... ... qdisc red 10: parent 1:1 limit 360Kb min 30Kb max 90Kb ecn ewma 5 probability 0.09 Scell_log 15 Make sure we avoid potential divides by 0 in reciprocal_value(), if (max_th - min_th) is big. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
0221cd5154
commit
a73ed26bba
@@ -170,6 +170,7 @@ static void red_destroy(struct Qdisc *sch)
|
||||
static const struct nla_policy red_policy[TCA_RED_MAX + 1] = {
|
||||
[TCA_RED_PARMS] = { .len = sizeof(struct tc_red_qopt) },
|
||||
[TCA_RED_STAB] = { .len = RED_STAB_SIZE },
|
||||
[TCA_RED_MAX_P] = { .type = NLA_U32 },
|
||||
};
|
||||
|
||||
static int red_change(struct Qdisc *sch, struct nlattr *opt)
|
||||
@@ -179,6 +180,7 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt)
|
||||
struct tc_red_qopt *ctl;
|
||||
struct Qdisc *child = NULL;
|
||||
int err;
|
||||
u32 max_P;
|
||||
|
||||
if (opt == NULL)
|
||||
return -EINVAL;
|
||||
@@ -191,6 +193,8 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt)
|
||||
tb[TCA_RED_STAB] == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
max_P = tb[TCA_RED_MAX_P] ? nla_get_u32(tb[TCA_RED_MAX_P]) : 0;
|
||||
|
||||
ctl = nla_data(tb[TCA_RED_PARMS]);
|
||||
|
||||
if (ctl->limit > 0) {
|
||||
@@ -209,8 +213,9 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt)
|
||||
}
|
||||
|
||||
red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog,
|
||||
ctl->Plog, ctl->Scell_log,
|
||||
nla_data(tb[TCA_RED_STAB]));
|
||||
ctl->Plog, ctl->Scell_log,
|
||||
nla_data(tb[TCA_RED_STAB]),
|
||||
max_P);
|
||||
|
||||
del_timer(&q->adapt_timer);
|
||||
if (ctl->flags & TC_RED_ADAPTATIVE)
|
||||
|
Reference in New Issue
Block a user