aboutsummaryrefslogtreecommitdiffstats
path: root/net/802
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 /net/802
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 'net/802')
-rw-r--r--net/802/fc.c11
-rw-r--r--net/802/fddi.c10
-rw-r--r--net/802/hippi.c16
-rw-r--r--net/802/tr.c15
4 files changed, 33 insertions, 19 deletions
diff --git a/net/802/fc.c b/net/802/fc.c
index 675d9ba8e591..cb3475ea6fda 100644
--- a/net/802/fc.c
+++ b/net/802/fc.c
@@ -35,7 +35,7 @@
35 35
36static int fc_header(struct sk_buff *skb, struct net_device *dev, 36static int fc_header(struct sk_buff *skb, struct net_device *dev,
37 unsigned short type, 37 unsigned short type,
38 void *daddr, void *saddr, unsigned len) 38 const void *daddr, const void *saddr, unsigned len)
39{ 39{
40 struct fch_hdr *fch; 40 struct fch_hdr *fch;
41 int hdr_len; 41 int hdr_len;
@@ -95,11 +95,14 @@ static int fc_rebuild_header(struct sk_buff *skb)
95#endif 95#endif
96} 96}
97 97
98static const struct header_ops fc_header_ops = {
99 .create = fc_header,
100 .rebuild = fc_rebuild_header,
101};
102
98static void fc_setup(struct net_device *dev) 103static void fc_setup(struct net_device *dev)
99{ 104{
100 dev->hard_header = fc_header; 105 dev->header_ops = &fc_header_ops;
101 dev->rebuild_header = fc_rebuild_header;
102
103 dev->type = ARPHRD_IEEE802; 106 dev->type = ARPHRD_IEEE802;
104 dev->hard_header_len = FC_HLEN; 107 dev->hard_header_len = FC_HLEN;
105 dev->mtu = 2024; 108 dev->mtu = 2024;
diff --git a/net/802/fddi.c b/net/802/fddi.c
index 91dde41b5481..0549317b9356 100644
--- a/net/802/fddi.c
+++ b/net/802/fddi.c
@@ -52,7 +52,7 @@
52 52
53static int fddi_header(struct sk_buff *skb, struct net_device *dev, 53static int fddi_header(struct sk_buff *skb, struct net_device *dev,
54 unsigned short type, 54 unsigned short type,
55 void *daddr, void *saddr, unsigned len) 55 const void *daddr, const void *saddr, unsigned len)
56{ 56{
57 int hl = FDDI_K_SNAP_HLEN; 57 int hl = FDDI_K_SNAP_HLEN;
58 struct fddihdr *fddi; 58 struct fddihdr *fddi;
@@ -175,11 +175,15 @@ static int fddi_change_mtu(struct net_device *dev, int new_mtu)
175 return(0); 175 return(0);
176} 176}
177 177
178static const struct header_ops fddi_header_ops = {
179 .create = fddi_header,
180 .rebuild = fddi_rebuild_header,
181};
182
178static void fddi_setup(struct net_device *dev) 183static void fddi_setup(struct net_device *dev)
179{ 184{
180 dev->change_mtu = fddi_change_mtu; 185 dev->change_mtu = fddi_change_mtu;
181 dev->hard_header = fddi_header; 186 dev->header_ops = &fddi_header_ops;
182 dev->rebuild_header = fddi_rebuild_header;
183 187
184 dev->type = ARPHRD_FDDI; 188 dev->type = ARPHRD_FDDI;
185 dev->hard_header_len = FDDI_K_SNAP_HLEN+3; /* Assume 802.2 SNAP hdr len + 3 pad bytes */ 189 dev->hard_header_len = FDDI_K_SNAP_HLEN+3; /* Assume 802.2 SNAP hdr len + 3 pad bytes */
diff --git a/net/802/hippi.c b/net/802/hippi.c
index 87ffc12b6891..e35dc1e0915d 100644
--- a/net/802/hippi.c
+++ b/net/802/hippi.c
@@ -45,8 +45,8 @@
45 */ 45 */
46 46
47static int hippi_header(struct sk_buff *skb, struct net_device *dev, 47static int hippi_header(struct sk_buff *skb, struct net_device *dev,
48 unsigned short type, void *daddr, void *saddr, 48 unsigned short type,
49 unsigned len) 49 const void *daddr, const void *saddr, unsigned len)
50{ 50{
51 struct hippi_hdr *hip = (struct hippi_hdr *)skb_push(skb, HIPPI_HLEN); 51 struct hippi_hdr *hip = (struct hippi_hdr *)skb_push(skb, HIPPI_HLEN);
52 struct hippi_cb *hcb = (struct hippi_cb *) skb->cb; 52 struct hippi_cb *hcb = (struct hippi_cb *) skb->cb;
@@ -182,16 +182,18 @@ static int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p)
182 return 0; 182 return 0;
183} 183}
184 184
185static const struct header_ops hippi_header_ops = {
186 .create = hippi_header,
187 .rebuild = hippi_rebuild_header,
188};
189
190
185static void hippi_setup(struct net_device *dev) 191static void hippi_setup(struct net_device *dev)
186{ 192{
187 dev->set_multicast_list = NULL; 193 dev->set_multicast_list = NULL;
188 dev->change_mtu = hippi_change_mtu; 194 dev->change_mtu = hippi_change_mtu;
189 dev->hard_header = hippi_header; 195 dev->header_ops = &hippi_header_ops;
190 dev->rebuild_header = hippi_rebuild_header;
191 dev->set_mac_address = hippi_mac_addr; 196 dev->set_mac_address = hippi_mac_addr;
192 dev->hard_header_parse = NULL;
193 dev->hard_header_cache = NULL;
194 dev->header_cache_update = NULL;
195 dev->neigh_setup = hippi_neigh_setup_dev; 197 dev->neigh_setup = hippi_neigh_setup_dev;
196 198
197 /* 199 /*
diff --git a/net/802/tr.c b/net/802/tr.c
index aa3c2e936abc..a2bd0f2e3af8 100644
--- a/net/802/tr.c
+++ b/net/802/tr.c
@@ -100,7 +100,7 @@ static inline unsigned long rif_hash(const unsigned char *addr)
100 100
101static int tr_header(struct sk_buff *skb, struct net_device *dev, 101static int tr_header(struct sk_buff *skb, struct net_device *dev,
102 unsigned short type, 102 unsigned short type,
103 void *daddr, void *saddr, unsigned len) 103 const void *daddr, const void *saddr, unsigned len)
104{ 104{
105 struct trh_hdr *trh; 105 struct trh_hdr *trh;
106 int hdr_len; 106 int hdr_len;
@@ -142,7 +142,7 @@ static int tr_header(struct sk_buff *skb, struct net_device *dev,
142 if(daddr) 142 if(daddr)
143 { 143 {
144 memcpy(trh->daddr,daddr,dev->addr_len); 144 memcpy(trh->daddr,daddr,dev->addr_len);
145 tr_source_route(skb,trh,dev); 145 tr_source_route(skb, trh, dev);
146 return(hdr_len); 146 return(hdr_len);
147 } 147 }
148 148
@@ -247,7 +247,8 @@ __be16 tr_type_trans(struct sk_buff *skb, struct net_device *dev)
247 * We try to do source routing... 247 * We try to do source routing...
248 */ 248 */
249 249
250void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,struct net_device *dev) 250void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,
251 struct net_device *dev)
251{ 252{
252 int slack; 253 int slack;
253 unsigned int hash; 254 unsigned int hash;
@@ -592,14 +593,18 @@ static const struct file_operations rif_seq_fops = {
592 593
593#endif 594#endif
594 595
596static const struct header_ops tr_header_ops = {
597 .create = tr_header,
598 .rebuild= tr_rebuild_header,
599};
600
595static void tr_setup(struct net_device *dev) 601static void tr_setup(struct net_device *dev)
596{ 602{
597 /* 603 /*
598 * Configure and register 604 * Configure and register
599 */ 605 */
600 606
601 dev->hard_header = tr_header; 607 dev->header_ops = &tr_header_ops;
602 dev->rebuild_header = tr_rebuild_header;
603 608
604 dev->type = ARPHRD_IEEE802_TR; 609 dev->type = ARPHRD_IEEE802_TR;
605 dev->hard_header_len = TR_HLEN; 610 dev->hard_header_len = TR_HLEN;