aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
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 /include/linux
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 'include/linux')
-rw-r--r--include/linux/etherdevice.h20
-rw-r--r--include/linux/if_ether.h2
-rw-r--r--include/linux/if_shaper.h11
-rw-r--r--include/linux/isdn.h7
-rw-r--r--include/linux/netdevice.h43
5 files changed, 37 insertions, 46 deletions
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 6cdb97365e47..b7558ec81ed5 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -29,15 +29,19 @@
29#include <linux/random.h> 29#include <linux/random.h>
30 30
31#ifdef __KERNEL__ 31#ifdef __KERNEL__
32extern int eth_header(struct sk_buff *skb, struct net_device *dev,
33 unsigned short type, void *daddr,
34 void *saddr, unsigned len);
35extern int eth_rebuild_header(struct sk_buff *skb);
36extern __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev); 32extern __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev);
37extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev, 33extern const struct header_ops eth_header_ops;
38 unsigned char * haddr); 34
39extern int eth_header_cache(struct neighbour *neigh, 35extern int eth_header(struct sk_buff *skb, struct net_device *dev,
40 struct hh_cache *hh); 36 unsigned short type,
37 const void *daddr, const void *saddr, unsigned len);
38extern int eth_rebuild_header(struct sk_buff *skb);
39extern int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
40extern int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh);
41extern void eth_header_cache_update(struct hh_cache *hh,
42 const struct net_device *dev,
43 const unsigned char *haddr);
44
41 45
42extern struct net_device *alloc_etherdev_mq(int sizeof_priv, unsigned int queue_count); 46extern struct net_device *alloc_etherdev_mq(int sizeof_priv, unsigned int queue_count);
43#define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1) 47#define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1)
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 0e791e2c0c5a..5f9297793661 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -117,6 +117,8 @@ static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
117 return (struct ethhdr *)skb_mac_header(skb); 117 return (struct ethhdr *)skb_mac_header(skb);
118} 118}
119 119
120int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
121
120#ifdef CONFIG_SYSCTL 122#ifdef CONFIG_SYSCTL
121extern struct ctl_table ether_table[]; 123extern struct ctl_table ether_table[];
122#endif 124#endif
diff --git a/include/linux/if_shaper.h b/include/linux/if_shaper.h
index 51574743aa1b..3b1b7ba19825 100644
--- a/include/linux/if_shaper.h
+++ b/include/linux/if_shaper.h
@@ -25,17 +25,6 @@ struct shaper
25 an empty queue */ 25 an empty queue */
26 spinlock_t lock; 26 spinlock_t lock;
27 struct net_device *dev; 27 struct net_device *dev;
28 int (*hard_start_xmit) (struct sk_buff *skb,
29 struct net_device *dev);
30 int (*hard_header) (struct sk_buff *skb,
31 struct net_device *dev,
32 unsigned short type,
33 void *daddr,
34 void *saddr,
35 unsigned len);
36 int (*rebuild_header)(struct sk_buff *skb);
37 int (*hard_header_cache)(struct neighbour *neigh, struct hh_cache *hh);
38 void (*header_cache_update)(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr);
39 struct net_device_stats* (*get_stats)(struct net_device *dev); 28 struct net_device_stats* (*get_stats)(struct net_device *dev);
40 struct timer_list timer; 29 struct timer_list timer;
41}; 30};
diff --git a/include/linux/isdn.h b/include/linux/isdn.h
index 3c7875b7ab5b..a6fb366748bb 100644
--- a/include/linux/isdn.h
+++ b/include/linux/isdn.h
@@ -353,13 +353,6 @@ typedef struct isdn_net_local_s {
353 /* a particular channel (including */ 353 /* a particular channel (including */
354 /* the frame_cnt */ 354 /* the frame_cnt */
355 355
356 int (*org_hhc)(
357 struct neighbour *neigh,
358 struct hh_cache *hh);
359 /* Ptr to orig. header_cache_update */
360 void (*org_hcu)(struct hh_cache *,
361 struct net_device *,
362 unsigned char *);
363 int pppbind; /* ippp device for bindings */ 356 int pppbind; /* ippp device for bindings */
364 int dialtimeout; /* How long shall we try on dialing? (jiffies) */ 357 int dialtimeout; /* How long shall we try on dialing? (jiffies) */
365 int dialwait; /* How long shall we wait after failed attempt? (jiffies) */ 358 int dialwait; /* How long shall we wait after failed attempt? (jiffies) */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index aae9ec367f5d..91cd3f3db507 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -250,6 +250,19 @@ struct hh_cache
250#define LL_RESERVED_SPACE_EXTRA(dev,extra) \ 250#define LL_RESERVED_SPACE_EXTRA(dev,extra) \
251 ((((dev)->hard_header_len+extra)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD) 251 ((((dev)->hard_header_len+extra)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
252 252
253struct header_ops {
254 int (*create) (struct sk_buff *skb, struct net_device *dev,
255 unsigned short type, const void *daddr,
256 const void *saddr, unsigned len);
257 int (*parse)(const struct sk_buff *skb, unsigned char *haddr);
258 int (*rebuild)(struct sk_buff *skb);
259#define HAVE_HEADER_CACHE
260 int (*cache)(const struct neighbour *neigh, struct hh_cache *hh);
261 void (*cache_update)(struct hh_cache *hh,
262 const struct net_device *dev,
263 const unsigned char *haddr);
264};
265
253/* These flag bits are private to the generic network queueing 266/* These flag bits are private to the generic network queueing
254 * layer, they may not be explicitly referenced by any other 267 * layer, they may not be explicitly referenced by any other
255 * code. 268 * code.
@@ -492,6 +505,9 @@ struct net_device
492#endif 505#endif
493 const struct ethtool_ops *ethtool_ops; 506 const struct ethtool_ops *ethtool_ops;
494 507
508 /* Hardware header description */
509 const struct header_ops *header_ops;
510
495 /* 511 /*
496 * This marks the end of the "visible" part of the structure. All 512 * This marks the end of the "visible" part of the structure. All
497 * fields hereafter are internal to the system, and may change at 513 * fields hereafter are internal to the system, and may change at
@@ -615,13 +631,6 @@ struct net_device
615 int (*open)(struct net_device *dev); 631 int (*open)(struct net_device *dev);
616 int (*stop)(struct net_device *dev); 632 int (*stop)(struct net_device *dev);
617#define HAVE_NETDEV_POLL 633#define HAVE_NETDEV_POLL
618 int (*hard_header) (struct sk_buff *skb,
619 struct net_device *dev,
620 unsigned short type,
621 void *daddr,
622 void *saddr,
623 unsigned len);
624 int (*rebuild_header)(struct sk_buff *skb);
625#define HAVE_CHANGE_RX_FLAGS 634#define HAVE_CHANGE_RX_FLAGS
626 void (*change_rx_flags)(struct net_device *dev, 635 void (*change_rx_flags)(struct net_device *dev,
627 int flags); 636 int flags);
@@ -638,12 +647,6 @@ struct net_device
638#define HAVE_SET_CONFIG 647#define HAVE_SET_CONFIG
639 int (*set_config)(struct net_device *dev, 648 int (*set_config)(struct net_device *dev,
640 struct ifmap *map); 649 struct ifmap *map);
641#define HAVE_HEADER_CACHE
642 int (*hard_header_cache)(struct neighbour *neigh,
643 struct hh_cache *hh);
644 void (*header_cache_update)(struct hh_cache *hh,
645 struct net_device *dev,
646 unsigned char * haddr);
647#define HAVE_CHANGE_MTU 650#define HAVE_CHANGE_MTU
648 int (*change_mtu)(struct net_device *dev, int new_mtu); 651 int (*change_mtu)(struct net_device *dev, int new_mtu);
649 652
@@ -657,8 +660,6 @@ struct net_device
657 void (*vlan_rx_kill_vid)(struct net_device *dev, 660 void (*vlan_rx_kill_vid)(struct net_device *dev,
658 unsigned short vid); 661 unsigned short vid);
659 662
660 int (*hard_header_parse)(const struct sk_buff *skb,
661 unsigned char *haddr);
662 int (*neigh_setup)(struct net_device *dev, struct neigh_parms *); 663 int (*neigh_setup)(struct net_device *dev, struct neigh_parms *);
663#ifdef CONFIG_NETPOLL 664#ifdef CONFIG_NETPOLL
664 struct netpoll_info *npinfo; 665 struct netpoll_info *npinfo;
@@ -802,11 +803,13 @@ extern int netpoll_trap(void);
802 803
803static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev, 804static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
804 unsigned short type, 805 unsigned short type,
805 void *daddr, void *saddr, unsigned len) 806 const void *daddr, const void *saddr,
807 unsigned len)
806{ 808{
807 if (!dev->hard_header) 809 if (!dev->header_ops)
808 return 0; 810 return 0;
809 return dev->hard_header(skb, dev, type, daddr, saddr, len); 811
812 return dev->header_ops->create(skb, dev, type, daddr, saddr, len);
810} 813}
811 814
812static inline int dev_parse_header(const struct sk_buff *skb, 815static inline int dev_parse_header(const struct sk_buff *skb,
@@ -814,9 +817,9 @@ static inline int dev_parse_header(const struct sk_buff *skb,
814{ 817{
815 const struct net_device *dev = skb->dev; 818 const struct net_device *dev = skb->dev;
816 819
817 if (!dev->hard_header_parse) 820 if (!dev->header_ops->parse)
818 return 0; 821 return 0;
819 return dev->hard_header_parse(skb, haddr); 822 return dev->header_ops->parse(skb, haddr);
820} 823}
821 824
822typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len); 825typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);