]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sched/sch_hfsc.c
Driver core: fix class glue dir cleanup logic
[linux-2.6-omap-h63xx.git] / net / sched / sch_hfsc.c
index 3cc2714fd5ae4888f1f1c16216af573134edb680..a6ad491e434b90bb7fb866ac743adea3180224b5 100644 (file)
@@ -53,7 +53,6 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/errno.h>
-#include <linux/jiffies.h>
 #include <linux/compiler.h>
 #include <linux/spinlock.h>
 #include <linux/skbuff.h>
 #include <linux/list.h>
 #include <linux/rbtree.h>
 #include <linux/init.h>
-#include <linux/netdevice.h>
 #include <linux/rtnetlink.h>
 #include <linux/pkt_sched.h>
+#include <net/netlink.h>
 #include <net/pkt_sched.h>
 #include <net/pkt_cls.h>
-#include <asm/system.h>
 #include <asm/div64.h>
 
 /*
@@ -121,7 +119,6 @@ struct hfsc_class
        struct gnet_stats_basic bstats;
        struct gnet_stats_queue qstats;
        struct gnet_stats_rate_est rate_est;
-       spinlock_t      *stats_lock;
        unsigned int    level;          /* class level in hierarchy */
        struct tcf_proto *filter_list;  /* filter list */
        unsigned int    filter_cnt;     /* filter count */
@@ -163,7 +160,7 @@ struct hfsc_class
        u64     cl_vtoff;               /* inter-period cumulative vt offset */
        u64     cl_cvtmax;              /* max child's vt in the last period */
        u64     cl_cvtoff;              /* cumulative cvtmax of all periods */
-       u64     cl_pcvtoff;             /* parent's cvtoff at initalization
+       u64     cl_pcvtoff;             /* parent's cvtoff at initialization
                                           time */
 
        struct internal_sc cl_rsc;      /* internal real-time service curve */
@@ -434,8 +431,8 @@ m2sm(u32 m)
        u64 sm;
 
        sm = ((u64)m << SM_SHIFT);
-       sm += PSCHED_JIFFIE2US(HZ) - 1;
-       do_div(sm, PSCHED_JIFFIE2US(HZ));
+       sm += PSCHED_TICKS_PER_SEC - 1;
+       do_div(sm, PSCHED_TICKS_PER_SEC);
        return sm;
 }
 
@@ -448,7 +445,7 @@ m2ism(u32 m)
        if (m == 0)
                ism = HT_INFINITY;
        else {
-               ism = ((u64)PSCHED_JIFFIE2US(HZ) << ISM_SHIFT);
+               ism = ((u64)PSCHED_TICKS_PER_SEC << ISM_SHIFT);
                ism += m - 1;
                do_div(ism, m);
        }
@@ -461,7 +458,7 @@ d2dx(u32 d)
 {
        u64 dx;
 
-       dx = ((u64)d * PSCHED_JIFFIE2US(HZ));
+       dx = ((u64)d * PSCHED_TICKS_PER_SEC);
        dx += USEC_PER_SEC - 1;
        do_div(dx, USEC_PER_SEC);
        return dx;
@@ -473,7 +470,7 @@ sm2m(u64 sm)
 {
        u64 m;
 
-       m = (sm * PSCHED_JIFFIE2US(HZ)) >> SM_SHIFT;
+       m = (sm * PSCHED_TICKS_PER_SEC) >> SM_SHIFT;
        return (u32)m;
 }
 
@@ -484,7 +481,7 @@ dx2d(u64 dx)
        u64 d;
 
        d = dx * USEC_PER_SEC;
-       do_div(d, PSCHED_JIFFIE2US(HZ));
+       do_div(d, PSCHED_TICKS_PER_SEC);
        return (u32)d;
 }
 
@@ -628,9 +625,7 @@ rtsc_min(struct runtime_sc *rtsc, struct internal_sc *isc, u64 x, u64 y)
 static void
 init_ed(struct hfsc_class *cl, unsigned int next_len)
 {
-       u64 cur_time;
-
-       PSCHED_GET_TIME(cur_time);
+       u64 cur_time = psched_get_time();
 
        /* update the deadline curve */
        rtsc_min(&cl->cl_deadline, &cl->cl_rsc, cur_time, cl->cl_cumul);
@@ -753,7 +748,7 @@ init_vf(struct hfsc_class *cl, unsigned int len)
                        if (cl->cl_flags & HFSC_USC) {
                                /* class has upper limit curve */
                                if (cur_time == 0)
-                                       PSCHED_GET_TIME(cur_time);
+                                       cur_time = psched_get_time();
 
                                /* update the ulimit curve */
                                rtsc_min(&cl->cl_ulimit, &cl->cl_usc, cur_time,
@@ -1037,7 +1032,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
                        if (cl->cl_parent == NULL && parentid != TC_H_ROOT)
                                return -EINVAL;
                }
-               PSCHED_GET_TIME(cur_time);
+               cur_time = psched_get_time();
 
                sch_tree_lock(sch);
                if (rsc != NULL)
@@ -1055,11 +1050,10 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
                }
                sch_tree_unlock(sch);
 
-#ifdef CONFIG_NET_ESTIMATOR
                if (tca[TCA_RATE-1])
                        gen_replace_estimator(&cl->bstats, &cl->rate_est,
-                               cl->stats_lock, tca[TCA_RATE-1]);
-#endif
+                                             &sch->dev->queue_lock,
+                                             tca[TCA_RATE-1]);
                return 0;
        }
 
@@ -1099,7 +1093,6 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
        cl->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops, classid);
        if (cl->qdisc == NULL)
                cl->qdisc = &noop_qdisc;
-       cl->stats_lock = &sch->dev->queue_lock;
        INIT_LIST_HEAD(&cl->children);
        cl->vt_tree = RB_ROOT;
        cl->cf_tree = RB_ROOT;
@@ -1113,36 +1106,21 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
        cl->cl_pcvtoff = parent->cl_cvtoff;
        sch_tree_unlock(sch);
 
-#ifdef CONFIG_NET_ESTIMATOR
        if (tca[TCA_RATE-1])
                gen_new_estimator(&cl->bstats, &cl->rate_est,
-                       cl->stats_lock, tca[TCA_RATE-1]);
-#endif
+                                 &sch->dev->queue_lock, tca[TCA_RATE-1]);
        *arg = (unsigned long)cl;
        return 0;
 }
 
-static void
-hfsc_destroy_filters(struct tcf_proto **fl)
-{
-       struct tcf_proto *tp;
-
-       while ((tp = *fl) != NULL) {
-               *fl = tp->next;
-               tcf_destroy(tp);
-       }
-}
-
 static void
 hfsc_destroy_class(struct Qdisc *sch, struct hfsc_class *cl)
 {
        struct hfsc_sched *q = qdisc_priv(sch);
 
-       hfsc_destroy_filters(&cl->filter_list);
+       tcf_destroy_chain(cl->filter_list);
        qdisc_destroy(cl->qdisc);
-#ifdef CONFIG_NET_ESTIMATOR
        gen_kill_estimator(&cl->bstats, &cl->rate_est);
-#endif
        if (cl != &q->root)
                kfree(cl);
 }
@@ -1196,9 +1174,6 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
                case TC_ACT_SHOT:
                        return NULL;
                }
-#elif defined(CONFIG_NET_CLS_POLICE)
-               if (result == TC_POLICE_SHOT)
-                       return NULL;
 #endif
                if ((cl = (struct hfsc_class *)res.class) == NULL) {
                        if ((cl = hfsc_find_class(res.classid, sch)) == NULL)
@@ -1363,7 +1338,7 @@ hfsc_dump_class(struct Qdisc *sch, unsigned long arg, struct sk_buff *skb,
                struct tcmsg *tcm)
 {
        struct hfsc_class *cl = (struct hfsc_class *)arg;
-       unsigned char *b = skb->tail;
+       unsigned char *b = skb_tail_pointer(skb);
        struct rtattr *rta = (struct rtattr *)b;
 
        tcm->tcm_parent = cl->cl_parent ? cl->cl_parent->classid : TC_H_ROOT;
@@ -1374,11 +1349,11 @@ hfsc_dump_class(struct Qdisc *sch, unsigned long arg, struct sk_buff *skb,
        RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
        if (hfsc_dump_curves(skb, cl) < 0)
                goto rtattr_failure;
-       rta->rta_len = skb->tail - b;
+       rta->rta_len = skb_tail_pointer(skb) - b;
        return skb->len;
 
  rtattr_failure:
-       skb_trim(skb, b - skb->data);
+       nlmsg_trim(skb, b);
        return -1;
 }
 
@@ -1396,9 +1371,7 @@ hfsc_dump_class_stats(struct Qdisc *sch, unsigned long arg,
        xstats.rtwork  = cl->cl_cumul;
 
        if (gnet_stats_copy_basic(d, &cl->bstats) < 0 ||
-#ifdef CONFIG_NET_ESTIMATOR
            gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
-#endif
            gnet_stats_copy_queue(d, &cl->qstats) < 0)
                return -1;
 
@@ -1460,8 +1433,6 @@ hfsc_init_qdisc(struct Qdisc *sch, struct rtattr *opt)
                return -EINVAL;
        qopt = RTA_DATA(opt);
 
-       sch->stats_lock = &sch->dev->queue_lock;
-
        q->defcls = qopt->defcls;
        for (i = 0; i < HFSC_HSIZE; i++)
                INIT_LIST_HEAD(&q->clhash[i]);
@@ -1476,7 +1447,6 @@ hfsc_init_qdisc(struct Qdisc *sch, struct rtattr *opt)
                                          sch->handle);
        if (q->root.qdisc == NULL)
                q->root.qdisc = &noop_qdisc;
-       q->root.stats_lock = &sch->dev->queue_lock;
        INIT_LIST_HEAD(&q->root.children);
        q->root.vt_tree = RB_ROOT;
        q->root.cf_tree = RB_ROOT;
@@ -1576,7 +1546,7 @@ static int
 hfsc_dump_qdisc(struct Qdisc *sch, struct sk_buff *skb)
 {
        struct hfsc_sched *q = qdisc_priv(sch);
-       unsigned char *b = skb->tail;
+       unsigned char *b = skb_tail_pointer(skb);
        struct tc_hfsc_qopt qopt;
 
        qopt.defcls = q->defcls;
@@ -1584,7 +1554,7 @@ hfsc_dump_qdisc(struct Qdisc *sch, struct sk_buff *skb)
        return skb->len;
 
  rtattr_failure:
-       skb_trim(skb, b - skb->data);
+       nlmsg_trim(skb, b);
        return -1;
 }
 
@@ -1638,7 +1608,7 @@ hfsc_dequeue(struct Qdisc *sch)
        if ((skb = __skb_dequeue(&q->requeue)))
                goto out;
 
-       PSCHED_GET_TIME(cur_time);
+       cur_time = psched_get_time();
 
        /*
         * if there are eligible classes, use real-time criteria.