[PKT_SCHED]: GRED: Transform grio to GRED_RIO_MODE

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
Thomas Graf 2005-11-05 21:14:10 +01:00 committed by Thomas Graf
parent dea3f62852
commit d6fd4e9667

View File

@ -93,6 +93,7 @@ struct gred_sched_data
enum { enum {
GRED_WRED_MODE = 1, GRED_WRED_MODE = 1,
GRED_RIO_MODE,
}; };
struct gred_sched struct gred_sched
@ -102,7 +103,6 @@ struct gred_sched
u32 DPs; u32 DPs;
u32 def; u32 def;
u8 initd; u8 initd;
u8 grio;
}; };
static inline int gred_wred_mode(struct gred_sched *table) static inline int gred_wred_mode(struct gred_sched *table)
@ -120,6 +120,21 @@ static inline void gred_disable_wred_mode(struct gred_sched *table)
__clear_bit(GRED_WRED_MODE, &table->flags); __clear_bit(GRED_WRED_MODE, &table->flags);
} }
static inline int gred_rio_mode(struct gred_sched *table)
{
return test_bit(GRED_RIO_MODE, &table->flags);
}
static inline void gred_enable_rio_mode(struct gred_sched *table)
{
__set_bit(GRED_RIO_MODE, &table->flags);
}
static inline void gred_disable_rio_mode(struct gred_sched *table)
{
__clear_bit(GRED_RIO_MODE, &table->flags);
}
static inline int gred_wred_mode_check(struct Qdisc *sch) static inline int gred_wred_mode_check(struct Qdisc *sch)
{ {
struct gred_sched *table = qdisc_priv(sch); struct gred_sched *table = qdisc_priv(sch);
@ -173,7 +188,7 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
"general backlog %d\n",skb->tc_index&0xf,sch->handle,q->backlog, "general backlog %d\n",skb->tc_index&0xf,sch->handle,q->backlog,
sch->qstats.backlog); sch->qstats.backlog);
/* sum up all the qaves of prios <= to ours to get the new qave*/ /* sum up all the qaves of prios <= to ours to get the new qave*/
if (!gred_wred_mode(t) && t->grio) { if (!gred_wred_mode(t) && gred_rio_mode(t)) {
for (i=0;i<t->DPs;i++) { for (i=0;i<t->DPs;i++) {
if ((!t->tab[i]) || (i==q->DP)) if ((!t->tab[i]) || (i==q->DP))
continue; continue;
@ -386,12 +401,12 @@ static int gred_change(struct Qdisc *sch, struct rtattr *opt)
table->def=sopt->def_DP; table->def=sopt->def_DP;
if (sopt->grio) { if (sopt->grio) {
table->grio = 1; gred_enable_rio_mode(table);
gred_disable_wred_mode(table); gred_disable_wred_mode(table);
if (gred_wred_mode_check(sch)) if (gred_wred_mode_check(sch))
gred_enable_wred_mode(table); gred_enable_wred_mode(table);
} else { } else {
table->grio = 0; gred_disable_rio_mode(table);
gred_disable_wred_mode(table); gred_disable_wred_mode(table);
} }
@ -423,7 +438,7 @@ static int gred_change(struct Qdisc *sch, struct rtattr *opt)
} }
q= table->tab[ctl->DP]; q= table->tab[ctl->DP];
if (table->grio) { if (gred_rio_mode(table)) {
if (ctl->prio <=0) { if (ctl->prio <=0) {
if (table->def && table->tab[table->def]) { if (table->def && table->tab[table->def]) {
DPRINTK("\nGRED: DP %u does not have a prio" DPRINTK("\nGRED: DP %u does not have a prio"
@ -463,7 +478,7 @@ static int gred_change(struct Qdisc *sch, struct rtattr *opt)
PSCHED_SET_PASTPERFECT(q->qidlestart); PSCHED_SET_PASTPERFECT(q->qidlestart);
memcpy(q->Stab, RTA_DATA(tb[TCA_GRED_STAB-1]), 256); memcpy(q->Stab, RTA_DATA(tb[TCA_GRED_STAB-1]), 256);
if (table->grio) { if (gred_rio_mode(table)) {
gred_disable_wred_mode(table); gred_disable_wred_mode(table);
if (gred_wred_mode_check(sch)) if (gred_wred_mode_check(sch))
gred_enable_wred_mode(table); gred_enable_wred_mode(table);
@ -496,7 +511,7 @@ static int gred_change(struct Qdisc *sch, struct rtattr *opt)
q->qth_min = ctl->qth_min<<ctl->Wlog; q->qth_min = ctl->qth_min<<ctl->Wlog;
q->qth_max = ctl->qth_max<<ctl->Wlog; q->qth_max = ctl->qth_max<<ctl->Wlog;
if (table->grio) if (gred_rio_mode(table))
q->prio=table->tab[ctl->DP]->prio; q->prio=table->tab[ctl->DP]->prio;
else else
q->prio=8; q->prio=8;
@ -528,7 +543,12 @@ static int gred_init(struct Qdisc *sch, struct rtattr *opt)
sopt = RTA_DATA(tb2[TCA_GRED_DPS-1]); sopt = RTA_DATA(tb2[TCA_GRED_DPS-1]);
table->DPs=sopt->DPs; table->DPs=sopt->DPs;
table->def=sopt->def_DP; table->def=sopt->def_DP;
table->grio=sopt->grio;
if (sopt->grio)
gred_enable_rio_mode(table);
else
gred_disable_rio_mode(table);
table->initd=0; table->initd=0;
return 0; return 0;
} }