aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/zd1211rw
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2008-09-10 02:19:49 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-09-15 16:48:19 -0400
commite83a1070a1167eac1bf8844b9f08df5e9ea1b5bc (patch)
treeeedd67417236e38bc63e09a735362938459fd1f7 /drivers/net/wireless/zd1211rw
parentb2e1b30290539b344cbaff0d9da38012e03aa347 (diff)
zd1211rw: make use of new regulatory_hint()
This cleans up zd1211rw's own regulatory work, and makes use of the new cfg80211 regulatory_hint(). Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/zd1211rw')
-rw-r--r--drivers/net/wireless/zd1211rw/Makefile2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.c100
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.h95
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c40
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h65
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf.c2
7 files changed, 102 insertions, 203 deletions
diff --git a/drivers/net/wireless/zd1211rw/Makefile b/drivers/net/wireless/zd1211rw/Makefile
index cc36126cee88..1907eafb9b16 100644
--- a/drivers/net/wireless/zd1211rw/Makefile
+++ b/drivers/net/wireless/zd1211rw/Makefile
@@ -1,6 +1,6 @@
1obj-$(CONFIG_ZD1211RW) += zd1211rw.o 1obj-$(CONFIG_ZD1211RW) += zd1211rw.o
2 2
3zd1211rw-objs := zd_chip.o zd_ieee80211.o zd_mac.o \ 3zd1211rw-objs := zd_chip.o zd_mac.o \
4 zd_rf_al2230.o zd_rf_rf2959.o \ 4 zd_rf_al2230.o zd_rf_rf2959.o \
5 zd_rf_al7230b.o zd_rf_uw2453.o \ 5 zd_rf_al7230b.o zd_rf_uw2453.o \
6 zd_rf.o zd_usb.o 6 zd_rf.o zd_usb.o
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 0acb5c345734..e0ac58b8ff1f 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -28,7 +28,6 @@
28 28
29#include "zd_def.h" 29#include "zd_def.h"
30#include "zd_chip.h" 30#include "zd_chip.h"
31#include "zd_ieee80211.h"
32#include "zd_mac.h" 31#include "zd_mac.h"
33#include "zd_rf.h" 32#include "zd_rf.h"
34 33
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.c b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
deleted file mode 100644
index d8dc41ec0e5d..000000000000
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.c
+++ /dev/null
@@ -1,100 +0,0 @@
1/* ZD1211 USB-WLAN driver for Linux
2 *
3 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
4 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * In the long term, we'll probably find a better way of handling regulatory
23 * requirements outside of the driver.
24 */
25
26#include <linux/kernel.h>
27#include <net/mac80211.h>
28
29#include "zd_ieee80211.h"
30#include "zd_mac.h"
31
32struct channel_range {
33 u8 regdomain;
34 u8 start;
35 u8 end; /* exclusive (channel must be less than end) */
36};
37
38static const struct channel_range channel_ranges[] = {
39 { ZD_REGDOMAIN_FCC, 1, 12 },
40 { ZD_REGDOMAIN_IC, 1, 12 },
41 { ZD_REGDOMAIN_ETSI, 1, 14 },
42 { ZD_REGDOMAIN_JAPAN, 1, 14 },
43 { ZD_REGDOMAIN_SPAIN, 1, 14 },
44 { ZD_REGDOMAIN_FRANCE, 1, 14 },
45
46 /* Japan originally only had channel 14 available (see CHNL_ID 0x40 in
47 * 802.11). However, in 2001 the range was extended to include channels
48 * 1-13. The ZyDAS devices still use the old region code but are
49 * designed to allow the extra channel access in Japan. */
50 { ZD_REGDOMAIN_JAPAN_ADD, 1, 15 },
51};
52
53static const struct channel_range *zd_channel_range(u8 regdomain)
54{
55 int i;
56 for (i = 0; i < ARRAY_SIZE(channel_ranges); i++) {
57 const struct channel_range *range = &channel_ranges[i];
58 if (range->regdomain == regdomain)
59 return range;
60 }
61 return NULL;
62}
63
64#define CHAN_TO_IDX(chan) ((chan) - 1)
65
66static void unmask_bg_channels(struct ieee80211_hw *hw,
67 const struct channel_range *range,
68 struct ieee80211_supported_band *sband)
69{
70 u8 channel;
71
72 for (channel = range->start; channel < range->end; channel++) {
73 struct ieee80211_channel *chan =
74 &sband->channels[CHAN_TO_IDX(channel)];
75 chan->flags = 0;
76 }
77}
78
79void zd_geo_init(struct ieee80211_hw *hw, u8 regdomain)
80{
81 struct zd_mac *mac = zd_hw_mac(hw);
82 const struct channel_range *range;
83
84 dev_dbg(zd_mac_dev(mac), "regdomain %#02x\n", regdomain);
85
86 range = zd_channel_range(regdomain);
87 if (!range) {
88 /* The vendor driver overrides the regulatory domain and
89 * allowed channel registers and unconditionally restricts
90 * available channels to 1-11 everywhere. Match their
91 * questionable behaviour only for regdomains which we don't
92 * recognise. */
93 dev_warn(zd_mac_dev(mac), "Unrecognised regulatory domain: "
94 "%#02x. Defaulting to FCC.\n", regdomain);
95 range = zd_channel_range(ZD_REGDOMAIN_FCC);
96 }
97
98 unmask_bg_channels(hw, range, &mac->band);
99}
100
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.h b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
deleted file mode 100644
index 26b79f197587..000000000000
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.h
+++ /dev/null
@@ -1,95 +0,0 @@
1/* ZD1211 USB-WLAN driver for Linux
2 *
3 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
4 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef _ZD_IEEE80211_H
22#define _ZD_IEEE80211_H
23
24#include <net/mac80211.h>
25
26/* Additional definitions from the standards.
27 */
28
29#define ZD_REGDOMAIN_FCC 0x10
30#define ZD_REGDOMAIN_IC 0x20
31#define ZD_REGDOMAIN_ETSI 0x30
32#define ZD_REGDOMAIN_SPAIN 0x31
33#define ZD_REGDOMAIN_FRANCE 0x32
34#define ZD_REGDOMAIN_JAPAN_ADD 0x40
35#define ZD_REGDOMAIN_JAPAN 0x41
36
37enum {
38 MIN_CHANNEL24 = 1,
39 MAX_CHANNEL24 = 14,
40};
41
42void zd_geo_init(struct ieee80211_hw *hw, u8 regdomain);
43
44#define ZD_PLCP_SERVICE_LENGTH_EXTENSION 0x80
45
46struct ofdm_plcp_header {
47 u8 prefix[3];
48 __le16 service;
49} __attribute__((packed));
50
51static inline u8 zd_ofdm_plcp_header_rate(const struct ofdm_plcp_header *header)
52{
53 return header->prefix[0] & 0xf;
54}
55
56/* The following defines give the encoding of the 4-bit rate field in the
57 * OFDM (802.11a/802.11g) PLCP header. Notify that these values are used to
58 * define the zd-rate values for OFDM.
59 *
60 * See the struct zd_ctrlset definition in zd_mac.h.
61 */
62#define ZD_OFDM_PLCP_RATE_6M 0xb
63#define ZD_OFDM_PLCP_RATE_9M 0xf
64#define ZD_OFDM_PLCP_RATE_12M 0xa
65#define ZD_OFDM_PLCP_RATE_18M 0xe
66#define ZD_OFDM_PLCP_RATE_24M 0x9
67#define ZD_OFDM_PLCP_RATE_36M 0xd
68#define ZD_OFDM_PLCP_RATE_48M 0x8
69#define ZD_OFDM_PLCP_RATE_54M 0xc
70
71struct cck_plcp_header {
72 u8 signal;
73 u8 service;
74 __le16 length;
75 __le16 crc16;
76} __attribute__((packed));
77
78static inline u8 zd_cck_plcp_header_signal(const struct cck_plcp_header *header)
79{
80 return header->signal;
81}
82
83/* These defines give the encodings of the signal field in the 802.11b PLCP
84 * header. The signal field gives the bit rate of the following packet. Even
85 * if technically wrong we use CCK here also for the 1 MBit/s and 2 MBit/s
86 * rate to stay consistent with Zydas and our use of the term.
87 *
88 * Notify that these values are *not* used in the zd-rates.
89 */
90#define ZD_CCK_PLCP_SIGNAL_1M 0x0a
91#define ZD_CCK_PLCP_SIGNAL_2M 0x14
92#define ZD_CCK_PLCP_SIGNAL_5M5 0x37
93#define ZD_CCK_PLCP_SIGNAL_11M 0x6e
94
95#endif /* _ZD_IEEE80211_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index e019102b2285..3005dd1fde42 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -3,7 +3,7 @@
3 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de> 3 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
4 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org> 4 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
5 * Copyright (C) 2006-2007 Michael Wu <flamingice@sourmilk.net> 5 * Copyright (C) 2006-2007 Michael Wu <flamingice@sourmilk.net>
6 * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu> 6 * Copyright (C) 2007-2008 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -29,9 +29,23 @@
29#include "zd_def.h" 29#include "zd_def.h"
30#include "zd_chip.h" 30#include "zd_chip.h"
31#include "zd_mac.h" 31#include "zd_mac.h"
32#include "zd_ieee80211.h"
33#include "zd_rf.h" 32#include "zd_rf.h"
34 33
34struct zd_reg_alpha2_map {
35 u32 reg;
36 char alpha2[2];
37};
38
39static struct zd_reg_alpha2_map reg_alpha2_map[] = {
40 { ZD_REGDOMAIN_FCC, "US" },
41 { ZD_REGDOMAIN_IC, "CA" },
42 { ZD_REGDOMAIN_ETSI, "DE" }, /* Generic ETSI, use most restrictive */
43 { ZD_REGDOMAIN_JAPAN, "JP" },
44 { ZD_REGDOMAIN_JAPAN_ADD, "JP" },
45 { ZD_REGDOMAIN_SPAIN, "ES" },
46 { ZD_REGDOMAIN_FRANCE, "FR" },
47};
48
35/* This table contains the hardware specific values for the modulation rates. */ 49/* This table contains the hardware specific values for the modulation rates. */
36static const struct ieee80211_rate zd_rates[] = { 50static const struct ieee80211_rate zd_rates[] = {
37 { .bitrate = 10, 51 { .bitrate = 10,
@@ -95,6 +109,21 @@ static void housekeeping_init(struct zd_mac *mac);
95static void housekeeping_enable(struct zd_mac *mac); 109static void housekeeping_enable(struct zd_mac *mac);
96static void housekeeping_disable(struct zd_mac *mac); 110static void housekeeping_disable(struct zd_mac *mac);
97 111
112static int zd_reg2alpha2(u8 regdomain, char *alpha2)
113{
114 unsigned int i;
115 struct zd_reg_alpha2_map *reg_map;
116 for (i = 0; i < ARRAY_SIZE(reg_alpha2_map); i++) {
117 reg_map = &reg_alpha2_map[i];
118 if (regdomain == reg_map->reg) {
119 alpha2[0] = reg_map->alpha2[0];
120 alpha2[1] = reg_map->alpha2[1];
121 return 0;
122 }
123 }
124 return 1;
125}
126
98int zd_mac_preinit_hw(struct ieee80211_hw *hw) 127int zd_mac_preinit_hw(struct ieee80211_hw *hw)
99{ 128{
100 int r; 129 int r;
@@ -115,6 +144,7 @@ int zd_mac_init_hw(struct ieee80211_hw *hw)
115 int r; 144 int r;
116 struct zd_mac *mac = zd_hw_mac(hw); 145 struct zd_mac *mac = zd_hw_mac(hw);
117 struct zd_chip *chip = &mac->chip; 146 struct zd_chip *chip = &mac->chip;
147 char alpha2[2];
118 u8 default_regdomain; 148 u8 default_regdomain;
119 149
120 r = zd_chip_enable_int(chip); 150 r = zd_chip_enable_int(chip);
@@ -139,7 +169,9 @@ int zd_mac_init_hw(struct ieee80211_hw *hw)
139 if (r) 169 if (r)
140 goto disable_int; 170 goto disable_int;
141 171
142 zd_geo_init(hw, mac->regdomain); 172 r = zd_reg2alpha2(mac->regdomain, alpha2);
173 if (!r)
174 regulatory_hint(hw->wiphy, alpha2, NULL);
143 175
144 r = 0; 176 r = 0;
145disable_int: 177disable_int:
@@ -753,7 +785,7 @@ static int zd_op_config_interface(struct ieee80211_hw *hw,
753 return 0; 785 return 0;
754} 786}
755 787
756void zd_process_intr(struct work_struct *work) 788static void zd_process_intr(struct work_struct *work)
757{ 789{
758 u16 int_status; 790 u16 int_status;
759 struct zd_mac *mac = container_of(work, struct zd_mac, process_intr); 791 struct zd_mac *mac = container_of(work, struct zd_mac, process_intr);
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 18c1d56d3dd7..4c05d3ee4c37 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -25,7 +25,6 @@
25#include <net/mac80211.h> 25#include <net/mac80211.h>
26 26
27#include "zd_chip.h" 27#include "zd_chip.h"
28#include "zd_ieee80211.h"
29 28
30struct zd_ctrlset { 29struct zd_ctrlset {
31 u8 modulation; 30 u8 modulation;
@@ -187,6 +186,70 @@ struct zd_mac {
187 unsigned int pass_ctrl:1; 186 unsigned int pass_ctrl:1;
188}; 187};
189 188
189#define ZD_REGDOMAIN_FCC 0x10
190#define ZD_REGDOMAIN_IC 0x20
191#define ZD_REGDOMAIN_ETSI 0x30
192#define ZD_REGDOMAIN_SPAIN 0x31
193#define ZD_REGDOMAIN_FRANCE 0x32
194#define ZD_REGDOMAIN_JAPAN_ADD 0x40
195#define ZD_REGDOMAIN_JAPAN 0x41
196
197enum {
198 MIN_CHANNEL24 = 1,
199 MAX_CHANNEL24 = 14,
200};
201
202#define ZD_PLCP_SERVICE_LENGTH_EXTENSION 0x80
203
204struct ofdm_plcp_header {
205 u8 prefix[3];
206 __le16 service;
207} __attribute__((packed));
208
209static inline u8 zd_ofdm_plcp_header_rate(const struct ofdm_plcp_header *header)
210{
211 return header->prefix[0] & 0xf;
212}
213
214/* The following defines give the encoding of the 4-bit rate field in the
215 * OFDM (802.11a/802.11g) PLCP header. Notify that these values are used to
216 * define the zd-rate values for OFDM.
217 *
218 * See the struct zd_ctrlset definition in zd_mac.h.
219 */
220#define ZD_OFDM_PLCP_RATE_6M 0xb
221#define ZD_OFDM_PLCP_RATE_9M 0xf
222#define ZD_OFDM_PLCP_RATE_12M 0xa
223#define ZD_OFDM_PLCP_RATE_18M 0xe
224#define ZD_OFDM_PLCP_RATE_24M 0x9
225#define ZD_OFDM_PLCP_RATE_36M 0xd
226#define ZD_OFDM_PLCP_RATE_48M 0x8
227#define ZD_OFDM_PLCP_RATE_54M 0xc
228
229struct cck_plcp_header {
230 u8 signal;
231 u8 service;
232 __le16 length;
233 __le16 crc16;
234} __attribute__((packed));
235
236static inline u8 zd_cck_plcp_header_signal(const struct cck_plcp_header *header)
237{
238 return header->signal;
239}
240
241/* These defines give the encodings of the signal field in the 802.11b PLCP
242 * header. The signal field gives the bit rate of the following packet. Even
243 * if technically wrong we use CCK here also for the 1 MBit/s and 2 MBit/s
244 * rate to stay consistent with Zydas and our use of the term.
245 *
246 * Notify that these values are *not* used in the zd-rates.
247 */
248#define ZD_CCK_PLCP_SIGNAL_1M 0x0a
249#define ZD_CCK_PLCP_SIGNAL_2M 0x14
250#define ZD_CCK_PLCP_SIGNAL_5M5 0x37
251#define ZD_CCK_PLCP_SIGNAL_11M 0x6e
252
190static inline struct zd_mac *zd_hw_mac(struct ieee80211_hw *hw) 253static inline struct zd_mac *zd_hw_mac(struct ieee80211_hw *hw)
191{ 254{
192 return hw->priv; 255 return hw->priv;
diff --git a/drivers/net/wireless/zd1211rw/zd_rf.c b/drivers/net/wireless/zd1211rw/zd_rf.c
index ec4129312813..7207bfd2e6cd 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf.c
+++ b/drivers/net/wireless/zd1211rw/zd_rf.c
@@ -23,7 +23,7 @@
23 23
24#include "zd_def.h" 24#include "zd_def.h"
25#include "zd_rf.h" 25#include "zd_rf.h"
26#include "zd_ieee80211.h" 26#include "zd_mac.h"
27#include "zd_chip.h" 27#include "zd_chip.h"
28 28
29static const char * const rfs[] = { 29static const char * const rfs[] = {