summaryrefslogtreecommitdiff
path: root/patches/backport-adjustments/sch_codel.patch
blob: c6d6618a1c1d2ae87dd66340484a8170eb92eb9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
--- a/compat/net-sched-sch_codel.c
+++ b/compat/net-sched-sch_codel.c
@@ -58,6 +58,9 @@ struct codel_sched_data {
 	struct codel_vars	vars;
 	struct codel_stats	stats;
 	u32			drop_overlimit;
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
+	u32 limit;
+#endif
 };
 
 /* This is the specific function called from codel_dequeue()
@@ -95,11 +98,16 @@ static int codel_qdisc_enqueue(struct sk
 {
 	struct codel_sched_data *q;
 
+	q = qdisc_priv(sch);
+
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
+	if (likely(qdisc_qlen(sch) < q->limit)) {
+#else
 	if (likely(qdisc_qlen(sch) < sch->limit)) {
+#endif
 		codel_set_enqueue_time(skb);
 		return qdisc_enqueue_tail(skb, sch);
 	}
-	q = qdisc_priv(sch);
 	q->drop_overlimit++;
 	return qdisc_drop(skb, sch);
 }
@@ -140,13 +148,21 @@ static int codel_change(struct Qdisc *sc
 	}
 
 	if (tb[TCA_CODEL_LIMIT])
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
+		q->limit = nla_get_u32(tb[TCA_CODEL_LIMIT]);
+#else
 		sch->limit = nla_get_u32(tb[TCA_CODEL_LIMIT]);
+#endif
 
 	if (tb[TCA_CODEL_ECN])
 		q->params.ecn = !!nla_get_u32(tb[TCA_CODEL_ECN]);
 
 	qlen = sch->q.qlen;
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
+	while (sch->q.qlen > q->limit) {
+#else
 	while (sch->q.qlen > sch->limit) {
+#endif
 		struct sk_buff *skb = __skb_dequeue(&sch->q);
 
 		sch->qstats.backlog -= qdisc_pkt_len(skb);
@@ -162,7 +178,11 @@ static int codel_init(struct Qdisc *sch,
 {
 	struct codel_sched_data *q = qdisc_priv(sch);
 
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
+	q->limit = DEFAULT_CODEL_LIMIT;
+#else
 	sch->limit = DEFAULT_CODEL_LIMIT;
+#endif
 
 	codel_params_init(&q->params);
 	codel_vars_init(&q->vars);
@@ -175,7 +195,11 @@ static int codel_init(struct Qdisc *sch,
 			return err;
 	}
 
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
+	if (q->limit >= 1)
+#else
 	if (sch->limit >= 1)
+#endif
 		sch->flags |= TCQ_F_CAN_BYPASS;
 	else
 		sch->flags &= ~TCQ_F_CAN_BYPASS;
@@ -195,7 +219,11 @@ static int codel_dump(struct Qdisc *sch,
 	if (nla_put_u32(skb, TCA_CODEL_TARGET,
 			codel_time_to_us(q->params.target)) ||
 	    nla_put_u32(skb, TCA_CODEL_LIMIT,
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
+			q->limit) ||
+#else
 			sch->limit) ||
+#endif
 	    nla_put_u32(skb, TCA_CODEL_INTERVAL,
 			codel_time_to_us(q->params.interval)) ||
 	    nla_put_u32(skb, TCA_CODEL_ECN,
@@ -248,7 +276,9 @@ static struct Qdisc_ops codel_qdisc_ops
 
 	.enqueue	=	codel_qdisc_enqueue,
 	.dequeue	=	codel_qdisc_dequeue,
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
 	.peek		=	qdisc_peek_dequeued,
+#endif
 	.init		=	codel_init,
 	.reset		=	codel_reset,
 	.change 	=	codel_change,