add fix for htb with tsc timers and disable hysteresis for more precise shaping
[openwrt.git] / target / linux / linux-2.4 / patches / generic / 212-htb_time_fix.patch
1 --- linux.old/net/sched/sch_htb.c       2005-11-15 14:09:41.548066000 +0100
2 +++ linux.dev/net/sched/sch_htb.c       2005-11-15 14:08:34.000000000 +0100
3 @@ -369,7 +369,7 @@
4                 struct list_head *l;
5                 list_for_each (l,q->hash+i) {
6                         struct htb_class *cl = list_entry(l,struct htb_class,hlist);
7 -                       long diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, 0);
8 +                       long long diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, 0);
9                         printk(KERN_DEBUG "htb*c%x m=%d t=%ld c=%ld pq=%lu df=%ld ql=%d "
10                                         "pa=%x f:",
11                                 cl->classid,cl->cmode,cl->tokens,cl->ctokens,
12 @@ -617,7 +617,7 @@
13   * mode transitions per time unit. The speed gain is about 1/6.
14   */
15  static __inline__ enum htb_cmode 
16 -htb_class_mode(struct htb_class *cl,long *diff)
17 +htb_class_mode(struct htb_class *cl,long long *diff)
18  {
19      long toks;
20  
21 @@ -650,7 +650,7 @@
22   * to mode other than HTB_CAN_SEND (see htb_add_to_wait_tree).
23   */
24  static void 
25 -htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, long *diff)
26 +htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, long long *diff)
27  { 
28         enum htb_cmode new_mode = htb_class_mode(cl,diff);
29         
30 @@ -815,7 +815,8 @@
31  static void htb_charge_class(struct htb_sched *q,struct htb_class *cl,
32                 int level,int bytes)
33  {      
34 -       long toks,diff;
35 +       long long diff;
36 +       long toks;
37         enum htb_cmode old_mode;
38         HTB_DBG(5,1,"htb_chrg_cl cl=%X lev=%d len=%d\n",cl->classid,level,bytes);
39  
40 @@ -831,7 +832,7 @@
41  #ifdef HTB_DEBUG
42                 if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) {
43                         if (net_ratelimit())
44 -                               printk(KERN_ERR "HTB: bad diff in charge, cl=%X diff=%lX now=%Lu then=%Lu j=%lu\n",
45 +                               printk(KERN_ERR "HTB: bad diff in charge, cl=%X diff=%Ld now=%Lu then=%Lu j=%lu\n",
46                                        cl->classid, diff,
47                                        (unsigned long long) q->now,
48                                        (unsigned long long) cl->t_c,
49 @@ -848,7 +849,7 @@
50                 }
51                 HTB_ACCNT (ctokens,cbuffer,ceil);
52                 cl->t_c = q->now;
53 -               HTB_DBG(5,2,"htb_chrg_clp cl=%X diff=%ld tok=%ld ctok=%ld\n",cl->classid,diff,cl->tokens,cl->ctokens);
54 +               HTB_DBG(5,2,"htb_chrg_clp cl=%X diff=%Ld tok=%ld ctok=%ld\n",cl->classid,diff,cl->tokens,cl->ctokens);
55  
56                 old_mode = cl->cmode; diff = 0;
57                 htb_change_class_mode(q,cl,&diff);
58 @@ -887,7 +888,7 @@
59                         level,q->wait_pq[level].rb_node,q->row_mask[level]);
60         for (i = 0; i < 500; i++) {
61                 struct htb_class *cl;
62 -               long diff;
63 +               long long diff;
64                 rb_node_t *p = q->wait_pq[level].rb_node;
65                 if (!p) return 0;
66                 while (p->rb_left) p = p->rb_left;
67 @@ -902,7 +903,7 @@
68  #ifdef HTB_DEBUG
69                 if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) {
70                         if (net_ratelimit())
71 -                               printk(KERN_ERR "HTB: bad diff in events, cl=%X diff=%lX now=%Lu then=%Lu j=%lu\n",
72 +                               printk(KERN_ERR "HTB: bad diff in events, cl=%X diff=%Ld now=%Lu then=%Lu j=%lu\n",
73                                        cl->classid, diff,
74                                        (unsigned long long) q->now,
75                                        (unsigned long long) cl->t_c,