diff options
author | James Ketrenos <jketreno@linux.intel.com> | 2005-09-21 12:56:38 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-21 23:03:55 -0400 |
commit | 02cda6ae01814f58422c45259fb48136fbd7bcc1 (patch) | |
tree | 3efdd946b19928c4dbe039f68ee1cfc65fe57355 | |
parent | 9e8571affd1c54b9638b4ff9844e47aae07310f6 (diff) |
[PATCH] ieee80211: Added ieee80211_geo to provide helper functions
tree 385b391fc0d7c124cd0547fdb6183e9a0c333391
parent 97d7a47f76e72bedde7f402785559ed4c7a8e8e8
author James Ketrenos <jketreno@linux.intel.com> 1124447590 -0500
committer James Ketrenos <jketreno@linux.intel.com> 1127313735 -0500
Added ieee80211_geo to provide helper functions to drivers for
implementing supported channel maps.
Signed-off-by: James Ketrenos <jketreno@linux.intel.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
-rw-r--r-- | include/net/ieee80211.h | 46 | ||||
-rw-r--r-- | net/ieee80211/Makefile | 3 | ||||
-rw-r--r-- | net/ieee80211/ieee80211_geo.c | 141 |
3 files changed, 189 insertions, 1 deletions
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h index 72bd2b17eeb4..b3815fd810c8 100644 --- a/include/net/ieee80211.h +++ b/include/net/ieee80211.h | |||
@@ -781,6 +781,38 @@ enum ieee80211_state { | |||
781 | #define CFG_IEEE80211_COMPUTE_FCS (1<<1) | 781 | #define CFG_IEEE80211_COMPUTE_FCS (1<<1) |
782 | #define CFG_IEEE80211_RTS (1<<2) | 782 | #define CFG_IEEE80211_RTS (1<<2) |
783 | 783 | ||
784 | #define IEEE80211_24GHZ_MIN_CHANNEL 1 | ||
785 | #define IEEE80211_24GHZ_MAX_CHANNEL 14 | ||
786 | #define IEEE80211_24GHZ_CHANNELS 14 | ||
787 | |||
788 | #define IEEE80211_52GHZ_MIN_CHANNEL 36 | ||
789 | #define IEEE80211_52GHZ_MAX_CHANNEL 165 | ||
790 | #define IEEE80211_52GHZ_CHANNELS 32 | ||
791 | |||
792 | enum { | ||
793 | IEEE80211_CH_PASSIVE_ONLY = (1 << 0), | ||
794 | IEEE80211_CH_B_ONLY = (1 << 2), | ||
795 | IEEE80211_CH_NO_IBSS = (1 << 3), | ||
796 | IEEE80211_CH_UNIFORM_SPREADING = (1 << 4), | ||
797 | IEEE80211_CH_RADAR_DETECT = (1 << 5), | ||
798 | IEEE80211_CH_INVALID = (1 << 6), | ||
799 | }; | ||
800 | |||
801 | struct ieee80211_channel { | ||
802 | u16 freq; | ||
803 | u8 channel; | ||
804 | u8 flags; | ||
805 | u8 max_power; | ||
806 | }; | ||
807 | |||
808 | struct ieee80211_geo { | ||
809 | u8 name[4]; | ||
810 | u8 bg_channels; | ||
811 | u8 a_channels; | ||
812 | struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS]; | ||
813 | struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS]; | ||
814 | }; | ||
815 | |||
784 | struct ieee80211_device { | 816 | struct ieee80211_device { |
785 | struct net_device *dev; | 817 | struct net_device *dev; |
786 | struct ieee80211_security sec; | 818 | struct ieee80211_security sec; |
@@ -789,6 +821,8 @@ struct ieee80211_device { | |||
789 | struct net_device_stats stats; | 821 | struct net_device_stats stats; |
790 | struct ieee80211_stats ieee_stats; | 822 | struct ieee80211_stats ieee_stats; |
791 | 823 | ||
824 | struct ieee80211_geo geo; | ||
825 | |||
792 | /* Probe / Beacon management */ | 826 | /* Probe / Beacon management */ |
793 | struct list_head network_free_list; | 827 | struct list_head network_free_list; |
794 | struct list_head network_list; | 828 | struct list_head network_list; |
@@ -1005,6 +1039,18 @@ extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, | |||
1005 | struct ieee80211_hdr_4addr *header, | 1039 | struct ieee80211_hdr_4addr *header, |
1006 | struct ieee80211_rx_stats *stats); | 1040 | struct ieee80211_rx_stats *stats); |
1007 | 1041 | ||
1042 | /* ieee80211_geo.c */ | ||
1043 | extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device | ||
1044 | *ieee); | ||
1045 | extern int ieee80211_set_geo(struct ieee80211_device *ieee, | ||
1046 | const struct ieee80211_geo *geo); | ||
1047 | |||
1048 | extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee, | ||
1049 | u8 channel); | ||
1050 | extern int ieee80211_channel_to_index(struct ieee80211_device *ieee, | ||
1051 | u8 channel); | ||
1052 | extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq); | ||
1053 | |||
1008 | /* ieee80211_wx.c */ | 1054 | /* ieee80211_wx.c */ |
1009 | extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, | 1055 | extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, |
1010 | struct iw_request_info *info, | 1056 | struct iw_request_info *info, |
diff --git a/net/ieee80211/Makefile b/net/ieee80211/Makefile index a6ccac5baea8..f988417121da 100644 --- a/net/ieee80211/Makefile +++ b/net/ieee80211/Makefile | |||
@@ -7,5 +7,6 @@ ieee80211-objs := \ | |||
7 | ieee80211_module.o \ | 7 | ieee80211_module.o \ |
8 | ieee80211_tx.o \ | 8 | ieee80211_tx.o \ |
9 | ieee80211_rx.o \ | 9 | ieee80211_rx.o \ |
10 | ieee80211_wx.o | 10 | ieee80211_wx.o \ |
11 | ieee80211_geo.o | ||
11 | 12 | ||
diff --git a/net/ieee80211/ieee80211_geo.c b/net/ieee80211/ieee80211_geo.c new file mode 100644 index 000000000000..c4b54ef8f6d5 --- /dev/null +++ b/net/ieee80211/ieee80211_geo.c | |||
@@ -0,0 +1,141 @@ | |||
1 | /****************************************************************************** | ||
2 | |||
3 | Copyright(c) 2005 Intel Corporation. All rights reserved. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify it | ||
6 | under the terms of version 2 of the GNU General Public License as | ||
7 | published by the Free Software Foundation. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along with | ||
15 | this program; if not, write to the Free Software Foundation, Inc., 59 | ||
16 | Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | |||
18 | The full GNU General Public License is included in this distribution in the | ||
19 | file called LICENSE. | ||
20 | |||
21 | Contact Information: | ||
22 | James P. Ketrenos <ipw2100-admin@linux.intel.com> | ||
23 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
24 | |||
25 | ******************************************************************************/ | ||
26 | #include <linux/compiler.h> | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/errno.h> | ||
29 | #include <linux/if_arp.h> | ||
30 | #include <linux/in6.h> | ||
31 | #include <linux/in.h> | ||
32 | #include <linux/ip.h> | ||
33 | #include <linux/kernel.h> | ||
34 | #include <linux/module.h> | ||
35 | #include <linux/netdevice.h> | ||
36 | #include <linux/proc_fs.h> | ||
37 | #include <linux/skbuff.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/tcp.h> | ||
40 | #include <linux/types.h> | ||
41 | #include <linux/version.h> | ||
42 | #include <linux/wireless.h> | ||
43 | #include <linux/etherdevice.h> | ||
44 | #include <asm/uaccess.h> | ||
45 | |||
46 | #include <net/ieee80211.h> | ||
47 | |||
48 | int ieee80211_is_valid_channel(struct ieee80211_device *ieee, u8 channel) | ||
49 | { | ||
50 | int i; | ||
51 | |||
52 | /* Driver needs to initialize the geography map before using | ||
53 | * these helper functions */ | ||
54 | BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0); | ||
55 | |||
56 | if (ieee->freq_band & IEEE80211_24GHZ_BAND) | ||
57 | for (i = 0; i < ieee->geo.bg_channels; i++) | ||
58 | /* NOTE: If G mode is currently supported but | ||
59 | * this is a B only channel, we don't see it | ||
60 | * as valid. */ | ||
61 | if ((ieee->geo.bg[i].channel == channel) && | ||
62 | (!(ieee->mode & IEEE_G) || | ||
63 | !(ieee->geo.bg[i].flags & IEEE80211_CH_B_ONLY))) | ||
64 | return IEEE80211_24GHZ_BAND; | ||
65 | |||
66 | if (ieee->freq_band & IEEE80211_52GHZ_BAND) | ||
67 | for (i = 0; i < ieee->geo.a_channels; i++) | ||
68 | if (ieee->geo.a[i].channel == channel) | ||
69 | return IEEE80211_52GHZ_BAND; | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | int ieee80211_channel_to_index(struct ieee80211_device *ieee, u8 channel) | ||
75 | { | ||
76 | int i; | ||
77 | |||
78 | /* Driver needs to initialize the geography map before using | ||
79 | * these helper functions */ | ||
80 | BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0); | ||
81 | |||
82 | if (ieee->freq_band & IEEE80211_24GHZ_BAND) | ||
83 | for (i = 0; i < ieee->geo.bg_channels; i++) | ||
84 | if (ieee->geo.bg[i].channel == channel) | ||
85 | return i; | ||
86 | |||
87 | if (ieee->freq_band & IEEE80211_52GHZ_BAND) | ||
88 | for (i = 0; i < ieee->geo.a_channels; i++) | ||
89 | if (ieee->geo.a[i].channel == channel) | ||
90 | return i; | ||
91 | |||
92 | return -1; | ||
93 | } | ||
94 | |||
95 | u8 ieee80211_freq_to_channel(struct ieee80211_device * ieee, u32 freq) | ||
96 | { | ||
97 | int i; | ||
98 | |||
99 | /* Driver needs to initialize the geography map before using | ||
100 | * these helper functions */ | ||
101 | BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0); | ||
102 | |||
103 | freq /= 100000; | ||
104 | |||
105 | if (ieee->freq_band & IEEE80211_24GHZ_BAND) | ||
106 | for (i = 0; i < ieee->geo.bg_channels; i++) | ||
107 | if (ieee->geo.bg[i].freq == freq) | ||
108 | return ieee->geo.bg[i].channel; | ||
109 | |||
110 | if (ieee->freq_band & IEEE80211_52GHZ_BAND) | ||
111 | for (i = 0; i < ieee->geo.a_channels; i++) | ||
112 | if (ieee->geo.a[i].freq == freq) | ||
113 | return ieee->geo.a[i].channel; | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | int ieee80211_set_geo(struct ieee80211_device *ieee, | ||
119 | const struct ieee80211_geo *geo) | ||
120 | { | ||
121 | memcpy(ieee->geo.name, geo->name, 3); | ||
122 | ieee->geo.name[3] = '\0'; | ||
123 | ieee->geo.bg_channels = geo->bg_channels; | ||
124 | ieee->geo.a_channels = geo->a_channels; | ||
125 | memcpy(ieee->geo.bg, geo->bg, geo->bg_channels * | ||
126 | sizeof(struct ieee80211_channel)); | ||
127 | memcpy(ieee->geo.a, geo->a, ieee->geo.a_channels * | ||
128 | sizeof(struct ieee80211_channel)); | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device *ieee) | ||
133 | { | ||
134 | return &ieee->geo; | ||
135 | } | ||
136 | |||
137 | EXPORT_SYMBOL(ieee80211_is_valid_channel); | ||
138 | EXPORT_SYMBOL(ieee80211_freq_to_channel); | ||
139 | EXPORT_SYMBOL(ieee80211_channel_to_index); | ||
140 | EXPORT_SYMBOL(ieee80211_set_geo); | ||
141 | EXPORT_SYMBOL(ieee80211_get_geo); | ||