aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wan
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/wan
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/wan')
-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
7 files changed, 48 insertions, 36 deletions
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