net: convert BUG_TRAP to generic WARN_ON
[firefly-linux-kernel-4.4.55.git] / net / sched / sch_cbq.c
index 968b4c73c9c1cd93423272aaa1003b3f72ed2410..14954bf4a6836c8fe21731072af228d23f85b33e 100644 (file)
@@ -370,7 +370,6 @@ static int
 cbq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 {
        struct cbq_sched_data *q = qdisc_priv(sch);
-       int len = skb->len;
        int uninitialized_var(ret);
        struct cbq_class *cl = cbq_classify(skb, sch, &ret);
 
@@ -387,10 +386,11 @@ cbq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 #ifdef CONFIG_NET_CLS_ACT
        cl->q->__parent = sch;
 #endif
-       if ((ret = cl->q->enqueue(skb, cl->q)) == NET_XMIT_SUCCESS) {
+       ret = qdisc_enqueue(skb, cl->q);
+       if (ret == NET_XMIT_SUCCESS) {
                sch->q.qlen++;
                sch->bstats.packets++;
-               sch->bstats.bytes+=len;
+               sch->bstats.bytes += qdisc_pkt_len(skb);
                cbq_mark_toplevel(q, cl);
                if (!cl->next_alive)
                        cbq_activate_class(cl);
@@ -650,14 +650,13 @@ static enum hrtimer_restart cbq_undelay(struct hrtimer *timer)
        }
 
        sch->flags &= ~TCQ_F_THROTTLED;
-       netif_schedule(sch->dev);
+       __netif_schedule(sch);
        return HRTIMER_NORESTART;
 }
 
 #ifdef CONFIG_NET_CLS_ACT
 static int cbq_reshape_fail(struct sk_buff *skb, struct Qdisc *child)
 {
-       int len = skb->len;
        struct Qdisc *sch = child->__parent;
        struct cbq_sched_data *q = qdisc_priv(sch);
        struct cbq_class *cl = q->rx_class;
@@ -671,10 +670,10 @@ static int cbq_reshape_fail(struct sk_buff *skb, struct Qdisc *child)
                q->rx_class = cl;
                cl->q->__parent = sch;
 
-               if (cl->q->enqueue(skb, cl->q) == 0) {
+               if (qdisc_enqueue(skb, cl->q) == 0) {
                        sch->q.qlen++;
                        sch->bstats.packets++;
-                       sch->bstats.bytes+=len;
+                       sch->bstats.bytes += qdisc_pkt_len(skb);
                        if (!cl->next_alive)
                                cbq_activate_class(cl);
                        return 0;
@@ -880,7 +879,7 @@ cbq_dequeue_prio(struct Qdisc *sch, int prio)
                        if (skb == NULL)
                                goto skip_class;
 
-                       cl->deficit -= skb->len;
+                       cl->deficit -= qdisc_pkt_len(skb);
                        q->tx_class = cl;
                        q->tx_borrowed = borrow;
                        if (borrow != cl) {
@@ -888,11 +887,11 @@ cbq_dequeue_prio(struct Qdisc *sch, int prio)
                                borrow->xstats.borrows++;
                                cl->xstats.borrows++;
 #else
-                               borrow->xstats.borrows += skb->len;
-                               cl->xstats.borrows += skb->len;
+                               borrow->xstats.borrows += qdisc_pkt_len(skb);
+                               cl->xstats.borrows += qdisc_pkt_len(skb);
 #endif
                        }
-                       q->tx_len = skb->len;
+                       q->tx_len = qdisc_pkt_len(skb);
 
                        if (cl->deficit <= 0) {
                                q->active[prio] = cl;
@@ -1077,9 +1076,9 @@ static void cbq_normalize_quanta(struct cbq_sched_data *q, int prio)
                                cl->quantum = (cl->weight*cl->allot*q->nclasses[prio])/
                                        q->quanta[prio];
                        }
-                       if (cl->quantum <= 0 || cl->quantum>32*cl->qdisc->dev->mtu) {
+                       if (cl->quantum <= 0 || cl->quantum>32*qdisc_dev(cl->qdisc)->mtu) {
                                printk(KERN_WARNING "CBQ: class %08x has bad quantum==%ld, repaired.\n", cl->common.classid, cl->quantum);
-                               cl->quantum = cl->qdisc->dev->mtu/2 + 1;
+                               cl->quantum = qdisc_dev(cl->qdisc)->mtu/2 + 1;
                        }
                }
        }
@@ -1176,7 +1175,7 @@ static void cbq_unlink_class(struct cbq_class *this)
                                this->tparent->children = NULL;
                }
        } else {
-               BUG_TRAP(this->sibling == this);
+               WARN_ON(this->sibling != this);
        }
 }
 
@@ -1401,7 +1400,8 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
        q->link.sibling = &q->link;
        q->link.common.classid = sch->handle;
        q->link.qdisc = sch;
-       if (!(q->link.q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
+       if (!(q->link.q = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue,
+                                           &pfifo_qdisc_ops,
                                            sch->handle)))
                q->link.q = &noop_qdisc;
 
@@ -1410,7 +1410,7 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
        q->link.cpriority = TC_CBQ_MAXPRIO-1;
        q->link.ovl_strategy = TC_CBQ_OVL_CLASSIC;
        q->link.overlimit = cbq_ovl_classic;
-       q->link.allot = psched_mtu(sch->dev);
+       q->link.allot = psched_mtu(qdisc_dev(sch));
        q->link.quantum = q->link.allot;
        q->link.weight = q->link.R_tab->rate.rate;
 
@@ -1645,7 +1645,8 @@ static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
 
        if (cl) {
                if (new == NULL) {
-                       new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
+                       new = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue,
+                                               &pfifo_qdisc_ops,
                                                cl->common.classid);
                        if (new == NULL)
                                return -ENOBUFS;
@@ -1698,7 +1699,7 @@ static void cbq_destroy_class(struct Qdisc *sch, struct cbq_class *cl)
 {
        struct cbq_sched_data *q = qdisc_priv(sch);
 
-       BUG_TRAP(!cl->filters);
+       WARN_ON(cl->filters);
 
        tcf_destroy_chain(&cl->filter_list);
        qdisc_destroy(cl->q);
@@ -1742,12 +1743,13 @@ static void cbq_put(struct Qdisc *sch, unsigned long arg)
 
        if (--cl->refcnt == 0) {
 #ifdef CONFIG_NET_CLS_ACT
+               spinlock_t *root_lock = qdisc_root_lock(sch);
                struct cbq_sched_data *q = qdisc_priv(sch);
 
-               spin_lock_bh(&sch->dev->queue_lock);
+               spin_lock_bh(root_lock);
                if (q->rx_class == cl)
                        q->rx_class = NULL;
-               spin_unlock_bh(&sch->dev->queue_lock);
+               spin_unlock_bh(root_lock);
 #endif
 
                cbq_destroy_class(sch, cl);
@@ -1826,7 +1828,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t
 
                if (tca[TCA_RATE])
                        gen_replace_estimator(&cl->bstats, &cl->rate_est,
-                                             &sch->dev->queue_lock,
+                                             qdisc_root_lock(sch),
                                              tca[TCA_RATE]);
                return 0;
        }
@@ -1877,7 +1879,8 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t
        cl->R_tab = rtab;
        rtab = NULL;
        cl->refcnt = 1;
-       if (!(cl->q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops, classid)))
+       if (!(cl->q = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue,
+                                       &pfifo_qdisc_ops, classid)))
                cl->q = &noop_qdisc;
        cl->common.classid = classid;
        cl->tparent = parent;
@@ -1916,7 +1919,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t
 
        if (tca[TCA_RATE])
                gen_new_estimator(&cl->bstats, &cl->rate_est,
-                                 &sch->dev->queue_lock, tca[TCA_RATE]);
+                                 qdisc_root_lock(sch), tca[TCA_RATE]);
 
        *arg = (unsigned long)cl;
        return 0;