diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-01-24 13:38:38 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-02-29 15:19:32 -0500 |
commit | 8318d78a44d49ac1edf2bdec7299de3617c4232e (patch) | |
tree | d434634418edd7399737801615d247be06616fdd /drivers | |
parent | 10b6b80145cc93887dd8aab99bfffa375e9add31 (diff) |
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')
40 files changed, 1012 insertions, 1699 deletions
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig index 714a6ca30ad2..cd5fcc67e954 100644 --- a/drivers/net/wireless/Kconfig +++ b/drivers/net/wireless/Kconfig | |||
@@ -735,6 +735,7 @@ config P54_PCI | |||
735 | config ATH5K | 735 | config ATH5K |
736 | tristate "Atheros 5xxx wireless cards support" | 736 | tristate "Atheros 5xxx wireless cards support" |
737 | depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL | 737 | depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL |
738 | depends on BROKEN | ||
738 | ---help--- | 739 | ---help--- |
739 | This module adds support for wireless adapters based on | 740 | This module adds support for wireless adapters based on |
740 | Atheros 5xxx chipset. | 741 | Atheros 5xxx chipset. |
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 = { | |||
48 | { 0 } | 48 | { 0 } |
49 | }; | 49 | }; |
50 | 50 | ||
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 | |||
51 | static void adm8211_eeprom_register_read(struct eeprom_93cx6 *eeprom) | 77 | static void adm8211_eeprom_register_read(struct eeprom_93cx6 *eeprom) |
52 | { | 78 | { |
53 | struct adm8211_priv *priv = eeprom->data; | 79 | struct adm8211_priv *priv = eeprom->data; |
@@ -155,17 +181,17 @@ static int adm8211_read_eeprom(struct ieee80211_hw *dev) | |||
155 | printk(KERN_DEBUG "%s (adm8211): Channel range: %d - %d\n", | 181 | printk(KERN_DEBUG "%s (adm8211): Channel range: %d - %d\n", |
156 | pci_name(priv->pdev), (int)chan_range.min, (int)chan_range.max); | 182 | pci_name(priv->pdev), (int)chan_range.min, (int)chan_range.max); |
157 | 183 | ||
158 | priv->modes[0].num_channels = chan_range.max - chan_range.min + 1; | 184 | BUILD_BUG_ON(sizeof(priv->channels) != sizeof(adm8211_channels)); |
159 | priv->modes[0].channels = priv->channels; | ||
160 | 185 | ||
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); | ||
162 | 191 | ||
163 | for (i = 1; i <= ARRAY_SIZE(adm8211_channels); i++) | 192 | for (i = 1; i <= ARRAY_SIZE(adm8211_channels); i++) |
164 | if (i >= chan_range.min && i <= chan_range.max) | 193 | if (i < chan_range.min || i > chan_range.max) |
165 | priv->channels[i - 1].flag = | 194 | priv->channels[i - 1].flags |= IEEE80211_CHAN_DISABLED; |
166 | IEEE80211_CHAN_W_SCAN | | ||
167 | IEEE80211_CHAN_W_ACTIVE_SCAN | | ||
168 | IEEE80211_CHAN_W_IBSS; | ||
169 | 195 | ||
170 | switch (priv->eeprom->specific_bbptype) { | 196 | switch (priv->eeprom->specific_bbptype) { |
171 | case ADM8211_BBP_RFMD3000: | 197 | case ADM8211_BBP_RFMD3000: |
@@ -347,7 +373,6 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev) | |||
347 | unsigned int pktlen; | 373 | unsigned int pktlen; |
348 | struct sk_buff *skb, *newskb; | 374 | struct sk_buff *skb, *newskb; |
349 | unsigned int limit = priv->rx_ring_size; | 375 | unsigned int limit = priv->rx_ring_size; |
350 | static const u8 rate_tbl[] = {10, 20, 55, 110, 220}; | ||
351 | u8 rssi, rate; | 376 | u8 rssi, rate; |
352 | 377 | ||
353 | while (!(priv->rx_ring[entry].status & cpu_to_le32(RDES0_STATUS_OWN))) { | 378 | 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) | |||
425 | else | 450 | else |
426 | rx_status.ssi = 100 - rssi; | 451 | rx_status.ssi = 100 - rssi; |
427 | 452 | ||
428 | if (rate <= 4) | 453 | rx_status.rate_idx = rate; |
429 | rx_status.rate = rate_tbl[rate]; | ||
430 | 454 | ||
431 | rx_status.channel = priv->channel; | 455 | rx_status.freq = adm8211_channels[priv->channel - 1].center_freq; |
432 | rx_status.freq = adm8211_channels[priv->channel - 1].freq; | 456 | rx_status.band = IEEE80211_BAND_2GHZ; |
433 | rx_status.phymode = MODE_IEEE80211B; | ||
434 | 457 | ||
435 | ieee80211_rx_irqsafe(dev, skb, &rx_status); | 458 | ieee80211_rx_irqsafe(dev, skb, &rx_status); |
436 | } | 459 | } |
@@ -1054,7 +1077,7 @@ static int adm8211_set_rate(struct ieee80211_hw *dev) | |||
1054 | if (priv->pdev->revision != ADM8211_REV_BA) { | 1077 | if (priv->pdev->revision != ADM8211_REV_BA) { |
1055 | rate_buf[0] = ARRAY_SIZE(adm8211_rates); | 1078 | rate_buf[0] = ARRAY_SIZE(adm8211_rates); |
1056 | for (i = 0; i < ARRAY_SIZE(adm8211_rates); i++) | 1079 | 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; |
1058 | } else { | 1081 | } else { |
1059 | /* workaround for rev BA specific bug */ | 1082 | /* workaround for rev BA specific bug */ |
1060 | rate_buf[0] = 0x04; | 1083 | rate_buf[0] = 0x04; |
@@ -1303,9 +1326,10 @@ static int adm8211_set_ssid(struct ieee80211_hw *dev, u8 *ssid, size_t ssid_len) | |||
1303 | static int adm8211_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) | 1326 | static int adm8211_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) |
1304 | { | 1327 | { |
1305 | struct adm8211_priv *priv = dev->priv; | 1328 | struct adm8211_priv *priv = dev->priv; |
1329 | int channel = ieee80211_frequency_to_channel(conf->channel->center_freq); | ||
1306 | 1330 | ||
1307 | if (conf->channel != priv->channel) { | 1331 | if (channel != priv->channel) { |
1308 | priv->channel = conf->channel; | 1332 | priv->channel = channel; |
1309 | adm8211_rf_set_channel(dev, priv->channel); | 1333 | adm8211_rf_set_channel(dev, priv->channel); |
1310 | } | 1334 | } |
1311 | 1335 | ||
@@ -1680,10 +1704,10 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
1680 | 1704 | ||
1681 | if (control->tx_rate < 0) { | 1705 | if (control->tx_rate < 0) { |
1682 | short_preamble = 1; | 1706 | short_preamble = 1; |
1683 | plcp_signal = -control->tx_rate; | 1707 | plcp_signal = -control->tx_rate->bitrate; |
1684 | } else { | 1708 | } else { |
1685 | short_preamble = 0; | 1709 | short_preamble = 0; |
1686 | plcp_signal = control->tx_rate; | 1710 | plcp_signal = control->tx_rate->bitrate; |
1687 | } | 1711 | } |
1688 | 1712 | ||
1689 | hdr = (struct ieee80211_hdr *)skb->data; | 1713 | hdr = (struct ieee80211_hdr *)skb->data; |
@@ -1880,18 +1904,11 @@ static int __devinit adm8211_probe(struct pci_dev *pdev, | |||
1880 | SET_IEEE80211_PERM_ADDR(dev, perm_addr); | 1904 | SET_IEEE80211_PERM_ADDR(dev, perm_addr); |
1881 | 1905 | ||
1882 | dev->extra_tx_headroom = sizeof(struct adm8211_tx_hdr); | 1906 | dev->extra_tx_headroom = sizeof(struct adm8211_tx_hdr); |
1883 | dev->flags = IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED; | 1907 | /* dev->flags = IEEE80211_HW_RX_INCLUDES_FCS in promisc mode */ |
1884 | /* IEEE80211_HW_RX_INCLUDES_FCS in promisc mode */ | ||
1885 | 1908 | ||
1886 | dev->channel_change_time = 1000; | 1909 | dev->channel_change_time = 1000; |
1887 | dev->max_rssi = 100; /* FIXME: find better value */ | 1910 | dev->max_rssi = 100; /* FIXME: find better value */ |
1888 | 1911 | ||
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 | |||
1895 | dev->queues = 1; /* ADM8211C supports more, maybe ADM8211B too */ | 1912 | dev->queues = 1; /* ADM8211C supports more, maybe ADM8211B too */ |
1896 | 1913 | ||
1897 | priv->retry_limit = 3; | 1914 | priv->retry_limit = 3; |
@@ -1917,14 +1934,7 @@ static int __devinit adm8211_probe(struct pci_dev *pdev, | |||
1917 | goto err_free_desc; | 1934 | goto err_free_desc; |
1918 | } | 1935 | } |
1919 | 1936 | ||
1920 | priv->channel = priv->modes[0].channels[0].chan; | 1937 | priv->channel = 1; |
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 | } | ||
1928 | 1938 | ||
1929 | err = ieee80211_register_hw(dev); | 1939 | err = ieee80211_register_hw(dev); |
1930 | if (err) { | 1940 | if (err) { |
diff --git a/drivers/net/wireless/adm8211.h b/drivers/net/wireless/adm8211.h index ef326fed42e4..8d7c564b3b04 100644 --- a/drivers/net/wireless/adm8211.h +++ b/drivers/net/wireless/adm8211.h | |||
@@ -534,61 +534,6 @@ struct adm8211_eeprom { | |||
534 | u8 cis_data[0]; /* 0x80, 384 bytes */ | 534 | u8 cis_data[0]; /* 0x80, 384 bytes */ |
535 | } __attribute__ ((packed)); | 535 | } __attribute__ ((packed)); |
536 | 536 | ||
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 | |||
592 | struct adm8211_priv { | 537 | struct adm8211_priv { |
593 | struct pci_dev *pdev; | 538 | struct pci_dev *pdev; |
594 | spinlock_t lock; | 539 | spinlock_t lock; |
@@ -603,9 +548,8 @@ struct adm8211_priv { | |||
603 | unsigned int cur_tx, dirty_tx, cur_rx; | 548 | unsigned int cur_tx, dirty_tx, cur_rx; |
604 | 549 | ||
605 | struct ieee80211_low_level_stats stats; | 550 | struct ieee80211_low_level_stats stats; |
606 | struct ieee80211_hw_mode modes[1]; | 551 | struct ieee80211_supported_band band; |
607 | struct ieee80211_channel channels[ARRAY_SIZE(adm8211_channels)]; | 552 | struct ieee80211_channel channels[14]; |
608 | struct ieee80211_rate rates[ARRAY_SIZE(adm8211_rates)]; | ||
609 | int mode; | 553 | int mode; |
610 | 554 | ||
611 | int channel; | 555 | int channel; |
@@ -643,6 +587,11 @@ struct adm8211_priv { | |||
643 | } transceiver_type; | 587 | } transceiver_type; |
644 | }; | 588 | }; |
645 | 589 | ||
590 | struct ieee80211_chan_range { | ||
591 | u8 min; | ||
592 | u8 max; | ||
593 | }; | ||
594 | |||
646 | static const struct ieee80211_chan_range cranges[] = { | 595 | static const struct ieee80211_chan_range cranges[] = { |
647 | {1, 11}, /* FCC */ | 596 | {1, 11}, /* FCC */ |
648 | {1, 11}, /* IC */ | 597 | {1, 11}, /* IC */ |
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h index f13346ba9dd2..3e40323cd43f 100644 --- a/drivers/net/wireless/b43/b43.h +++ b/drivers/net/wireless/b43/b43.h | |||
@@ -468,10 +468,6 @@ struct b43_phy { | |||
468 | u8 possible_phymodes; | 468 | u8 possible_phymodes; |
469 | /* GMODE bit enabled? */ | 469 | /* GMODE bit enabled? */ |
470 | bool gmode; | 470 | 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]; | ||
475 | 471 | ||
476 | /* Analog Type */ | 472 | /* Analog Type */ |
477 | u8 analog; | 473 | u8 analog; |
@@ -727,7 +723,6 @@ struct b43_wldev { | |||
727 | 723 | ||
728 | bool bad_frames_preempt; /* Use "Bad Frames Preemption" (default off) */ | 724 | bool bad_frames_preempt; /* Use "Bad Frames Preemption" (default off) */ |
729 | bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM) */ | 725 | bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM) */ |
730 | bool short_preamble; /* TRUE, if short preamble is enabled. */ | ||
731 | bool short_slot; /* TRUE, if short slot timing is enabled. */ | 726 | bool short_slot; /* TRUE, if short slot timing is enabled. */ |
732 | bool radio_hw_enable; /* saved state of radio hardware enabled state */ | 727 | bool radio_hw_enable; /* saved state of radio hardware enabled state */ |
733 | bool suspend_in_progress; /* TRUE, if we are in a suspend/resume cycle */ | 728 | bool suspend_in_progress; /* TRUE, if we are in a suspend/resume cycle */ |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 51dfce16178a..017a041d07d0 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -96,25 +96,29 @@ MODULE_DEVICE_TABLE(ssb, b43_ssb_tbl); | |||
96 | * data in there. This data is the same for all devices, so we don't | 96 | * data in there. This data is the same for all devices, so we don't |
97 | * get concurrency issues */ | 97 | * get concurrency issues */ |
98 | #define RATETAB_ENT(_rateid, _flags) \ | 98 | #define RATETAB_ENT(_rateid, _flags) \ |
99 | { \ | 99 | { \ |
100 | .rate = B43_RATE_TO_BASE100KBPS(_rateid), \ | 100 | .bitrate = B43_RATE_TO_BASE100KBPS(_rateid), \ |
101 | .val = (_rateid), \ | 101 | .hw_value = (_rateid), \ |
102 | .val2 = (_rateid), \ | 102 | .flags = (_flags), \ |
103 | .flags = (_flags), \ | ||
104 | } | 103 | } |
104 | |||
105 | /* | ||
106 | * NOTE: When changing this, sync with xmit.c's | ||
107 | * b43_plcp_get_bitrate_idx_* functions! | ||
108 | */ | ||
105 | static struct ieee80211_rate __b43_ratetable[] = { | 109 | static struct ieee80211_rate __b43_ratetable[] = { |
106 | RATETAB_ENT(B43_CCK_RATE_1MB, IEEE80211_RATE_CCK), | 110 | RATETAB_ENT(B43_CCK_RATE_1MB, 0), |
107 | RATETAB_ENT(B43_CCK_RATE_2MB, IEEE80211_RATE_CCK_2), | 111 | RATETAB_ENT(B43_CCK_RATE_2MB, IEEE80211_RATE_SHORT_PREAMBLE), |
108 | RATETAB_ENT(B43_CCK_RATE_5MB, IEEE80211_RATE_CCK_2), | 112 | RATETAB_ENT(B43_CCK_RATE_5MB, IEEE80211_RATE_SHORT_PREAMBLE), |
109 | RATETAB_ENT(B43_CCK_RATE_11MB, IEEE80211_RATE_CCK_2), | 113 | RATETAB_ENT(B43_CCK_RATE_11MB, IEEE80211_RATE_SHORT_PREAMBLE), |
110 | RATETAB_ENT(B43_OFDM_RATE_6MB, IEEE80211_RATE_OFDM), | 114 | RATETAB_ENT(B43_OFDM_RATE_6MB, 0), |
111 | RATETAB_ENT(B43_OFDM_RATE_9MB, IEEE80211_RATE_OFDM), | 115 | RATETAB_ENT(B43_OFDM_RATE_9MB, 0), |
112 | RATETAB_ENT(B43_OFDM_RATE_12MB, IEEE80211_RATE_OFDM), | 116 | RATETAB_ENT(B43_OFDM_RATE_12MB, 0), |
113 | RATETAB_ENT(B43_OFDM_RATE_18MB, IEEE80211_RATE_OFDM), | 117 | RATETAB_ENT(B43_OFDM_RATE_18MB, 0), |
114 | RATETAB_ENT(B43_OFDM_RATE_24MB, IEEE80211_RATE_OFDM), | 118 | RATETAB_ENT(B43_OFDM_RATE_24MB, 0), |
115 | RATETAB_ENT(B43_OFDM_RATE_36MB, IEEE80211_RATE_OFDM), | 119 | RATETAB_ENT(B43_OFDM_RATE_36MB, 0), |
116 | RATETAB_ENT(B43_OFDM_RATE_48MB, IEEE80211_RATE_OFDM), | 120 | RATETAB_ENT(B43_OFDM_RATE_48MB, 0), |
117 | RATETAB_ENT(B43_OFDM_RATE_54MB, IEEE80211_RATE_OFDM), | 121 | RATETAB_ENT(B43_OFDM_RATE_54MB, 0), |
118 | }; | 122 | }; |
119 | 123 | ||
120 | #define b43_a_ratetable (__b43_ratetable + 4) | 124 | #define b43_a_ratetable (__b43_ratetable + 4) |
@@ -126,14 +130,8 @@ static struct ieee80211_rate __b43_ratetable[] = { | |||
126 | 130 | ||
127 | #define CHANTAB_ENT(_chanid, _freq) \ | 131 | #define CHANTAB_ENT(_chanid, _freq) \ |
128 | { \ | 132 | { \ |
129 | .chan = (_chanid), \ | 133 | .center_freq = (_freq), \ |
130 | .freq = (_freq), \ | 134 | .hw_value = (_chanid), \ |
131 | .val = (_chanid), \ | ||
132 | .flag = IEEE80211_CHAN_W_SCAN | \ | ||
133 | IEEE80211_CHAN_W_ACTIVE_SCAN | \ | ||
134 | IEEE80211_CHAN_W_IBSS, \ | ||
135 | .power_level = 0xFF, \ | ||
136 | .antenna_max = 0xFF, \ | ||
137 | } | 135 | } |
138 | static struct ieee80211_channel b43_2ghz_chantable[] = { | 136 | static struct ieee80211_channel b43_2ghz_chantable[] = { |
139 | CHANTAB_ENT(1, 2412), | 137 | CHANTAB_ENT(1, 2412), |
@@ -151,9 +149,8 @@ static struct ieee80211_channel b43_2ghz_chantable[] = { | |||
151 | CHANTAB_ENT(13, 2472), | 149 | CHANTAB_ENT(13, 2472), |
152 | CHANTAB_ENT(14, 2484), | 150 | CHANTAB_ENT(14, 2484), |
153 | }; | 151 | }; |
154 | #define b43_2ghz_chantable_size ARRAY_SIZE(b43_2ghz_chantable) | ||
155 | 152 | ||
156 | #if 0 | 153 | #ifdef NOTYET |
157 | static struct ieee80211_channel b43_5ghz_chantable[] = { | 154 | static struct ieee80211_channel b43_5ghz_chantable[] = { |
158 | CHANTAB_ENT(36, 5180), | 155 | CHANTAB_ENT(36, 5180), |
159 | CHANTAB_ENT(40, 5200), | 156 | CHANTAB_ENT(40, 5200), |
@@ -169,9 +166,22 @@ static struct ieee80211_channel b43_5ghz_chantable[] = { | |||
169 | CHANTAB_ENT(161, 5805), | 166 | CHANTAB_ENT(161, 5805), |
170 | CHANTAB_ENT(165, 5825), | 167 | CHANTAB_ENT(165, 5825), |
171 | }; | 168 | }; |
172 | #define b43_5ghz_chantable_size ARRAY_SIZE(b43_5ghz_chantable) | 169 | |
170 | static struct ieee80211_supported_band b43_band_5GHz = { | ||
171 | .channels = b43_5ghz_chantable, | ||
172 | .n_channels = ARRAY_SIZE(b43_5ghz_chantable), | ||
173 | .bitrates = b43_a_ratetable, | ||
174 | .n_bitrates = b43_a_ratetable_size, | ||
175 | }; | ||
173 | #endif | 176 | #endif |
174 | 177 | ||
178 | static struct ieee80211_supported_band b43_band_2GHz = { | ||
179 | .channels = b43_2ghz_chantable, | ||
180 | .n_channels = ARRAY_SIZE(b43_2ghz_chantable), | ||
181 | .bitrates = b43_g_ratetable, | ||
182 | .n_bitrates = b43_g_ratetable_size, | ||
183 | }; | ||
184 | |||
175 | static void b43_wireless_core_exit(struct b43_wldev *dev); | 185 | static void b43_wireless_core_exit(struct b43_wldev *dev); |
176 | static int b43_wireless_core_init(struct b43_wldev *dev); | 186 | static int b43_wireless_core_init(struct b43_wldev *dev); |
177 | static void b43_wireless_core_stop(struct b43_wldev *dev); | 187 | static void b43_wireless_core_stop(struct b43_wldev *dev); |
@@ -1222,17 +1232,18 @@ static void b43_write_beacon_template(struct b43_wldev *dev, | |||
1222 | } | 1232 | } |
1223 | 1233 | ||
1224 | static void b43_write_probe_resp_plcp(struct b43_wldev *dev, | 1234 | static void b43_write_probe_resp_plcp(struct b43_wldev *dev, |
1225 | u16 shm_offset, u16 size, u8 rate) | 1235 | u16 shm_offset, u16 size, |
1236 | struct ieee80211_rate *rate) | ||
1226 | { | 1237 | { |
1227 | struct b43_plcp_hdr4 plcp; | 1238 | struct b43_plcp_hdr4 plcp; |
1228 | u32 tmp; | 1239 | u32 tmp; |
1229 | __le16 dur; | 1240 | __le16 dur; |
1230 | 1241 | ||
1231 | plcp.data = 0; | 1242 | plcp.data = 0; |
1232 | b43_generate_plcp_hdr(&plcp, size + FCS_LEN, rate); | 1243 | b43_generate_plcp_hdr(&plcp, size + FCS_LEN, rate->hw_value); |
1233 | dur = ieee80211_generic_frame_duration(dev->wl->hw, | 1244 | dur = ieee80211_generic_frame_duration(dev->wl->hw, |
1234 | dev->wl->vif, size, | 1245 | dev->wl->vif, size, |
1235 | B43_RATE_TO_BASE100KBPS(rate)); | 1246 | rate); |
1236 | /* Write PLCP in two parts and timing for packet transfer */ | 1247 | /* Write PLCP in two parts and timing for packet transfer */ |
1237 | tmp = le32_to_cpu(plcp.data); | 1248 | tmp = le32_to_cpu(plcp.data); |
1238 | b43_shm_write16(dev, B43_SHM_SHARED, shm_offset, tmp & 0xFFFF); | 1249 | b43_shm_write16(dev, B43_SHM_SHARED, shm_offset, tmp & 0xFFFF); |
@@ -1247,7 +1258,8 @@ static void b43_write_probe_resp_plcp(struct b43_wldev *dev, | |||
1247 | * 3) Stripping TIM | 1258 | * 3) Stripping TIM |
1248 | */ | 1259 | */ |
1249 | static const u8 * b43_generate_probe_resp(struct b43_wldev *dev, | 1260 | static const u8 * b43_generate_probe_resp(struct b43_wldev *dev, |
1250 | u16 *dest_size, u8 rate) | 1261 | u16 *dest_size, |
1262 | struct ieee80211_rate *rate) | ||
1251 | { | 1263 | { |
1252 | const u8 *src_data; | 1264 | const u8 *src_data; |
1253 | u8 *dest_data; | 1265 | u8 *dest_data; |
@@ -1292,7 +1304,7 @@ static const u8 * b43_generate_probe_resp(struct b43_wldev *dev, | |||
1292 | IEEE80211_STYPE_PROBE_RESP); | 1304 | IEEE80211_STYPE_PROBE_RESP); |
1293 | dur = ieee80211_generic_frame_duration(dev->wl->hw, | 1305 | dur = ieee80211_generic_frame_duration(dev->wl->hw, |
1294 | dev->wl->vif, *dest_size, | 1306 | dev->wl->vif, *dest_size, |
1295 | B43_RATE_TO_BASE100KBPS(rate)); | 1307 | rate); |
1296 | hdr->duration_id = dur; | 1308 | hdr->duration_id = dur; |
1297 | 1309 | ||
1298 | return dest_data; | 1310 | return dest_data; |
@@ -1300,7 +1312,8 @@ static const u8 * b43_generate_probe_resp(struct b43_wldev *dev, | |||
1300 | 1312 | ||
1301 | static void b43_write_probe_resp_template(struct b43_wldev *dev, | 1313 | static void b43_write_probe_resp_template(struct b43_wldev *dev, |
1302 | u16 ram_offset, | 1314 | u16 ram_offset, |
1303 | u16 shm_size_offset, u8 rate) | 1315 | u16 shm_size_offset, |
1316 | struct ieee80211_rate *rate) | ||
1304 | { | 1317 | { |
1305 | const u8 *probe_resp_data; | 1318 | const u8 *probe_resp_data; |
1306 | u16 size; | 1319 | u16 size; |
@@ -1313,14 +1326,15 @@ static void b43_write_probe_resp_template(struct b43_wldev *dev, | |||
1313 | /* Looks like PLCP headers plus packet timings are stored for | 1326 | /* Looks like PLCP headers plus packet timings are stored for |
1314 | * all possible basic rates | 1327 | * all possible basic rates |
1315 | */ | 1328 | */ |
1316 | b43_write_probe_resp_plcp(dev, 0x31A, size, B43_CCK_RATE_1MB); | 1329 | b43_write_probe_resp_plcp(dev, 0x31A, size, &b43_b_ratetable[0]); |
1317 | b43_write_probe_resp_plcp(dev, 0x32C, size, B43_CCK_RATE_2MB); | 1330 | b43_write_probe_resp_plcp(dev, 0x32C, size, &b43_b_ratetable[1]); |
1318 | b43_write_probe_resp_plcp(dev, 0x33E, size, B43_CCK_RATE_5MB); | 1331 | b43_write_probe_resp_plcp(dev, 0x33E, size, &b43_b_ratetable[2]); |
1319 | b43_write_probe_resp_plcp(dev, 0x350, size, B43_CCK_RATE_11MB); | 1332 | b43_write_probe_resp_plcp(dev, 0x350, size, &b43_b_ratetable[3]); |
1320 | 1333 | ||
1321 | size = min((size_t) size, 0x200 - sizeof(struct b43_plcp_hdr6)); | 1334 | size = min((size_t) size, 0x200 - sizeof(struct b43_plcp_hdr6)); |
1322 | b43_write_template_common(dev, probe_resp_data, | 1335 | b43_write_template_common(dev, probe_resp_data, |
1323 | size, ram_offset, shm_size_offset, rate); | 1336 | size, ram_offset, shm_size_offset, |
1337 | rate->hw_value); | ||
1324 | kfree(probe_resp_data); | 1338 | kfree(probe_resp_data); |
1325 | } | 1339 | } |
1326 | 1340 | ||
@@ -1388,7 +1402,7 @@ static void handle_irq_beacon(struct b43_wldev *dev) | |||
1388 | b43_write_beacon_template(dev, 0x68, 0x18, | 1402 | b43_write_beacon_template(dev, 0x68, 0x18, |
1389 | B43_CCK_RATE_1MB); | 1403 | B43_CCK_RATE_1MB); |
1390 | b43_write_probe_resp_template(dev, 0x268, 0x4A, | 1404 | b43_write_probe_resp_template(dev, 0x268, 0x4A, |
1391 | B43_CCK_RATE_11MB); | 1405 | &__b43_ratetable[3]); |
1392 | wl->beacon0_uploaded = 1; | 1406 | wl->beacon0_uploaded = 1; |
1393 | } | 1407 | } |
1394 | cmd |= B43_MACCMD_BEACON0_VALID; | 1408 | cmd |= B43_MACCMD_BEACON0_VALID; |
@@ -2830,14 +2844,11 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) | |||
2830 | mutex_lock(&wl->mutex); | 2844 | mutex_lock(&wl->mutex); |
2831 | 2845 | ||
2832 | /* Switch the PHY mode (if necessary). */ | 2846 | /* Switch the PHY mode (if necessary). */ |
2833 | switch (conf->phymode) { | 2847 | switch (conf->channel->band) { |
2834 | case MODE_IEEE80211A: | 2848 | case IEEE80211_BAND_5GHZ: |
2835 | new_phymode = B43_PHYMODE_A; | 2849 | new_phymode = B43_PHYMODE_A; |
2836 | break; | 2850 | break; |
2837 | case MODE_IEEE80211B: | 2851 | case IEEE80211_BAND_2GHZ: |
2838 | new_phymode = B43_PHYMODE_B; | ||
2839 | break; | ||
2840 | case MODE_IEEE80211G: | ||
2841 | new_phymode = B43_PHYMODE_G; | 2852 | new_phymode = B43_PHYMODE_G; |
2842 | break; | 2853 | break; |
2843 | default: | 2854 | default: |
@@ -2863,8 +2874,8 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) | |||
2863 | 2874 | ||
2864 | /* Switch to the requested channel. | 2875 | /* Switch to the requested channel. |
2865 | * The firmware takes care of races with the TX handler. */ | 2876 | * The firmware takes care of races with the TX handler. */ |
2866 | if (conf->channel_val != phy->channel) | 2877 | if (conf->channel->hw_value != phy->channel) |
2867 | b43_radio_selectchannel(dev, conf->channel_val, 0); | 2878 | b43_radio_selectchannel(dev, conf->channel->hw_value, 0); |
2868 | 2879 | ||
2869 | /* Enable/Disable ShortSlot timing. */ | 2880 | /* Enable/Disable ShortSlot timing. */ |
2870 | if ((!!(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)) != | 2881 | if ((!!(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)) != |
@@ -3810,9 +3821,7 @@ static int b43_setup_modes(struct b43_wldev *dev, | |||
3810 | bool have_2ghz_phy, bool have_5ghz_phy) | 3821 | bool have_2ghz_phy, bool have_5ghz_phy) |
3811 | { | 3822 | { |
3812 | struct ieee80211_hw *hw = dev->wl->hw; | 3823 | struct ieee80211_hw *hw = dev->wl->hw; |
3813 | struct ieee80211_hw_mode *mode; | ||
3814 | struct b43_phy *phy = &dev->phy; | 3824 | struct b43_phy *phy = &dev->phy; |
3815 | int err; | ||
3816 | 3825 | ||
3817 | /* XXX: This function will go away soon, when mac80211 | 3826 | /* XXX: This function will go away soon, when mac80211 |
3818 | * band stuff is rewritten. So this is just a hack. | 3827 | * band stuff is rewritten. So this is just a hack. |
@@ -3821,15 +3830,7 @@ static int b43_setup_modes(struct b43_wldev *dev, | |||
3821 | * This assumption is OK, as any B, N or A PHY will already | 3830 | * This assumption is OK, as any B, N or A PHY will already |
3822 | * have died a horrible sanity check death earlier. */ | 3831 | * have died a horrible sanity check death earlier. */ |
3823 | 3832 | ||
3824 | mode = &phy->hwmodes[0]; | 3833 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &b43_band_2GHz; |
3825 | mode->mode = MODE_IEEE80211G; | ||
3826 | mode->num_channels = b43_2ghz_chantable_size; | ||
3827 | mode->channels = b43_2ghz_chantable; | ||
3828 | mode->num_rates = b43_g_ratetable_size; | ||
3829 | mode->rates = b43_g_ratetable; | ||
3830 | err = ieee80211_register_hwmode(hw, mode); | ||
3831 | if (err) | ||
3832 | return err; | ||
3833 | phy->possible_phymodes |= B43_PHYMODE_G; | 3834 | phy->possible_phymodes |= B43_PHYMODE_G; |
3834 | 3835 | ||
3835 | return 0; | 3836 | return 0; |
diff --git a/drivers/net/wireless/b43/sysfs.c b/drivers/net/wireless/b43/sysfs.c index f4faff6a7d6c..275095b8cbe7 100644 --- a/drivers/net/wireless/b43/sysfs.c +++ b/drivers/net/wireless/b43/sysfs.c | |||
@@ -47,29 +47,6 @@ static int get_integer(const char *buf, size_t count) | |||
47 | return ret; | 47 | return ret; |
48 | } | 48 | } |
49 | 49 | ||
50 | static int get_boolean(const char *buf, size_t count) | ||
51 | { | ||
52 | if (count != 0) { | ||
53 | if (buf[0] == '1') | ||
54 | return 1; | ||
55 | if (buf[0] == '0') | ||
56 | return 0; | ||
57 | if (count >= 4 && memcmp(buf, "true", 4) == 0) | ||
58 | return 1; | ||
59 | if (count >= 5 && memcmp(buf, "false", 5) == 0) | ||
60 | return 0; | ||
61 | if (count >= 3 && memcmp(buf, "yes", 3) == 0) | ||
62 | return 1; | ||
63 | if (count >= 2 && memcmp(buf, "no", 2) == 0) | ||
64 | return 0; | ||
65 | if (count >= 2 && memcmp(buf, "on", 2) == 0) | ||
66 | return 1; | ||
67 | if (count >= 3 && memcmp(buf, "off", 3) == 0) | ||
68 | return 0; | ||
69 | } | ||
70 | return -EINVAL; | ||
71 | } | ||
72 | |||
73 | static ssize_t b43_attr_interfmode_show(struct device *dev, | 50 | static ssize_t b43_attr_interfmode_show(struct device *dev, |
74 | struct device_attribute *attr, | 51 | struct device_attribute *attr, |
75 | char *buf) | 52 | char *buf) |
@@ -155,82 +132,18 @@ static ssize_t b43_attr_interfmode_store(struct device *dev, | |||
155 | static DEVICE_ATTR(interference, 0644, | 132 | static DEVICE_ATTR(interference, 0644, |
156 | b43_attr_interfmode_show, b43_attr_interfmode_store); | 133 | b43_attr_interfmode_show, b43_attr_interfmode_store); |
157 | 134 | ||
158 | static ssize_t b43_attr_preamble_show(struct device *dev, | ||
159 | struct device_attribute *attr, char *buf) | ||
160 | { | ||
161 | struct b43_wldev *wldev = dev_to_b43_wldev(dev); | ||
162 | ssize_t count; | ||
163 | |||
164 | if (!capable(CAP_NET_ADMIN)) | ||
165 | return -EPERM; | ||
166 | |||
167 | mutex_lock(&wldev->wl->mutex); | ||
168 | |||
169 | if (wldev->short_preamble) | ||
170 | count = | ||
171 | snprintf(buf, PAGE_SIZE, "1 (Short Preamble enabled)\n"); | ||
172 | else | ||
173 | count = | ||
174 | snprintf(buf, PAGE_SIZE, "0 (Short Preamble disabled)\n"); | ||
175 | |||
176 | mutex_unlock(&wldev->wl->mutex); | ||
177 | |||
178 | return count; | ||
179 | } | ||
180 | |||
181 | static ssize_t b43_attr_preamble_store(struct device *dev, | ||
182 | struct device_attribute *attr, | ||
183 | const char *buf, size_t count) | ||
184 | { | ||
185 | struct b43_wldev *wldev = dev_to_b43_wldev(dev); | ||
186 | unsigned long flags; | ||
187 | int value; | ||
188 | |||
189 | if (!capable(CAP_NET_ADMIN)) | ||
190 | return -EPERM; | ||
191 | |||
192 | value = get_boolean(buf, count); | ||
193 | if (value < 0) | ||
194 | return value; | ||
195 | mutex_lock(&wldev->wl->mutex); | ||
196 | spin_lock_irqsave(&wldev->wl->irq_lock, flags); | ||
197 | |||
198 | wldev->short_preamble = !!value; | ||
199 | |||
200 | spin_unlock_irqrestore(&wldev->wl->irq_lock, flags); | ||
201 | mutex_unlock(&wldev->wl->mutex); | ||
202 | |||
203 | return count; | ||
204 | } | ||
205 | |||
206 | static DEVICE_ATTR(shortpreamble, 0644, | ||
207 | b43_attr_preamble_show, b43_attr_preamble_store); | ||
208 | |||
209 | int b43_sysfs_register(struct b43_wldev *wldev) | 135 | int b43_sysfs_register(struct b43_wldev *wldev) |
210 | { | 136 | { |
211 | struct device *dev = wldev->dev->dev; | 137 | struct device *dev = wldev->dev->dev; |
212 | int err; | ||
213 | 138 | ||
214 | B43_WARN_ON(b43_status(wldev) != B43_STAT_INITIALIZED); | 139 | B43_WARN_ON(b43_status(wldev) != B43_STAT_INITIALIZED); |
215 | 140 | ||
216 | err = device_create_file(dev, &dev_attr_interference); | 141 | return device_create_file(dev, &dev_attr_interference); |
217 | if (err) | ||
218 | goto out; | ||
219 | err = device_create_file(dev, &dev_attr_shortpreamble); | ||
220 | if (err) | ||
221 | goto err_remove_interfmode; | ||
222 | |||
223 | out: | ||
224 | return err; | ||
225 | err_remove_interfmode: | ||
226 | device_remove_file(dev, &dev_attr_interference); | ||
227 | goto out; | ||
228 | } | 142 | } |
229 | 143 | ||
230 | void b43_sysfs_unregister(struct b43_wldev *wldev) | 144 | void b43_sysfs_unregister(struct b43_wldev *wldev) |
231 | { | 145 | { |
232 | struct device *dev = wldev->dev->dev; | 146 | struct device *dev = wldev->dev->dev; |
233 | 147 | ||
234 | device_remove_file(dev, &dev_attr_shortpreamble); | ||
235 | device_remove_file(dev, &dev_attr_interference); | 148 | device_remove_file(dev, &dev_attr_interference); |
236 | } | 149 | } |
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c index 7caa26eb4105..4014b6c8272b 100644 --- a/drivers/net/wireless/b43/xmit.c +++ b/drivers/net/wireless/b43/xmit.c | |||
@@ -32,46 +32,48 @@ | |||
32 | #include "dma.h" | 32 | #include "dma.h" |
33 | 33 | ||
34 | 34 | ||
35 | /* Extract the bitrate out of a CCK PLCP header. */ | 35 | /* Extract the bitrate index out of a CCK PLCP header. */ |
36 | static u8 b43_plcp_get_bitrate_cck(struct b43_plcp_hdr6 *plcp) | 36 | static int b43_plcp_get_bitrate_idx_cck(struct b43_plcp_hdr6 *plcp) |
37 | { | 37 | { |
38 | switch (plcp->raw[0]) { | 38 | switch (plcp->raw[0]) { |
39 | case 0x0A: | 39 | case 0x0A: |
40 | return B43_CCK_RATE_1MB; | 40 | return 0; |
41 | case 0x14: | 41 | case 0x14: |
42 | return B43_CCK_RATE_2MB; | 42 | return 1; |
43 | case 0x37: | 43 | case 0x37: |
44 | return B43_CCK_RATE_5MB; | 44 | return 2; |
45 | case 0x6E: | 45 | case 0x6E: |
46 | return B43_CCK_RATE_11MB; | 46 | return 3; |
47 | } | 47 | } |
48 | B43_WARN_ON(1); | 48 | B43_WARN_ON(1); |
49 | return 0; | 49 | return -1; |
50 | } | 50 | } |
51 | 51 | ||
52 | /* Extract the bitrate out of an OFDM PLCP header. */ | 52 | /* Extract the bitrate index out of an OFDM PLCP header. */ |
53 | static u8 b43_plcp_get_bitrate_ofdm(struct b43_plcp_hdr6 *plcp) | 53 | static u8 b43_plcp_get_bitrate_idx_ofdm(struct b43_plcp_hdr6 *plcp, bool aphy) |
54 | { | 54 | { |
55 | int base = aphy ? 0 : 4; | ||
56 | |||
55 | switch (plcp->raw[0] & 0xF) { | 57 | switch (plcp->raw[0] & 0xF) { |
56 | case 0xB: | 58 | case 0xB: |
57 | return B43_OFDM_RATE_6MB; | 59 | return base + 0; |
58 | case 0xF: | 60 | case 0xF: |
59 | return B43_OFDM_RATE_9MB; | 61 | return base + 1; |
60 | case 0xA: | 62 | case 0xA: |
61 | return B43_OFDM_RATE_12MB; | 63 | return base + 2; |
62 | case 0xE: | 64 | case 0xE: |
63 | return B43_OFDM_RATE_18MB; | 65 | return base + 3; |
64 | case 0x9: | 66 | case 0x9: |
65 | return B43_OFDM_RATE_24MB; | 67 | return base + 4; |
66 | case 0xD: | 68 | case 0xD: |
67 | return B43_OFDM_RATE_36MB; | 69 | return base + 5; |
68 | case 0x8: | 70 | case 0x8: |
69 | return B43_OFDM_RATE_48MB; | 71 | return base + 6; |
70 | case 0xC: | 72 | case 0xC: |
71 | return B43_OFDM_RATE_54MB; | 73 | return base + 7; |
72 | } | 74 | } |
73 | B43_WARN_ON(1); | 75 | B43_WARN_ON(1); |
74 | return 0; | 76 | return -1; |
75 | } | 77 | } |
76 | 78 | ||
77 | u8 b43_plcp_get_ratecode_cck(const u8 bitrate) | 79 | u8 b43_plcp_get_ratecode_cck(const u8 bitrate) |
@@ -191,6 +193,7 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
191 | (const struct ieee80211_hdr *)fragment_data; | 193 | (const struct ieee80211_hdr *)fragment_data; |
192 | int use_encryption = (!(txctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)); | 194 | int use_encryption = (!(txctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)); |
193 | u16 fctl = le16_to_cpu(wlhdr->frame_control); | 195 | u16 fctl = le16_to_cpu(wlhdr->frame_control); |
196 | struct ieee80211_rate *fbrate; | ||
194 | u8 rate, rate_fb; | 197 | u8 rate, rate_fb; |
195 | int rate_ofdm, rate_fb_ofdm; | 198 | int rate_ofdm, rate_fb_ofdm; |
196 | unsigned int plcp_fragment_len; | 199 | unsigned int plcp_fragment_len; |
@@ -200,9 +203,11 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
200 | 203 | ||
201 | memset(txhdr, 0, sizeof(*txhdr)); | 204 | memset(txhdr, 0, sizeof(*txhdr)); |
202 | 205 | ||
203 | rate = txctl->tx_rate; | 206 | WARN_ON(!txctl->tx_rate); |
207 | rate = txctl->tx_rate ? txctl->tx_rate->hw_value : B43_CCK_RATE_1MB; | ||
204 | rate_ofdm = b43_is_ofdm_rate(rate); | 208 | rate_ofdm = b43_is_ofdm_rate(rate); |
205 | rate_fb = (txctl->alt_retry_rate == -1) ? rate : txctl->alt_retry_rate; | 209 | fbrate = txctl->alt_retry_rate ? : txctl->tx_rate; |
210 | rate_fb = fbrate->hw_value; | ||
206 | rate_fb_ofdm = b43_is_ofdm_rate(rate_fb); | 211 | rate_fb_ofdm = b43_is_ofdm_rate(rate_fb); |
207 | 212 | ||
208 | if (rate_ofdm) | 213 | if (rate_ofdm) |
@@ -221,11 +226,10 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
221 | * use the original dur_id field. */ | 226 | * use the original dur_id field. */ |
222 | txhdr->dur_fb = wlhdr->duration_id; | 227 | txhdr->dur_fb = wlhdr->duration_id; |
223 | } else { | 228 | } else { |
224 | int fbrate_base100kbps = B43_RATE_TO_BASE100KBPS(rate_fb); | ||
225 | txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw, | 229 | txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw, |
226 | txctl->vif, | 230 | txctl->vif, |
227 | fragment_len, | 231 | fragment_len, |
228 | fbrate_base100kbps); | 232 | fbrate); |
229 | } | 233 | } |
230 | 234 | ||
231 | plcp_fragment_len = fragment_len + FCS_LEN; | 235 | plcp_fragment_len = fragment_len + FCS_LEN; |
@@ -287,7 +291,7 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
287 | phy_ctl |= B43_TXH_PHY_ENC_OFDM; | 291 | phy_ctl |= B43_TXH_PHY_ENC_OFDM; |
288 | else | 292 | else |
289 | phy_ctl |= B43_TXH_PHY_ENC_CCK; | 293 | phy_ctl |= B43_TXH_PHY_ENC_CCK; |
290 | if (dev->short_preamble) | 294 | if (txctl->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) |
291 | phy_ctl |= B43_TXH_PHY_SHORTPRMBL; | 295 | phy_ctl |= B43_TXH_PHY_SHORTPRMBL; |
292 | 296 | ||
293 | switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) { | 297 | switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) { |
@@ -332,7 +336,8 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
332 | int rts_rate_ofdm, rts_rate_fb_ofdm; | 336 | int rts_rate_ofdm, rts_rate_fb_ofdm; |
333 | struct b43_plcp_hdr6 *plcp; | 337 | struct b43_plcp_hdr6 *plcp; |
334 | 338 | ||
335 | rts_rate = txctl->rts_cts_rate; | 339 | WARN_ON(!txctl->rts_cts_rate); |
340 | rts_rate = txctl->rts_cts_rate ? txctl->rts_cts_rate->hw_value : B43_CCK_RATE_1MB; | ||
336 | rts_rate_ofdm = b43_is_ofdm_rate(rts_rate); | 341 | rts_rate_ofdm = b43_is_ofdm_rate(rts_rate); |
337 | rts_rate_fb = b43_calc_fallback_rate(rts_rate); | 342 | rts_rate_fb = b43_calc_fallback_rate(rts_rate); |
338 | rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb); | 343 | rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb); |
@@ -506,6 +511,7 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) | |||
506 | u16 phystat0, phystat3, chanstat, mactime; | 511 | u16 phystat0, phystat3, chanstat, mactime; |
507 | u32 macstat; | 512 | u32 macstat; |
508 | u16 chanid; | 513 | u16 chanid; |
514 | u16 phytype; | ||
509 | u8 jssi; | 515 | u8 jssi; |
510 | int padding; | 516 | int padding; |
511 | 517 | ||
@@ -518,6 +524,7 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) | |||
518 | macstat = le32_to_cpu(rxhdr->mac_status); | 524 | macstat = le32_to_cpu(rxhdr->mac_status); |
519 | mactime = le16_to_cpu(rxhdr->mac_time); | 525 | mactime = le16_to_cpu(rxhdr->mac_time); |
520 | chanstat = le16_to_cpu(rxhdr->channel); | 526 | chanstat = le16_to_cpu(rxhdr->channel); |
527 | phytype = chanstat & B43_RX_CHAN_PHYTYPE; | ||
521 | 528 | ||
522 | if (macstat & B43_RX_MAC_FCSERR) | 529 | if (macstat & B43_RX_MAC_FCSERR) |
523 | dev->wl->ieee_stats.dot11FCSErrorCount++; | 530 | dev->wl->ieee_stats.dot11FCSErrorCount++; |
@@ -575,9 +582,10 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) | |||
575 | /* the next line looks wrong, but is what mac80211 wants */ | 582 | /* the next line looks wrong, but is what mac80211 wants */ |
576 | status.signal = (jssi * 100) / B43_RX_MAX_SSI; | 583 | status.signal = (jssi * 100) / B43_RX_MAX_SSI; |
577 | if (phystat0 & B43_RX_PHYST0_OFDM) | 584 | if (phystat0 & B43_RX_PHYST0_OFDM) |
578 | status.rate = b43_plcp_get_bitrate_ofdm(plcp); | 585 | status.rate_idx = b43_plcp_get_bitrate_idx_ofdm(plcp, |
586 | phytype == B43_PHYTYPE_A); | ||
579 | else | 587 | else |
580 | status.rate = b43_plcp_get_bitrate_cck(plcp); | 588 | status.rate_idx = b43_plcp_get_bitrate_idx_cck(plcp); |
581 | status.antenna = !!(phystat0 & B43_RX_PHYST0_ANT); | 589 | status.antenna = !!(phystat0 & B43_RX_PHYST0_ANT); |
582 | 590 | ||
583 | /* | 591 | /* |
@@ -601,29 +609,28 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) | |||
601 | chanid = (chanstat & B43_RX_CHAN_ID) >> B43_RX_CHAN_ID_SHIFT; | 609 | chanid = (chanstat & B43_RX_CHAN_ID) >> B43_RX_CHAN_ID_SHIFT; |
602 | switch (chanstat & B43_RX_CHAN_PHYTYPE) { | 610 | switch (chanstat & B43_RX_CHAN_PHYTYPE) { |
603 | case B43_PHYTYPE_A: | 611 | case B43_PHYTYPE_A: |
604 | status.phymode = MODE_IEEE80211A; | 612 | status.band = IEEE80211_BAND_5GHZ; |
605 | B43_WARN_ON(1); | 613 | B43_WARN_ON(1); |
606 | /* FIXME: We don't really know which value the "chanid" contains. | 614 | /* FIXME: We don't really know which value the "chanid" contains. |
607 | * So the following assignment might be wrong. */ | 615 | * So the following assignment might be wrong. */ |
608 | status.channel = chanid; | 616 | status.freq = b43_channel_to_freq_5ghz(chanid); |
609 | status.freq = b43_channel_to_freq_5ghz(status.channel); | ||
610 | break; | 617 | break; |
611 | case B43_PHYTYPE_G: | 618 | case B43_PHYTYPE_G: |
612 | status.phymode = MODE_IEEE80211G; | 619 | status.band = IEEE80211_BAND_2GHZ; |
613 | /* chanid is the radio channel cookie value as used | 620 | /* chanid is the radio channel cookie value as used |
614 | * to tune the radio. */ | 621 | * to tune the radio. */ |
615 | status.freq = chanid + 2400; | 622 | status.freq = chanid + 2400; |
616 | status.channel = b43_freq_to_channel_2ghz(status.freq); | ||
617 | break; | 623 | break; |
618 | case B43_PHYTYPE_N: | 624 | case B43_PHYTYPE_N: |
619 | status.phymode = 0xDEAD /*FIXME MODE_IEEE80211N*/; | ||
620 | /* chanid is the SHM channel cookie. Which is the plain | 625 | /* chanid is the SHM channel cookie. Which is the plain |
621 | * channel number in b43. */ | 626 | * channel number in b43. */ |
622 | status.channel = chanid; | 627 | if (chanstat & B43_RX_CHAN_5GHZ) { |
623 | if (chanstat & B43_RX_CHAN_5GHZ) | 628 | status.band = IEEE80211_BAND_5GHZ; |
624 | status.freq = b43_freq_to_channel_5ghz(status.freq); | 629 | status.freq = b43_freq_to_channel_5ghz(chanid); |
625 | else | 630 | } else { |
626 | status.freq = b43_freq_to_channel_2ghz(status.freq); | 631 | status.band = IEEE80211_BAND_2GHZ; |
632 | status.freq = b43_freq_to_channel_2ghz(chanid); | ||
633 | } | ||
627 | break; | 634 | break; |
628 | default: | 635 | default: |
629 | B43_WARN_ON(1); | 636 | B43_WARN_ON(1); |
diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h index 93d45b71799a..5f217d6d2e6a 100644 --- a/drivers/net/wireless/b43legacy/b43legacy.h +++ b/drivers/net/wireless/b43legacy/b43legacy.h | |||
@@ -392,10 +392,6 @@ struct b43legacy_phy { | |||
392 | u8 possible_phymodes; | 392 | u8 possible_phymodes; |
393 | /* GMODE bit enabled in MACCTL? */ | 393 | /* GMODE bit enabled in MACCTL? */ |
394 | bool gmode; | 394 | bool gmode; |
395 | /* Possible ieee80211 subsystem hwmodes for this PHY. | ||
396 | * Which mode is selected, depends on thr GMODE enabled bit */ | ||
397 | #define B43legacy_MAX_PHYHWMODES 2 | ||
398 | struct ieee80211_hw_mode hwmodes[B43legacy_MAX_PHYHWMODES]; | ||
399 | 395 | ||
400 | /* Analog Type */ | 396 | /* Analog Type */ |
401 | u8 analog; | 397 | u8 analog; |
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index c39de422e220..d2a72a2cd178 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c | |||
@@ -95,28 +95,29 @@ MODULE_DEVICE_TABLE(ssb, b43legacy_ssb_tbl); | |||
95 | * data in there. This data is the same for all devices, so we don't | 95 | * data in there. This data is the same for all devices, so we don't |
96 | * get concurrency issues */ | 96 | * get concurrency issues */ |
97 | #define RATETAB_ENT(_rateid, _flags) \ | 97 | #define RATETAB_ENT(_rateid, _flags) \ |
98 | { \ | 98 | { \ |
99 | .rate = B43legacy_RATE_TO_100KBPS(_rateid), \ | 99 | .bitrate = B43legacy_RATE_TO_100KBPS(_rateid), \ |
100 | .val = (_rateid), \ | 100 | .hw_value = (_rateid), \ |
101 | .val2 = (_rateid), \ | 101 | .flags = (_flags), \ |
102 | .flags = (_flags), \ | ||
103 | } | 102 | } |
103 | /* | ||
104 | * NOTE: When changing this, sync with xmit.c's | ||
105 | * b43legacy_plcp_get_bitrate_idx_* functions! | ||
106 | */ | ||
104 | static struct ieee80211_rate __b43legacy_ratetable[] = { | 107 | static struct ieee80211_rate __b43legacy_ratetable[] = { |
105 | RATETAB_ENT(B43legacy_CCK_RATE_1MB, IEEE80211_RATE_CCK), | 108 | RATETAB_ENT(B43legacy_CCK_RATE_1MB, 0), |
106 | RATETAB_ENT(B43legacy_CCK_RATE_2MB, IEEE80211_RATE_CCK_2), | 109 | RATETAB_ENT(B43legacy_CCK_RATE_2MB, IEEE80211_RATE_SHORT_PREAMBLE), |
107 | RATETAB_ENT(B43legacy_CCK_RATE_5MB, IEEE80211_RATE_CCK_2), | 110 | RATETAB_ENT(B43legacy_CCK_RATE_5MB, IEEE80211_RATE_SHORT_PREAMBLE), |
108 | RATETAB_ENT(B43legacy_CCK_RATE_11MB, IEEE80211_RATE_CCK_2), | 111 | RATETAB_ENT(B43legacy_CCK_RATE_11MB, IEEE80211_RATE_SHORT_PREAMBLE), |
109 | RATETAB_ENT(B43legacy_OFDM_RATE_6MB, IEEE80211_RATE_OFDM), | 112 | RATETAB_ENT(B43legacy_OFDM_RATE_6MB, 0), |
110 | RATETAB_ENT(B43legacy_OFDM_RATE_9MB, IEEE80211_RATE_OFDM), | 113 | RATETAB_ENT(B43legacy_OFDM_RATE_9MB, 0), |
111 | RATETAB_ENT(B43legacy_OFDM_RATE_12MB, IEEE80211_RATE_OFDM), | 114 | RATETAB_ENT(B43legacy_OFDM_RATE_12MB, 0), |
112 | RATETAB_ENT(B43legacy_OFDM_RATE_18MB, IEEE80211_RATE_OFDM), | 115 | RATETAB_ENT(B43legacy_OFDM_RATE_18MB, 0), |
113 | RATETAB_ENT(B43legacy_OFDM_RATE_24MB, IEEE80211_RATE_OFDM), | 116 | RATETAB_ENT(B43legacy_OFDM_RATE_24MB, 0), |
114 | RATETAB_ENT(B43legacy_OFDM_RATE_36MB, IEEE80211_RATE_OFDM), | 117 | RATETAB_ENT(B43legacy_OFDM_RATE_36MB, 0), |
115 | RATETAB_ENT(B43legacy_OFDM_RATE_48MB, IEEE80211_RATE_OFDM), | 118 | RATETAB_ENT(B43legacy_OFDM_RATE_48MB, 0), |
116 | RATETAB_ENT(B43legacy_OFDM_RATE_54MB, IEEE80211_RATE_OFDM), | 119 | RATETAB_ENT(B43legacy_OFDM_RATE_54MB, 0), |
117 | }; | 120 | }; |
118 | #define b43legacy_a_ratetable (__b43legacy_ratetable + 4) | ||
119 | #define b43legacy_a_ratetable_size 8 | ||
120 | #define b43legacy_b_ratetable (__b43legacy_ratetable + 0) | 121 | #define b43legacy_b_ratetable (__b43legacy_ratetable + 0) |
121 | #define b43legacy_b_ratetable_size 4 | 122 | #define b43legacy_b_ratetable_size 4 |
122 | #define b43legacy_g_ratetable (__b43legacy_ratetable + 0) | 123 | #define b43legacy_g_ratetable (__b43legacy_ratetable + 0) |
@@ -124,14 +125,8 @@ static struct ieee80211_rate __b43legacy_ratetable[] = { | |||
124 | 125 | ||
125 | #define CHANTAB_ENT(_chanid, _freq) \ | 126 | #define CHANTAB_ENT(_chanid, _freq) \ |
126 | { \ | 127 | { \ |
127 | .chan = (_chanid), \ | 128 | .center_freq = (_freq), \ |
128 | .freq = (_freq), \ | 129 | .hw_value = (_chanid), \ |
129 | .val = (_chanid), \ | ||
130 | .flag = IEEE80211_CHAN_W_SCAN | \ | ||
131 | IEEE80211_CHAN_W_ACTIVE_SCAN | \ | ||
132 | IEEE80211_CHAN_W_IBSS, \ | ||
133 | .power_level = 0x0A, \ | ||
134 | .antenna_max = 0xFF, \ | ||
135 | } | 130 | } |
136 | static struct ieee80211_channel b43legacy_bg_chantable[] = { | 131 | static struct ieee80211_channel b43legacy_bg_chantable[] = { |
137 | CHANTAB_ENT(1, 2412), | 132 | CHANTAB_ENT(1, 2412), |
@@ -149,7 +144,20 @@ static struct ieee80211_channel b43legacy_bg_chantable[] = { | |||
149 | CHANTAB_ENT(13, 2472), | 144 | CHANTAB_ENT(13, 2472), |
150 | CHANTAB_ENT(14, 2484), | 145 | CHANTAB_ENT(14, 2484), |
151 | }; | 146 | }; |
152 | #define b43legacy_bg_chantable_size ARRAY_SIZE(b43legacy_bg_chantable) | 147 | |
148 | static struct ieee80211_supported_band b43legacy_band_2GHz_BPHY = { | ||
149 | .channels = b43legacy_bg_chantable, | ||
150 | .n_channels = ARRAY_SIZE(b43legacy_bg_chantable), | ||
151 | .bitrates = b43legacy_b_ratetable, | ||
152 | .n_bitrates = b43legacy_b_ratetable_size, | ||
153 | }; | ||
154 | |||
155 | static struct ieee80211_supported_band b43legacy_band_2GHz_GPHY = { | ||
156 | .channels = b43legacy_bg_chantable, | ||
157 | .n_channels = ARRAY_SIZE(b43legacy_bg_chantable), | ||
158 | .bitrates = b43legacy_g_ratetable, | ||
159 | .n_bitrates = b43legacy_g_ratetable_size, | ||
160 | }; | ||
153 | 161 | ||
154 | static void b43legacy_wireless_core_exit(struct b43legacy_wldev *dev); | 162 | static void b43legacy_wireless_core_exit(struct b43legacy_wldev *dev); |
155 | static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev); | 163 | static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev); |
@@ -969,18 +977,18 @@ static void b43legacy_write_beacon_template(struct b43legacy_wldev *dev, | |||
969 | 977 | ||
970 | static void b43legacy_write_probe_resp_plcp(struct b43legacy_wldev *dev, | 978 | static void b43legacy_write_probe_resp_plcp(struct b43legacy_wldev *dev, |
971 | u16 shm_offset, u16 size, | 979 | u16 shm_offset, u16 size, |
972 | u8 rate) | 980 | struct ieee80211_rate *rate) |
973 | { | 981 | { |
974 | struct b43legacy_plcp_hdr4 plcp; | 982 | struct b43legacy_plcp_hdr4 plcp; |
975 | u32 tmp; | 983 | u32 tmp; |
976 | __le16 dur; | 984 | __le16 dur; |
977 | 985 | ||
978 | plcp.data = 0; | 986 | plcp.data = 0; |
979 | b43legacy_generate_plcp_hdr(&plcp, size + FCS_LEN, rate); | 987 | b43legacy_generate_plcp_hdr(&plcp, size + FCS_LEN, rate->bitrate); |
980 | dur = ieee80211_generic_frame_duration(dev->wl->hw, | 988 | dur = ieee80211_generic_frame_duration(dev->wl->hw, |
981 | dev->wl->vif, | 989 | dev->wl->vif, |
982 | size, | 990 | size, |
983 | B43legacy_RATE_TO_100KBPS(rate)); | 991 | rate); |
984 | /* Write PLCP in two parts and timing for packet transfer */ | 992 | /* Write PLCP in two parts and timing for packet transfer */ |
985 | tmp = le32_to_cpu(plcp.data); | 993 | tmp = le32_to_cpu(plcp.data); |
986 | b43legacy_shm_write16(dev, B43legacy_SHM_SHARED, shm_offset, | 994 | b43legacy_shm_write16(dev, B43legacy_SHM_SHARED, shm_offset, |
@@ -998,7 +1006,8 @@ static void b43legacy_write_probe_resp_plcp(struct b43legacy_wldev *dev, | |||
998 | * 3) Stripping TIM | 1006 | * 3) Stripping TIM |
999 | */ | 1007 | */ |
1000 | static u8 *b43legacy_generate_probe_resp(struct b43legacy_wldev *dev, | 1008 | static u8 *b43legacy_generate_probe_resp(struct b43legacy_wldev *dev, |
1001 | u16 *dest_size, u8 rate) | 1009 | u16 *dest_size, |
1010 | struct ieee80211_rate *rate) | ||
1002 | { | 1011 | { |
1003 | const u8 *src_data; | 1012 | const u8 *src_data; |
1004 | u8 *dest_data; | 1013 | u8 *dest_data; |
@@ -1046,7 +1055,7 @@ static u8 *b43legacy_generate_probe_resp(struct b43legacy_wldev *dev, | |||
1046 | dur = ieee80211_generic_frame_duration(dev->wl->hw, | 1055 | dur = ieee80211_generic_frame_duration(dev->wl->hw, |
1047 | dev->wl->vif, | 1056 | dev->wl->vif, |
1048 | *dest_size, | 1057 | *dest_size, |
1049 | B43legacy_RATE_TO_100KBPS(rate)); | 1058 | rate); |
1050 | hdr->duration_id = dur; | 1059 | hdr->duration_id = dur; |
1051 | 1060 | ||
1052 | return dest_data; | 1061 | return dest_data; |
@@ -1054,7 +1063,8 @@ static u8 *b43legacy_generate_probe_resp(struct b43legacy_wldev *dev, | |||
1054 | 1063 | ||
1055 | static void b43legacy_write_probe_resp_template(struct b43legacy_wldev *dev, | 1064 | static void b43legacy_write_probe_resp_template(struct b43legacy_wldev *dev, |
1056 | u16 ram_offset, | 1065 | u16 ram_offset, |
1057 | u16 shm_size_offset, u8 rate) | 1066 | u16 shm_size_offset, |
1067 | struct ieee80211_rate *rate) | ||
1058 | { | 1068 | { |
1059 | u8 *probe_resp_data; | 1069 | u8 *probe_resp_data; |
1060 | u16 size; | 1070 | u16 size; |
@@ -1069,19 +1079,19 @@ static void b43legacy_write_probe_resp_template(struct b43legacy_wldev *dev, | |||
1069 | * all possible basic rates | 1079 | * all possible basic rates |
1070 | */ | 1080 | */ |
1071 | b43legacy_write_probe_resp_plcp(dev, 0x31A, size, | 1081 | b43legacy_write_probe_resp_plcp(dev, 0x31A, size, |
1072 | B43legacy_CCK_RATE_1MB); | 1082 | &b43legacy_b_ratetable[0]); |
1073 | b43legacy_write_probe_resp_plcp(dev, 0x32C, size, | 1083 | b43legacy_write_probe_resp_plcp(dev, 0x32C, size, |
1074 | B43legacy_CCK_RATE_2MB); | 1084 | &b43legacy_b_ratetable[1]); |
1075 | b43legacy_write_probe_resp_plcp(dev, 0x33E, size, | 1085 | b43legacy_write_probe_resp_plcp(dev, 0x33E, size, |
1076 | B43legacy_CCK_RATE_5MB); | 1086 | &b43legacy_b_ratetable[2]); |
1077 | b43legacy_write_probe_resp_plcp(dev, 0x350, size, | 1087 | b43legacy_write_probe_resp_plcp(dev, 0x350, size, |
1078 | B43legacy_CCK_RATE_11MB); | 1088 | &b43legacy_b_ratetable[3]); |
1079 | 1089 | ||
1080 | size = min((size_t)size, | 1090 | size = min((size_t)size, |
1081 | 0x200 - sizeof(struct b43legacy_plcp_hdr6)); | 1091 | 0x200 - sizeof(struct b43legacy_plcp_hdr6)); |
1082 | b43legacy_write_template_common(dev, probe_resp_data, | 1092 | b43legacy_write_template_common(dev, probe_resp_data, |
1083 | size, ram_offset, | 1093 | size, ram_offset, |
1084 | shm_size_offset, rate); | 1094 | shm_size_offset, rate->bitrate); |
1085 | kfree(probe_resp_data); | 1095 | kfree(probe_resp_data); |
1086 | } | 1096 | } |
1087 | 1097 | ||
@@ -1106,7 +1116,7 @@ static void b43legacy_update_templates(struct b43legacy_wldev *dev) | |||
1106 | b43legacy_write_beacon_template(dev, 0x468, 0x1A, | 1116 | b43legacy_write_beacon_template(dev, 0x468, 0x1A, |
1107 | B43legacy_CCK_RATE_1MB); | 1117 | B43legacy_CCK_RATE_1MB); |
1108 | b43legacy_write_probe_resp_template(dev, 0x268, 0x4A, | 1118 | b43legacy_write_probe_resp_template(dev, 0x268, 0x4A, |
1109 | B43legacy_CCK_RATE_11MB); | 1119 | &b43legacy_b_ratetable[0]); |
1110 | 1120 | ||
1111 | status = b43legacy_read32(dev, B43legacy_MMIO_MACCMD); | 1121 | status = b43legacy_read32(dev, B43legacy_MMIO_MACCMD); |
1112 | status |= 0x03; | 1122 | status |= 0x03; |
@@ -2550,14 +2560,16 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw, | |||
2550 | antenna_rx = b43legacy_antenna_from_ieee80211(conf->antenna_sel_rx); | 2560 | antenna_rx = b43legacy_antenna_from_ieee80211(conf->antenna_sel_rx); |
2551 | 2561 | ||
2552 | mutex_lock(&wl->mutex); | 2562 | mutex_lock(&wl->mutex); |
2563 | dev = wl->current_dev; | ||
2564 | phy = &dev->phy; | ||
2553 | 2565 | ||
2554 | /* Switch the PHY mode (if necessary). */ | 2566 | /* Switch the PHY mode (if necessary). */ |
2555 | switch (conf->phymode) { | 2567 | switch (conf->channel->band) { |
2556 | case MODE_IEEE80211B: | 2568 | case IEEE80211_BAND_2GHZ: |
2557 | new_phymode = B43legacy_PHYMODE_B; | 2569 | if (phy->type == B43legacy_PHYTYPE_B) |
2558 | break; | 2570 | new_phymode = B43legacy_PHYMODE_B; |
2559 | case MODE_IEEE80211G: | 2571 | else |
2560 | new_phymode = B43legacy_PHYMODE_G; | 2572 | new_phymode = B43legacy_PHYMODE_G; |
2561 | break; | 2573 | break; |
2562 | default: | 2574 | default: |
2563 | B43legacy_WARN_ON(1); | 2575 | B43legacy_WARN_ON(1); |
@@ -2565,8 +2577,6 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw, | |||
2565 | err = b43legacy_switch_phymode(wl, new_phymode); | 2577 | err = b43legacy_switch_phymode(wl, new_phymode); |
2566 | if (err) | 2578 | if (err) |
2567 | goto out_unlock_mutex; | 2579 | goto out_unlock_mutex; |
2568 | dev = wl->current_dev; | ||
2569 | phy = &dev->phy; | ||
2570 | 2580 | ||
2571 | /* Disable IRQs while reconfiguring the device. | 2581 | /* Disable IRQs while reconfiguring the device. |
2572 | * This makes it possible to drop the spinlock throughout | 2582 | * This makes it possible to drop the spinlock throughout |
@@ -2582,8 +2592,8 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw, | |||
2582 | 2592 | ||
2583 | /* Switch to the requested channel. | 2593 | /* Switch to the requested channel. |
2584 | * The firmware takes care of races with the TX handler. */ | 2594 | * The firmware takes care of races with the TX handler. */ |
2585 | if (conf->channel_val != phy->channel) | 2595 | if (conf->channel->hw_value != phy->channel) |
2586 | b43legacy_radio_selectchannel(dev, conf->channel_val, 0); | 2596 | b43legacy_radio_selectchannel(dev, conf->channel->hw_value, 0); |
2587 | 2597 | ||
2588 | /* Enable/Disable ShortSlot timing. */ | 2598 | /* Enable/Disable ShortSlot timing. */ |
2589 | if ((!!(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)) | 2599 | if ((!!(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)) |
@@ -3398,48 +3408,19 @@ static int b43legacy_setup_modes(struct b43legacy_wldev *dev, | |||
3398 | int have_gphy) | 3408 | int have_gphy) |
3399 | { | 3409 | { |
3400 | struct ieee80211_hw *hw = dev->wl->hw; | 3410 | struct ieee80211_hw *hw = dev->wl->hw; |
3401 | struct ieee80211_hw_mode *mode; | ||
3402 | struct b43legacy_phy *phy = &dev->phy; | 3411 | struct b43legacy_phy *phy = &dev->phy; |
3403 | int cnt = 0; | ||
3404 | int err; | ||
3405 | 3412 | ||
3406 | phy->possible_phymodes = 0; | 3413 | phy->possible_phymodes = 0; |
3407 | for (; 1; cnt++) { | 3414 | if (have_bphy) { |
3408 | if (have_bphy) { | 3415 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
3409 | B43legacy_WARN_ON(cnt >= B43legacy_MAX_PHYHWMODES); | 3416 | &b43legacy_band_2GHz_BPHY; |
3410 | mode = &phy->hwmodes[cnt]; | 3417 | phy->possible_phymodes |= B43legacy_PHYMODE_B; |
3411 | 3418 | } | |
3412 | mode->mode = MODE_IEEE80211B; | 3419 | |
3413 | mode->num_channels = b43legacy_bg_chantable_size; | 3420 | if (have_gphy) { |
3414 | mode->channels = b43legacy_bg_chantable; | 3421 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
3415 | mode->num_rates = b43legacy_b_ratetable_size; | 3422 | &b43legacy_band_2GHz_GPHY; |
3416 | mode->rates = b43legacy_b_ratetable; | 3423 | phy->possible_phymodes |= B43legacy_PHYMODE_G; |
3417 | err = ieee80211_register_hwmode(hw, mode); | ||
3418 | if (err) | ||
3419 | return err; | ||
3420 | |||
3421 | phy->possible_phymodes |= B43legacy_PHYMODE_B; | ||
3422 | have_bphy = 0; | ||
3423 | continue; | ||
3424 | } | ||
3425 | if (have_gphy) { | ||
3426 | B43legacy_WARN_ON(cnt >= B43legacy_MAX_PHYHWMODES); | ||
3427 | mode = &phy->hwmodes[cnt]; | ||
3428 | |||
3429 | mode->mode = MODE_IEEE80211G; | ||
3430 | mode->num_channels = b43legacy_bg_chantable_size; | ||
3431 | mode->channels = b43legacy_bg_chantable; | ||
3432 | mode->num_rates = b43legacy_g_ratetable_size; | ||
3433 | mode->rates = b43legacy_g_ratetable; | ||
3434 | err = ieee80211_register_hwmode(hw, mode); | ||
3435 | if (err) | ||
3436 | return err; | ||
3437 | |||
3438 | phy->possible_phymodes |= B43legacy_PHYMODE_G; | ||
3439 | have_gphy = 0; | ||
3440 | continue; | ||
3441 | } | ||
3442 | break; | ||
3443 | } | 3424 | } |
3444 | 3425 | ||
3445 | return 0; | 3426 | return 0; |
diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c index d84408a82db9..47e130e9fdf2 100644 --- a/drivers/net/wireless/b43legacy/xmit.c +++ b/drivers/net/wireless/b43legacy/xmit.c | |||
@@ -37,45 +37,48 @@ | |||
37 | 37 | ||
38 | 38 | ||
39 | /* Extract the bitrate out of a CCK PLCP header. */ | 39 | /* Extract the bitrate out of a CCK PLCP header. */ |
40 | static u8 b43legacy_plcp_get_bitrate_cck(struct b43legacy_plcp_hdr6 *plcp) | 40 | static u8 b43legacy_plcp_get_bitrate_idx_cck(struct b43legacy_plcp_hdr6 *plcp) |
41 | { | 41 | { |
42 | switch (plcp->raw[0]) { | 42 | switch (plcp->raw[0]) { |
43 | case 0x0A: | 43 | case 0x0A: |
44 | return B43legacy_CCK_RATE_1MB; | 44 | return 0; |
45 | case 0x14: | 45 | case 0x14: |
46 | return B43legacy_CCK_RATE_2MB; | 46 | return 1; |
47 | case 0x37: | 47 | case 0x37: |
48 | return B43legacy_CCK_RATE_5MB; | 48 | return 2; |
49 | case 0x6E: | 49 | case 0x6E: |
50 | return B43legacy_CCK_RATE_11MB; | 50 | return 3; |
51 | } | 51 | } |
52 | B43legacy_BUG_ON(1); | 52 | B43legacy_BUG_ON(1); |
53 | return 0; | 53 | return -1; |
54 | } | 54 | } |
55 | 55 | ||
56 | /* Extract the bitrate out of an OFDM PLCP header. */ | 56 | /* Extract the bitrate out of an OFDM PLCP header. */ |
57 | static u8 b43legacy_plcp_get_bitrate_ofdm(struct b43legacy_plcp_hdr6 *plcp) | 57 | static u8 b43legacy_plcp_get_bitrate_idx_ofdm(struct b43legacy_plcp_hdr6 *plcp, |
58 | bool aphy) | ||
58 | { | 59 | { |
60 | int base = aphy ? 0 : 4; | ||
61 | |||
59 | switch (plcp->raw[0] & 0xF) { | 62 | switch (plcp->raw[0] & 0xF) { |
60 | case 0xB: | 63 | case 0xB: |
61 | return B43legacy_OFDM_RATE_6MB; | 64 | return base + 0; |
62 | case 0xF: | 65 | case 0xF: |
63 | return B43legacy_OFDM_RATE_9MB; | 66 | return base + 1; |
64 | case 0xA: | 67 | case 0xA: |
65 | return B43legacy_OFDM_RATE_12MB; | 68 | return base + 2; |
66 | case 0xE: | 69 | case 0xE: |
67 | return B43legacy_OFDM_RATE_18MB; | 70 | return base + 3; |
68 | case 0x9: | 71 | case 0x9: |
69 | return B43legacy_OFDM_RATE_24MB; | 72 | return base + 4; |
70 | case 0xD: | 73 | case 0xD: |
71 | return B43legacy_OFDM_RATE_36MB; | 74 | return base + 5; |
72 | case 0x8: | 75 | case 0x8: |
73 | return B43legacy_OFDM_RATE_48MB; | 76 | return base + 6; |
74 | case 0xC: | 77 | case 0xC: |
75 | return B43legacy_OFDM_RATE_54MB; | 78 | return base + 7; |
76 | } | 79 | } |
77 | B43legacy_BUG_ON(1); | 80 | B43legacy_BUG_ON(1); |
78 | return 0; | 81 | return -1; |
79 | } | 82 | } |
80 | 83 | ||
81 | u8 b43legacy_plcp_get_ratecode_cck(const u8 bitrate) | 84 | u8 b43legacy_plcp_get_ratecode_cck(const u8 bitrate) |
@@ -192,7 +195,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
192 | int use_encryption = (!(txctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)); | 195 | int use_encryption = (!(txctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)); |
193 | u16 fctl; | 196 | u16 fctl; |
194 | u8 rate; | 197 | u8 rate; |
195 | u8 rate_fb; | 198 | struct ieee80211_rate *rate_fb; |
196 | int rate_ofdm; | 199 | int rate_ofdm; |
197 | int rate_fb_ofdm; | 200 | int rate_fb_ofdm; |
198 | unsigned int plcp_fragment_len; | 201 | unsigned int plcp_fragment_len; |
@@ -204,16 +207,16 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
204 | 207 | ||
205 | memset(txhdr, 0, sizeof(*txhdr)); | 208 | memset(txhdr, 0, sizeof(*txhdr)); |
206 | 209 | ||
207 | rate = txctl->tx_rate; | 210 | rate = txctl->tx_rate->hw_value; |
208 | rate_ofdm = b43legacy_is_ofdm_rate(rate); | 211 | rate_ofdm = b43legacy_is_ofdm_rate(rate); |
209 | rate_fb = (txctl->alt_retry_rate == -1) ? rate : txctl->alt_retry_rate; | 212 | rate_fb = txctl->alt_retry_rate ? : txctl->tx_rate; |
210 | rate_fb_ofdm = b43legacy_is_ofdm_rate(rate_fb); | 213 | rate_fb_ofdm = b43legacy_is_ofdm_rate(rate_fb->hw_value); |
211 | 214 | ||
212 | txhdr->mac_frame_ctl = wlhdr->frame_control; | 215 | txhdr->mac_frame_ctl = wlhdr->frame_control; |
213 | memcpy(txhdr->tx_receiver, wlhdr->addr1, 6); | 216 | memcpy(txhdr->tx_receiver, wlhdr->addr1, 6); |
214 | 217 | ||
215 | /* Calculate duration for fallback rate */ | 218 | /* Calculate duration for fallback rate */ |
216 | if ((rate_fb == rate) || | 219 | if ((rate_fb->hw_value == rate) || |
217 | (wlhdr->duration_id & cpu_to_le16(0x8000)) || | 220 | (wlhdr->duration_id & cpu_to_le16(0x8000)) || |
218 | (wlhdr->duration_id == cpu_to_le16(0))) { | 221 | (wlhdr->duration_id == cpu_to_le16(0))) { |
219 | /* If the fallback rate equals the normal rate or the | 222 | /* If the fallback rate equals the normal rate or the |
@@ -221,11 +224,10 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
221 | * use the original dur_id field. */ | 224 | * use the original dur_id field. */ |
222 | txhdr->dur_fb = wlhdr->duration_id; | 225 | txhdr->dur_fb = wlhdr->duration_id; |
223 | } else { | 226 | } else { |
224 | int fbrate_base100kbps = B43legacy_RATE_TO_100KBPS(rate_fb); | ||
225 | txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw, | 227 | txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw, |
226 | txctl->vif, | 228 | txctl->vif, |
227 | fragment_len, | 229 | fragment_len, |
228 | fbrate_base100kbps); | 230 | rate_fb); |
229 | } | 231 | } |
230 | 232 | ||
231 | plcp_fragment_len = fragment_len + FCS_LEN; | 233 | plcp_fragment_len = fragment_len + FCS_LEN; |
@@ -266,7 +268,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
266 | rate); | 268 | rate); |
267 | b43legacy_generate_plcp_hdr((struct b43legacy_plcp_hdr4 *) | 269 | b43legacy_generate_plcp_hdr((struct b43legacy_plcp_hdr4 *) |
268 | (&txhdr->plcp_fb), plcp_fragment_len, | 270 | (&txhdr->plcp_fb), plcp_fragment_len, |
269 | rate_fb); | 271 | rate_fb->hw_value); |
270 | 272 | ||
271 | /* PHY TX Control word */ | 273 | /* PHY TX Control word */ |
272 | if (rate_ofdm) | 274 | if (rate_ofdm) |
@@ -310,7 +312,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
310 | int rts_rate_ofdm; | 312 | int rts_rate_ofdm; |
311 | int rts_rate_fb_ofdm; | 313 | int rts_rate_fb_ofdm; |
312 | 314 | ||
313 | rts_rate = txctl->rts_cts_rate; | 315 | rts_rate = txctl->rts_cts_rate->hw_value; |
314 | rts_rate_ofdm = b43legacy_is_ofdm_rate(rts_rate); | 316 | rts_rate_ofdm = b43legacy_is_ofdm_rate(rts_rate); |
315 | rts_rate_fb = b43legacy_calc_fallback_rate(rts_rate); | 317 | rts_rate_fb = b43legacy_calc_fallback_rate(rts_rate); |
316 | rts_rate_fb_ofdm = b43legacy_is_ofdm_rate(rts_rate_fb); | 318 | rts_rate_fb_ofdm = b43legacy_is_ofdm_rate(rts_rate_fb); |
@@ -536,10 +538,11 @@ void b43legacy_rx(struct b43legacy_wldev *dev, | |||
536 | (phystat3 & B43legacy_RX_PHYST3_TRSTATE)); | 538 | (phystat3 & B43legacy_RX_PHYST3_TRSTATE)); |
537 | status.noise = dev->stats.link_noise; | 539 | status.noise = dev->stats.link_noise; |
538 | status.signal = (jssi * 100) / B43legacy_RX_MAX_SSI; | 540 | status.signal = (jssi * 100) / B43legacy_RX_MAX_SSI; |
541 | /* change to support A PHY */ | ||
539 | if (phystat0 & B43legacy_RX_PHYST0_OFDM) | 542 | if (phystat0 & B43legacy_RX_PHYST0_OFDM) |
540 | status.rate = b43legacy_plcp_get_bitrate_ofdm(plcp); | 543 | status.rate_idx = b43legacy_plcp_get_bitrate_idx_ofdm(plcp, false); |
541 | else | 544 | else |
542 | status.rate = b43legacy_plcp_get_bitrate_cck(plcp); | 545 | status.rate_idx = b43legacy_plcp_get_bitrate_idx_cck(plcp); |
543 | status.antenna = !!(phystat0 & B43legacy_RX_PHYST0_ANT); | 546 | status.antenna = !!(phystat0 & B43legacy_RX_PHYST0_ANT); |
544 | 547 | ||
545 | /* | 548 | /* |
@@ -564,14 +567,9 @@ void b43legacy_rx(struct b43legacy_wldev *dev, | |||
564 | B43legacy_RX_CHAN_ID_SHIFT; | 567 | B43legacy_RX_CHAN_ID_SHIFT; |
565 | switch (chanstat & B43legacy_RX_CHAN_PHYTYPE) { | 568 | switch (chanstat & B43legacy_RX_CHAN_PHYTYPE) { |
566 | case B43legacy_PHYTYPE_B: | 569 | case B43legacy_PHYTYPE_B: |
567 | status.phymode = MODE_IEEE80211B; | ||
568 | status.freq = chanid + 2400; | ||
569 | status.channel = b43legacy_freq_to_channel_bg(chanid + 2400); | ||
570 | break; | ||
571 | case B43legacy_PHYTYPE_G: | 570 | case B43legacy_PHYTYPE_G: |
572 | status.phymode = MODE_IEEE80211G; | 571 | status.band = IEEE80211_BAND_2GHZ; |
573 | status.freq = chanid + 2400; | 572 | status.freq = chanid + 2400; |
574 | status.channel = b43legacy_freq_to_channel_bg(chanid + 2400); | ||
575 | break; | 573 | break; |
576 | default: | 574 | default: |
577 | b43legacywarn(dev->wl, "Unexpected value for chanstat (0x%X)\n", | 575 | b43legacywarn(dev->wl, "Unexpected value for chanstat (0x%X)\n", |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c index 80d31ae51e77..f018ce464d97 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c | |||
@@ -100,14 +100,6 @@ static struct iwl3945_tpt_entry iwl3945_tpt_table_a[] = { | |||
100 | {-89, IWL_RATE_6M_INDEX} | 100 | {-89, IWL_RATE_6M_INDEX} |
101 | }; | 101 | }; |
102 | 102 | ||
103 | static struct iwl3945_tpt_entry iwl3945_tpt_table_b[] = { | ||
104 | {-86, IWL_RATE_11M_INDEX}, | ||
105 | {-88, IWL_RATE_5M_INDEX}, | ||
106 | {-90, IWL_RATE_2M_INDEX}, | ||
107 | {-92, IWL_RATE_1M_INDEX} | ||
108 | |||
109 | }; | ||
110 | |||
111 | static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = { | 103 | static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = { |
112 | {-60, IWL_RATE_54M_INDEX}, | 104 | {-60, IWL_RATE_54M_INDEX}, |
113 | {-64, IWL_RATE_48M_INDEX}, | 105 | {-64, IWL_RATE_48M_INDEX}, |
@@ -129,7 +121,7 @@ static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = { | |||
129 | #define IWL_RATE_MIN_SUCCESS_TH 8 | 121 | #define IWL_RATE_MIN_SUCCESS_TH 8 |
130 | #define IWL_RATE_DECREASE_TH 1920 | 122 | #define IWL_RATE_DECREASE_TH 1920 |
131 | 123 | ||
132 | static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, u8 mode) | 124 | static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) |
133 | { | 125 | { |
134 | u32 index = 0; | 126 | u32 index = 0; |
135 | u32 table_size = 0; | 127 | u32 table_size = 0; |
@@ -138,21 +130,19 @@ static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, u8 mode) | |||
138 | if ((rssi < IWL_MIN_RSSI_VAL) || (rssi > IWL_MAX_RSSI_VAL)) | 130 | if ((rssi < IWL_MIN_RSSI_VAL) || (rssi > IWL_MAX_RSSI_VAL)) |
139 | rssi = IWL_MIN_RSSI_VAL; | 131 | rssi = IWL_MIN_RSSI_VAL; |
140 | 132 | ||
141 | switch (mode) { | 133 | switch (band) { |
142 | case MODE_IEEE80211G: | 134 | case IEEE80211_BAND_2GHZ: |
143 | tpt_table = iwl3945_tpt_table_g; | 135 | tpt_table = iwl3945_tpt_table_g; |
144 | table_size = ARRAY_SIZE(iwl3945_tpt_table_g); | 136 | table_size = ARRAY_SIZE(iwl3945_tpt_table_g); |
145 | break; | 137 | break; |
146 | 138 | ||
147 | case MODE_IEEE80211A: | 139 | case IEEE80211_BAND_5GHZ: |
148 | tpt_table = iwl3945_tpt_table_a; | 140 | tpt_table = iwl3945_tpt_table_a; |
149 | table_size = ARRAY_SIZE(iwl3945_tpt_table_a); | 141 | table_size = ARRAY_SIZE(iwl3945_tpt_table_a); |
150 | break; | 142 | break; |
151 | 143 | ||
152 | default: | 144 | default: |
153 | case MODE_IEEE80211B: | 145 | BUG(); |
154 | tpt_table = iwl3945_tpt_table_b; | ||
155 | table_size = ARRAY_SIZE(iwl3945_tpt_table_b); | ||
156 | break; | 146 | break; |
157 | } | 147 | } |
158 | 148 | ||
@@ -340,17 +330,17 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
340 | * after assoc.. */ | 330 | * after assoc.. */ |
341 | 331 | ||
342 | for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { | 332 | for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { |
343 | if (sta->supp_rates & (1 << i)) { | 333 | if (sta->supp_rates[local->hw.conf.channel->band] & (1 << i)) { |
344 | sta->txrate = i; | 334 | sta->txrate_idx = i; |
345 | break; | 335 | break; |
346 | } | 336 | } |
347 | } | 337 | } |
348 | 338 | ||
349 | sta->last_txrate = sta->txrate; | 339 | sta->last_txrate_idx = sta->txrate_idx; |
350 | 340 | ||
351 | /* For MODE_IEEE80211A mode it start at IWL_FIRST_OFDM_RATE */ | 341 | /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ |
352 | if (local->hw.conf.phymode == MODE_IEEE80211A) | 342 | if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) |
353 | sta->last_txrate += IWL_FIRST_OFDM_RATE; | 343 | sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; |
354 | 344 | ||
355 | IWL_DEBUG_RATE("leave\n"); | 345 | IWL_DEBUG_RATE("leave\n"); |
356 | } | 346 | } |
@@ -429,17 +419,19 @@ static int rs_adjust_next_rate(struct iwl3945_priv *priv, int rate) | |||
429 | { | 419 | { |
430 | int next_rate = iwl3945_get_prev_ieee_rate(rate); | 420 | int next_rate = iwl3945_get_prev_ieee_rate(rate); |
431 | 421 | ||
432 | switch (priv->phymode) { | 422 | switch (priv->band) { |
433 | case MODE_IEEE80211A: | 423 | case IEEE80211_BAND_5GHZ: |
434 | if (rate == IWL_RATE_12M_INDEX) | 424 | if (rate == IWL_RATE_12M_INDEX) |
435 | next_rate = IWL_RATE_9M_INDEX; | 425 | next_rate = IWL_RATE_9M_INDEX; |
436 | else if (rate == IWL_RATE_6M_INDEX) | 426 | else if (rate == IWL_RATE_6M_INDEX) |
437 | next_rate = IWL_RATE_6M_INDEX; | 427 | next_rate = IWL_RATE_6M_INDEX; |
438 | break; | 428 | break; |
429 | /* XXX cannot be invoked in current mac80211 so not a regression | ||
439 | case MODE_IEEE80211B: | 430 | case MODE_IEEE80211B: |
440 | if (rate == IWL_RATE_11M_INDEX_TABLE) | 431 | if (rate == IWL_RATE_11M_INDEX_TABLE) |
441 | next_rate = IWL_RATE_5M_INDEX_TABLE; | 432 | next_rate = IWL_RATE_5M_INDEX_TABLE; |
442 | break; | 433 | break; |
434 | */ | ||
443 | default: | 435 | default: |
444 | break; | 436 | break; |
445 | } | 437 | } |
@@ -465,15 +457,17 @@ static void rs_tx_status(void *priv_rate, | |||
465 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; | 457 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; |
466 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 458 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
467 | struct iwl3945_rs_sta *rs_sta; | 459 | struct iwl3945_rs_sta *rs_sta; |
460 | struct ieee80211_supported_band *sband; | ||
461 | |||
462 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
468 | 463 | ||
469 | IWL_DEBUG_RATE("enter\n"); | 464 | IWL_DEBUG_RATE("enter\n"); |
470 | 465 | ||
471 | retries = tx_resp->retry_count; | 466 | retries = tx_resp->retry_count; |
472 | 467 | ||
473 | first_index = tx_resp->control.tx_rate; | 468 | first_index = &sband->bitrates[0] - tx_resp->control.tx_rate; |
474 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { | 469 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { |
475 | IWL_DEBUG_RATE("leave: Rate out of bounds: %0x for %d\n", | 470 | IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); |
476 | tx_resp->control.tx_rate, first_index); | ||
477 | return; | 471 | return; |
478 | } | 472 | } |
479 | 473 | ||
@@ -561,14 +555,14 @@ static void rs_tx_status(void *priv_rate, | |||
561 | } | 555 | } |
562 | 556 | ||
563 | static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, | 557 | static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, |
564 | u8 index, u16 rate_mask, int phymode) | 558 | u8 index, u16 rate_mask, enum ieee80211_band band) |
565 | { | 559 | { |
566 | u8 high = IWL_RATE_INVALID; | 560 | u8 high = IWL_RATE_INVALID; |
567 | u8 low = IWL_RATE_INVALID; | 561 | u8 low = IWL_RATE_INVALID; |
568 | 562 | ||
569 | /* 802.11A walks to the next literal adjacent rate in | 563 | /* 802.11A walks to the next literal adjacent rate in |
570 | * the rate table */ | 564 | * the rate table */ |
571 | if (unlikely(phymode == MODE_IEEE80211A)) { | 565 | if (unlikely(band == IEEE80211_BAND_5GHZ)) { |
572 | int i; | 566 | int i; |
573 | u32 mask; | 567 | u32 mask; |
574 | 568 | ||
@@ -639,7 +633,8 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, | |||
639 | * | 633 | * |
640 | */ | 634 | */ |
641 | static void rs_get_rate(void *priv_rate, struct net_device *dev, | 635 | static void rs_get_rate(void *priv_rate, struct net_device *dev, |
642 | struct ieee80211_hw_mode *mode, struct sk_buff *skb, | 636 | struct ieee80211_supported_band *band, |
637 | struct sk_buff *skb, | ||
643 | struct rate_selection *sel) | 638 | struct rate_selection *sel) |
644 | { | 639 | { |
645 | u8 low = IWL_RATE_INVALID; | 640 | u8 low = IWL_RATE_INVALID; |
@@ -672,16 +667,16 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
672 | is_multicast_ether_addr(hdr->addr1) || | 667 | is_multicast_ether_addr(hdr->addr1) || |
673 | !sta || !sta->rate_ctrl_priv) { | 668 | !sta || !sta->rate_ctrl_priv) { |
674 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); | 669 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); |
675 | sel->rate = rate_lowest(local, local->oper_hw_mode, sta); | 670 | sel->rate = rate_lowest(local, band, sta); |
676 | if (sta) | 671 | if (sta) |
677 | sta_info_put(sta); | 672 | sta_info_put(sta); |
678 | return; | 673 | return; |
679 | } | 674 | } |
680 | 675 | ||
681 | rate_mask = sta->supp_rates; | 676 | rate_mask = sta->supp_rates[band->band]; |
682 | index = min(sta->last_txrate & 0xffff, IWL_RATE_COUNT - 1); | 677 | index = min(sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); |
683 | 678 | ||
684 | if (priv->phymode == (u8) MODE_IEEE80211A) | 679 | if (priv->band == IEEE80211_BAND_5GHZ) |
685 | rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; | 680 | rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; |
686 | 681 | ||
687 | rs_sta = (void *)sta->rate_ctrl_priv; | 682 | rs_sta = (void *)sta->rate_ctrl_priv; |
@@ -732,7 +727,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
732 | current_tpt = window->average_tpt; | 727 | current_tpt = window->average_tpt; |
733 | 728 | ||
734 | high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, | 729 | high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, |
735 | local->hw.conf.phymode); | 730 | band->band); |
736 | low = high_low & 0xff; | 731 | low = high_low & 0xff; |
737 | high = (high_low >> 8) & 0xff; | 732 | high = (high_low >> 8) & 0xff; |
738 | 733 | ||
@@ -810,11 +805,11 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
810 | 805 | ||
811 | out: | 806 | out: |
812 | 807 | ||
813 | sta->last_txrate = index; | 808 | sta->last_txrate_idx = index; |
814 | if (priv->phymode == (u8) MODE_IEEE80211A) | 809 | if (priv->band == IEEE80211_BAND_5GHZ) |
815 | sta->txrate = sta->last_txrate - IWL_FIRST_OFDM_RATE; | 810 | sta->txrate_idx = sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; |
816 | else | 811 | else |
817 | sta->txrate = sta->last_txrate; | 812 | sta->txrate_idx = sta->last_txrate_idx; |
818 | 813 | ||
819 | sta_info_put(sta); | 814 | sta_info_put(sta); |
820 | 815 | ||
@@ -945,8 +940,9 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | |||
945 | spin_lock_irqsave(&rs_sta->lock, flags); | 940 | spin_lock_irqsave(&rs_sta->lock, flags); |
946 | 941 | ||
947 | rs_sta->tgg = 0; | 942 | rs_sta->tgg = 0; |
948 | switch (priv->phymode) { | 943 | switch (priv->band) { |
949 | case MODE_IEEE80211G: | 944 | case IEEE80211_BAND_2GHZ: |
945 | /* TODO: this always does G, not a regression */ | ||
950 | if (priv->active_rxon.flags & RXON_FLG_TGG_PROTECT_MSK) { | 946 | if (priv->active_rxon.flags & RXON_FLG_TGG_PROTECT_MSK) { |
951 | rs_sta->tgg = 1; | 947 | rs_sta->tgg = 1; |
952 | rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot; | 948 | rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot; |
@@ -954,14 +950,11 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | |||
954 | rs_sta->expected_tpt = iwl3945_expected_tpt_g; | 950 | rs_sta->expected_tpt = iwl3945_expected_tpt_g; |
955 | break; | 951 | break; |
956 | 952 | ||
957 | case MODE_IEEE80211A: | 953 | case IEEE80211_BAND_5GHZ: |
958 | rs_sta->expected_tpt = iwl3945_expected_tpt_a; | 954 | rs_sta->expected_tpt = iwl3945_expected_tpt_a; |
959 | break; | 955 | break; |
960 | 956 | case IEEE80211_NUM_BANDS: | |
961 | default: | 957 | BUG(); |
962 | IWL_WARNING("Invalid phymode. Defaulting to 802.11b\n"); | ||
963 | case MODE_IEEE80211B: | ||
964 | rs_sta->expected_tpt = iwl3945_expected_tpt_b; | ||
965 | break; | 958 | break; |
966 | } | 959 | } |
967 | 960 | ||
@@ -974,8 +967,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | |||
974 | 967 | ||
975 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_RATE, "Network RSSI: %d\n", rssi); | 968 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_RATE, "Network RSSI: %d\n", rssi); |
976 | 969 | ||
977 | rs_sta->start_rate = | 970 | rs_sta->start_rate = iwl3945_get_rate_index_by_rssi(rssi, priv->band); |
978 | iwl3945_get_rate_index_by_rssi(rssi, priv->phymode); | ||
979 | 971 | ||
980 | IWL_DEBUG_RATE("leave: rssi %d assign rate index: " | 972 | IWL_DEBUG_RATE("leave: rssi %d assign rate index: " |
981 | "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, | 973 | "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c index 8d4d91d35fd2..50d927bb2170 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c | |||
@@ -247,7 +247,7 @@ static void iwl3945_add_radiotap(struct iwl3945_priv *priv, | |||
247 | * the information provided in the skb from the hardware */ | 247 | * the information provided in the skb from the hardware */ |
248 | s8 signal = stats->ssi; | 248 | s8 signal = stats->ssi; |
249 | s8 noise = 0; | 249 | s8 noise = 0; |
250 | int rate = stats->rate; | 250 | int rate = stats->rate_idx; |
251 | u64 tsf = stats->mactime; | 251 | u64 tsf = stats->mactime; |
252 | __le16 phy_flags_hw = rx_hdr->phy_flags; | 252 | __le16 phy_flags_hw = rx_hdr->phy_flags; |
253 | 253 | ||
@@ -315,7 +315,6 @@ static void iwl3945_add_radiotap(struct iwl3945_priv *priv, | |||
315 | IEEE80211_CHAN_2GHZ), | 315 | IEEE80211_CHAN_2GHZ), |
316 | &iwl3945_rt->rt_chbitmask); | 316 | &iwl3945_rt->rt_chbitmask); |
317 | 317 | ||
318 | rate = iwl3945_rate_index_from_plcp(rate); | ||
319 | if (rate == -1) | 318 | if (rate == -1) |
320 | iwl3945_rt->rt_rate = 0; | 319 | iwl3945_rt->rt_rate = 0; |
321 | else | 320 | else |
@@ -387,11 +386,10 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv, | |||
387 | struct ieee80211_rx_status stats = { | 386 | struct ieee80211_rx_status stats = { |
388 | .mactime = le64_to_cpu(rx_end->timestamp), | 387 | .mactime = le64_to_cpu(rx_end->timestamp), |
389 | .freq = ieee80211chan2mhz(le16_to_cpu(rx_hdr->channel)), | 388 | .freq = ieee80211chan2mhz(le16_to_cpu(rx_hdr->channel)), |
390 | .channel = le16_to_cpu(rx_hdr->channel), | 389 | .band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? |
391 | .phymode = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? | 390 | IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ, |
392 | MODE_IEEE80211G : MODE_IEEE80211A, | ||
393 | .antenna = 0, | 391 | .antenna = 0, |
394 | .rate = rx_hdr->rate, | 392 | .rate_idx = iwl3945_rate_index_from_plcp(rx_hdr->rate), |
395 | .flag = 0, | 393 | .flag = 0, |
396 | }; | 394 | }; |
397 | u8 network_packet; | 395 | u8 network_packet; |
@@ -450,8 +448,6 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv, | |||
450 | stats.ssi, stats.noise, stats.signal, | 448 | stats.ssi, stats.noise, stats.signal, |
451 | rx_stats_sig_avg, rx_stats_noise_diff); | 449 | rx_stats_sig_avg, rx_stats_noise_diff); |
452 | 450 | ||
453 | stats.freq = ieee80211chan2mhz(stats.channel); | ||
454 | |||
455 | /* can be covered by iwl3945_report_frame() in most cases */ | 451 | /* can be covered by iwl3945_report_frame() in most cases */ |
456 | /* IWL_DEBUG_RX("RX status: 0x%08X\n", rx_end->status); */ | 452 | /* IWL_DEBUG_RX("RX status: 0x%08X\n", rx_end->status); */ |
457 | 453 | ||
@@ -464,8 +460,9 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv, | |||
464 | IWL_DEBUG_STATS | 460 | IWL_DEBUG_STATS |
465 | ("[%c] %d RSSI: %d Signal: %u, Noise: %u, Rate: %u\n", | 461 | ("[%c] %d RSSI: %d Signal: %u, Noise: %u, Rate: %u\n", |
466 | network_packet ? '*' : ' ', | 462 | network_packet ? '*' : ' ', |
467 | stats.channel, stats.ssi, stats.ssi, | 463 | le16_to_cpu(rx_hdr->channel), |
468 | stats.ssi, stats.rate); | 464 | stats.ssi, stats.ssi, |
465 | stats.ssi, stats.rate_idx); | ||
469 | 466 | ||
470 | if (iwl3945_debug_level & (IWL_DL_RX)) | 467 | if (iwl3945_debug_level & (IWL_DL_RX)) |
471 | /* Set "1" to report good data frames in groups of 100 */ | 468 | /* Set "1" to report good data frames in groups of 100 */ |
@@ -689,7 +686,7 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl3945_priv *priv, | |||
689 | struct ieee80211_hdr *hdr, int sta_id, int tx_id) | 686 | struct ieee80211_hdr *hdr, int sta_id, int tx_id) |
690 | { | 687 | { |
691 | unsigned long flags; | 688 | unsigned long flags; |
692 | u16 rate_index = min(ctrl->tx_rate & 0xffff, IWL_RATE_COUNT - 1); | 689 | u16 rate_index = min(ctrl->tx_rate->hw_value & 0xffff, IWL_RATE_COUNT - 1); |
693 | u16 rate_mask; | 690 | u16 rate_mask; |
694 | int rate; | 691 | int rate; |
695 | u8 rts_retry_limit; | 692 | u8 rts_retry_limit; |
@@ -1552,14 +1549,14 @@ int iwl3945_hw_reg_send_txpower(struct iwl3945_priv *priv) | |||
1552 | .channel = priv->active_rxon.channel, | 1549 | .channel = priv->active_rxon.channel, |
1553 | }; | 1550 | }; |
1554 | 1551 | ||
1555 | txpower.band = (priv->phymode == MODE_IEEE80211A) ? 0 : 1; | 1552 | txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1; |
1556 | ch_info = iwl3945_get_channel_info(priv, | 1553 | ch_info = iwl3945_get_channel_info(priv, |
1557 | priv->phymode, | 1554 | priv->band, |
1558 | le16_to_cpu(priv->active_rxon.channel)); | 1555 | le16_to_cpu(priv->active_rxon.channel)); |
1559 | if (!ch_info) { | 1556 | if (!ch_info) { |
1560 | IWL_ERROR | 1557 | IWL_ERROR |
1561 | ("Failed to get channel info for channel %d [%d]\n", | 1558 | ("Failed to get channel info for channel %d [%d]\n", |
1562 | le16_to_cpu(priv->active_rxon.channel), priv->phymode); | 1559 | le16_to_cpu(priv->active_rxon.channel), priv->band); |
1563 | return -EINVAL; | 1560 | return -EINVAL; |
1564 | } | 1561 | } |
1565 | 1562 | ||
@@ -2241,8 +2238,8 @@ int iwl3945_init_hw_rate_table(struct iwl3945_priv *priv) | |||
2241 | table[index].next_rate_index = iwl3945_rates[prev_index].table_rs_index; | 2238 | table[index].next_rate_index = iwl3945_rates[prev_index].table_rs_index; |
2242 | } | 2239 | } |
2243 | 2240 | ||
2244 | switch (priv->phymode) { | 2241 | switch (priv->band) { |
2245 | case MODE_IEEE80211A: | 2242 | case IEEE80211_BAND_5GHZ: |
2246 | IWL_DEBUG_RATE("Select A mode rate scale\n"); | 2243 | IWL_DEBUG_RATE("Select A mode rate scale\n"); |
2247 | /* If one of the following CCK rates is used, | 2244 | /* If one of the following CCK rates is used, |
2248 | * have it fall back to the 6M OFDM rate */ | 2245 | * have it fall back to the 6M OFDM rate */ |
@@ -2257,8 +2254,8 @@ int iwl3945_init_hw_rate_table(struct iwl3945_priv *priv) | |||
2257 | iwl3945_rates[IWL_FIRST_OFDM_RATE].table_rs_index; | 2254 | iwl3945_rates[IWL_FIRST_OFDM_RATE].table_rs_index; |
2258 | break; | 2255 | break; |
2259 | 2256 | ||
2260 | case MODE_IEEE80211B: | 2257 | case IEEE80211_BAND_2GHZ: |
2261 | IWL_DEBUG_RATE("Select B mode rate scale\n"); | 2258 | IWL_DEBUG_RATE("Select B/G mode rate scale\n"); |
2262 | /* If an OFDM rate is used, have it fall back to the | 2259 | /* If an OFDM rate is used, have it fall back to the |
2263 | * 1M CCK rates */ | 2260 | * 1M CCK rates */ |
2264 | for (i = IWL_RATE_6M_INDEX_TABLE; i <= IWL_RATE_54M_INDEX_TABLE; i++) | 2261 | for (i = IWL_RATE_6M_INDEX_TABLE; i <= IWL_RATE_54M_INDEX_TABLE; i++) |
@@ -2269,7 +2266,7 @@ int iwl3945_init_hw_rate_table(struct iwl3945_priv *priv) | |||
2269 | break; | 2266 | break; |
2270 | 2267 | ||
2271 | default: | 2268 | default: |
2272 | IWL_DEBUG_RATE("Select G mode rate scale\n"); | 2269 | WARN_ON(1); |
2273 | break; | 2270 | break; |
2274 | } | 2271 | } |
2275 | 2272 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h index 1da14f9bbe0f..1beb5b676797 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.h +++ b/drivers/net/wireless/iwlwifi/iwl-3945.h | |||
@@ -195,7 +195,7 @@ struct iwl3945_channel_info { | |||
195 | 195 | ||
196 | u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */ | 196 | u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */ |
197 | u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */ | 197 | u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */ |
198 | u8 phymode; /* MODE_IEEE80211{A,B,G} */ | 198 | enum ieee80211_band band; |
199 | 199 | ||
200 | /* Radio/DSP gain settings for each "normal" data Tx rate. | 200 | /* Radio/DSP gain settings for each "normal" data Tx rate. |
201 | * These include, in addition to RF and DSP gain, a few fields for | 201 | * These include, in addition to RF and DSP gain, a few fields for |
@@ -699,14 +699,14 @@ struct iwl3945_priv { | |||
699 | struct list_head free_frames; | 699 | struct list_head free_frames; |
700 | int frames_count; | 700 | int frames_count; |
701 | 701 | ||
702 | u8 phymode; | 702 | enum ieee80211_band band; |
703 | int alloc_rxb_skb; | 703 | int alloc_rxb_skb; |
704 | bool add_radiotap; | 704 | bool add_radiotap; |
705 | 705 | ||
706 | void (*rx_handlers[REPLY_MAX])(struct iwl3945_priv *priv, | 706 | void (*rx_handlers[REPLY_MAX])(struct iwl3945_priv *priv, |
707 | struct iwl3945_rx_mem_buffer *rxb); | 707 | struct iwl3945_rx_mem_buffer *rxb); |
708 | 708 | ||
709 | const struct ieee80211_hw_mode *modes; | 709 | struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; |
710 | 710 | ||
711 | #ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT | 711 | #ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT |
712 | /* spectrum measurement report caching */ | 712 | /* spectrum measurement report caching */ |
@@ -937,13 +937,12 @@ static inline int is_channel_radar(const struct iwl3945_channel_info *ch_info) | |||
937 | 937 | ||
938 | static inline u8 is_channel_a_band(const struct iwl3945_channel_info *ch_info) | 938 | static inline u8 is_channel_a_band(const struct iwl3945_channel_info *ch_info) |
939 | { | 939 | { |
940 | return ch_info->phymode == MODE_IEEE80211A; | 940 | return ch_info->band == IEEE80211_BAND_5GHZ; |
941 | } | 941 | } |
942 | 942 | ||
943 | static inline u8 is_channel_bg_band(const struct iwl3945_channel_info *ch_info) | 943 | static inline u8 is_channel_bg_band(const struct iwl3945_channel_info *ch_info) |
944 | { | 944 | { |
945 | return ((ch_info->phymode == MODE_IEEE80211B) || | 945 | return ch_info->band == IEEE80211_BAND_2GHZ; |
946 | (ch_info->phymode == MODE_IEEE80211G)); | ||
947 | } | 946 | } |
948 | 947 | ||
949 | static inline int is_channel_passive(const struct iwl3945_channel_info *ch) | 948 | static inline int is_channel_passive(const struct iwl3945_channel_info *ch) |
@@ -967,7 +966,7 @@ static inline int iwl3945_rate_index_from_plcp(int plcp) | |||
967 | } | 966 | } |
968 | 967 | ||
969 | extern const struct iwl3945_channel_info *iwl3945_get_channel_info( | 968 | extern const struct iwl3945_channel_info *iwl3945_get_channel_info( |
970 | const struct iwl3945_priv *priv, int phymode, u16 channel); | 969 | const struct iwl3945_priv *priv, enum ieee80211_band band, u16 channel); |
971 | 970 | ||
972 | /* Requires full declaration of iwl3945_priv before including */ | 971 | /* Requires full declaration of iwl3945_priv before including */ |
973 | #include "iwl-3945-io.h" | 972 | #include "iwl-3945-io.h" |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c index 660671f17a3b..48a6a85355ec 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c | |||
@@ -139,7 +139,7 @@ struct iwl4965_lq_sta { | |||
139 | u8 valid_antenna; | 139 | u8 valid_antenna; |
140 | u8 is_green; | 140 | u8 is_green; |
141 | u8 is_dup; | 141 | u8 is_dup; |
142 | u8 phymode; | 142 | enum ieee80211_band band; |
143 | u8 ibss_sta_added; | 143 | u8 ibss_sta_added; |
144 | 144 | ||
145 | /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */ | 145 | /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */ |
@@ -563,7 +563,8 @@ static void rs_mcs_from_tbl(struct iwl4965_rate *mcs_rate, | |||
563 | * fill "search" or "active" tx mode table. | 563 | * fill "search" or "active" tx mode table. |
564 | */ | 564 | */ |
565 | static int rs_get_tbl_info_from_mcs(const struct iwl4965_rate *mcs_rate, | 565 | static int rs_get_tbl_info_from_mcs(const struct iwl4965_rate *mcs_rate, |
566 | int phymode, struct iwl4965_scale_tbl_info *tbl, | 566 | enum ieee80211_band band, |
567 | struct iwl4965_scale_tbl_info *tbl, | ||
567 | int *rate_idx) | 568 | int *rate_idx) |
568 | { | 569 | { |
569 | int index; | 570 | int index; |
@@ -588,7 +589,7 @@ static int rs_get_tbl_info_from_mcs(const struct iwl4965_rate *mcs_rate, | |||
588 | tbl->lq_type = LQ_NONE; | 589 | tbl->lq_type = LQ_NONE; |
589 | else { | 590 | else { |
590 | 591 | ||
591 | if (phymode == MODE_IEEE80211A) | 592 | if (band == IEEE80211_BAND_5GHZ) |
592 | tbl->lq_type = LQ_A; | 593 | tbl->lq_type = LQ_A; |
593 | else | 594 | else |
594 | tbl->lq_type = LQ_G; | 595 | tbl->lq_type = LQ_G; |
@@ -766,7 +767,7 @@ static void rs_get_lower_rate(struct iwl4965_lq_sta *lq_sta, | |||
766 | if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_index)) { | 767 | if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_index)) { |
767 | switch_to_legacy = 1; | 768 | switch_to_legacy = 1; |
768 | scale_index = rs_ht_to_legacy[scale_index]; | 769 | scale_index = rs_ht_to_legacy[scale_index]; |
769 | if (lq_sta->phymode == MODE_IEEE80211A) | 770 | if (lq_sta->band == IEEE80211_BAND_5GHZ) |
770 | tbl->lq_type = LQ_A; | 771 | tbl->lq_type = LQ_A; |
771 | else | 772 | else |
772 | tbl->lq_type = LQ_G; | 773 | tbl->lq_type = LQ_G; |
@@ -784,7 +785,7 @@ static void rs_get_lower_rate(struct iwl4965_lq_sta *lq_sta, | |||
784 | /* Mask with station rate restriction */ | 785 | /* Mask with station rate restriction */ |
785 | if (is_legacy(tbl->lq_type)) { | 786 | if (is_legacy(tbl->lq_type)) { |
786 | /* supp_rates has no CCK bits in A mode */ | 787 | /* supp_rates has no CCK bits in A mode */ |
787 | if (lq_sta->phymode == (u8) MODE_IEEE80211A) | 788 | if (lq_sta->band == IEEE80211_BAND_5GHZ) |
788 | rate_mask = (u16)(rate_mask & | 789 | rate_mask = (u16)(rate_mask & |
789 | (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); | 790 | (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); |
790 | else | 791 | else |
@@ -883,9 +884,9 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
883 | search_win = (struct iwl4965_rate_scale_data *) | 884 | search_win = (struct iwl4965_rate_scale_data *) |
884 | &(search_tbl->win[0]); | 885 | &(search_tbl->win[0]); |
885 | 886 | ||
886 | tx_mcs.rate_n_flags = tx_resp->control.tx_rate; | 887 | tx_mcs.rate_n_flags = tx_resp->control.tx_rate->hw_value; |
887 | 888 | ||
888 | rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, | 889 | rs_get_tbl_info_from_mcs(&tx_mcs, priv->band, |
889 | &tbl_type, &rs_index); | 890 | &tbl_type, &rs_index); |
890 | if ((rs_index < 0) || (rs_index >= IWL_RATE_COUNT)) { | 891 | if ((rs_index < 0) || (rs_index >= IWL_RATE_COUNT)) { |
891 | IWL_DEBUG_RATE("bad rate index at: %d rate 0x%X\n", | 892 | IWL_DEBUG_RATE("bad rate index at: %d rate 0x%X\n", |
@@ -918,7 +919,7 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
918 | * Each tx attempt steps one entry deeper in the rate table. */ | 919 | * Each tx attempt steps one entry deeper in the rate table. */ |
919 | tx_mcs.rate_n_flags = | 920 | tx_mcs.rate_n_flags = |
920 | le32_to_cpu(table->rs_table[index].rate_n_flags); | 921 | le32_to_cpu(table->rs_table[index].rate_n_flags); |
921 | rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, | 922 | rs_get_tbl_info_from_mcs(&tx_mcs, priv->band, |
922 | &tbl_type, &rs_index); | 923 | &tbl_type, &rs_index); |
923 | 924 | ||
924 | /* If type matches "search" table, | 925 | /* If type matches "search" table, |
@@ -959,12 +960,12 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
959 | * else look up the rate that was, finally, successful. | 960 | * else look up the rate that was, finally, successful. |
960 | */ | 961 | */ |
961 | if (!tx_resp->retry_count) | 962 | if (!tx_resp->retry_count) |
962 | tx_mcs.rate_n_flags = tx_resp->control.tx_rate; | 963 | tx_mcs.rate_n_flags = tx_resp->control.tx_rate->hw_value; |
963 | else | 964 | else |
964 | tx_mcs.rate_n_flags = | 965 | tx_mcs.rate_n_flags = |
965 | le32_to_cpu(table->rs_table[index].rate_n_flags); | 966 | le32_to_cpu(table->rs_table[index].rate_n_flags); |
966 | 967 | ||
967 | rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, | 968 | rs_get_tbl_info_from_mcs(&tx_mcs, priv->band, |
968 | &tbl_type, &rs_index); | 969 | &tbl_type, &rs_index); |
969 | 970 | ||
970 | /* Update frame history window with "success" if Tx got ACKed ... */ | 971 | /* Update frame history window with "success" if Tx got ACKed ... */ |
@@ -1801,7 +1802,7 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv, | |||
1801 | is_green = lq_sta->is_green; | 1802 | is_green = lq_sta->is_green; |
1802 | 1803 | ||
1803 | /* current tx rate */ | 1804 | /* current tx rate */ |
1804 | index = sta->last_txrate; | 1805 | index = sta->last_txrate_idx; |
1805 | 1806 | ||
1806 | IWL_DEBUG_RATE("Rate scale index %d for type %d\n", index, | 1807 | IWL_DEBUG_RATE("Rate scale index %d for type %d\n", index, |
1807 | tbl->lq_type); | 1808 | tbl->lq_type); |
@@ -1814,7 +1815,7 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv, | |||
1814 | 1815 | ||
1815 | /* mask with station rate restriction */ | 1816 | /* mask with station rate restriction */ |
1816 | if (is_legacy(tbl->lq_type)) { | 1817 | if (is_legacy(tbl->lq_type)) { |
1817 | if (lq_sta->phymode == (u8) MODE_IEEE80211A) | 1818 | if (lq_sta->band == IEEE80211_BAND_5GHZ) |
1818 | /* supp_rates has no CCK bits in A mode */ | 1819 | /* supp_rates has no CCK bits in A mode */ |
1819 | rate_scale_index_msk = (u16) (rate_mask & | 1820 | rate_scale_index_msk = (u16) (rate_mask & |
1820 | (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); | 1821 | (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); |
@@ -2134,15 +2135,15 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv, | |||
2134 | out: | 2135 | out: |
2135 | rs_mcs_from_tbl(&tbl->current_rate, tbl, index, is_green); | 2136 | rs_mcs_from_tbl(&tbl->current_rate, tbl, index, is_green); |
2136 | i = index; | 2137 | i = index; |
2137 | sta->last_txrate = i; | 2138 | sta->last_txrate_idx = i; |
2138 | 2139 | ||
2139 | /* sta->txrate is an index to A mode rates which start | 2140 | /* sta->txrate_idx is an index to A mode rates which start |
2140 | * at IWL_FIRST_OFDM_RATE | 2141 | * at IWL_FIRST_OFDM_RATE |
2141 | */ | 2142 | */ |
2142 | if (lq_sta->phymode == (u8) MODE_IEEE80211A) | 2143 | if (lq_sta->band == IEEE80211_BAND_5GHZ) |
2143 | sta->txrate = i - IWL_FIRST_OFDM_RATE; | 2144 | sta->txrate_idx = i - IWL_FIRST_OFDM_RATE; |
2144 | else | 2145 | else |
2145 | sta->txrate = i; | 2146 | sta->txrate_idx = i; |
2146 | 2147 | ||
2147 | return; | 2148 | return; |
2148 | } | 2149 | } |
@@ -2164,7 +2165,7 @@ static void rs_initialize_lq(struct iwl4965_priv *priv, | |||
2164 | goto out; | 2165 | goto out; |
2165 | 2166 | ||
2166 | lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; | 2167 | lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; |
2167 | i = sta->last_txrate; | 2168 | i = sta->last_txrate_idx; |
2168 | 2169 | ||
2169 | if ((lq_sta->lq.sta_id == 0xff) && | 2170 | if ((lq_sta->lq.sta_id == 0xff) && |
2170 | (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) | 2171 | (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) |
@@ -2188,7 +2189,7 @@ static void rs_initialize_lq(struct iwl4965_priv *priv, | |||
2188 | mcs_rate.rate_n_flags |= RATE_MCS_CCK_MSK; | 2189 | mcs_rate.rate_n_flags |= RATE_MCS_CCK_MSK; |
2189 | 2190 | ||
2190 | tbl->antenna_type = ANT_AUX; | 2191 | tbl->antenna_type = ANT_AUX; |
2191 | rs_get_tbl_info_from_mcs(&mcs_rate, priv->phymode, tbl, &rate_idx); | 2192 | rs_get_tbl_info_from_mcs(&mcs_rate, priv->band, tbl, &rate_idx); |
2192 | if (!rs_is_ant_connected(priv->valid_antenna, tbl->antenna_type)) | 2193 | if (!rs_is_ant_connected(priv->valid_antenna, tbl->antenna_type)) |
2193 | rs_toggle_antenna(&mcs_rate, tbl); | 2194 | rs_toggle_antenna(&mcs_rate, tbl); |
2194 | 2195 | ||
@@ -2202,7 +2203,8 @@ static void rs_initialize_lq(struct iwl4965_priv *priv, | |||
2202 | } | 2203 | } |
2203 | 2204 | ||
2204 | static void rs_get_rate(void *priv_rate, struct net_device *dev, | 2205 | static void rs_get_rate(void *priv_rate, struct net_device *dev, |
2205 | struct ieee80211_hw_mode *mode, struct sk_buff *skb, | 2206 | struct ieee80211_supported_band *sband, |
2207 | struct sk_buff *skb, | ||
2206 | struct rate_selection *sel) | 2208 | struct rate_selection *sel) |
2207 | { | 2209 | { |
2208 | 2210 | ||
@@ -2224,14 +2226,14 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
2224 | fc = le16_to_cpu(hdr->frame_control); | 2226 | fc = le16_to_cpu(hdr->frame_control); |
2225 | if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || | 2227 | if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || |
2226 | !sta || !sta->rate_ctrl_priv) { | 2228 | !sta || !sta->rate_ctrl_priv) { |
2227 | sel->rate = rate_lowest(local, local->oper_hw_mode, sta); | 2229 | sel->rate = rate_lowest(local, sband, sta); |
2228 | if (sta) | 2230 | if (sta) |
2229 | sta_info_put(sta); | 2231 | sta_info_put(sta); |
2230 | return; | 2232 | return; |
2231 | } | 2233 | } |
2232 | 2234 | ||
2233 | lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; | 2235 | lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; |
2234 | i = sta->last_txrate; | 2236 | i = sta->last_txrate_idx; |
2235 | 2237 | ||
2236 | if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && | 2238 | if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && |
2237 | !lq_sta->ibss_sta_added) { | 2239 | !lq_sta->ibss_sta_added) { |
@@ -2256,7 +2258,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
2256 | 2258 | ||
2257 | done: | 2259 | done: |
2258 | if ((i < 0) || (i > IWL_RATE_COUNT)) { | 2260 | if ((i < 0) || (i > IWL_RATE_COUNT)) { |
2259 | sel->rate = rate_lowest(local, local->oper_hw_mode, sta); | 2261 | sel->rate = rate_lowest(local, sband, sta); |
2260 | return; | 2262 | return; |
2261 | } | 2263 | } |
2262 | sta_info_put(sta); | 2264 | sta_info_put(sta); |
@@ -2291,13 +2293,15 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
2291 | { | 2293 | { |
2292 | int i, j; | 2294 | int i, j; |
2293 | struct ieee80211_conf *conf = &local->hw.conf; | 2295 | struct ieee80211_conf *conf = &local->hw.conf; |
2294 | struct ieee80211_hw_mode *mode = local->oper_hw_mode; | 2296 | struct ieee80211_supported_band *sband; |
2295 | struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; | 2297 | struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; |
2296 | struct iwl4965_lq_sta *lq_sta = priv_sta; | 2298 | struct iwl4965_lq_sta *lq_sta = priv_sta; |
2297 | 2299 | ||
2300 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
2301 | |||
2298 | lq_sta->flush_timer = 0; | 2302 | lq_sta->flush_timer = 0; |
2299 | lq_sta->supp_rates = sta->supp_rates; | 2303 | lq_sta->supp_rates = sta->supp_rates[sband->band]; |
2300 | sta->txrate = 3; | 2304 | sta->txrate_idx = 3; |
2301 | for (j = 0; j < LQ_SIZE; j++) | 2305 | for (j = 0; j < LQ_SIZE; j++) |
2302 | for (i = 0; i < IWL_RATE_COUNT; i++) | 2306 | for (i = 0; i < IWL_RATE_COUNT; i++) |
2303 | rs_rate_scale_clear_window(&(lq_sta->lq_info[j].win[i])); | 2307 | rs_rate_scale_clear_window(&(lq_sta->lq_info[j].win[i])); |
@@ -2332,15 +2336,15 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
2332 | } | 2336 | } |
2333 | 2337 | ||
2334 | /* Find highest tx rate supported by hardware and destination station */ | 2338 | /* Find highest tx rate supported by hardware and destination station */ |
2335 | for (i = 0; i < mode->num_rates; i++) { | 2339 | for (i = 0; i < sband->n_bitrates; i++) |
2336 | if ((sta->supp_rates & BIT(i)) && | 2340 | if (sta->supp_rates[sband->band] & BIT(i)) |
2337 | (mode->rates[i].flags & IEEE80211_RATE_SUPPORTED)) | 2341 | sta->txrate_idx = i; |
2338 | sta->txrate = i; | 2342 | |
2339 | } | 2343 | sta->last_txrate_idx = sta->txrate_idx; |
2340 | sta->last_txrate = sta->txrate; | 2344 | /* WTF is with this bogus comment? A doesn't have cck rates */ |
2341 | /* For MODE_IEEE80211A, cck rates are at end of rate table */ | 2345 | /* For MODE_IEEE80211A, cck rates are at end of rate table */ |
2342 | if (local->hw.conf.phymode == MODE_IEEE80211A) | 2346 | if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) |
2343 | sta->last_txrate += IWL_FIRST_OFDM_RATE; | 2347 | sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; |
2344 | 2348 | ||
2345 | lq_sta->is_dup = 0; | 2349 | lq_sta->is_dup = 0; |
2346 | lq_sta->valid_antenna = priv->valid_antenna; | 2350 | lq_sta->valid_antenna = priv->valid_antenna; |
@@ -2349,7 +2353,7 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
2349 | lq_sta->active_rate = priv->active_rate; | 2353 | lq_sta->active_rate = priv->active_rate; |
2350 | lq_sta->active_rate &= ~(0x1000); | 2354 | lq_sta->active_rate &= ~(0x1000); |
2351 | lq_sta->active_rate_basic = priv->active_rate_basic; | 2355 | lq_sta->active_rate_basic = priv->active_rate_basic; |
2352 | lq_sta->phymode = priv->phymode; | 2356 | lq_sta->band = priv->band; |
2353 | #ifdef CONFIG_IWL4965_HT | 2357 | #ifdef CONFIG_IWL4965_HT |
2354 | /* | 2358 | /* |
2355 | * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), | 2359 | * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), |
@@ -2401,7 +2405,7 @@ static void rs_fill_link_cmd(struct iwl4965_lq_sta *lq_sta, | |||
2401 | rs_dbgfs_set_mcs(lq_sta, tx_mcs, index); | 2405 | rs_dbgfs_set_mcs(lq_sta, tx_mcs, index); |
2402 | 2406 | ||
2403 | /* Interpret rate_n_flags */ | 2407 | /* Interpret rate_n_flags */ |
2404 | rs_get_tbl_info_from_mcs(tx_mcs, lq_sta->phymode, | 2408 | rs_get_tbl_info_from_mcs(tx_mcs, lq_sta->band, |
2405 | &tbl_type, &rate_idx); | 2409 | &tbl_type, &rate_idx); |
2406 | 2410 | ||
2407 | /* How many times should we repeat the initial rate? */ | 2411 | /* How many times should we repeat the initial rate? */ |
@@ -2455,7 +2459,7 @@ static void rs_fill_link_cmd(struct iwl4965_lq_sta *lq_sta, | |||
2455 | index++; | 2459 | index++; |
2456 | } | 2460 | } |
2457 | 2461 | ||
2458 | rs_get_tbl_info_from_mcs(&new_rate, lq_sta->phymode, &tbl_type, | 2462 | rs_get_tbl_info_from_mcs(&new_rate, lq_sta->band, &tbl_type, |
2459 | &rate_idx); | 2463 | &rate_idx); |
2460 | 2464 | ||
2461 | /* Indicate to uCode which entries might be MIMO. | 2465 | /* Indicate to uCode which entries might be MIMO. |
@@ -2542,7 +2546,7 @@ static void rs_dbgfs_set_mcs(struct iwl4965_lq_sta *lq_sta, | |||
2542 | { | 2546 | { |
2543 | u32 base_rate; | 2547 | u32 base_rate; |
2544 | 2548 | ||
2545 | if (lq_sta->phymode == (u8) MODE_IEEE80211A) | 2549 | if (lq_sta->band == IEEE80211_BAND_5GHZ) |
2546 | base_rate = 0x800D; | 2550 | base_rate = 0x800D; |
2547 | else | 2551 | else |
2548 | base_rate = 0x820A; | 2552 | base_rate = 0x820A; |
@@ -2802,7 +2806,7 @@ int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) | |||
2802 | 2806 | ||
2803 | cnt += sprintf(&buf[cnt], "\nrate scale type %d antenna %d " | 2807 | cnt += sprintf(&buf[cnt], "\nrate scale type %d antenna %d " |
2804 | "active_search %d rate index %d\n", lq_type, antenna, | 2808 | "active_search %d rate index %d\n", lq_type, antenna, |
2805 | lq_sta->search_better_tbl, sta->last_txrate); | 2809 | lq_sta->search_better_tbl, sta->last_txrate_idx); |
2806 | 2810 | ||
2807 | sta_info_put(sta); | 2811 | sta_info_put(sta); |
2808 | return cnt; | 2812 | return cnt; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index 0bded8570275..a89439320498 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -339,14 +339,15 @@ static int iwl4965_kw_alloc(struct iwl4965_priv *priv) | |||
339 | * | 339 | * |
340 | * Does not set up a command, or touch hardware. | 340 | * Does not set up a command, or touch hardware. |
341 | */ | 341 | */ |
342 | int iwl4965_set_fat_chan_info(struct iwl4965_priv *priv, int phymode, u16 channel, | 342 | int iwl4965_set_fat_chan_info(struct iwl4965_priv *priv, |
343 | enum ieee80211_band band, u16 channel, | ||
343 | const struct iwl4965_eeprom_channel *eeprom_ch, | 344 | const struct iwl4965_eeprom_channel *eeprom_ch, |
344 | u8 fat_extension_channel) | 345 | u8 fat_extension_channel) |
345 | { | 346 | { |
346 | struct iwl4965_channel_info *ch_info; | 347 | struct iwl4965_channel_info *ch_info; |
347 | 348 | ||
348 | ch_info = (struct iwl4965_channel_info *) | 349 | ch_info = (struct iwl4965_channel_info *) |
349 | iwl4965_get_channel_info(priv, phymode, channel); | 350 | iwl4965_get_channel_info(priv, band, channel); |
350 | 351 | ||
351 | if (!is_channel_valid(ch_info)) | 352 | if (!is_channel_valid(ch_info)) |
352 | return -1; | 353 | return -1; |
@@ -1939,11 +1940,12 @@ static s32 iwl4965_get_voltage_compensation(s32 eeprom_voltage, | |||
1939 | } | 1940 | } |
1940 | 1941 | ||
1941 | static const struct iwl4965_channel_info * | 1942 | static const struct iwl4965_channel_info * |
1942 | iwl4965_get_channel_txpower_info(struct iwl4965_priv *priv, u8 phymode, u16 channel) | 1943 | iwl4965_get_channel_txpower_info(struct iwl4965_priv *priv, |
1944 | enum ieee80211_band band, u16 channel) | ||
1943 | { | 1945 | { |
1944 | const struct iwl4965_channel_info *ch_info; | 1946 | const struct iwl4965_channel_info *ch_info; |
1945 | 1947 | ||
1946 | ch_info = iwl4965_get_channel_info(priv, phymode, channel); | 1948 | ch_info = iwl4965_get_channel_info(priv, band, channel); |
1947 | 1949 | ||
1948 | if (!is_channel_valid(ch_info)) | 1950 | if (!is_channel_valid(ch_info)) |
1949 | return NULL; | 1951 | return NULL; |
@@ -2392,7 +2394,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl4965_priv *priv, u8 band, u16 chan | |||
2392 | 2394 | ||
2393 | /* Get current (RXON) channel, band, width */ | 2395 | /* Get current (RXON) channel, band, width */ |
2394 | ch_info = | 2396 | ch_info = |
2395 | iwl4965_get_channel_txpower_info(priv, priv->phymode, channel); | 2397 | iwl4965_get_channel_txpower_info(priv, priv->band, channel); |
2396 | 2398 | ||
2397 | IWL_DEBUG_TXPOWER("chan %d band %d is_fat %d\n", channel, band, | 2399 | IWL_DEBUG_TXPOWER("chan %d band %d is_fat %d\n", channel, band, |
2398 | is_fat); | 2400 | is_fat); |
@@ -2619,8 +2621,7 @@ int iwl4965_hw_reg_send_txpower(struct iwl4965_priv *priv) | |||
2619 | return -EAGAIN; | 2621 | return -EAGAIN; |
2620 | } | 2622 | } |
2621 | 2623 | ||
2622 | band = ((priv->phymode == MODE_IEEE80211B) || | 2624 | band = priv->band == IEEE80211_BAND_2GHZ; |
2623 | (priv->phymode == MODE_IEEE80211G)); | ||
2624 | 2625 | ||
2625 | is_fat = is_fat_channel(priv->active_rxon.flags); | 2626 | is_fat = is_fat_channel(priv->active_rxon.flags); |
2626 | 2627 | ||
@@ -2650,10 +2651,9 @@ int iwl4965_hw_channel_switch(struct iwl4965_priv *priv, u16 channel) | |||
2650 | struct iwl4965_channel_switch_cmd cmd = { 0 }; | 2651 | struct iwl4965_channel_switch_cmd cmd = { 0 }; |
2651 | const struct iwl4965_channel_info *ch_info; | 2652 | const struct iwl4965_channel_info *ch_info; |
2652 | 2653 | ||
2653 | band = ((priv->phymode == MODE_IEEE80211B) || | 2654 | band = priv->band == IEEE80211_BAND_2GHZ; |
2654 | (priv->phymode == MODE_IEEE80211G)); | ||
2655 | 2655 | ||
2656 | ch_info = iwl4965_get_channel_info(priv, priv->phymode, channel); | 2656 | ch_info = iwl4965_get_channel_info(priv, priv->band, channel); |
2657 | 2657 | ||
2658 | is_fat = is_fat_channel(priv->staging_rxon.flags); | 2658 | is_fat = is_fat_channel(priv->staging_rxon.flags); |
2659 | 2659 | ||
@@ -2698,7 +2698,7 @@ void iwl4965_hw_build_tx_cmd_rate(struct iwl4965_priv *priv, | |||
2698 | u16 fc = le16_to_cpu(hdr->frame_control); | 2698 | u16 fc = le16_to_cpu(hdr->frame_control); |
2699 | u8 rate_plcp; | 2699 | u8 rate_plcp; |
2700 | u16 rate_flags = 0; | 2700 | u16 rate_flags = 0; |
2701 | int rate_idx = min(ctrl->tx_rate & 0xffff, IWL_RATE_COUNT - 1); | 2701 | int rate_idx = min(ctrl->tx_rate->hw_value & 0xffff, IWL_RATE_COUNT - 1); |
2702 | 2702 | ||
2703 | rate_plcp = iwl4965_rates[rate_idx].plcp; | 2703 | rate_plcp = iwl4965_rates[rate_idx].plcp; |
2704 | 2704 | ||
@@ -3178,7 +3178,7 @@ static void iwl4965_add_radiotap(struct iwl4965_priv *priv, | |||
3178 | { | 3178 | { |
3179 | s8 signal = stats->ssi; | 3179 | s8 signal = stats->ssi; |
3180 | s8 noise = 0; | 3180 | s8 noise = 0; |
3181 | int rate = stats->rate; | 3181 | int rate = stats->rate_idx; |
3182 | u64 tsf = stats->mactime; | 3182 | u64 tsf = stats->mactime; |
3183 | __le16 phy_flags_hw = rx_start->phy_flags; | 3183 | __le16 phy_flags_hw = rx_start->phy_flags; |
3184 | struct iwl4965_rt_rx_hdr { | 3184 | struct iwl4965_rt_rx_hdr { |
@@ -3246,7 +3246,6 @@ static void iwl4965_add_radiotap(struct iwl4965_priv *priv, | |||
3246 | IEEE80211_CHAN_2GHZ), | 3246 | IEEE80211_CHAN_2GHZ), |
3247 | &iwl4965_rt->rt_chbitmask); | 3247 | &iwl4965_rt->rt_chbitmask); |
3248 | 3248 | ||
3249 | rate = iwl4965_rate_index_from_plcp(rate); | ||
3250 | if (rate == -1) | 3249 | if (rate == -1) |
3251 | iwl4965_rt->rt_rate = 0; | 3250 | iwl4965_rt->rt_rate = 0; |
3252 | else | 3251 | else |
@@ -3542,12 +3541,13 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv, | |||
3542 | u16 fc; | 3541 | u16 fc; |
3543 | struct ieee80211_rx_status stats = { | 3542 | struct ieee80211_rx_status stats = { |
3544 | .mactime = le64_to_cpu(rx_start->timestamp), | 3543 | .mactime = le64_to_cpu(rx_start->timestamp), |
3545 | .channel = le16_to_cpu(rx_start->channel), | 3544 | .freq = ieee80211chan2mhz(le16_to_cpu(rx_start->channel)), |
3546 | .phymode = | 3545 | .band = |
3547 | (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? | 3546 | (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? |
3548 | MODE_IEEE80211G : MODE_IEEE80211A, | 3547 | IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ, |
3549 | .antenna = 0, | 3548 | .antenna = 0, |
3550 | .rate = iwl4965_hw_get_rate(rx_start->rate_n_flags), | 3549 | .rate_idx = iwl4965_hw_get_rate( |
3550 | le32_to_cpu(rx_start->rate_n_flags)), | ||
3551 | .flag = 0, | 3551 | .flag = 0, |
3552 | }; | 3552 | }; |
3553 | u8 network_packet; | 3553 | u8 network_packet; |
@@ -3598,8 +3598,6 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv, | |||
3598 | 3598 | ||
3599 | priv->ucode_beacon_time = le32_to_cpu(rx_start->beacon_time_stamp); | 3599 | priv->ucode_beacon_time = le32_to_cpu(rx_start->beacon_time_stamp); |
3600 | 3600 | ||
3601 | stats.freq = ieee80211chan2mhz(stats.channel); | ||
3602 | |||
3603 | /* Find max signal strength (dBm) among 3 antenna/receiver chains */ | 3601 | /* Find max signal strength (dBm) among 3 antenna/receiver chains */ |
3604 | stats.ssi = iwl4965_calc_rssi(rx_start); | 3602 | stats.ssi = iwl4965_calc_rssi(rx_start); |
3605 | 3603 | ||
@@ -4185,7 +4183,7 @@ void iwl4965_add_station(struct iwl4965_priv *priv, const u8 *addr, int is_ap) | |||
4185 | * all the way down to 1M in IEEE order, and then spin on 1M */ | 4183 | * all the way down to 1M in IEEE order, and then spin on 1M */ |
4186 | if (is_ap) | 4184 | if (is_ap) |
4187 | r = IWL_RATE_54M_INDEX; | 4185 | r = IWL_RATE_54M_INDEX; |
4188 | else if (priv->phymode == MODE_IEEE80211A) | 4186 | else if (priv->band == IEEE80211_BAND_5GHZ) |
4189 | r = IWL_RATE_6M_INDEX; | 4187 | r = IWL_RATE_6M_INDEX; |
4190 | else | 4188 | else |
4191 | r = IWL_RATE_1M_INDEX; | 4189 | r = IWL_RATE_1M_INDEX; |
@@ -4218,12 +4216,13 @@ void iwl4965_add_station(struct iwl4965_priv *priv, const u8 *addr, int is_ap) | |||
4218 | 4216 | ||
4219 | #ifdef CONFIG_IWL4965_HT | 4217 | #ifdef CONFIG_IWL4965_HT |
4220 | 4218 | ||
4221 | static u8 iwl4965_is_channel_extension(struct iwl4965_priv *priv, int phymode, | 4219 | static u8 iwl4965_is_channel_extension(struct iwl4965_priv *priv, |
4220 | enum ieee80211_band band, | ||
4222 | u16 channel, u8 extension_chan_offset) | 4221 | u16 channel, u8 extension_chan_offset) |
4223 | { | 4222 | { |
4224 | const struct iwl4965_channel_info *ch_info; | 4223 | const struct iwl4965_channel_info *ch_info; |
4225 | 4224 | ||
4226 | ch_info = iwl4965_get_channel_info(priv, phymode, channel); | 4225 | ch_info = iwl4965_get_channel_info(priv, band, channel); |
4227 | if (!is_channel_valid(ch_info)) | 4226 | if (!is_channel_valid(ch_info)) |
4228 | return 0; | 4227 | return 0; |
4229 | 4228 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.h b/drivers/net/wireless/iwlwifi/iwl-4965.h index de5c1bf8fc42..cb8f7f2a8d48 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.h +++ b/drivers/net/wireless/iwlwifi/iwl-4965.h | |||
@@ -206,7 +206,7 @@ struct iwl4965_channel_info { | |||
206 | 206 | ||
207 | u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */ | 207 | u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */ |
208 | u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */ | 208 | u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */ |
209 | u8 phymode; /* MODE_IEEE80211{A,B,G} */ | 209 | enum ieee80211_band band; |
210 | 210 | ||
211 | /* Radio/DSP gain settings for each "normal" data Tx rate. | 211 | /* Radio/DSP gain settings for each "normal" data Tx rate. |
212 | * These include, in addition to RF and DSP gain, a few fields for | 212 | * These include, in addition to RF and DSP gain, a few fields for |
@@ -764,7 +764,8 @@ extern void iwl4965_update_rate_scaling(struct iwl4965_priv *priv, u8 mode); | |||
764 | extern void iwl4965_chain_noise_reset(struct iwl4965_priv *priv); | 764 | extern void iwl4965_chain_noise_reset(struct iwl4965_priv *priv); |
765 | extern void iwl4965_init_sensitivity(struct iwl4965_priv *priv, u8 flags, | 765 | extern void iwl4965_init_sensitivity(struct iwl4965_priv *priv, u8 flags, |
766 | u8 force); | 766 | u8 force); |
767 | extern int iwl4965_set_fat_chan_info(struct iwl4965_priv *priv, int phymode, | 767 | extern int iwl4965_set_fat_chan_info(struct iwl4965_priv *priv, |
768 | enum ieee80211_band band, | ||
768 | u16 channel, | 769 | u16 channel, |
769 | const struct iwl4965_eeprom_channel *eeprom_ch, | 770 | const struct iwl4965_eeprom_channel *eeprom_ch, |
770 | u8 fat_extension_channel); | 771 | u8 fat_extension_channel); |
@@ -977,14 +978,14 @@ struct iwl4965_priv { | |||
977 | struct list_head free_frames; | 978 | struct list_head free_frames; |
978 | int frames_count; | 979 | int frames_count; |
979 | 980 | ||
980 | u8 phymode; | 981 | enum ieee80211_band band; |
981 | int alloc_rxb_skb; | 982 | int alloc_rxb_skb; |
982 | bool add_radiotap; | 983 | bool add_radiotap; |
983 | 984 | ||
984 | void (*rx_handlers[REPLY_MAX])(struct iwl4965_priv *priv, | 985 | void (*rx_handlers[REPLY_MAX])(struct iwl4965_priv *priv, |
985 | struct iwl4965_rx_mem_buffer *rxb); | 986 | struct iwl4965_rx_mem_buffer *rxb); |
986 | 987 | ||
987 | const struct ieee80211_hw_mode *modes; | 988 | struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; |
988 | 989 | ||
989 | #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT | 990 | #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT |
990 | /* spectrum measurement report caching */ | 991 | /* spectrum measurement report caching */ |
@@ -1243,13 +1244,12 @@ static inline int is_channel_radar(const struct iwl4965_channel_info *ch_info) | |||
1243 | 1244 | ||
1244 | static inline u8 is_channel_a_band(const struct iwl4965_channel_info *ch_info) | 1245 | static inline u8 is_channel_a_band(const struct iwl4965_channel_info *ch_info) |
1245 | { | 1246 | { |
1246 | return ch_info->phymode == MODE_IEEE80211A; | 1247 | return ch_info->band == IEEE80211_BAND_5GHZ; |
1247 | } | 1248 | } |
1248 | 1249 | ||
1249 | static inline u8 is_channel_bg_band(const struct iwl4965_channel_info *ch_info) | 1250 | static inline u8 is_channel_bg_band(const struct iwl4965_channel_info *ch_info) |
1250 | { | 1251 | { |
1251 | return ((ch_info->phymode == MODE_IEEE80211B) || | 1252 | return ch_info->band == IEEE80211_BAND_2GHZ; |
1252 | (ch_info->phymode == MODE_IEEE80211G)); | ||
1253 | } | 1253 | } |
1254 | 1254 | ||
1255 | static inline int is_channel_passive(const struct iwl4965_channel_info *ch) | 1255 | static inline int is_channel_passive(const struct iwl4965_channel_info *ch) |
@@ -1263,7 +1263,7 @@ static inline int is_channel_ibss(const struct iwl4965_channel_info *ch) | |||
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | extern const struct iwl4965_channel_info *iwl4965_get_channel_info( | 1265 | extern const struct iwl4965_channel_info *iwl4965_get_channel_info( |
1266 | const struct iwl4965_priv *priv, int phymode, u16 channel); | 1266 | const struct iwl4965_priv *priv, enum ieee80211_band band, u16 channel); |
1267 | 1267 | ||
1268 | /* Requires full declaration of iwl4965_priv before including */ | 1268 | /* Requires full declaration of iwl4965_priv before including */ |
1269 | #include "iwl-4965-io.h" | 1269 | #include "iwl-4965-io.h" |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 40b71bc2c4a4..57a1d70f2abf 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -116,16 +116,10 @@ static __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr) | |||
116 | return NULL; | 116 | return NULL; |
117 | } | 117 | } |
118 | 118 | ||
119 | static const struct ieee80211_hw_mode *iwl3945_get_hw_mode( | 119 | static const struct ieee80211_supported_band *iwl3945_get_band( |
120 | struct iwl3945_priv *priv, int mode) | 120 | struct iwl3945_priv *priv, enum ieee80211_band band) |
121 | { | 121 | { |
122 | int i; | 122 | return priv->hw->wiphy->bands[band]; |
123 | |||
124 | for (i = 0; i < 3; i++) | ||
125 | if (priv->modes[i].mode == mode) | ||
126 | return &priv->modes[i]; | ||
127 | |||
128 | return NULL; | ||
129 | } | 123 | } |
130 | 124 | ||
131 | static int iwl3945_is_empty_essid(const char *essid, int essid_len) | 125 | static int iwl3945_is_empty_essid(const char *essid, int essid_len) |
@@ -547,7 +541,7 @@ u8 iwl3945_add_station(struct iwl3945_priv *priv, const u8 *addr, int is_ap, u8 | |||
547 | station->sta.sta.sta_id = index; | 541 | station->sta.sta.sta_id = index; |
548 | station->sta.station_flags = 0; | 542 | station->sta.station_flags = 0; |
549 | 543 | ||
550 | if (priv->phymode == MODE_IEEE80211A) | 544 | if (priv->band == IEEE80211_BAND_5GHZ) |
551 | rate = IWL_RATE_6M_PLCP; | 545 | rate = IWL_RATE_6M_PLCP; |
552 | else | 546 | else |
553 | rate = IWL_RATE_1M_PLCP; | 547 | rate = IWL_RATE_1M_PLCP; |
@@ -894,35 +888,37 @@ int iwl3945_send_statistics_request(struct iwl3945_priv *priv) | |||
894 | 888 | ||
895 | /** | 889 | /** |
896 | * iwl3945_set_rxon_channel - Set the phymode and channel values in staging RXON | 890 | * iwl3945_set_rxon_channel - Set the phymode and channel values in staging RXON |
897 | * @phymode: MODE_IEEE80211A sets to 5.2GHz; all else set to 2.4GHz | 891 | * @band: 2.4 or 5 GHz band |
898 | * @channel: Any channel valid for the requested phymode | 892 | * @channel: Any channel valid for the requested band |
899 | 893 | ||
900 | * In addition to setting the staging RXON, priv->phymode is also set. | 894 | * In addition to setting the staging RXON, priv->band is also set. |
901 | * | 895 | * |
902 | * NOTE: Does not commit to the hardware; it sets appropriate bit fields | 896 | * NOTE: Does not commit to the hardware; it sets appropriate bit fields |
903 | * in the staging RXON flag structure based on the phymode | 897 | * in the staging RXON flag structure based on the band |
904 | */ | 898 | */ |
905 | static int iwl3945_set_rxon_channel(struct iwl3945_priv *priv, u8 phymode, u16 channel) | 899 | static int iwl3945_set_rxon_channel(struct iwl3945_priv *priv, |
900 | enum ieee80211_band band, | ||
901 | u16 channel) | ||
906 | { | 902 | { |
907 | if (!iwl3945_get_channel_info(priv, phymode, channel)) { | 903 | if (!iwl3945_get_channel_info(priv, band, channel)) { |
908 | IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", | 904 | IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", |
909 | channel, phymode); | 905 | channel, band); |
910 | return -EINVAL; | 906 | return -EINVAL; |
911 | } | 907 | } |
912 | 908 | ||
913 | if ((le16_to_cpu(priv->staging_rxon.channel) == channel) && | 909 | if ((le16_to_cpu(priv->staging_rxon.channel) == channel) && |
914 | (priv->phymode == phymode)) | 910 | (priv->band == band)) |
915 | return 0; | 911 | return 0; |
916 | 912 | ||
917 | priv->staging_rxon.channel = cpu_to_le16(channel); | 913 | priv->staging_rxon.channel = cpu_to_le16(channel); |
918 | if (phymode == MODE_IEEE80211A) | 914 | if (band == IEEE80211_BAND_5GHZ) |
919 | priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK; | 915 | priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK; |
920 | else | 916 | else |
921 | priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; | 917 | priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; |
922 | 918 | ||
923 | priv->phymode = phymode; | 919 | priv->band = band; |
924 | 920 | ||
925 | IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, phymode); | 921 | IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band); |
926 | 922 | ||
927 | return 0; | 923 | return 0; |
928 | } | 924 | } |
@@ -1210,8 +1206,7 @@ static int iwl3945_commit_rxon(struct iwl3945_priv *priv) | |||
1210 | return -EIO; | 1206 | return -EIO; |
1211 | } | 1207 | } |
1212 | 1208 | ||
1213 | /* Init the hardware's rate fallback order based on the | 1209 | /* Init the hardware's rate fallback order based on the band */ |
1214 | * phymode */ | ||
1215 | rc = iwl3945_init_hw_rate_table(priv); | 1210 | rc = iwl3945_init_hw_rate_table(priv); |
1216 | if (rc) { | 1211 | if (rc) { |
1217 | IWL_ERROR("Error setting HW rate table: %02X\n", rc); | 1212 | IWL_ERROR("Error setting HW rate table: %02X\n", rc); |
@@ -2461,9 +2456,10 @@ static int iwl3945_set_rxon_hwcrypto(struct iwl3945_priv *priv, int hw_decrypt) | |||
2461 | return 0; | 2456 | return 0; |
2462 | } | 2457 | } |
2463 | 2458 | ||
2464 | static void iwl3945_set_flags_for_phymode(struct iwl3945_priv *priv, u8 phymode) | 2459 | static void iwl3945_set_flags_for_phymode(struct iwl3945_priv *priv, |
2460 | enum ieee80211_band band) | ||
2465 | { | 2461 | { |
2466 | if (phymode == MODE_IEEE80211A) { | 2462 | if (band == IEEE80211_BAND_5GHZ) { |
2467 | priv->staging_rxon.flags &= | 2463 | priv->staging_rxon.flags &= |
2468 | ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | 2464 | ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK |
2469 | | RXON_FLG_CCK_MSK); | 2465 | | RXON_FLG_CCK_MSK); |
@@ -2526,7 +2522,7 @@ static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv) | |||
2526 | priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; | 2522 | priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; |
2527 | #endif | 2523 | #endif |
2528 | 2524 | ||
2529 | ch_info = iwl3945_get_channel_info(priv, priv->phymode, | 2525 | ch_info = iwl3945_get_channel_info(priv, priv->band, |
2530 | le16_to_cpu(priv->staging_rxon.channel)); | 2526 | le16_to_cpu(priv->staging_rxon.channel)); |
2531 | 2527 | ||
2532 | if (!ch_info) | 2528 | if (!ch_info) |
@@ -2542,11 +2538,11 @@ static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv) | |||
2542 | 2538 | ||
2543 | priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); | 2539 | priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); |
2544 | if (is_channel_a_band(ch_info)) | 2540 | if (is_channel_a_band(ch_info)) |
2545 | priv->phymode = MODE_IEEE80211A; | 2541 | priv->band = IEEE80211_BAND_5GHZ; |
2546 | else | 2542 | else |
2547 | priv->phymode = MODE_IEEE80211G; | 2543 | priv->band = IEEE80211_BAND_2GHZ; |
2548 | 2544 | ||
2549 | iwl3945_set_flags_for_phymode(priv, priv->phymode); | 2545 | iwl3945_set_flags_for_phymode(priv, priv->band); |
2550 | 2546 | ||
2551 | priv->staging_rxon.ofdm_basic_rates = | 2547 | priv->staging_rxon.ofdm_basic_rates = |
2552 | (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; | 2548 | (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; |
@@ -2560,7 +2556,7 @@ static int iwl3945_set_mode(struct iwl3945_priv *priv, int mode) | |||
2560 | const struct iwl3945_channel_info *ch_info; | 2556 | const struct iwl3945_channel_info *ch_info; |
2561 | 2557 | ||
2562 | ch_info = iwl3945_get_channel_info(priv, | 2558 | ch_info = iwl3945_get_channel_info(priv, |
2563 | priv->phymode, | 2559 | priv->band, |
2564 | le16_to_cpu(priv->staging_rxon.channel)); | 2560 | le16_to_cpu(priv->staging_rxon.channel)); |
2565 | 2561 | ||
2566 | if (!ch_info || !is_channel_ibss(ch_info)) { | 2562 | if (!ch_info || !is_channel_ibss(ch_info)) { |
@@ -2792,7 +2788,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, | |||
2792 | goto drop_unlock; | 2788 | goto drop_unlock; |
2793 | } | 2789 | } |
2794 | 2790 | ||
2795 | if ((ctl->tx_rate & 0xFF) == IWL_INVALID_RATE) { | 2791 | if ((ctl->tx_rate->hw_value & 0xFF) == IWL_INVALID_RATE) { |
2796 | IWL_ERROR("ERROR: No TX rate available.\n"); | 2792 | IWL_ERROR("ERROR: No TX rate available.\n"); |
2797 | goto drop_unlock; | 2793 | goto drop_unlock; |
2798 | } | 2794 | } |
@@ -2992,12 +2988,12 @@ drop: | |||
2992 | 2988 | ||
2993 | static void iwl3945_set_rate(struct iwl3945_priv *priv) | 2989 | static void iwl3945_set_rate(struct iwl3945_priv *priv) |
2994 | { | 2990 | { |
2995 | const struct ieee80211_hw_mode *hw = NULL; | 2991 | const struct ieee80211_supported_band *sband = NULL; |
2996 | struct ieee80211_rate *rate; | 2992 | struct ieee80211_rate *rate; |
2997 | int i; | 2993 | int i; |
2998 | 2994 | ||
2999 | hw = iwl3945_get_hw_mode(priv, priv->phymode); | 2995 | sband = iwl3945_get_band(priv, priv->band); |
3000 | if (!hw) { | 2996 | if (!sband) { |
3001 | IWL_ERROR("Failed to set rate: unable to get hw mode\n"); | 2997 | IWL_ERROR("Failed to set rate: unable to get hw mode\n"); |
3002 | return; | 2998 | return; |
3003 | } | 2999 | } |
@@ -3005,24 +3001,17 @@ static void iwl3945_set_rate(struct iwl3945_priv *priv) | |||
3005 | priv->active_rate = 0; | 3001 | priv->active_rate = 0; |
3006 | priv->active_rate_basic = 0; | 3002 | priv->active_rate_basic = 0; |
3007 | 3003 | ||
3008 | IWL_DEBUG_RATE("Setting rates for 802.11%c\n", | 3004 | IWL_DEBUG_RATE("Setting rates for %s GHz\n", |
3009 | hw->mode == MODE_IEEE80211A ? | 3005 | sband->band == IEEE80211_BAND_2GHZ ? "2.4" : "5"); |
3010 | 'a' : ((hw->mode == MODE_IEEE80211B) ? 'b' : 'g')); | 3006 | |
3011 | 3007 | for (i = 0; i < sband->n_bitrates; i++) { | |
3012 | for (i = 0; i < hw->num_rates; i++) { | 3008 | rate = &sband->bitrates[i]; |
3013 | rate = &(hw->rates[i]); | 3009 | if ((rate->hw_value < IWL_RATE_COUNT) && |
3014 | if ((rate->val < IWL_RATE_COUNT) && | 3010 | !(rate->flags & IEEE80211_CHAN_DISABLED)) { |
3015 | (rate->flags & IEEE80211_RATE_SUPPORTED)) { | 3011 | IWL_DEBUG_RATE("Adding rate index %d (plcp %d)\n", |
3016 | IWL_DEBUG_RATE("Adding rate index %d (plcp %d)%s\n", | 3012 | rate->hw_value, iwl3945_rates[rate->hw_value].plcp); |
3017 | rate->val, iwl3945_rates[rate->val].plcp, | 3013 | priv->active_rate |= (1 << rate->hw_value); |
3018 | (rate->flags & IEEE80211_RATE_BASIC) ? | 3014 | } |
3019 | "*" : ""); | ||
3020 | priv->active_rate |= (1 << rate->val); | ||
3021 | if (rate->flags & IEEE80211_RATE_BASIC) | ||
3022 | priv->active_rate_basic |= (1 << rate->val); | ||
3023 | } else | ||
3024 | IWL_DEBUG_RATE("Not adding rate %d (plcp %d)\n", | ||
3025 | rate->val, iwl3945_rates[rate->val].plcp); | ||
3026 | } | 3015 | } |
3027 | 3016 | ||
3028 | IWL_DEBUG_RATE("Set active_rate = %0x, active_rate_basic = %0x\n", | 3017 | IWL_DEBUG_RATE("Set active_rate = %0x, active_rate_basic = %0x\n", |
@@ -3436,8 +3425,6 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv, | |||
3436 | tx_status->flags = | 3425 | tx_status->flags = |
3437 | iwl3945_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0; | 3426 | iwl3945_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0; |
3438 | 3427 | ||
3439 | tx_status->control.tx_rate = iwl3945_rate_index_from_plcp(tx_resp->rate); | ||
3440 | |||
3441 | IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", | 3428 | IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", |
3442 | txq_id, iwl3945_get_tx_fail_reason(status), status, | 3429 | txq_id, iwl3945_get_tx_fail_reason(status), status, |
3443 | tx_resp->rate, tx_resp->failure_frame); | 3430 | tx_resp->rate, tx_resp->failure_frame); |
@@ -5026,24 +5013,24 @@ static void iwl3945_init_band_reference(const struct iwl3945_priv *priv, int ban | |||
5026 | * Based on band and channel number. | 5013 | * Based on band and channel number. |
5027 | */ | 5014 | */ |
5028 | const struct iwl3945_channel_info *iwl3945_get_channel_info(const struct iwl3945_priv *priv, | 5015 | const struct iwl3945_channel_info *iwl3945_get_channel_info(const struct iwl3945_priv *priv, |
5029 | int phymode, u16 channel) | 5016 | enum ieee80211_band band, u16 channel) |
5030 | { | 5017 | { |
5031 | int i; | 5018 | int i; |
5032 | 5019 | ||
5033 | switch (phymode) { | 5020 | switch (band) { |
5034 | case MODE_IEEE80211A: | 5021 | case IEEE80211_BAND_5GHZ: |
5035 | for (i = 14; i < priv->channel_count; i++) { | 5022 | for (i = 14; i < priv->channel_count; i++) { |
5036 | if (priv->channel_info[i].channel == channel) | 5023 | if (priv->channel_info[i].channel == channel) |
5037 | return &priv->channel_info[i]; | 5024 | return &priv->channel_info[i]; |
5038 | } | 5025 | } |
5039 | break; | 5026 | break; |
5040 | 5027 | ||
5041 | case MODE_IEEE80211B: | 5028 | case IEEE80211_BAND_2GHZ: |
5042 | case MODE_IEEE80211G: | ||
5043 | if (channel >= 1 && channel <= 14) | 5029 | if (channel >= 1 && channel <= 14) |
5044 | return &priv->channel_info[channel - 1]; | 5030 | return &priv->channel_info[channel - 1]; |
5045 | break; | 5031 | break; |
5046 | 5032 | case IEEE80211_NUM_BANDS: | |
5033 | WARN_ON(1); | ||
5047 | } | 5034 | } |
5048 | 5035 | ||
5049 | return NULL; | 5036 | return NULL; |
@@ -5106,8 +5093,8 @@ static int iwl3945_init_channel_map(struct iwl3945_priv *priv) | |||
5106 | /* Loop through each band adding each of the channels */ | 5093 | /* Loop through each band adding each of the channels */ |
5107 | for (ch = 0; ch < eeprom_ch_count; ch++) { | 5094 | for (ch = 0; ch < eeprom_ch_count; ch++) { |
5108 | ch_info->channel = eeprom_ch_index[ch]; | 5095 | ch_info->channel = eeprom_ch_index[ch]; |
5109 | ch_info->phymode = (band == 1) ? MODE_IEEE80211B : | 5096 | ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : |
5110 | MODE_IEEE80211A; | 5097 | IEEE80211_BAND_5GHZ; |
5111 | 5098 | ||
5112 | /* permanently store EEPROM's channel regulatory flags | 5099 | /* permanently store EEPROM's channel regulatory flags |
5113 | * and max power in channel info database. */ | 5100 | * and max power in channel info database. */ |
@@ -5203,18 +5190,20 @@ static void iwl3945_free_channel_map(struct iwl3945_priv *priv) | |||
5203 | #define IWL_PASSIVE_DWELL_BASE (100) | 5190 | #define IWL_PASSIVE_DWELL_BASE (100) |
5204 | #define IWL_CHANNEL_TUNE_TIME 5 | 5191 | #define IWL_CHANNEL_TUNE_TIME 5 |
5205 | 5192 | ||
5206 | static inline u16 iwl3945_get_active_dwell_time(struct iwl3945_priv *priv, int phymode) | 5193 | static inline u16 iwl3945_get_active_dwell_time(struct iwl3945_priv *priv, |
5194 | enum ieee80211_band band) | ||
5207 | { | 5195 | { |
5208 | if (phymode == MODE_IEEE80211A) | 5196 | if (band == IEEE80211_BAND_5GHZ) |
5209 | return IWL_ACTIVE_DWELL_TIME_52; | 5197 | return IWL_ACTIVE_DWELL_TIME_52; |
5210 | else | 5198 | else |
5211 | return IWL_ACTIVE_DWELL_TIME_24; | 5199 | return IWL_ACTIVE_DWELL_TIME_24; |
5212 | } | 5200 | } |
5213 | 5201 | ||
5214 | static u16 iwl3945_get_passive_dwell_time(struct iwl3945_priv *priv, int phymode) | 5202 | static u16 iwl3945_get_passive_dwell_time(struct iwl3945_priv *priv, |
5203 | enum ieee80211_band band) | ||
5215 | { | 5204 | { |
5216 | u16 active = iwl3945_get_active_dwell_time(priv, phymode); | 5205 | u16 active = iwl3945_get_active_dwell_time(priv, band); |
5217 | u16 passive = (phymode != MODE_IEEE80211A) ? | 5206 | u16 passive = (band == IEEE80211_BAND_2GHZ) ? |
5218 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : | 5207 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : |
5219 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; | 5208 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; |
5220 | 5209 | ||
@@ -5234,28 +5223,29 @@ static u16 iwl3945_get_passive_dwell_time(struct iwl3945_priv *priv, int phymode | |||
5234 | return passive; | 5223 | return passive; |
5235 | } | 5224 | } |
5236 | 5225 | ||
5237 | static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, int phymode, | 5226 | static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, |
5227 | enum ieee80211_band band, | ||
5238 | u8 is_active, u8 direct_mask, | 5228 | u8 is_active, u8 direct_mask, |
5239 | struct iwl3945_scan_channel *scan_ch) | 5229 | struct iwl3945_scan_channel *scan_ch) |
5240 | { | 5230 | { |
5241 | const struct ieee80211_channel *channels = NULL; | 5231 | const struct ieee80211_channel *channels = NULL; |
5242 | const struct ieee80211_hw_mode *hw_mode; | 5232 | const struct ieee80211_supported_band *sband; |
5243 | const struct iwl3945_channel_info *ch_info; | 5233 | const struct iwl3945_channel_info *ch_info; |
5244 | u16 passive_dwell = 0; | 5234 | u16 passive_dwell = 0; |
5245 | u16 active_dwell = 0; | 5235 | u16 active_dwell = 0; |
5246 | int added, i; | 5236 | int added, i; |
5247 | 5237 | ||
5248 | hw_mode = iwl3945_get_hw_mode(priv, phymode); | 5238 | sband = iwl3945_get_band(priv, band); |
5249 | if (!hw_mode) | 5239 | if (!sband) |
5250 | return 0; | 5240 | return 0; |
5251 | 5241 | ||
5252 | channels = hw_mode->channels; | 5242 | channels = sband->channels; |
5253 | 5243 | ||
5254 | active_dwell = iwl3945_get_active_dwell_time(priv, phymode); | 5244 | active_dwell = iwl3945_get_active_dwell_time(priv, band); |
5255 | passive_dwell = iwl3945_get_passive_dwell_time(priv, phymode); | 5245 | passive_dwell = iwl3945_get_passive_dwell_time(priv, band); |
5256 | 5246 | ||
5257 | for (i = 0, added = 0; i < hw_mode->num_channels; i++) { | 5247 | for (i = 0, added = 0; i < sband->n_channels; i++) { |
5258 | if (channels[i].chan == | 5248 | if (channels[i].hw_value == |
5259 | le16_to_cpu(priv->active_rxon.channel)) { | 5249 | le16_to_cpu(priv->active_rxon.channel)) { |
5260 | if (iwl3945_is_associated(priv)) { | 5250 | if (iwl3945_is_associated(priv)) { |
5261 | IWL_DEBUG_SCAN | 5251 | IWL_DEBUG_SCAN |
@@ -5266,9 +5256,9 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, int phymode, | |||
5266 | } else if (priv->only_active_channel) | 5256 | } else if (priv->only_active_channel) |
5267 | continue; | 5257 | continue; |
5268 | 5258 | ||
5269 | scan_ch->channel = channels[i].chan; | 5259 | scan_ch->channel = channels[i].hw_value; |
5270 | 5260 | ||
5271 | ch_info = iwl3945_get_channel_info(priv, phymode, scan_ch->channel); | 5261 | ch_info = iwl3945_get_channel_info(priv, band, scan_ch->channel); |
5272 | if (!is_channel_valid(ch_info)) { | 5262 | if (!is_channel_valid(ch_info)) { |
5273 | IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", | 5263 | IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", |
5274 | scan_ch->channel); | 5264 | scan_ch->channel); |
@@ -5276,7 +5266,7 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, int phymode, | |||
5276 | } | 5266 | } |
5277 | 5267 | ||
5278 | if (!is_active || is_channel_passive(ch_info) || | 5268 | if (!is_active || is_channel_passive(ch_info) || |
5279 | !(channels[i].flag & IEEE80211_CHAN_W_ACTIVE_SCAN)) | 5269 | (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) |
5280 | scan_ch->type = 0; /* passive */ | 5270 | scan_ch->type = 0; /* passive */ |
5281 | else | 5271 | else |
5282 | scan_ch->type = 1; /* active */ | 5272 | scan_ch->type = 1; /* active */ |
@@ -5295,7 +5285,7 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, int phymode, | |||
5295 | /* scan_pwr_info->tpc.dsp_atten; */ | 5285 | /* scan_pwr_info->tpc.dsp_atten; */ |
5296 | 5286 | ||
5297 | /*scan_pwr_info->tpc.tx_gain; */ | 5287 | /*scan_pwr_info->tpc.tx_gain; */ |
5298 | if (phymode == MODE_IEEE80211A) | 5288 | if (band == IEEE80211_BAND_5GHZ) |
5299 | scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; | 5289 | scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; |
5300 | else { | 5290 | else { |
5301 | scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); | 5291 | scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); |
@@ -5319,41 +5309,23 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, int phymode, | |||
5319 | return added; | 5309 | return added; |
5320 | } | 5310 | } |
5321 | 5311 | ||
5322 | static void iwl3945_reset_channel_flag(struct iwl3945_priv *priv) | ||
5323 | { | ||
5324 | int i, j; | ||
5325 | for (i = 0; i < 3; i++) { | ||
5326 | struct ieee80211_hw_mode *hw_mode = (void *)&priv->modes[i]; | ||
5327 | for (j = 0; j < hw_mode->num_channels; j++) | ||
5328 | hw_mode->channels[j].flag = hw_mode->channels[j].val; | ||
5329 | } | ||
5330 | } | ||
5331 | |||
5332 | static void iwl3945_init_hw_rates(struct iwl3945_priv *priv, | 5312 | static void iwl3945_init_hw_rates(struct iwl3945_priv *priv, |
5333 | struct ieee80211_rate *rates) | 5313 | struct ieee80211_rate *rates) |
5334 | { | 5314 | { |
5335 | int i; | 5315 | int i; |
5336 | 5316 | ||
5337 | for (i = 0; i < IWL_RATE_COUNT; i++) { | 5317 | for (i = 0; i < IWL_RATE_COUNT; i++) { |
5338 | rates[i].rate = iwl3945_rates[i].ieee * 5; | 5318 | rates[i].bitrate = iwl3945_rates[i].ieee * 5; |
5339 | rates[i].val = i; /* Rate scaling will work on indexes */ | 5319 | rates[i].hw_value = i; /* Rate scaling will work on indexes */ |
5340 | rates[i].val2 = i; | 5320 | rates[i].hw_value_short = i; |
5341 | rates[i].flags = IEEE80211_RATE_SUPPORTED; | 5321 | rates[i].flags = 0; |
5342 | /* Only OFDM have the bits-per-symbol set */ | 5322 | if ((i > IWL_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) { |
5343 | if ((i <= IWL_LAST_OFDM_RATE) && (i >= IWL_FIRST_OFDM_RATE)) | ||
5344 | rates[i].flags |= IEEE80211_RATE_OFDM; | ||
5345 | else { | ||
5346 | /* | 5323 | /* |
5347 | * If CCK 1M then set rate flag to CCK else CCK_2 | 5324 | * If CCK != 1M then set short preamble rate flag. |
5348 | * which is CCK | PREAMBLE2 | ||
5349 | */ | 5325 | */ |
5350 | rates[i].flags |= (iwl3945_rates[i].plcp == 10) ? | 5326 | rates[i].flags |= (iwl3945_rates[i].plcp == 10) ? |
5351 | IEEE80211_RATE_CCK : IEEE80211_RATE_CCK_2; | 5327 | 0 : IEEE80211_RATE_SHORT_PREAMBLE; |
5352 | } | 5328 | } |
5353 | |||
5354 | /* Set up which ones are basic rates... */ | ||
5355 | if (IWL_BASIC_RATES_MASK & (1 << i)) | ||
5356 | rates[i].flags |= IEEE80211_RATE_BASIC; | ||
5357 | } | 5329 | } |
5358 | } | 5330 | } |
5359 | 5331 | ||
@@ -5363,67 +5335,41 @@ static void iwl3945_init_hw_rates(struct iwl3945_priv *priv, | |||
5363 | static int iwl3945_init_geos(struct iwl3945_priv *priv) | 5335 | static int iwl3945_init_geos(struct iwl3945_priv *priv) |
5364 | { | 5336 | { |
5365 | struct iwl3945_channel_info *ch; | 5337 | struct iwl3945_channel_info *ch; |
5366 | struct ieee80211_hw_mode *modes; | 5338 | struct ieee80211_supported_band *band; |
5367 | struct ieee80211_channel *channels; | 5339 | struct ieee80211_channel *channels; |
5368 | struct ieee80211_channel *geo_ch; | 5340 | struct ieee80211_channel *geo_ch; |
5369 | struct ieee80211_rate *rates; | 5341 | struct ieee80211_rate *rates; |
5370 | int i = 0; | 5342 | int i = 0; |
5371 | enum { | ||
5372 | A = 0, | ||
5373 | B = 1, | ||
5374 | G = 2, | ||
5375 | }; | ||
5376 | int mode_count = 3; | ||
5377 | 5343 | ||
5378 | if (priv->modes) { | 5344 | if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || |
5345 | priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { | ||
5379 | IWL_DEBUG_INFO("Geography modes already initialized.\n"); | 5346 | IWL_DEBUG_INFO("Geography modes already initialized.\n"); |
5380 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); | 5347 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); |
5381 | return 0; | 5348 | return 0; |
5382 | } | 5349 | } |
5383 | 5350 | ||
5384 | modes = kzalloc(sizeof(struct ieee80211_hw_mode) * mode_count, | ||
5385 | GFP_KERNEL); | ||
5386 | if (!modes) | ||
5387 | return -ENOMEM; | ||
5388 | |||
5389 | channels = kzalloc(sizeof(struct ieee80211_channel) * | 5351 | channels = kzalloc(sizeof(struct ieee80211_channel) * |
5390 | priv->channel_count, GFP_KERNEL); | 5352 | priv->channel_count, GFP_KERNEL); |
5391 | if (!channels) { | 5353 | if (!channels) |
5392 | kfree(modes); | ||
5393 | return -ENOMEM; | 5354 | return -ENOMEM; |
5394 | } | ||
5395 | 5355 | ||
5396 | rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_MAX_RATES + 1)), | 5356 | rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_MAX_RATES + 1)), |
5397 | GFP_KERNEL); | 5357 | GFP_KERNEL); |
5398 | if (!rates) { | 5358 | if (!rates) { |
5399 | kfree(modes); | ||
5400 | kfree(channels); | 5359 | kfree(channels); |
5401 | return -ENOMEM; | 5360 | return -ENOMEM; |
5402 | } | 5361 | } |
5403 | 5362 | ||
5404 | /* 0 = 802.11a | ||
5405 | * 1 = 802.11b | ||
5406 | * 2 = 802.11g | ||
5407 | */ | ||
5408 | |||
5409 | /* 5.2GHz channels start after the 2.4GHz channels */ | 5363 | /* 5.2GHz channels start after the 2.4GHz channels */ |
5410 | modes[A].mode = MODE_IEEE80211A; | 5364 | band = &priv->bands[IEEE80211_BAND_5GHZ]; |
5411 | modes[A].channels = &channels[ARRAY_SIZE(iwl3945_eeprom_band_1)]; | 5365 | band->channels = &channels[ARRAY_SIZE(iwl3945_eeprom_band_1)]; |
5412 | modes[A].rates = &rates[4]; | 5366 | band->bitrates = &rates[4]; |
5413 | modes[A].num_rates = 8; /* just OFDM */ | 5367 | band->n_bitrates = 8; /* just OFDM */ |
5414 | modes[A].num_channels = 0; | 5368 | |
5415 | 5369 | band = &priv->bands[IEEE80211_BAND_2GHZ]; | |
5416 | modes[B].mode = MODE_IEEE80211B; | 5370 | band->channels = channels; |
5417 | modes[B].channels = channels; | 5371 | band->bitrates = rates; |
5418 | modes[B].rates = rates; | 5372 | band->n_bitrates = 12; /* OFDM & CCK */ |
5419 | modes[B].num_rates = 4; /* just CCK */ | ||
5420 | modes[B].num_channels = 0; | ||
5421 | |||
5422 | modes[G].mode = MODE_IEEE80211G; | ||
5423 | modes[G].channels = channels; | ||
5424 | modes[G].rates = rates; | ||
5425 | modes[G].num_rates = 12; /* OFDM & CCK */ | ||
5426 | modes[G].num_channels = 0; | ||
5427 | 5373 | ||
5428 | priv->ieee_channels = channels; | 5374 | priv->ieee_channels = channels; |
5429 | priv->ieee_rates = rates; | 5375 | priv->ieee_rates = rates; |
@@ -5442,37 +5388,32 @@ static int iwl3945_init_geos(struct iwl3945_priv *priv) | |||
5442 | } | 5388 | } |
5443 | 5389 | ||
5444 | if (is_channel_a_band(ch)) | 5390 | if (is_channel_a_band(ch)) |
5445 | geo_ch = &modes[A].channels[modes[A].num_channels++]; | 5391 | geo_ch = &priv->bands[IEEE80211_BAND_5GHZ].channels[priv->bands[IEEE80211_BAND_5GHZ].n_channels++]; |
5446 | else { | 5392 | else |
5447 | geo_ch = &modes[B].channels[modes[B].num_channels++]; | 5393 | geo_ch = &priv->bands[IEEE80211_BAND_2GHZ].channels[priv->bands[IEEE80211_BAND_2GHZ].n_channels++]; |
5448 | modes[G].num_channels++; | ||
5449 | } | ||
5450 | 5394 | ||
5451 | geo_ch->freq = ieee80211chan2mhz(ch->channel); | 5395 | geo_ch->center_freq = ieee80211chan2mhz(ch->channel); |
5452 | geo_ch->chan = ch->channel; | 5396 | geo_ch->max_power = ch->max_power_avg; |
5453 | geo_ch->power_level = ch->max_power_avg; | 5397 | geo_ch->max_antenna_gain = 0xff; |
5454 | geo_ch->antenna_max = 0xff; | ||
5455 | 5398 | ||
5456 | if (is_channel_valid(ch)) { | 5399 | if (is_channel_valid(ch)) { |
5457 | geo_ch->flag = IEEE80211_CHAN_W_SCAN; | 5400 | if (!(ch->flags & EEPROM_CHANNEL_IBSS)) |
5458 | if (ch->flags & EEPROM_CHANNEL_IBSS) | 5401 | geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; |
5459 | geo_ch->flag |= IEEE80211_CHAN_W_IBSS; | ||
5460 | 5402 | ||
5461 | if (ch->flags & EEPROM_CHANNEL_ACTIVE) | 5403 | if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) |
5462 | geo_ch->flag |= IEEE80211_CHAN_W_ACTIVE_SCAN; | 5404 | geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
5463 | 5405 | ||
5464 | if (ch->flags & EEPROM_CHANNEL_RADAR) | 5406 | if (ch->flags & EEPROM_CHANNEL_RADAR) |
5465 | geo_ch->flag |= IEEE80211_CHAN_W_RADAR_DETECT; | 5407 | geo_ch->flags |= IEEE80211_CHAN_RADAR; |
5466 | 5408 | ||
5467 | if (ch->max_power_avg > priv->max_channel_txpower_limit) | 5409 | if (ch->max_power_avg > priv->max_channel_txpower_limit) |
5468 | priv->max_channel_txpower_limit = | 5410 | priv->max_channel_txpower_limit = |
5469 | ch->max_power_avg; | 5411 | ch->max_power_avg; |
5470 | } | 5412 | } else |
5471 | 5413 | geo_ch->flags |= IEEE80211_CHAN_DISABLED; | |
5472 | geo_ch->val = geo_ch->flag; | ||
5473 | } | 5414 | } |
5474 | 5415 | ||
5475 | if ((modes[A].num_channels == 0) && priv->is_abg) { | 5416 | if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && priv->is_abg) { |
5476 | printk(KERN_INFO DRV_NAME | 5417 | printk(KERN_INFO DRV_NAME |
5477 | ": Incorrectly detected BG card as ABG. Please send " | 5418 | ": Incorrectly detected BG card as ABG. Please send " |
5478 | "your PCI ID 0x%04X:0x%04X to maintainer.\n", | 5419 | "your PCI ID 0x%04X:0x%04X to maintainer.\n", |
@@ -5482,24 +5423,12 @@ static int iwl3945_init_geos(struct iwl3945_priv *priv) | |||
5482 | 5423 | ||
5483 | printk(KERN_INFO DRV_NAME | 5424 | printk(KERN_INFO DRV_NAME |
5484 | ": Tunable channels: %d 802.11bg, %d 802.11a channels\n", | 5425 | ": Tunable channels: %d 802.11bg, %d 802.11a channels\n", |
5485 | modes[G].num_channels, modes[A].num_channels); | 5426 | priv->bands[IEEE80211_BAND_2GHZ].n_channels, |
5427 | priv->bands[IEEE80211_BAND_5GHZ].n_channels); | ||
5486 | 5428 | ||
5487 | /* | 5429 | priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->bands[IEEE80211_BAND_2GHZ]; |
5488 | * NOTE: We register these in preference of order -- the | 5430 | priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->bands[IEEE80211_BAND_5GHZ]; |
5489 | * stack doesn't currently (as of 7.0.6 / Apr 24 '07) pick | ||
5490 | * a phymode based on rates or AP capabilities but seems to | ||
5491 | * configure it purely on if the channel being configured | ||
5492 | * is supported by a mode -- and the first match is taken | ||
5493 | */ | ||
5494 | |||
5495 | if (modes[G].num_channels) | ||
5496 | ieee80211_register_hwmode(priv->hw, &modes[G]); | ||
5497 | if (modes[B].num_channels) | ||
5498 | ieee80211_register_hwmode(priv->hw, &modes[B]); | ||
5499 | if (modes[A].num_channels) | ||
5500 | ieee80211_register_hwmode(priv->hw, &modes[A]); | ||
5501 | 5431 | ||
5502 | priv->modes = modes; | ||
5503 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); | 5432 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); |
5504 | 5433 | ||
5505 | return 0; | 5434 | return 0; |
@@ -5510,7 +5439,6 @@ static int iwl3945_init_geos(struct iwl3945_priv *priv) | |||
5510 | */ | 5439 | */ |
5511 | static void iwl3945_free_geos(struct iwl3945_priv *priv) | 5440 | static void iwl3945_free_geos(struct iwl3945_priv *priv) |
5512 | { | 5441 | { |
5513 | kfree(priv->modes); | ||
5514 | kfree(priv->ieee_channels); | 5442 | kfree(priv->ieee_channels); |
5515 | kfree(priv->ieee_rates); | 5443 | kfree(priv->ieee_rates); |
5516 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); | 5444 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); |
@@ -6519,7 +6447,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data) | |||
6519 | struct iwl3945_scan_cmd *scan; | 6447 | struct iwl3945_scan_cmd *scan; |
6520 | struct ieee80211_conf *conf = NULL; | 6448 | struct ieee80211_conf *conf = NULL; |
6521 | u8 direct_mask; | 6449 | u8 direct_mask; |
6522 | int phymode; | 6450 | enum ieee80211_band band; |
6523 | 6451 | ||
6524 | conf = ieee80211_get_hw_conf(priv->hw); | 6452 | conf = ieee80211_get_hw_conf(priv->hw); |
6525 | 6453 | ||
@@ -6651,13 +6579,13 @@ static void iwl3945_bg_request_scan(struct work_struct *data) | |||
6651 | scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; | 6579 | scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; |
6652 | scan->tx_cmd.rate = IWL_RATE_1M_PLCP; | 6580 | scan->tx_cmd.rate = IWL_RATE_1M_PLCP; |
6653 | scan->good_CRC_th = 0; | 6581 | scan->good_CRC_th = 0; |
6654 | phymode = MODE_IEEE80211G; | 6582 | band = IEEE80211_BAND_2GHZ; |
6655 | break; | 6583 | break; |
6656 | 6584 | ||
6657 | case 1: | 6585 | case 1: |
6658 | scan->tx_cmd.rate = IWL_RATE_6M_PLCP; | 6586 | scan->tx_cmd.rate = IWL_RATE_6M_PLCP; |
6659 | scan->good_CRC_th = IWL_GOOD_CRC_TH; | 6587 | scan->good_CRC_th = IWL_GOOD_CRC_TH; |
6660 | phymode = MODE_IEEE80211A; | 6588 | band = IEEE80211_BAND_5GHZ; |
6661 | break; | 6589 | break; |
6662 | 6590 | ||
6663 | default: | 6591 | default: |
@@ -6680,7 +6608,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data) | |||
6680 | 6608 | ||
6681 | scan->channel_count = | 6609 | scan->channel_count = |
6682 | iwl3945_get_channels_for_scan( | 6610 | iwl3945_get_channels_for_scan( |
6683 | priv, phymode, 1, /* active */ | 6611 | priv, band, 1, /* active */ |
6684 | direct_mask, | 6612 | direct_mask, |
6685 | (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); | 6613 | (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); |
6686 | 6614 | ||
@@ -6825,7 +6753,7 @@ static void iwl3945_bg_post_associate(struct work_struct *data) | |||
6825 | iwl3945_add_station(priv, iwl3945_broadcast_addr, 0, 0); | 6753 | iwl3945_add_station(priv, iwl3945_broadcast_addr, 0, 0); |
6826 | iwl3945_add_station(priv, priv->bssid, 0, 0); | 6754 | iwl3945_add_station(priv, priv->bssid, 0, 0); |
6827 | iwl3945_sync_sta(priv, IWL_STA_ID, | 6755 | iwl3945_sync_sta(priv, IWL_STA_ID, |
6828 | (priv->phymode == MODE_IEEE80211A)? | 6756 | (priv->band == IEEE80211_BAND_5GHZ) ? |
6829 | IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP, | 6757 | IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP, |
6830 | CMD_ASYNC); | 6758 | CMD_ASYNC); |
6831 | iwl3945_rate_scale_init(priv->hw, IWL_STA_ID); | 6759 | iwl3945_rate_scale_init(priv->hw, IWL_STA_ID); |
@@ -7020,7 +6948,7 @@ static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
7020 | } | 6948 | } |
7021 | 6949 | ||
7022 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, | 6950 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, |
7023 | ctl->tx_rate); | 6951 | ctl->tx_rate->bitrate); |
7024 | 6952 | ||
7025 | if (iwl3945_tx_skb(priv, skb, ctl)) | 6953 | if (iwl3945_tx_skb(priv, skb, ctl)) |
7026 | dev_kfree_skb_any(skb); | 6954 | dev_kfree_skb_any(skb); |
@@ -7079,7 +7007,7 @@ static int iwl3945_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
7079 | int ret = 0; | 7007 | int ret = 0; |
7080 | 7008 | ||
7081 | mutex_lock(&priv->mutex); | 7009 | mutex_lock(&priv->mutex); |
7082 | IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel); | 7010 | IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); |
7083 | 7011 | ||
7084 | priv->add_radiotap = !!(conf->flags & IEEE80211_CONF_RADIOTAP); | 7012 | priv->add_radiotap = !!(conf->flags & IEEE80211_CONF_RADIOTAP); |
7085 | 7013 | ||
@@ -7099,19 +7027,20 @@ static int iwl3945_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
7099 | 7027 | ||
7100 | spin_lock_irqsave(&priv->lock, flags); | 7028 | spin_lock_irqsave(&priv->lock, flags); |
7101 | 7029 | ||
7102 | ch_info = iwl3945_get_channel_info(priv, conf->phymode, conf->channel); | 7030 | ch_info = iwl3945_get_channel_info(priv, conf->channel->band, |
7031 | conf->channel->hw_value); | ||
7103 | if (!is_channel_valid(ch_info)) { | 7032 | if (!is_channel_valid(ch_info)) { |
7104 | IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this SKU.\n", | 7033 | IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this SKU.\n", |
7105 | conf->channel, conf->phymode); | 7034 | conf->channel->hw_value, conf->channel->band); |
7106 | IWL_DEBUG_MAC80211("leave - invalid channel\n"); | 7035 | IWL_DEBUG_MAC80211("leave - invalid channel\n"); |
7107 | spin_unlock_irqrestore(&priv->lock, flags); | 7036 | spin_unlock_irqrestore(&priv->lock, flags); |
7108 | ret = -EINVAL; | 7037 | ret = -EINVAL; |
7109 | goto out; | 7038 | goto out; |
7110 | } | 7039 | } |
7111 | 7040 | ||
7112 | iwl3945_set_rxon_channel(priv, conf->phymode, conf->channel); | 7041 | iwl3945_set_rxon_channel(priv, conf->channel->band, conf->channel->hw_value); |
7113 | 7042 | ||
7114 | iwl3945_set_flags_for_phymode(priv, conf->phymode); | 7043 | iwl3945_set_flags_for_phymode(priv, conf->channel->band); |
7115 | 7044 | ||
7116 | /* The list of supported rates and rate mask can be different | 7045 | /* The list of supported rates and rate mask can be different |
7117 | * for each phymode; since the phymode may have changed, reset | 7046 | * for each phymode; since the phymode may have changed, reset |
@@ -7892,65 +7821,6 @@ static ssize_t store_filter_flags(struct device *d, | |||
7892 | static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags, | 7821 | static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags, |
7893 | store_filter_flags); | 7822 | store_filter_flags); |
7894 | 7823 | ||
7895 | static ssize_t show_tune(struct device *d, | ||
7896 | struct device_attribute *attr, char *buf) | ||
7897 | { | ||
7898 | struct iwl3945_priv *priv = (struct iwl3945_priv *)d->driver_data; | ||
7899 | |||
7900 | return sprintf(buf, "0x%04X\n", | ||
7901 | (priv->phymode << 8) | | ||
7902 | le16_to_cpu(priv->active_rxon.channel)); | ||
7903 | } | ||
7904 | |||
7905 | static void iwl3945_set_flags_for_phymode(struct iwl3945_priv *priv, u8 phymode); | ||
7906 | |||
7907 | static ssize_t store_tune(struct device *d, | ||
7908 | struct device_attribute *attr, | ||
7909 | const char *buf, size_t count) | ||
7910 | { | ||
7911 | struct iwl3945_priv *priv = (struct iwl3945_priv *)d->driver_data; | ||
7912 | char *p = (char *)buf; | ||
7913 | u16 tune = simple_strtoul(p, &p, 0); | ||
7914 | u8 phymode = (tune >> 8) & 0xff; | ||
7915 | u16 channel = tune & 0xff; | ||
7916 | |||
7917 | IWL_DEBUG_INFO("Tune request to:%d channel:%d\n", phymode, channel); | ||
7918 | |||
7919 | mutex_lock(&priv->mutex); | ||
7920 | if ((le16_to_cpu(priv->staging_rxon.channel) != channel) || | ||
7921 | (priv->phymode != phymode)) { | ||
7922 | const struct iwl3945_channel_info *ch_info; | ||
7923 | |||
7924 | ch_info = iwl3945_get_channel_info(priv, phymode, channel); | ||
7925 | if (!ch_info) { | ||
7926 | IWL_WARNING("Requested invalid phymode/channel " | ||
7927 | "combination: %d %d\n", phymode, channel); | ||
7928 | mutex_unlock(&priv->mutex); | ||
7929 | return -EINVAL; | ||
7930 | } | ||
7931 | |||
7932 | /* Cancel any currently running scans... */ | ||
7933 | if (iwl3945_scan_cancel_timeout(priv, 100)) | ||
7934 | IWL_WARNING("Could not cancel scan.\n"); | ||
7935 | else { | ||
7936 | IWL_DEBUG_INFO("Committing phymode and " | ||
7937 | "rxon.channel = %d %d\n", | ||
7938 | phymode, channel); | ||
7939 | |||
7940 | iwl3945_set_rxon_channel(priv, phymode, channel); | ||
7941 | iwl3945_set_flags_for_phymode(priv, phymode); | ||
7942 | |||
7943 | iwl3945_set_rate(priv); | ||
7944 | iwl3945_commit_rxon(priv); | ||
7945 | } | ||
7946 | } | ||
7947 | mutex_unlock(&priv->mutex); | ||
7948 | |||
7949 | return count; | ||
7950 | } | ||
7951 | |||
7952 | static DEVICE_ATTR(tune, S_IWUSR | S_IRUGO, show_tune, store_tune); | ||
7953 | |||
7954 | #ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT | 7824 | #ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT |
7955 | 7825 | ||
7956 | static ssize_t show_measurement(struct device *d, | 7826 | static ssize_t show_measurement(struct device *d, |
@@ -8165,73 +8035,8 @@ static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR, show_power_level, | |||
8165 | static ssize_t show_channels(struct device *d, | 8035 | static ssize_t show_channels(struct device *d, |
8166 | struct device_attribute *attr, char *buf) | 8036 | struct device_attribute *attr, char *buf) |
8167 | { | 8037 | { |
8168 | struct iwl3945_priv *priv = dev_get_drvdata(d); | 8038 | /* all this shit doesn't belong into sysfs anyway */ |
8169 | int len = 0, i; | 8039 | return 0; |
8170 | struct ieee80211_channel *channels = NULL; | ||
8171 | const struct ieee80211_hw_mode *hw_mode = NULL; | ||
8172 | int count = 0; | ||
8173 | |||
8174 | if (!iwl3945_is_ready(priv)) | ||
8175 | return -EAGAIN; | ||
8176 | |||
8177 | hw_mode = iwl3945_get_hw_mode(priv, MODE_IEEE80211G); | ||
8178 | if (!hw_mode) | ||
8179 | hw_mode = iwl3945_get_hw_mode(priv, MODE_IEEE80211B); | ||
8180 | if (hw_mode) { | ||
8181 | channels = hw_mode->channels; | ||
8182 | count = hw_mode->num_channels; | ||
8183 | } | ||
8184 | |||
8185 | len += | ||
8186 | sprintf(&buf[len], | ||
8187 | "Displaying %d channels in 2.4GHz band " | ||
8188 | "(802.11bg):\n", count); | ||
8189 | |||
8190 | for (i = 0; i < count; i++) | ||
8191 | len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n", | ||
8192 | channels[i].chan, | ||
8193 | channels[i].power_level, | ||
8194 | channels[i]. | ||
8195 | flag & IEEE80211_CHAN_W_RADAR_DETECT ? | ||
8196 | " (IEEE 802.11h required)" : "", | ||
8197 | (!(channels[i].flag & IEEE80211_CHAN_W_IBSS) | ||
8198 | || (channels[i]. | ||
8199 | flag & | ||
8200 | IEEE80211_CHAN_W_RADAR_DETECT)) ? "" : | ||
8201 | ", IBSS", | ||
8202 | channels[i]. | ||
8203 | flag & IEEE80211_CHAN_W_ACTIVE_SCAN ? | ||
8204 | "active/passive" : "passive only"); | ||
8205 | |||
8206 | hw_mode = iwl3945_get_hw_mode(priv, MODE_IEEE80211A); | ||
8207 | if (hw_mode) { | ||
8208 | channels = hw_mode->channels; | ||
8209 | count = hw_mode->num_channels; | ||
8210 | } else { | ||
8211 | channels = NULL; | ||
8212 | count = 0; | ||
8213 | } | ||
8214 | |||
8215 | len += sprintf(&buf[len], "Displaying %d channels in 5.2GHz band " | ||
8216 | "(802.11a):\n", count); | ||
8217 | |||
8218 | for (i = 0; i < count; i++) | ||
8219 | len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n", | ||
8220 | channels[i].chan, | ||
8221 | channels[i].power_level, | ||
8222 | channels[i]. | ||
8223 | flag & IEEE80211_CHAN_W_RADAR_DETECT ? | ||
8224 | " (IEEE 802.11h required)" : "", | ||
8225 | (!(channels[i].flag & IEEE80211_CHAN_W_IBSS) | ||
8226 | || (channels[i]. | ||
8227 | flag & | ||
8228 | IEEE80211_CHAN_W_RADAR_DETECT)) ? "" : | ||
8229 | ", IBSS", | ||
8230 | channels[i]. | ||
8231 | flag & IEEE80211_CHAN_W_ACTIVE_SCAN ? | ||
8232 | "active/passive" : "passive only"); | ||
8233 | |||
8234 | return len; | ||
8235 | } | 8040 | } |
8236 | 8041 | ||
8237 | static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL); | 8042 | static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL); |
@@ -8411,7 +8216,6 @@ static struct attribute *iwl3945_sysfs_entries[] = { | |||
8411 | &dev_attr_statistics.attr, | 8216 | &dev_attr_statistics.attr, |
8412 | &dev_attr_status.attr, | 8217 | &dev_attr_status.attr, |
8413 | &dev_attr_temperature.attr, | 8218 | &dev_attr_temperature.attr, |
8414 | &dev_attr_tune.attr, | ||
8415 | &dev_attr_tx_power.attr, | 8219 | &dev_attr_tx_power.attr, |
8416 | 8220 | ||
8417 | NULL | 8221 | NULL |
@@ -8532,7 +8336,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
8532 | priv->data_retry_limit = -1; | 8336 | priv->data_retry_limit = -1; |
8533 | priv->ieee_channels = NULL; | 8337 | priv->ieee_channels = NULL; |
8534 | priv->ieee_rates = NULL; | 8338 | priv->ieee_rates = NULL; |
8535 | priv->phymode = -1; | 8339 | priv->band = IEEE80211_BAND_2GHZ; |
8536 | 8340 | ||
8537 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 8341 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
8538 | if (!err) | 8342 | if (!err) |
@@ -8614,7 +8418,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
8614 | priv->qos_data.qos_cap.val = 0; | 8418 | priv->qos_data.qos_cap.val = 0; |
8615 | #endif /* CONFIG_IWL3945_QOS */ | 8419 | #endif /* CONFIG_IWL3945_QOS */ |
8616 | 8420 | ||
8617 | iwl3945_set_rxon_channel(priv, MODE_IEEE80211G, 6); | 8421 | iwl3945_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); |
8618 | iwl3945_setup_deferred_work(priv); | 8422 | iwl3945_setup_deferred_work(priv); |
8619 | iwl3945_setup_rx_handlers(priv); | 8423 | iwl3945_setup_rx_handlers(priv); |
8620 | 8424 | ||
@@ -8665,7 +8469,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
8665 | IWL_ERROR("initializing geos failed: %d\n", err); | 8469 | IWL_ERROR("initializing geos failed: %d\n", err); |
8666 | goto out_free_channel_map; | 8470 | goto out_free_channel_map; |
8667 | } | 8471 | } |
8668 | iwl3945_reset_channel_flag(priv); | ||
8669 | 8472 | ||
8670 | iwl3945_rate_control_register(priv->hw); | 8473 | iwl3945_rate_control_register(priv->hw); |
8671 | err = ieee80211_register_hw(priv->hw); | 8474 | err = ieee80211_register_hw(priv->hw); |
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 5f38fc585eda..6de969de4c84 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c | |||
@@ -115,16 +115,10 @@ __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr) | |||
115 | return NULL; | 115 | return NULL; |
116 | } | 116 | } |
117 | 117 | ||
118 | static const struct ieee80211_hw_mode *iwl4965_get_hw_mode( | 118 | static const struct ieee80211_supported_band *iwl4965_get_hw_mode( |
119 | struct iwl4965_priv *priv, int mode) | 119 | struct iwl4965_priv *priv, enum ieee80211_band band) |
120 | { | 120 | { |
121 | int i; | 121 | return priv->hw->wiphy->bands[band]; |
122 | |||
123 | for (i = 0; i < 3; i++) | ||
124 | if (priv->modes[i].mode == mode) | ||
125 | return &priv->modes[i]; | ||
126 | |||
127 | return NULL; | ||
128 | } | 122 | } |
129 | 123 | ||
130 | static int iwl4965_is_empty_essid(const char *essid, int essid_len) | 124 | static int iwl4965_is_empty_essid(const char *essid, int essid_len) |
@@ -937,28 +931,29 @@ static int iwl4965_rxon_add_station(struct iwl4965_priv *priv, | |||
937 | * NOTE: Does not commit to the hardware; it sets appropriate bit fields | 931 | * NOTE: Does not commit to the hardware; it sets appropriate bit fields |
938 | * in the staging RXON flag structure based on the phymode | 932 | * in the staging RXON flag structure based on the phymode |
939 | */ | 933 | */ |
940 | static int iwl4965_set_rxon_channel(struct iwl4965_priv *priv, u8 phymode, | 934 | static int iwl4965_set_rxon_channel(struct iwl4965_priv *priv, |
935 | enum ieee80211_band band, | ||
941 | u16 channel) | 936 | u16 channel) |
942 | { | 937 | { |
943 | if (!iwl4965_get_channel_info(priv, phymode, channel)) { | 938 | if (!iwl4965_get_channel_info(priv, band, channel)) { |
944 | IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", | 939 | IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", |
945 | channel, phymode); | 940 | channel, band); |
946 | return -EINVAL; | 941 | return -EINVAL; |
947 | } | 942 | } |
948 | 943 | ||
949 | if ((le16_to_cpu(priv->staging_rxon.channel) == channel) && | 944 | if ((le16_to_cpu(priv->staging_rxon.channel) == channel) && |
950 | (priv->phymode == phymode)) | 945 | (priv->band == band)) |
951 | return 0; | 946 | return 0; |
952 | 947 | ||
953 | priv->staging_rxon.channel = cpu_to_le16(channel); | 948 | priv->staging_rxon.channel = cpu_to_le16(channel); |
954 | if (phymode == MODE_IEEE80211A) | 949 | if (band == IEEE80211_BAND_5GHZ) |
955 | priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK; | 950 | priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK; |
956 | else | 951 | else |
957 | priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; | 952 | priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; |
958 | 953 | ||
959 | priv->phymode = phymode; | 954 | priv->band = band; |
960 | 955 | ||
961 | IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, phymode); | 956 | IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band); |
962 | 957 | ||
963 | return 0; | 958 | return 0; |
964 | } | 959 | } |
@@ -2571,9 +2566,10 @@ static int iwl4965_set_rxon_hwcrypto(struct iwl4965_priv *priv, int hw_decrypt) | |||
2571 | return 0; | 2566 | return 0; |
2572 | } | 2567 | } |
2573 | 2568 | ||
2574 | static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv, u8 phymode) | 2569 | static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv, |
2570 | enum ieee80211_band band) | ||
2575 | { | 2571 | { |
2576 | if (phymode == MODE_IEEE80211A) { | 2572 | if (band == IEEE80211_BAND_5GHZ) { |
2577 | priv->staging_rxon.flags &= | 2573 | priv->staging_rxon.flags &= |
2578 | ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | 2574 | ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK |
2579 | | RXON_FLG_CCK_MSK); | 2575 | | RXON_FLG_CCK_MSK); |
@@ -2636,7 +2632,7 @@ static void iwl4965_connection_init_rx_config(struct iwl4965_priv *priv) | |||
2636 | priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; | 2632 | priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; |
2637 | #endif | 2633 | #endif |
2638 | 2634 | ||
2639 | ch_info = iwl4965_get_channel_info(priv, priv->phymode, | 2635 | ch_info = iwl4965_get_channel_info(priv, priv->band, |
2640 | le16_to_cpu(priv->staging_rxon.channel)); | 2636 | le16_to_cpu(priv->staging_rxon.channel)); |
2641 | 2637 | ||
2642 | if (!ch_info) | 2638 | if (!ch_info) |
@@ -2651,12 +2647,9 @@ static void iwl4965_connection_init_rx_config(struct iwl4965_priv *priv) | |||
2651 | ch_info = &priv->channel_info[0]; | 2647 | ch_info = &priv->channel_info[0]; |
2652 | 2648 | ||
2653 | priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); | 2649 | priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); |
2654 | if (is_channel_a_band(ch_info)) | 2650 | priv->band = ch_info->band; |
2655 | priv->phymode = MODE_IEEE80211A; | ||
2656 | else | ||
2657 | priv->phymode = MODE_IEEE80211G; | ||
2658 | 2651 | ||
2659 | iwl4965_set_flags_for_phymode(priv, priv->phymode); | 2652 | iwl4965_set_flags_for_phymode(priv, priv->band); |
2660 | 2653 | ||
2661 | priv->staging_rxon.ofdm_basic_rates = | 2654 | priv->staging_rxon.ofdm_basic_rates = |
2662 | (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; | 2655 | (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; |
@@ -2678,7 +2671,7 @@ static int iwl4965_set_mode(struct iwl4965_priv *priv, int mode) | |||
2678 | const struct iwl4965_channel_info *ch_info; | 2671 | const struct iwl4965_channel_info *ch_info; |
2679 | 2672 | ||
2680 | ch_info = iwl4965_get_channel_info(priv, | 2673 | ch_info = iwl4965_get_channel_info(priv, |
2681 | priv->phymode, | 2674 | priv->band, |
2682 | le16_to_cpu(priv->staging_rxon.channel)); | 2675 | le16_to_cpu(priv->staging_rxon.channel)); |
2683 | 2676 | ||
2684 | if (!ch_info || !is_channel_ibss(ch_info)) { | 2677 | if (!ch_info || !is_channel_ibss(ch_info)) { |
@@ -2918,7 +2911,7 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv, | |||
2918 | goto drop_unlock; | 2911 | goto drop_unlock; |
2919 | } | 2912 | } |
2920 | 2913 | ||
2921 | if ((ctl->tx_rate & 0xFF) == IWL_INVALID_RATE) { | 2914 | if ((ctl->tx_rate->hw_value & 0xFF) == IWL_INVALID_RATE) { |
2922 | IWL_ERROR("ERROR: No TX rate available.\n"); | 2915 | IWL_ERROR("ERROR: No TX rate available.\n"); |
2923 | goto drop_unlock; | 2916 | goto drop_unlock; |
2924 | } | 2917 | } |
@@ -3125,11 +3118,11 @@ drop: | |||
3125 | 3118 | ||
3126 | static void iwl4965_set_rate(struct iwl4965_priv *priv) | 3119 | static void iwl4965_set_rate(struct iwl4965_priv *priv) |
3127 | { | 3120 | { |
3128 | const struct ieee80211_hw_mode *hw = NULL; | 3121 | const struct ieee80211_supported_band *hw = NULL; |
3129 | struct ieee80211_rate *rate; | 3122 | struct ieee80211_rate *rate; |
3130 | int i; | 3123 | int i; |
3131 | 3124 | ||
3132 | hw = iwl4965_get_hw_mode(priv, priv->phymode); | 3125 | hw = iwl4965_get_hw_mode(priv, priv->band); |
3133 | if (!hw) { | 3126 | if (!hw) { |
3134 | IWL_ERROR("Failed to set rate: unable to get hw mode\n"); | 3127 | IWL_ERROR("Failed to set rate: unable to get hw mode\n"); |
3135 | return; | 3128 | return; |
@@ -3138,24 +3131,10 @@ static void iwl4965_set_rate(struct iwl4965_priv *priv) | |||
3138 | priv->active_rate = 0; | 3131 | priv->active_rate = 0; |
3139 | priv->active_rate_basic = 0; | 3132 | priv->active_rate_basic = 0; |
3140 | 3133 | ||
3141 | IWL_DEBUG_RATE("Setting rates for 802.11%c\n", | 3134 | for (i = 0; i < hw->n_bitrates; i++) { |
3142 | hw->mode == MODE_IEEE80211A ? | 3135 | rate = &(hw->bitrates[i]); |
3143 | 'a' : ((hw->mode == MODE_IEEE80211B) ? 'b' : 'g')); | 3136 | if (rate->hw_value < IWL_RATE_COUNT) |
3144 | 3137 | priv->active_rate |= (1 << rate->hw_value); | |
3145 | for (i = 0; i < hw->num_rates; i++) { | ||
3146 | rate = &(hw->rates[i]); | ||
3147 | if ((rate->val < IWL_RATE_COUNT) && | ||
3148 | (rate->flags & IEEE80211_RATE_SUPPORTED)) { | ||
3149 | IWL_DEBUG_RATE("Adding rate index %d (plcp %d)%s\n", | ||
3150 | rate->val, iwl4965_rates[rate->val].plcp, | ||
3151 | (rate->flags & IEEE80211_RATE_BASIC) ? | ||
3152 | "*" : ""); | ||
3153 | priv->active_rate |= (1 << rate->val); | ||
3154 | if (rate->flags & IEEE80211_RATE_BASIC) | ||
3155 | priv->active_rate_basic |= (1 << rate->val); | ||
3156 | } else | ||
3157 | IWL_DEBUG_RATE("Not adding rate %d (plcp %d)\n", | ||
3158 | rate->val, iwl4965_rates[rate->val].plcp); | ||
3159 | } | 3138 | } |
3160 | 3139 | ||
3161 | IWL_DEBUG_RATE("Set active_rate = %0x, active_rate_basic = %0x\n", | 3140 | IWL_DEBUG_RATE("Set active_rate = %0x, active_rate_basic = %0x\n", |
@@ -3775,9 +3754,6 @@ static void iwl4965_rx_reply_tx(struct iwl4965_priv *priv, | |||
3775 | tx_status->flags = | 3754 | tx_status->flags = |
3776 | iwl4965_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0; | 3755 | iwl4965_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0; |
3777 | 3756 | ||
3778 | tx_status->control.tx_rate = | ||
3779 | iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags); | ||
3780 | |||
3781 | IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " | 3757 | IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " |
3782 | "retries %d\n", txq_id, iwl4965_get_tx_fail_reason(status), | 3758 | "retries %d\n", txq_id, iwl4965_get_tx_fail_reason(status), |
3783 | status, le32_to_cpu(tx_resp->rate_n_flags), | 3759 | status, le32_to_cpu(tx_resp->rate_n_flags), |
@@ -5419,24 +5395,23 @@ static void iwl4965_init_band_reference(const struct iwl4965_priv *priv, | |||
5419 | * Based on band and channel number. | 5395 | * Based on band and channel number. |
5420 | */ | 5396 | */ |
5421 | const struct iwl4965_channel_info *iwl4965_get_channel_info(const struct iwl4965_priv *priv, | 5397 | const struct iwl4965_channel_info *iwl4965_get_channel_info(const struct iwl4965_priv *priv, |
5422 | int phymode, u16 channel) | 5398 | enum ieee80211_band band, u16 channel) |
5423 | { | 5399 | { |
5424 | int i; | 5400 | int i; |
5425 | 5401 | ||
5426 | switch (phymode) { | 5402 | switch (band) { |
5427 | case MODE_IEEE80211A: | 5403 | case IEEE80211_BAND_5GHZ: |
5428 | for (i = 14; i < priv->channel_count; i++) { | 5404 | for (i = 14; i < priv->channel_count; i++) { |
5429 | if (priv->channel_info[i].channel == channel) | 5405 | if (priv->channel_info[i].channel == channel) |
5430 | return &priv->channel_info[i]; | 5406 | return &priv->channel_info[i]; |
5431 | } | 5407 | } |
5432 | break; | 5408 | break; |
5433 | 5409 | case IEEE80211_BAND_2GHZ: | |
5434 | case MODE_IEEE80211B: | ||
5435 | case MODE_IEEE80211G: | ||
5436 | if (channel >= 1 && channel <= 14) | 5410 | if (channel >= 1 && channel <= 14) |
5437 | return &priv->channel_info[channel - 1]; | 5411 | return &priv->channel_info[channel - 1]; |
5438 | break; | 5412 | break; |
5439 | 5413 | default: | |
5414 | BUG(); | ||
5440 | } | 5415 | } |
5441 | 5416 | ||
5442 | return NULL; | 5417 | return NULL; |
@@ -5499,8 +5474,8 @@ static int iwl4965_init_channel_map(struct iwl4965_priv *priv) | |||
5499 | /* Loop through each band adding each of the channels */ | 5474 | /* Loop through each band adding each of the channels */ |
5500 | for (ch = 0; ch < eeprom_ch_count; ch++) { | 5475 | for (ch = 0; ch < eeprom_ch_count; ch++) { |
5501 | ch_info->channel = eeprom_ch_index[ch]; | 5476 | ch_info->channel = eeprom_ch_index[ch]; |
5502 | ch_info->phymode = (band == 1) ? MODE_IEEE80211B : | 5477 | ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : |
5503 | MODE_IEEE80211A; | 5478 | IEEE80211_BAND_5GHZ; |
5504 | 5479 | ||
5505 | /* permanently store EEPROM's channel regulatory flags | 5480 | /* permanently store EEPROM's channel regulatory flags |
5506 | * and max power in channel info database. */ | 5481 | * and max power in channel info database. */ |
@@ -5559,14 +5534,14 @@ static int iwl4965_init_channel_map(struct iwl4965_priv *priv) | |||
5559 | 5534 | ||
5560 | /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */ | 5535 | /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */ |
5561 | for (band = 6; band <= 7; band++) { | 5536 | for (band = 6; band <= 7; band++) { |
5562 | int phymode; | 5537 | enum ieee80211_band ieeeband; |
5563 | u8 fat_extension_chan; | 5538 | u8 fat_extension_chan; |
5564 | 5539 | ||
5565 | iwl4965_init_band_reference(priv, band, &eeprom_ch_count, | 5540 | iwl4965_init_band_reference(priv, band, &eeprom_ch_count, |
5566 | &eeprom_ch_info, &eeprom_ch_index); | 5541 | &eeprom_ch_info, &eeprom_ch_index); |
5567 | 5542 | ||
5568 | /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ | 5543 | /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ |
5569 | phymode = (band == 6) ? MODE_IEEE80211B : MODE_IEEE80211A; | 5544 | ieeeband = (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; |
5570 | 5545 | ||
5571 | /* Loop through each band adding each of the channels */ | 5546 | /* Loop through each band adding each of the channels */ |
5572 | for (ch = 0; ch < eeprom_ch_count; ch++) { | 5547 | for (ch = 0; ch < eeprom_ch_count; ch++) { |
@@ -5580,13 +5555,13 @@ static int iwl4965_init_channel_map(struct iwl4965_priv *priv) | |||
5580 | fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE; | 5555 | fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE; |
5581 | 5556 | ||
5582 | /* Set up driver's info for lower half */ | 5557 | /* Set up driver's info for lower half */ |
5583 | iwl4965_set_fat_chan_info(priv, phymode, | 5558 | iwl4965_set_fat_chan_info(priv, ieeeband, |
5584 | eeprom_ch_index[ch], | 5559 | eeprom_ch_index[ch], |
5585 | &(eeprom_ch_info[ch]), | 5560 | &(eeprom_ch_info[ch]), |
5586 | fat_extension_chan); | 5561 | fat_extension_chan); |
5587 | 5562 | ||
5588 | /* Set up driver's info for upper half */ | 5563 | /* Set up driver's info for upper half */ |
5589 | iwl4965_set_fat_chan_info(priv, phymode, | 5564 | iwl4965_set_fat_chan_info(priv, ieeeband, |
5590 | (eeprom_ch_index[ch] + 4), | 5565 | (eeprom_ch_index[ch] + 4), |
5591 | &(eeprom_ch_info[ch]), | 5566 | &(eeprom_ch_info[ch]), |
5592 | HT_IE_EXT_CHANNEL_BELOW); | 5567 | HT_IE_EXT_CHANNEL_BELOW); |
@@ -5628,18 +5603,20 @@ static void iwl4965_free_channel_map(struct iwl4965_priv *priv) | |||
5628 | #define IWL_PASSIVE_DWELL_BASE (100) | 5603 | #define IWL_PASSIVE_DWELL_BASE (100) |
5629 | #define IWL_CHANNEL_TUNE_TIME 5 | 5604 | #define IWL_CHANNEL_TUNE_TIME 5 |
5630 | 5605 | ||
5631 | static inline u16 iwl4965_get_active_dwell_time(struct iwl4965_priv *priv, int phymode) | 5606 | static inline u16 iwl4965_get_active_dwell_time(struct iwl4965_priv *priv, |
5607 | enum ieee80211_band band) | ||
5632 | { | 5608 | { |
5633 | if (phymode == MODE_IEEE80211A) | 5609 | if (band == IEEE80211_BAND_5GHZ) |
5634 | return IWL_ACTIVE_DWELL_TIME_52; | 5610 | return IWL_ACTIVE_DWELL_TIME_52; |
5635 | else | 5611 | else |
5636 | return IWL_ACTIVE_DWELL_TIME_24; | 5612 | return IWL_ACTIVE_DWELL_TIME_24; |
5637 | } | 5613 | } |
5638 | 5614 | ||
5639 | static u16 iwl4965_get_passive_dwell_time(struct iwl4965_priv *priv, int phymode) | 5615 | static u16 iwl4965_get_passive_dwell_time(struct iwl4965_priv *priv, |
5616 | enum ieee80211_band band) | ||
5640 | { | 5617 | { |
5641 | u16 active = iwl4965_get_active_dwell_time(priv, phymode); | 5618 | u16 active = iwl4965_get_active_dwell_time(priv, band); |
5642 | u16 passive = (phymode != MODE_IEEE80211A) ? | 5619 | u16 passive = (band != IEEE80211_BAND_5GHZ) ? |
5643 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : | 5620 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : |
5644 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; | 5621 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; |
5645 | 5622 | ||
@@ -5659,28 +5636,29 @@ static u16 iwl4965_get_passive_dwell_time(struct iwl4965_priv *priv, int phymode | |||
5659 | return passive; | 5636 | return passive; |
5660 | } | 5637 | } |
5661 | 5638 | ||
5662 | static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode, | 5639 | static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, |
5640 | enum ieee80211_band band, | ||
5663 | u8 is_active, u8 direct_mask, | 5641 | u8 is_active, u8 direct_mask, |
5664 | struct iwl4965_scan_channel *scan_ch) | 5642 | struct iwl4965_scan_channel *scan_ch) |
5665 | { | 5643 | { |
5666 | const struct ieee80211_channel *channels = NULL; | 5644 | const struct ieee80211_channel *channels = NULL; |
5667 | const struct ieee80211_hw_mode *hw_mode; | 5645 | const struct ieee80211_supported_band *sband; |
5668 | const struct iwl4965_channel_info *ch_info; | 5646 | const struct iwl4965_channel_info *ch_info; |
5669 | u16 passive_dwell = 0; | 5647 | u16 passive_dwell = 0; |
5670 | u16 active_dwell = 0; | 5648 | u16 active_dwell = 0; |
5671 | int added, i; | 5649 | int added, i; |
5672 | 5650 | ||
5673 | hw_mode = iwl4965_get_hw_mode(priv, phymode); | 5651 | sband = iwl4965_get_hw_mode(priv, band); |
5674 | if (!hw_mode) | 5652 | if (!sband) |
5675 | return 0; | 5653 | return 0; |
5676 | 5654 | ||
5677 | channels = hw_mode->channels; | 5655 | channels = sband->channels; |
5678 | 5656 | ||
5679 | active_dwell = iwl4965_get_active_dwell_time(priv, phymode); | 5657 | active_dwell = iwl4965_get_active_dwell_time(priv, band); |
5680 | passive_dwell = iwl4965_get_passive_dwell_time(priv, phymode); | 5658 | passive_dwell = iwl4965_get_passive_dwell_time(priv, band); |
5681 | 5659 | ||
5682 | for (i = 0, added = 0; i < hw_mode->num_channels; i++) { | 5660 | for (i = 0, added = 0; i < sband->n_channels; i++) { |
5683 | if (channels[i].chan == | 5661 | if (ieee80211_frequency_to_channel(channels[i].center_freq) == |
5684 | le16_to_cpu(priv->active_rxon.channel)) { | 5662 | le16_to_cpu(priv->active_rxon.channel)) { |
5685 | if (iwl4965_is_associated(priv)) { | 5663 | if (iwl4965_is_associated(priv)) { |
5686 | IWL_DEBUG_SCAN | 5664 | IWL_DEBUG_SCAN |
@@ -5691,9 +5669,9 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode, | |||
5691 | } else if (priv->only_active_channel) | 5669 | } else if (priv->only_active_channel) |
5692 | continue; | 5670 | continue; |
5693 | 5671 | ||
5694 | scan_ch->channel = channels[i].chan; | 5672 | scan_ch->channel = ieee80211_frequency_to_channel(channels[i].center_freq); |
5695 | 5673 | ||
5696 | ch_info = iwl4965_get_channel_info(priv, phymode, | 5674 | ch_info = iwl4965_get_channel_info(priv, band, |
5697 | scan_ch->channel); | 5675 | scan_ch->channel); |
5698 | if (!is_channel_valid(ch_info)) { | 5676 | if (!is_channel_valid(ch_info)) { |
5699 | IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", | 5677 | IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", |
@@ -5702,7 +5680,7 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode, | |||
5702 | } | 5680 | } |
5703 | 5681 | ||
5704 | if (!is_active || is_channel_passive(ch_info) || | 5682 | if (!is_active || is_channel_passive(ch_info) || |
5705 | !(channels[i].flag & IEEE80211_CHAN_W_ACTIVE_SCAN)) | 5683 | (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) |
5706 | scan_ch->type = 0; /* passive */ | 5684 | scan_ch->type = 0; /* passive */ |
5707 | else | 5685 | else |
5708 | scan_ch->type = 1; /* active */ | 5686 | scan_ch->type = 1; /* active */ |
@@ -5721,7 +5699,7 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode, | |||
5721 | /* scan_pwr_info->tpc.dsp_atten; */ | 5699 | /* scan_pwr_info->tpc.dsp_atten; */ |
5722 | 5700 | ||
5723 | /*scan_pwr_info->tpc.tx_gain; */ | 5701 | /*scan_pwr_info->tpc.tx_gain; */ |
5724 | if (phymode == MODE_IEEE80211A) | 5702 | if (band == IEEE80211_BAND_5GHZ) |
5725 | scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; | 5703 | scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; |
5726 | else { | 5704 | else { |
5727 | scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); | 5705 | scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); |
@@ -5745,41 +5723,23 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode, | |||
5745 | return added; | 5723 | return added; |
5746 | } | 5724 | } |
5747 | 5725 | ||
5748 | static void iwl4965_reset_channel_flag(struct iwl4965_priv *priv) | ||
5749 | { | ||
5750 | int i, j; | ||
5751 | for (i = 0; i < 3; i++) { | ||
5752 | struct ieee80211_hw_mode *hw_mode = (void *)&priv->modes[i]; | ||
5753 | for (j = 0; j < hw_mode->num_channels; j++) | ||
5754 | hw_mode->channels[j].flag = hw_mode->channels[j].val; | ||
5755 | } | ||
5756 | } | ||
5757 | |||
5758 | static void iwl4965_init_hw_rates(struct iwl4965_priv *priv, | 5726 | static void iwl4965_init_hw_rates(struct iwl4965_priv *priv, |
5759 | struct ieee80211_rate *rates) | 5727 | struct ieee80211_rate *rates) |
5760 | { | 5728 | { |
5761 | int i; | 5729 | int i; |
5762 | 5730 | ||
5763 | for (i = 0; i < IWL_RATE_COUNT; i++) { | 5731 | for (i = 0; i < IWL_RATE_COUNT; i++) { |
5764 | rates[i].rate = iwl4965_rates[i].ieee * 5; | 5732 | rates[i].bitrate = iwl4965_rates[i].ieee * 5; |
5765 | rates[i].val = i; /* Rate scaling will work on indexes */ | 5733 | rates[i].hw_value = i; /* Rate scaling will work on indexes */ |
5766 | rates[i].val2 = i; | 5734 | rates[i].hw_value_short = i; |
5767 | rates[i].flags = IEEE80211_RATE_SUPPORTED; | 5735 | rates[i].flags = 0; |
5768 | /* Only OFDM have the bits-per-symbol set */ | 5736 | if ((i > IWL_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) { |
5769 | if ((i <= IWL_LAST_OFDM_RATE) && (i >= IWL_FIRST_OFDM_RATE)) | ||
5770 | rates[i].flags |= IEEE80211_RATE_OFDM; | ||
5771 | else { | ||
5772 | /* | 5737 | /* |
5773 | * If CCK 1M then set rate flag to CCK else CCK_2 | 5738 | * If CCK != 1M then set short preamble rate flag. |
5774 | * which is CCK | PREAMBLE2 | ||
5775 | */ | 5739 | */ |
5776 | rates[i].flags |= (iwl4965_rates[i].plcp == 10) ? | 5740 | rates[i].flags |= (iwl4965_rates[i].plcp == 10) ? |
5777 | IEEE80211_RATE_CCK : IEEE80211_RATE_CCK_2; | 5741 | 0 : IEEE80211_RATE_SHORT_PREAMBLE; |
5778 | } | 5742 | } |
5779 | |||
5780 | /* Set up which ones are basic rates... */ | ||
5781 | if (IWL_BASIC_RATES_MASK & (1 << i)) | ||
5782 | rates[i].flags |= IEEE80211_RATE_BASIC; | ||
5783 | } | 5743 | } |
5784 | } | 5744 | } |
5785 | 5745 | ||
@@ -5789,74 +5749,47 @@ static void iwl4965_init_hw_rates(struct iwl4965_priv *priv, | |||
5789 | static int iwl4965_init_geos(struct iwl4965_priv *priv) | 5749 | static int iwl4965_init_geos(struct iwl4965_priv *priv) |
5790 | { | 5750 | { |
5791 | struct iwl4965_channel_info *ch; | 5751 | struct iwl4965_channel_info *ch; |
5792 | struct ieee80211_hw_mode *modes; | 5752 | struct ieee80211_supported_band *band; |
5793 | struct ieee80211_channel *channels; | 5753 | struct ieee80211_channel *channels; |
5794 | struct ieee80211_channel *geo_ch; | 5754 | struct ieee80211_channel *geo_ch; |
5795 | struct ieee80211_rate *rates; | 5755 | struct ieee80211_rate *rates; |
5796 | int i = 0; | 5756 | int i = 0; |
5797 | enum { | ||
5798 | A = 0, | ||
5799 | B = 1, | ||
5800 | G = 2, | ||
5801 | }; | ||
5802 | int mode_count = 3; | ||
5803 | 5757 | ||
5804 | if (priv->modes) { | 5758 | if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || |
5759 | priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { | ||
5805 | IWL_DEBUG_INFO("Geography modes already initialized.\n"); | 5760 | IWL_DEBUG_INFO("Geography modes already initialized.\n"); |
5806 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); | 5761 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); |
5807 | return 0; | 5762 | return 0; |
5808 | } | 5763 | } |
5809 | 5764 | ||
5810 | modes = kzalloc(sizeof(struct ieee80211_hw_mode) * mode_count, | ||
5811 | GFP_KERNEL); | ||
5812 | if (!modes) | ||
5813 | return -ENOMEM; | ||
5814 | |||
5815 | channels = kzalloc(sizeof(struct ieee80211_channel) * | 5765 | channels = kzalloc(sizeof(struct ieee80211_channel) * |
5816 | priv->channel_count, GFP_KERNEL); | 5766 | priv->channel_count, GFP_KERNEL); |
5817 | if (!channels) { | 5767 | if (!channels) |
5818 | kfree(modes); | ||
5819 | return -ENOMEM; | 5768 | return -ENOMEM; |
5820 | } | ||
5821 | 5769 | ||
5822 | rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_MAX_RATES + 1)), | 5770 | rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_MAX_RATES + 1)), |
5823 | GFP_KERNEL); | 5771 | GFP_KERNEL); |
5824 | if (!rates) { | 5772 | if (!rates) { |
5825 | kfree(modes); | ||
5826 | kfree(channels); | 5773 | kfree(channels); |
5827 | return -ENOMEM; | 5774 | return -ENOMEM; |
5828 | } | 5775 | } |
5829 | 5776 | ||
5830 | /* 0 = 802.11a | ||
5831 | * 1 = 802.11b | ||
5832 | * 2 = 802.11g | ||
5833 | */ | ||
5834 | |||
5835 | /* 5.2GHz channels start after the 2.4GHz channels */ | 5777 | /* 5.2GHz channels start after the 2.4GHz channels */ |
5836 | modes[A].mode = MODE_IEEE80211A; | ||
5837 | modes[A].channels = &channels[ARRAY_SIZE(iwl4965_eeprom_band_1)]; | ||
5838 | modes[A].rates = rates; | ||
5839 | modes[A].num_rates = 8; /* just OFDM */ | ||
5840 | modes[A].rates = &rates[4]; | ||
5841 | modes[A].num_channels = 0; | ||
5842 | #ifdef CONFIG_IWL4965_HT | 5778 | #ifdef CONFIG_IWL4965_HT |
5843 | iwl4965_init_ht_hw_capab(&modes[A].ht_info, MODE_IEEE80211A); | 5779 | iwl4965_init_ht_hw_capab(&modes[A].ht_info, MODE_IEEE80211A); |
5844 | #endif | 5780 | #endif |
5845 | |||
5846 | modes[B].mode = MODE_IEEE80211B; | ||
5847 | modes[B].channels = channels; | ||
5848 | modes[B].rates = rates; | ||
5849 | modes[B].num_rates = 4; /* just CCK */ | ||
5850 | modes[B].num_channels = 0; | ||
5851 | |||
5852 | modes[G].mode = MODE_IEEE80211G; | ||
5853 | modes[G].channels = channels; | ||
5854 | modes[G].rates = rates; | ||
5855 | modes[G].num_rates = 12; /* OFDM & CCK */ | ||
5856 | modes[G].num_channels = 0; | ||
5857 | #ifdef CONFIG_IWL4965_HT | 5781 | #ifdef CONFIG_IWL4965_HT |
5858 | iwl4965_init_ht_hw_capab(&modes[G].ht_info, MODE_IEEE80211G); | 5782 | iwl4965_init_ht_hw_capab(&modes[G].ht_info, MODE_IEEE80211G); |
5859 | #endif | 5783 | #endif |
5784 | band = &priv->bands[IEEE80211_BAND_5GHZ]; | ||
5785 | band->channels = &channels[ARRAY_SIZE(iwl4965_eeprom_band_1)]; | ||
5786 | band->bitrates = &rates[4]; | ||
5787 | band->n_bitrates = 8; /* just OFDM */ | ||
5788 | |||
5789 | band = &priv->bands[IEEE80211_BAND_2GHZ]; | ||
5790 | band->channels = channels; | ||
5791 | band->bitrates = rates; | ||
5792 | band->n_bitrates = 12; /* OFDM & CCK */ | ||
5860 | 5793 | ||
5861 | priv->ieee_channels = channels; | 5794 | priv->ieee_channels = channels; |
5862 | priv->ieee_rates = rates; | 5795 | priv->ieee_rates = rates; |
@@ -5875,37 +5808,32 @@ static int iwl4965_init_geos(struct iwl4965_priv *priv) | |||
5875 | } | 5808 | } |
5876 | 5809 | ||
5877 | if (is_channel_a_band(ch)) { | 5810 | if (is_channel_a_band(ch)) { |
5878 | geo_ch = &modes[A].channels[modes[A].num_channels++]; | 5811 | geo_ch = &priv->bands[IEEE80211_BAND_5GHZ].channels[priv->bands[IEEE80211_BAND_5GHZ].n_channels++]; |
5879 | } else { | 5812 | } else |
5880 | geo_ch = &modes[B].channels[modes[B].num_channels++]; | 5813 | geo_ch = &priv->bands[IEEE80211_BAND_2GHZ].channels[priv->bands[IEEE80211_BAND_2GHZ].n_channels++]; |
5881 | modes[G].num_channels++; | ||
5882 | } | ||
5883 | 5814 | ||
5884 | geo_ch->freq = ieee80211chan2mhz(ch->channel); | 5815 | geo_ch->center_freq = ieee80211chan2mhz(ch->channel); |
5885 | geo_ch->chan = ch->channel; | 5816 | geo_ch->max_power = ch->max_power_avg; |
5886 | geo_ch->power_level = ch->max_power_avg; | 5817 | geo_ch->max_antenna_gain = 0xff; |
5887 | geo_ch->antenna_max = 0xff; | ||
5888 | 5818 | ||
5889 | if (is_channel_valid(ch)) { | 5819 | if (is_channel_valid(ch)) { |
5890 | geo_ch->flag = IEEE80211_CHAN_W_SCAN; | 5820 | if (!(ch->flags & EEPROM_CHANNEL_IBSS)) |
5891 | if (ch->flags & EEPROM_CHANNEL_IBSS) | 5821 | geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; |
5892 | geo_ch->flag |= IEEE80211_CHAN_W_IBSS; | ||
5893 | 5822 | ||
5894 | if (ch->flags & EEPROM_CHANNEL_ACTIVE) | 5823 | if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) |
5895 | geo_ch->flag |= IEEE80211_CHAN_W_ACTIVE_SCAN; | 5824 | geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
5896 | 5825 | ||
5897 | if (ch->flags & EEPROM_CHANNEL_RADAR) | 5826 | if (ch->flags & EEPROM_CHANNEL_RADAR) |
5898 | geo_ch->flag |= IEEE80211_CHAN_W_RADAR_DETECT; | 5827 | geo_ch->flags |= IEEE80211_CHAN_RADAR; |
5899 | 5828 | ||
5900 | if (ch->max_power_avg > priv->max_channel_txpower_limit) | 5829 | if (ch->max_power_avg > priv->max_channel_txpower_limit) |
5901 | priv->max_channel_txpower_limit = | 5830 | priv->max_channel_txpower_limit = |
5902 | ch->max_power_avg; | 5831 | ch->max_power_avg; |
5903 | } | 5832 | } else |
5904 | 5833 | geo_ch->flags |= IEEE80211_CHAN_DISABLED; | |
5905 | geo_ch->val = geo_ch->flag; | ||
5906 | } | 5834 | } |
5907 | 5835 | ||
5908 | if ((modes[A].num_channels == 0) && priv->is_abg) { | 5836 | if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && priv->is_abg) { |
5909 | printk(KERN_INFO DRV_NAME | 5837 | printk(KERN_INFO DRV_NAME |
5910 | ": Incorrectly detected BG card as ABG. Please send " | 5838 | ": Incorrectly detected BG card as ABG. Please send " |
5911 | "your PCI ID 0x%04X:0x%04X to maintainer.\n", | 5839 | "your PCI ID 0x%04X:0x%04X to maintainer.\n", |
@@ -5915,24 +5843,12 @@ static int iwl4965_init_geos(struct iwl4965_priv *priv) | |||
5915 | 5843 | ||
5916 | printk(KERN_INFO DRV_NAME | 5844 | printk(KERN_INFO DRV_NAME |
5917 | ": Tunable channels: %d 802.11bg, %d 802.11a channels\n", | 5845 | ": Tunable channels: %d 802.11bg, %d 802.11a channels\n", |
5918 | modes[G].num_channels, modes[A].num_channels); | 5846 | priv->bands[IEEE80211_BAND_2GHZ].n_channels, |
5919 | 5847 | priv->bands[IEEE80211_BAND_5GHZ].n_channels); | |
5920 | /* | ||
5921 | * NOTE: We register these in preference of order -- the | ||
5922 | * stack doesn't currently (as of 7.0.6 / Apr 24 '07) pick | ||
5923 | * a phymode based on rates or AP capabilities but seems to | ||
5924 | * configure it purely on if the channel being configured | ||
5925 | * is supported by a mode -- and the first match is taken | ||
5926 | */ | ||
5927 | 5848 | ||
5928 | if (modes[G].num_channels) | 5849 | priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->bands[IEEE80211_BAND_2GHZ]; |
5929 | ieee80211_register_hwmode(priv->hw, &modes[G]); | 5850 | priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->bands[IEEE80211_BAND_5GHZ]; |
5930 | if (modes[B].num_channels) | ||
5931 | ieee80211_register_hwmode(priv->hw, &modes[B]); | ||
5932 | if (modes[A].num_channels) | ||
5933 | ieee80211_register_hwmode(priv->hw, &modes[A]); | ||
5934 | 5851 | ||
5935 | priv->modes = modes; | ||
5936 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); | 5852 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); |
5937 | 5853 | ||
5938 | return 0; | 5854 | return 0; |
@@ -5943,7 +5859,6 @@ static int iwl4965_init_geos(struct iwl4965_priv *priv) | |||
5943 | */ | 5859 | */ |
5944 | static void iwl4965_free_geos(struct iwl4965_priv *priv) | 5860 | static void iwl4965_free_geos(struct iwl4965_priv *priv) |
5945 | { | 5861 | { |
5946 | kfree(priv->modes); | ||
5947 | kfree(priv->ieee_channels); | 5862 | kfree(priv->ieee_channels); |
5948 | kfree(priv->ieee_rates); | 5863 | kfree(priv->ieee_rates); |
5949 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); | 5864 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); |
@@ -6945,7 +6860,7 @@ static void iwl4965_bg_request_scan(struct work_struct *data) | |||
6945 | struct iwl4965_scan_cmd *scan; | 6860 | struct iwl4965_scan_cmd *scan; |
6946 | struct ieee80211_conf *conf = NULL; | 6861 | struct ieee80211_conf *conf = NULL; |
6947 | u8 direct_mask; | 6862 | u8 direct_mask; |
6948 | int phymode; | 6863 | enum ieee80211_band band; |
6949 | 6864 | ||
6950 | conf = ieee80211_get_hw_conf(priv->hw); | 6865 | conf = ieee80211_get_hw_conf(priv->hw); |
6951 | 6866 | ||
@@ -7075,7 +6990,7 @@ static void iwl4965_bg_request_scan(struct work_struct *data) | |||
7075 | RATE_MCS_ANT_B_MSK|RATE_MCS_CCK_MSK); | 6990 | RATE_MCS_ANT_B_MSK|RATE_MCS_CCK_MSK); |
7076 | 6991 | ||
7077 | scan->good_CRC_th = 0; | 6992 | scan->good_CRC_th = 0; |
7078 | phymode = MODE_IEEE80211G; | 6993 | band = IEEE80211_BAND_2GHZ; |
7079 | break; | 6994 | break; |
7080 | 6995 | ||
7081 | case 1: | 6996 | case 1: |
@@ -7083,7 +6998,7 @@ static void iwl4965_bg_request_scan(struct work_struct *data) | |||
7083 | iwl4965_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, | 6998 | iwl4965_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, |
7084 | RATE_MCS_ANT_B_MSK); | 6999 | RATE_MCS_ANT_B_MSK); |
7085 | scan->good_CRC_th = IWL_GOOD_CRC_TH; | 7000 | scan->good_CRC_th = IWL_GOOD_CRC_TH; |
7086 | phymode = MODE_IEEE80211A; | 7001 | band = IEEE80211_BAND_5GHZ; |
7087 | break; | 7002 | break; |
7088 | 7003 | ||
7089 | default: | 7004 | default: |
@@ -7113,7 +7028,7 @@ static void iwl4965_bg_request_scan(struct work_struct *data) | |||
7113 | 7028 | ||
7114 | scan->channel_count = | 7029 | scan->channel_count = |
7115 | iwl4965_get_channels_for_scan( | 7030 | iwl4965_get_channels_for_scan( |
7116 | priv, phymode, 1, /* active */ | 7031 | priv, band, 1, /* active */ |
7117 | direct_mask, | 7032 | direct_mask, |
7118 | (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); | 7033 | (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); |
7119 | 7034 | ||
@@ -7463,7 +7378,7 @@ static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
7463 | } | 7378 | } |
7464 | 7379 | ||
7465 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, | 7380 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, |
7466 | ctl->tx_rate); | 7381 | ctl->tx_rate->bitrate); |
7467 | 7382 | ||
7468 | if (iwl4965_tx_skb(priv, skb, ctl)) | 7383 | if (iwl4965_tx_skb(priv, skb, ctl)) |
7469 | dev_kfree_skb_any(skb); | 7384 | dev_kfree_skb_any(skb); |
@@ -7522,7 +7437,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
7522 | int ret = 0; | 7437 | int ret = 0; |
7523 | 7438 | ||
7524 | mutex_lock(&priv->mutex); | 7439 | mutex_lock(&priv->mutex); |
7525 | IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel); | 7440 | IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); |
7526 | 7441 | ||
7527 | priv->add_radiotap = !!(conf->flags & IEEE80211_CONF_RADIOTAP); | 7442 | priv->add_radiotap = !!(conf->flags & IEEE80211_CONF_RADIOTAP); |
7528 | 7443 | ||
@@ -7542,10 +7457,9 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
7542 | 7457 | ||
7543 | spin_lock_irqsave(&priv->lock, flags); | 7458 | spin_lock_irqsave(&priv->lock, flags); |
7544 | 7459 | ||
7545 | ch_info = iwl4965_get_channel_info(priv, conf->phymode, conf->channel); | 7460 | ch_info = iwl4965_get_channel_info(priv, conf->channel->band, |
7461 | ieee80211_frequency_to_channel(conf->channel->center_freq)); | ||
7546 | if (!is_channel_valid(ch_info)) { | 7462 | if (!is_channel_valid(ch_info)) { |
7547 | IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this SKU.\n", | ||
7548 | conf->channel, conf->phymode); | ||
7549 | IWL_DEBUG_MAC80211("leave - invalid channel\n"); | 7463 | IWL_DEBUG_MAC80211("leave - invalid channel\n"); |
7550 | spin_unlock_irqrestore(&priv->lock, flags); | 7464 | spin_unlock_irqrestore(&priv->lock, flags); |
7551 | ret = -EINVAL; | 7465 | ret = -EINVAL; |
@@ -7564,12 +7478,13 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
7564 | priv->staging_rxon.flags = 0; | 7478 | priv->staging_rxon.flags = 0; |
7565 | #endif /* CONFIG_IWL4965_HT */ | 7479 | #endif /* CONFIG_IWL4965_HT */ |
7566 | 7480 | ||
7567 | iwl4965_set_rxon_channel(priv, conf->phymode, conf->channel); | 7481 | iwl4965_set_rxon_channel(priv, conf->channel->band, |
7482 | ieee80211_frequency_to_channel(conf->channel->center_freq)); | ||
7568 | 7483 | ||
7569 | iwl4965_set_flags_for_phymode(priv, conf->phymode); | 7484 | iwl4965_set_flags_for_phymode(priv, conf->channel->band); |
7570 | 7485 | ||
7571 | /* The list of supported rates and rate mask can be different | 7486 | /* The list of supported rates and rate mask can be different |
7572 | * for each phymode; since the phymode may have changed, reset | 7487 | * for each band; since the band may have changed, reset |
7573 | * the rate mask to what mac80211 lists */ | 7488 | * the rate mask to what mac80211 lists */ |
7574 | iwl4965_set_rate(priv); | 7489 | iwl4965_set_rate(priv); |
7575 | 7490 | ||
@@ -7839,7 +7754,7 @@ static void iwl4965_bss_info_changed(struct ieee80211_hw *hw, | |||
7839 | } | 7754 | } |
7840 | 7755 | ||
7841 | if (changes & BSS_CHANGED_ERP_CTS_PROT) { | 7756 | if (changes & BSS_CHANGED_ERP_CTS_PROT) { |
7842 | if (bss_conf->use_cts_prot && (priv->phymode != MODE_IEEE80211A)) | 7757 | if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ)) |
7843 | priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK; | 7758 | priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK; |
7844 | else | 7759 | else |
7845 | priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK; | 7760 | priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK; |
@@ -8277,7 +8192,6 @@ static void iwl4965_set_ht_capab(struct ieee80211_hw *hw, | |||
8277 | u8 use_current_config) | 8192 | u8 use_current_config) |
8278 | { | 8193 | { |
8279 | struct ieee80211_conf *conf = &hw->conf; | 8194 | struct ieee80211_conf *conf = &hw->conf; |
8280 | struct ieee80211_hw_mode *mode = conf->mode; | ||
8281 | 8195 | ||
8282 | if (use_current_config) { | 8196 | if (use_current_config) { |
8283 | ht_cap->cap_info = cpu_to_le16(conf->ht_conf.cap); | 8197 | ht_cap->cap_info = cpu_to_le16(conf->ht_conf.cap); |
@@ -8488,65 +8402,6 @@ static ssize_t store_filter_flags(struct device *d, | |||
8488 | static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags, | 8402 | static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags, |
8489 | store_filter_flags); | 8403 | store_filter_flags); |
8490 | 8404 | ||
8491 | static ssize_t show_tune(struct device *d, | ||
8492 | struct device_attribute *attr, char *buf) | ||
8493 | { | ||
8494 | struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; | ||
8495 | |||
8496 | return sprintf(buf, "0x%04X\n", | ||
8497 | (priv->phymode << 8) | | ||
8498 | le16_to_cpu(priv->active_rxon.channel)); | ||
8499 | } | ||
8500 | |||
8501 | static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv, u8 phymode); | ||
8502 | |||
8503 | static ssize_t store_tune(struct device *d, | ||
8504 | struct device_attribute *attr, | ||
8505 | const char *buf, size_t count) | ||
8506 | { | ||
8507 | struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; | ||
8508 | char *p = (char *)buf; | ||
8509 | u16 tune = simple_strtoul(p, &p, 0); | ||
8510 | u8 phymode = (tune >> 8) & 0xff; | ||
8511 | u16 channel = tune & 0xff; | ||
8512 | |||
8513 | IWL_DEBUG_INFO("Tune request to:%d channel:%d\n", phymode, channel); | ||
8514 | |||
8515 | mutex_lock(&priv->mutex); | ||
8516 | if ((le16_to_cpu(priv->staging_rxon.channel) != channel) || | ||
8517 | (priv->phymode != phymode)) { | ||
8518 | const struct iwl4965_channel_info *ch_info; | ||
8519 | |||
8520 | ch_info = iwl4965_get_channel_info(priv, phymode, channel); | ||
8521 | if (!ch_info) { | ||
8522 | IWL_WARNING("Requested invalid phymode/channel " | ||
8523 | "combination: %d %d\n", phymode, channel); | ||
8524 | mutex_unlock(&priv->mutex); | ||
8525 | return -EINVAL; | ||
8526 | } | ||
8527 | |||
8528 | /* Cancel any currently running scans... */ | ||
8529 | if (iwl4965_scan_cancel_timeout(priv, 100)) | ||
8530 | IWL_WARNING("Could not cancel scan.\n"); | ||
8531 | else { | ||
8532 | IWL_DEBUG_INFO("Committing phymode and " | ||
8533 | "rxon.channel = %d %d\n", | ||
8534 | phymode, channel); | ||
8535 | |||
8536 | iwl4965_set_rxon_channel(priv, phymode, channel); | ||
8537 | iwl4965_set_flags_for_phymode(priv, phymode); | ||
8538 | |||
8539 | iwl4965_set_rate(priv); | ||
8540 | iwl4965_commit_rxon(priv); | ||
8541 | } | ||
8542 | } | ||
8543 | mutex_unlock(&priv->mutex); | ||
8544 | |||
8545 | return count; | ||
8546 | } | ||
8547 | |||
8548 | static DEVICE_ATTR(tune, S_IWUSR | S_IRUGO, show_tune, store_tune); | ||
8549 | |||
8550 | #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT | 8405 | #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT |
8551 | 8406 | ||
8552 | static ssize_t show_measurement(struct device *d, | 8407 | static ssize_t show_measurement(struct device *d, |
@@ -8736,73 +8591,8 @@ static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR, show_power_level, | |||
8736 | static ssize_t show_channels(struct device *d, | 8591 | static ssize_t show_channels(struct device *d, |
8737 | struct device_attribute *attr, char *buf) | 8592 | struct device_attribute *attr, char *buf) |
8738 | { | 8593 | { |
8739 | struct iwl4965_priv *priv = dev_get_drvdata(d); | 8594 | /* all this shit doesn't belong into sysfs anyway */ |
8740 | int len = 0, i; | 8595 | return 0; |
8741 | struct ieee80211_channel *channels = NULL; | ||
8742 | const struct ieee80211_hw_mode *hw_mode = NULL; | ||
8743 | int count = 0; | ||
8744 | |||
8745 | if (!iwl4965_is_ready(priv)) | ||
8746 | return -EAGAIN; | ||
8747 | |||
8748 | hw_mode = iwl4965_get_hw_mode(priv, MODE_IEEE80211G); | ||
8749 | if (!hw_mode) | ||
8750 | hw_mode = iwl4965_get_hw_mode(priv, MODE_IEEE80211B); | ||
8751 | if (hw_mode) { | ||
8752 | channels = hw_mode->channels; | ||
8753 | count = hw_mode->num_channels; | ||
8754 | } | ||
8755 | |||
8756 | len += | ||
8757 | sprintf(&buf[len], | ||
8758 | "Displaying %d channels in 2.4GHz band " | ||
8759 | "(802.11bg):\n", count); | ||
8760 | |||
8761 | for (i = 0; i < count; i++) | ||
8762 | len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n", | ||
8763 | channels[i].chan, | ||
8764 | channels[i].power_level, | ||
8765 | channels[i]. | ||
8766 | flag & IEEE80211_CHAN_W_RADAR_DETECT ? | ||
8767 | " (IEEE 802.11h required)" : "", | ||
8768 | (!(channels[i].flag & IEEE80211_CHAN_W_IBSS) | ||
8769 | || (channels[i]. | ||
8770 | flag & | ||
8771 | IEEE80211_CHAN_W_RADAR_DETECT)) ? "" : | ||
8772 | ", IBSS", | ||
8773 | channels[i]. | ||
8774 | flag & IEEE80211_CHAN_W_ACTIVE_SCAN ? | ||
8775 | "active/passive" : "passive only"); | ||
8776 | |||
8777 | hw_mode = iwl4965_get_hw_mode(priv, MODE_IEEE80211A); | ||
8778 | if (hw_mode) { | ||
8779 | channels = hw_mode->channels; | ||
8780 | count = hw_mode->num_channels; | ||
8781 | } else { | ||
8782 | channels = NULL; | ||
8783 | count = 0; | ||
8784 | } | ||
8785 | |||
8786 | len += sprintf(&buf[len], "Displaying %d channels in 5.2GHz band " | ||
8787 | "(802.11a):\n", count); | ||
8788 | |||
8789 | for (i = 0; i < count; i++) | ||
8790 | len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n", | ||
8791 | channels[i].chan, | ||
8792 | channels[i].power_level, | ||
8793 | channels[i]. | ||
8794 | flag & IEEE80211_CHAN_W_RADAR_DETECT ? | ||
8795 | " (IEEE 802.11h required)" : "", | ||
8796 | (!(channels[i].flag & IEEE80211_CHAN_W_IBSS) | ||
8797 | || (channels[i]. | ||
8798 | flag & | ||
8799 | IEEE80211_CHAN_W_RADAR_DETECT)) ? "" : | ||
8800 | ", IBSS", | ||
8801 | channels[i]. | ||
8802 | flag & IEEE80211_CHAN_W_ACTIVE_SCAN ? | ||
8803 | "active/passive" : "passive only"); | ||
8804 | |||
8805 | return len; | ||
8806 | } | 8596 | } |
8807 | 8597 | ||
8808 | static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL); | 8598 | static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL); |
@@ -8981,7 +8771,6 @@ static struct attribute *iwl4965_sysfs_entries[] = { | |||
8981 | &dev_attr_statistics.attr, | 8771 | &dev_attr_statistics.attr, |
8982 | &dev_attr_status.attr, | 8772 | &dev_attr_status.attr, |
8983 | &dev_attr_temperature.attr, | 8773 | &dev_attr_temperature.attr, |
8984 | &dev_attr_tune.attr, | ||
8985 | &dev_attr_tx_power.attr, | 8774 | &dev_attr_tx_power.attr, |
8986 | 8775 | ||
8987 | NULL | 8776 | NULL |
@@ -9109,7 +8898,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
9109 | priv->data_retry_limit = -1; | 8898 | priv->data_retry_limit = -1; |
9110 | priv->ieee_channels = NULL; | 8899 | priv->ieee_channels = NULL; |
9111 | priv->ieee_rates = NULL; | 8900 | priv->ieee_rates = NULL; |
9112 | priv->phymode = -1; | 8901 | priv->band = IEEE80211_BAND_2GHZ; |
9113 | 8902 | ||
9114 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 8903 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
9115 | if (!err) | 8904 | if (!err) |
@@ -9175,7 +8964,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
9175 | priv->qos_data.qos_cap.val = 0; | 8964 | priv->qos_data.qos_cap.val = 0; |
9176 | #endif /* CONFIG_IWL4965_QOS */ | 8965 | #endif /* CONFIG_IWL4965_QOS */ |
9177 | 8966 | ||
9178 | iwl4965_set_rxon_channel(priv, MODE_IEEE80211G, 6); | 8967 | iwl4965_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); |
9179 | iwl4965_setup_deferred_work(priv); | 8968 | iwl4965_setup_deferred_work(priv); |
9180 | iwl4965_setup_rx_handlers(priv); | 8969 | iwl4965_setup_rx_handlers(priv); |
9181 | 8970 | ||
@@ -9226,7 +9015,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
9226 | IWL_ERROR("initializing geos failed: %d\n", err); | 9015 | IWL_ERROR("initializing geos failed: %d\n", err); |
9227 | goto out_free_channel_map; | 9016 | goto out_free_channel_map; |
9228 | } | 9017 | } |
9229 | iwl4965_reset_channel_flag(priv); | ||
9230 | 9018 | ||
9231 | iwl4965_rate_control_register(priv->hw); | 9019 | iwl4965_rate_control_register(priv->hw); |
9232 | err = ieee80211_register_hw(priv->hw); | 9020 | err = ieee80211_register_hw(priv->hw); |
diff --git a/drivers/net/wireless/p54.h b/drivers/net/wireless/p54.h index 744c866066c5..06d2c67f4c81 100644 --- a/drivers/net/wireless/p54.h +++ b/drivers/net/wireless/p54.h | |||
@@ -64,10 +64,6 @@ struct p54_common { | |||
64 | unsigned int tx_hdr_len; | 64 | unsigned int tx_hdr_len; |
65 | void *cached_vdcf; | 65 | void *cached_vdcf; |
66 | unsigned int fw_var; | 66 | unsigned int fw_var; |
67 | /* FIXME: this channels/modes/rates stuff sucks */ | ||
68 | struct ieee80211_channel channels[14]; | ||
69 | struct ieee80211_rate rates[12]; | ||
70 | struct ieee80211_hw_mode modes[2]; | ||
71 | struct ieee80211_tx_queue_stats tx_stats; | 67 | struct ieee80211_tx_queue_stats tx_stats; |
72 | }; | 68 | }; |
73 | 69 | ||
diff --git a/drivers/net/wireless/p54common.c b/drivers/net/wireless/p54common.c index 5cda49aff3a8..218ff7770ef6 100644 --- a/drivers/net/wireless/p54common.c +++ b/drivers/net/wireless/p54common.c | |||
@@ -27,6 +27,46 @@ MODULE_DESCRIPTION("Softmac Prism54 common code"); | |||
27 | MODULE_LICENSE("GPL"); | 27 | MODULE_LICENSE("GPL"); |
28 | MODULE_ALIAS("prism54common"); | 28 | MODULE_ALIAS("prism54common"); |
29 | 29 | ||
30 | static struct ieee80211_rate p54_rates[] = { | ||
31 | { .bitrate = 10, .hw_value = 0, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
32 | { .bitrate = 20, .hw_value = 1, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
33 | { .bitrate = 55, .hw_value = 2, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
34 | { .bitrate = 110, .hw_value = 3, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
35 | { .bitrate = 60, .hw_value = 4, }, | ||
36 | { .bitrate = 90, .hw_value = 5, }, | ||
37 | { .bitrate = 120, .hw_value = 6, }, | ||
38 | { .bitrate = 180, .hw_value = 7, }, | ||
39 | { .bitrate = 240, .hw_value = 8, }, | ||
40 | { .bitrate = 360, .hw_value = 9, }, | ||
41 | { .bitrate = 480, .hw_value = 10, }, | ||
42 | { .bitrate = 540, .hw_value = 11, }, | ||
43 | }; | ||
44 | |||
45 | static struct ieee80211_channel p54_channels[] = { | ||
46 | { .center_freq = 2412, .hw_value = 1, }, | ||
47 | { .center_freq = 2417, .hw_value = 2, }, | ||
48 | { .center_freq = 2422, .hw_value = 3, }, | ||
49 | { .center_freq = 2427, .hw_value = 4, }, | ||
50 | { .center_freq = 2432, .hw_value = 5, }, | ||
51 | { .center_freq = 2437, .hw_value = 6, }, | ||
52 | { .center_freq = 2442, .hw_value = 7, }, | ||
53 | { .center_freq = 2447, .hw_value = 8, }, | ||
54 | { .center_freq = 2452, .hw_value = 9, }, | ||
55 | { .center_freq = 2457, .hw_value = 10, }, | ||
56 | { .center_freq = 2462, .hw_value = 11, }, | ||
57 | { .center_freq = 2467, .hw_value = 12, }, | ||
58 | { .center_freq = 2472, .hw_value = 13, }, | ||
59 | { .center_freq = 2484, .hw_value = 14, }, | ||
60 | }; | ||
61 | |||
62 | struct ieee80211_supported_band band_2GHz = { | ||
63 | .channels = p54_channels, | ||
64 | .n_channels = ARRAY_SIZE(p54_channels), | ||
65 | .bitrates = p54_rates, | ||
66 | .n_bitrates = ARRAY_SIZE(p54_rates), | ||
67 | }; | ||
68 | |||
69 | |||
30 | void p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw) | 70 | void p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw) |
31 | { | 71 | { |
32 | struct p54_common *priv = dev->priv; | 72 | struct p54_common *priv = dev->priv; |
@@ -308,10 +348,10 @@ static void p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb) | |||
308 | u16 freq = le16_to_cpu(hdr->freq); | 348 | u16 freq = le16_to_cpu(hdr->freq); |
309 | 349 | ||
310 | rx_status.ssi = hdr->rssi; | 350 | rx_status.ssi = hdr->rssi; |
311 | rx_status.rate = hdr->rate & 0x1f; /* report short preambles & CCK too */ | 351 | /* XX correct? */ |
312 | rx_status.channel = freq == 2484 ? 14 : (freq - 2407)/5; | 352 | rx_status.rate_idx = hdr->rate & 0xf; |
313 | rx_status.freq = freq; | 353 | rx_status.freq = freq; |
314 | rx_status.phymode = MODE_IEEE80211G; | 354 | rx_status.band = IEEE80211_BAND_2GHZ; |
315 | rx_status.antenna = hdr->antenna; | 355 | rx_status.antenna = hdr->antenna; |
316 | rx_status.mactime = le64_to_cpu(hdr->timestamp); | 356 | rx_status.mactime = le64_to_cpu(hdr->timestamp); |
317 | rx_status.flag |= RX_FLAG_TSFT; | 357 | rx_status.flag |= RX_FLAG_TSFT; |
@@ -547,7 +587,9 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
547 | txhdr->padding2 = 0; | 587 | txhdr->padding2 = 0; |
548 | 588 | ||
549 | /* TODO: add support for alternate retry TX rates */ | 589 | /* TODO: add support for alternate retry TX rates */ |
550 | rate = control->tx_rate; | 590 | rate = control->tx_rate->hw_value; |
591 | if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) | ||
592 | rate |= 0x10; | ||
551 | if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) | 593 | if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) |
552 | rate |= 0x40; | 594 | rate |= 0x40; |
553 | else if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) | 595 | else if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) |
@@ -849,7 +891,7 @@ static int p54_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) | |||
849 | { | 891 | { |
850 | int ret; | 892 | int ret; |
851 | 893 | ||
852 | ret = p54_set_freq(dev, cpu_to_le16(conf->freq)); | 894 | ret = p54_set_freq(dev, cpu_to_le16(conf->channel->center_freq)); |
853 | p54_set_vdcf(dev); | 895 | p54_set_vdcf(dev); |
854 | return ret; | 896 | return ret; |
855 | } | 897 | } |
@@ -944,7 +986,6 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len) | |||
944 | { | 986 | { |
945 | struct ieee80211_hw *dev; | 987 | struct ieee80211_hw *dev; |
946 | struct p54_common *priv; | 988 | struct p54_common *priv; |
947 | int i; | ||
948 | 989 | ||
949 | dev = ieee80211_alloc_hw(priv_data_len, &p54_ops); | 990 | dev = ieee80211_alloc_hw(priv_data_len, &p54_ops); |
950 | if (!dev) | 991 | if (!dev) |
@@ -953,18 +994,7 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len) | |||
953 | priv = dev->priv; | 994 | priv = dev->priv; |
954 | priv->mode = IEEE80211_IF_TYPE_INVALID; | 995 | priv->mode = IEEE80211_IF_TYPE_INVALID; |
955 | skb_queue_head_init(&priv->tx_queue); | 996 | skb_queue_head_init(&priv->tx_queue); |
956 | memcpy(priv->channels, p54_channels, sizeof(p54_channels)); | 997 | dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz; |
957 | memcpy(priv->rates, p54_rates, sizeof(p54_rates)); | ||
958 | priv->modes[1].mode = MODE_IEEE80211B; | ||
959 | priv->modes[1].num_rates = 4; | ||
960 | priv->modes[1].rates = priv->rates; | ||
961 | priv->modes[1].num_channels = ARRAY_SIZE(p54_channels); | ||
962 | priv->modes[1].channels = priv->channels; | ||
963 | priv->modes[0].mode = MODE_IEEE80211G; | ||
964 | priv->modes[0].num_rates = ARRAY_SIZE(p54_rates); | ||
965 | priv->modes[0].rates = priv->rates; | ||
966 | priv->modes[0].num_channels = ARRAY_SIZE(p54_channels); | ||
967 | priv->modes[0].channels = priv->channels; | ||
968 | dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | /* not sure */ | 998 | dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | /* not sure */ |
969 | IEEE80211_HW_RX_INCLUDES_FCS; | 999 | IEEE80211_HW_RX_INCLUDES_FCS; |
970 | dev->channel_change_time = 1000; /* TODO: find actual value */ | 1000 | dev->channel_change_time = 1000; /* TODO: find actual value */ |
@@ -986,14 +1016,6 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len) | |||
986 | 1016 | ||
987 | p54_init_vdcf(dev); | 1017 | p54_init_vdcf(dev); |
988 | 1018 | ||
989 | for (i = 0; i < 2; i++) { | ||
990 | if (ieee80211_register_hwmode(dev, &priv->modes[i])) { | ||
991 | kfree(priv->cached_vdcf); | ||
992 | ieee80211_free_hw(dev); | ||
993 | return NULL; | ||
994 | } | ||
995 | } | ||
996 | |||
997 | return dev; | 1019 | return dev; |
998 | } | 1020 | } |
999 | EXPORT_SYMBOL_GPL(p54_init_common); | 1021 | EXPORT_SYMBOL_GPL(p54_init_common); |
diff --git a/drivers/net/wireless/p54common.h b/drivers/net/wireless/p54common.h index a721334e20d9..dc9f4cef585e 100644 --- a/drivers/net/wireless/p54common.h +++ b/drivers/net/wireless/p54common.h | |||
@@ -251,79 +251,4 @@ struct p54_tx_control_vdcf { | |||
251 | __le16 frameburst; | 251 | __le16 frameburst; |
252 | } __attribute__ ((packed)); | 252 | } __attribute__ ((packed)); |
253 | 253 | ||
254 | static const struct ieee80211_rate p54_rates[] = { | ||
255 | { .rate = 10, | ||
256 | .val = 0, | ||
257 | .val2 = 0x10, | ||
258 | .flags = IEEE80211_RATE_CCK_2 }, | ||
259 | { .rate = 20, | ||
260 | .val = 1, | ||
261 | .val2 = 0x11, | ||
262 | .flags = IEEE80211_RATE_CCK_2 }, | ||
263 | { .rate = 55, | ||
264 | .val = 2, | ||
265 | .val2 = 0x12, | ||
266 | .flags = IEEE80211_RATE_CCK_2 }, | ||
267 | { .rate = 110, | ||
268 | .val = 3, | ||
269 | .val2 = 0x13, | ||
270 | .flags = IEEE80211_RATE_CCK_2 }, | ||
271 | { .rate = 60, | ||
272 | .val = 4, | ||
273 | .flags = IEEE80211_RATE_OFDM }, | ||
274 | { .rate = 90, | ||
275 | .val = 5, | ||
276 | .flags = IEEE80211_RATE_OFDM }, | ||
277 | { .rate = 120, | ||
278 | .val = 6, | ||
279 | .flags = IEEE80211_RATE_OFDM }, | ||
280 | { .rate = 180, | ||
281 | .val = 7, | ||
282 | .flags = IEEE80211_RATE_OFDM }, | ||
283 | { .rate = 240, | ||
284 | .val = 8, | ||
285 | .flags = IEEE80211_RATE_OFDM }, | ||
286 | { .rate = 360, | ||
287 | .val = 9, | ||
288 | .flags = IEEE80211_RATE_OFDM }, | ||
289 | { .rate = 480, | ||
290 | .val = 10, | ||
291 | .flags = IEEE80211_RATE_OFDM }, | ||
292 | { .rate = 540, | ||
293 | .val = 11, | ||
294 | .flags = IEEE80211_RATE_OFDM }, | ||
295 | }; | ||
296 | |||
297 | // TODO: just generate this.. | ||
298 | static const struct ieee80211_channel p54_channels[] = { | ||
299 | { .chan = 1, | ||
300 | .freq = 2412}, | ||
301 | { .chan = 2, | ||
302 | .freq = 2417}, | ||
303 | { .chan = 3, | ||
304 | .freq = 2422}, | ||
305 | { .chan = 4, | ||
306 | .freq = 2427}, | ||
307 | { .chan = 5, | ||
308 | .freq = 2432}, | ||
309 | { .chan = 6, | ||
310 | .freq = 2437}, | ||
311 | { .chan = 7, | ||
312 | .freq = 2442}, | ||
313 | { .chan = 8, | ||
314 | .freq = 2447}, | ||
315 | { .chan = 9, | ||
316 | .freq = 2452}, | ||
317 | { .chan = 10, | ||
318 | .freq = 2457}, | ||
319 | { .chan = 11, | ||
320 | .freq = 2462}, | ||
321 | { .chan = 12, | ||
322 | .freq = 2467}, | ||
323 | { .chan = 13, | ||
324 | .freq = 2472}, | ||
325 | { .chan = 14, | ||
326 | .freq = 2484} | ||
327 | }; | ||
328 | |||
329 | #endif /* PRISM54COMMON_H */ | 254 | #endif /* PRISM54COMMON_H */ |
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index b0e4ea7c9dca..4fa762bdb734 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h | |||
@@ -390,6 +390,10 @@ static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif) | |||
390 | return (struct rt2x00_intf *)vif->drv_priv; | 390 | return (struct rt2x00_intf *)vif->drv_priv; |
391 | } | 391 | } |
392 | 392 | ||
393 | #define HWMODE_B 0 | ||
394 | #define HWMODE_G 1 | ||
395 | #define HWMODE_A 2 | ||
396 | |||
393 | /* | 397 | /* |
394 | * Details about the supported modes, rates and channels | 398 | * Details about the supported modes, rates and channels |
395 | * of a particular chipset. This is used by rt2x00lib | 399 | * of a particular chipset. This is used by rt2x00lib |
@@ -644,11 +648,8 @@ struct rt2x00_dev { | |||
644 | * IEEE80211 control structure. | 648 | * IEEE80211 control structure. |
645 | */ | 649 | */ |
646 | struct ieee80211_hw *hw; | 650 | struct ieee80211_hw *hw; |
647 | struct ieee80211_hw_mode *hwmodes; | 651 | struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; |
648 | unsigned int curr_hwmode; | 652 | enum ieee80211_band curr_band; |
649 | #define HWMODE_B 0 | ||
650 | #define HWMODE_G 1 | ||
651 | #define HWMODE_A 2 | ||
652 | 653 | ||
653 | /* | 654 | /* |
654 | * rfkill structure for RF state switching support. | 655 | * rfkill structure for RF state switching support. |
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c index 20231e0c53fa..9fba485a40ac 100644 --- a/drivers/net/wireless/rt2x00/rt2x00config.c +++ b/drivers/net/wireless/rt2x00/rt2x00config.c | |||
@@ -152,7 +152,7 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, | |||
152 | struct ieee80211_conf *conf, const int force_config) | 152 | struct ieee80211_conf *conf, const int force_config) |
153 | { | 153 | { |
154 | struct rt2x00lib_conf libconf; | 154 | struct rt2x00lib_conf libconf; |
155 | struct ieee80211_hw_mode *mode; | 155 | struct ieee80211_supported_band *band; |
156 | struct ieee80211_rate *rate; | 156 | struct ieee80211_rate *rate; |
157 | struct antenna_setup *default_ant = &rt2x00dev->default_ant; | 157 | struct antenna_setup *default_ant = &rt2x00dev->default_ant; |
158 | struct antenna_setup *active_ant = &rt2x00dev->link.ant.active; | 158 | struct antenna_setup *active_ant = &rt2x00dev->link.ant.active; |
@@ -172,9 +172,9 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, | |||
172 | * Check which configuration options have been | 172 | * Check which configuration options have been |
173 | * updated and should be send to the device. | 173 | * updated and should be send to the device. |
174 | */ | 174 | */ |
175 | if (rt2x00dev->rx_status.phymode != conf->phymode) | 175 | if (rt2x00dev->rx_status.band != conf->channel->band) |
176 | flags |= CONFIG_UPDATE_PHYMODE; | 176 | flags |= CONFIG_UPDATE_PHYMODE; |
177 | if (rt2x00dev->rx_status.channel != conf->channel) | 177 | if (rt2x00dev->rx_status.freq != conf->channel->center_freq) |
178 | flags |= CONFIG_UPDATE_CHANNEL; | 178 | flags |= CONFIG_UPDATE_CHANNEL; |
179 | if (rt2x00dev->tx_power != conf->power_level) | 179 | if (rt2x00dev->tx_power != conf->power_level) |
180 | flags |= CONFIG_UPDATE_TXPOWER; | 180 | flags |= CONFIG_UPDATE_TXPOWER; |
@@ -229,33 +229,31 @@ config: | |||
229 | memset(&libconf, 0, sizeof(libconf)); | 229 | memset(&libconf, 0, sizeof(libconf)); |
230 | 230 | ||
231 | if (flags & CONFIG_UPDATE_PHYMODE) { | 231 | if (flags & CONFIG_UPDATE_PHYMODE) { |
232 | switch (conf->phymode) { | 232 | switch (conf->channel->band) { |
233 | case MODE_IEEE80211A: | 233 | case IEEE80211_BAND_5GHZ: |
234 | libconf.phymode = HWMODE_A; | 234 | libconf.phymode = HWMODE_A; |
235 | break; | 235 | break; |
236 | case MODE_IEEE80211B: | 236 | case IEEE80211_BAND_2GHZ: |
237 | libconf.phymode = HWMODE_B; | 237 | /* Uh oh. what about B? */ |
238 | break; | ||
239 | case MODE_IEEE80211G: | ||
240 | libconf.phymode = HWMODE_G; | 238 | libconf.phymode = HWMODE_G; |
241 | break; | 239 | break; |
242 | default: | 240 | default: |
243 | ERROR(rt2x00dev, | 241 | ERROR(rt2x00dev, |
244 | "Attempt to configure unsupported mode (%d)" | 242 | "Attempt to configure unsupported mode (%d)" |
245 | "Defaulting to 802.11b", conf->phymode); | 243 | "Defaulting to 802.11b", conf->channel->band); |
246 | libconf.phymode = HWMODE_B; | 244 | libconf.phymode = HWMODE_B; |
247 | } | 245 | } |
248 | 246 | ||
249 | mode = &rt2x00dev->hwmodes[libconf.phymode]; | 247 | band = &rt2x00dev->bands[conf->channel->band]; |
250 | rate = &mode->rates[mode->num_rates - 1]; | 248 | rate = &band->bitrates[band->n_bitrates - 1]; |
251 | 249 | ||
252 | libconf.basic_rates = | 250 | libconf.basic_rates = |
253 | DEVICE_GET_RATE_FIELD(rate->val, RATEMASK) & DEV_BASIC_RATEMASK; | 251 | DEVICE_GET_RATE_FIELD(rate->hw_value, RATEMASK) & DEV_BASIC_RATEMASK; |
254 | } | 252 | } |
255 | 253 | ||
256 | if (flags & CONFIG_UPDATE_CHANNEL) { | 254 | if (flags & CONFIG_UPDATE_CHANNEL) { |
257 | memcpy(&libconf.rf, | 255 | memcpy(&libconf.rf, |
258 | &rt2x00dev->spec.channels[conf->channel_val], | 256 | &rt2x00dev->spec.channels[conf->channel->hw_value], |
259 | sizeof(libconf.rf)); | 257 | sizeof(libconf.rf)); |
260 | } | 258 | } |
261 | 259 | ||
@@ -301,12 +299,11 @@ config: | |||
301 | rt2x00lib_reset_link_tuner(rt2x00dev); | 299 | rt2x00lib_reset_link_tuner(rt2x00dev); |
302 | 300 | ||
303 | if (flags & CONFIG_UPDATE_PHYMODE) { | 301 | if (flags & CONFIG_UPDATE_PHYMODE) { |
304 | rt2x00dev->curr_hwmode = libconf.phymode; | 302 | rt2x00dev->curr_band = conf->channel->band; |
305 | rt2x00dev->rx_status.phymode = conf->phymode; | 303 | rt2x00dev->rx_status.band = conf->channel->band; |
306 | } | 304 | } |
307 | 305 | ||
308 | rt2x00dev->rx_status.freq = conf->freq; | 306 | rt2x00dev->rx_status.freq = conf->channel->center_freq; |
309 | rt2x00dev->rx_status.channel = conf->channel; | ||
310 | rt2x00dev->tx_power = conf->power_level; | 307 | rt2x00dev->tx_power = conf->power_level; |
311 | 308 | ||
312 | if (flags & CONFIG_UPDATE_ANTENNA) { | 309 | if (flags & CONFIG_UPDATE_ANTENNA) { |
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index 0df8062b1a8e..83a72ae36638 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c | |||
@@ -550,19 +550,19 @@ void rt2x00lib_rxdone(struct queue_entry *entry, | |||
550 | { | 550 | { |
551 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | 551 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
552 | struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status; | 552 | struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status; |
553 | struct ieee80211_hw_mode *mode; | 553 | struct ieee80211_supported_band *sband; |
554 | struct ieee80211_rate *rate; | 554 | struct ieee80211_rate *rate; |
555 | struct ieee80211_hdr *hdr; | 555 | struct ieee80211_hdr *hdr; |
556 | unsigned int i; | 556 | unsigned int i; |
557 | int val = 0; | 557 | int val = 0, idx = -1; |
558 | u16 fc; | 558 | u16 fc; |
559 | 559 | ||
560 | /* | 560 | /* |
561 | * Update RX statistics. | 561 | * Update RX statistics. |
562 | */ | 562 | */ |
563 | mode = &rt2x00dev->hwmodes[rt2x00dev->curr_hwmode]; | 563 | sband = &rt2x00dev->bands[rt2x00dev->curr_band]; |
564 | for (i = 0; i < mode->num_rates; i++) { | 564 | for (i = 0; i < sband->n_bitrates; i++) { |
565 | rate = &mode->rates[i]; | 565 | rate = &sband->bitrates[i]; |
566 | 566 | ||
567 | /* | 567 | /* |
568 | * When frame was received with an OFDM bitrate, | 568 | * When frame was received with an OFDM bitrate, |
@@ -570,12 +570,12 @@ void rt2x00lib_rxdone(struct queue_entry *entry, | |||
570 | * a CCK bitrate the signal is the rate in 0.5kbit/s. | 570 | * a CCK bitrate the signal is the rate in 0.5kbit/s. |
571 | */ | 571 | */ |
572 | if (!rxdesc->ofdm) | 572 | if (!rxdesc->ofdm) |
573 | val = DEVICE_GET_RATE_FIELD(rate->val, RATE); | 573 | val = DEVICE_GET_RATE_FIELD(rate->hw_value, RATE); |
574 | else | 574 | else |
575 | val = DEVICE_GET_RATE_FIELD(rate->val, PLCP); | 575 | val = DEVICE_GET_RATE_FIELD(rate->hw_value, PLCP); |
576 | 576 | ||
577 | if (val == rxdesc->signal) { | 577 | if (val == rxdesc->signal) { |
578 | val = rate->val; | 578 | idx = i; |
579 | break; | 579 | break; |
580 | } | 580 | } |
581 | } | 581 | } |
@@ -590,7 +590,7 @@ void rt2x00lib_rxdone(struct queue_entry *entry, | |||
590 | 590 | ||
591 | rt2x00dev->link.qual.rx_success++; | 591 | rt2x00dev->link.qual.rx_success++; |
592 | 592 | ||
593 | rx_status->rate = val; | 593 | rx_status->rate_idx = idx; |
594 | rx_status->signal = | 594 | rx_status->signal = |
595 | rt2x00lib_calculate_link_signal(rt2x00dev, rxdesc->rssi); | 595 | rt2x00lib_calculate_link_signal(rt2x00dev, rxdesc->rssi); |
596 | rx_status->ssi = rxdesc->rssi; | 596 | rx_status->ssi = rxdesc->rssi; |
@@ -639,7 +639,7 @@ void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
639 | frame_control = le16_to_cpu(ieee80211hdr->frame_control); | 639 | frame_control = le16_to_cpu(ieee80211hdr->frame_control); |
640 | seq_ctrl = le16_to_cpu(ieee80211hdr->seq_ctrl); | 640 | seq_ctrl = le16_to_cpu(ieee80211hdr->seq_ctrl); |
641 | 641 | ||
642 | tx_rate = control->tx_rate; | 642 | tx_rate = control->tx_rate->hw_value; |
643 | 643 | ||
644 | /* | 644 | /* |
645 | * Check whether this frame is to be acked | 645 | * Check whether this frame is to be acked |
@@ -658,7 +658,7 @@ void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
658 | } else | 658 | } else |
659 | __clear_bit(ENTRY_TXD_ACK, &txdesc.flags); | 659 | __clear_bit(ENTRY_TXD_ACK, &txdesc.flags); |
660 | if (control->rts_cts_rate) | 660 | if (control->rts_cts_rate) |
661 | tx_rate = control->rts_cts_rate; | 661 | tx_rate = control->rts_cts_rate->hw_value; |
662 | } | 662 | } |
663 | 663 | ||
664 | /* | 664 | /* |
@@ -760,54 +760,45 @@ static void rt2x00lib_channel(struct ieee80211_channel *entry, | |||
760 | const int channel, const int tx_power, | 760 | const int channel, const int tx_power, |
761 | const int value) | 761 | const int value) |
762 | { | 762 | { |
763 | entry->chan = channel; | ||
764 | if (channel <= 14) | 763 | if (channel <= 14) |
765 | entry->freq = 2407 + (5 * channel); | 764 | entry->center_freq = 2407 + (5 * channel); |
766 | else | 765 | else |
767 | entry->freq = 5000 + (5 * channel); | 766 | entry->center_freq = 5000 + (5 * channel); |
768 | entry->val = value; | 767 | entry->hw_value = value; |
769 | entry->flag = | 768 | entry->max_power = tx_power; |
770 | IEEE80211_CHAN_W_IBSS | | 769 | entry->max_antenna_gain = 0xff; |
771 | IEEE80211_CHAN_W_ACTIVE_SCAN | | ||
772 | IEEE80211_CHAN_W_SCAN; | ||
773 | entry->power_level = tx_power; | ||
774 | entry->antenna_max = 0xff; | ||
775 | } | 770 | } |
776 | 771 | ||
777 | static void rt2x00lib_rate(struct ieee80211_rate *entry, | 772 | static void rt2x00lib_rate(struct ieee80211_rate *entry, |
778 | const int rate, const int mask, | 773 | const int rate, const int mask, |
779 | const int plcp, const int flags) | 774 | const int plcp, const int flags) |
780 | { | 775 | { |
781 | entry->rate = rate; | 776 | entry->bitrate = rate; |
782 | entry->val = | 777 | entry->hw_value = |
783 | DEVICE_SET_RATE_FIELD(rate, RATE) | | 778 | DEVICE_SET_RATE_FIELD(rate, RATE) | |
784 | DEVICE_SET_RATE_FIELD(mask, RATEMASK) | | 779 | DEVICE_SET_RATE_FIELD(mask, RATEMASK) | |
785 | DEVICE_SET_RATE_FIELD(plcp, PLCP); | 780 | DEVICE_SET_RATE_FIELD(plcp, PLCP); |
786 | entry->flags = flags; | 781 | entry->flags = flags; |
787 | entry->val2 = entry->val; | 782 | entry->hw_value_short = entry->hw_value; |
788 | if (entry->flags & IEEE80211_RATE_PREAMBLE2) | 783 | if (entry->flags & IEEE80211_RATE_SHORT_PREAMBLE) |
789 | entry->val2 |= DEVICE_SET_RATE_FIELD(1, PREAMBLE); | 784 | entry->hw_value_short |= DEVICE_SET_RATE_FIELD(1, PREAMBLE); |
790 | entry->min_rssi_ack = 0; | ||
791 | entry->min_rssi_ack_delta = 0; | ||
792 | } | 785 | } |
793 | 786 | ||
794 | static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, | 787 | static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, |
795 | struct hw_mode_spec *spec) | 788 | struct hw_mode_spec *spec) |
796 | { | 789 | { |
797 | struct ieee80211_hw *hw = rt2x00dev->hw; | 790 | struct ieee80211_hw *hw = rt2x00dev->hw; |
798 | struct ieee80211_hw_mode *hwmodes; | 791 | struct ieee80211_supported_band *sbands; |
799 | struct ieee80211_channel *channels; | 792 | struct ieee80211_channel *channels; |
800 | struct ieee80211_rate *rates; | 793 | struct ieee80211_rate *rates; |
801 | unsigned int i; | 794 | unsigned int i; |
802 | unsigned char tx_power; | 795 | unsigned char tx_power; |
803 | 796 | ||
804 | hwmodes = kzalloc(sizeof(*hwmodes) * spec->num_modes, GFP_KERNEL); | 797 | sbands = &rt2x00dev->bands[0]; |
805 | if (!hwmodes) | ||
806 | goto exit; | ||
807 | 798 | ||
808 | channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL); | 799 | channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL); |
809 | if (!channels) | 800 | if (!channels) |
810 | goto exit_free_modes; | 801 | return -ENOMEM; |
811 | 802 | ||
812 | rates = kzalloc(sizeof(*rates) * spec->num_rates, GFP_KERNEL); | 803 | rates = kzalloc(sizeof(*rates) * spec->num_rates, GFP_KERNEL); |
813 | if (!rates) | 804 | if (!rates) |
@@ -817,31 +808,31 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, | |||
817 | * Initialize Rate list. | 808 | * Initialize Rate list. |
818 | */ | 809 | */ |
819 | rt2x00lib_rate(&rates[0], 10, DEV_RATEMASK_1MB, | 810 | rt2x00lib_rate(&rates[0], 10, DEV_RATEMASK_1MB, |
820 | 0x00, IEEE80211_RATE_CCK); | 811 | 0x00, 0); |
821 | rt2x00lib_rate(&rates[1], 20, DEV_RATEMASK_2MB, | 812 | rt2x00lib_rate(&rates[1], 20, DEV_RATEMASK_2MB, |
822 | 0x01, IEEE80211_RATE_CCK_2); | 813 | 0x01, IEEE80211_RATE_SHORT_PREAMBLE); |
823 | rt2x00lib_rate(&rates[2], 55, DEV_RATEMASK_5_5MB, | 814 | rt2x00lib_rate(&rates[2], 55, DEV_RATEMASK_5_5MB, |
824 | 0x02, IEEE80211_RATE_CCK_2); | 815 | 0x02, IEEE80211_RATE_SHORT_PREAMBLE); |
825 | rt2x00lib_rate(&rates[3], 110, DEV_RATEMASK_11MB, | 816 | rt2x00lib_rate(&rates[3], 110, DEV_RATEMASK_11MB, |
826 | 0x03, IEEE80211_RATE_CCK_2); | 817 | 0x03, IEEE80211_RATE_SHORT_PREAMBLE); |
827 | 818 | ||
828 | if (spec->num_rates > 4) { | 819 | if (spec->num_rates > 4) { |
829 | rt2x00lib_rate(&rates[4], 60, DEV_RATEMASK_6MB, | 820 | rt2x00lib_rate(&rates[4], 60, DEV_RATEMASK_6MB, |
830 | 0x0b, IEEE80211_RATE_OFDM); | 821 | 0x0b, 0); |
831 | rt2x00lib_rate(&rates[5], 90, DEV_RATEMASK_9MB, | 822 | rt2x00lib_rate(&rates[5], 90, DEV_RATEMASK_9MB, |
832 | 0x0f, IEEE80211_RATE_OFDM); | 823 | 0x0f, 0); |
833 | rt2x00lib_rate(&rates[6], 120, DEV_RATEMASK_12MB, | 824 | rt2x00lib_rate(&rates[6], 120, DEV_RATEMASK_12MB, |
834 | 0x0a, IEEE80211_RATE_OFDM); | 825 | 0x0a, 0); |
835 | rt2x00lib_rate(&rates[7], 180, DEV_RATEMASK_18MB, | 826 | rt2x00lib_rate(&rates[7], 180, DEV_RATEMASK_18MB, |
836 | 0x0e, IEEE80211_RATE_OFDM); | 827 | 0x0e, 0); |
837 | rt2x00lib_rate(&rates[8], 240, DEV_RATEMASK_24MB, | 828 | rt2x00lib_rate(&rates[8], 240, DEV_RATEMASK_24MB, |
838 | 0x09, IEEE80211_RATE_OFDM); | 829 | 0x09, 0); |
839 | rt2x00lib_rate(&rates[9], 360, DEV_RATEMASK_36MB, | 830 | rt2x00lib_rate(&rates[9], 360, DEV_RATEMASK_36MB, |
840 | 0x0d, IEEE80211_RATE_OFDM); | 831 | 0x0d, 0); |
841 | rt2x00lib_rate(&rates[10], 480, DEV_RATEMASK_48MB, | 832 | rt2x00lib_rate(&rates[10], 480, DEV_RATEMASK_48MB, |
842 | 0x08, IEEE80211_RATE_OFDM); | 833 | 0x08, 0); |
843 | rt2x00lib_rate(&rates[11], 540, DEV_RATEMASK_54MB, | 834 | rt2x00lib_rate(&rates[11], 540, DEV_RATEMASK_54MB, |
844 | 0x0c, IEEE80211_RATE_OFDM); | 835 | 0x0c, 0); |
845 | } | 836 | } |
846 | 837 | ||
847 | /* | 838 | /* |
@@ -862,27 +853,27 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, | |||
862 | /* | 853 | /* |
863 | * Intitialize 802.11b | 854 | * Intitialize 802.11b |
864 | * Rates: CCK. | 855 | * Rates: CCK. |
865 | * Channels: OFDM. | 856 | * Channels: 2.4 GHz |
866 | */ | 857 | */ |
867 | if (spec->num_modes > HWMODE_B) { | 858 | if (spec->num_modes > HWMODE_B) { |
868 | hwmodes[HWMODE_B].mode = MODE_IEEE80211B; | 859 | sbands[IEEE80211_BAND_2GHZ].n_channels = 14; |
869 | hwmodes[HWMODE_B].num_channels = 14; | 860 | sbands[IEEE80211_BAND_2GHZ].n_bitrates = 4; |
870 | hwmodes[HWMODE_B].num_rates = 4; | 861 | sbands[IEEE80211_BAND_2GHZ].channels = channels; |
871 | hwmodes[HWMODE_B].channels = channels; | 862 | sbands[IEEE80211_BAND_2GHZ].bitrates = rates; |
872 | hwmodes[HWMODE_B].rates = rates; | 863 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &rt2x00dev->bands[IEEE80211_BAND_2GHZ]; |
873 | } | 864 | } |
874 | 865 | ||
875 | /* | 866 | /* |
876 | * Intitialize 802.11g | 867 | * Intitialize 802.11g |
877 | * Rates: CCK, OFDM. | 868 | * Rates: CCK, OFDM. |
878 | * Channels: OFDM. | 869 | * Channels: 2.4 GHz |
879 | */ | 870 | */ |
880 | if (spec->num_modes > HWMODE_G) { | 871 | if (spec->num_modes > HWMODE_G) { |
881 | hwmodes[HWMODE_G].mode = MODE_IEEE80211G; | 872 | sbands[IEEE80211_BAND_2GHZ].n_channels = 14; |
882 | hwmodes[HWMODE_G].num_channels = 14; | 873 | sbands[IEEE80211_BAND_2GHZ].n_bitrates = spec->num_rates; |
883 | hwmodes[HWMODE_G].num_rates = spec->num_rates; | 874 | sbands[IEEE80211_BAND_2GHZ].channels = channels; |
884 | hwmodes[HWMODE_G].channels = channels; | 875 | sbands[IEEE80211_BAND_2GHZ].bitrates = rates; |
885 | hwmodes[HWMODE_G].rates = rates; | 876 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &rt2x00dev->bands[IEEE80211_BAND_2GHZ]; |
886 | } | 877 | } |
887 | 878 | ||
888 | /* | 879 | /* |
@@ -891,39 +882,17 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, | |||
891 | * Channels: OFDM, UNII, HiperLAN2. | 882 | * Channels: OFDM, UNII, HiperLAN2. |
892 | */ | 883 | */ |
893 | if (spec->num_modes > HWMODE_A) { | 884 | if (spec->num_modes > HWMODE_A) { |
894 | hwmodes[HWMODE_A].mode = MODE_IEEE80211A; | 885 | sbands[IEEE80211_BAND_5GHZ].n_channels = spec->num_channels - 14; |
895 | hwmodes[HWMODE_A].num_channels = spec->num_channels - 14; | 886 | sbands[IEEE80211_BAND_5GHZ].n_bitrates = spec->num_rates - 4; |
896 | hwmodes[HWMODE_A].num_rates = spec->num_rates - 4; | 887 | sbands[IEEE80211_BAND_5GHZ].channels = &channels[14]; |
897 | hwmodes[HWMODE_A].channels = &channels[14]; | 888 | sbands[IEEE80211_BAND_5GHZ].bitrates = &rates[4]; |
898 | hwmodes[HWMODE_A].rates = &rates[4]; | 889 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &rt2x00dev->bands[IEEE80211_BAND_5GHZ]; |
899 | } | 890 | } |
900 | 891 | ||
901 | if (spec->num_modes > HWMODE_G && | ||
902 | ieee80211_register_hwmode(hw, &hwmodes[HWMODE_G])) | ||
903 | goto exit_free_rates; | ||
904 | |||
905 | if (spec->num_modes > HWMODE_B && | ||
906 | ieee80211_register_hwmode(hw, &hwmodes[HWMODE_B])) | ||
907 | goto exit_free_rates; | ||
908 | |||
909 | if (spec->num_modes > HWMODE_A && | ||
910 | ieee80211_register_hwmode(hw, &hwmodes[HWMODE_A])) | ||
911 | goto exit_free_rates; | ||
912 | |||
913 | rt2x00dev->hwmodes = hwmodes; | ||
914 | |||
915 | return 0; | 892 | return 0; |
916 | 893 | ||
917 | exit_free_rates: | 894 | exit_free_channels: |
918 | kfree(rates); | ||
919 | |||
920 | exit_free_channels: | ||
921 | kfree(channels); | 895 | kfree(channels); |
922 | |||
923 | exit_free_modes: | ||
924 | kfree(hwmodes); | ||
925 | |||
926 | exit: | ||
927 | ERROR(rt2x00dev, "Allocation ieee80211 modes failed.\n"); | 896 | ERROR(rt2x00dev, "Allocation ieee80211 modes failed.\n"); |
928 | return -ENOMEM; | 897 | return -ENOMEM; |
929 | } | 898 | } |
@@ -933,11 +902,11 @@ static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev) | |||
933 | if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags)) | 902 | if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags)) |
934 | ieee80211_unregister_hw(rt2x00dev->hw); | 903 | ieee80211_unregister_hw(rt2x00dev->hw); |
935 | 904 | ||
936 | if (likely(rt2x00dev->hwmodes)) { | 905 | if (likely(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ])) { |
937 | kfree(rt2x00dev->hwmodes->channels); | 906 | kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels); |
938 | kfree(rt2x00dev->hwmodes->rates); | 907 | kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->bitrates); |
939 | kfree(rt2x00dev->hwmodes); | 908 | rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; |
940 | rt2x00dev->hwmodes = NULL; | 909 | rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; |
941 | } | 910 | } |
942 | } | 911 | } |
943 | 912 | ||
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index 59e87a1d96a4..1dd30510ed1e 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c | |||
@@ -426,12 +426,12 @@ static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev, | |||
426 | case ANTENNA_HW_DIVERSITY: | 426 | case ANTENNA_HW_DIVERSITY: |
427 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2); | 427 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2); |
428 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, | 428 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, |
429 | (rt2x00dev->curr_hwmode != HWMODE_A)); | 429 | (rt2x00dev->curr_band != IEEE80211_BAND_5GHZ)); |
430 | break; | 430 | break; |
431 | case ANTENNA_A: | 431 | case ANTENNA_A: |
432 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); | 432 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); |
433 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); | 433 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); |
434 | if (rt2x00dev->curr_hwmode == HWMODE_A) | 434 | if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) |
435 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); | 435 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); |
436 | else | 436 | else |
437 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); | 437 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); |
@@ -446,7 +446,7 @@ static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev, | |||
446 | case ANTENNA_B: | 446 | case ANTENNA_B: |
447 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); | 447 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); |
448 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); | 448 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); |
449 | if (rt2x00dev->curr_hwmode == HWMODE_A) | 449 | if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) |
450 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); | 450 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); |
451 | else | 451 | else |
452 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); | 452 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); |
@@ -602,7 +602,7 @@ static void rt61pci_config_antenna(struct rt2x00_dev *rt2x00dev, | |||
602 | unsigned int i; | 602 | unsigned int i; |
603 | u32 reg; | 603 | u32 reg; |
604 | 604 | ||
605 | if (rt2x00dev->curr_hwmode == HWMODE_A) { | 605 | if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) { |
606 | sel = antenna_sel_a; | 606 | sel = antenna_sel_a; |
607 | lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); | 607 | lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); |
608 | } else { | 608 | } else { |
@@ -616,10 +616,9 @@ static void rt61pci_config_antenna(struct rt2x00_dev *rt2x00dev, | |||
616 | rt2x00pci_register_read(rt2x00dev, PHY_CSR0, ®); | 616 | rt2x00pci_register_read(rt2x00dev, PHY_CSR0, ®); |
617 | 617 | ||
618 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_BG, | 618 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_BG, |
619 | (rt2x00dev->curr_hwmode == HWMODE_B || | 619 | rt2x00dev->curr_band == IEEE80211_BAND_2GHZ); |
620 | rt2x00dev->curr_hwmode == HWMODE_G)); | ||
621 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_A, | 620 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_A, |
622 | (rt2x00dev->curr_hwmode == HWMODE_A)); | 621 | rt2x00dev->curr_band == IEEE80211_BAND_5GHZ); |
623 | 622 | ||
624 | rt2x00pci_register_write(rt2x00dev, PHY_CSR0, reg); | 623 | rt2x00pci_register_write(rt2x00dev, PHY_CSR0, reg); |
625 | 624 | ||
@@ -698,9 +697,9 @@ static void rt61pci_enable_led(struct rt2x00_dev *rt2x00dev) | |||
698 | 697 | ||
699 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1); | 698 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1); |
700 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS, | 699 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS, |
701 | (rt2x00dev->rx_status.phymode == MODE_IEEE80211A)); | 700 | rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ); |
702 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS, | 701 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS, |
703 | (rt2x00dev->rx_status.phymode != MODE_IEEE80211A)); | 702 | rt2x00dev->rx_status.band != IEEE80211_BAND_5GHZ); |
704 | 703 | ||
705 | arg0 = rt2x00dev->led_reg & 0xff; | 704 | arg0 = rt2x00dev->led_reg & 0xff; |
706 | arg1 = (rt2x00dev->led_reg >> 8) & 0xff; | 705 | arg1 = (rt2x00dev->led_reg >> 8) & 0xff; |
@@ -798,7 +797,7 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev) | |||
798 | /* | 797 | /* |
799 | * Determine r17 bounds. | 798 | * Determine r17 bounds. |
800 | */ | 799 | */ |
801 | if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { | 800 | if (rt2x00dev->rx_status.band == IEEE80211_BAND_2GHZ) { |
802 | low_bound = 0x28; | 801 | low_bound = 0x28; |
803 | up_bound = 0x48; | 802 | up_bound = 0x48; |
804 | if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) { | 803 | if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) { |
@@ -1544,8 +1543,10 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1544 | rt2x00_desc_write(txd, 2, word); | 1543 | rt2x00_desc_write(txd, 2, word); |
1545 | 1544 | ||
1546 | rt2x00_desc_read(txd, 5, &word); | 1545 | rt2x00_desc_read(txd, 5, &word); |
1546 | /* XXX: removed for now | ||
1547 | rt2x00_set_field32(&word, TXD_W5_TX_POWER, | 1547 | rt2x00_set_field32(&word, TXD_W5_TX_POWER, |
1548 | TXPOWER_TO_DEV(control->power_level)); | 1548 | TXPOWER_TO_DEV(control->power_level)); |
1549 | */ | ||
1549 | rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); | 1550 | rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); |
1550 | rt2x00_desc_write(txd, 5, word); | 1551 | rt2x00_desc_write(txd, 5, word); |
1551 | 1552 | ||
@@ -1637,7 +1638,7 @@ static int rt61pci_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1) | |||
1637 | return 0; | 1638 | return 0; |
1638 | } | 1639 | } |
1639 | 1640 | ||
1640 | if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { | 1641 | if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) { |
1641 | if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) | 1642 | if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) |
1642 | offset += 14; | 1643 | offset += 14; |
1643 | 1644 | ||
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index 4b5bde8b53de..9cbc879da037 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -439,13 +439,13 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev, | |||
439 | case ANTENNA_HW_DIVERSITY: | 439 | case ANTENNA_HW_DIVERSITY: |
440 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2); | 440 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2); |
441 | temp = !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags) | 441 | temp = !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags) |
442 | && (rt2x00dev->curr_hwmode != HWMODE_A); | 442 | && (rt2x00dev->curr_band != IEEE80211_BAND_5GHZ); |
443 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, temp); | 443 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, temp); |
444 | break; | 444 | break; |
445 | case ANTENNA_A: | 445 | case ANTENNA_A: |
446 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); | 446 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); |
447 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); | 447 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); |
448 | if (rt2x00dev->curr_hwmode == HWMODE_A) | 448 | if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) |
449 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); | 449 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); |
450 | else | 450 | else |
451 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); | 451 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); |
@@ -460,7 +460,7 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev, | |||
460 | case ANTENNA_B: | 460 | case ANTENNA_B: |
461 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); | 461 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); |
462 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); | 462 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); |
463 | if (rt2x00dev->curr_hwmode == HWMODE_A) | 463 | if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) |
464 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); | 464 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); |
465 | else | 465 | else |
466 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); | 466 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); |
@@ -555,7 +555,7 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev, | |||
555 | unsigned int i; | 555 | unsigned int i; |
556 | u32 reg; | 556 | u32 reg; |
557 | 557 | ||
558 | if (rt2x00dev->curr_hwmode == HWMODE_A) { | 558 | if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) { |
559 | sel = antenna_sel_a; | 559 | sel = antenna_sel_a; |
560 | lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); | 560 | lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); |
561 | } else { | 561 | } else { |
@@ -569,10 +569,9 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev, | |||
569 | rt73usb_register_read(rt2x00dev, PHY_CSR0, ®); | 569 | rt73usb_register_read(rt2x00dev, PHY_CSR0, ®); |
570 | 570 | ||
571 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_BG, | 571 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_BG, |
572 | (rt2x00dev->curr_hwmode == HWMODE_B || | 572 | (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ)); |
573 | rt2x00dev->curr_hwmode == HWMODE_G)); | ||
574 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_A, | 573 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_A, |
575 | (rt2x00dev->curr_hwmode == HWMODE_A)); | 574 | (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ)); |
576 | 575 | ||
577 | rt73usb_register_write(rt2x00dev, PHY_CSR0, reg); | 576 | rt73usb_register_write(rt2x00dev, PHY_CSR0, reg); |
578 | 577 | ||
@@ -644,9 +643,9 @@ static void rt73usb_enable_led(struct rt2x00_dev *rt2x00dev) | |||
644 | 643 | ||
645 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1); | 644 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1); |
646 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS, | 645 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS, |
647 | (rt2x00dev->rx_status.phymode == MODE_IEEE80211A)); | 646 | (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ)); |
648 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS, | 647 | rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS, |
649 | (rt2x00dev->rx_status.phymode != MODE_IEEE80211A)); | 648 | (rt2x00dev->rx_status.band != IEEE80211_BAND_5GHZ)); |
650 | 649 | ||
651 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, 0x0000, | 650 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, 0x0000, |
652 | rt2x00dev->led_reg, REGISTER_TIMEOUT); | 651 | rt2x00dev->led_reg, REGISTER_TIMEOUT); |
@@ -736,7 +735,7 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev) | |||
736 | /* | 735 | /* |
737 | * Determine r17 bounds. | 736 | * Determine r17 bounds. |
738 | */ | 737 | */ |
739 | if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { | 738 | if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) { |
740 | low_bound = 0x28; | 739 | low_bound = 0x28; |
741 | up_bound = 0x48; | 740 | up_bound = 0x48; |
742 | 741 | ||
@@ -1278,8 +1277,10 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1278 | rt2x00_desc_write(txd, 2, word); | 1277 | rt2x00_desc_write(txd, 2, word); |
1279 | 1278 | ||
1280 | rt2x00_desc_read(txd, 5, &word); | 1279 | rt2x00_desc_read(txd, 5, &word); |
1280 | /* XXX: removed for now | ||
1281 | rt2x00_set_field32(&word, TXD_W5_TX_POWER, | 1281 | rt2x00_set_field32(&word, TXD_W5_TX_POWER, |
1282 | TXPOWER_TO_DEV(control->power_level)); | 1282 | TXPOWER_TO_DEV(control->power_level)); |
1283 | */ | ||
1283 | rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); | 1284 | rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); |
1284 | rt2x00_desc_write(txd, 5, word); | 1285 | rt2x00_desc_write(txd, 5, word); |
1285 | 1286 | ||
@@ -1370,7 +1371,7 @@ static int rt73usb_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1) | |||
1370 | return 0; | 1371 | return 0; |
1371 | } | 1372 | } |
1372 | 1373 | ||
1373 | if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { | 1374 | if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) { |
1374 | if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) { | 1375 | if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) { |
1375 | if (lna == 3 || lna == 2) | 1376 | if (lna == 3 || lna == 2) |
1376 | offset += 10; | 1377 | offset += 10; |
diff --git a/drivers/net/wireless/rtl8180.h b/drivers/net/wireless/rtl8180.h index 2cbfe3c8081f..082a11f93beb 100644 --- a/drivers/net/wireless/rtl8180.h +++ b/drivers/net/wireless/rtl8180.h | |||
@@ -102,7 +102,7 @@ struct rtl8180_priv { | |||
102 | struct rtl8180_tx_ring tx_ring[4]; | 102 | struct rtl8180_tx_ring tx_ring[4]; |
103 | struct ieee80211_channel channels[14]; | 103 | struct ieee80211_channel channels[14]; |
104 | struct ieee80211_rate rates[12]; | 104 | struct ieee80211_rate rates[12]; |
105 | struct ieee80211_hw_mode modes[2]; | 105 | struct ieee80211_supported_band band; |
106 | struct pci_dev *pdev; | 106 | struct pci_dev *pdev; |
107 | u32 rx_conf; | 107 | u32 rx_conf; |
108 | 108 | ||
diff --git a/drivers/net/wireless/rtl8180_dev.c b/drivers/net/wireless/rtl8180_dev.c index 5e9a8ace0d81..d0928c91c21c 100644 --- a/drivers/net/wireless/rtl8180_dev.c +++ b/drivers/net/wireless/rtl8180_dev.c | |||
@@ -49,6 +49,41 @@ static struct pci_device_id rtl8180_table[] __devinitdata = { | |||
49 | 49 | ||
50 | MODULE_DEVICE_TABLE(pci, rtl8180_table); | 50 | MODULE_DEVICE_TABLE(pci, rtl8180_table); |
51 | 51 | ||
52 | static const struct ieee80211_rate rtl818x_rates[] = { | ||
53 | { .bitrate = 10, .hw_value = 0, }, | ||
54 | { .bitrate = 20, .hw_value = 1, }, | ||
55 | { .bitrate = 55, .hw_value = 2, }, | ||
56 | { .bitrate = 110, .hw_value = 3, }, | ||
57 | { .bitrate = 60, .hw_value = 4, }, | ||
58 | { .bitrate = 90, .hw_value = 5, }, | ||
59 | { .bitrate = 120, .hw_value = 6, }, | ||
60 | { .bitrate = 180, .hw_value = 7, }, | ||
61 | { .bitrate = 240, .hw_value = 8, }, | ||
62 | { .bitrate = 360, .hw_value = 9, }, | ||
63 | { .bitrate = 480, .hw_value = 10, }, | ||
64 | { .bitrate = 540, .hw_value = 11, }, | ||
65 | }; | ||
66 | |||
67 | static const struct ieee80211_channel rtl818x_channels[] = { | ||
68 | { .center_freq = 2412 }, | ||
69 | { .center_freq = 2417 }, | ||
70 | { .center_freq = 2422 }, | ||
71 | { .center_freq = 2427 }, | ||
72 | { .center_freq = 2432 }, | ||
73 | { .center_freq = 2437 }, | ||
74 | { .center_freq = 2442 }, | ||
75 | { .center_freq = 2447 }, | ||
76 | { .center_freq = 2452 }, | ||
77 | { .center_freq = 2457 }, | ||
78 | { .center_freq = 2462 }, | ||
79 | { .center_freq = 2467 }, | ||
80 | { .center_freq = 2472 }, | ||
81 | { .center_freq = 2484 }, | ||
82 | }; | ||
83 | |||
84 | |||
85 | |||
86 | |||
52 | void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data) | 87 | void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data) |
53 | { | 88 | { |
54 | struct rtl8180_priv *priv = dev->priv; | 89 | struct rtl8180_priv *priv = dev->priv; |
@@ -99,10 +134,10 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) | |||
99 | /* TODO: improve signal/rssi reporting */ | 134 | /* TODO: improve signal/rssi reporting */ |
100 | rx_status.signal = flags2 & 0xFF; | 135 | rx_status.signal = flags2 & 0xFF; |
101 | rx_status.ssi = (flags2 >> 8) & 0x7F; | 136 | rx_status.ssi = (flags2 >> 8) & 0x7F; |
102 | rx_status.rate = (flags >> 20) & 0xF; | 137 | /* XXX: is this correct? */ |
103 | rx_status.freq = dev->conf.freq; | 138 | rx_status.rate_idx = (flags >> 20) & 0xF; |
104 | rx_status.channel = dev->conf.channel; | 139 | rx_status.freq = dev->conf.channel->center_freq; |
105 | rx_status.phymode = dev->conf.phymode; | 140 | rx_status.band = dev->conf.channel->band; |
106 | rx_status.mactime = le64_to_cpu(entry->tsft); | 141 | rx_status.mactime = le64_to_cpu(entry->tsft); |
107 | rx_status.flag |= RX_FLAG_TSFT; | 142 | rx_status.flag |= RX_FLAG_TSFT; |
108 | if (flags & RTL8180_RX_DESC_FLAG_CRC32_ERR) | 143 | if (flags & RTL8180_RX_DESC_FLAG_CRC32_ERR) |
@@ -223,8 +258,9 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
223 | skb->len, PCI_DMA_TODEVICE); | 258 | skb->len, PCI_DMA_TODEVICE); |
224 | 259 | ||
225 | tx_flags = RTL8180_TX_DESC_FLAG_OWN | RTL8180_TX_DESC_FLAG_FS | | 260 | tx_flags = RTL8180_TX_DESC_FLAG_OWN | RTL8180_TX_DESC_FLAG_FS | |
226 | RTL8180_TX_DESC_FLAG_LS | (control->tx_rate << 24) | | 261 | RTL8180_TX_DESC_FLAG_LS | |
227 | (control->rts_cts_rate << 19) | skb->len; | 262 | (control->tx_rate->hw_value << 24) | |
263 | (control->rts_cts_rate->hw_value << 19) | skb->len; | ||
228 | 264 | ||
229 | if (priv->r8185) | 265 | if (priv->r8185) |
230 | tx_flags |= RTL8180_TX_DESC_FLAG_DMA | | 266 | tx_flags |= RTL8180_TX_DESC_FLAG_DMA | |
@@ -246,9 +282,9 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
246 | unsigned int remainder; | 282 | unsigned int remainder; |
247 | 283 | ||
248 | plcp_len = DIV_ROUND_UP(16 * (skb->len + 4), | 284 | plcp_len = DIV_ROUND_UP(16 * (skb->len + 4), |
249 | (control->rate->rate * 2) / 10); | 285 | (control->tx_rate->bitrate * 2) / 10); |
250 | remainder = (16 * (skb->len + 4)) % | 286 | remainder = (16 * (skb->len + 4)) % |
251 | ((control->rate->rate * 2) / 10); | 287 | ((control->tx_rate->bitrate * 2) / 10); |
252 | if (remainder > 0 && remainder <= 6) | 288 | if (remainder > 0 && remainder <= 6) |
253 | plcp_len |= 1 << 15; | 289 | plcp_len |= 1 << 15; |
254 | } | 290 | } |
@@ -261,8 +297,8 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
261 | entry->plcp_len = cpu_to_le16(plcp_len); | 297 | entry->plcp_len = cpu_to_le16(plcp_len); |
262 | entry->tx_buf = cpu_to_le32(mapping); | 298 | entry->tx_buf = cpu_to_le32(mapping); |
263 | entry->frame_len = cpu_to_le32(skb->len); | 299 | entry->frame_len = cpu_to_le32(skb->len); |
264 | entry->flags2 = control->alt_retry_rate != -1 ? | 300 | entry->flags2 = control->alt_retry_rate != NULL ? |
265 | control->alt_retry_rate << 4 : 0; | 301 | control->alt_retry_rate->bitrate << 4 : 0; |
266 | entry->retry_limit = control->retry_limit; | 302 | entry->retry_limit = control->retry_limit; |
267 | entry->flags = cpu_to_le32(tx_flags); | 303 | entry->flags = cpu_to_le32(tx_flags); |
268 | __skb_queue_tail(&ring->queue, skb); | 304 | __skb_queue_tail(&ring->queue, skb); |
@@ -838,19 +874,19 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev, | |||
838 | goto err_free_dev; | 874 | goto err_free_dev; |
839 | } | 875 | } |
840 | 876 | ||
877 | BUILD_BUG_ON(sizeof(priv->channels) != sizeof(rtl818x_channels)); | ||
878 | BUILD_BUG_ON(sizeof(priv->rates) != sizeof(rtl818x_rates)); | ||
879 | |||
841 | memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); | 880 | memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); |
842 | memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); | 881 | memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); |
843 | priv->modes[0].mode = MODE_IEEE80211G; | 882 | |
844 | priv->modes[0].num_rates = ARRAY_SIZE(rtl818x_rates); | 883 | priv->band.band = IEEE80211_BAND_2GHZ; |
845 | priv->modes[0].rates = priv->rates; | 884 | priv->band.channels = priv->channels; |
846 | priv->modes[0].num_channels = ARRAY_SIZE(rtl818x_channels); | 885 | priv->band.n_channels = ARRAY_SIZE(rtl818x_channels); |
847 | priv->modes[0].channels = priv->channels; | 886 | priv->band.bitrates = priv->rates; |
848 | priv->modes[1].mode = MODE_IEEE80211B; | 887 | priv->band.n_bitrates = 4; |
849 | priv->modes[1].num_rates = 4; | 888 | dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band; |
850 | priv->modes[1].rates = priv->rates; | 889 | |
851 | priv->modes[1].num_channels = ARRAY_SIZE(rtl818x_channels); | ||
852 | priv->modes[1].channels = priv->channels; | ||
853 | priv->mode = IEEE80211_IF_TYPE_INVALID; | ||
854 | dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | | 890 | dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | |
855 | IEEE80211_HW_RX_INCLUDES_FCS; | 891 | IEEE80211_HW_RX_INCLUDES_FCS; |
856 | dev->queues = 1; | 892 | dev->queues = 1; |
@@ -879,15 +915,10 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev, | |||
879 | 915 | ||
880 | priv->r8185 = reg & RTL818X_TX_CONF_R8185_ABC; | 916 | priv->r8185 = reg & RTL818X_TX_CONF_R8185_ABC; |
881 | if (priv->r8185) { | 917 | if (priv->r8185) { |
882 | if ((err = ieee80211_register_hwmode(dev, &priv->modes[0]))) | 918 | priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates); |
883 | goto err_iounmap; | ||
884 | |||
885 | pci_try_set_mwi(pdev); | 919 | pci_try_set_mwi(pdev); |
886 | } | 920 | } |
887 | 921 | ||
888 | if ((err = ieee80211_register_hwmode(dev, &priv->modes[1]))) | ||
889 | goto err_iounmap; | ||
890 | |||
891 | eeprom.data = dev; | 922 | eeprom.data = dev; |
892 | eeprom.register_read = rtl8180_eeprom_register_read; | 923 | eeprom.register_read = rtl8180_eeprom_register_read; |
893 | eeprom.register_write = rtl8180_eeprom_register_write; | 924 | eeprom.register_write = rtl8180_eeprom_register_write; |
@@ -950,8 +981,8 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev, | |||
950 | for (i = 0; i < 14; i += 2) { | 981 | for (i = 0; i < 14; i += 2) { |
951 | u16 txpwr; | 982 | u16 txpwr; |
952 | eeprom_93cx6_read(&eeprom, 0x10 + (i >> 1), &txpwr); | 983 | eeprom_93cx6_read(&eeprom, 0x10 + (i >> 1), &txpwr); |
953 | priv->channels[i].val = txpwr & 0xFF; | 984 | priv->channels[i].hw_value = txpwr & 0xFF; |
954 | priv->channels[i + 1].val = txpwr >> 8; | 985 | priv->channels[i + 1].hw_value = txpwr >> 8; |
955 | } | 986 | } |
956 | 987 | ||
957 | /* OFDM TX power */ | 988 | /* OFDM TX power */ |
@@ -959,8 +990,8 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev, | |||
959 | for (i = 0; i < 14; i += 2) { | 990 | for (i = 0; i < 14; i += 2) { |
960 | u16 txpwr; | 991 | u16 txpwr; |
961 | eeprom_93cx6_read(&eeprom, 0x20 + (i >> 1), &txpwr); | 992 | eeprom_93cx6_read(&eeprom, 0x20 + (i >> 1), &txpwr); |
962 | priv->channels[i].val |= (txpwr & 0xFF) << 8; | 993 | priv->channels[i].hw_value |= (txpwr & 0xFF) << 8; |
963 | priv->channels[i + 1].val |= txpwr & 0xFF00; | 994 | priv->channels[i + 1].hw_value |= txpwr & 0xFF00; |
964 | } | 995 | } |
965 | } | 996 | } |
966 | 997 | ||
diff --git a/drivers/net/wireless/rtl8180_grf5101.c b/drivers/net/wireless/rtl8180_grf5101.c index 8293e19c4c59..5d47935dbac3 100644 --- a/drivers/net/wireless/rtl8180_grf5101.c +++ b/drivers/net/wireless/rtl8180_grf5101.c | |||
@@ -73,8 +73,9 @@ static void grf5101_rf_set_channel(struct ieee80211_hw *dev, | |||
73 | struct ieee80211_conf *conf) | 73 | struct ieee80211_conf *conf) |
74 | { | 74 | { |
75 | struct rtl8180_priv *priv = dev->priv; | 75 | struct rtl8180_priv *priv = dev->priv; |
76 | u32 txpw = priv->channels[conf->channel - 1].val & 0xFF; | 76 | int channel = ieee80211_frequency_to_channel(conf->channel->center_freq); |
77 | u32 chan = conf->channel - 1; | 77 | u32 txpw = priv->channels[channel - 1].hw_value & 0xFF; |
78 | u32 chan = channel - 1; | ||
78 | 79 | ||
79 | /* set TX power */ | 80 | /* set TX power */ |
80 | write_grf5101(dev, 0x15, 0x0); | 81 | write_grf5101(dev, 0x15, 0x0); |
diff --git a/drivers/net/wireless/rtl8180_max2820.c b/drivers/net/wireless/rtl8180_max2820.c index 98fe9fd64968..a34dfd382b6d 100644 --- a/drivers/net/wireless/rtl8180_max2820.c +++ b/drivers/net/wireless/rtl8180_max2820.c | |||
@@ -78,8 +78,9 @@ static void max2820_rf_set_channel(struct ieee80211_hw *dev, | |||
78 | struct ieee80211_conf *conf) | 78 | struct ieee80211_conf *conf) |
79 | { | 79 | { |
80 | struct rtl8180_priv *priv = dev->priv; | 80 | struct rtl8180_priv *priv = dev->priv; |
81 | unsigned int chan_idx = conf ? conf->channel - 1 : 0; | 81 | int channel = ieee80211_frequency_to_channel(conf->channel->center_freq); |
82 | u32 txpw = priv->channels[chan_idx].val & 0xFF; | 82 | unsigned int chan_idx = channel - 1; |
83 | u32 txpw = priv->channels[chan_idx].hw_value & 0xFF; | ||
83 | u32 chan = max2820_chan[chan_idx]; | 84 | u32 chan = max2820_chan[chan_idx]; |
84 | 85 | ||
85 | /* While philips SA2400 drive the PA bias from | 86 | /* While philips SA2400 drive the PA bias from |
diff --git a/drivers/net/wireless/rtl8180_rtl8225.c b/drivers/net/wireless/rtl8180_rtl8225.c index ef3832bee85c..cd22781728a9 100644 --- a/drivers/net/wireless/rtl8180_rtl8225.c +++ b/drivers/net/wireless/rtl8180_rtl8225.c | |||
@@ -261,8 +261,8 @@ static void rtl8225_rf_set_tx_power(struct ieee80211_hw *dev, int channel) | |||
261 | u32 reg; | 261 | u32 reg; |
262 | int i; | 262 | int i; |
263 | 263 | ||
264 | cck_power = priv->channels[channel - 1].val & 0xFF; | 264 | cck_power = priv->channels[channel - 1].hw_value & 0xFF; |
265 | ofdm_power = priv->channels[channel - 1].val >> 8; | 265 | ofdm_power = priv->channels[channel - 1].hw_value >> 8; |
266 | 266 | ||
267 | cck_power = min(cck_power, (u8)35); | 267 | cck_power = min(cck_power, (u8)35); |
268 | ofdm_power = min(ofdm_power, (u8)35); | 268 | ofdm_power = min(ofdm_power, (u8)35); |
@@ -476,8 +476,8 @@ static void rtl8225z2_rf_set_tx_power(struct ieee80211_hw *dev, int channel) | |||
476 | const u8 *tmp; | 476 | const u8 *tmp; |
477 | int i; | 477 | int i; |
478 | 478 | ||
479 | cck_power = priv->channels[channel - 1].val & 0xFF; | 479 | cck_power = priv->channels[channel - 1].hw_value & 0xFF; |
480 | ofdm_power = priv->channels[channel - 1].val >> 8; | 480 | ofdm_power = priv->channels[channel - 1].hw_value >> 8; |
481 | 481 | ||
482 | if (channel == 14) | 482 | if (channel == 14) |
483 | tmp = rtl8225z2_tx_power_cck_ch14; | 483 | tmp = rtl8225z2_tx_power_cck_ch14; |
@@ -716,13 +716,14 @@ static void rtl8225_rf_set_channel(struct ieee80211_hw *dev, | |||
716 | struct ieee80211_conf *conf) | 716 | struct ieee80211_conf *conf) |
717 | { | 717 | { |
718 | struct rtl8180_priv *priv = dev->priv; | 718 | struct rtl8180_priv *priv = dev->priv; |
719 | int chan = ieee80211_frequency_to_channel(conf->channel->center_freq); | ||
719 | 720 | ||
720 | if (priv->rf->init == rtl8225_rf_init) | 721 | if (priv->rf->init == rtl8225_rf_init) |
721 | rtl8225_rf_set_tx_power(dev, conf->channel); | 722 | rtl8225_rf_set_tx_power(dev, chan); |
722 | else | 723 | else |
723 | rtl8225z2_rf_set_tx_power(dev, conf->channel); | 724 | rtl8225z2_rf_set_tx_power(dev, chan); |
724 | 725 | ||
725 | rtl8225_write(dev, 0x7, rtl8225_chan[conf->channel - 1]); | 726 | rtl8225_write(dev, 0x7, rtl8225_chan[chan - 1]); |
726 | msleep(10); | 727 | msleep(10); |
727 | 728 | ||
728 | if (conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME) { | 729 | if (conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME) { |
diff --git a/drivers/net/wireless/rtl8180_sa2400.c b/drivers/net/wireless/rtl8180_sa2400.c index e08ace7b1cb7..0311b4ea124c 100644 --- a/drivers/net/wireless/rtl8180_sa2400.c +++ b/drivers/net/wireless/rtl8180_sa2400.c | |||
@@ -80,8 +80,9 @@ static void sa2400_rf_set_channel(struct ieee80211_hw *dev, | |||
80 | struct ieee80211_conf *conf) | 80 | struct ieee80211_conf *conf) |
81 | { | 81 | { |
82 | struct rtl8180_priv *priv = dev->priv; | 82 | struct rtl8180_priv *priv = dev->priv; |
83 | u32 txpw = priv->channels[conf->channel - 1].val & 0xFF; | 83 | int channel = ieee80211_frequency_to_channel(conf->channel->center_freq); |
84 | u32 chan = sa2400_chan[conf->channel - 1]; | 84 | u32 txpw = priv->channels[channel - 1].hw_value & 0xFF; |
85 | u32 chan = sa2400_chan[channel - 1]; | ||
85 | 86 | ||
86 | write_sa2400(dev, 7, txpw); | 87 | write_sa2400(dev, 7, txpw); |
87 | 88 | ||
diff --git a/drivers/net/wireless/rtl8187.h b/drivers/net/wireless/rtl8187.h index 8680a0b6433c..076d88b6db0e 100644 --- a/drivers/net/wireless/rtl8187.h +++ b/drivers/net/wireless/rtl8187.h | |||
@@ -71,7 +71,7 @@ struct rtl8187_priv { | |||
71 | /* rtl8187 specific */ | 71 | /* rtl8187 specific */ |
72 | struct ieee80211_channel channels[14]; | 72 | struct ieee80211_channel channels[14]; |
73 | struct ieee80211_rate rates[12]; | 73 | struct ieee80211_rate rates[12]; |
74 | struct ieee80211_hw_mode modes[2]; | 74 | struct ieee80211_supported_band band; |
75 | struct usb_device *udev; | 75 | struct usb_device *udev; |
76 | u32 rx_conf; | 76 | u32 rx_conf; |
77 | u16 txpwr_base; | 77 | u16 txpwr_base; |
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c index f44505994a0e..6ef67990692d 100644 --- a/drivers/net/wireless/rtl8187_dev.c +++ b/drivers/net/wireless/rtl8187_dev.c | |||
@@ -45,6 +45,38 @@ static struct usb_device_id rtl8187_table[] __devinitdata = { | |||
45 | 45 | ||
46 | MODULE_DEVICE_TABLE(usb, rtl8187_table); | 46 | MODULE_DEVICE_TABLE(usb, rtl8187_table); |
47 | 47 | ||
48 | static const struct ieee80211_rate rtl818x_rates[] = { | ||
49 | { .bitrate = 10, .hw_value = 0, }, | ||
50 | { .bitrate = 20, .hw_value = 1, }, | ||
51 | { .bitrate = 55, .hw_value = 2, }, | ||
52 | { .bitrate = 110, .hw_value = 3, }, | ||
53 | { .bitrate = 60, .hw_value = 4, }, | ||
54 | { .bitrate = 90, .hw_value = 5, }, | ||
55 | { .bitrate = 120, .hw_value = 6, }, | ||
56 | { .bitrate = 180, .hw_value = 7, }, | ||
57 | { .bitrate = 240, .hw_value = 8, }, | ||
58 | { .bitrate = 360, .hw_value = 9, }, | ||
59 | { .bitrate = 480, .hw_value = 10, }, | ||
60 | { .bitrate = 540, .hw_value = 11, }, | ||
61 | }; | ||
62 | |||
63 | static const struct ieee80211_channel rtl818x_channels[] = { | ||
64 | { .center_freq = 2412 }, | ||
65 | { .center_freq = 2417 }, | ||
66 | { .center_freq = 2422 }, | ||
67 | { .center_freq = 2427 }, | ||
68 | { .center_freq = 2432 }, | ||
69 | { .center_freq = 2437 }, | ||
70 | { .center_freq = 2442 }, | ||
71 | { .center_freq = 2447 }, | ||
72 | { .center_freq = 2452 }, | ||
73 | { .center_freq = 2457 }, | ||
74 | { .center_freq = 2462 }, | ||
75 | { .center_freq = 2467 }, | ||
76 | { .center_freq = 2472 }, | ||
77 | { .center_freq = 2484 }, | ||
78 | }; | ||
79 | |||
48 | static void rtl8187_iowrite_async_cb(struct urb *urb) | 80 | static void rtl8187_iowrite_async_cb(struct urb *urb) |
49 | { | 81 | { |
50 | kfree(urb->context); | 82 | kfree(urb->context); |
@@ -146,8 +178,8 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
146 | 178 | ||
147 | flags = skb->len; | 179 | flags = skb->len; |
148 | flags |= RTL8187_TX_FLAG_NO_ENCRYPT; | 180 | flags |= RTL8187_TX_FLAG_NO_ENCRYPT; |
149 | flags |= control->rts_cts_rate << 19; | 181 | flags |= control->rts_cts_rate->hw_value << 19; |
150 | flags |= control->tx_rate << 24; | 182 | flags |= control->tx_rate->hw_value << 24; |
151 | if (ieee80211_get_morefrag((struct ieee80211_hdr *)skb->data)) | 183 | if (ieee80211_get_morefrag((struct ieee80211_hdr *)skb->data)) |
152 | flags |= RTL8187_TX_FLAG_MORE_FRAG; | 184 | flags |= RTL8187_TX_FLAG_MORE_FRAG; |
153 | if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) { | 185 | if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) { |
@@ -225,10 +257,9 @@ static void rtl8187_rx_cb(struct urb *urb) | |||
225 | rx_status.antenna = (hdr->signal >> 7) & 1; | 257 | rx_status.antenna = (hdr->signal >> 7) & 1; |
226 | rx_status.signal = 64 - min(hdr->noise, (u8)64); | 258 | rx_status.signal = 64 - min(hdr->noise, (u8)64); |
227 | rx_status.ssi = signal; | 259 | rx_status.ssi = signal; |
228 | rx_status.rate = rate; | 260 | rx_status.rate_idx = rate; |
229 | rx_status.freq = dev->conf.freq; | 261 | rx_status.freq = dev->conf.channel->center_freq; |
230 | rx_status.channel = dev->conf.channel; | 262 | rx_status.band = dev->conf.channel->band; |
231 | rx_status.phymode = dev->conf.phymode; | ||
232 | rx_status.mactime = le64_to_cpu(hdr->mac_time); | 263 | rx_status.mactime = le64_to_cpu(hdr->mac_time); |
233 | rx_status.flag |= RX_FLAG_TSFT; | 264 | rx_status.flag |= RX_FLAG_TSFT; |
234 | if (flags & (1 << 13)) | 265 | if (flags & (1 << 13)) |
@@ -682,19 +713,22 @@ static int __devinit rtl8187_probe(struct usb_interface *intf, | |||
682 | usb_get_dev(udev); | 713 | usb_get_dev(udev); |
683 | 714 | ||
684 | skb_queue_head_init(&priv->rx_queue); | 715 | skb_queue_head_init(&priv->rx_queue); |
716 | |||
717 | BUILD_BUG_ON(sizeof(priv->channels) != sizeof(rtl818x_channels)); | ||
718 | BUILD_BUG_ON(sizeof(priv->rates) != sizeof(rtl818x_rates)); | ||
719 | |||
685 | memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); | 720 | memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); |
686 | memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); | 721 | memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); |
687 | priv->map = (struct rtl818x_csr *)0xFF00; | 722 | priv->map = (struct rtl818x_csr *)0xFF00; |
688 | priv->modes[0].mode = MODE_IEEE80211G; | 723 | |
689 | priv->modes[0].num_rates = ARRAY_SIZE(rtl818x_rates); | 724 | priv->band.band = IEEE80211_BAND_2GHZ; |
690 | priv->modes[0].rates = priv->rates; | 725 | priv->band.channels = priv->channels; |
691 | priv->modes[0].num_channels = ARRAY_SIZE(rtl818x_channels); | 726 | priv->band.n_channels = ARRAY_SIZE(rtl818x_channels); |
692 | priv->modes[0].channels = priv->channels; | 727 | priv->band.bitrates = priv->rates; |
693 | priv->modes[1].mode = MODE_IEEE80211B; | 728 | priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates); |
694 | priv->modes[1].num_rates = 4; | 729 | dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band; |
695 | priv->modes[1].rates = priv->rates; | 730 | |
696 | priv->modes[1].num_channels = ARRAY_SIZE(rtl818x_channels); | 731 | |
697 | priv->modes[1].channels = priv->channels; | ||
698 | priv->mode = IEEE80211_IF_TYPE_MNTR; | 732 | priv->mode = IEEE80211_IF_TYPE_MNTR; |
699 | dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | | 733 | dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | |
700 | IEEE80211_HW_RX_INCLUDES_FCS; | 734 | IEEE80211_HW_RX_INCLUDES_FCS; |
@@ -703,10 +737,6 @@ static int __devinit rtl8187_probe(struct usb_interface *intf, | |||
703 | dev->max_rssi = 65; | 737 | dev->max_rssi = 65; |
704 | dev->max_signal = 64; | 738 | dev->max_signal = 64; |
705 | 739 | ||
706 | for (i = 0; i < 2; i++) | ||
707 | if ((err = ieee80211_register_hwmode(dev, &priv->modes[i]))) | ||
708 | goto err_free_dev; | ||
709 | |||
710 | eeprom.data = dev; | 740 | eeprom.data = dev; |
711 | eeprom.register_read = rtl8187_eeprom_register_read; | 741 | eeprom.register_read = rtl8187_eeprom_register_read; |
712 | eeprom.register_write = rtl8187_eeprom_register_write; | 742 | eeprom.register_write = rtl8187_eeprom_register_write; |
@@ -730,20 +760,20 @@ static int __devinit rtl8187_probe(struct usb_interface *intf, | |||
730 | for (i = 0; i < 3; i++) { | 760 | for (i = 0; i < 3; i++) { |
731 | eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_1 + i, | 761 | eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_1 + i, |
732 | &txpwr); | 762 | &txpwr); |
733 | (*channel++).val = txpwr & 0xFF; | 763 | (*channel++).hw_value = txpwr & 0xFF; |
734 | (*channel++).val = txpwr >> 8; | 764 | (*channel++).hw_value = txpwr >> 8; |
735 | } | 765 | } |
736 | for (i = 0; i < 2; i++) { | 766 | for (i = 0; i < 2; i++) { |
737 | eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_4 + i, | 767 | eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_4 + i, |
738 | &txpwr); | 768 | &txpwr); |
739 | (*channel++).val = txpwr & 0xFF; | 769 | (*channel++).hw_value = txpwr & 0xFF; |
740 | (*channel++).val = txpwr >> 8; | 770 | (*channel++).hw_value = txpwr >> 8; |
741 | } | 771 | } |
742 | for (i = 0; i < 2; i++) { | 772 | for (i = 0; i < 2; i++) { |
743 | eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_6 + i, | 773 | eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_6 + i, |
744 | &txpwr); | 774 | &txpwr); |
745 | (*channel++).val = txpwr & 0xFF; | 775 | (*channel++).hw_value = txpwr & 0xFF; |
746 | (*channel++).val = txpwr >> 8; | 776 | (*channel++).hw_value = txpwr >> 8; |
747 | } | 777 | } |
748 | 778 | ||
749 | eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_BASE, | 779 | eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_BASE, |
diff --git a/drivers/net/wireless/rtl8187_rtl8225.c b/drivers/net/wireless/rtl8187_rtl8225.c index b713de17ba0a..9146387b4c5e 100644 --- a/drivers/net/wireless/rtl8187_rtl8225.c +++ b/drivers/net/wireless/rtl8187_rtl8225.c | |||
@@ -283,8 +283,8 @@ static void rtl8225_rf_set_tx_power(struct ieee80211_hw *dev, int channel) | |||
283 | u32 reg; | 283 | u32 reg; |
284 | int i; | 284 | int i; |
285 | 285 | ||
286 | cck_power = priv->channels[channel - 1].val & 0xF; | 286 | cck_power = priv->channels[channel - 1].hw_value & 0xF; |
287 | ofdm_power = priv->channels[channel - 1].val >> 4; | 287 | ofdm_power = priv->channels[channel - 1].hw_value >> 4; |
288 | 288 | ||
289 | cck_power = min(cck_power, (u8)11); | 289 | cck_power = min(cck_power, (u8)11); |
290 | ofdm_power = min(ofdm_power, (u8)35); | 290 | ofdm_power = min(ofdm_power, (u8)35); |
@@ -500,8 +500,8 @@ static void rtl8225z2_rf_set_tx_power(struct ieee80211_hw *dev, int channel) | |||
500 | u32 reg; | 500 | u32 reg; |
501 | int i; | 501 | int i; |
502 | 502 | ||
503 | cck_power = priv->channels[channel - 1].val & 0xF; | 503 | cck_power = priv->channels[channel - 1].hw_value & 0xF; |
504 | ofdm_power = priv->channels[channel - 1].val >> 4; | 504 | ofdm_power = priv->channels[channel - 1].hw_value >> 4; |
505 | 505 | ||
506 | cck_power = min(cck_power, (u8)15); | 506 | cck_power = min(cck_power, (u8)15); |
507 | cck_power += priv->txpwr_base & 0xF; | 507 | cck_power += priv->txpwr_base & 0xF; |
@@ -735,13 +735,14 @@ static void rtl8225_rf_set_channel(struct ieee80211_hw *dev, | |||
735 | struct ieee80211_conf *conf) | 735 | struct ieee80211_conf *conf) |
736 | { | 736 | { |
737 | struct rtl8187_priv *priv = dev->priv; | 737 | struct rtl8187_priv *priv = dev->priv; |
738 | int chan = ieee80211_frequency_to_channel(conf->channel->center_freq); | ||
738 | 739 | ||
739 | if (priv->rf->init == rtl8225_rf_init) | 740 | if (priv->rf->init == rtl8225_rf_init) |
740 | rtl8225_rf_set_tx_power(dev, conf->channel); | 741 | rtl8225_rf_set_tx_power(dev, chan); |
741 | else | 742 | else |
742 | rtl8225z2_rf_set_tx_power(dev, conf->channel); | 743 | rtl8225z2_rf_set_tx_power(dev, chan); |
743 | 744 | ||
744 | rtl8225_write(dev, 0x7, rtl8225_chan[conf->channel - 1]); | 745 | rtl8225_write(dev, 0x7, rtl8225_chan[chan - 1]); |
745 | msleep(10); | 746 | msleep(10); |
746 | } | 747 | } |
747 | 748 | ||
diff --git a/drivers/net/wireless/rtl818x.h b/drivers/net/wireless/rtl818x.h index 1e7d6f8278d7..4f7d38f506eb 100644 --- a/drivers/net/wireless/rtl818x.h +++ b/drivers/net/wireless/rtl818x.h | |||
@@ -175,74 +175,4 @@ struct rtl818x_rf_ops { | |||
175 | void (*set_chan)(struct ieee80211_hw *, struct ieee80211_conf *); | 175 | void (*set_chan)(struct ieee80211_hw *, struct ieee80211_conf *); |
176 | }; | 176 | }; |
177 | 177 | ||
178 | static const struct ieee80211_rate rtl818x_rates[] = { | ||
179 | { .rate = 10, | ||
180 | .val = 0, | ||
181 | .flags = IEEE80211_RATE_CCK }, | ||
182 | { .rate = 20, | ||
183 | .val = 1, | ||
184 | .flags = IEEE80211_RATE_CCK }, | ||
185 | { .rate = 55, | ||
186 | .val = 2, | ||
187 | .flags = IEEE80211_RATE_CCK }, | ||
188 | { .rate = 110, | ||
189 | .val = 3, | ||
190 | .flags = IEEE80211_RATE_CCK }, | ||
191 | { .rate = 60, | ||
192 | .val = 4, | ||
193 | .flags = IEEE80211_RATE_OFDM }, | ||
194 | { .rate = 90, | ||
195 | .val = 5, | ||
196 | .flags = IEEE80211_RATE_OFDM }, | ||
197 | { .rate = 120, | ||
198 | .val = 6, | ||
199 | .flags = IEEE80211_RATE_OFDM }, | ||
200 | { .rate = 180, | ||
201 | .val = 7, | ||
202 | .flags = IEEE80211_RATE_OFDM }, | ||
203 | { .rate = 240, | ||
204 | .val = 8, | ||
205 | .flags = IEEE80211_RATE_OFDM }, | ||
206 | { .rate = 360, | ||
207 | .val = 9, | ||
208 | .flags = IEEE80211_RATE_OFDM }, | ||
209 | { .rate = 480, | ||
210 | .val = 10, | ||
211 | .flags = IEEE80211_RATE_OFDM }, | ||
212 | { .rate = 540, | ||
213 | .val = 11, | ||
214 | .flags = IEEE80211_RATE_OFDM }, | ||
215 | }; | ||
216 | |||
217 | static const struct ieee80211_channel rtl818x_channels[] = { | ||
218 | { .chan = 1, | ||
219 | .freq = 2412}, | ||
220 | { .chan = 2, | ||
221 | .freq = 2417}, | ||
222 | { .chan = 3, | ||
223 | .freq = 2422}, | ||
224 | { .chan = 4, | ||
225 | .freq = 2427}, | ||
226 | { .chan = 5, | ||
227 | .freq = 2432}, | ||
228 | { .chan = 6, | ||
229 | .freq = 2437}, | ||
230 | { .chan = 7, | ||
231 | .freq = 2442}, | ||
232 | { .chan = 8, | ||
233 | .freq = 2447}, | ||
234 | { .chan = 9, | ||
235 | .freq = 2452}, | ||
236 | { .chan = 10, | ||
237 | .freq = 2457}, | ||
238 | { .chan = 11, | ||
239 | .freq = 2462}, | ||
240 | { .chan = 12, | ||
241 | .freq = 2467}, | ||
242 | { .chan = 13, | ||
243 | .freq = 2472}, | ||
244 | { .chan = 14, | ||
245 | .freq = 2484} | ||
246 | }; | ||
247 | |||
248 | #endif /* RTL818X_H */ | 178 | #endif /* RTL818X_H */ |
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c index 99e5b03b3f51..e3fba6f09455 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) | |||
986 | return 0; | 986 | return 0; |
987 | } | 987 | } |
988 | 988 | ||
989 | static int set_mandatory_rates(struct zd_chip *chip, int mode) | 989 | static int set_mandatory_rates(struct zd_chip *chip, int gmode) |
990 | { | 990 | { |
991 | u32 rates; | 991 | u32 rates; |
992 | ZD_ASSERT(mutex_is_locked(&chip->mutex)); | 992 | ZD_ASSERT(mutex_is_locked(&chip->mutex)); |
@@ -994,17 +994,12 @@ static int set_mandatory_rates(struct zd_chip *chip, int mode) | |||
994 | * that the device is supporting. Until further notice we should try | 994 | * that the device is supporting. Until further notice we should try |
995 | * to support 802.11g also for full speed USB. | 995 | * to support 802.11g also for full speed USB. |
996 | */ | 996 | */ |
997 | switch (mode) { | 997 | if (!gmode) |
998 | case MODE_IEEE80211B: | ||
999 | rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M; | 998 | rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M; |
1000 | break; | 999 | else |
1001 | case MODE_IEEE80211G: | ||
1002 | rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M| | 1000 | rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M| |
1003 | CR_RATE_6M|CR_RATE_12M|CR_RATE_24M; | 1001 | CR_RATE_6M|CR_RATE_12M|CR_RATE_24M; |
1004 | break; | 1002 | |
1005 | default: | ||
1006 | return -EINVAL; | ||
1007 | } | ||
1008 | return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL); | 1003 | return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL); |
1009 | } | 1004 | } |
1010 | 1005 | ||
@@ -1108,7 +1103,7 @@ int zd_chip_init_hw(struct zd_chip *chip) | |||
1108 | * It might be discussed, whether we should suppport pure b mode for | 1103 | * It might be discussed, whether we should suppport pure b mode for |
1109 | * full speed USB. | 1104 | * full speed USB. |
1110 | */ | 1105 | */ |
1111 | r = set_mandatory_rates(chip, MODE_IEEE80211G); | 1106 | r = set_mandatory_rates(chip, 1); |
1112 | if (r) | 1107 | if (r) |
1113 | goto out; | 1108 | goto out; |
1114 | /* Disabling interrupts is certainly a smart thing here. | 1109 | /* 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 7c277ec43f79..d8dc41ec0e5d 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) | |||
65 | 65 | ||
66 | static void unmask_bg_channels(struct ieee80211_hw *hw, | 66 | static void unmask_bg_channels(struct ieee80211_hw *hw, |
67 | const struct channel_range *range, | 67 | const struct channel_range *range, |
68 | struct ieee80211_hw_mode *mode) | 68 | struct ieee80211_supported_band *sband) |
69 | { | 69 | { |
70 | u8 channel; | 70 | u8 channel; |
71 | 71 | ||
72 | for (channel = range->start; channel < range->end; channel++) { | 72 | for (channel = range->start; channel < range->end; channel++) { |
73 | struct ieee80211_channel *chan = | 73 | struct ieee80211_channel *chan = |
74 | &mode->channels[CHAN_TO_IDX(channel)]; | 74 | &sband->channels[CHAN_TO_IDX(channel)]; |
75 | chan->flag |= IEEE80211_CHAN_W_SCAN | | 75 | chan->flags = 0; |
76 | IEEE80211_CHAN_W_ACTIVE_SCAN | | ||
77 | IEEE80211_CHAN_W_IBSS; | ||
78 | } | 76 | } |
79 | } | 77 | } |
80 | 78 | ||
@@ -97,7 +95,6 @@ void zd_geo_init(struct ieee80211_hw *hw, u8 regdomain) | |||
97 | range = zd_channel_range(ZD_REGDOMAIN_FCC); | 95 | range = zd_channel_range(ZD_REGDOMAIN_FCC); |
98 | } | 96 | } |
99 | 97 | ||
100 | unmask_bg_channels(hw, range, &mac->modes[0]); | 98 | unmask_bg_channels(hw, range, &mac->band); |
101 | unmask_bg_channels(hw, range, &mac->modes[1]); | ||
102 | } | 99 | } |
103 | 100 | ||
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index 76ef2d83919d..21b653458831 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c | |||
@@ -34,76 +34,61 @@ | |||
34 | 34 | ||
35 | /* This table contains the hardware specific values for the modulation rates. */ | 35 | /* This table contains the hardware specific values for the modulation rates. */ |
36 | static const struct ieee80211_rate zd_rates[] = { | 36 | static const struct ieee80211_rate zd_rates[] = { |
37 | { .rate = 10, | 37 | { .bitrate = 10, |
38 | .val = ZD_CCK_RATE_1M, | 38 | .hw_value = ZD_CCK_RATE_1M, }, |
39 | .flags = IEEE80211_RATE_CCK }, | 39 | { .bitrate = 20, |
40 | { .rate = 20, | 40 | .hw_value = ZD_CCK_RATE_2M, |
41 | .val = ZD_CCK_RATE_2M, | 41 | .hw_value_short = ZD_CCK_RATE_2M | ZD_CCK_PREA_SHORT, |
42 | .val2 = ZD_CCK_RATE_2M | ZD_CCK_PREA_SHORT, | 42 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
43 | .flags = IEEE80211_RATE_CCK_2 }, | 43 | { .bitrate = 55, |
44 | { .rate = 55, | 44 | .hw_value = ZD_CCK_RATE_5_5M, |
45 | .val = ZD_CCK_RATE_5_5M, | 45 | .hw_value_short = ZD_CCK_RATE_5_5M | ZD_CCK_PREA_SHORT, |
46 | .val2 = ZD_CCK_RATE_5_5M | ZD_CCK_PREA_SHORT, | 46 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
47 | .flags = IEEE80211_RATE_CCK_2 }, | 47 | { .bitrate = 110, |
48 | { .rate = 110, | 48 | .hw_value = ZD_CCK_RATE_11M, |
49 | .val = ZD_CCK_RATE_11M, | 49 | .hw_value_short = ZD_CCK_RATE_11M | ZD_CCK_PREA_SHORT, |
50 | .val2 = ZD_CCK_RATE_11M | ZD_CCK_PREA_SHORT, | 50 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
51 | .flags = IEEE80211_RATE_CCK_2 }, | 51 | { .bitrate = 60, |
52 | { .rate = 60, | 52 | .hw_value = ZD_OFDM_RATE_6M, |
53 | .val = ZD_OFDM_RATE_6M, | 53 | .flags = 0 }, |
54 | .flags = IEEE80211_RATE_OFDM }, | 54 | { .bitrate = 90, |
55 | { .rate = 90, | 55 | .hw_value = ZD_OFDM_RATE_9M, |
56 | .val = ZD_OFDM_RATE_9M, | 56 | .flags = 0 }, |
57 | .flags = IEEE80211_RATE_OFDM }, | 57 | { .bitrate = 120, |
58 | { .rate = 120, | 58 | .hw_value = ZD_OFDM_RATE_12M, |
59 | .val = ZD_OFDM_RATE_12M, | 59 | .flags = 0 }, |
60 | .flags = IEEE80211_RATE_OFDM }, | 60 | { .bitrate = 180, |
61 | { .rate = 180, | 61 | .hw_value = ZD_OFDM_RATE_18M, |
62 | .val = ZD_OFDM_RATE_18M, | 62 | .flags = 0 }, |
63 | .flags = IEEE80211_RATE_OFDM }, | 63 | { .bitrate = 240, |
64 | { .rate = 240, | 64 | .hw_value = ZD_OFDM_RATE_24M, |
65 | .val = ZD_OFDM_RATE_24M, | 65 | .flags = 0 }, |
66 | .flags = IEEE80211_RATE_OFDM }, | 66 | { .bitrate = 360, |
67 | { .rate = 360, | 67 | .hw_value = ZD_OFDM_RATE_36M, |
68 | .val = ZD_OFDM_RATE_36M, | 68 | .flags = 0 }, |
69 | .flags = IEEE80211_RATE_OFDM }, | 69 | { .bitrate = 480, |
70 | { .rate = 480, | 70 | .hw_value = ZD_OFDM_RATE_48M, |
71 | .val = ZD_OFDM_RATE_48M, | 71 | .flags = 0 }, |
72 | .flags = IEEE80211_RATE_OFDM }, | 72 | { .bitrate = 540, |
73 | { .rate = 540, | 73 | .hw_value = ZD_OFDM_RATE_54M, |
74 | .val = ZD_OFDM_RATE_54M, | 74 | .flags = 0 }, |
75 | .flags = IEEE80211_RATE_OFDM }, | ||
76 | }; | 75 | }; |
77 | 76 | ||
78 | static const struct ieee80211_channel zd_channels[] = { | 77 | static const struct ieee80211_channel zd_channels[] = { |
79 | { .chan = 1, | 78 | { .center_freq = 2412, .hw_value = 1 }, |
80 | .freq = 2412}, | 79 | { .center_freq = 2417, .hw_value = 2 }, |
81 | { .chan = 2, | 80 | { .center_freq = 2422, .hw_value = 3 }, |
82 | .freq = 2417}, | 81 | { .center_freq = 2427, .hw_value = 4 }, |
83 | { .chan = 3, | 82 | { .center_freq = 2432, .hw_value = 5 }, |
84 | .freq = 2422}, | 83 | { .center_freq = 2437, .hw_value = 6 }, |
85 | { .chan = 4, | 84 | { .center_freq = 2442, .hw_value = 7 }, |
86 | .freq = 2427}, | 85 | { .center_freq = 2447, .hw_value = 8 }, |
87 | { .chan = 5, | 86 | { .center_freq = 2452, .hw_value = 9 }, |
88 | .freq = 2432}, | 87 | { .center_freq = 2457, .hw_value = 10 }, |
89 | { .chan = 6, | 88 | { .center_freq = 2462, .hw_value = 11 }, |
90 | .freq = 2437}, | 89 | { .center_freq = 2467, .hw_value = 12 }, |
91 | { .chan = 7, | 90 | { .center_freq = 2472, .hw_value = 13 }, |
92 | .freq = 2442}, | 91 | { .center_freq = 2484, .hw_value = 14 }, |
93 | { .chan = 8, | ||
94 | .freq = 2447}, | ||
95 | { .chan = 9, | ||
96 | .freq = 2452}, | ||
97 | { .chan = 10, | ||
98 | .freq = 2457}, | ||
99 | { .chan = 11, | ||
100 | .freq = 2462}, | ||
101 | { .chan = 12, | ||
102 | .freq = 2467}, | ||
103 | { .chan = 13, | ||
104 | .freq = 2472}, | ||
105 | { .chan = 14, | ||
106 | .freq = 2484} | ||
107 | }; | 92 | }; |
108 | 93 | ||
109 | static void housekeeping_init(struct zd_mac *mac); | 94 | static void housekeeping_init(struct zd_mac *mac); |
@@ -503,7 +488,9 @@ static int fill_ctrlset(struct zd_mac *mac, | |||
503 | 488 | ||
504 | ZD_ASSERT(frag_len <= 0xffff); | 489 | ZD_ASSERT(frag_len <= 0xffff); |
505 | 490 | ||
506 | cs->modulation = control->tx_rate; | 491 | cs->modulation = control->tx_rate->hw_value; |
492 | if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) | ||
493 | cs->modulation = control->tx_rate->hw_value_short; | ||
507 | 494 | ||
508 | cs->tx_length = cpu_to_le16(frag_len); | 495 | cs->tx_length = cpu_to_le16(frag_len); |
509 | 496 | ||
@@ -631,6 +618,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length) | |||
631 | int bad_frame = 0; | 618 | int bad_frame = 0; |
632 | u16 fc; | 619 | u16 fc; |
633 | bool is_qos, is_4addr, need_padding; | 620 | bool is_qos, is_4addr, need_padding; |
621 | int i; | ||
622 | u8 rate; | ||
634 | 623 | ||
635 | if (length < ZD_PLCP_HEADER_SIZE + 10 /* IEEE80211_1ADDR_LEN */ + | 624 | if (length < ZD_PLCP_HEADER_SIZE + 10 /* IEEE80211_1ADDR_LEN */ + |
636 | FCS_LEN + sizeof(struct rx_status)) | 625 | FCS_LEN + sizeof(struct rx_status)) |
@@ -660,14 +649,19 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length) | |||
660 | } | 649 | } |
661 | } | 650 | } |
662 | 651 | ||
663 | stats.channel = _zd_chip_get_channel(&mac->chip); | 652 | stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; |
664 | stats.freq = zd_channels[stats.channel - 1].freq; | 653 | stats.band = IEEE80211_BAND_2GHZ; |
665 | stats.phymode = MODE_IEEE80211G; | ||
666 | stats.ssi = status->signal_strength; | 654 | stats.ssi = status->signal_strength; |
667 | stats.signal = zd_rx_qual_percent(buffer, | 655 | stats.signal = zd_rx_qual_percent(buffer, |
668 | length - sizeof(struct rx_status), | 656 | length - sizeof(struct rx_status), |
669 | status); | 657 | status); |
670 | stats.rate = zd_rx_rate(buffer, status); | 658 | |
659 | rate = zd_rx_rate(buffer, status); | ||
660 | |||
661 | /* todo: return index in the big switches in zd_rx_rate instead */ | ||
662 | for (i = 0; i < mac->band.n_bitrates; i++) | ||
663 | if (rate == mac->band.bitrates[i].hw_value) | ||
664 | stats.rate_idx = i; | ||
671 | 665 | ||
672 | length -= ZD_PLCP_HEADER_SIZE + sizeof(struct rx_status); | 666 | length -= ZD_PLCP_HEADER_SIZE + sizeof(struct rx_status); |
673 | buffer += ZD_PLCP_HEADER_SIZE; | 667 | buffer += ZD_PLCP_HEADER_SIZE; |
@@ -736,7 +730,7 @@ static void zd_op_remove_interface(struct ieee80211_hw *hw, | |||
736 | static int zd_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) | 730 | static int zd_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) |
737 | { | 731 | { |
738 | struct zd_mac *mac = zd_hw_mac(hw); | 732 | struct zd_mac *mac = zd_hw_mac(hw); |
739 | return zd_chip_set_channel(&mac->chip, conf->channel); | 733 | return zd_chip_set_channel(&mac->chip, conf->channel->hw_value); |
740 | } | 734 | } |
741 | 735 | ||
742 | static int zd_op_config_interface(struct ieee80211_hw *hw, | 736 | 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) | |||
894 | { | 888 | { |
895 | struct zd_mac *mac; | 889 | struct zd_mac *mac; |
896 | struct ieee80211_hw *hw; | 890 | struct ieee80211_hw *hw; |
897 | int i; | ||
898 | 891 | ||
899 | hw = ieee80211_alloc_hw(sizeof(struct zd_mac), &zd_ops); | 892 | hw = ieee80211_alloc_hw(sizeof(struct zd_mac), &zd_ops); |
900 | if (!hw) { | 893 | if (!hw) { |
@@ -912,19 +905,14 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) | |||
912 | 905 | ||
913 | memcpy(mac->channels, zd_channels, sizeof(zd_channels)); | 906 | memcpy(mac->channels, zd_channels, sizeof(zd_channels)); |
914 | memcpy(mac->rates, zd_rates, sizeof(zd_rates)); | 907 | memcpy(mac->rates, zd_rates, sizeof(zd_rates)); |
915 | mac->modes[0].mode = MODE_IEEE80211G; | 908 | mac->band.n_bitrates = ARRAY_SIZE(zd_rates); |
916 | mac->modes[0].num_rates = ARRAY_SIZE(zd_rates); | 909 | mac->band.bitrates = mac->rates; |
917 | mac->modes[0].rates = mac->rates; | 910 | mac->band.n_channels = ARRAY_SIZE(zd_channels); |
918 | mac->modes[0].num_channels = ARRAY_SIZE(zd_channels); | 911 | mac->band.channels = mac->channels; |
919 | mac->modes[0].channels = mac->channels; | 912 | |
920 | mac->modes[1].mode = MODE_IEEE80211B; | 913 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; |
921 | mac->modes[1].num_rates = 4; | 914 | |
922 | mac->modes[1].rates = mac->rates; | 915 | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS; |
923 | mac->modes[1].num_channels = ARRAY_SIZE(zd_channels); | ||
924 | mac->modes[1].channels = mac->channels; | ||
925 | |||
926 | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | | ||
927 | IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED; | ||
928 | hw->max_rssi = 100; | 916 | hw->max_rssi = 100; |
929 | hw->max_signal = 100; | 917 | hw->max_signal = 100; |
930 | 918 | ||
@@ -933,14 +921,6 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) | |||
933 | 921 | ||
934 | skb_queue_head_init(&mac->ack_wait_queue); | 922 | skb_queue_head_init(&mac->ack_wait_queue); |
935 | 923 | ||
936 | for (i = 0; i < 2; i++) { | ||
937 | if (ieee80211_register_hwmode(hw, &mac->modes[i])) { | ||
938 | dev_dbg_f(&intf->dev, "cannot register hwmode\n"); | ||
939 | ieee80211_free_hw(hw); | ||
940 | return NULL; | ||
941 | } | ||
942 | } | ||
943 | |||
944 | zd_chip_init(&mac->chip, hw, intf); | 924 | zd_chip_init(&mac->chip, hw, intf); |
945 | housekeeping_init(mac); | 925 | housekeeping_init(mac); |
946 | INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler); | 926 | 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 2dde108df767..67dea9739c8f 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.h +++ b/drivers/net/wireless/zd1211rw/zd_mac.h | |||
@@ -185,7 +185,7 @@ struct zd_mac { | |||
185 | struct sk_buff_head ack_wait_queue; | 185 | struct sk_buff_head ack_wait_queue; |
186 | struct ieee80211_channel channels[14]; | 186 | struct ieee80211_channel channels[14]; |
187 | struct ieee80211_rate rates[12]; | 187 | struct ieee80211_rate rates[12]; |
188 | struct ieee80211_hw_mode modes[2]; | 188 | struct ieee80211_supported_band band; |
189 | 189 | ||
190 | /* Short preamble (used for RTS/CTS) */ | 190 | /* Short preamble (used for RTS/CTS) */ |
191 | unsigned int short_preamble:1; | 191 | unsigned int short_preamble:1; |