aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ieee80211.h
diff options
context:
space:
mode:
authorDavid Kilroy <kilroyd@googlemail.com>2008-12-23 09:03:38 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:58:46 -0500
commit9ee677c2276bfcbcf68042ec2718a504af0c5fd7 (patch)
tree0b5528241690e143c60832d319ddbb2ad1c5d7f1 /include/linux/ieee80211.h
parenteaee7cc2c180c291084a1c1f49cd2bf13002b3e1 (diff)
wireless: Add channel/frequency conversions to ieee80211.h
Added mappings for FHSS, DSSS and OFDM channels - with macros to point HR DSSS and ERP to the DSSS mappings. Currently just static inline functions. Use the new functions in the older fullmac drivers. This eliminates a number of const static buffers and removes a couple of range checks that are now redundant. Signed-off-by: David Kilroy <kilroyd@googlemail.com> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Richard Farina <sidhayn@gmail.com> Acked-by: Jeroen Vreeken <pe1rxq@amsat.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include/linux/ieee80211.h')
-rw-r--r--include/linux/ieee80211.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index c4e6ca1a6306..cade2556af0e 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -1185,4 +1185,120 @@ static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1185 return hdr->addr1; 1185 return hdr->addr1;
1186} 1186}
1187 1187
1188/**
1189 * ieee80211_fhss_chan_to_freq - get channel frequency
1190 * @channel: the FHSS channel
1191 *
1192 * Convert IEEE802.11 FHSS channel to frequency (MHz)
1193 * Ref IEEE 802.11-2007 section 14.6
1194 */
1195static inline int ieee80211_fhss_chan_to_freq(int channel)
1196{
1197 if ((channel > 1) && (channel < 96))
1198 return channel + 2400;
1199 else
1200 return -1;
1201}
1202
1203/**
1204 * ieee80211_freq_to_fhss_chan - get channel
1205 * @freq: the channels frequency
1206 *
1207 * Convert frequency (MHz) to IEEE802.11 FHSS channel
1208 * Ref IEEE 802.11-2007 section 14.6
1209 */
1210static inline int ieee80211_freq_to_fhss_chan(int freq)
1211{
1212 if ((freq > 2401) && (freq < 2496))
1213 return freq - 2400;
1214 else
1215 return -1;
1216}
1217
1218/**
1219 * ieee80211_dsss_chan_to_freq - get channel center frequency
1220 * @channel: the DSSS channel
1221 *
1222 * Convert IEEE802.11 DSSS channel to the center frequency (MHz).
1223 * Ref IEEE 802.11-2007 section 15.6
1224 */
1225static inline int ieee80211_dsss_chan_to_freq(int channel)
1226{
1227 if ((channel > 0) && (channel < 14))
1228 return 2407 + (channel * 5);
1229 else if (channel == 14)
1230 return 2484;
1231 else
1232 return -1;
1233}
1234
1235/**
1236 * ieee80211_freq_to_dsss_chan - get channel
1237 * @freq: the frequency
1238 *
1239 * Convert frequency (MHz) to IEEE802.11 DSSS channel
1240 * Ref IEEE 802.11-2007 section 15.6
1241 *
1242 * This routine selects the channel with the closest center frequency.
1243 */
1244static inline int ieee80211_freq_to_dsss_chan(int freq)
1245{
1246 if ((freq >= 2410) && (freq < 2475))
1247 return (freq - 2405) / 5;
1248 else if ((freq >= 2482) && (freq < 2487))
1249 return 14;
1250 else
1251 return -1;
1252}
1253
1254/* Convert IEEE802.11 HR DSSS channel to frequency (MHz) and back
1255 * Ref IEEE 802.11-2007 section 18.4.6.2
1256 *
1257 * The channels and frequencies are the same as those defined for DSSS
1258 */
1259#define ieee80211_hr_chan_to_freq(chan) ieee80211_dsss_chan_to_freq(chan)
1260#define ieee80211_freq_to_hr_chan(freq) ieee80211_freq_to_dsss_chan(freq)
1261
1262/* Convert IEEE802.11 ERP channel to frequency (MHz) and back
1263 * Ref IEEE 802.11-2007 section 19.4.2
1264 */
1265#define ieee80211_erp_chan_to_freq(chan) ieee80211_hr_chan_to_freq(chan)
1266#define ieee80211_freq_to_erp_chan(freq) ieee80211_freq_to_hr_chan(freq)
1267
1268/**
1269 * ieee80211_ofdm_chan_to_freq - get channel center frequency
1270 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
1271 * @channel: the OFDM channel
1272 *
1273 * Convert IEEE802.11 OFDM channel to center frequency (MHz)
1274 * Ref IEEE 802.11-2007 section 17.3.8.3.2
1275 */
1276static inline int ieee80211_ofdm_chan_to_freq(int s_freq, int channel)
1277{
1278 if ((channel > 0) && (channel <= 200) &&
1279 (s_freq >= 4000))
1280 return s_freq + (channel * 5);
1281 else
1282 return -1;
1283}
1284
1285/**
1286 * ieee80211_freq_to_ofdm_channel - get channel
1287 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
1288 * @freq: the frequency
1289 *
1290 * Convert frequency (MHz) to IEEE802.11 OFDM channel
1291 * Ref IEEE 802.11-2007 section 17.3.8.3.2
1292 *
1293 * This routine selects the channel with the closest center frequency.
1294 */
1295static inline int ieee80211_freq_to_ofdm_chan(int s_freq, int freq)
1296{
1297 if ((freq > (s_freq + 2)) && (freq <= (s_freq + 1202)) &&
1298 (s_freq >= 4000))
1299 return (freq + 2 - s_freq) / 5;
1300 else
1301 return -1;
1302}
1303
1188#endif /* LINUX_IEEE80211_H */ 1304#endif /* LINUX_IEEE80211_H */