Pull remove-hotkey into release branch
[pandora-kernel.git] / net / sched / sch_gred.c
index 69f0fd4..fa1b4fe 100644 (file)
@@ -18,7 +18,6 @@
  *  For all the glorious comments look at include/net/red.h
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -55,6 +54,7 @@ struct gred_sched
 {
        struct gred_sched_data *tab[MAX_DPs];
        unsigned long   flags;
+       u32             red_flags;
        u32             DPs;
        u32             def;
        struct red_parms wred_set;
@@ -140,6 +140,16 @@ static inline void gred_store_wred_set(struct gred_sched *table,
        table->wred_set.qavg = q->parms.qavg;
 }
 
+static inline int gred_use_ecn(struct gred_sched *t)
+{
+       return t->red_flags & TC_RED_ECN;
+}
+
+static inline int gred_use_harddrop(struct gred_sched *t)
+{
+       return t->red_flags & TC_RED_HARDDROP;
+}
+
 static int gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
 {
        struct gred_sched_data *q=NULL;
@@ -198,13 +208,23 @@ static int gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
 
                case RED_PROB_MARK:
                        sch->qstats.overlimits++;
-                       q->stats.prob_drop++;
-                       goto congestion_drop;
+                       if (!gred_use_ecn(t) || !INET_ECN_set_ce(skb)) {
+                               q->stats.prob_drop++;
+                               goto congestion_drop;
+                       }
+
+                       q->stats.prob_mark++;
+                       break;
 
                case RED_HARD_MARK:
                        sch->qstats.overlimits++;
-                       q->stats.forced_drop++;
-                       goto congestion_drop;
+                       if (gred_use_harddrop(t) || !gred_use_ecn(t) ||
+                           !INET_ECN_set_ce(skb)) {
+                               q->stats.forced_drop++;
+                               goto congestion_drop;
+                       }
+                       q->stats.forced_mark++;
+                       break;
        }
 
        if (q->backlog + skb->len <= q->limit) {
@@ -315,7 +335,7 @@ static void gred_reset(struct Qdisc* sch)
 
        qdisc_reset_queue(sch);
 
-        for (i = 0; i < t->DPs; i++) {
+       for (i = 0; i < t->DPs; i++) {
                struct gred_sched_data *q = t->tab[i];
 
                if (!q)
@@ -348,6 +368,7 @@ static inline int gred_change_table_def(struct Qdisc *sch, struct rtattr *dps)
        sch_tree_lock(sch);
        table->DPs = sopt->DPs;
        table->def = sopt->def_DP;
+       table->red_flags = sopt->flags;
 
        /*
         * Every entry point to GRED is synchronized with the above code
@@ -372,7 +393,7 @@ static inline int gred_change_table_def(struct Qdisc *sch, struct rtattr *dps)
                               "shadowed VQ 0x%x\n", i);
                        gred_destroy_vq(table->tab[i]);
                        table->tab[i] = NULL;
-               }
+               }
        }
 
        return 0;
@@ -385,10 +406,9 @@ static inline int gred_change_vq(struct Qdisc *sch, int dp,
        struct gred_sched_data *q;
 
        if (table->tab[dp] == NULL) {
-               table->tab[dp] = kmalloc(sizeof(*q), GFP_KERNEL);
+               table->tab[dp] = kzalloc(sizeof(*q), GFP_KERNEL);
                if (table->tab[dp] == NULL)
                        return -ENOMEM;
-               memset(table->tab[dp], 0, sizeof(*q));
        }
 
        q = table->tab[dp];
@@ -489,6 +509,7 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
                .DPs    = table->DPs,
                .def_DP = table->def,
                .grio   = gred_rio_mode(table),
+               .flags  = table->red_flags,
        };
 
        opts = RTA_NEST(skb, TCA_OPTIONS);