[NETLINK]: Use nlmsg_trim() where appropriate
[deliverable/linux.git] / net / sched / sch_hfsc.c
index f85cfba647f85ec2b12b2519dae8d87011543001..6a762cf781d77c59bf437c079c97f3a91558a7b7 100644 (file)
 #include <linux/skbuff.h>
 #include <linux/string.h>
 #include <linux/slab.h>
-#include <linux/timer.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>
@@ -192,7 +192,7 @@ struct hfsc_sched
        struct list_head droplist;              /* active leaf class list (for
                                                   dropping) */
        struct sk_buff_head requeue;            /* requeued packet */
-       struct timer_list wd_timer;             /* watchdog timer */
+       struct qdisc_watchdog watchdog;         /* watchdog timer */
 };
 
 #define        HT_INFINITY     0xffffffffffffffffULL   /* infinite time value */
@@ -435,8 +435,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;
 }
 
@@ -449,7 +449,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);
        }
@@ -462,7 +462,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;
@@ -474,7 +474,7 @@ sm2m(u64 sm)
 {
        u64 m;
 
-       m = (sm * PSCHED_JIFFIE2US(HZ)) >> SM_SHIFT;
+       m = (sm * PSCHED_TICKS_PER_SEC) >> SM_SHIFT;
        return (u32)m;
 }
 
@@ -485,7 +485,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;
 }
 
@@ -1364,7 +1364,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;
@@ -1375,11 +1375,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;
 }
 
@@ -1434,21 +1434,11 @@ hfsc_walk(struct Qdisc *sch, struct qdisc_walker *arg)
 }
 
 static void
-hfsc_watchdog(unsigned long arg)
-{
-       struct Qdisc *sch = (struct Qdisc *)arg;
-
-       sch->flags &= ~TCQ_F_THROTTLED;
-       netif_schedule(sch->dev);
-}
-
-static void
-hfsc_schedule_watchdog(struct Qdisc *sch, u64 cur_time)
+hfsc_schedule_watchdog(struct Qdisc *sch)
 {
        struct hfsc_sched *q = qdisc_priv(sch);
        struct hfsc_class *cl;
        u64 next_time = 0;
-       long delay;
 
        if ((cl = eltree_get_minel(q)) != NULL)
                next_time = cl->cl_e;
@@ -1457,11 +1447,7 @@ hfsc_schedule_watchdog(struct Qdisc *sch, u64 cur_time)
                        next_time = q->root.cl_cfmin;
        }
        WARN_ON(next_time == 0);
-       delay = next_time - cur_time;
-       delay = PSCHED_US2JIFFIE(delay);
-
-       sch->flags |= TCQ_F_THROTTLED;
-       mod_timer(&q->wd_timer, jiffies + delay);
+       qdisc_watchdog_schedule(&q->watchdog, next_time);
 }
 
 static int
@@ -1498,9 +1484,7 @@ hfsc_init_qdisc(struct Qdisc *sch, struct rtattr *opt)
 
        list_add(&q->root.hlist, &q->clhash[hfsc_hash(q->root.classid)]);
 
-       init_timer(&q->wd_timer);
-       q->wd_timer.function = hfsc_watchdog;
-       q->wd_timer.data = (unsigned long)sch;
+       qdisc_watchdog_init(&q->watchdog, sch);
 
        return 0;
 }
@@ -1570,8 +1554,7 @@ hfsc_reset_qdisc(struct Qdisc *sch)
        __skb_queue_purge(&q->requeue);
        q->eligible = RB_ROOT;
        INIT_LIST_HEAD(&q->droplist);
-       del_timer(&q->wd_timer);
-       sch->flags &= ~TCQ_F_THROTTLED;
+       qdisc_watchdog_cancel(&q->watchdog);
        sch->q.qlen = 0;
 }
 
@@ -1587,14 +1570,14 @@ hfsc_destroy_qdisc(struct Qdisc *sch)
                        hfsc_destroy_class(sch, cl);
        }
        __skb_queue_purge(&q->requeue);
-       del_timer(&q->wd_timer);
+       qdisc_watchdog_cancel(&q->watchdog);
 }
 
 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;
@@ -1602,7 +1585,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;
 }
 
@@ -1673,7 +1656,7 @@ hfsc_dequeue(struct Qdisc *sch)
                cl = vttree_get_minvt(&q->root, cur_time);
                if (cl == NULL) {
                        sch->qstats.overlimits++;
-                       hfsc_schedule_watchdog(sch, cur_time);
+                       hfsc_schedule_watchdog(sch);
                        return NULL;
                }
        }
This page took 0.027338 seconds and 5 git commands to generate.