Merge git://oss.sgi.com:8090/xfs/xfs-2.6
[linux-drm-fsl-dcu.git] / net / sched / sch_sfq.c
index 86d8da0cbd027262024277ea1ba7fe14164f7d4f..66f32051a99b4b182adf0db17fdb0c29ae67c3c8 100644 (file)
@@ -9,7 +9,6 @@
  * Authors:    Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -54,7 +53,7 @@
        Queuing using Deficit Round Robin", Proc. SIGCOMM 95.
 
 
-       This is not the thing that is usually called (W)FQ nowadays. 
+       This is not the thing that is usually called (W)FQ nowadays.
        It does not use any timestamp mechanism, but instead
        processes queues in round-robin order.
 
@@ -64,7 +63,7 @@
 
        DRAWBACKS:
 
-       - "Stochastic" -> It is not 100% fair. 
+       - "Stochastic" -> It is not 100% fair.
        When hash collisions occur, several flows are considered as one.
 
        - "Round-robin" -> It introduces larger delays than virtual clock
@@ -144,6 +143,7 @@ static unsigned sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)
                if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
                    (iph->protocol == IPPROTO_TCP ||
                     iph->protocol == IPPROTO_UDP ||
+                    iph->protocol == IPPROTO_UDPLITE ||
                     iph->protocol == IPPROTO_SCTP ||
                     iph->protocol == IPPROTO_DCCP ||
                     iph->protocol == IPPROTO_ESP))
@@ -157,6 +157,7 @@ static unsigned sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)
                h2 = iph->saddr.s6_addr32[3]^iph->nexthdr;
                if (iph->nexthdr == IPPROTO_TCP ||
                    iph->nexthdr == IPPROTO_UDP ||
+                   iph->nexthdr == IPPROTO_UDPLITE ||
                    iph->nexthdr == IPPROTO_SCTP ||
                    iph->nexthdr == IPPROTO_DCCP ||
                    iph->nexthdr == IPPROTO_ESP)
@@ -232,6 +233,7 @@ static unsigned int sfq_drop(struct Qdisc *sch)
                sfq_dec(q, x);
                sch->q.qlen--;
                sch->qstats.drops++;
+               sch->qstats.backlog -= len;
                return len;
        }
 
@@ -248,6 +250,7 @@ static unsigned int sfq_drop(struct Qdisc *sch)
                sch->q.qlen--;
                q->ht[q->hash[d]] = SFQ_DEPTH;
                sch->qstats.drops++;
+               sch->qstats.backlog -= len;
                return len;
        }
 
@@ -266,6 +269,7 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
                q->ht[hash] = x = q->dep[SFQ_DEPTH].next;
                q->hash[x] = hash;
        }
+       sch->qstats.backlog += skb->len;
        __skb_queue_tail(&q->qs[x], skb);
        sfq_inc(q, x);
        if (q->qs[x].qlen == 1) {               /* The flow is new */
@@ -301,6 +305,7 @@ sfq_requeue(struct sk_buff *skb, struct Qdisc* sch)
                q->ht[hash] = x = q->dep[SFQ_DEPTH].next;
                q->hash[x] = hash;
        }
+       sch->qstats.backlog += skb->len;
        __skb_queue_head(&q->qs[x], skb);
        sfq_inc(q, x);
        if (q->qs[x].qlen == 1) {               /* The flow is new */
@@ -344,6 +349,7 @@ sfq_dequeue(struct Qdisc* sch)
        skb = __skb_dequeue(&q->qs[a]);
        sfq_dec(q, a);
        sch->q.qlen--;
+       sch->qstats.backlog -= skb->len;
 
        /* Is the slot empty? */
        if (q->qs[a].qlen == 0) {
@@ -389,6 +395,7 @@ static int sfq_change(struct Qdisc *sch, struct rtattr *opt)
 {
        struct sfq_sched_data *q = qdisc_priv(sch);
        struct tc_sfq_qopt *ctl = RTA_DATA(opt);
+       unsigned int qlen;
 
        if (opt->rta_len < RTA_LENGTH(sizeof(*ctl)))
                return -EINVAL;
@@ -399,8 +406,10 @@ static int sfq_change(struct Qdisc *sch, struct rtattr *opt)
        if (ctl->limit)
                q->limit = min_t(u32, ctl->limit, SFQ_DEPTH);
 
+       qlen = sch->q.qlen;
        while (sch->q.qlen >= q->limit-1)
                sfq_drop(sch);
+       qdisc_tree_decrease_qlen(sch, qlen - sch->q.qlen);
 
        del_timer(&q->perturb_timer);
        if (q->perturb_period) {
@@ -492,7 +501,7 @@ static int __init sfq_module_init(void)
 {
        return register_qdisc(&sfq_qdisc_ops);
 }
-static void __exit sfq_module_exit(void) 
+static void __exit sfq_module_exit(void)
 {
        unregister_qdisc(&sfq_qdisc_ops);
 }