Skip to content

Commit

Permalink
[PKT_SCHED]: GRED: Introduce tc_index_to_dp()
Browse files Browse the repository at this point in the history
Adds a transformation function returning the DP index for a
given skb according to its tc_index.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
  • Loading branch information
Thomas Graf authored and Thomas Graf committed Nov 5, 2005
1 parent edf7a7b commit 716a1b4
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions net/sched/sch_gred.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#endif

#define GRED_DEF_PRIO (MAX_DPs / 2)
#define GRED_VQ_MASK (MAX_DPs - 1)

struct gred_sched_data;
struct gred_sched;
Expand Down Expand Up @@ -153,21 +154,28 @@ static inline unsigned int gred_backlog(struct gred_sched *table,
return q->backlog;
}

static inline u16 tc_index_to_dp(struct sk_buff *skb)
{
return skb->tc_index & GRED_VQ_MASK;
}

static int
gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
{
struct gred_sched_data *q=NULL;
struct gred_sched *t= qdisc_priv(sch);
unsigned long qavg = 0;
int i=0;
u16 dp;

if (!t->initd && skb_queue_len(&sch->q) < (sch->dev->tx_queue_len ? : 1)) {
D2PRINTK("NO GRED Queues setup yet! Enqueued anyway\n");
goto do_enqueue;
}

dp = tc_index_to_dp(skb);

if ( ((skb->tc_index&0xf) > (t->DPs -1)) || !(q=t->tab[skb->tc_index&0xf])) {
if (dp >= t->DPs || (q = t->tab[dp]) == NULL) {
printk("GRED: setting to default (%d)\n ",t->def);
if (!(q=t->tab[t->def])) {
DPRINTK("GRED: setting to default FAILED! dropping!! "
Expand All @@ -176,7 +184,7 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
}
/* fix tc_index? --could be controvesial but needed for
requeueing */
skb->tc_index=(skb->tc_index&0xfffffff0) | t->def;
skb->tc_index=(skb->tc_index & ~GRED_VQ_MASK) | t->def;
}

D2PRINTK("gred_enqueue virtualQ 0x%x classid %x backlog %d "
Expand Down Expand Up @@ -245,9 +253,8 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
static int
gred_requeue(struct sk_buff *skb, struct Qdisc* sch)
{
struct gred_sched_data *q;
struct gred_sched *t= qdisc_priv(sch);
q= t->tab[(skb->tc_index&0xf)];
struct gred_sched *t = qdisc_priv(sch);
struct gred_sched_data *q = t->tab[tc_index_to_dp(skb)];
/* error checking here -- probably unnecessary */

if (red_is_idling(&q->parms))
Expand All @@ -267,13 +274,14 @@ gred_dequeue(struct Qdisc* sch)
skb = qdisc_dequeue_head(sch);

if (skb) {
q= t->tab[(skb->tc_index&0xf)];
q = t->tab[tc_index_to_dp(skb)];
if (q) {
q->backlog -= skb->len;
if (!q->backlog && !gred_wred_mode(t))
red_start_of_idle_period(&q->parms);
} else {
D2PRINTK("gred_dequeue: skb has bad tcindex %x\n",skb->tc_index&0xf);
D2PRINTK("gred_dequeue: skb has bad tcindex %x\n",
tc_index_to_dp(skb));
}
return skb;
}
Expand All @@ -300,14 +308,15 @@ static unsigned int gred_drop(struct Qdisc* sch)
skb = qdisc_dequeue_tail(sch);
if (skb) {
unsigned int len = skb->len;
q= t->tab[(skb->tc_index&0xf)];
q = t->tab[tc_index_to_dp(skb)];
if (q) {
q->backlog -= len;
q->stats.other++;
if (!q->backlog && !gred_wred_mode(t))
red_start_of_idle_period(&q->parms);
} else {
D2PRINTK("gred_dequeue: skb has bad tcindex %x\n",skb->tc_index&0xf);
D2PRINTK("gred_dequeue: skb has bad tcindex %x\n",
tc_index_to_dp(skb));
}

qdisc_drop(skb, sch);
Expand Down

0 comments on commit 716a1b4

Please sign in to comment.