aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
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/netdevice.h
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/netdevice.h')
-rw-r--r--include/linux/netdevice.h43
1 files changed, 23 insertions, 20 deletions
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);