sch_sfq.c (14f0290ba44de6ed435fea24bba26e7868421c66) sch_sfq.c (cc7ec456f82da7f89a5b376e613b3ac4311b3e9a)
1/*
2 * net/sched/sch_sfq.c Stochastic Fairness Queueing discipline.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *

--- 78 unchanged lines hidden (view full) ---

87typedef unsigned char sfq_index;
88
89/*
90 * We dont use pointers to save space.
91 * Small indexes [0 ... SFQ_SLOTS - 1] are 'pointers' to slots[] array
92 * while following values [SFQ_SLOTS ... SFQ_SLOTS + SFQ_DEPTH - 1]
93 * are 'pointers' to dep[] array
94 */
1/*
2 * net/sched/sch_sfq.c Stochastic Fairness Queueing discipline.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *

--- 78 unchanged lines hidden (view full) ---

87typedef unsigned char sfq_index;
88
89/*
90 * We dont use pointers to save space.
91 * Small indexes [0 ... SFQ_SLOTS - 1] are 'pointers' to slots[] array
92 * while following values [SFQ_SLOTS ... SFQ_SLOTS + SFQ_DEPTH - 1]
93 * are 'pointers' to dep[] array
94 */
95struct sfq_head
96{
95struct sfq_head {
97 sfq_index next;
98 sfq_index prev;
99};
100
101struct sfq_slot {
102 struct sk_buff *skblist_next;
103 struct sk_buff *skblist_prev;
104 sfq_index qlen; /* number of skbs in skblist */
105 sfq_index next; /* next slot in sfq chain */
106 struct sfq_head dep; /* anchor in dep[] chains */
107 unsigned short hash; /* hash value (index in ht[]) */
108 short allot; /* credit for this slot */
109};
110
96 sfq_index next;
97 sfq_index prev;
98};
99
100struct sfq_slot {
101 struct sk_buff *skblist_next;
102 struct sk_buff *skblist_prev;
103 sfq_index qlen; /* number of skbs in skblist */
104 sfq_index next; /* next slot in sfq chain */
105 struct sfq_head dep; /* anchor in dep[] chains */
106 unsigned short hash; /* hash value (index in ht[]) */
107 short allot; /* credit for this slot */
108};
109
111struct sfq_sched_data
112{
110struct sfq_sched_data {
113/* Parameters */
114 int perturb_period;
111/* Parameters */
112 int perturb_period;
115 unsigned quantum; /* Allotment per round: MUST BE >= MTU */
113 unsigned int quantum; /* Allotment per round: MUST BE >= MTU */
116 int limit;
117
118/* Variables */
119 struct tcf_proto *filter_list;
120 struct timer_list perturb_timer;
121 u32 perturbation;
122 sfq_index cur_depth; /* depth of longest slot */
123 unsigned short scaled_quantum; /* SFQ_ALLOT_SIZE(quantum) */

--- 8 unchanged lines hidden (view full) ---

132 */
133static inline struct sfq_head *sfq_dep_head(struct sfq_sched_data *q, sfq_index val)
134{
135 if (val < SFQ_SLOTS)
136 return &q->slots[val].dep;
137 return &q->dep[val - SFQ_SLOTS];
138}
139
114 int limit;
115
116/* Variables */
117 struct tcf_proto *filter_list;
118 struct timer_list perturb_timer;
119 u32 perturbation;
120 sfq_index cur_depth; /* depth of longest slot */
121 unsigned short scaled_quantum; /* SFQ_ALLOT_SIZE(quantum) */

--- 8 unchanged lines hidden (view full) ---

130 */
131static inline struct sfq_head *sfq_dep_head(struct sfq_sched_data *q, sfq_index val)
132{
133 if (val < SFQ_SLOTS)
134 return &q->slots[val].dep;
135 return &q->dep[val - SFQ_SLOTS];
136}
137
140static __inline__ unsigned sfq_fold_hash(struct sfq_sched_data *q, u32 h, u32 h1)
138static unsigned int sfq_fold_hash(struct sfq_sched_data *q, u32 h, u32 h1)
141{
142 return jhash_2words(h, h1, q->perturbation) & (SFQ_HASH_DIVISOR - 1);
143}
144
139{
140 return jhash_2words(h, h1, q->perturbation) & (SFQ_HASH_DIVISOR - 1);
141}
142
145static unsigned sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)
143static unsigned int sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)
146{
147 u32 h, h2;
148
149 switch (skb->protocol) {
150 case htons(ETH_P_IP):
151 {
152 const struct iphdr *iph;
153 int poff;
154
155 if (!pskb_network_may_pull(skb, sizeof(*iph)))
156 goto err;
157 iph = ip_hdr(skb);
158 h = (__force u32)iph->daddr;
159 h2 = (__force u32)iph->saddr ^ iph->protocol;
144{
145 u32 h, h2;
146
147 switch (skb->protocol) {
148 case htons(ETH_P_IP):
149 {
150 const struct iphdr *iph;
151 int poff;
152
153 if (!pskb_network_may_pull(skb, sizeof(*iph)))
154 goto err;
155 iph = ip_hdr(skb);
156 h = (__force u32)iph->daddr;
157 h2 = (__force u32)iph->saddr ^ iph->protocol;
160 if (iph->frag_off & htons(IP_MF|IP_OFFSET))
158 if (iph->frag_off & htons(IP_MF | IP_OFFSET))
161 break;
162 poff = proto_ports_offset(iph->protocol);
163 if (poff >= 0 &&
164 pskb_network_may_pull(skb, iph->ihl * 4 + 4 + poff)) {
165 iph = ip_hdr(skb);
159 break;
160 poff = proto_ports_offset(iph->protocol);
161 if (poff >= 0 &&
162 pskb_network_may_pull(skb, iph->ihl * 4 + 4 + poff)) {
163 iph = ip_hdr(skb);
166 h2 ^= *(u32*)((void *)iph + iph->ihl * 4 + poff);
164 h2 ^= *(u32 *)((void *)iph + iph->ihl * 4 + poff);
167 }
168 break;
169 }
170 case htons(ETH_P_IPV6):
171 {
172 struct ipv6hdr *iph;
173 int poff;
174
175 if (!pskb_network_may_pull(skb, sizeof(*iph)))
176 goto err;
177 iph = ipv6_hdr(skb);
178 h = (__force u32)iph->daddr.s6_addr32[3];
179 h2 = (__force u32)iph->saddr.s6_addr32[3] ^ iph->nexthdr;
180 poff = proto_ports_offset(iph->nexthdr);
181 if (poff >= 0 &&
182 pskb_network_may_pull(skb, sizeof(*iph) + 4 + poff)) {
183 iph = ipv6_hdr(skb);
165 }
166 break;
167 }
168 case htons(ETH_P_IPV6):
169 {
170 struct ipv6hdr *iph;
171 int poff;
172
173 if (!pskb_network_may_pull(skb, sizeof(*iph)))
174 goto err;
175 iph = ipv6_hdr(skb);
176 h = (__force u32)iph->daddr.s6_addr32[3];
177 h2 = (__force u32)iph->saddr.s6_addr32[3] ^ iph->nexthdr;
178 poff = proto_ports_offset(iph->nexthdr);
179 if (poff >= 0 &&
180 pskb_network_may_pull(skb, sizeof(*iph) + 4 + poff)) {
181 iph = ipv6_hdr(skb);
184 h2 ^= *(u32*)((void *)iph + sizeof(*iph) + poff);
182 h2 ^= *(u32 *)((void *)iph + sizeof(*iph) + poff);
185 }
186 break;
187 }
188 default:
189err:
190 h = (unsigned long)skb_dst(skb) ^ (__force u32)skb->protocol;
191 h2 = (unsigned long)skb->sk;
192 }

--- 511 unchanged lines hidden ---
183 }
184 break;
185 }
186 default:
187err:
188 h = (unsigned long)skb_dst(skb) ^ (__force u32)skb->protocol;
189 h2 = (unsigned long)skb->sk;
190 }

--- 511 unchanged lines hidden ---