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/wireless/hostap | |
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/wireless/hostap')
-rw-r--r-- | drivers/net/wireless/hostap/hostap.h | 3 | ||||
-rw-r--r-- | drivers/net/wireless/hostap/hostap_hw.c | 3 | ||||
-rw-r--r-- | drivers/net/wireless/hostap/hostap_ioctl.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/hostap/hostap_main.c | 47 | ||||
-rw-r--r-- | drivers/net/wireless/hostap/hostap_wlan.h | 2 |
5 files changed, 32 insertions, 28 deletions
diff --git a/drivers/net/wireless/hostap/hostap.h b/drivers/net/wireless/hostap/hostap.h index ef37a75d550b..951df83702f9 100644 --- a/drivers/net/wireless/hostap/hostap.h +++ b/drivers/net/wireless/hostap/hostap.h | |||
@@ -30,8 +30,7 @@ void hostap_dump_rx_header(const char *name, | |||
30 | const struct hfa384x_rx_frame *rx); | 30 | const struct hfa384x_rx_frame *rx); |
31 | void hostap_dump_tx_header(const char *name, | 31 | void hostap_dump_tx_header(const char *name, |
32 | const struct hfa384x_tx_frame *tx); | 32 | const struct hfa384x_tx_frame *tx); |
33 | int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr); | 33 | extern const struct header_ops hostap_80211_ops; |
34 | int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr); | ||
35 | int hostap_80211_get_hdrlen(u16 fc); | 34 | int hostap_80211_get_hdrlen(u16 fc); |
36 | struct net_device_stats *hostap_get_stats(struct net_device *dev); | 35 | struct net_device_stats *hostap_get_stats(struct net_device *dev); |
37 | void hostap_setup_dev(struct net_device *dev, local_info_t *local, | 36 | void hostap_setup_dev(struct net_device *dev, local_info_t *local, |
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c index 7fa7ab0a4b23..b20bb013d57e 100644 --- a/drivers/net/wireless/hostap/hostap_hw.c +++ b/drivers/net/wireless/hostap/hostap_hw.c | |||
@@ -3258,11 +3258,10 @@ while (0) | |||
3258 | INIT_LIST_HEAD(&local->bss_list); | 3258 | INIT_LIST_HEAD(&local->bss_list); |
3259 | 3259 | ||
3260 | hostap_setup_dev(dev, local, 1); | 3260 | hostap_setup_dev(dev, local, 1); |
3261 | local->saved_eth_header_parse = dev->hard_header_parse; | ||
3262 | 3261 | ||
3263 | dev->hard_start_xmit = hostap_master_start_xmit; | 3262 | dev->hard_start_xmit = hostap_master_start_xmit; |
3264 | dev->type = ARPHRD_IEEE80211; | 3263 | dev->type = ARPHRD_IEEE80211; |
3265 | dev->hard_header_parse = hostap_80211_header_parse; | 3264 | dev->header_ops = &hostap_80211_ops; |
3266 | 3265 | ||
3267 | rtnl_lock(); | 3266 | rtnl_lock(); |
3268 | ret = dev_alloc_name(dev, "wifi%d"); | 3267 | ret = dev_alloc_name(dev, "wifi%d"); |
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c index 7036ecff5ec1..40f516d42c5e 100644 --- a/drivers/net/wireless/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/hostap/hostap_ioctl.c | |||
@@ -897,11 +897,8 @@ static void hostap_monitor_set_type(local_info_t *local) | |||
897 | if (local->monitor_type == PRISM2_MONITOR_PRISM || | 897 | if (local->monitor_type == PRISM2_MONITOR_PRISM || |
898 | local->monitor_type == PRISM2_MONITOR_CAPHDR) { | 898 | local->monitor_type == PRISM2_MONITOR_CAPHDR) { |
899 | dev->type = ARPHRD_IEEE80211_PRISM; | 899 | dev->type = ARPHRD_IEEE80211_PRISM; |
900 | dev->hard_header_parse = | ||
901 | hostap_80211_prism_header_parse; | ||
902 | } else { | 900 | } else { |
903 | dev->type = ARPHRD_IEEE80211; | 901 | dev->type = ARPHRD_IEEE80211; |
904 | dev->hard_header_parse = hostap_80211_header_parse; | ||
905 | } | 902 | } |
906 | } | 903 | } |
907 | 904 | ||
@@ -1141,7 +1138,7 @@ static int hostap_monitor_mode_disable(local_info_t *local) | |||
1141 | 1138 | ||
1142 | printk(KERN_DEBUG "%s: Disabling monitor mode\n", dev->name); | 1139 | printk(KERN_DEBUG "%s: Disabling monitor mode\n", dev->name); |
1143 | dev->type = ARPHRD_ETHER; | 1140 | dev->type = ARPHRD_ETHER; |
1144 | dev->hard_header_parse = local->saved_eth_header_parse; | 1141 | |
1145 | if (local->func->cmd(dev, HFA384X_CMDCODE_TEST | | 1142 | if (local->func->cmd(dev, HFA384X_CMDCODE_TEST | |
1146 | (HFA384X_TEST_STOP << 8), | 1143 | (HFA384X_TEST_STOP << 8), |
1147 | 0, NULL, NULL)) | 1144 | 0, NULL, NULL)) |
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c index 4cb09d81b404..b75cf9205ce0 100644 --- a/drivers/net/wireless/hostap/hostap_main.c +++ b/drivers/net/wireless/hostap/hostap_main.c | |||
@@ -594,24 +594,27 @@ void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx) | |||
594 | } | 594 | } |
595 | 595 | ||
596 | 596 | ||
597 | int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr) | 597 | int hostap_80211_header_parse(const struct sk_buff *skb, unsigned char *haddr) |
598 | { | 598 | { |
599 | memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */ | 599 | struct hostap_interface *iface = netdev_priv(skb->dev); |
600 | return ETH_ALEN; | 600 | local_info_t *local = iface->local; |
601 | } | 601 | |
602 | 602 | if (local->monitor_type == PRISM2_MONITOR_PRISM || | |
603 | local->monitor_type == PRISM2_MONITOR_CAPHDR) { | ||
604 | const unsigned char *mac = skb_mac_header(skb); | ||
605 | |||
606 | if (*(u32 *)mac == LWNG_CAP_DID_BASE) { | ||
607 | memcpy(haddr, | ||
608 | mac + sizeof(struct linux_wlan_ng_prism_hdr) + 10, | ||
609 | ETH_ALEN); /* addr2 */ | ||
610 | } else { /* (*(u32 *)mac == htonl(LWNG_CAPHDR_VERSION)) */ | ||
611 | memcpy(haddr, | ||
612 | mac + sizeof(struct linux_wlan_ng_cap_hdr) + 10, | ||
613 | ETH_ALEN); /* addr2 */ | ||
614 | } | ||
615 | } else | ||
616 | memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */ | ||
603 | 617 | ||
604 | int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr) | ||
605 | { | ||
606 | const unsigned char *mac = skb_mac_header(skb); | ||
607 | |||
608 | if (*(u32 *)mac == LWNG_CAP_DID_BASE) { | ||
609 | memcpy(haddr, mac + sizeof(struct linux_wlan_ng_prism_hdr) + 10, | ||
610 | ETH_ALEN); /* addr2 */ | ||
611 | } else { /* (*(u32 *)mac == htonl(LWNG_CAPHDR_VERSION)) */ | ||
612 | memcpy(haddr, mac + sizeof(struct linux_wlan_ng_cap_hdr) + 10, | ||
613 | ETH_ALEN); /* addr2 */ | ||
614 | } | ||
615 | return ETH_ALEN; | 618 | return ETH_ALEN; |
616 | } | 619 | } |
617 | 620 | ||
@@ -843,6 +846,15 @@ static void prism2_tx_timeout(struct net_device *dev) | |||
843 | local->func->schedule_reset(local); | 846 | local->func->schedule_reset(local); |
844 | } | 847 | } |
845 | 848 | ||
849 | const struct header_ops hostap_80211_ops = { | ||
850 | .create = eth_header, | ||
851 | .rebuild = eth_rebuild_header, | ||
852 | .cache = eth_header_cache, | ||
853 | .cache_update = eth_header_cache_update, | ||
854 | |||
855 | .parse = hostap_80211_header_parse, | ||
856 | }; | ||
857 | EXPORT_SYMBOL(hostap_80211_ops); | ||
846 | 858 | ||
847 | void hostap_setup_dev(struct net_device *dev, local_info_t *local, | 859 | void hostap_setup_dev(struct net_device *dev, local_info_t *local, |
848 | int main_dev) | 860 | int main_dev) |
@@ -883,7 +895,6 @@ void hostap_setup_dev(struct net_device *dev, local_info_t *local, | |||
883 | netif_stop_queue(dev); | 895 | netif_stop_queue(dev); |
884 | } | 896 | } |
885 | 897 | ||
886 | |||
887 | static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked) | 898 | static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked) |
888 | { | 899 | { |
889 | struct net_device *dev = local->dev; | 900 | struct net_device *dev = local->dev; |
@@ -901,7 +912,7 @@ static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked) | |||
901 | 912 | ||
902 | local->apdev->hard_start_xmit = hostap_mgmt_start_xmit; | 913 | local->apdev->hard_start_xmit = hostap_mgmt_start_xmit; |
903 | local->apdev->type = ARPHRD_IEEE80211; | 914 | local->apdev->type = ARPHRD_IEEE80211; |
904 | local->apdev->hard_header_parse = hostap_80211_header_parse; | 915 | local->apdev->header_ops = &hostap_80211_ops; |
905 | 916 | ||
906 | return 0; | 917 | return 0; |
907 | } | 918 | } |
diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h index a42325c145b4..c27b2c1c06af 100644 --- a/drivers/net/wireless/hostap/hostap_wlan.h +++ b/drivers/net/wireless/hostap/hostap_wlan.h | |||
@@ -736,8 +736,6 @@ struct local_info { | |||
736 | PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1, | 736 | PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1, |
737 | PRISM2_MONITOR_CAPHDR = 2 | 737 | PRISM2_MONITOR_CAPHDR = 2 |
738 | } monitor_type; | 738 | } monitor_type; |
739 | int (*saved_eth_header_parse)(struct sk_buff *skb, | ||
740 | unsigned char *haddr); | ||
741 | int monitor_allow_fcserr; | 739 | int monitor_allow_fcserr; |
742 | 740 | ||
743 | int hostapd; /* whether user space daemon, hostapd, is used for AP | 741 | int hostapd; /* whether user space daemon, hostapd, is used for AP |