summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/zd1211rw
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-01-24 18:38:38 (GMT)
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 20:19:32 (GMT)
commit8318d78a44d49ac1edf2bdec7299de3617c4232e (patch)
treed434634418edd7399737801615d247be06616fdd /drivers/net/wireless/zd1211rw
parent10b6b80145cc93887dd8aab99bfffa375e9add31 (diff)
downloadlinux-fsl-qoriq-8318d78a44d49ac1edf2bdec7299de3617c4232e.tar.xz
cfg80211 API for channels/bitrates, mac80211 and driver conversion
This patch creates new cfg80211 wiphy API for channel and bitrate registration and converts mac80211 and drivers to the new API. The old mac80211 API is completely ripped out. All drivers (except ath5k) are updated to the new API, in many cases I expect that optimisations can be done. Along with the regulatory code I've also ripped out the IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED flag, I believe it to be unnecessary if the hardware simply gives us whatever channels it wants to support and we then enable/disable them as required, which is pretty much required for travelling. Additionally, the patch adds proper "basic" rate handling for STA mode interface, AP mode interface will have to have new API added to allow userspace to set the basic rate set, currently it'll be empty... However, the basic rate handling will need to be moved to the BSS conf stuff. I do expect there to be bugs in this, especially wrt. transmit power handling where I'm basically clueless about how it should work. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/zd1211rw')
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c15
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.c11
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c170
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h2
4 files changed, 85 insertions, 113 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 99e5b03..e3fba6f 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -986,7 +986,7 @@ static int print_fw_version(struct zd_chip *chip)
return 0;
}
-static int set_mandatory_rates(struct zd_chip *chip, int mode)
+static int set_mandatory_rates(struct zd_chip *chip, int gmode)
{
u32 rates;
ZD_ASSERT(mutex_is_locked(&chip->mutex));
@@ -994,17 +994,12 @@ static int set_mandatory_rates(struct zd_chip *chip, int mode)
* that the device is supporting. Until further notice we should try
* to support 802.11g also for full speed USB.
*/
- switch (mode) {
- case MODE_IEEE80211B:
+ if (!gmode)
rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M;
- break;
- case MODE_IEEE80211G:
+ else
rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M|
CR_RATE_6M|CR_RATE_12M|CR_RATE_24M;
- break;
- default:
- return -EINVAL;
- }
+
return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL);
}
@@ -1108,7 +1103,7 @@ int zd_chip_init_hw(struct zd_chip *chip)
* It might be discussed, whether we should suppport pure b mode for
* full speed USB.
*/
- r = set_mandatory_rates(chip, MODE_IEEE80211G);
+ r = set_mandatory_rates(chip, 1);
if (r)
goto out;
/* Disabling interrupts is certainly a smart thing here.
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.c b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
index 7c277ec..d8dc41e 100644
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.c
+++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
@@ -65,16 +65,14 @@ static const struct channel_range *zd_channel_range(u8 regdomain)
static void unmask_bg_channels(struct ieee80211_hw *hw,
const struct channel_range *range,
- struct ieee80211_hw_mode *mode)
+ struct ieee80211_supported_band *sband)
{
u8 channel;
for (channel = range->start; channel < range->end; channel++) {
struct ieee80211_channel *chan =
- &mode->channels[CHAN_TO_IDX(channel)];
- chan->flag |= IEEE80211_CHAN_W_SCAN |
- IEEE80211_CHAN_W_ACTIVE_SCAN |
- IEEE80211_CHAN_W_IBSS;
+ &sband->channels[CHAN_TO_IDX(channel)];
+ chan->flags = 0;
}
}
@@ -97,7 +95,6 @@ void zd_geo_init(struct ieee80211_hw *hw, u8 regdomain)
range = zd_channel_range(ZD_REGDOMAIN_FCC);
}
- unmask_bg_channels(hw, range, &mac->modes[0]);
- unmask_bg_channels(hw, range, &mac->modes[1]);
+ unmask_bg_channels(hw, range, &mac->band);
}
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 76ef2d8..21b6534 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -34,76 +34,61 @@
/* This table contains the hardware specific values for the modulation rates. */
static const struct ieee80211_rate zd_rates[] = {
- { .rate = 10,
- .val = ZD_CCK_RATE_1M,
- .flags = IEEE80211_RATE_CCK },
- { .rate = 20,
- .val = ZD_CCK_RATE_2M,
- .val2 = ZD_CCK_RATE_2M | ZD_CCK_PREA_SHORT,
- .flags = IEEE80211_RATE_CCK_2 },
- { .rate = 55,
- .val = ZD_CCK_RATE_5_5M,
- .val2 = ZD_CCK_RATE_5_5M | ZD_CCK_PREA_SHORT,
- .flags = IEEE80211_RATE_CCK_2 },
- { .rate = 110,
- .val = ZD_CCK_RATE_11M,
- .val2 = ZD_CCK_RATE_11M | ZD_CCK_PREA_SHORT,
- .flags = IEEE80211_RATE_CCK_2 },
- { .rate = 60,
- .val = ZD_OFDM_RATE_6M,
- .flags = IEEE80211_RATE_OFDM },
- { .rate = 90,
- .val = ZD_OFDM_RATE_9M,
- .flags = IEEE80211_RATE_OFDM },
- { .rate = 120,
- .val = ZD_OFDM_RATE_12M,
- .flags = IEEE80211_RATE_OFDM },
- { .rate = 180,
- .val = ZD_OFDM_RATE_18M,
- .flags = IEEE80211_RATE_OFDM },
- { .rate = 240,
- .val = ZD_OFDM_RATE_24M,
- .flags = IEEE80211_RATE_OFDM },
- { .rate = 360,
- .val = ZD_OFDM_RATE_36M,
- .flags = IEEE80211_RATE_OFDM },
- { .rate = 480,
- .val = ZD_OFDM_RATE_48M,
- .flags = IEEE80211_RATE_OFDM },
- { .rate = 540,
- .val = ZD_OFDM_RATE_54M,
- .flags = IEEE80211_RATE_OFDM },
+ { .bitrate = 10,
+ .hw_value = ZD_CCK_RATE_1M, },
+ { .bitrate = 20,
+ .hw_value = ZD_CCK_RATE_2M,
+ .hw_value_short = ZD_CCK_RATE_2M | ZD_CCK_PREA_SHORT,
+ .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 55,
+ .hw_value = ZD_CCK_RATE_5_5M,
+ .hw_value_short = ZD_CCK_RATE_5_5M | ZD_CCK_PREA_SHORT,
+ .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 110,
+ .hw_value = ZD_CCK_RATE_11M,
+ .hw_value_short = ZD_CCK_RATE_11M | ZD_CCK_PREA_SHORT,
+ .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 60,
+ .hw_value = ZD_OFDM_RATE_6M,
+ .flags = 0 },
+ { .bitrate = 90,
+ .hw_value = ZD_OFDM_RATE_9M,
+ .flags = 0 },
+ { .bitrate = 120,
+ .hw_value = ZD_OFDM_RATE_12M,
+ .flags = 0 },
+ { .bitrate = 180,
+ .hw_value = ZD_OFDM_RATE_18M,
+ .flags = 0 },
+ { .bitrate = 240,
+ .hw_value = ZD_OFDM_RATE_24M,
+ .flags = 0 },
+ { .bitrate = 360,
+ .hw_value = ZD_OFDM_RATE_36M,
+ .flags = 0 },
+ { .bitrate = 480,
+ .hw_value = ZD_OFDM_RATE_48M,
+ .flags = 0 },
+ { .bitrate = 540,
+ .hw_value = ZD_OFDM_RATE_54M,
+ .flags = 0 },
};
static const struct ieee80211_channel zd_channels[] = {
- { .chan = 1,
- .freq = 2412},
- { .chan = 2,
- .freq = 2417},
- { .chan = 3,
- .freq = 2422},
- { .chan = 4,
- .freq = 2427},
- { .chan = 5,
- .freq = 2432},
- { .chan = 6,
- .freq = 2437},
- { .chan = 7,
- .freq = 2442},
- { .chan = 8,
- .freq = 2447},
- { .chan = 9,
- .freq = 2452},
- { .chan = 10,
- .freq = 2457},
- { .chan = 11,
- .freq = 2462},
- { .chan = 12,
- .freq = 2467},
- { .chan = 13,
- .freq = 2472},
- { .chan = 14,
- .freq = 2484}
+ { .center_freq = 2412, .hw_value = 1 },
+ { .center_freq = 2417, .hw_value = 2 },
+ { .center_freq = 2422, .hw_value = 3 },
+ { .center_freq = 2427, .hw_value = 4 },
+ { .center_freq = 2432, .hw_value = 5 },
+ { .center_freq = 2437, .hw_value = 6 },
+ { .center_freq = 2442, .hw_value = 7 },
+ { .center_freq = 2447, .hw_value = 8 },
+ { .center_freq = 2452, .hw_value = 9 },
+ { .center_freq = 2457, .hw_value = 10 },
+ { .center_freq = 2462, .hw_value = 11 },
+ { .center_freq = 2467, .hw_value = 12 },
+ { .center_freq = 2472, .hw_value = 13 },
+ { .center_freq = 2484, .hw_value = 14 },
};
static void housekeeping_init(struct zd_mac *mac);
@@ -503,7 +488,9 @@ static int fill_ctrlset(struct zd_mac *mac,
ZD_ASSERT(frag_len <= 0xffff);
- cs->modulation = control->tx_rate;
+ cs->modulation = control->tx_rate->hw_value;
+ if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE)
+ cs->modulation = control->tx_rate->hw_value_short;
cs->tx_length = cpu_to_le16(frag_len);
@@ -631,6 +618,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length)
int bad_frame = 0;
u16 fc;
bool is_qos, is_4addr, need_padding;
+ int i;
+ u8 rate;
if (length < ZD_PLCP_HEADER_SIZE + 10 /* IEEE80211_1ADDR_LEN */ +
FCS_LEN + sizeof(struct rx_status))
@@ -660,14 +649,19 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length)
}
}
- stats.channel = _zd_chip_get_channel(&mac->chip);
- stats.freq = zd_channels[stats.channel - 1].freq;
- stats.phymode = MODE_IEEE80211G;
+ stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq;
+ stats.band = IEEE80211_BAND_2GHZ;
stats.ssi = status->signal_strength;
stats.signal = zd_rx_qual_percent(buffer,
length - sizeof(struct rx_status),
status);
- stats.rate = zd_rx_rate(buffer, status);
+
+ rate = zd_rx_rate(buffer, status);
+
+ /* todo: return index in the big switches in zd_rx_rate instead */
+ for (i = 0; i < mac->band.n_bitrates; i++)
+ if (rate == mac->band.bitrates[i].hw_value)
+ stats.rate_idx = i;
length -= ZD_PLCP_HEADER_SIZE + sizeof(struct rx_status);
buffer += ZD_PLCP_HEADER_SIZE;
@@ -736,7 +730,7 @@ static void zd_op_remove_interface(struct ieee80211_hw *hw,
static int zd_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
{
struct zd_mac *mac = zd_hw_mac(hw);
- return zd_chip_set_channel(&mac->chip, conf->channel);
+ return zd_chip_set_channel(&mac->chip, conf->channel->hw_value);
}
static int zd_op_config_interface(struct ieee80211_hw *hw,
@@ -894,7 +888,6 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf)
{
struct zd_mac *mac;
struct ieee80211_hw *hw;
- int i;
hw = ieee80211_alloc_hw(sizeof(struct zd_mac), &zd_ops);
if (!hw) {
@@ -912,19 +905,14 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf)
memcpy(mac->channels, zd_channels, sizeof(zd_channels));
memcpy(mac->rates, zd_rates, sizeof(zd_rates));
- mac->modes[0].mode = MODE_IEEE80211G;
- mac->modes[0].num_rates = ARRAY_SIZE(zd_rates);
- mac->modes[0].rates = mac->rates;
- mac->modes[0].num_channels = ARRAY_SIZE(zd_channels);
- mac->modes[0].channels = mac->channels;
- mac->modes[1].mode = MODE_IEEE80211B;
- mac->modes[1].num_rates = 4;
- mac->modes[1].rates = mac->rates;
- mac->modes[1].num_channels = ARRAY_SIZE(zd_channels);
- mac->modes[1].channels = mac->channels;
-
- hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
- IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED;
+ mac->band.n_bitrates = ARRAY_SIZE(zd_rates);
+ mac->band.bitrates = mac->rates;
+ mac->band.n_channels = ARRAY_SIZE(zd_channels);
+ mac->band.channels = mac->channels;
+
+ hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band;
+
+ hw->flags = IEEE80211_HW_RX_INCLUDES_FCS;
hw->max_rssi = 100;
hw->max_signal = 100;
@@ -933,14 +921,6 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf)
skb_queue_head_init(&mac->ack_wait_queue);
- for (i = 0; i < 2; i++) {
- if (ieee80211_register_hwmode(hw, &mac->modes[i])) {
- dev_dbg_f(&intf->dev, "cannot register hwmode\n");
- ieee80211_free_hw(hw);
- return NULL;
- }
- }
-
zd_chip_init(&mac->chip, hw, intf);
housekeeping_init(mac);
INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler);
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 2dde108..67dea97 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -185,7 +185,7 @@ struct zd_mac {
struct sk_buff_head ack_wait_queue;
struct ieee80211_channel channels[14];
struct ieee80211_rate rates[12];
- struct ieee80211_hw_mode modes[2];
+ struct ieee80211_supported_band band;
/* Short preamble (used for RTS/CTS) */
unsigned int short_preamble:1;