diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-10-09 04:40:57 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:52:52 -0400 |
commit | 3b04ddde02cf1b6f14f2697da5c20eca5715017f (patch) | |
tree | 9da1341a5a399a507b5ea6bf5a3047506b8d8f8f /drivers/net/myri_sbus.c | |
parent | b95cce3576813ac3f86bafa6b5daaaaf7574b0fe (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/myri_sbus.c')
-rw-r--r-- | drivers/net/myri_sbus.c | 28 |
1 files changed, 18 insertions, 10 deletions
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 | */ |
679 | static int myri_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, | 679 | static 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 | ||
762 | int myri_header_cache(struct neighbour *neigh, struct hh_cache *hh) | 763 | static 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. */ |
789 | void myri_header_cache_update(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr) | 790 | void 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 | ||
887 | static 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 | |||
884 | static int __devinit myri_ether_init(struct sbus_dev *sdev) | 894 | static 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")); |