Skip to content

Commit 8318d78

Browse files
jmberglinvjw
authored andcommitted
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>
1 parent 10b6b80 commit 8318d78

66 files changed

Lines changed: 2116 additions & 2781 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drivers/net/wireless/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ config P54_PCI
735735
config ATH5K
736736
tristate "Atheros 5xxx wireless cards support"
737737
depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
738+
depends on BROKEN
738739
---help---
739740
This module adds support for wireless adapters based on
740741
Atheros 5xxx chipset.

‎drivers/net/wireless/adm8211.c‎

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,32 @@ static struct pci_device_id adm8211_pci_id_table[] __devinitdata = {
4848
{ 0 }
4949
};
5050

51+
static struct ieee80211_rate adm8211_rates[] = {
52+
{ .bitrate = 10, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
53+
{ .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
54+
{ .bitrate = 55, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
55+
{ .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
56+
{ .bitrate = 220, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, /* XX ?? */
57+
};
58+
59+
static const struct ieee80211_channel adm8211_channels[] = {
60+
{ .center_freq = 2412},
61+
{ .center_freq = 2417},
62+
{ .center_freq = 2422},
63+
{ .center_freq = 2427},
64+
{ .center_freq = 2432},
65+
{ .center_freq = 2437},
66+
{ .center_freq = 2442},
67+
{ .center_freq = 2447},
68+
{ .center_freq = 2452},
69+
{ .center_freq = 2457},
70+
{ .center_freq = 2462},
71+
{ .center_freq = 2467},
72+
{ .center_freq = 2472},
73+
{ .center_freq = 2484},
74+
};
75+
76+
5177
static void adm8211_eeprom_register_read(struct eeprom_93cx6 *eeprom)
5278
{
5379
struct adm8211_priv *priv = eeprom->data;
@@ -155,17 +181,17 @@ static int adm8211_read_eeprom(struct ieee80211_hw *dev)
155181
printk(KERN_DEBUG "%s (adm8211): Channel range: %d - %d\n",
156182
pci_name(priv->pdev), (int)chan_range.min, (int)chan_range.max);
157183

158-
priv->modes[0].num_channels = chan_range.max - chan_range.min + 1;
159-
priv->modes[0].channels = priv->channels;
184+
BUILD_BUG_ON(sizeof(priv->channels) != sizeof(adm8211_channels));
160185

161-
memcpy(priv->channels, adm8211_channels, sizeof(adm8211_channels));
186+
memcpy(priv->channels, adm8211_channels, sizeof(priv->channels));
187+
priv->band.channels = priv->channels;
188+
priv->band.n_channels = ARRAY_SIZE(adm8211_channels);
189+
priv->band.bitrates = adm8211_rates;
190+
priv->band.n_bitrates = ARRAY_SIZE(adm8211_rates);
162191

163192
for (i = 1; i <= ARRAY_SIZE(adm8211_channels); i++)
164-
if (i >= chan_range.min && i <= chan_range.max)
165-
priv->channels[i - 1].flag =
166-
IEEE80211_CHAN_W_SCAN |
167-
IEEE80211_CHAN_W_ACTIVE_SCAN |
168-
IEEE80211_CHAN_W_IBSS;
193+
if (i < chan_range.min || i > chan_range.max)
194+
priv->channels[i - 1].flags |= IEEE80211_CHAN_DISABLED;
169195

170196
switch (priv->eeprom->specific_bbptype) {
171197
case ADM8211_BBP_RFMD3000:
@@ -347,7 +373,6 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev)
347373
unsigned int pktlen;
348374
struct sk_buff *skb, *newskb;
349375
unsigned int limit = priv->rx_ring_size;
350-
static const u8 rate_tbl[] = {10, 20, 55, 110, 220};
351376
u8 rssi, rate;
352377

353378
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)
425450
else
426451
rx_status.ssi = 100 - rssi;
427452

428-
if (rate <= 4)
429-
rx_status.rate = rate_tbl[rate];
453+
rx_status.rate_idx = rate;
430454

431-
rx_status.channel = priv->channel;
432-
rx_status.freq = adm8211_channels[priv->channel - 1].freq;
433-
rx_status.phymode = MODE_IEEE80211B;
455+
rx_status.freq = adm8211_channels[priv->channel - 1].center_freq;
456+
rx_status.band = IEEE80211_BAND_2GHZ;
434457

435458
ieee80211_rx_irqsafe(dev, skb, &rx_status);
436459
}
@@ -1054,7 +1077,7 @@ static int adm8211_set_rate(struct ieee80211_hw *dev)
10541077
if (priv->pdev->revision != ADM8211_REV_BA) {
10551078
rate_buf[0] = ARRAY_SIZE(adm8211_rates);
10561079
for (i = 0; i < ARRAY_SIZE(adm8211_rates); i++)
1057-
rate_buf[i + 1] = (adm8211_rates[i].rate / 5) | 0x80;
1080+
rate_buf[i + 1] = (adm8211_rates[i].bitrate / 5) | 0x80;
10581081
} else {
10591082
/* workaround for rev BA specific bug */
10601083
rate_buf[0] = 0x04;
@@ -1303,9 +1326,10 @@ static int adm8211_set_ssid(struct ieee80211_hw *dev, u8 *ssid, size_t ssid_len)
13031326
static int adm8211_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
13041327
{
13051328
struct adm8211_priv *priv = dev->priv;
1329+
int channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
13061330

1307-
if (conf->channel != priv->channel) {
1308-
priv->channel = conf->channel;
1331+
if (channel != priv->channel) {
1332+
priv->channel = channel;
13091333
adm8211_rf_set_channel(dev, priv->channel);
13101334
}
13111335

@@ -1680,10 +1704,10 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
16801704

16811705
if (control->tx_rate < 0) {
16821706
short_preamble = 1;
1683-
plcp_signal = -control->tx_rate;
1707+
plcp_signal = -control->tx_rate->bitrate;
16841708
} else {
16851709
short_preamble = 0;
1686-
plcp_signal = control->tx_rate;
1710+
plcp_signal = control->tx_rate->bitrate;
16871711
}
16881712

16891713
hdr = (struct ieee80211_hdr *)skb->data;
@@ -1880,18 +1904,11 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
18801904
SET_IEEE80211_PERM_ADDR(dev, perm_addr);
18811905

18821906
dev->extra_tx_headroom = sizeof(struct adm8211_tx_hdr);
1883-
dev->flags = IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED;
1884-
/* IEEE80211_HW_RX_INCLUDES_FCS in promisc mode */
1907+
/* dev->flags = IEEE80211_HW_RX_INCLUDES_FCS in promisc mode */
18851908

18861909
dev->channel_change_time = 1000;
18871910
dev->max_rssi = 100; /* FIXME: find better value */
18881911

1889-
priv->modes[0].mode = MODE_IEEE80211B;
1890-
/* channel info filled in by adm8211_read_eeprom */
1891-
memcpy(priv->rates, adm8211_rates, sizeof(adm8211_rates));
1892-
priv->modes[0].num_rates = ARRAY_SIZE(adm8211_rates);
1893-
priv->modes[0].rates = priv->rates;
1894-
18951912
dev->queues = 1; /* ADM8211C supports more, maybe ADM8211B too */
18961913

18971914
priv->retry_limit = 3;
@@ -1917,14 +1934,7 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
19171934
goto err_free_desc;
19181935
}
19191936

1920-
priv->channel = priv->modes[0].channels[0].chan;
1921-
1922-
err = ieee80211_register_hwmode(dev, &priv->modes[0]);
1923-
if (err) {
1924-
printk(KERN_ERR "%s (adm8211): Can't register hwmode\n",
1925-
pci_name(pdev));
1926-
goto err_free_desc;
1927-
}
1937+
priv->channel = 1;
19281938

19291939
err = ieee80211_register_hw(dev);
19301940
if (err) {

‎drivers/net/wireless/adm8211.h‎

Lines changed: 7 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -534,61 +534,6 @@ struct adm8211_eeprom {
534534
u8 cis_data[0]; /* 0x80, 384 bytes */
535535
} __attribute__ ((packed));
536536

537-
static const struct ieee80211_rate adm8211_rates[] = {
538-
{ .rate = 10,
539-
.val = 10,
540-
.val2 = -10,
541-
.flags = IEEE80211_RATE_CCK_2 },
542-
{ .rate = 20,
543-
.val = 20,
544-
.val2 = -20,
545-
.flags = IEEE80211_RATE_CCK_2 },
546-
{ .rate = 55,
547-
.val = 55,
548-
.val2 = -55,
549-
.flags = IEEE80211_RATE_CCK_2 },
550-
{ .rate = 110,
551-
.val = 110,
552-
.val2 = -110,
553-
.flags = IEEE80211_RATE_CCK_2 }
554-
};
555-
556-
struct ieee80211_chan_range {
557-
u8 min;
558-
u8 max;
559-
};
560-
561-
static const struct ieee80211_channel adm8211_channels[] = {
562-
{ .chan = 1,
563-
.freq = 2412},
564-
{ .chan = 2,
565-
.freq = 2417},
566-
{ .chan = 3,
567-
.freq = 2422},
568-
{ .chan = 4,
569-
.freq = 2427},
570-
{ .chan = 5,
571-
.freq = 2432},
572-
{ .chan = 6,
573-
.freq = 2437},
574-
{ .chan = 7,
575-
.freq = 2442},
576-
{ .chan = 8,
577-
.freq = 2447},
578-
{ .chan = 9,
579-
.freq = 2452},
580-
{ .chan = 10,
581-
.freq = 2457},
582-
{ .chan = 11,
583-
.freq = 2462},
584-
{ .chan = 12,
585-
.freq = 2467},
586-
{ .chan = 13,
587-
.freq = 2472},
588-
{ .chan = 14,
589-
.freq = 2484},
590-
};
591-
592537
struct adm8211_priv {
593538
struct pci_dev *pdev;
594539
spinlock_t lock;
@@ -603,9 +548,8 @@ struct adm8211_priv {
603548
unsigned int cur_tx, dirty_tx, cur_rx;
604549

605550
struct ieee80211_low_level_stats stats;
606-
struct ieee80211_hw_mode modes[1];
607-
struct ieee80211_channel channels[ARRAY_SIZE(adm8211_channels)];
608-
struct ieee80211_rate rates[ARRAY_SIZE(adm8211_rates)];
551+
struct ieee80211_supported_band band;
552+
struct ieee80211_channel channels[14];
609553
int mode;
610554

611555
int channel;
@@ -643,6 +587,11 @@ struct adm8211_priv {
643587
} transceiver_type;
644588
};
645589

590+
struct ieee80211_chan_range {
591+
u8 min;
592+
u8 max;
593+
};
594+
646595
static const struct ieee80211_chan_range cranges[] = {
647596
{1, 11}, /* FCC */
648597
{1, 11}, /* IC */

‎drivers/net/wireless/b43/b43.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,6 @@ struct b43_phy {
468468
u8 possible_phymodes;
469469
/* GMODE bit enabled? */
470470
bool gmode;
471-
/* Possible ieee80211 subsystem hwmodes for this PHY.
472-
* Which mode is selected, depends on thr GMODE enabled bit */
473-
#define B43_MAX_PHYHWMODES 2
474-
struct ieee80211_hw_mode hwmodes[B43_MAX_PHYHWMODES];
475471

476472
/* Analog Type */
477473
u8 analog;
@@ -727,7 +723,6 @@ struct b43_wldev {
727723

728724
bool bad_frames_preempt; /* Use "Bad Frames Preemption" (default off) */
729725
bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM) */
730-
bool short_preamble; /* TRUE, if short preamble is enabled. */
731726
bool short_slot; /* TRUE, if short slot timing is enabled. */
732727
bool radio_hw_enable; /* saved state of radio hardware enabled state */
733728
bool suspend_in_progress; /* TRUE, if we are in a suspend/resume cycle */

0 commit comments

Comments
 (0)