aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/shaper.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2007-10-09 04:40:57 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:52:52 -0400
commit3b04ddde02cf1b6f14f2697da5c20eca5715017f (patch)
tree9da1341a5a399a507b5ea6bf5a3047506b8d8f8f /drivers/net/shaper.c
parentb95cce3576813ac3f86bafa6b5daaaaf7574b0fe (diff)
[NET]: Move hardware header operations out of netdevice.
Since hardware header operations are part of the protocol class not the device instance, make them into a separate object and save memory. Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/shaper.c')
-rw-r--r--drivers/net/shaper.c61
1 files changed, 11 insertions, 50 deletions
diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c
index 315feba7dacc..228f650250f6 100644
--- a/drivers/net/shaper.c
+++ b/drivers/net/shaper.c
@@ -331,15 +331,16 @@ static int shaper_close(struct net_device *dev)
331 */ 331 */
332 332
333static int shaper_header(struct sk_buff *skb, struct net_device *dev, 333static int shaper_header(struct sk_buff *skb, struct net_device *dev,
334 unsigned short type, void *daddr, void *saddr, unsigned len) 334 unsigned short type,
335 const void *daddr, const void *saddr, unsigned len)
335{ 336{
336 struct shaper *sh=dev->priv; 337 struct shaper *sh=dev->priv;
337 int v; 338 int v;
338 if(sh_debug) 339 if(sh_debug)
339 printk("Shaper header\n"); 340 printk("Shaper header\n");
340 skb->dev=sh->dev; 341 skb->dev = sh->dev;
341 v=sh->hard_header(skb,sh->dev,type,daddr,saddr,len); 342 v = dev_hard_header(skb, sh->dev, type, daddr, saddr, len);
342 skb->dev=dev; 343 skb->dev = dev;
343 return v; 344 return v;
344} 345}
345 346
@@ -351,7 +352,7 @@ static int shaper_rebuild_header(struct sk_buff *skb)
351 if(sh_debug) 352 if(sh_debug)
352 printk("Shaper rebuild header\n"); 353 printk("Shaper rebuild header\n");
353 skb->dev=sh->dev; 354 skb->dev=sh->dev;
354 v=sh->rebuild_header(skb); 355 v = sh->dev->header_ops->rebuild(skb);
355 skb->dev=dev; 356 skb->dev=dev;
356 return v; 357 return v;
357} 358}
@@ -415,51 +416,17 @@ static int shaper_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p)
415 416
416#endif 417#endif
417 418
419static const struct header_ops shaper_ops = {
420 .create = shaper_header,
421 .rebuild = shaper_rebuild_header,
422};
423
418static int shaper_attach(struct net_device *shdev, struct shaper *sh, struct net_device *dev) 424static int shaper_attach(struct net_device *shdev, struct shaper *sh, struct net_device *dev)
419{ 425{
420 sh->dev = dev; 426 sh->dev = dev;
421 sh->hard_start_xmit=dev->hard_start_xmit;
422 sh->get_stats=dev->get_stats; 427 sh->get_stats=dev->get_stats;
423 if(dev->hard_header)
424 {
425 sh->hard_header=dev->hard_header;
426 shdev->hard_header = shaper_header;
427 }
428 else
429 shdev->hard_header = NULL;
430 428
431 if(dev->rebuild_header)
432 {
433 sh->rebuild_header = dev->rebuild_header;
434 shdev->rebuild_header = shaper_rebuild_header;
435 }
436 else
437 shdev->rebuild_header = NULL;
438
439#if 0
440 if(dev->hard_header_cache)
441 {
442 sh->hard_header_cache = dev->hard_header_cache;
443 shdev->hard_header_cache= shaper_cache;
444 }
445 else
446 {
447 shdev->hard_header_cache= NULL;
448 }
449
450 if(dev->header_cache_update)
451 {
452 sh->header_cache_update = dev->header_cache_update;
453 shdev->header_cache_update = shaper_cache_update;
454 }
455 else
456 shdev->header_cache_update= NULL;
457#else
458 shdev->header_cache_update = NULL;
459 shdev->hard_header_cache = NULL;
460#endif
461 shdev->neigh_setup = shaper_neigh_setup_dev; 429 shdev->neigh_setup = shaper_neigh_setup_dev;
462
463 shdev->hard_header_len=dev->hard_header_len; 430 shdev->hard_header_len=dev->hard_header_len;
464 shdev->type=dev->type; 431 shdev->type=dev->type;
465 shdev->addr_len=dev->addr_len; 432 shdev->addr_len=dev->addr_len;
@@ -542,12 +509,6 @@ static void __init shaper_setup(struct net_device *dev)
542 * Handlers for when we attach to a device. 509 * Handlers for when we attach to a device.
543 */ 510 */
544 511
545 dev->hard_header = shaper_header;
546 dev->rebuild_header = shaper_rebuild_header;
547#if 0
548 dev->hard_header_cache = shaper_cache;
549 dev->header_cache_update= shaper_cache_update;
550#endif
551 dev->neigh_setup = shaper_neigh_setup_dev; 512 dev->neigh_setup = shaper_neigh_setup_dev;
552 dev->do_ioctl = shaper_ioctl; 513 dev->do_ioctl = shaper_ioctl;
553 dev->hard_header_len = 0; 514 dev->hard_header_len = 0;