From 8318d78a44d49ac1edf2bdec7299de3617c4232e Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 24 Jan 2008 19:38:38 +0100 Subject: 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 Signed-off-by: John W. Linville --- drivers/net/wireless/adm8211.c | 80 ++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 35 deletions(-) (limited to 'drivers/net/wireless/adm8211.c') diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c index 79796186713e..7d4218206c47 100644 --- a/drivers/net/wireless/adm8211.c +++ b/drivers/net/wireless/adm8211.c @@ -48,6 +48,32 @@ static struct pci_device_id adm8211_pci_id_table[] __devinitdata = { { 0 } }; +static struct ieee80211_rate adm8211_rates[] = { + { .bitrate = 10, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, + { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, + { .bitrate = 55, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, + { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, + { .bitrate = 220, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, /* XX ?? */ +}; + +static const struct ieee80211_channel adm8211_channels[] = { + { .center_freq = 2412}, + { .center_freq = 2417}, + { .center_freq = 2422}, + { .center_freq = 2427}, + { .center_freq = 2432}, + { .center_freq = 2437}, + { .center_freq = 2442}, + { .center_freq = 2447}, + { .center_freq = 2452}, + { .center_freq = 2457}, + { .center_freq = 2462}, + { .center_freq = 2467}, + { .center_freq = 2472}, + { .center_freq = 2484}, +}; + + static void adm8211_eeprom_register_read(struct eeprom_93cx6 *eeprom) { struct adm8211_priv *priv = eeprom->data; @@ -155,17 +181,17 @@ static int adm8211_read_eeprom(struct ieee80211_hw *dev) printk(KERN_DEBUG "%s (adm8211): Channel range: %d - %d\n", pci_name(priv->pdev), (int)chan_range.min, (int)chan_range.max); - priv->modes[0].num_channels = chan_range.max - chan_range.min + 1; - priv->modes[0].channels = priv->channels; + BUILD_BUG_ON(sizeof(priv->channels) != sizeof(adm8211_channels)); - memcpy(priv->channels, adm8211_channels, sizeof(adm8211_channels)); + memcpy(priv->channels, adm8211_channels, sizeof(priv->channels)); + priv->band.channels = priv->channels; + priv->band.n_channels = ARRAY_SIZE(adm8211_channels); + priv->band.bitrates = adm8211_rates; + priv->band.n_bitrates = ARRAY_SIZE(adm8211_rates); for (i = 1; i <= ARRAY_SIZE(adm8211_channels); i++) - if (i >= chan_range.min && i <= chan_range.max) - priv->channels[i - 1].flag = - IEEE80211_CHAN_W_SCAN | - IEEE80211_CHAN_W_ACTIVE_SCAN | - IEEE80211_CHAN_W_IBSS; + if (i < chan_range.min || i > chan_range.max) + priv->channels[i - 1].flags |= IEEE80211_CHAN_DISABLED; switch (priv->eeprom->specific_bbptype) { case ADM8211_BBP_RFMD3000: @@ -347,7 +373,6 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev) unsigned int pktlen; struct sk_buff *skb, *newskb; unsigned int limit = priv->rx_ring_size; - static const u8 rate_tbl[] = {10, 20, 55, 110, 220}; u8 rssi, rate; while (!(priv->rx_ring[entry].status & cpu_to_le32(RDES0_STATUS_OWN))) { @@ -425,12 +450,10 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev) else rx_status.ssi = 100 - rssi; - if (rate <= 4) - rx_status.rate = rate_tbl[rate]; + rx_status.rate_idx = rate; - rx_status.channel = priv->channel; - rx_status.freq = adm8211_channels[priv->channel - 1].freq; - rx_status.phymode = MODE_IEEE80211B; + rx_status.freq = adm8211_channels[priv->channel - 1].center_freq; + rx_status.band = IEEE80211_BAND_2GHZ; ieee80211_rx_irqsafe(dev, skb, &rx_status); } @@ -1054,7 +1077,7 @@ static int adm8211_set_rate(struct ieee80211_hw *dev) if (priv->pdev->revision != ADM8211_REV_BA) { rate_buf[0] = ARRAY_SIZE(adm8211_rates); for (i = 0; i < ARRAY_SIZE(adm8211_rates); i++) - rate_buf[i + 1] = (adm8211_rates[i].rate / 5) | 0x80; + rate_buf[i + 1] = (adm8211_rates[i].bitrate / 5) | 0x80; } else { /* workaround for rev BA specific bug */ rate_buf[0] = 0x04; @@ -1303,9 +1326,10 @@ static int adm8211_set_ssid(struct ieee80211_hw *dev, u8 *ssid, size_t ssid_len) static int adm8211_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) { struct adm8211_priv *priv = dev->priv; + int channel = ieee80211_frequency_to_channel(conf->channel->center_freq); - if (conf->channel != priv->channel) { - priv->channel = conf->channel; + if (channel != priv->channel) { + priv->channel = channel; adm8211_rf_set_channel(dev, priv->channel); } @@ -1680,10 +1704,10 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb, if (control->tx_rate < 0) { short_preamble = 1; - plcp_signal = -control->tx_rate; + plcp_signal = -control->tx_rate->bitrate; } else { short_preamble = 0; - plcp_signal = control->tx_rate; + plcp_signal = control->tx_rate->bitrate; } hdr = (struct ieee80211_hdr *)skb->data; @@ -1880,18 +1904,11 @@ static int __devinit adm8211_probe(struct pci_dev *pdev, SET_IEEE80211_PERM_ADDR(dev, perm_addr); dev->extra_tx_headroom = sizeof(struct adm8211_tx_hdr); - dev->flags = IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED; - /* IEEE80211_HW_RX_INCLUDES_FCS in promisc mode */ + /* dev->flags = IEEE80211_HW_RX_INCLUDES_FCS in promisc mode */ dev->channel_change_time = 1000; dev->max_rssi = 100; /* FIXME: find better value */ - priv->modes[0].mode = MODE_IEEE80211B; - /* channel info filled in by adm8211_read_eeprom */ - memcpy(priv->rates, adm8211_rates, sizeof(adm8211_rates)); - priv->modes[0].num_rates = ARRAY_SIZE(adm8211_rates); - priv->modes[0].rates = priv->rates; - dev->queues = 1; /* ADM8211C supports more, maybe ADM8211B too */ priv->retry_limit = 3; @@ -1917,14 +1934,7 @@ static int __devinit adm8211_probe(struct pci_dev *pdev, goto err_free_desc; } - priv->channel = priv->modes[0].channels[0].chan; - - err = ieee80211_register_hwmode(dev, &priv->modes[0]); - if (err) { - printk(KERN_ERR "%s (adm8211): Can't register hwmode\n", - pci_name(pdev)); - goto err_free_desc; - } + priv->channel = 1; err = ieee80211_register_hw(dev); if (err) { -- cgit v1.2.3-59-g8ed1b From e63e3fa7bd4d0dc8cbab5ab7aff84cd37d45295e Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 20 Feb 2008 12:06:47 +0100 Subject: adm8211: fix sparse warnings Both of these seem to be actual errors, the first is just wrong and the second is my mistake introduced by the cfg80211 API update. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- drivers/net/wireless/adm8211.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'drivers/net/wireless/adm8211.c') diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c index 7d4218206c47..a1303ae03b0d 100644 --- a/drivers/net/wireless/adm8211.c +++ b/drivers/net/wireless/adm8211.c @@ -1109,7 +1109,7 @@ static void adm8211_hw_init(struct ieee80211_hw *dev) u32 reg; u8 cline; - reg = le32_to_cpu(ADM8211_CSR_READ(PAR)); + reg = ADM8211_CSR_READ(PAR); reg |= ADM8211_PAR_MRLE | ADM8211_PAR_MRME; reg &= ~(ADM8211_PAR_BAR | ADM8211_PAR_CAL); @@ -1702,13 +1702,9 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb, int plcp, dur, len, plcp_signal, short_preamble; struct ieee80211_hdr *hdr; - if (control->tx_rate < 0) { - short_preamble = 1; - plcp_signal = -control->tx_rate->bitrate; - } else { - short_preamble = 0; - plcp_signal = control->tx_rate->bitrate; - } + short_preamble = !!(control->tx_rate->flags & + IEEE80211_TXCTL_SHORT_PREAMBLE); + plcp_signal = control->tx_rate->bitrate; hdr = (struct ieee80211_hdr *)skb->data; fc = le16_to_cpu(hdr->frame_control) & ~IEEE80211_FCTL_PROTECTED; -- cgit v1.2.3-59-g8ed1b From 9a89c839f79395426b84cf6da9d56773402b4c0e Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 25 Feb 2008 11:12:18 +0100 Subject: adm8211: fix cfg80211 band API conversion Insert a missing band assignment. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- drivers/net/wireless/adm8211.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/net/wireless/adm8211.c') diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c index a1303ae03b0d..2e257ee2783b 100644 --- a/drivers/net/wireless/adm8211.c +++ b/drivers/net/wireless/adm8211.c @@ -1932,6 +1932,8 @@ static int __devinit adm8211_probe(struct pci_dev *pdev, priv->channel = 1; + dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band; + err = ieee80211_register_hw(dev); if (err) { printk(KERN_ERR "%s (adm8211): Cannot register device\n", -- cgit v1.2.3-59-g8ed1b From e764948b1abd8316f8a1364757d6629f5cda199d Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Mon, 7 Apr 2008 21:08:55 +0200 Subject: adm8211: remove commented-out code Remove some commented-out code from adm8211. Signed-off-by: Pavel Machek Signed-off-by: John W. Linville --- drivers/net/wireless/adm8211.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers/net/wireless/adm8211.c') diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c index 2e257ee2783b..5c0d2b082750 100644 --- a/drivers/net/wireless/adm8211.c +++ b/drivers/net/wireless/adm8211.c @@ -488,9 +488,6 @@ do { \ if (stsr & ADM8211_STSR_TCI) adm8211_interrupt_tci(dev); - /*ADM8211_INT(LinkOn);*/ - /*ADM8211_INT(LinkOff);*/ - ADM8211_INT(PCF); ADM8211_INT(BCNTC); ADM8211_INT(GPINT); @@ -500,7 +497,6 @@ do { \ ADM8211_INT(SQL); ADM8211_INT(WEPTD); ADM8211_INT(ATIME); - /*ADM8211_INT(TBTT);*/ ADM8211_INT(TEIS); ADM8211_INT(FBE); ADM8211_INT(REIS); @@ -508,9 +504,6 @@ do { \ ADM8211_INT(RPS); ADM8211_INT(RDU); ADM8211_INT(TUF); - /*ADM8211_INT(TRT);*/ - /*ADM8211_INT(TLT);*/ - /*ADM8211_INT(TDU);*/ ADM8211_INT(TPS); return IRQ_HANDLED; -- cgit v1.2.3-59-g8ed1b