Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.git] / net / sched / sch_netem.c
index c9c649b..c5ea40c 100644 (file)
@@ -180,7 +180,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
         * skb will be queued.
         */
        if (count > 1 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
-               struct Qdisc *rootq = sch->dev->qdisc;
+               struct Qdisc *rootq = qdisc_root(sch);
                u32 dupsave = q->duplicate; /* prevent duplicating a dup... */
                q->duplicate = 0;
 
@@ -310,28 +310,6 @@ static void netem_reset(struct Qdisc *sch)
        qdisc_watchdog_cancel(&q->watchdog);
 }
 
-/* Pass size change message down to embedded FIFO */
-static int set_fifo_limit(struct Qdisc *q, int limit)
-{
-       struct nlattr *nla;
-       int ret = -ENOMEM;
-
-       /* Hack to avoid sending change message to non-FIFO */
-       if (strncmp(q->ops->id + 1, "fifo", 4) != 0)
-               return 0;
-
-       nla = kmalloc(nla_attr_size(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
-       if (nla) {
-               nla->nla_type = RTM_NEWQDISC;
-               nla->nla_len = nla_attr_size(sizeof(struct tc_fifo_qopt));
-               ((struct tc_fifo_qopt *)nla_data(nla))->limit = limit;
-
-               ret = q->ops->change(q, nla);
-               kfree(nla);
-       }
-       return ret;
-}
-
 /*
  * Distribution data is a variable size payload containing
  * signed 16 bit values.
@@ -341,6 +319,7 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
        struct netem_sched_data *q = qdisc_priv(sch);
        unsigned long n = nla_len(attr)/sizeof(__s16);
        const __s16 *data = nla_data(attr);
+       spinlock_t *root_lock;
        struct disttable *d;
        int i;
 
@@ -355,9 +334,11 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
        for (i = 0; i < n; i++)
                d->table[i] = data[i];
 
-       spin_lock_bh(&sch->dev->queue_lock);
+       root_lock = qdisc_root_lock(sch);
+
+       spin_lock_bh(root_lock);
        d = xchg(&q->delay_dist, d);
-       spin_unlock_bh(&sch->dev->queue_lock);
+       spin_unlock_bh(root_lock);
 
        kfree(d);
        return 0;
@@ -416,7 +397,7 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt)
        if (ret < 0)
                return ret;
 
-       ret = set_fifo_limit(q->qdisc, qopt->limit);
+       ret = fifo_set_limit(q->qdisc, qopt->limit);
        if (ret) {
                pr_debug("netem: can't set fifo limit\n");
                return ret;
@@ -517,7 +498,7 @@ static int tfifo_init(struct Qdisc *sch, struct nlattr *opt)
 
                q->limit = ctl->limit;
        } else
-               q->limit = max_t(u32, sch->dev->tx_queue_len, 1);
+               q->limit = max_t(u32, qdisc_dev(sch)->tx_queue_len, 1);
 
        q->oldest = PSCHED_PASTPERFECT;
        return 0;
@@ -558,7 +539,8 @@ static int netem_init(struct Qdisc *sch, struct nlattr *opt)
 
        qdisc_watchdog_init(&q->watchdog, sch);
 
-       q->qdisc = qdisc_create_dflt(sch->dev, &tfifo_qdisc_ops,
+       q->qdisc = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue,
+                                    &tfifo_qdisc_ops,
                                     TC_H_MAKE(sch->handle, 1));
        if (!q->qdisc) {
                pr_debug("netem: qdisc create failed\n");