aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
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
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')
-rw-r--r--drivers/net/appletalk/cops.c20
-rw-r--r--drivers/net/appletalk/ltpc.c10
-rw-r--r--drivers/net/arcnet/arcnet.c18
-rw-r--r--drivers/net/hamradio/6pack.c13
-rw-r--r--drivers/net/hamradio/baycom_epp.c3
-rw-r--r--drivers/net/hamradio/bpqether.c3
-rw-r--r--drivers/net/hamradio/dmascc.c3
-rw-r--r--drivers/net/hamradio/hdlcdrv.c3
-rw-r--r--drivers/net/hamradio/mkiss.c14
-rw-r--r--drivers/net/hamradio/scc.c4
-rw-r--r--drivers/net/hamradio/yam.c3
-rw-r--r--drivers/net/loopback.c8
-rw-r--r--drivers/net/macvlan.c15
-rw-r--r--drivers/net/myri_sbus.c28
-rw-r--r--drivers/net/plip.c50
-rw-r--r--drivers/net/shaper.c61
-rw-r--r--drivers/net/skfp/skfddi.c1
-rw-r--r--drivers/net/wan/cycx_x25.c31
-rw-r--r--drivers/net/wan/dlci.c10
-rw-r--r--drivers/net/wan/hdlc.c10
-rw-r--r--drivers/net/wan/hdlc_cisco.c10
-rw-r--r--drivers/net/wan/hdlc_ppp.c2
-rw-r--r--drivers/net/wan/lmc/lmc_proto.c2
-rw-r--r--drivers/net/wan/syncppp.c19
-rw-r--r--drivers/net/wireless/airo.c6
-rw-r--r--drivers/net/wireless/hostap/hostap.h3
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c3
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c5
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c47
-rw-r--r--drivers/net/wireless/hostap/hostap_wlan.h2
-rw-r--r--drivers/net/wireless/strip.c13
31 files changed, 198 insertions, 222 deletions
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index c4b560d42a67..92c3a4cf0bb1 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -194,10 +194,6 @@ static void cops_timeout(struct net_device *dev);
194static void cops_rx (struct net_device *dev); 194static void cops_rx (struct net_device *dev);
195static int cops_send_packet (struct sk_buff *skb, struct net_device *dev); 195static int cops_send_packet (struct sk_buff *skb, struct net_device *dev);
196static void set_multicast_list (struct net_device *dev); 196static void set_multicast_list (struct net_device *dev);
197static int cops_hard_header (struct sk_buff *skb, struct net_device *dev,
198 unsigned short type, void *daddr, void *saddr,
199 unsigned len);
200
201static int cops_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); 197static int cops_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
202static int cops_close (struct net_device *dev); 198static int cops_close (struct net_device *dev);
203static struct net_device_stats *cops_get_stats (struct net_device *dev); 199static struct net_device_stats *cops_get_stats (struct net_device *dev);
@@ -331,7 +327,6 @@ static int __init cops_probe1(struct net_device *dev, int ioaddr)
331 dev->base_addr = ioaddr; 327 dev->base_addr = ioaddr;
332 328
333 lp = netdev_priv(dev); 329 lp = netdev_priv(dev);
334 memset(lp, 0, sizeof(struct cops_local));
335 spin_lock_init(&lp->lock); 330 spin_lock_init(&lp->lock);
336 331
337 /* Copy local board variable to lp struct. */ 332 /* Copy local board variable to lp struct. */
@@ -340,7 +335,7 @@ static int __init cops_probe1(struct net_device *dev, int ioaddr)
340 dev->hard_start_xmit = cops_send_packet; 335 dev->hard_start_xmit = cops_send_packet;
341 dev->tx_timeout = cops_timeout; 336 dev->tx_timeout = cops_timeout;
342 dev->watchdog_timeo = HZ * 2; 337 dev->watchdog_timeo = HZ * 2;
343 dev->hard_header = cops_hard_header; 338
344 dev->get_stats = cops_get_stats; 339 dev->get_stats = cops_get_stats;
345 dev->open = cops_open; 340 dev->open = cops_open;
346 dev->stop = cops_close; 341 dev->stop = cops_close;
@@ -945,19 +940,6 @@ static void set_multicast_list(struct net_device *dev)
945} 940}
946 941
947/* 942/*
948 * Another Dummy function to keep the Appletalk layer happy.
949 */
950
951static int cops_hard_header(struct sk_buff *skb, struct net_device *dev,
952 unsigned short type, void *daddr, void *saddr,
953 unsigned len)
954{
955 if(cops_debug >= 3)
956 printk("%s: cops_hard_header executed. Wow!\n", dev->name);
957 return 0;
958}
959
960/*
961 * System ioctls for the COPS LocalTalk card. 943 * System ioctls for the COPS LocalTalk card.
962 */ 944 */
963 945
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index cb4744e56905..6ab2c2d4d673 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -870,15 +870,6 @@ static void set_multicast_list(struct net_device *dev)
870 /* Actually netatalk needs fixing! */ 870 /* Actually netatalk needs fixing! */
871} 871}
872 872
873static int ltpc_hard_header (struct sk_buff *skb, struct net_device *dev,
874 unsigned short type, void *daddr, void *saddr, unsigned len)
875{
876 if(debug & DEBUG_VERBOSE)
877 printk("ltpc_hard_header called for device %s\n",
878 dev->name);
879 return 0;
880}
881
882static int ltpc_poll_counter; 873static int ltpc_poll_counter;
883 874
884static void ltpc_poll(unsigned long l) 875static void ltpc_poll(unsigned long l)
@@ -1141,7 +1132,6 @@ struct net_device * __init ltpc_probe(void)
1141 1132
1142 /* Fill in the fields of the device structure with ethernet-generic values. */ 1133 /* Fill in the fields of the device structure with ethernet-generic values. */
1143 dev->hard_start_xmit = ltpc_xmit; 1134 dev->hard_start_xmit = ltpc_xmit;
1144 dev->hard_header = ltpc_hard_header;
1145 dev->get_stats = ltpc_get_stats; 1135 dev->get_stats = ltpc_get_stats;
1146 1136
1147 /* add the ltpc-specific things */ 1137 /* add the ltpc-specific things */
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 681e20b8466f..c59c8067de99 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -102,8 +102,8 @@ static int arcnet_close(struct net_device *dev);
102static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev); 102static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev);
103static void arcnet_timeout(struct net_device *dev); 103static void arcnet_timeout(struct net_device *dev);
104static int arcnet_header(struct sk_buff *skb, struct net_device *dev, 104static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
105 unsigned short type, void *daddr, void *saddr, 105 unsigned short type, const void *daddr,
106 unsigned len); 106 const void *saddr, unsigned len);
107static int arcnet_rebuild_header(struct sk_buff *skb); 107static int arcnet_rebuild_header(struct sk_buff *skb);
108static struct net_device_stats *arcnet_get_stats(struct net_device *dev); 108static struct net_device_stats *arcnet_get_stats(struct net_device *dev);
109static int go_tx(struct net_device *dev); 109static int go_tx(struct net_device *dev);
@@ -317,11 +317,17 @@ static int choose_mtu(void)
317 return mtu == 65535 ? XMTU : mtu; 317 return mtu == 65535 ? XMTU : mtu;
318} 318}
319 319
320static const struct header_ops arcnet_header_ops = {
321 .create = arcnet_header,
322 .rebuild = arcnet_rebuild_header,
323};
324
320 325
321/* Setup a struct device for ARCnet. */ 326/* Setup a struct device for ARCnet. */
322static void arcdev_setup(struct net_device *dev) 327static void arcdev_setup(struct net_device *dev)
323{ 328{
324 dev->type = ARPHRD_ARCNET; 329 dev->type = ARPHRD_ARCNET;
330 dev->header_ops = &arcnet_header_ops;
325 dev->hard_header_len = sizeof(struct archdr); 331 dev->hard_header_len = sizeof(struct archdr);
326 dev->mtu = choose_mtu(); 332 dev->mtu = choose_mtu();
327 333
@@ -342,8 +348,6 @@ static void arcdev_setup(struct net_device *dev)
342 dev->hard_start_xmit = arcnet_send_packet; 348 dev->hard_start_xmit = arcnet_send_packet;
343 dev->tx_timeout = arcnet_timeout; 349 dev->tx_timeout = arcnet_timeout;
344 dev->get_stats = arcnet_get_stats; 350 dev->get_stats = arcnet_get_stats;
345 dev->hard_header = arcnet_header;
346 dev->rebuild_header = arcnet_rebuild_header;
347} 351}
348 352
349struct net_device *alloc_arcdev(char *name) 353struct net_device *alloc_arcdev(char *name)
@@ -488,10 +492,10 @@ static int arcnet_close(struct net_device *dev)
488 492
489 493
490static int arcnet_header(struct sk_buff *skb, struct net_device *dev, 494static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
491 unsigned short type, void *daddr, void *saddr, 495 unsigned short type, const void *daddr,
492 unsigned len) 496 const void *saddr, unsigned len)
493{ 497{
494 struct arcnet_local *lp = dev->priv; 498 const struct arcnet_local *lp = netdev_priv(dev);
495 uint8_t _daddr, proto_num; 499 uint8_t _daddr, proto_num;
496 struct ArcProto *proto; 500 struct ArcProto *proto;
497 501
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 0a847326a5e4..ecd156def039 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -288,7 +288,8 @@ static int sp_close(struct net_device *dev)
288 288
289/* Return the frame type ID */ 289/* Return the frame type ID */
290static int sp_header(struct sk_buff *skb, struct net_device *dev, 290static int sp_header(struct sk_buff *skb, struct net_device *dev,
291 unsigned short type, void *daddr, void *saddr, unsigned len) 291 unsigned short type, const void *daddr,
292 const void *saddr, unsigned len)
292{ 293{
293#ifdef CONFIG_INET 294#ifdef CONFIG_INET
294 if (type != htons(ETH_P_AX25)) 295 if (type != htons(ETH_P_AX25))
@@ -323,6 +324,11 @@ static int sp_rebuild_header(struct sk_buff *skb)
323#endif 324#endif
324} 325}
325 326
327static const struct header_ops sp_header_ops = {
328 .create = sp_header,
329 .rebuild = sp_rebuild_header,
330};
331
326static void sp_setup(struct net_device *dev) 332static void sp_setup(struct net_device *dev)
327{ 333{
328 /* Finish setting up the DEVICE info. */ 334 /* Finish setting up the DEVICE info. */
@@ -331,14 +337,15 @@ static void sp_setup(struct net_device *dev)
331 dev->open = sp_open_dev; 337 dev->open = sp_open_dev;
332 dev->destructor = free_netdev; 338 dev->destructor = free_netdev;
333 dev->stop = sp_close; 339 dev->stop = sp_close;
334 dev->hard_header = sp_header; 340
335 dev->get_stats = sp_get_stats; 341 dev->get_stats = sp_get_stats;
336 dev->set_mac_address = sp_set_mac_address; 342 dev->set_mac_address = sp_set_mac_address;
337 dev->hard_header_len = AX25_MAX_HEADER_LEN; 343 dev->hard_header_len = AX25_MAX_HEADER_LEN;
344 dev->header_ops = &sp_header_ops;
345
338 dev->addr_len = AX25_ADDR_LEN; 346 dev->addr_len = AX25_ADDR_LEN;
339 dev->type = ARPHRD_AX25; 347 dev->type = ARPHRD_AX25;
340 dev->tx_queue_len = 10; 348 dev->tx_queue_len = 10;
341 dev->rebuild_header = sp_rebuild_header;
342 dev->tx_timeout = NULL; 349 dev->tx_timeout = NULL;
343 350
344 /* Only activated in AX.25 mode */ 351 /* Only activated in AX.25 mode */
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 355c6cf3d112..1a5a75acf73e 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -1159,8 +1159,7 @@ static void baycom_probe(struct net_device *dev)
1159 /* Fill in the fields of the device structure */ 1159 /* Fill in the fields of the device structure */
1160 bc->skb = NULL; 1160 bc->skb = NULL;
1161 1161
1162 dev->hard_header = ax25_hard_header; 1162 dev->header_ops = &ax25_header_ops;
1163 dev->rebuild_header = ax25_rebuild_header;
1164 dev->set_mac_address = baycom_set_mac_address; 1163 dev->set_mac_address = baycom_set_mac_address;
1165 1164
1166 dev->type = ARPHRD_AX25; /* AF_AX25 device */ 1165 dev->type = ARPHRD_AX25; /* AF_AX25 device */
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index 4bff23e3b970..5ddf8b0c34f9 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -483,8 +483,7 @@ static void bpq_setup(struct net_device *dev)
483 dev->flags = 0; 483 dev->flags = 0;
484 484
485#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 485#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
486 dev->hard_header = ax25_hard_header; 486 dev->header_ops = &ax25_header_ops;
487 dev->rebuild_header = ax25_rebuild_header;
488#endif 487#endif
489 488
490 dev->type = ARPHRD_AX25; 489 dev->type = ARPHRD_AX25;
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 205f09672492..bc02e4694804 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -581,8 +581,7 @@ static int __init setup_adapter(int card_base, int type, int n)
581 dev->do_ioctl = scc_ioctl; 581 dev->do_ioctl = scc_ioctl;
582 dev->hard_start_xmit = scc_send_packet; 582 dev->hard_start_xmit = scc_send_packet;
583 dev->get_stats = scc_get_stats; 583 dev->get_stats = scc_get_stats;
584 dev->hard_header = ax25_hard_header; 584 dev->header_ops = &ax25_header_ops;
585 dev->rebuild_header = ax25_rebuild_header;
586 dev->set_mac_address = scc_set_mac_address; 585 dev->set_mac_address = scc_set_mac_address;
587 } 586 }
588 if (register_netdev(info->dev[0])) { 587 if (register_netdev(info->dev[0])) {
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index b33adc6a340b..ae9629fa6882 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -682,8 +682,7 @@ static void hdlcdrv_setup(struct net_device *dev)
682 682
683 s->skb = NULL; 683 s->skb = NULL;
684 684
685 dev->hard_header = ax25_hard_header; 685 dev->header_ops = &ax25_header_ops;
686 dev->rebuild_header = ax25_rebuild_header;
687 dev->set_mac_address = hdlcdrv_set_mac_address; 686 dev->set_mac_address = hdlcdrv_set_mac_address;
688 687
689 dev->type = ARPHRD_AX25; /* AF_AX25 device */ 688 dev->type = ARPHRD_AX25; /* AF_AX25 device */
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index d08fbc396648..9e43c47691ca 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -578,8 +578,9 @@ static int ax_open_dev(struct net_device *dev)
578#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 578#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
579 579
580/* Return the frame type ID */ 580/* Return the frame type ID */
581static int ax_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, 581static int ax_header(struct sk_buff *skb, struct net_device *dev,
582 void *daddr, void *saddr, unsigned len) 582 unsigned short type, const void *daddr,
583 const void *saddr, unsigned len)
583{ 584{
584#ifdef CONFIG_INET 585#ifdef CONFIG_INET
585 if (type != htons(ETH_P_AX25)) 586 if (type != htons(ETH_P_AX25))
@@ -670,6 +671,11 @@ static struct net_device_stats *ax_get_stats(struct net_device *dev)
670 return &ax->stats; 671 return &ax->stats;
671} 672}
672 673
674static const struct header_ops ax_header_ops = {
675 .create = ax_header,
676 .rebuild = ax_rebuild_header,
677};
678
673static void ax_setup(struct net_device *dev) 679static void ax_setup(struct net_device *dev)
674{ 680{
675 /* Finish setting up the DEVICE info. */ 681 /* Finish setting up the DEVICE info. */
@@ -683,8 +689,8 @@ static void ax_setup(struct net_device *dev)
683 dev->addr_len = 0; 689 dev->addr_len = 0;
684 dev->type = ARPHRD_AX25; 690 dev->type = ARPHRD_AX25;
685 dev->tx_queue_len = 10; 691 dev->tx_queue_len = 10;
686 dev->hard_header = ax_header; 692 dev->header_ops = &ax_header_ops;
687 dev->rebuild_header = ax_rebuild_header; 693
688 694
689 memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); 695 memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
690 memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN); 696 memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN);
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index 39b3b82aa4a4..353d13e543ce 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -1551,8 +1551,8 @@ static void scc_net_setup(struct net_device *dev)
1551 dev->stop = scc_net_close; 1551 dev->stop = scc_net_close;
1552 1552
1553 dev->hard_start_xmit = scc_net_tx; 1553 dev->hard_start_xmit = scc_net_tx;
1554 dev->hard_header = ax25_hard_header; 1554 dev->header_ops = &ax25_header_ops;
1555 dev->rebuild_header = ax25_rebuild_header; 1555
1556 dev->set_mac_address = scc_net_set_mac_address; 1556 dev->set_mac_address = scc_net_set_mac_address;
1557 dev->get_stats = scc_net_get_stats; 1557 dev->get_stats = scc_net_get_stats;
1558 dev->do_ioctl = scc_net_ioctl; 1558 dev->do_ioctl = scc_net_ioctl;
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 401724ddafcd..1c942862a3f4 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -1097,8 +1097,7 @@ static void yam_setup(struct net_device *dev)
1097 1097
1098 skb_queue_head_init(&yp->send_queue); 1098 skb_queue_head_init(&yp->send_queue);
1099 1099
1100 dev->hard_header = ax25_hard_header; 1100 dev->header_ops = &ax25_header_ops;
1101 dev->rebuild_header = ax25_rebuild_header;
1102 1101
1103 dev->set_mac_address = yam_set_mac_address; 1102 dev->set_mac_address = yam_set_mac_address;
1104 1103
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index f11120b7a3b2..b6d4ae3ad506 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -221,22 +221,17 @@ static void loopback_dev_free(struct net_device *dev)
221} 221}
222 222
223/* 223/*
224 * The loopback device is special. There is only one instance and 224 * The loopback device is special. There is only one instance.
225 * it is statically allocated. Don't do this for other devices.
226 */ 225 */
227static void loopback_setup(struct net_device *dev) 226static void loopback_setup(struct net_device *dev)
228{ 227{
229 dev->get_stats = &get_stats; 228 dev->get_stats = &get_stats;
230 dev->mtu = (16 * 1024) + 20 + 20 + 12; 229 dev->mtu = (16 * 1024) + 20 + 20 + 12;
231 dev->hard_start_xmit = loopback_xmit; 230 dev->hard_start_xmit = loopback_xmit;
232 dev->hard_header = eth_header;
233 dev->hard_header_cache = eth_header_cache;
234 dev->header_cache_update = eth_header_cache_update;
235 dev->hard_header_len = ETH_HLEN; /* 14 */ 231 dev->hard_header_len = ETH_HLEN; /* 14 */
236 dev->addr_len = ETH_ALEN; /* 6 */ 232 dev->addr_len = ETH_ALEN; /* 6 */
237 dev->tx_queue_len = 0; 233 dev->tx_queue_len = 0;
238 dev->type = ARPHRD_LOOPBACK; /* 0x0001*/ 234 dev->type = ARPHRD_LOOPBACK; /* 0x0001*/
239 dev->rebuild_header = eth_rebuild_header;
240 dev->flags = IFF_LOOPBACK; 235 dev->flags = IFF_LOOPBACK;
241 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST 236 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST
242#ifdef LOOPBACK_TSO 237#ifdef LOOPBACK_TSO
@@ -247,6 +242,7 @@ static void loopback_setup(struct net_device *dev)
247 | NETIF_F_LLTX 242 | NETIF_F_LLTX
248 | NETIF_F_NETNS_LOCAL, 243 | NETIF_F_NETNS_LOCAL,
249 dev->ethtool_ops = &loopback_ethtool_ops; 244 dev->ethtool_ops = &loopback_ethtool_ops;
245 dev->header_ops = &eth_header_ops;
250 dev->init = loopback_dev_init; 246 dev->init = loopback_dev_init;
251 dev->destructor = loopback_dev_free; 247 dev->destructor = loopback_dev_free;
252} 248}
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index a22087ca968d..b7c81c874f7a 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -164,8 +164,8 @@ static int macvlan_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
164} 164}
165 165
166static int macvlan_hard_header(struct sk_buff *skb, struct net_device *dev, 166static int macvlan_hard_header(struct sk_buff *skb, struct net_device *dev,
167 unsigned short type, void *daddr, void *saddr, 167 unsigned short type, const void *daddr,
168 unsigned len) 168 const void *saddr, unsigned len)
169{ 169{
170 const struct macvlan_dev *vlan = netdev_priv(dev); 170 const struct macvlan_dev *vlan = netdev_priv(dev);
171 struct net_device *lowerdev = vlan->lowerdev; 171 struct net_device *lowerdev = vlan->lowerdev;
@@ -174,6 +174,15 @@ static int macvlan_hard_header(struct sk_buff *skb, struct net_device *dev,
174 saddr ? : dev->dev_addr, len); 174 saddr ? : dev->dev_addr, len);
175} 175}
176 176
177static const struct header_ops macvlan_hard_header_ops = {
178 .create = macvlan_hard_header,
179 .rebuild = eth_rebuild_header,
180 .parse = eth_header_parse,
181 .rebuild = eth_rebuild_header,
182 .cache = eth_header_cache,
183 .cache_update = eth_header_cache_update,
184};
185
177static int macvlan_open(struct net_device *dev) 186static int macvlan_open(struct net_device *dev)
178{ 187{
179 struct macvlan_dev *vlan = netdev_priv(dev); 188 struct macvlan_dev *vlan = netdev_priv(dev);
@@ -295,9 +304,9 @@ static void macvlan_setup(struct net_device *dev)
295 dev->change_mtu = macvlan_change_mtu; 304 dev->change_mtu = macvlan_change_mtu;
296 dev->change_rx_flags = macvlan_change_rx_flags; 305 dev->change_rx_flags = macvlan_change_rx_flags;
297 dev->set_multicast_list = macvlan_set_multicast_list; 306 dev->set_multicast_list = macvlan_set_multicast_list;
298 dev->hard_header = macvlan_hard_header;
299 dev->hard_start_xmit = macvlan_hard_start_xmit; 307 dev->hard_start_xmit = macvlan_hard_start_xmit;
300 dev->destructor = free_netdev; 308 dev->destructor = free_netdev;
309 dev->header_ops = &macvlan_hard_header_ops,
301 dev->ethtool_ops = &macvlan_ethtool_ops; 310 dev->ethtool_ops = &macvlan_ethtool_ops;
302 dev->tx_queue_len = 0; 311 dev->tx_queue_len = 0;
303} 312}
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index d68ee51c095f..8d29319cc5cb 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -676,8 +676,9 @@ static int myri_start_xmit(struct sk_buff *skb, struct net_device *dev)
676 * saddr=NULL means use device source address 676 * saddr=NULL means use device source address
677 * daddr=NULL means leave destination address (eg unresolved arp) 677 * daddr=NULL means leave destination address (eg unresolved arp)
678 */ 678 */
679static int myri_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, 679static int myri_header(struct sk_buff *skb, struct net_device *dev,
680 void *daddr, void *saddr, unsigned len) 680 unsigned short type, const void *daddr,
681 const void *saddr, unsigned len)
681{ 682{
682 struct ethhdr *eth = (struct ethhdr *) skb_push(skb, ETH_HLEN); 683 struct ethhdr *eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
683 unsigned char *pad = (unsigned char *) skb_push(skb, MYRI_PAD_LEN); 684 unsigned char *pad = (unsigned char *) skb_push(skb, MYRI_PAD_LEN);
@@ -759,18 +760,18 @@ static int myri_rebuild_header(struct sk_buff *skb)
759 return 0; 760 return 0;
760} 761}
761 762
762int myri_header_cache(struct neighbour *neigh, struct hh_cache *hh) 763static int myri_header_cache(const struct neighbour *neigh, struct hh_cache *hh)
763{ 764{
764 unsigned short type = hh->hh_type; 765 unsigned short type = hh->hh_type;
765 unsigned char *pad; 766 unsigned char *pad;
766 struct ethhdr *eth; 767 struct ethhdr *eth;
767 struct net_device *dev = neigh->dev; 768 const struct net_device *dev = neigh->dev;
768 769
769 pad = ((unsigned char *) hh->hh_data) + 770 pad = ((unsigned char *) hh->hh_data) +
770 HH_DATA_OFF(sizeof(*eth) + MYRI_PAD_LEN); 771 HH_DATA_OFF(sizeof(*eth) + MYRI_PAD_LEN);
771 eth = (struct ethhdr *) (pad + MYRI_PAD_LEN); 772 eth = (struct ethhdr *) (pad + MYRI_PAD_LEN);
772 773
773 if (type == __constant_htons(ETH_P_802_3)) 774 if (type == htons(ETH_P_802_3))
774 return -1; 775 return -1;
775 776
776 /* Refill MyriNet padding identifiers, this is just being anal. */ 777 /* Refill MyriNet padding identifiers, this is just being anal. */
@@ -786,7 +787,9 @@ int myri_header_cache(struct neighbour *neigh, struct hh_cache *hh)
786 787
787 788
788/* Called by Address Resolution module to notify changes in address. */ 789/* Called by Address Resolution module to notify changes in address. */
789void myri_header_cache_update(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr) 790void myri_header_cache_update(struct hh_cache *hh,
791 const struct net_device *dev,
792 const unsigned char * haddr)
790{ 793{
791 memcpy(((u8*)hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)), 794 memcpy(((u8*)hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)),
792 haddr, dev->addr_len); 795 haddr, dev->addr_len);
@@ -881,6 +884,13 @@ static void dump_eeprom(struct myri_eth *mp)
881} 884}
882#endif 885#endif
883 886
887static const struct header_ops myri_header_ops = {
888 .create = myri_header,
889 .rebuild = myri_rebuild_header,
890 .cache = myri_header_cache,
891 .cache_update = myri_header_cache_update,
892};
893
884static int __devinit myri_ether_init(struct sbus_dev *sdev) 894static int __devinit myri_ether_init(struct sbus_dev *sdev)
885{ 895{
886 static int num; 896 static int num;
@@ -1065,11 +1075,9 @@ static int __devinit myri_ether_init(struct sbus_dev *sdev)
1065 1075
1066 dev->mtu = MYRINET_MTU; 1076 dev->mtu = MYRINET_MTU;
1067 dev->change_mtu = myri_change_mtu; 1077 dev->change_mtu = myri_change_mtu;
1068 dev->hard_header = myri_header; 1078 dev->header_ops = &myri_header_ops;
1069 dev->rebuild_header = myri_rebuild_header; 1079
1070 dev->hard_header_len = (ETH_HLEN + MYRI_PAD_LEN); 1080 dev->hard_header_len = (ETH_HLEN + MYRI_PAD_LEN);
1071 dev->hard_header_cache = myri_header_cache;
1072 dev->header_cache_update= myri_header_cache_update;
1073 1081
1074 /* Load code onto the LANai. */ 1082 /* Load code onto the LANai. */
1075 DET(("Loading LANAI firmware\n")); 1083 DET(("Loading LANAI firmware\n"));
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index c17d9ac9ff30..b5e9981d1060 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -148,9 +148,9 @@ static void plip_interrupt(int irq, void *dev_id);
148/* Functions for DEV methods */ 148/* Functions for DEV methods */
149static int plip_tx_packet(struct sk_buff *skb, struct net_device *dev); 149static int plip_tx_packet(struct sk_buff *skb, struct net_device *dev);
150static int plip_hard_header(struct sk_buff *skb, struct net_device *dev, 150static int plip_hard_header(struct sk_buff *skb, struct net_device *dev,
151 unsigned short type, void *daddr, 151 unsigned short type, const void *daddr,
152 void *saddr, unsigned len); 152 const void *saddr, unsigned len);
153static int plip_hard_header_cache(struct neighbour *neigh, 153static int plip_hard_header_cache(const struct neighbour *neigh,
154 struct hh_cache *hh); 154 struct hh_cache *hh);
155static int plip_open(struct net_device *dev); 155static int plip_open(struct net_device *dev);
156static int plip_close(struct net_device *dev); 156static int plip_close(struct net_device *dev);
@@ -219,11 +219,6 @@ struct net_local {
219 int is_deferred; 219 int is_deferred;
220 int port_owner; 220 int port_owner;
221 int should_relinquish; 221 int should_relinquish;
222 int (*orig_hard_header)(struct sk_buff *skb, struct net_device *dev,
223 unsigned short type, void *daddr,
224 void *saddr, unsigned len);
225 int (*orig_hard_header_cache)(struct neighbour *neigh,
226 struct hh_cache *hh);
227 spinlock_t lock; 222 spinlock_t lock;
228 atomic_t kill_timer; 223 atomic_t kill_timer;
229 struct semaphore killed_timer_sem; 224 struct semaphore killed_timer_sem;
@@ -265,6 +260,11 @@ static inline unsigned char read_status (struct net_device *dev)
265 return port->ops->read_status (port); 260 return port->ops->read_status (port);
266} 261}
267 262
263static const struct header_ops plip_header_ops = {
264 .create = plip_hard_header,
265 .cache = plip_hard_header_cache,
266};
267
268/* Entry point of PLIP driver. 268/* Entry point of PLIP driver.
269 Probe the hardware, and register/initialize the driver. 269 Probe the hardware, and register/initialize the driver.
270 270
@@ -284,17 +284,12 @@ plip_init_netdev(struct net_device *dev)
284 dev->open = plip_open; 284 dev->open = plip_open;
285 dev->stop = plip_close; 285 dev->stop = plip_close;
286 dev->do_ioctl = plip_ioctl; 286 dev->do_ioctl = plip_ioctl;
287 dev->header_cache_update = NULL; 287
288 dev->tx_queue_len = 10; 288 dev->tx_queue_len = 10;
289 dev->flags = IFF_POINTOPOINT|IFF_NOARP; 289 dev->flags = IFF_POINTOPOINT|IFF_NOARP;
290 memset(dev->dev_addr, 0xfc, ETH_ALEN); 290 memset(dev->dev_addr, 0xfc, ETH_ALEN);
291 291
292 /* Set the private structure */ 292 dev->header_ops = &plip_header_ops;
293 nl->orig_hard_header = dev->hard_header;
294 dev->hard_header = plip_hard_header;
295
296 nl->orig_hard_header_cache = dev->hard_header_cache;
297 dev->hard_header_cache = plip_hard_header_cache;
298 293
299 294
300 nl->port_owner = 0; 295 nl->port_owner = 0;
@@ -993,14 +988,14 @@ plip_tx_packet(struct sk_buff *skb, struct net_device *dev)
993} 988}
994 989
995static void 990static void
996plip_rewrite_address(struct net_device *dev, struct ethhdr *eth) 991plip_rewrite_address(const struct net_device *dev, struct ethhdr *eth)
997{ 992{
998 struct in_device *in_dev; 993 const struct in_device *in_dev = dev->ip_ptr;
999 994
1000 if ((in_dev=dev->ip_ptr) != NULL) { 995 if (in_dev) {
1001 /* Any address will do - we take the first */ 996 /* Any address will do - we take the first */
1002 struct in_ifaddr *ifa=in_dev->ifa_list; 997 const struct in_ifaddr *ifa = in_dev->ifa_list;
1003 if (ifa != NULL) { 998 if (ifa) {
1004 memcpy(eth->h_source, dev->dev_addr, 6); 999 memcpy(eth->h_source, dev->dev_addr, 6);
1005 memset(eth->h_dest, 0xfc, 2); 1000 memset(eth->h_dest, 0xfc, 2);
1006 memcpy(eth->h_dest+2, &ifa->ifa_address, 4); 1001 memcpy(eth->h_dest+2, &ifa->ifa_address, 4);
@@ -1010,26 +1005,25 @@ plip_rewrite_address(struct net_device *dev, struct ethhdr *eth)
1010 1005
1011static int 1006static int
1012plip_hard_header(struct sk_buff *skb, struct net_device *dev, 1007plip_hard_header(struct sk_buff *skb, struct net_device *dev,
1013 unsigned short type, void *daddr, 1008 unsigned short type, const void *daddr,
1014 void *saddr, unsigned len) 1009 const void *saddr, unsigned len)
1015{ 1010{
1016 struct net_local *nl = netdev_priv(dev);
1017 int ret; 1011 int ret;
1018 1012
1019 if ((ret = nl->orig_hard_header(skb, dev, type, daddr, saddr, len)) >= 0) 1013 ret = eth_header(skb, dev, type, daddr, saddr, len);
1014 if (ret >= 0)
1020 plip_rewrite_address (dev, (struct ethhdr *)skb->data); 1015 plip_rewrite_address (dev, (struct ethhdr *)skb->data);
1021 1016
1022 return ret; 1017 return ret;
1023} 1018}
1024 1019
1025int plip_hard_header_cache(struct neighbour *neigh, 1020int plip_hard_header_cache(const struct neighbour *neigh,
1026 struct hh_cache *hh) 1021 struct hh_cache *hh)
1027{ 1022{
1028 struct net_local *nl = neigh->dev->priv;
1029 int ret; 1023 int ret;
1030 1024
1031 if ((ret = nl->orig_hard_header_cache(neigh, hh)) == 0) 1025 ret = eth_header_cache(neigh, hh);
1032 { 1026 if (ret == 0) {
1033 struct ethhdr *eth; 1027 struct ethhdr *eth;
1034 1028
1035 eth = (struct ethhdr*)(((u8*)hh->hh_data) + 1029 eth = (struct ethhdr*)(((u8*)hh->hh_data) +
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;
diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
index ca508708229d..7cf9b9f35dee 100644
--- a/drivers/net/skfp/skfddi.c
+++ b/drivers/net/skfp/skfddi.c
@@ -260,7 +260,6 @@ static int skfp_init_one(struct pci_dev *pdev,
260 dev->set_multicast_list = &skfp_ctl_set_multicast_list; 260 dev->set_multicast_list = &skfp_ctl_set_multicast_list;
261 dev->set_mac_address = &skfp_ctl_set_mac_address; 261 dev->set_mac_address = &skfp_ctl_set_mac_address;
262 dev->do_ioctl = &skfp_ioctl; 262 dev->do_ioctl = &skfp_ioctl;
263 dev->header_cache_update = NULL; /* not supported */
264 263
265 SET_NETDEV_DEV(dev, &pdev->dev); 264 SET_NETDEV_DEV(dev, &pdev->dev);
266 265
diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c
index 46e053106d4d..8a1778cf98d1 100644
--- a/drivers/net/wan/cycx_x25.c
+++ b/drivers/net/wan/cycx_x25.c
@@ -131,14 +131,15 @@ static int cycx_wan_update(struct wan_device *wandev),
131 cycx_wan_del_if(struct wan_device *wandev, struct net_device *dev); 131 cycx_wan_del_if(struct wan_device *wandev, struct net_device *dev);
132 132
133/* Network device interface */ 133/* Network device interface */
134static int cycx_netdevice_init(struct net_device *dev), 134static int cycx_netdevice_init(struct net_device *dev);
135 cycx_netdevice_open(struct net_device *dev), 135static int cycx_netdevice_open(struct net_device *dev);
136 cycx_netdevice_stop(struct net_device *dev), 136static int cycx_netdevice_stop(struct net_device *dev);
137 cycx_netdevice_hard_header(struct sk_buff *skb, 137static int cycx_netdevice_hard_header(struct sk_buff *skb,
138 struct net_device *dev, u16 type, 138 struct net_device *dev, u16 type,
139 void *daddr, void *saddr, unsigned len), 139 const void *daddr, const void *saddr,
140 cycx_netdevice_rebuild_header(struct sk_buff *skb), 140 unsigned len);
141 cycx_netdevice_hard_start_xmit(struct sk_buff *skb, 141static int cycx_netdevice_rebuild_header(struct sk_buff *skb);
142static int cycx_netdevice_hard_start_xmit(struct sk_buff *skb,
142 struct net_device *dev); 143 struct net_device *dev);
143 144
144static struct net_device_stats * 145static struct net_device_stats *
@@ -468,7 +469,14 @@ static int cycx_wan_del_if(struct wan_device *wandev, struct net_device *dev)
468 return 0; 469 return 0;
469} 470}
470 471
472
471/* Network Device Interface */ 473/* Network Device Interface */
474
475static const struct header_ops cycx_header_ops = {
476 .create = cycx_netdevice_hard_header,
477 .rebuild = cycx_netdevice_rebuild_header,
478};
479
472/* Initialize Linux network interface. 480/* Initialize Linux network interface.
473 * 481 *
474 * This routine is called only once for each interface, during Linux network 482 * This routine is called only once for each interface, during Linux network
@@ -483,8 +491,8 @@ static int cycx_netdevice_init(struct net_device *dev)
483 /* Initialize device driver entry points */ 491 /* Initialize device driver entry points */
484 dev->open = cycx_netdevice_open; 492 dev->open = cycx_netdevice_open;
485 dev->stop = cycx_netdevice_stop; 493 dev->stop = cycx_netdevice_stop;
486 dev->hard_header = cycx_netdevice_hard_header; 494 dev->header_ops = &cycx_header_ops;
487 dev->rebuild_header = cycx_netdevice_rebuild_header; 495
488 dev->hard_start_xmit = cycx_netdevice_hard_start_xmit; 496 dev->hard_start_xmit = cycx_netdevice_hard_start_xmit;
489 dev->get_stats = cycx_netdevice_get_stats; 497 dev->get_stats = cycx_netdevice_get_stats;
490 498
@@ -554,7 +562,8 @@ static int cycx_netdevice_stop(struct net_device *dev)
554 * Return: media header length. */ 562 * Return: media header length. */
555static int cycx_netdevice_hard_header(struct sk_buff *skb, 563static int cycx_netdevice_hard_header(struct sk_buff *skb,
556 struct net_device *dev, u16 type, 564 struct net_device *dev, u16 type,
557 void *daddr, void *saddr, unsigned len) 565 const void *daddr, const void *saddr,
566 unsigned len)
558{ 567{
559 skb->protocol = type; 568 skb->protocol = type;
560 569
diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
index bc12810157e0..96b232446c0b 100644
--- a/drivers/net/wan/dlci.c
+++ b/drivers/net/wan/dlci.c
@@ -66,8 +66,8 @@ static void dlci_setup(struct net_device *);
66 */ 66 */
67 67
68static int dlci_header(struct sk_buff *skb, struct net_device *dev, 68static int dlci_header(struct sk_buff *skb, struct net_device *dev,
69 unsigned short type, void *daddr, void *saddr, 69 unsigned short type, const void *daddr,
70 unsigned len) 70 const void *saddr, unsigned len)
71{ 71{
72 struct frhdr hdr; 72 struct frhdr hdr;
73 struct dlci_local *dlp; 73 struct dlci_local *dlp;
@@ -485,6 +485,10 @@ static int dlci_ioctl(unsigned int cmd, void __user *arg)
485 return(err); 485 return(err);
486} 486}
487 487
488static const struct header_ops dlci_header_ops = {
489 .create = dlci_header,
490};
491
488static void dlci_setup(struct net_device *dev) 492static void dlci_setup(struct net_device *dev)
489{ 493{
490 struct dlci_local *dlp = dev->priv; 494 struct dlci_local *dlp = dev->priv;
@@ -494,7 +498,7 @@ static void dlci_setup(struct net_device *dev)
494 dev->stop = dlci_close; 498 dev->stop = dlci_close;
495 dev->do_ioctl = dlci_dev_ioctl; 499 dev->do_ioctl = dlci_dev_ioctl;
496 dev->hard_start_xmit = dlci_transmit; 500 dev->hard_start_xmit = dlci_transmit;
497 dev->hard_header = dlci_header; 501 dev->header_ops = &dlci_header_ops;
498 dev->get_stats = dlci_get_stats; 502 dev->get_stats = dlci_get_stats;
499 dev->change_mtu = dlci_change_mtu; 503 dev->change_mtu = dlci_change_mtu;
500 dev->destructor = free_netdev; 504 dev->destructor = free_netdev;
diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c
index ee23b91f23d9..d553e6f32851 100644
--- a/drivers/net/wan/hdlc.c
+++ b/drivers/net/wan/hdlc.c
@@ -232,6 +232,8 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
232 return -EINVAL; 232 return -EINVAL;
233} 233}
234 234
235static const struct header_ops hdlc_null_ops;
236
235static void hdlc_setup_dev(struct net_device *dev) 237static void hdlc_setup_dev(struct net_device *dev)
236{ 238{
237 /* Re-init all variables changed by HDLC protocol drivers, 239 /* Re-init all variables changed by HDLC protocol drivers,
@@ -243,13 +245,9 @@ static void hdlc_setup_dev(struct net_device *dev)
243 dev->type = ARPHRD_RAWHDLC; 245 dev->type = ARPHRD_RAWHDLC;
244 dev->hard_header_len = 16; 246 dev->hard_header_len = 16;
245 dev->addr_len = 0; 247 dev->addr_len = 0;
246 dev->hard_header = NULL; 248 dev->header_ops = &hdlc_null_ops;
247 dev->rebuild_header = NULL; 249
248 dev->set_mac_address = NULL;
249 dev->hard_header_cache = NULL;
250 dev->header_cache_update = NULL;
251 dev->change_mtu = hdlc_change_mtu; 250 dev->change_mtu = hdlc_change_mtu;
252 dev->hard_header_parse = NULL;
253} 251}
254 252
255static void hdlc_setup(struct net_device *dev) 253static void hdlc_setup(struct net_device *dev)
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index 9ec6cf2e510e..038a6e748bbf 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -74,7 +74,7 @@ static inline struct cisco_state * state(hdlc_device *hdlc)
74 74
75 75
76static int cisco_hard_header(struct sk_buff *skb, struct net_device *dev, 76static int cisco_hard_header(struct sk_buff *skb, struct net_device *dev,
77 u16 type, void *daddr, void *saddr, 77 u16 type, const void *daddr, const void *saddr,
78 unsigned int len) 78 unsigned int len)
79{ 79{
80 struct hdlc_header *data; 80 struct hdlc_header *data;
@@ -309,7 +309,6 @@ static void cisco_stop(struct net_device *dev)
309} 309}
310 310
311 311
312
313static struct hdlc_proto proto = { 312static struct hdlc_proto proto = {
314 .start = cisco_start, 313 .start = cisco_start,
315 .stop = cisco_stop, 314 .stop = cisco_stop,
@@ -317,7 +316,10 @@ static struct hdlc_proto proto = {
317 .ioctl = cisco_ioctl, 316 .ioctl = cisco_ioctl,
318 .module = THIS_MODULE, 317 .module = THIS_MODULE,
319}; 318};
320 319
320static const struct header_ops cisco_header_ops = {
321 .create = cisco_hard_header,
322};
321 323
322static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr) 324static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
323{ 325{
@@ -365,7 +367,7 @@ static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
365 367
366 memcpy(&state(hdlc)->settings, &new_settings, size); 368 memcpy(&state(hdlc)->settings, &new_settings, size);
367 dev->hard_start_xmit = hdlc->xmit; 369 dev->hard_start_xmit = hdlc->xmit;
368 dev->hard_header = cisco_hard_header; 370 dev->header_ops = &cisco_header_ops;
369 dev->type = ARPHRD_CISCO; 371 dev->type = ARPHRD_CISCO;
370 netif_dormant_on(dev); 372 netif_dormant_on(dev);
371 return 0; 373 return 0;
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index 4591437dd2f3..3caeb528eace 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -73,7 +73,7 @@ static void ppp_close(struct net_device *dev)
73 73
74 sppp_close(dev); 74 sppp_close(dev);
75 sppp_detach(dev); 75 sppp_detach(dev);
76 dev->rebuild_header = NULL; 76
77 dev->change_mtu = state(hdlc)->old_change_mtu; 77 dev->change_mtu = state(hdlc)->old_change_mtu;
78 dev->mtu = HDLC_MAX_MTU; 78 dev->mtu = HDLC_MAX_MTU;
79 dev->hard_header_len = 16; 79 dev->hard_header_len = 16;
diff --git a/drivers/net/wan/lmc/lmc_proto.c b/drivers/net/wan/lmc/lmc_proto.c
index 31e1799571ad..426c0678d983 100644
--- a/drivers/net/wan/lmc/lmc_proto.c
+++ b/drivers/net/wan/lmc/lmc_proto.c
@@ -111,7 +111,7 @@ void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
111 * They set a few basics because they don't use sync_ppp 111 * They set a few basics because they don't use sync_ppp
112 */ 112 */
113 dev->flags |= IFF_POINTOPOINT; 113 dev->flags |= IFF_POINTOPOINT;
114 dev->hard_header = NULL; 114
115 dev->hard_header_len = 0; 115 dev->hard_header_len = 0;
116 dev->addr_len = 0; 116 dev->addr_len = 0;
117 } 117 }
diff --git a/drivers/net/wan/syncppp.c b/drivers/net/wan/syncppp.c
index 5c71af6ea3a5..232ecba5340f 100644
--- a/drivers/net/wan/syncppp.c
+++ b/drivers/net/wan/syncppp.c
@@ -359,8 +359,10 @@ done:
359 * Handle transmit packets. 359 * Handle transmit packets.
360 */ 360 */
361 361
362static int sppp_hard_header(struct sk_buff *skb, struct net_device *dev, __u16 type, 362static int sppp_hard_header(struct sk_buff *skb,
363 void *daddr, void *saddr, unsigned int len) 363 struct net_device *dev, __u16 type,
364 const void *daddr, const void *saddr,
365 unsigned int len)
364{ 366{
365 struct sppp *sp = (struct sppp *)sppp_of(dev); 367 struct sppp *sp = (struct sppp *)sppp_of(dev);
366 struct ppp_header *h; 368 struct ppp_header *h;
@@ -392,10 +394,9 @@ static int sppp_hard_header(struct sk_buff *skb, struct net_device *dev, __u16 t
392 return sizeof(struct ppp_header); 394 return sizeof(struct ppp_header);
393} 395}
394 396
395static int sppp_rebuild_header(struct sk_buff *skb) 397static const struct header_ops sppp_header_ops = {
396{ 398 .create = sppp_hard_header,
397 return 0; 399};
398}
399 400
400/* 401/*
401 * Send keepalive packets, every 10 seconds. 402 * Send keepalive packets, every 10 seconds.
@@ -1098,8 +1099,8 @@ void sppp_attach(struct ppp_device *pd)
1098 * hard_start_xmit. 1099 * hard_start_xmit.
1099 */ 1100 */
1100 1101
1101 dev->hard_header = sppp_hard_header; 1102 dev->header_ops = &sppp_header_ops;
1102 dev->rebuild_header = sppp_rebuild_header; 1103
1103 dev->tx_queue_len = 10; 1104 dev->tx_queue_len = 10;
1104 dev->type = ARPHRD_HDLC; 1105 dev->type = ARPHRD_HDLC;
1105 dev->addr_len = 0; 1106 dev->addr_len = 0;
@@ -1115,8 +1116,6 @@ void sppp_attach(struct ppp_device *pd)
1115 dev->stop = sppp_close; 1116 dev->stop = sppp_close;
1116#endif 1117#endif
1117 dev->change_mtu = sppp_change_mtu; 1118 dev->change_mtu = sppp_change_mtu;
1118 dev->hard_header_cache = NULL;
1119 dev->header_cache_update = NULL;
1120 dev->flags = IFF_MULTICAST|IFF_POINTOPOINT|IFF_NOARP; 1119 dev->flags = IFF_MULTICAST|IFF_POINTOPOINT|IFF_NOARP;
1121} 1120}
1122 1121
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index cd03a61359aa..074055e18c5c 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2696,9 +2696,13 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci)
2696 return rc; 2696 return rc;
2697} 2697}
2698 2698
2699static const struct header_ops airo_header_ops = {
2700 .parse = wll_header_parse,
2701};
2702
2699static void wifi_setup(struct net_device *dev) 2703static void wifi_setup(struct net_device *dev)
2700{ 2704{
2701 dev->hard_header_parse = wll_header_parse; 2705 dev->header_ops = &airo_header_ops;
2702 dev->hard_start_xmit = &airo_start_xmit11; 2706 dev->hard_start_xmit = &airo_start_xmit11;
2703 dev->get_stats = &airo_get_stats; 2707 dev->get_stats = &airo_get_stats;
2704 dev->set_mac_address = &airo_set_mac_address; 2708 dev->set_mac_address = &airo_set_mac_address;
diff --git a/drivers/net/wireless/hostap/hostap.h b/drivers/net/wireless/hostap/hostap.h
index ef37a75d550b..951df83702f9 100644
--- a/drivers/net/wireless/hostap/hostap.h
+++ b/drivers/net/wireless/hostap/hostap.h
@@ -30,8 +30,7 @@ void hostap_dump_rx_header(const char *name,
30 const struct hfa384x_rx_frame *rx); 30 const struct hfa384x_rx_frame *rx);
31void hostap_dump_tx_header(const char *name, 31void hostap_dump_tx_header(const char *name,
32 const struct hfa384x_tx_frame *tx); 32 const struct hfa384x_tx_frame *tx);
33int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr); 33extern const struct header_ops hostap_80211_ops;
34int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr);
35int hostap_80211_get_hdrlen(u16 fc); 34int hostap_80211_get_hdrlen(u16 fc);
36struct net_device_stats *hostap_get_stats(struct net_device *dev); 35struct net_device_stats *hostap_get_stats(struct net_device *dev);
37void hostap_setup_dev(struct net_device *dev, local_info_t *local, 36void hostap_setup_dev(struct net_device *dev, local_info_t *local,
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index 7fa7ab0a4b23..b20bb013d57e 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -3258,11 +3258,10 @@ while (0)
3258 INIT_LIST_HEAD(&local->bss_list); 3258 INIT_LIST_HEAD(&local->bss_list);
3259 3259
3260 hostap_setup_dev(dev, local, 1); 3260 hostap_setup_dev(dev, local, 1);
3261 local->saved_eth_header_parse = dev->hard_header_parse;
3262 3261
3263 dev->hard_start_xmit = hostap_master_start_xmit; 3262 dev->hard_start_xmit = hostap_master_start_xmit;
3264 dev->type = ARPHRD_IEEE80211; 3263 dev->type = ARPHRD_IEEE80211;
3265 dev->hard_header_parse = hostap_80211_header_parse; 3264 dev->header_ops = &hostap_80211_ops;
3266 3265
3267 rtnl_lock(); 3266 rtnl_lock();
3268 ret = dev_alloc_name(dev, "wifi%d"); 3267 ret = dev_alloc_name(dev, "wifi%d");
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index 7036ecff5ec1..40f516d42c5e 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -897,11 +897,8 @@ static void hostap_monitor_set_type(local_info_t *local)
897 if (local->monitor_type == PRISM2_MONITOR_PRISM || 897 if (local->monitor_type == PRISM2_MONITOR_PRISM ||
898 local->monitor_type == PRISM2_MONITOR_CAPHDR) { 898 local->monitor_type == PRISM2_MONITOR_CAPHDR) {
899 dev->type = ARPHRD_IEEE80211_PRISM; 899 dev->type = ARPHRD_IEEE80211_PRISM;
900 dev->hard_header_parse =
901 hostap_80211_prism_header_parse;
902 } else { 900 } else {
903 dev->type = ARPHRD_IEEE80211; 901 dev->type = ARPHRD_IEEE80211;
904 dev->hard_header_parse = hostap_80211_header_parse;
905 } 902 }
906} 903}
907 904
@@ -1141,7 +1138,7 @@ static int hostap_monitor_mode_disable(local_info_t *local)
1141 1138
1142 printk(KERN_DEBUG "%s: Disabling monitor mode\n", dev->name); 1139 printk(KERN_DEBUG "%s: Disabling monitor mode\n", dev->name);
1143 dev->type = ARPHRD_ETHER; 1140 dev->type = ARPHRD_ETHER;
1144 dev->hard_header_parse = local->saved_eth_header_parse; 1141
1145 if (local->func->cmd(dev, HFA384X_CMDCODE_TEST | 1142 if (local->func->cmd(dev, HFA384X_CMDCODE_TEST |
1146 (HFA384X_TEST_STOP << 8), 1143 (HFA384X_TEST_STOP << 8),
1147 0, NULL, NULL)) 1144 0, NULL, NULL))
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 4cb09d81b404..b75cf9205ce0 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -594,24 +594,27 @@ void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx)
594} 594}
595 595
596 596
597int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr) 597int hostap_80211_header_parse(const struct sk_buff *skb, unsigned char *haddr)
598{ 598{
599 memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */ 599 struct hostap_interface *iface = netdev_priv(skb->dev);
600 return ETH_ALEN; 600 local_info_t *local = iface->local;
601} 601
602 602 if (local->monitor_type == PRISM2_MONITOR_PRISM ||
603 local->monitor_type == PRISM2_MONITOR_CAPHDR) {
604 const unsigned char *mac = skb_mac_header(skb);
605
606 if (*(u32 *)mac == LWNG_CAP_DID_BASE) {
607 memcpy(haddr,
608 mac + sizeof(struct linux_wlan_ng_prism_hdr) + 10,
609 ETH_ALEN); /* addr2 */
610 } else { /* (*(u32 *)mac == htonl(LWNG_CAPHDR_VERSION)) */
611 memcpy(haddr,
612 mac + sizeof(struct linux_wlan_ng_cap_hdr) + 10,
613 ETH_ALEN); /* addr2 */
614 }
615 } else
616 memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
603 617
604int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr)
605{
606 const unsigned char *mac = skb_mac_header(skb);
607
608 if (*(u32 *)mac == LWNG_CAP_DID_BASE) {
609 memcpy(haddr, mac + sizeof(struct linux_wlan_ng_prism_hdr) + 10,
610 ETH_ALEN); /* addr2 */
611 } else { /* (*(u32 *)mac == htonl(LWNG_CAPHDR_VERSION)) */
612 memcpy(haddr, mac + sizeof(struct linux_wlan_ng_cap_hdr) + 10,
613 ETH_ALEN); /* addr2 */
614 }
615 return ETH_ALEN; 618 return ETH_ALEN;
616} 619}
617 620
@@ -843,6 +846,15 @@ static void prism2_tx_timeout(struct net_device *dev)
843 local->func->schedule_reset(local); 846 local->func->schedule_reset(local);
844} 847}
845 848
849const struct header_ops hostap_80211_ops = {
850 .create = eth_header,
851 .rebuild = eth_rebuild_header,
852 .cache = eth_header_cache,
853 .cache_update = eth_header_cache_update,
854
855 .parse = hostap_80211_header_parse,
856};
857EXPORT_SYMBOL(hostap_80211_ops);
846 858
847void hostap_setup_dev(struct net_device *dev, local_info_t *local, 859void hostap_setup_dev(struct net_device *dev, local_info_t *local,
848 int main_dev) 860 int main_dev)
@@ -883,7 +895,6 @@ void hostap_setup_dev(struct net_device *dev, local_info_t *local,
883 netif_stop_queue(dev); 895 netif_stop_queue(dev);
884} 896}
885 897
886
887static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked) 898static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked)
888{ 899{
889 struct net_device *dev = local->dev; 900 struct net_device *dev = local->dev;
@@ -901,7 +912,7 @@ static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked)
901 912
902 local->apdev->hard_start_xmit = hostap_mgmt_start_xmit; 913 local->apdev->hard_start_xmit = hostap_mgmt_start_xmit;
903 local->apdev->type = ARPHRD_IEEE80211; 914 local->apdev->type = ARPHRD_IEEE80211;
904 local->apdev->hard_header_parse = hostap_80211_header_parse; 915 local->apdev->header_ops = &hostap_80211_ops;
905 916
906 return 0; 917 return 0;
907} 918}
diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h
index a42325c145b4..c27b2c1c06af 100644
--- a/drivers/net/wireless/hostap/hostap_wlan.h
+++ b/drivers/net/wireless/hostap/hostap_wlan.h
@@ -736,8 +736,6 @@ struct local_info {
736 PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1, 736 PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1,
737 PRISM2_MONITOR_CAPHDR = 2 737 PRISM2_MONITOR_CAPHDR = 2
738 } monitor_type; 738 } monitor_type;
739 int (*saved_eth_header_parse)(struct sk_buff *skb,
740 unsigned char *haddr);
741 int monitor_allow_fcserr; 739 int monitor_allow_fcserr;
742 740
743 int hostapd; /* whether user space daemon, hostapd, is used for AP 741 int hostapd; /* whether user space daemon, hostapd, is used for AP
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index 404cd1512312..4bd14b331862 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -1631,8 +1631,8 @@ static void strip_IdleTask(unsigned long parameter)
1631 */ 1631 */
1632 1632
1633static int strip_header(struct sk_buff *skb, struct net_device *dev, 1633static int strip_header(struct sk_buff *skb, struct net_device *dev,
1634 unsigned short type, void *daddr, void *saddr, 1634 unsigned short type, const void *daddr,
1635 unsigned len) 1635 const void *saddr, unsigned len)
1636{ 1636{
1637 struct strip *strip_info = netdev_priv(dev); 1637 struct strip *strip_info = netdev_priv(dev);
1638 STRIP_Header *header = (STRIP_Header *) skb_push(skb, sizeof(STRIP_Header)); 1638 STRIP_Header *header = (STRIP_Header *) skb_push(skb, sizeof(STRIP_Header));
@@ -2497,6 +2497,11 @@ static int strip_close_low(struct net_device *dev)
2497 return 0; 2497 return 0;
2498} 2498}
2499 2499
2500static const struct header_ops strip_header_ops = {
2501 .create = strip_header,
2502 .rebuild = strip_rebuild_header,
2503};
2504
2500/* 2505/*
2501 * This routine is called by DDI when the 2506 * This routine is called by DDI when the
2502 * (dynamically assigned) device is registered 2507 * (dynamically assigned) device is registered
@@ -2531,8 +2536,8 @@ static void strip_dev_setup(struct net_device *dev)
2531 dev->open = strip_open_low; 2536 dev->open = strip_open_low;
2532 dev->stop = strip_close_low; 2537 dev->stop = strip_close_low;
2533 dev->hard_start_xmit = strip_xmit; 2538 dev->hard_start_xmit = strip_xmit;
2534 dev->hard_header = strip_header; 2539 dev->header_ops = &strip_header_ops;
2535 dev->rebuild_header = strip_rebuild_header; 2540
2536 dev->set_mac_address = strip_set_mac_address; 2541 dev->set_mac_address = strip_set_mac_address;
2537 dev->get_stats = strip_get_stats; 2542 dev->get_stats = strip_get_stats;
2538 dev->change_mtu = strip_change_mtu; 2543 dev->change_mtu = strip_change_mtu;