diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-09-13 13:24:59 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-09-13 13:24:59 -0400 |
commit | 6aa20a2235535605db6d6d2bd850298b2fe7f31e (patch) | |
tree | df0b855043407b831d57f2f2c271f8aab48444f4 /drivers/net/shaper.c | |
parent | 7a291083225af6e22ffaa46b3d91cfc1a1ccaab4 (diff) |
drivers/net: Trim trailing whitespace
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/shaper.c')
-rw-r--r-- | drivers/net/shaper.c | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c index c7832e69f177..e886e8d7cfdf 100644 --- a/drivers/net/shaper.c +++ b/drivers/net/shaper.c | |||
@@ -8,12 +8,12 @@ | |||
8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
9 | * as published by the Free Software Foundation; either version | 9 | * as published by the Free Software Foundation; either version |
10 | * 2 of the License, or (at your option) any later version. | 10 | * 2 of the License, or (at your option) any later version. |
11 | * | ||
12 | * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide | ||
13 | * warranty for any of this software. This material is provided | ||
14 | * "AS-IS" and at no charge. | ||
15 | * | 11 | * |
16 | * | 12 | * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide |
13 | * warranty for any of this software. This material is provided | ||
14 | * "AS-IS" and at no charge. | ||
15 | * | ||
16 | * | ||
17 | * Algorithm: | 17 | * Algorithm: |
18 | * | 18 | * |
19 | * Queue Frame: | 19 | * Queue Frame: |
@@ -26,7 +26,7 @@ | |||
26 | * | 26 | * |
27 | * SHAPER_QLEN Maximum queued frames | 27 | * SHAPER_QLEN Maximum queued frames |
28 | * SHAPER_LATENCY Bounding latency on a frame. Leaving this latency | 28 | * SHAPER_LATENCY Bounding latency on a frame. Leaving this latency |
29 | * window drops the frame. This stops us queueing | 29 | * window drops the frame. This stops us queueing |
30 | * frames for a long time and confusing a remote | 30 | * frames for a long time and confusing a remote |
31 | * host. | 31 | * host. |
32 | * SHAPER_MAXSLIP Maximum time a priority frame may jump forward. | 32 | * SHAPER_MAXSLIP Maximum time a priority frame may jump forward. |
@@ -42,8 +42,8 @@ | |||
42 | * run off a 100-150Hz base clock typically. This gives us a resolution at | 42 | * run off a 100-150Hz base clock typically. This gives us a resolution at |
43 | * 200Kbit/second of about 2Kbit or 256 bytes. Above that our timer | 43 | * 200Kbit/second of about 2Kbit or 256 bytes. Above that our timer |
44 | * resolution may start to cause much more burstiness in the traffic. We | 44 | * resolution may start to cause much more burstiness in the traffic. We |
45 | * could avoid a lot of that by calling kick_shaper() at the end of the | 45 | * could avoid a lot of that by calling kick_shaper() at the end of the |
46 | * tied device transmissions. If you run above about 100K second you | 46 | * tied device transmissions. If you run above about 100K second you |
47 | * may need to tune the supposed speed rate for the right values. | 47 | * may need to tune the supposed speed rate for the right values. |
48 | * | 48 | * |
49 | * BUGS: | 49 | * BUGS: |
@@ -68,7 +68,7 @@ | |||
68 | * Use skb->cb for private data. | 68 | * Use skb->cb for private data. |
69 | * 2000/03 Andi Kleen | 69 | * 2000/03 Andi Kleen |
70 | */ | 70 | */ |
71 | 71 | ||
72 | #include <linux/module.h> | 72 | #include <linux/module.h> |
73 | #include <linux/kernel.h> | 73 | #include <linux/kernel.h> |
74 | #include <linux/fcntl.h> | 74 | #include <linux/fcntl.h> |
@@ -87,13 +87,13 @@ | |||
87 | #include <net/dst.h> | 87 | #include <net/dst.h> |
88 | #include <net/arp.h> | 88 | #include <net/arp.h> |
89 | 89 | ||
90 | struct shaper_cb { | 90 | struct shaper_cb { |
91 | unsigned long shapeclock; /* Time it should go out */ | 91 | unsigned long shapeclock; /* Time it should go out */ |
92 | unsigned long shapestamp; /* Stamp for shaper */ | 92 | unsigned long shapestamp; /* Stamp for shaper */ |
93 | __u32 shapelatency; /* Latency on frame */ | 93 | __u32 shapelatency; /* Latency on frame */ |
94 | __u32 shapelen; /* Frame length in clocks */ | 94 | __u32 shapelen; /* Frame length in clocks */ |
95 | __u16 shapepend; /* Pending */ | 95 | __u16 shapepend; /* Pending */ |
96 | }; | 96 | }; |
97 | #define SHAPERCB(skb) ((struct shaper_cb *) ((skb)->cb)) | 97 | #define SHAPERCB(skb) ((struct shaper_cb *) ((skb)->cb)) |
98 | 98 | ||
99 | static int sh_debug; /* Debug flag */ | 99 | static int sh_debug; /* Debug flag */ |
@@ -105,7 +105,7 @@ static void shaper_kick(struct shaper *sh); | |||
105 | /* | 105 | /* |
106 | * Compute clocks on a buffer | 106 | * Compute clocks on a buffer |
107 | */ | 107 | */ |
108 | 108 | ||
109 | static int shaper_clocks(struct shaper *shaper, struct sk_buff *skb) | 109 | static int shaper_clocks(struct shaper *shaper, struct sk_buff *skb) |
110 | { | 110 | { |
111 | int t=skb->len/shaper->bytespertick; | 111 | int t=skb->len/shaper->bytespertick; |
@@ -115,9 +115,9 @@ static int shaper_clocks(struct shaper *shaper, struct sk_buff *skb) | |||
115 | /* | 115 | /* |
116 | * Set the speed of a shaper. We compute this in bytes per tick since | 116 | * Set the speed of a shaper. We compute this in bytes per tick since |
117 | * thats how the machine wants to run. Quoted input is in bits per second | 117 | * thats how the machine wants to run. Quoted input is in bits per second |
118 | * as is traditional (note not BAUD). We assume 8 bit bytes. | 118 | * as is traditional (note not BAUD). We assume 8 bit bytes. |
119 | */ | 119 | */ |
120 | 120 | ||
121 | static void shaper_setspeed(struct shaper *shaper, int bitspersec) | 121 | static void shaper_setspeed(struct shaper *shaper, int bitspersec) |
122 | { | 122 | { |
123 | shaper->bitspersec=bitspersec; | 123 | shaper->bitspersec=bitspersec; |
@@ -129,40 +129,40 @@ static void shaper_setspeed(struct shaper *shaper, int bitspersec) | |||
129 | /* | 129 | /* |
130 | * Throw a frame at a shaper. | 130 | * Throw a frame at a shaper. |
131 | */ | 131 | */ |
132 | 132 | ||
133 | 133 | ||
134 | static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev) | 134 | static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev) |
135 | { | 135 | { |
136 | struct shaper *shaper = dev->priv; | 136 | struct shaper *shaper = dev->priv; |
137 | struct sk_buff *ptr; | 137 | struct sk_buff *ptr; |
138 | 138 | ||
139 | spin_lock(&shaper->lock); | 139 | spin_lock(&shaper->lock); |
140 | ptr=shaper->sendq.prev; | 140 | ptr=shaper->sendq.prev; |
141 | 141 | ||
142 | /* | 142 | /* |
143 | * Set up our packet details | 143 | * Set up our packet details |
144 | */ | 144 | */ |
145 | 145 | ||
146 | SHAPERCB(skb)->shapelatency=0; | 146 | SHAPERCB(skb)->shapelatency=0; |
147 | SHAPERCB(skb)->shapeclock=shaper->recovery; | 147 | SHAPERCB(skb)->shapeclock=shaper->recovery; |
148 | if(time_before(SHAPERCB(skb)->shapeclock, jiffies)) | 148 | if(time_before(SHAPERCB(skb)->shapeclock, jiffies)) |
149 | SHAPERCB(skb)->shapeclock=jiffies; | 149 | SHAPERCB(skb)->shapeclock=jiffies; |
150 | skb->priority=0; /* short term bug fix */ | 150 | skb->priority=0; /* short term bug fix */ |
151 | SHAPERCB(skb)->shapestamp=jiffies; | 151 | SHAPERCB(skb)->shapestamp=jiffies; |
152 | 152 | ||
153 | /* | 153 | /* |
154 | * Time slots for this packet. | 154 | * Time slots for this packet. |
155 | */ | 155 | */ |
156 | 156 | ||
157 | SHAPERCB(skb)->shapelen= shaper_clocks(shaper,skb); | 157 | SHAPERCB(skb)->shapelen= shaper_clocks(shaper,skb); |
158 | 158 | ||
159 | { | 159 | { |
160 | struct sk_buff *tmp; | 160 | struct sk_buff *tmp; |
161 | /* | 161 | /* |
162 | * Up our shape clock by the time pending on the queue | 162 | * Up our shape clock by the time pending on the queue |
163 | * (Should keep this in the shaper as a variable..) | 163 | * (Should keep this in the shaper as a variable..) |
164 | */ | 164 | */ |
165 | for(tmp=skb_peek(&shaper->sendq); tmp!=NULL && | 165 | for(tmp=skb_peek(&shaper->sendq); tmp!=NULL && |
166 | tmp!=(struct sk_buff *)&shaper->sendq; tmp=tmp->next) | 166 | tmp!=(struct sk_buff *)&shaper->sendq; tmp=tmp->next) |
167 | SHAPERCB(skb)->shapeclock+=SHAPERCB(tmp)->shapelen; | 167 | SHAPERCB(skb)->shapeclock+=SHAPERCB(tmp)->shapelen; |
168 | /* | 168 | /* |
@@ -191,7 +191,7 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
191 | /* | 191 | /* |
192 | * Transmit from a shaper | 192 | * Transmit from a shaper |
193 | */ | 193 | */ |
194 | 194 | ||
195 | static void shaper_queue_xmit(struct shaper *shaper, struct sk_buff *skb) | 195 | static void shaper_queue_xmit(struct shaper *shaper, struct sk_buff *skb) |
196 | { | 196 | { |
197 | struct sk_buff *newskb=skb_clone(skb, GFP_ATOMIC); | 197 | struct sk_buff *newskb=skb_clone(skb, GFP_ATOMIC); |
@@ -218,7 +218,7 @@ static void shaper_queue_xmit(struct shaper *shaper, struct sk_buff *skb) | |||
218 | /* | 218 | /* |
219 | * Timer handler for shaping clock | 219 | * Timer handler for shaping clock |
220 | */ | 220 | */ |
221 | 221 | ||
222 | static void shaper_timer(unsigned long data) | 222 | static void shaper_timer(unsigned long data) |
223 | { | 223 | { |
224 | struct shaper *shaper = (struct shaper *)data; | 224 | struct shaper *shaper = (struct shaper *)data; |
@@ -229,25 +229,25 @@ static void shaper_timer(unsigned long data) | |||
229 | } | 229 | } |
230 | 230 | ||
231 | /* | 231 | /* |
232 | * Kick a shaper queue and try and do something sensible with the | 232 | * Kick a shaper queue and try and do something sensible with the |
233 | * queue. | 233 | * queue. |
234 | */ | 234 | */ |
235 | 235 | ||
236 | static void shaper_kick(struct shaper *shaper) | 236 | static void shaper_kick(struct shaper *shaper) |
237 | { | 237 | { |
238 | struct sk_buff *skb; | 238 | struct sk_buff *skb; |
239 | 239 | ||
240 | /* | 240 | /* |
241 | * Walk the list (may be empty) | 241 | * Walk the list (may be empty) |
242 | */ | 242 | */ |
243 | 243 | ||
244 | while((skb=skb_peek(&shaper->sendq))!=NULL) | 244 | while((skb=skb_peek(&shaper->sendq))!=NULL) |
245 | { | 245 | { |
246 | /* | 246 | /* |
247 | * Each packet due to go out by now (within an error | 247 | * Each packet due to go out by now (within an error |
248 | * of SHAPER_BURST) gets kicked onto the link | 248 | * of SHAPER_BURST) gets kicked onto the link |
249 | */ | 249 | */ |
250 | 250 | ||
251 | if(sh_debug) | 251 | if(sh_debug) |
252 | printk("Clock = %ld, jiffies = %ld\n", SHAPERCB(skb)->shapeclock, jiffies); | 252 | printk("Clock = %ld, jiffies = %ld\n", SHAPERCB(skb)->shapeclock, jiffies); |
253 | if(time_before_eq(SHAPERCB(skb)->shapeclock, jiffies + SHAPER_BURST)) | 253 | if(time_before_eq(SHAPERCB(skb)->shapeclock, jiffies + SHAPER_BURST)) |
@@ -255,16 +255,16 @@ static void shaper_kick(struct shaper *shaper) | |||
255 | /* | 255 | /* |
256 | * Pull the frame and get interrupts back on. | 256 | * Pull the frame and get interrupts back on. |
257 | */ | 257 | */ |
258 | 258 | ||
259 | skb_unlink(skb, &shaper->sendq); | 259 | skb_unlink(skb, &shaper->sendq); |
260 | if (shaper->recovery < | 260 | if (shaper->recovery < |
261 | SHAPERCB(skb)->shapeclock + SHAPERCB(skb)->shapelen) | 261 | SHAPERCB(skb)->shapeclock + SHAPERCB(skb)->shapelen) |
262 | shaper->recovery = SHAPERCB(skb)->shapeclock + SHAPERCB(skb)->shapelen; | 262 | shaper->recovery = SHAPERCB(skb)->shapeclock + SHAPERCB(skb)->shapelen; |
263 | /* | 263 | /* |
264 | * Pass on to the physical target device via | 264 | * Pass on to the physical target device via |
265 | * our low level packet thrower. | 265 | * our low level packet thrower. |
266 | */ | 266 | */ |
267 | 267 | ||
268 | SHAPERCB(skb)->shapepend=0; | 268 | SHAPERCB(skb)->shapepend=0; |
269 | shaper_queue_xmit(shaper, skb); /* Fire */ | 269 | shaper_queue_xmit(shaper, skb); /* Fire */ |
270 | } | 270 | } |
@@ -275,27 +275,27 @@ static void shaper_kick(struct shaper *shaper) | |||
275 | /* | 275 | /* |
276 | * Next kick. | 276 | * Next kick. |
277 | */ | 277 | */ |
278 | 278 | ||
279 | if(skb!=NULL) | 279 | if(skb!=NULL) |
280 | mod_timer(&shaper->timer, SHAPERCB(skb)->shapeclock); | 280 | mod_timer(&shaper->timer, SHAPERCB(skb)->shapeclock); |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | /* | 284 | /* |
285 | * Bring the interface up. We just disallow this until a | 285 | * Bring the interface up. We just disallow this until a |
286 | * bind. | 286 | * bind. |
287 | */ | 287 | */ |
288 | 288 | ||
289 | static int shaper_open(struct net_device *dev) | 289 | static int shaper_open(struct net_device *dev) |
290 | { | 290 | { |
291 | struct shaper *shaper=dev->priv; | 291 | struct shaper *shaper=dev->priv; |
292 | 292 | ||
293 | /* | 293 | /* |
294 | * Can't open until attached. | 294 | * Can't open until attached. |
295 | * Also can't open until speed is set, or we'll get | 295 | * Also can't open until speed is set, or we'll get |
296 | * a division by zero. | 296 | * a division by zero. |
297 | */ | 297 | */ |
298 | 298 | ||
299 | if(shaper->dev==NULL) | 299 | if(shaper->dev==NULL) |
300 | return -ENODEV; | 300 | return -ENODEV; |
301 | if(shaper->bitspersec==0) | 301 | if(shaper->bitspersec==0) |
@@ -306,7 +306,7 @@ static int shaper_open(struct net_device *dev) | |||
306 | /* | 306 | /* |
307 | * Closing a shaper flushes the queues. | 307 | * Closing a shaper flushes the queues. |
308 | */ | 308 | */ |
309 | 309 | ||
310 | static int shaper_close(struct net_device *dev) | 310 | static int shaper_close(struct net_device *dev) |
311 | { | 311 | { |
312 | struct shaper *shaper=dev->priv; | 312 | struct shaper *shaper=dev->priv; |
@@ -335,7 +335,7 @@ static struct net_device_stats *shaper_get_stats(struct net_device *dev) | |||
335 | return &sh->stats; | 335 | return &sh->stats; |
336 | } | 336 | } |
337 | 337 | ||
338 | static int shaper_header(struct sk_buff *skb, struct net_device *dev, | 338 | static int shaper_header(struct sk_buff *skb, struct net_device *dev, |
339 | unsigned short type, void *daddr, void *saddr, unsigned len) | 339 | unsigned short type, void *daddr, void *saddr, unsigned len) |
340 | { | 340 | { |
341 | struct shaper *sh=dev->priv; | 341 | struct shaper *sh=dev->priv; |
@@ -395,7 +395,7 @@ static int shaper_neigh_setup(struct neighbour *n) | |||
395 | n->ops = &arp_broken_ops; | 395 | n->ops = &arp_broken_ops; |
396 | n->output = n->ops->output; | 396 | n->output = n->ops->output; |
397 | } | 397 | } |
398 | #endif | 398 | #endif |
399 | return 0; | 399 | return 0; |
400 | } | 400 | } |
401 | 401 | ||
@@ -407,7 +407,7 @@ static int shaper_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p) | |||
407 | p->ucast_probes = 0; | 407 | p->ucast_probes = 0; |
408 | p->mcast_probes = 0; | 408 | p->mcast_probes = 0; |
409 | } | 409 | } |
410 | #endif | 410 | #endif |
411 | return 0; | 411 | return 0; |
412 | } | 412 | } |
413 | 413 | ||
@@ -432,7 +432,7 @@ static int shaper_attach(struct net_device *shdev, struct shaper *sh, struct net | |||
432 | } | 432 | } |
433 | else | 433 | else |
434 | shdev->hard_header = NULL; | 434 | shdev->hard_header = NULL; |
435 | 435 | ||
436 | if(dev->rebuild_header) | 436 | if(dev->rebuild_header) |
437 | { | 437 | { |
438 | sh->rebuild_header = dev->rebuild_header; | 438 | sh->rebuild_header = dev->rebuild_header; |
@@ -440,7 +440,7 @@ static int shaper_attach(struct net_device *shdev, struct shaper *sh, struct net | |||
440 | } | 440 | } |
441 | else | 441 | else |
442 | shdev->rebuild_header = NULL; | 442 | shdev->rebuild_header = NULL; |
443 | 443 | ||
444 | #if 0 | 444 | #if 0 |
445 | if(dev->hard_header_cache) | 445 | if(dev->hard_header_cache) |
446 | { | 446 | { |
@@ -451,7 +451,7 @@ static int shaper_attach(struct net_device *shdev, struct shaper *sh, struct net | |||
451 | { | 451 | { |
452 | shdev->hard_header_cache= NULL; | 452 | shdev->hard_header_cache= NULL; |
453 | } | 453 | } |
454 | 454 | ||
455 | if(dev->header_cache_update) | 455 | if(dev->header_cache_update) |
456 | { | 456 | { |
457 | sh->header_cache_update = dev->header_cache_update; | 457 | sh->header_cache_update = dev->header_cache_update; |
@@ -464,7 +464,7 @@ static int shaper_attach(struct net_device *shdev, struct shaper *sh, struct net | |||
464 | shdev->hard_header_cache = NULL; | 464 | shdev->hard_header_cache = NULL; |
465 | #endif | 465 | #endif |
466 | shdev->neigh_setup = shaper_neigh_setup_dev; | 466 | shdev->neigh_setup = shaper_neigh_setup_dev; |
467 | 467 | ||
468 | shdev->hard_header_len=dev->hard_header_len; | 468 | shdev->hard_header_len=dev->hard_header_len; |
469 | shdev->type=dev->type; | 469 | shdev->type=dev->type; |
470 | shdev->addr_len=dev->addr_len; | 470 | shdev->addr_len=dev->addr_len; |
@@ -477,13 +477,13 @@ static int shaper_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
477 | { | 477 | { |
478 | struct shaperconf *ss= (struct shaperconf *)&ifr->ifr_ifru; | 478 | struct shaperconf *ss= (struct shaperconf *)&ifr->ifr_ifru; |
479 | struct shaper *sh=dev->priv; | 479 | struct shaper *sh=dev->priv; |
480 | 480 | ||
481 | if(ss->ss_cmd == SHAPER_SET_DEV || ss->ss_cmd == SHAPER_SET_SPEED) | 481 | if(ss->ss_cmd == SHAPER_SET_DEV || ss->ss_cmd == SHAPER_SET_SPEED) |
482 | { | 482 | { |
483 | if(!capable(CAP_NET_ADMIN)) | 483 | if(!capable(CAP_NET_ADMIN)) |
484 | return -EPERM; | 484 | return -EPERM; |
485 | } | 485 | } |
486 | 486 | ||
487 | switch(ss->ss_cmd) | 487 | switch(ss->ss_cmd) |
488 | { | 488 | { |
489 | case SHAPER_SET_DEV: | 489 | case SHAPER_SET_DEV: |
@@ -525,7 +525,7 @@ static void shaper_init_priv(struct net_device *dev) | |||
525 | /* | 525 | /* |
526 | * Add a shaper device to the system | 526 | * Add a shaper device to the system |
527 | */ | 527 | */ |
528 | 528 | ||
529 | static void __init shaper_setup(struct net_device *dev) | 529 | static void __init shaper_setup(struct net_device *dev) |
530 | { | 530 | { |
531 | /* | 531 | /* |
@@ -541,11 +541,11 @@ static void __init shaper_setup(struct net_device *dev) | |||
541 | dev->hard_start_xmit = shaper_start_xmit; | 541 | dev->hard_start_xmit = shaper_start_xmit; |
542 | dev->get_stats = shaper_get_stats; | 542 | dev->get_stats = shaper_get_stats; |
543 | dev->set_multicast_list = NULL; | 543 | dev->set_multicast_list = NULL; |
544 | 544 | ||
545 | /* | 545 | /* |
546 | * Intialise the packet queues | 546 | * Intialise the packet queues |
547 | */ | 547 | */ |
548 | 548 | ||
549 | /* | 549 | /* |
550 | * Handlers for when we attach to a device. | 550 | * Handlers for when we attach to a device. |
551 | */ | 551 | */ |
@@ -566,7 +566,7 @@ static void __init shaper_setup(struct net_device *dev) | |||
566 | dev->tx_queue_len = 10; | 566 | dev->tx_queue_len = 10; |
567 | dev->flags = 0; | 567 | dev->flags = 0; |
568 | } | 568 | } |
569 | 569 | ||
570 | static int shapers = 1; | 570 | static int shapers = 1; |
571 | #ifdef MODULE | 571 | #ifdef MODULE |
572 | 572 | ||
@@ -610,7 +610,7 @@ static int __init shaper_init(void) | |||
610 | snprintf(name, IFNAMSIZ, "shaper%d", i); | 610 | snprintf(name, IFNAMSIZ, "shaper%d", i); |
611 | dev = alloc_netdev(sizeof(struct shaper), name, | 611 | dev = alloc_netdev(sizeof(struct shaper), name, |
612 | shaper_setup); | 612 | shaper_setup); |
613 | if (!dev) | 613 | if (!dev) |
614 | break; | 614 | break; |
615 | 615 | ||
616 | if (register_netdev(dev)) { | 616 | if (register_netdev(dev)) { |