Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Johannes Berg and committed by
John W. Linville
8318d78a 10b6b801

+2111 -2776
+1
drivers/net/wireless/Kconfig
··· 735 735 config ATH5K 736 736 tristate "Atheros 5xxx wireless cards support" 737 737 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL 738 + depends on BROKEN 738 739 ---help--- 739 740 This module adds support for wireless adapters based on 740 741 Atheros 5xxx chipset.
+45 -35
drivers/net/wireless/adm8211.c
··· 48 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 77 static void adm8211_eeprom_register_read(struct eeprom_93cx6 *eeprom) 52 78 { 53 79 struct adm8211_priv *priv = eeprom->data; ··· 181 155 printk(KERN_DEBUG "%s (adm8211): Channel range: %d - %d\n", 182 156 pci_name(priv->pdev), (int)chan_range.min, (int)chan_range.max); 183 157 184 - priv->modes[0].num_channels = chan_range.max - chan_range.min + 1; 185 - priv->modes[0].channels = priv->channels; 158 + BUILD_BUG_ON(sizeof(priv->channels) != sizeof(adm8211_channels)); 186 159 187 - memcpy(priv->channels, adm8211_channels, sizeof(adm8211_channels)); 160 + memcpy(priv->channels, adm8211_channels, sizeof(priv->channels)); 161 + priv->band.channels = priv->channels; 162 + priv->band.n_channels = ARRAY_SIZE(adm8211_channels); 163 + priv->band.bitrates = adm8211_rates; 164 + priv->band.n_bitrates = ARRAY_SIZE(adm8211_rates); 188 165 189 166 for (i = 1; i <= ARRAY_SIZE(adm8211_channels); i++) 190 - if (i >= chan_range.min && i <= chan_range.max) 191 - priv->channels[i - 1].flag = 192 - IEEE80211_CHAN_W_SCAN | 193 - IEEE80211_CHAN_W_ACTIVE_SCAN | 194 - IEEE80211_CHAN_W_IBSS; 167 + if (i < chan_range.min || i > chan_range.max) 168 + priv->channels[i - 1].flags |= IEEE80211_CHAN_DISABLED; 195 169 196 170 switch (priv->eeprom->specific_bbptype) { 197 171 case ADM8211_BBP_RFMD3000: ··· 373 347 unsigned int pktlen; 374 348 struct sk_buff *skb, *newskb; 375 349 unsigned int limit = priv->rx_ring_size; 376 - static const u8 rate_tbl[] = {10, 20, 55, 110, 220}; 377 350 u8 rssi, rate; 378 351 379 352 while (!(priv->rx_ring[entry].status & cpu_to_le32(RDES0_STATUS_OWN))) { ··· 450 425 else 451 426 rx_status.ssi = 100 - rssi; 452 427 453 - if (rate <= 4) 454 - rx_status.rate = rate_tbl[rate]; 428 + rx_status.rate_idx = rate; 455 429 456 - rx_status.channel = priv->channel; 457 - rx_status.freq = adm8211_channels[priv->channel - 1].freq; 458 - rx_status.phymode = MODE_IEEE80211B; 430 + rx_status.freq = adm8211_channels[priv->channel - 1].center_freq; 431 + rx_status.band = IEEE80211_BAND_2GHZ; 459 432 460 433 ieee80211_rx_irqsafe(dev, skb, &rx_status); 461 434 } ··· 1077 1054 if (priv->pdev->revision != ADM8211_REV_BA) { 1078 1055 rate_buf[0] = ARRAY_SIZE(adm8211_rates); 1079 1056 for (i = 0; i < ARRAY_SIZE(adm8211_rates); i++) 1080 - rate_buf[i + 1] = (adm8211_rates[i].rate / 5) | 0x80; 1057 + rate_buf[i + 1] = (adm8211_rates[i].bitrate / 5) | 0x80; 1081 1058 } else { 1082 1059 /* workaround for rev BA specific bug */ 1083 1060 rate_buf[0] = 0x04; ··· 1326 1303 static int adm8211_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) 1327 1304 { 1328 1305 struct adm8211_priv *priv = dev->priv; 1306 + int channel = ieee80211_frequency_to_channel(conf->channel->center_freq); 1329 1307 1330 - if (conf->channel != priv->channel) { 1331 - priv->channel = conf->channel; 1308 + if (channel != priv->channel) { 1309 + priv->channel = channel; 1332 1310 adm8211_rf_set_channel(dev, priv->channel); 1333 1311 } 1334 1312 ··· 1704 1680 1705 1681 if (control->tx_rate < 0) { 1706 1682 short_preamble = 1; 1707 - plcp_signal = -control->tx_rate; 1683 + plcp_signal = -control->tx_rate->bitrate; 1708 1684 } else { 1709 1685 short_preamble = 0; 1710 - plcp_signal = control->tx_rate; 1686 + plcp_signal = control->tx_rate->bitrate; 1711 1687 } 1712 1688 1713 1689 hdr = (struct ieee80211_hdr *)skb->data; ··· 1904 1880 SET_IEEE80211_PERM_ADDR(dev, perm_addr); 1905 1881 1906 1882 dev->extra_tx_headroom = sizeof(struct adm8211_tx_hdr); 1907 - dev->flags = IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED; 1908 - /* IEEE80211_HW_RX_INCLUDES_FCS in promisc mode */ 1883 + /* dev->flags = IEEE80211_HW_RX_INCLUDES_FCS in promisc mode */ 1909 1884 1910 1885 dev->channel_change_time = 1000; 1911 1886 dev->max_rssi = 100; /* FIXME: find better value */ 1912 - 1913 - priv->modes[0].mode = MODE_IEEE80211B; 1914 - /* channel info filled in by adm8211_read_eeprom */ 1915 - memcpy(priv->rates, adm8211_rates, sizeof(adm8211_rates)); 1916 - priv->modes[0].num_rates = ARRAY_SIZE(adm8211_rates); 1917 - priv->modes[0].rates = priv->rates; 1918 1887 1919 1888 dev->queues = 1; /* ADM8211C supports more, maybe ADM8211B too */ 1920 1889 ··· 1934 1917 goto err_free_desc; 1935 1918 } 1936 1919 1937 - priv->channel = priv->modes[0].channels[0].chan; 1938 - 1939 - err = ieee80211_register_hwmode(dev, &priv->modes[0]); 1940 - if (err) { 1941 - printk(KERN_ERR "%s (adm8211): Can't register hwmode\n", 1942 - pci_name(pdev)); 1943 - goto err_free_desc; 1944 - } 1920 + priv->channel = 1; 1945 1921 1946 1922 err = ieee80211_register_hw(dev); 1947 1923 if (err) {
+7 -58
drivers/net/wireless/adm8211.h
··· 534 534 u8 cis_data[0]; /* 0x80, 384 bytes */ 535 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 537 struct adm8211_priv { 593 538 struct pci_dev *pdev; 594 539 spinlock_t lock; ··· 548 603 unsigned int cur_tx, dirty_tx, cur_rx; 549 604 550 605 struct ieee80211_low_level_stats stats; 551 - struct ieee80211_hw_mode modes[1]; 552 - struct ieee80211_channel channels[ARRAY_SIZE(adm8211_channels)]; 553 - struct ieee80211_rate rates[ARRAY_SIZE(adm8211_rates)]; 606 + struct ieee80211_supported_band band; 607 + struct ieee80211_channel channels[14]; 554 608 int mode; 555 609 556 610 int channel; ··· 585 641 ADM8211_MAX2820 = 0x8, 586 642 ADM8211_AL2210L = 0xC, /* Airoha */ 587 643 } transceiver_type; 644 + }; 645 + 646 + struct ieee80211_chan_range { 647 + u8 min; 648 + u8 max; 588 649 }; 589 650 590 651 static const struct ieee80211_chan_range cranges[] = {
-5
drivers/net/wireless/b43/b43.h
··· 468 468 u8 possible_phymodes; 469 469 /* GMODE bit enabled? */ 470 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 472 /* Analog Type */ 477 473 u8 analog; ··· 723 727 724 728 bool bad_frames_preempt; /* Use "Bad Frames Preemption" (default off) */ 725 729 bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM) */ 726 - bool short_preamble; /* TRUE, if short preamble is enabled. */ 727 730 bool short_slot; /* TRUE, if short slot timing is enabled. */ 728 731 bool radio_hw_enable; /* saved state of radio hardware enabled state */ 729 732 bool suspend_in_progress; /* TRUE, if we are in a suspend/resume cycle */
+60 -59
drivers/net/wireless/b43/main.c
··· 96 96 * data in there. This data is the same for all devices, so we don't 97 97 * get concurrency issues */ 98 98 #define RATETAB_ENT(_rateid, _flags) \ 99 - { \ 100 - .rate = B43_RATE_TO_BASE100KBPS(_rateid), \ 101 - .val = (_rateid), \ 102 - .val2 = (_rateid), \ 103 - .flags = (_flags), \ 99 + { \ 100 + .bitrate = B43_RATE_TO_BASE100KBPS(_rateid), \ 101 + .hw_value = (_rateid), \ 102 + .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 109 static struct ieee80211_rate __b43_ratetable[] = { 106 - RATETAB_ENT(B43_CCK_RATE_1MB, IEEE80211_RATE_CCK), 107 - RATETAB_ENT(B43_CCK_RATE_2MB, IEEE80211_RATE_CCK_2), 108 - RATETAB_ENT(B43_CCK_RATE_5MB, IEEE80211_RATE_CCK_2), 109 - RATETAB_ENT(B43_CCK_RATE_11MB, IEEE80211_RATE_CCK_2), 110 - RATETAB_ENT(B43_OFDM_RATE_6MB, IEEE80211_RATE_OFDM), 111 - RATETAB_ENT(B43_OFDM_RATE_9MB, IEEE80211_RATE_OFDM), 112 - RATETAB_ENT(B43_OFDM_RATE_12MB, IEEE80211_RATE_OFDM), 113 - RATETAB_ENT(B43_OFDM_RATE_18MB, IEEE80211_RATE_OFDM), 114 - RATETAB_ENT(B43_OFDM_RATE_24MB, IEEE80211_RATE_OFDM), 115 - RATETAB_ENT(B43_OFDM_RATE_36MB, IEEE80211_RATE_OFDM), 116 - RATETAB_ENT(B43_OFDM_RATE_48MB, IEEE80211_RATE_OFDM), 117 - RATETAB_ENT(B43_OFDM_RATE_54MB, IEEE80211_RATE_OFDM), 110 + RATETAB_ENT(B43_CCK_RATE_1MB, 0), 111 + RATETAB_ENT(B43_CCK_RATE_2MB, IEEE80211_RATE_SHORT_PREAMBLE), 112 + RATETAB_ENT(B43_CCK_RATE_5MB, IEEE80211_RATE_SHORT_PREAMBLE), 113 + RATETAB_ENT(B43_CCK_RATE_11MB, IEEE80211_RATE_SHORT_PREAMBLE), 114 + RATETAB_ENT(B43_OFDM_RATE_6MB, 0), 115 + RATETAB_ENT(B43_OFDM_RATE_9MB, 0), 116 + RATETAB_ENT(B43_OFDM_RATE_12MB, 0), 117 + RATETAB_ENT(B43_OFDM_RATE_18MB, 0), 118 + RATETAB_ENT(B43_OFDM_RATE_24MB, 0), 119 + RATETAB_ENT(B43_OFDM_RATE_36MB, 0), 120 + RATETAB_ENT(B43_OFDM_RATE_48MB, 0), 121 + RATETAB_ENT(B43_OFDM_RATE_54MB, 0), 118 122 }; 119 123 120 124 #define b43_a_ratetable (__b43_ratetable + 4) ··· 130 126 131 127 #define CHANTAB_ENT(_chanid, _freq) \ 132 128 { \ 133 - .chan = (_chanid), \ 134 - .freq = (_freq), \ 135 - .val = (_chanid), \ 136 - .flag = IEEE80211_CHAN_W_SCAN | \ 137 - IEEE80211_CHAN_W_ACTIVE_SCAN | \ 138 - IEEE80211_CHAN_W_IBSS, \ 139 - .power_level = 0xFF, \ 140 - .antenna_max = 0xFF, \ 129 + .center_freq = (_freq), \ 130 + .hw_value = (_chanid), \ 141 131 } 142 132 static struct ieee80211_channel b43_2ghz_chantable[] = { 143 133 CHANTAB_ENT(1, 2412), ··· 149 151 CHANTAB_ENT(13, 2472), 150 152 CHANTAB_ENT(14, 2484), 151 153 }; 152 - #define b43_2ghz_chantable_size ARRAY_SIZE(b43_2ghz_chantable) 153 154 154 - #if 0 155 + #ifdef NOTYET 155 156 static struct ieee80211_channel b43_5ghz_chantable[] = { 156 157 CHANTAB_ENT(36, 5180), 157 158 CHANTAB_ENT(40, 5200), ··· 166 169 CHANTAB_ENT(161, 5805), 167 170 CHANTAB_ENT(165, 5825), 168 171 }; 169 - #define b43_5ghz_chantable_size ARRAY_SIZE(b43_5ghz_chantable) 172 + 173 + static struct ieee80211_supported_band b43_band_5GHz = { 174 + .channels = b43_5ghz_chantable, 175 + .n_channels = ARRAY_SIZE(b43_5ghz_chantable), 176 + .bitrates = b43_a_ratetable, 177 + .n_bitrates = b43_a_ratetable_size, 178 + }; 170 179 #endif 180 + 181 + static struct ieee80211_supported_band b43_band_2GHz = { 182 + .channels = b43_2ghz_chantable, 183 + .n_channels = ARRAY_SIZE(b43_2ghz_chantable), 184 + .bitrates = b43_g_ratetable, 185 + .n_bitrates = b43_g_ratetable_size, 186 + }; 171 187 172 188 static void b43_wireless_core_exit(struct b43_wldev *dev); 173 189 static int b43_wireless_core_init(struct b43_wldev *dev); ··· 1232 1222 } 1233 1223 1234 1224 static void b43_write_probe_resp_plcp(struct b43_wldev *dev, 1235 - u16 shm_offset, u16 size, u8 rate) 1225 + u16 shm_offset, u16 size, 1226 + struct ieee80211_rate *rate) 1236 1227 { 1237 1228 struct b43_plcp_hdr4 plcp; 1238 1229 u32 tmp; 1239 1230 __le16 dur; 1240 1231 1241 1232 plcp.data = 0; 1242 - b43_generate_plcp_hdr(&plcp, size + FCS_LEN, rate); 1233 + b43_generate_plcp_hdr(&plcp, size + FCS_LEN, rate->hw_value); 1243 1234 dur = ieee80211_generic_frame_duration(dev->wl->hw, 1244 1235 dev->wl->vif, size, 1245 - B43_RATE_TO_BASE100KBPS(rate)); 1236 + rate); 1246 1237 /* Write PLCP in two parts and timing for packet transfer */ 1247 1238 tmp = le32_to_cpu(plcp.data); 1248 1239 b43_shm_write16(dev, B43_SHM_SHARED, shm_offset, tmp & 0xFFFF); ··· 1258 1247 * 3) Stripping TIM 1259 1248 */ 1260 1249 static const u8 * b43_generate_probe_resp(struct b43_wldev *dev, 1261 - u16 *dest_size, u8 rate) 1250 + u16 *dest_size, 1251 + struct ieee80211_rate *rate) 1262 1252 { 1263 1253 const u8 *src_data; 1264 1254 u8 *dest_data; ··· 1304 1292 IEEE80211_STYPE_PROBE_RESP); 1305 1293 dur = ieee80211_generic_frame_duration(dev->wl->hw, 1306 1294 dev->wl->vif, *dest_size, 1307 - B43_RATE_TO_BASE100KBPS(rate)); 1295 + rate); 1308 1296 hdr->duration_id = dur; 1309 1297 1310 1298 return dest_data; ··· 1312 1300 1313 1301 static void b43_write_probe_resp_template(struct b43_wldev *dev, 1314 1302 u16 ram_offset, 1315 - u16 shm_size_offset, u8 rate) 1303 + u16 shm_size_offset, 1304 + struct ieee80211_rate *rate) 1316 1305 { 1317 1306 const u8 *probe_resp_data; 1318 1307 u16 size; ··· 1326 1313 /* Looks like PLCP headers plus packet timings are stored for 1327 1314 * all possible basic rates 1328 1315 */ 1329 - b43_write_probe_resp_plcp(dev, 0x31A, size, B43_CCK_RATE_1MB); 1330 - b43_write_probe_resp_plcp(dev, 0x32C, size, B43_CCK_RATE_2MB); 1331 - b43_write_probe_resp_plcp(dev, 0x33E, size, B43_CCK_RATE_5MB); 1332 - b43_write_probe_resp_plcp(dev, 0x350, size, B43_CCK_RATE_11MB); 1316 + b43_write_probe_resp_plcp(dev, 0x31A, size, &b43_b_ratetable[0]); 1317 + b43_write_probe_resp_plcp(dev, 0x32C, size, &b43_b_ratetable[1]); 1318 + b43_write_probe_resp_plcp(dev, 0x33E, size, &b43_b_ratetable[2]); 1319 + b43_write_probe_resp_plcp(dev, 0x350, size, &b43_b_ratetable[3]); 1333 1320 1334 1321 size = min((size_t) size, 0x200 - sizeof(struct b43_plcp_hdr6)); 1335 1322 b43_write_template_common(dev, probe_resp_data, 1336 - size, ram_offset, shm_size_offset, rate); 1323 + size, ram_offset, shm_size_offset, 1324 + rate->hw_value); 1337 1325 kfree(probe_resp_data); 1338 1326 } 1339 1327 ··· 1402 1388 b43_write_beacon_template(dev, 0x68, 0x18, 1403 1389 B43_CCK_RATE_1MB); 1404 1390 b43_write_probe_resp_template(dev, 0x268, 0x4A, 1405 - B43_CCK_RATE_11MB); 1391 + &__b43_ratetable[3]); 1406 1392 wl->beacon0_uploaded = 1; 1407 1393 } 1408 1394 cmd |= B43_MACCMD_BEACON0_VALID; ··· 2844 2830 mutex_lock(&wl->mutex); 2845 2831 2846 2832 /* Switch the PHY mode (if necessary). */ 2847 - switch (conf->phymode) { 2848 - case MODE_IEEE80211A: 2833 + switch (conf->channel->band) { 2834 + case IEEE80211_BAND_5GHZ: 2849 2835 new_phymode = B43_PHYMODE_A; 2850 2836 break; 2851 - case MODE_IEEE80211B: 2852 - new_phymode = B43_PHYMODE_B; 2853 - break; 2854 - case MODE_IEEE80211G: 2837 + case IEEE80211_BAND_2GHZ: 2855 2838 new_phymode = B43_PHYMODE_G; 2856 2839 break; 2857 2840 default: ··· 2874 2863 2875 2864 /* Switch to the requested channel. 2876 2865 * The firmware takes care of races with the TX handler. */ 2877 - if (conf->channel_val != phy->channel) 2878 - b43_radio_selectchannel(dev, conf->channel_val, 0); 2866 + if (conf->channel->hw_value != phy->channel) 2867 + b43_radio_selectchannel(dev, conf->channel->hw_value, 0); 2879 2868 2880 2869 /* Enable/Disable ShortSlot timing. */ 2881 2870 if ((!!(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)) != ··· 3821 3810 bool have_2ghz_phy, bool have_5ghz_phy) 3822 3811 { 3823 3812 struct ieee80211_hw *hw = dev->wl->hw; 3824 - struct ieee80211_hw_mode *mode; 3825 3813 struct b43_phy *phy = &dev->phy; 3826 - int err; 3827 3814 3828 3815 /* XXX: This function will go away soon, when mac80211 3829 3816 * band stuff is rewritten. So this is just a hack. ··· 3830 3821 * This assumption is OK, as any B, N or A PHY will already 3831 3822 * have died a horrible sanity check death earlier. */ 3832 3823 3833 - mode = &phy->hwmodes[0]; 3834 - mode->mode = MODE_IEEE80211G; 3835 - mode->num_channels = b43_2ghz_chantable_size; 3836 - mode->channels = b43_2ghz_chantable; 3837 - mode->num_rates = b43_g_ratetable_size; 3838 - mode->rates = b43_g_ratetable; 3839 - err = ieee80211_register_hwmode(hw, mode); 3840 - if (err) 3841 - return err; 3824 + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &b43_band_2GHz; 3842 3825 phy->possible_phymodes |= B43_PHYMODE_G; 3843 3826 3844 3827 return 0;
+1 -88
drivers/net/wireless/b43/sysfs.c
··· 47 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 50 static ssize_t b43_attr_interfmode_show(struct device *dev, 74 51 struct device_attribute *attr, 75 52 char *buf) ··· 132 155 static DEVICE_ATTR(interference, 0644, 133 156 b43_attr_interfmode_show, b43_attr_interfmode_store); 134 157 135 - static ssize_t b43_attr_preamble_show(struct device *dev, 136 - struct device_attribute *attr, char *buf) 137 - { 138 - struct b43_wldev *wldev = dev_to_b43_wldev(dev); 139 - ssize_t count; 140 - 141 - if (!capable(CAP_NET_ADMIN)) 142 - return -EPERM; 143 - 144 - mutex_lock(&wldev->wl->mutex); 145 - 146 - if (wldev->short_preamble) 147 - count = 148 - snprintf(buf, PAGE_SIZE, "1 (Short Preamble enabled)\n"); 149 - else 150 - count = 151 - snprintf(buf, PAGE_SIZE, "0 (Short Preamble disabled)\n"); 152 - 153 - mutex_unlock(&wldev->wl->mutex); 154 - 155 - return count; 156 - } 157 - 158 - static ssize_t b43_attr_preamble_store(struct device *dev, 159 - struct device_attribute *attr, 160 - const char *buf, size_t count) 161 - { 162 - struct b43_wldev *wldev = dev_to_b43_wldev(dev); 163 - unsigned long flags; 164 - int value; 165 - 166 - if (!capable(CAP_NET_ADMIN)) 167 - return -EPERM; 168 - 169 - value = get_boolean(buf, count); 170 - if (value < 0) 171 - return value; 172 - mutex_lock(&wldev->wl->mutex); 173 - spin_lock_irqsave(&wldev->wl->irq_lock, flags); 174 - 175 - wldev->short_preamble = !!value; 176 - 177 - spin_unlock_irqrestore(&wldev->wl->irq_lock, flags); 178 - mutex_unlock(&wldev->wl->mutex); 179 - 180 - return count; 181 - } 182 - 183 - static DEVICE_ATTR(shortpreamble, 0644, 184 - b43_attr_preamble_show, b43_attr_preamble_store); 185 - 186 158 int b43_sysfs_register(struct b43_wldev *wldev) 187 159 { 188 160 struct device *dev = wldev->dev->dev; 189 - int err; 190 161 191 162 B43_WARN_ON(b43_status(wldev) != B43_STAT_INITIALIZED); 192 163 193 - err = device_create_file(dev, &dev_attr_interference); 194 - if (err) 195 - goto out; 196 - err = device_create_file(dev, &dev_attr_shortpreamble); 197 - if (err) 198 - goto err_remove_interfmode; 199 - 200 - out: 201 - return err; 202 - err_remove_interfmode: 203 - device_remove_file(dev, &dev_attr_interference); 204 - goto out; 164 + return device_create_file(dev, &dev_attr_interference); 205 165 } 206 166 207 167 void b43_sysfs_unregister(struct b43_wldev *wldev) 208 168 { 209 169 struct device *dev = wldev->dev->dev; 210 170 211 - device_remove_file(dev, &dev_attr_shortpreamble); 212 171 device_remove_file(dev, &dev_attr_interference); 213 172 }
+44 -37
drivers/net/wireless/b43/xmit.c
··· 32 32 #include "dma.h" 33 33 34 34 35 - /* Extract the bitrate out of a CCK PLCP header. */ 36 - static u8 b43_plcp_get_bitrate_cck(struct b43_plcp_hdr6 *plcp) 35 + /* Extract the bitrate index out of a CCK PLCP header. */ 36 + static int b43_plcp_get_bitrate_idx_cck(struct b43_plcp_hdr6 *plcp) 37 37 { 38 38 switch (plcp->raw[0]) { 39 39 case 0x0A: 40 - return B43_CCK_RATE_1MB; 40 + return 0; 41 41 case 0x14: 42 - return B43_CCK_RATE_2MB; 42 + return 1; 43 43 case 0x37: 44 - return B43_CCK_RATE_5MB; 44 + return 2; 45 45 case 0x6E: 46 - return B43_CCK_RATE_11MB; 46 + return 3; 47 47 } 48 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. */ 53 - static u8 b43_plcp_get_bitrate_ofdm(struct b43_plcp_hdr6 *plcp) 52 + /* Extract the bitrate index out of an OFDM PLCP header. */ 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 57 switch (plcp->raw[0] & 0xF) { 56 58 case 0xB: 57 - return B43_OFDM_RATE_6MB; 59 + return base + 0; 58 60 case 0xF: 59 - return B43_OFDM_RATE_9MB; 61 + return base + 1; 60 62 case 0xA: 61 - return B43_OFDM_RATE_12MB; 63 + return base + 2; 62 64 case 0xE: 63 - return B43_OFDM_RATE_18MB; 65 + return base + 3; 64 66 case 0x9: 65 - return B43_OFDM_RATE_24MB; 67 + return base + 4; 66 68 case 0xD: 67 - return B43_OFDM_RATE_36MB; 69 + return base + 5; 68 70 case 0x8: 69 - return B43_OFDM_RATE_48MB; 71 + return base + 6; 70 72 case 0xC: 71 - return B43_OFDM_RATE_54MB; 73 + return base + 7; 72 74 } 73 75 B43_WARN_ON(1); 74 - return 0; 76 + return -1; 75 77 } 76 78 77 79 u8 b43_plcp_get_ratecode_cck(const u8 bitrate) ··· 193 191 (const struct ieee80211_hdr *)fragment_data; 194 192 int use_encryption = (!(txctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)); 195 193 u16 fctl = le16_to_cpu(wlhdr->frame_control); 194 + struct ieee80211_rate *fbrate; 196 195 u8 rate, rate_fb; 197 196 int rate_ofdm, rate_fb_ofdm; 198 197 unsigned int plcp_fragment_len; ··· 203 200 204 201 memset(txhdr, 0, sizeof(*txhdr)); 205 202 206 - rate = txctl->tx_rate; 203 + WARN_ON(!txctl->tx_rate); 204 + rate = txctl->tx_rate ? txctl->tx_rate->hw_value : B43_CCK_RATE_1MB; 207 205 rate_ofdm = b43_is_ofdm_rate(rate); 208 - rate_fb = (txctl->alt_retry_rate == -1) ? rate : txctl->alt_retry_rate; 206 + fbrate = txctl->alt_retry_rate ? : txctl->tx_rate; 207 + rate_fb = fbrate->hw_value; 209 208 rate_fb_ofdm = b43_is_ofdm_rate(rate_fb); 210 209 211 210 if (rate_ofdm) ··· 226 221 * use the original dur_id field. */ 227 222 txhdr->dur_fb = wlhdr->duration_id; 228 223 } else { 229 - int fbrate_base100kbps = B43_RATE_TO_BASE100KBPS(rate_fb); 230 224 txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw, 231 225 txctl->vif, 232 226 fragment_len, 233 - fbrate_base100kbps); 227 + fbrate); 234 228 } 235 229 236 230 plcp_fragment_len = fragment_len + FCS_LEN; ··· 291 287 phy_ctl |= B43_TXH_PHY_ENC_OFDM; 292 288 else 293 289 phy_ctl |= B43_TXH_PHY_ENC_CCK; 294 - if (dev->short_preamble) 290 + if (txctl->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) 295 291 phy_ctl |= B43_TXH_PHY_SHORTPRMBL; 296 292 297 293 switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) { ··· 336 332 int rts_rate_ofdm, rts_rate_fb_ofdm; 337 333 struct b43_plcp_hdr6 *plcp; 338 334 339 - rts_rate = txctl->rts_cts_rate; 335 + WARN_ON(!txctl->rts_cts_rate); 336 + rts_rate = txctl->rts_cts_rate ? txctl->rts_cts_rate->hw_value : B43_CCK_RATE_1MB; 340 337 rts_rate_ofdm = b43_is_ofdm_rate(rts_rate); 341 338 rts_rate_fb = b43_calc_fallback_rate(rts_rate); 342 339 rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb); ··· 511 506 u16 phystat0, phystat3, chanstat, mactime; 512 507 u32 macstat; 513 508 u16 chanid; 509 + u16 phytype; 514 510 u8 jssi; 515 511 int padding; 516 512 ··· 524 518 macstat = le32_to_cpu(rxhdr->mac_status); 525 519 mactime = le16_to_cpu(rxhdr->mac_time); 526 520 chanstat = le16_to_cpu(rxhdr->channel); 521 + phytype = chanstat & B43_RX_CHAN_PHYTYPE; 527 522 528 523 if (macstat & B43_RX_MAC_FCSERR) 529 524 dev->wl->ieee_stats.dot11FCSErrorCount++; ··· 582 575 /* the next line looks wrong, but is what mac80211 wants */ 583 576 status.signal = (jssi * 100) / B43_RX_MAX_SSI; 584 577 if (phystat0 & B43_RX_PHYST0_OFDM) 585 - status.rate = b43_plcp_get_bitrate_ofdm(plcp); 578 + status.rate_idx = b43_plcp_get_bitrate_idx_ofdm(plcp, 579 + phytype == B43_PHYTYPE_A); 586 580 else 587 - status.rate = b43_plcp_get_bitrate_cck(plcp); 581 + status.rate_idx = b43_plcp_get_bitrate_idx_cck(plcp); 588 582 status.antenna = !!(phystat0 & B43_RX_PHYST0_ANT); 589 583 590 584 /* ··· 609 601 chanid = (chanstat & B43_RX_CHAN_ID) >> B43_RX_CHAN_ID_SHIFT; 610 602 switch (chanstat & B43_RX_CHAN_PHYTYPE) { 611 603 case B43_PHYTYPE_A: 612 - status.phymode = MODE_IEEE80211A; 604 + status.band = IEEE80211_BAND_5GHZ; 613 605 B43_WARN_ON(1); 614 606 /* FIXME: We don't really know which value the "chanid" contains. 615 607 * So the following assignment might be wrong. */ 616 - status.channel = chanid; 617 - status.freq = b43_channel_to_freq_5ghz(status.channel); 608 + status.freq = b43_channel_to_freq_5ghz(chanid); 618 609 break; 619 610 case B43_PHYTYPE_G: 620 - status.phymode = MODE_IEEE80211G; 611 + status.band = IEEE80211_BAND_2GHZ; 621 612 /* chanid is the radio channel cookie value as used 622 613 * to tune the radio. */ 623 614 status.freq = chanid + 2400; 624 - status.channel = b43_freq_to_channel_2ghz(status.freq); 625 615 break; 626 616 case B43_PHYTYPE_N: 627 - status.phymode = 0xDEAD /*FIXME MODE_IEEE80211N*/; 628 617 /* chanid is the SHM channel cookie. Which is the plain 629 618 * channel number in b43. */ 630 - status.channel = chanid; 631 - if (chanstat & B43_RX_CHAN_5GHZ) 632 - status.freq = b43_freq_to_channel_5ghz(status.freq); 633 - else 634 - status.freq = b43_freq_to_channel_2ghz(status.freq); 619 + if (chanstat & B43_RX_CHAN_5GHZ) { 620 + status.band = IEEE80211_BAND_5GHZ; 621 + status.freq = b43_freq_to_channel_5ghz(chanid); 622 + } else { 623 + status.band = IEEE80211_BAND_2GHZ; 624 + status.freq = b43_freq_to_channel_2ghz(chanid); 625 + } 635 626 break; 636 627 default: 637 628 B43_WARN_ON(1);
-4
drivers/net/wireless/b43legacy/b43legacy.h
··· 392 392 u8 possible_phymodes; 393 393 /* GMODE bit enabled in MACCTL? */ 394 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 396 /* Analog Type */ 401 397 u8 analog;
+69 -88
drivers/net/wireless/b43legacy/main.c
··· 95 95 * data in there. This data is the same for all devices, so we don't 96 96 * get concurrency issues */ 97 97 #define RATETAB_ENT(_rateid, _flags) \ 98 - { \ 99 - .rate = B43legacy_RATE_TO_100KBPS(_rateid), \ 100 - .val = (_rateid), \ 101 - .val2 = (_rateid), \ 102 - .flags = (_flags), \ 98 + { \ 99 + .bitrate = B43legacy_RATE_TO_100KBPS(_rateid), \ 100 + .hw_value = (_rateid), \ 101 + .flags = (_flags), \ 103 102 } 103 + /* 104 + * NOTE: When changing this, sync with xmit.c's 105 + * b43legacy_plcp_get_bitrate_idx_* functions! 106 + */ 104 107 static struct ieee80211_rate __b43legacy_ratetable[] = { 105 - RATETAB_ENT(B43legacy_CCK_RATE_1MB, IEEE80211_RATE_CCK), 106 - RATETAB_ENT(B43legacy_CCK_RATE_2MB, IEEE80211_RATE_CCK_2), 107 - RATETAB_ENT(B43legacy_CCK_RATE_5MB, IEEE80211_RATE_CCK_2), 108 - RATETAB_ENT(B43legacy_CCK_RATE_11MB, IEEE80211_RATE_CCK_2), 109 - RATETAB_ENT(B43legacy_OFDM_RATE_6MB, IEEE80211_RATE_OFDM), 110 - RATETAB_ENT(B43legacy_OFDM_RATE_9MB, IEEE80211_RATE_OFDM), 111 - RATETAB_ENT(B43legacy_OFDM_RATE_12MB, IEEE80211_RATE_OFDM), 112 - RATETAB_ENT(B43legacy_OFDM_RATE_18MB, IEEE80211_RATE_OFDM), 113 - RATETAB_ENT(B43legacy_OFDM_RATE_24MB, IEEE80211_RATE_OFDM), 114 - RATETAB_ENT(B43legacy_OFDM_RATE_36MB, IEEE80211_RATE_OFDM), 115 - RATETAB_ENT(B43legacy_OFDM_RATE_48MB, IEEE80211_RATE_OFDM), 116 - RATETAB_ENT(B43legacy_OFDM_RATE_54MB, IEEE80211_RATE_OFDM), 108 + RATETAB_ENT(B43legacy_CCK_RATE_1MB, 0), 109 + RATETAB_ENT(B43legacy_CCK_RATE_2MB, IEEE80211_RATE_SHORT_PREAMBLE), 110 + RATETAB_ENT(B43legacy_CCK_RATE_5MB, IEEE80211_RATE_SHORT_PREAMBLE), 111 + RATETAB_ENT(B43legacy_CCK_RATE_11MB, IEEE80211_RATE_SHORT_PREAMBLE), 112 + RATETAB_ENT(B43legacy_OFDM_RATE_6MB, 0), 113 + RATETAB_ENT(B43legacy_OFDM_RATE_9MB, 0), 114 + RATETAB_ENT(B43legacy_OFDM_RATE_12MB, 0), 115 + RATETAB_ENT(B43legacy_OFDM_RATE_18MB, 0), 116 + RATETAB_ENT(B43legacy_OFDM_RATE_24MB, 0), 117 + RATETAB_ENT(B43legacy_OFDM_RATE_36MB, 0), 118 + RATETAB_ENT(B43legacy_OFDM_RATE_48MB, 0), 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 121 #define b43legacy_b_ratetable (__b43legacy_ratetable + 0) 121 122 #define b43legacy_b_ratetable_size 4 122 123 #define b43legacy_g_ratetable (__b43legacy_ratetable + 0) ··· 125 124 126 125 #define CHANTAB_ENT(_chanid, _freq) \ 127 126 { \ 128 - .chan = (_chanid), \ 129 - .freq = (_freq), \ 130 - .val = (_chanid), \ 131 - .flag = IEEE80211_CHAN_W_SCAN | \ 132 - IEEE80211_CHAN_W_ACTIVE_SCAN | \ 133 - IEEE80211_CHAN_W_IBSS, \ 134 - .power_level = 0x0A, \ 135 - .antenna_max = 0xFF, \ 127 + .center_freq = (_freq), \ 128 + .hw_value = (_chanid), \ 136 129 } 137 130 static struct ieee80211_channel b43legacy_bg_chantable[] = { 138 131 CHANTAB_ENT(1, 2412), ··· 144 149 CHANTAB_ENT(13, 2472), 145 150 CHANTAB_ENT(14, 2484), 146 151 }; 147 - #define b43legacy_bg_chantable_size ARRAY_SIZE(b43legacy_bg_chantable) 152 + 153 + static struct ieee80211_supported_band b43legacy_band_2GHz_BPHY = { 154 + .channels = b43legacy_bg_chantable, 155 + .n_channels = ARRAY_SIZE(b43legacy_bg_chantable), 156 + .bitrates = b43legacy_b_ratetable, 157 + .n_bitrates = b43legacy_b_ratetable_size, 158 + }; 159 + 160 + static struct ieee80211_supported_band b43legacy_band_2GHz_GPHY = { 161 + .channels = b43legacy_bg_chantable, 162 + .n_channels = ARRAY_SIZE(b43legacy_bg_chantable), 163 + .bitrates = b43legacy_g_ratetable, 164 + .n_bitrates = b43legacy_g_ratetable_size, 165 + }; 148 166 149 167 static void b43legacy_wireless_core_exit(struct b43legacy_wldev *dev); 150 168 static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev); ··· 977 969 978 970 static void b43legacy_write_probe_resp_plcp(struct b43legacy_wldev *dev, 979 971 u16 shm_offset, u16 size, 980 - u8 rate) 972 + struct ieee80211_rate *rate) 981 973 { 982 974 struct b43legacy_plcp_hdr4 plcp; 983 975 u32 tmp; 984 976 __le16 dur; 985 977 986 978 plcp.data = 0; 987 - b43legacy_generate_plcp_hdr(&plcp, size + FCS_LEN, rate); 979 + b43legacy_generate_plcp_hdr(&plcp, size + FCS_LEN, rate->bitrate); 988 980 dur = ieee80211_generic_frame_duration(dev->wl->hw, 989 981 dev->wl->vif, 990 982 size, 991 - B43legacy_RATE_TO_100KBPS(rate)); 983 + rate); 992 984 /* Write PLCP in two parts and timing for packet transfer */ 993 985 tmp = le32_to_cpu(plcp.data); 994 986 b43legacy_shm_write16(dev, B43legacy_SHM_SHARED, shm_offset, ··· 1006 998 * 3) Stripping TIM 1007 999 */ 1008 1000 static u8 *b43legacy_generate_probe_resp(struct b43legacy_wldev *dev, 1009 - u16 *dest_size, u8 rate) 1001 + u16 *dest_size, 1002 + struct ieee80211_rate *rate) 1010 1003 { 1011 1004 const u8 *src_data; 1012 1005 u8 *dest_data; ··· 1055 1046 dur = ieee80211_generic_frame_duration(dev->wl->hw, 1056 1047 dev->wl->vif, 1057 1048 *dest_size, 1058 - B43legacy_RATE_TO_100KBPS(rate)); 1049 + rate); 1059 1050 hdr->duration_id = dur; 1060 1051 1061 1052 return dest_data; ··· 1063 1054 1064 1055 static void b43legacy_write_probe_resp_template(struct b43legacy_wldev *dev, 1065 1056 u16 ram_offset, 1066 - u16 shm_size_offset, u8 rate) 1057 + u16 shm_size_offset, 1058 + struct ieee80211_rate *rate) 1067 1059 { 1068 1060 u8 *probe_resp_data; 1069 1061 u16 size; ··· 1079 1069 * all possible basic rates 1080 1070 */ 1081 1071 b43legacy_write_probe_resp_plcp(dev, 0x31A, size, 1082 - B43legacy_CCK_RATE_1MB); 1072 + &b43legacy_b_ratetable[0]); 1083 1073 b43legacy_write_probe_resp_plcp(dev, 0x32C, size, 1084 - B43legacy_CCK_RATE_2MB); 1074 + &b43legacy_b_ratetable[1]); 1085 1075 b43legacy_write_probe_resp_plcp(dev, 0x33E, size, 1086 - B43legacy_CCK_RATE_5MB); 1076 + &b43legacy_b_ratetable[2]); 1087 1077 b43legacy_write_probe_resp_plcp(dev, 0x350, size, 1088 - B43legacy_CCK_RATE_11MB); 1078 + &b43legacy_b_ratetable[3]); 1089 1079 1090 1080 size = min((size_t)size, 1091 1081 0x200 - sizeof(struct b43legacy_plcp_hdr6)); 1092 1082 b43legacy_write_template_common(dev, probe_resp_data, 1093 1083 size, ram_offset, 1094 - shm_size_offset, rate); 1084 + shm_size_offset, rate->bitrate); 1095 1085 kfree(probe_resp_data); 1096 1086 } 1097 1087 ··· 1116 1106 b43legacy_write_beacon_template(dev, 0x468, 0x1A, 1117 1107 B43legacy_CCK_RATE_1MB); 1118 1108 b43legacy_write_probe_resp_template(dev, 0x268, 0x4A, 1119 - B43legacy_CCK_RATE_11MB); 1109 + &b43legacy_b_ratetable[0]); 1120 1110 1121 1111 status = b43legacy_read32(dev, B43legacy_MMIO_MACCMD); 1122 1112 status |= 0x03; ··· 2560 2550 antenna_rx = b43legacy_antenna_from_ieee80211(conf->antenna_sel_rx); 2561 2551 2562 2552 mutex_lock(&wl->mutex); 2553 + dev = wl->current_dev; 2554 + phy = &dev->phy; 2563 2555 2564 2556 /* Switch the PHY mode (if necessary). */ 2565 - switch (conf->phymode) { 2566 - case MODE_IEEE80211B: 2567 - new_phymode = B43legacy_PHYMODE_B; 2568 - break; 2569 - case MODE_IEEE80211G: 2570 - new_phymode = B43legacy_PHYMODE_G; 2557 + switch (conf->channel->band) { 2558 + case IEEE80211_BAND_2GHZ: 2559 + if (phy->type == B43legacy_PHYTYPE_B) 2560 + new_phymode = B43legacy_PHYMODE_B; 2561 + else 2562 + new_phymode = B43legacy_PHYMODE_G; 2571 2563 break; 2572 2564 default: 2573 2565 B43legacy_WARN_ON(1); ··· 2577 2565 err = b43legacy_switch_phymode(wl, new_phymode); 2578 2566 if (err) 2579 2567 goto out_unlock_mutex; 2580 - dev = wl->current_dev; 2581 - phy = &dev->phy; 2582 2568 2583 2569 /* Disable IRQs while reconfiguring the device. 2584 2570 * This makes it possible to drop the spinlock throughout ··· 2592 2582 2593 2583 /* Switch to the requested channel. 2594 2584 * The firmware takes care of races with the TX handler. */ 2595 - if (conf->channel_val != phy->channel) 2596 - b43legacy_radio_selectchannel(dev, conf->channel_val, 0); 2585 + if (conf->channel->hw_value != phy->channel) 2586 + b43legacy_radio_selectchannel(dev, conf->channel->hw_value, 0); 2597 2587 2598 2588 /* Enable/Disable ShortSlot timing. */ 2599 2589 if ((!!(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)) ··· 3408 3398 int have_gphy) 3409 3399 { 3410 3400 struct ieee80211_hw *hw = dev->wl->hw; 3411 - struct ieee80211_hw_mode *mode; 3412 3401 struct b43legacy_phy *phy = &dev->phy; 3413 - int cnt = 0; 3414 - int err; 3415 3402 3416 3403 phy->possible_phymodes = 0; 3417 - for (; 1; cnt++) { 3418 - if (have_bphy) { 3419 - B43legacy_WARN_ON(cnt >= B43legacy_MAX_PHYHWMODES); 3420 - mode = &phy->hwmodes[cnt]; 3404 + if (have_bphy) { 3405 + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = 3406 + &b43legacy_band_2GHz_BPHY; 3407 + phy->possible_phymodes |= B43legacy_PHYMODE_B; 3408 + } 3421 3409 3422 - mode->mode = MODE_IEEE80211B; 3423 - mode->num_channels = b43legacy_bg_chantable_size; 3424 - mode->channels = b43legacy_bg_chantable; 3425 - mode->num_rates = b43legacy_b_ratetable_size; 3426 - mode->rates = b43legacy_b_ratetable; 3427 - err = ieee80211_register_hwmode(hw, mode); 3428 - if (err) 3429 - return err; 3430 - 3431 - phy->possible_phymodes |= B43legacy_PHYMODE_B; 3432 - have_bphy = 0; 3433 - continue; 3434 - } 3435 - if (have_gphy) { 3436 - B43legacy_WARN_ON(cnt >= B43legacy_MAX_PHYHWMODES); 3437 - mode = &phy->hwmodes[cnt]; 3438 - 3439 - mode->mode = MODE_IEEE80211G; 3440 - mode->num_channels = b43legacy_bg_chantable_size; 3441 - mode->channels = b43legacy_bg_chantable; 3442 - mode->num_rates = b43legacy_g_ratetable_size; 3443 - mode->rates = b43legacy_g_ratetable; 3444 - err = ieee80211_register_hwmode(hw, mode); 3445 - if (err) 3446 - return err; 3447 - 3448 - phy->possible_phymodes |= B43legacy_PHYMODE_G; 3449 - have_gphy = 0; 3450 - continue; 3451 - } 3452 - break; 3410 + if (have_gphy) { 3411 + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = 3412 + &b43legacy_band_2GHz_GPHY; 3413 + phy->possible_phymodes |= B43legacy_PHYMODE_G; 3453 3414 } 3454 3415 3455 3416 return 0;
+31 -33
drivers/net/wireless/b43legacy/xmit.c
··· 37 37 38 38 39 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 42 switch (plcp->raw[0]) { 43 43 case 0x0A: 44 - return B43legacy_CCK_RATE_1MB; 44 + return 0; 45 45 case 0x14: 46 - return B43legacy_CCK_RATE_2MB; 46 + return 1; 47 47 case 0x37: 48 - return B43legacy_CCK_RATE_5MB; 48 + return 2; 49 49 case 0x6E: 50 - return B43legacy_CCK_RATE_11MB; 50 + return 3; 51 51 } 52 52 B43legacy_BUG_ON(1); 53 - return 0; 53 + return -1; 54 54 } 55 55 56 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 62 switch (plcp->raw[0] & 0xF) { 60 63 case 0xB: 61 - return B43legacy_OFDM_RATE_6MB; 64 + return base + 0; 62 65 case 0xF: 63 - return B43legacy_OFDM_RATE_9MB; 66 + return base + 1; 64 67 case 0xA: 65 - return B43legacy_OFDM_RATE_12MB; 68 + return base + 2; 66 69 case 0xE: 67 - return B43legacy_OFDM_RATE_18MB; 70 + return base + 3; 68 71 case 0x9: 69 - return B43legacy_OFDM_RATE_24MB; 72 + return base + 4; 70 73 case 0xD: 71 - return B43legacy_OFDM_RATE_36MB; 74 + return base + 5; 72 75 case 0x8: 73 - return B43legacy_OFDM_RATE_48MB; 76 + return base + 6; 74 77 case 0xC: 75 - return B43legacy_OFDM_RATE_54MB; 78 + return base + 7; 76 79 } 77 80 B43legacy_BUG_ON(1); 78 - return 0; 81 + return -1; 79 82 } 80 83 81 84 u8 b43legacy_plcp_get_ratecode_cck(const u8 bitrate) ··· 195 192 int use_encryption = (!(txctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)); 196 193 u16 fctl; 197 194 u8 rate; 198 - u8 rate_fb; 195 + struct ieee80211_rate *rate_fb; 199 196 int rate_ofdm; 200 197 int rate_fb_ofdm; 201 198 unsigned int plcp_fragment_len; ··· 207 204 208 205 memset(txhdr, 0, sizeof(*txhdr)); 209 206 210 - rate = txctl->tx_rate; 207 + rate = txctl->tx_rate->hw_value; 211 208 rate_ofdm = b43legacy_is_ofdm_rate(rate); 212 - rate_fb = (txctl->alt_retry_rate == -1) ? rate : txctl->alt_retry_rate; 213 - rate_fb_ofdm = b43legacy_is_ofdm_rate(rate_fb); 209 + rate_fb = txctl->alt_retry_rate ? : txctl->tx_rate; 210 + rate_fb_ofdm = b43legacy_is_ofdm_rate(rate_fb->hw_value); 214 211 215 212 txhdr->mac_frame_ctl = wlhdr->frame_control; 216 213 memcpy(txhdr->tx_receiver, wlhdr->addr1, 6); 217 214 218 215 /* Calculate duration for fallback rate */ 219 - if ((rate_fb == rate) || 216 + if ((rate_fb->hw_value == rate) || 220 217 (wlhdr->duration_id & cpu_to_le16(0x8000)) || 221 218 (wlhdr->duration_id == cpu_to_le16(0))) { 222 219 /* If the fallback rate equals the normal rate or the ··· 224 221 * use the original dur_id field. */ 225 222 txhdr->dur_fb = wlhdr->duration_id; 226 223 } else { 227 - int fbrate_base100kbps = B43legacy_RATE_TO_100KBPS(rate_fb); 228 224 txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw, 229 225 txctl->vif, 230 226 fragment_len, 231 - fbrate_base100kbps); 227 + rate_fb); 232 228 } 233 229 234 230 plcp_fragment_len = fragment_len + FCS_LEN; ··· 268 266 rate); 269 267 b43legacy_generate_plcp_hdr((struct b43legacy_plcp_hdr4 *) 270 268 (&txhdr->plcp_fb), plcp_fragment_len, 271 - rate_fb); 269 + rate_fb->hw_value); 272 270 273 271 /* PHY TX Control word */ 274 272 if (rate_ofdm) ··· 312 310 int rts_rate_ofdm; 313 311 int rts_rate_fb_ofdm; 314 312 315 - rts_rate = txctl->rts_cts_rate; 313 + rts_rate = txctl->rts_cts_rate->hw_value; 316 314 rts_rate_ofdm = b43legacy_is_ofdm_rate(rts_rate); 317 315 rts_rate_fb = b43legacy_calc_fallback_rate(rts_rate); 318 316 rts_rate_fb_ofdm = b43legacy_is_ofdm_rate(rts_rate_fb); ··· 538 536 (phystat3 & B43legacy_RX_PHYST3_TRSTATE)); 539 537 status.noise = dev->stats.link_noise; 540 538 status.signal = (jssi * 100) / B43legacy_RX_MAX_SSI; 539 + /* change to support A PHY */ 541 540 if (phystat0 & B43legacy_RX_PHYST0_OFDM) 542 - status.rate = b43legacy_plcp_get_bitrate_ofdm(plcp); 541 + status.rate_idx = b43legacy_plcp_get_bitrate_idx_ofdm(plcp, false); 543 542 else 544 - status.rate = b43legacy_plcp_get_bitrate_cck(plcp); 543 + status.rate_idx = b43legacy_plcp_get_bitrate_idx_cck(plcp); 545 544 status.antenna = !!(phystat0 & B43legacy_RX_PHYST0_ANT); 546 545 547 546 /* ··· 567 564 B43legacy_RX_CHAN_ID_SHIFT; 568 565 switch (chanstat & B43legacy_RX_CHAN_PHYTYPE) { 569 566 case B43legacy_PHYTYPE_B: 570 - status.phymode = MODE_IEEE80211B; 571 - status.freq = chanid + 2400; 572 - status.channel = b43legacy_freq_to_channel_bg(chanid + 2400); 573 - break; 574 567 case B43legacy_PHYTYPE_G: 575 - status.phymode = MODE_IEEE80211G; 568 + status.band = IEEE80211_BAND_2GHZ; 576 569 status.freq = chanid + 2400; 577 - status.channel = b43legacy_freq_to_channel_bg(chanid + 2400); 578 570 break; 579 571 default: 580 572 b43legacywarn(dev->wl, "Unexpected value for chanstat (0x%X)\n",
+40 -48
drivers/net/wireless/iwlwifi/iwl-3945-rs.c
··· 100 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 103 static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = { 112 104 {-60, IWL_RATE_54M_INDEX}, 113 105 {-64, IWL_RATE_48M_INDEX}, ··· 121 129 #define IWL_RATE_MIN_SUCCESS_TH 8 122 130 #define IWL_RATE_DECREASE_TH 1920 123 131 124 - static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, u8 mode) 132 + static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) 125 133 { 126 134 u32 index = 0; 127 135 u32 table_size = 0; ··· 130 138 if ((rssi < IWL_MIN_RSSI_VAL) || (rssi > IWL_MAX_RSSI_VAL)) 131 139 rssi = IWL_MIN_RSSI_VAL; 132 140 133 - switch (mode) { 134 - case MODE_IEEE80211G: 141 + switch (band) { 142 + case IEEE80211_BAND_2GHZ: 135 143 tpt_table = iwl3945_tpt_table_g; 136 144 table_size = ARRAY_SIZE(iwl3945_tpt_table_g); 137 145 break; 138 146 139 - case MODE_IEEE80211A: 147 + case IEEE80211_BAND_5GHZ: 140 148 tpt_table = iwl3945_tpt_table_a; 141 149 table_size = ARRAY_SIZE(iwl3945_tpt_table_a); 142 150 break; 143 151 144 152 default: 145 - case MODE_IEEE80211B: 146 - tpt_table = iwl3945_tpt_table_b; 147 - table_size = ARRAY_SIZE(iwl3945_tpt_table_b); 153 + BUG(); 148 154 break; 149 155 } 150 156 ··· 330 340 * after assoc.. */ 331 341 332 342 for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { 333 - if (sta->supp_rates & (1 << i)) { 334 - sta->txrate = i; 343 + if (sta->supp_rates[local->hw.conf.channel->band] & (1 << i)) { 344 + sta->txrate_idx = i; 335 345 break; 336 346 } 337 347 } 338 348 339 - sta->last_txrate = sta->txrate; 349 + sta->last_txrate_idx = sta->txrate_idx; 340 350 341 - /* For MODE_IEEE80211A mode it start at IWL_FIRST_OFDM_RATE */ 342 - if (local->hw.conf.phymode == MODE_IEEE80211A) 343 - sta->last_txrate += IWL_FIRST_OFDM_RATE; 351 + /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ 352 + if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) 353 + sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 344 354 345 355 IWL_DEBUG_RATE("leave\n"); 346 356 } ··· 419 429 { 420 430 int next_rate = iwl3945_get_prev_ieee_rate(rate); 421 431 422 - switch (priv->phymode) { 423 - case MODE_IEEE80211A: 432 + switch (priv->band) { 433 + case IEEE80211_BAND_5GHZ: 424 434 if (rate == IWL_RATE_12M_INDEX) 425 435 next_rate = IWL_RATE_9M_INDEX; 426 436 else if (rate == IWL_RATE_6M_INDEX) 427 437 next_rate = IWL_RATE_6M_INDEX; 428 438 break; 439 + /* XXX cannot be invoked in current mac80211 so not a regression 429 440 case MODE_IEEE80211B: 430 441 if (rate == IWL_RATE_11M_INDEX_TABLE) 431 442 next_rate = IWL_RATE_5M_INDEX_TABLE; 432 443 break; 444 + */ 433 445 default: 434 446 break; 435 447 } ··· 457 465 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; 458 466 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 459 467 struct iwl3945_rs_sta *rs_sta; 468 + struct ieee80211_supported_band *sband; 469 + 470 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 460 471 461 472 IWL_DEBUG_RATE("enter\n"); 462 473 463 474 retries = tx_resp->retry_count; 464 475 465 - first_index = tx_resp->control.tx_rate; 476 + first_index = &sband->bitrates[0] - tx_resp->control.tx_rate; 466 477 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { 467 - IWL_DEBUG_RATE("leave: Rate out of bounds: %0x for %d\n", 468 - tx_resp->control.tx_rate, first_index); 478 + IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); 469 479 return; 470 480 } 471 481 ··· 555 561 } 556 562 557 563 static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, 558 - u8 index, u16 rate_mask, int phymode) 564 + u8 index, u16 rate_mask, enum ieee80211_band band) 559 565 { 560 566 u8 high = IWL_RATE_INVALID; 561 567 u8 low = IWL_RATE_INVALID; 562 568 563 569 /* 802.11A walks to the next literal adjacent rate in 564 570 * the rate table */ 565 - if (unlikely(phymode == MODE_IEEE80211A)) { 571 + if (unlikely(band == IEEE80211_BAND_5GHZ)) { 566 572 int i; 567 573 u32 mask; 568 574 ··· 633 639 * 634 640 */ 635 641 static void rs_get_rate(void *priv_rate, struct net_device *dev, 636 - struct ieee80211_hw_mode *mode, struct sk_buff *skb, 642 + struct ieee80211_supported_band *band, 643 + struct sk_buff *skb, 637 644 struct rate_selection *sel) 638 645 { 639 646 u8 low = IWL_RATE_INVALID; ··· 667 672 is_multicast_ether_addr(hdr->addr1) || 668 673 !sta || !sta->rate_ctrl_priv) { 669 674 IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); 670 - sel->rate = rate_lowest(local, local->oper_hw_mode, sta); 675 + sel->rate = rate_lowest(local, band, sta); 671 676 if (sta) 672 677 sta_info_put(sta); 673 678 return; 674 679 } 675 680 676 - rate_mask = sta->supp_rates; 677 - index = min(sta->last_txrate & 0xffff, IWL_RATE_COUNT - 1); 681 + rate_mask = sta->supp_rates[band->band]; 682 + index = min(sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); 678 683 679 - if (priv->phymode == (u8) MODE_IEEE80211A) 684 + if (priv->band == IEEE80211_BAND_5GHZ) 680 685 rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; 681 686 682 687 rs_sta = (void *)sta->rate_ctrl_priv; ··· 727 732 current_tpt = window->average_tpt; 728 733 729 734 high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, 730 - local->hw.conf.phymode); 735 + band->band); 731 736 low = high_low & 0xff; 732 737 high = (high_low >> 8) & 0xff; 733 738 ··· 805 810 806 811 out: 807 812 808 - sta->last_txrate = index; 809 - if (priv->phymode == (u8) MODE_IEEE80211A) 810 - sta->txrate = sta->last_txrate - IWL_FIRST_OFDM_RATE; 813 + sta->last_txrate_idx = index; 814 + if (priv->band == IEEE80211_BAND_5GHZ) 815 + sta->txrate_idx = sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; 811 816 else 812 - sta->txrate = sta->last_txrate; 817 + sta->txrate_idx = sta->last_txrate_idx; 813 818 814 819 sta_info_put(sta); 815 820 ··· 940 945 spin_lock_irqsave(&rs_sta->lock, flags); 941 946 942 947 rs_sta->tgg = 0; 943 - switch (priv->phymode) { 944 - case MODE_IEEE80211G: 948 + switch (priv->band) { 949 + case IEEE80211_BAND_2GHZ: 950 + /* TODO: this always does G, not a regression */ 945 951 if (priv->active_rxon.flags & RXON_FLG_TGG_PROTECT_MSK) { 946 952 rs_sta->tgg = 1; 947 953 rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot; ··· 950 954 rs_sta->expected_tpt = iwl3945_expected_tpt_g; 951 955 break; 952 956 953 - case MODE_IEEE80211A: 957 + case IEEE80211_BAND_5GHZ: 954 958 rs_sta->expected_tpt = iwl3945_expected_tpt_a; 955 959 break; 956 - 957 - default: 958 - IWL_WARNING("Invalid phymode. Defaulting to 802.11b\n"); 959 - case MODE_IEEE80211B: 960 - rs_sta->expected_tpt = iwl3945_expected_tpt_b; 960 + case IEEE80211_NUM_BANDS: 961 + BUG(); 961 962 break; 962 963 } 963 964 ··· 967 974 968 975 IWL_DEBUG(IWL_DL_INFO | IWL_DL_RATE, "Network RSSI: %d\n", rssi); 969 976 970 - rs_sta->start_rate = 971 - iwl3945_get_rate_index_by_rssi(rssi, priv->phymode); 977 + rs_sta->start_rate = iwl3945_get_rate_index_by_rssi(rssi, priv->band); 972 978 973 979 IWL_DEBUG_RATE("leave: rssi %d assign rate index: " 974 980 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate,
+16 -19
drivers/net/wireless/iwlwifi/iwl-3945.c
··· 247 247 * the information provided in the skb from the hardware */ 248 248 s8 signal = stats->ssi; 249 249 s8 noise = 0; 250 - int rate = stats->rate; 250 + int rate = stats->rate_idx; 251 251 u64 tsf = stats->mactime; 252 252 __le16 phy_flags_hw = rx_hdr->phy_flags; 253 253 ··· 315 315 IEEE80211_CHAN_2GHZ), 316 316 &iwl3945_rt->rt_chbitmask); 317 317 318 - rate = iwl3945_rate_index_from_plcp(rate); 319 318 if (rate == -1) 320 319 iwl3945_rt->rt_rate = 0; 321 320 else ··· 386 387 struct ieee80211_rx_status stats = { 387 388 .mactime = le64_to_cpu(rx_end->timestamp), 388 389 .freq = ieee80211chan2mhz(le16_to_cpu(rx_hdr->channel)), 389 - .channel = le16_to_cpu(rx_hdr->channel), 390 - .phymode = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 391 - MODE_IEEE80211G : MODE_IEEE80211A, 390 + .band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 391 + IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ, 392 392 .antenna = 0, 393 - .rate = rx_hdr->rate, 393 + .rate_idx = iwl3945_rate_index_from_plcp(rx_hdr->rate), 394 394 .flag = 0, 395 395 }; 396 396 u8 network_packet; ··· 448 450 stats.ssi, stats.noise, stats.signal, 449 451 rx_stats_sig_avg, rx_stats_noise_diff); 450 452 451 - stats.freq = ieee80211chan2mhz(stats.channel); 452 - 453 453 /* can be covered by iwl3945_report_frame() in most cases */ 454 454 /* IWL_DEBUG_RX("RX status: 0x%08X\n", rx_end->status); */ 455 455 ··· 460 464 IWL_DEBUG_STATS 461 465 ("[%c] %d RSSI: %d Signal: %u, Noise: %u, Rate: %u\n", 462 466 network_packet ? '*' : ' ', 463 - stats.channel, stats.ssi, stats.ssi, 464 - stats.ssi, stats.rate); 467 + le16_to_cpu(rx_hdr->channel), 468 + stats.ssi, stats.ssi, 469 + stats.ssi, stats.rate_idx); 465 470 466 471 if (iwl3945_debug_level & (IWL_DL_RX)) 467 472 /* Set "1" to report good data frames in groups of 100 */ ··· 686 689 struct ieee80211_hdr *hdr, int sta_id, int tx_id) 687 690 { 688 691 unsigned long flags; 689 - u16 rate_index = min(ctrl->tx_rate & 0xffff, IWL_RATE_COUNT - 1); 692 + u16 rate_index = min(ctrl->tx_rate->hw_value & 0xffff, IWL_RATE_COUNT - 1); 690 693 u16 rate_mask; 691 694 int rate; 692 695 u8 rts_retry_limit; ··· 1549 1552 .channel = priv->active_rxon.channel, 1550 1553 }; 1551 1554 1552 - txpower.band = (priv->phymode == MODE_IEEE80211A) ? 0 : 1; 1555 + txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1; 1553 1556 ch_info = iwl3945_get_channel_info(priv, 1554 - priv->phymode, 1557 + priv->band, 1555 1558 le16_to_cpu(priv->active_rxon.channel)); 1556 1559 if (!ch_info) { 1557 1560 IWL_ERROR 1558 1561 ("Failed to get channel info for channel %d [%d]\n", 1559 - le16_to_cpu(priv->active_rxon.channel), priv->phymode); 1562 + le16_to_cpu(priv->active_rxon.channel), priv->band); 1560 1563 return -EINVAL; 1561 1564 } 1562 1565 ··· 2238 2241 table[index].next_rate_index = iwl3945_rates[prev_index].table_rs_index; 2239 2242 } 2240 2243 2241 - switch (priv->phymode) { 2242 - case MODE_IEEE80211A: 2244 + switch (priv->band) { 2245 + case IEEE80211_BAND_5GHZ: 2243 2246 IWL_DEBUG_RATE("Select A mode rate scale\n"); 2244 2247 /* If one of the following CCK rates is used, 2245 2248 * have it fall back to the 6M OFDM rate */ ··· 2254 2257 iwl3945_rates[IWL_FIRST_OFDM_RATE].table_rs_index; 2255 2258 break; 2256 2259 2257 - case MODE_IEEE80211B: 2258 - IWL_DEBUG_RATE("Select B mode rate scale\n"); 2260 + case IEEE80211_BAND_2GHZ: 2261 + IWL_DEBUG_RATE("Select B/G mode rate scale\n"); 2259 2262 /* If an OFDM rate is used, have it fall back to the 2260 2263 * 1M CCK rates */ 2261 2264 for (i = IWL_RATE_6M_INDEX_TABLE; i <= IWL_RATE_54M_INDEX_TABLE; i++) ··· 2266 2269 break; 2267 2270 2268 2271 default: 2269 - IWL_DEBUG_RATE("Select G mode rate scale\n"); 2272 + WARN_ON(1); 2270 2273 break; 2271 2274 } 2272 2275
+6 -7
drivers/net/wireless/iwlwifi/iwl-3945.h
··· 195 195 196 196 u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */ 197 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 200 /* Radio/DSP gain settings for each "normal" data Tx rate. 201 201 * These include, in addition to RF and DSP gain, a few fields for ··· 699 699 struct list_head free_frames; 700 700 int frames_count; 701 701 702 - u8 phymode; 702 + enum ieee80211_band band; 703 703 int alloc_rxb_skb; 704 704 bool add_radiotap; 705 705 706 706 void (*rx_handlers[REPLY_MAX])(struct iwl3945_priv *priv, 707 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 711 #ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT 712 712 /* spectrum measurement report caching */ ··· 937 937 938 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 943 static inline u8 is_channel_bg_band(const struct iwl3945_channel_info *ch_info) 944 944 { 945 - return ((ch_info->phymode == MODE_IEEE80211B) || 946 - (ch_info->phymode == MODE_IEEE80211G)); 945 + return ch_info->band == IEEE80211_BAND_2GHZ; 947 946 } 948 947 949 948 static inline int is_channel_passive(const struct iwl3945_channel_info *ch) ··· 966 967 } 967 968 968 969 extern const struct iwl3945_channel_info *iwl3945_get_channel_info( 969 - const struct iwl3945_priv *priv, int phymode, u16 channel); 970 + const struct iwl3945_priv *priv, enum ieee80211_band band, u16 channel); 970 971 971 972 /* Requires full declaration of iwl3945_priv before including */ 972 973 #include "iwl-3945-io.h"
+43 -39
drivers/net/wireless/iwlwifi/iwl-4965-rs.c
··· 139 139 u8 valid_antenna; 140 140 u8 is_green; 141 141 u8 is_dup; 142 - u8 phymode; 142 + enum ieee80211_band band; 143 143 u8 ibss_sta_added; 144 144 145 145 /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */ ··· 563 563 * fill "search" or "active" tx mode table. 564 564 */ 565 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 568 int *rate_idx) 568 569 { 569 570 int index; ··· 589 588 tbl->lq_type = LQ_NONE; 590 589 else { 591 590 592 - if (phymode == MODE_IEEE80211A) 591 + if (band == IEEE80211_BAND_5GHZ) 593 592 tbl->lq_type = LQ_A; 594 593 else 595 594 tbl->lq_type = LQ_G; ··· 767 766 if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_index)) { 768 767 switch_to_legacy = 1; 769 768 scale_index = rs_ht_to_legacy[scale_index]; 770 - if (lq_sta->phymode == MODE_IEEE80211A) 769 + if (lq_sta->band == IEEE80211_BAND_5GHZ) 771 770 tbl->lq_type = LQ_A; 772 771 else 773 772 tbl->lq_type = LQ_G; ··· 785 784 /* Mask with station rate restriction */ 786 785 if (is_legacy(tbl->lq_type)) { 787 786 /* supp_rates has no CCK bits in A mode */ 788 - if (lq_sta->phymode == (u8) MODE_IEEE80211A) 787 + if (lq_sta->band == IEEE80211_BAND_5GHZ) 789 788 rate_mask = (u16)(rate_mask & 790 789 (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); 791 790 else ··· 884 883 search_win = (struct iwl4965_rate_scale_data *) 885 884 &(search_tbl->win[0]); 886 885 887 - tx_mcs.rate_n_flags = tx_resp->control.tx_rate; 886 + tx_mcs.rate_n_flags = tx_resp->control.tx_rate->hw_value; 888 887 889 - rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, 888 + rs_get_tbl_info_from_mcs(&tx_mcs, priv->band, 890 889 &tbl_type, &rs_index); 891 890 if ((rs_index < 0) || (rs_index >= IWL_RATE_COUNT)) { 892 891 IWL_DEBUG_RATE("bad rate index at: %d rate 0x%X\n", ··· 919 918 * Each tx attempt steps one entry deeper in the rate table. */ 920 919 tx_mcs.rate_n_flags = 921 920 le32_to_cpu(table->rs_table[index].rate_n_flags); 922 - rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, 921 + rs_get_tbl_info_from_mcs(&tx_mcs, priv->band, 923 922 &tbl_type, &rs_index); 924 923 925 924 /* If type matches "search" table, ··· 960 959 * else look up the rate that was, finally, successful. 961 960 */ 962 961 if (!tx_resp->retry_count) 963 - tx_mcs.rate_n_flags = tx_resp->control.tx_rate; 962 + tx_mcs.rate_n_flags = tx_resp->control.tx_rate->hw_value; 964 963 else 965 964 tx_mcs.rate_n_flags = 966 965 le32_to_cpu(table->rs_table[index].rate_n_flags); 967 966 968 - rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, 967 + rs_get_tbl_info_from_mcs(&tx_mcs, priv->band, 969 968 &tbl_type, &rs_index); 970 969 971 970 /* Update frame history window with "success" if Tx got ACKed ... */ ··· 1802 1801 is_green = lq_sta->is_green; 1803 1802 1804 1803 /* current tx rate */ 1805 - index = sta->last_txrate; 1804 + index = sta->last_txrate_idx; 1806 1805 1807 1806 IWL_DEBUG_RATE("Rate scale index %d for type %d\n", index, 1808 1807 tbl->lq_type); ··· 1815 1814 1816 1815 /* mask with station rate restriction */ 1817 1816 if (is_legacy(tbl->lq_type)) { 1818 - if (lq_sta->phymode == (u8) MODE_IEEE80211A) 1817 + if (lq_sta->band == IEEE80211_BAND_5GHZ) 1819 1818 /* supp_rates has no CCK bits in A mode */ 1820 1819 rate_scale_index_msk = (u16) (rate_mask & 1821 1820 (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); ··· 2135 2134 out: 2136 2135 rs_mcs_from_tbl(&tbl->current_rate, tbl, index, is_green); 2137 2136 i = index; 2138 - sta->last_txrate = i; 2137 + sta->last_txrate_idx = i; 2139 2138 2140 - /* sta->txrate is an index to A mode rates which start 2139 + /* sta->txrate_idx is an index to A mode rates which start 2141 2140 * at IWL_FIRST_OFDM_RATE 2142 2141 */ 2143 - if (lq_sta->phymode == (u8) MODE_IEEE80211A) 2144 - sta->txrate = i - IWL_FIRST_OFDM_RATE; 2142 + if (lq_sta->band == IEEE80211_BAND_5GHZ) 2143 + sta->txrate_idx = i - IWL_FIRST_OFDM_RATE; 2145 2144 else 2146 - sta->txrate = i; 2145 + sta->txrate_idx = i; 2147 2146 2148 2147 return; 2149 2148 } ··· 2165 2164 goto out; 2166 2165 2167 2166 lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; 2168 - i = sta->last_txrate; 2167 + i = sta->last_txrate_idx; 2169 2168 2170 2169 if ((lq_sta->lq.sta_id == 0xff) && 2171 2170 (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) ··· 2189 2188 mcs_rate.rate_n_flags |= RATE_MCS_CCK_MSK; 2190 2189 2191 2190 tbl->antenna_type = ANT_AUX; 2192 - rs_get_tbl_info_from_mcs(&mcs_rate, priv->phymode, tbl, &rate_idx); 2191 + rs_get_tbl_info_from_mcs(&mcs_rate, priv->band, tbl, &rate_idx); 2193 2192 if (!rs_is_ant_connected(priv->valid_antenna, tbl->antenna_type)) 2194 2193 rs_toggle_antenna(&mcs_rate, tbl); 2195 2194 ··· 2203 2202 } 2204 2203 2205 2204 static void rs_get_rate(void *priv_rate, struct net_device *dev, 2206 - struct ieee80211_hw_mode *mode, struct sk_buff *skb, 2205 + struct ieee80211_supported_band *sband, 2206 + struct sk_buff *skb, 2207 2207 struct rate_selection *sel) 2208 2208 { 2209 2209 ··· 2226 2224 fc = le16_to_cpu(hdr->frame_control); 2227 2225 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || 2228 2226 !sta || !sta->rate_ctrl_priv) { 2229 - sel->rate = rate_lowest(local, local->oper_hw_mode, sta); 2227 + sel->rate = rate_lowest(local, sband, sta); 2230 2228 if (sta) 2231 2229 sta_info_put(sta); 2232 2230 return; 2233 2231 } 2234 2232 2235 2233 lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; 2236 - i = sta->last_txrate; 2234 + i = sta->last_txrate_idx; 2237 2235 2238 2236 if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && 2239 2237 !lq_sta->ibss_sta_added) { ··· 2258 2256 2259 2257 done: 2260 2258 if ((i < 0) || (i > IWL_RATE_COUNT)) { 2261 - sel->rate = rate_lowest(local, local->oper_hw_mode, sta); 2259 + sel->rate = rate_lowest(local, sband, sta); 2262 2260 return; 2263 2261 } 2264 2262 sta_info_put(sta); ··· 2293 2291 { 2294 2292 int i, j; 2295 2293 struct ieee80211_conf *conf = &local->hw.conf; 2296 - struct ieee80211_hw_mode *mode = local->oper_hw_mode; 2294 + struct ieee80211_supported_band *sband; 2297 2295 struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; 2298 2296 struct iwl4965_lq_sta *lq_sta = priv_sta; 2299 2297 2298 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 2299 + 2300 2300 lq_sta->flush_timer = 0; 2301 - lq_sta->supp_rates = sta->supp_rates; 2302 - sta->txrate = 3; 2301 + lq_sta->supp_rates = sta->supp_rates[sband->band]; 2302 + sta->txrate_idx = 3; 2303 2303 for (j = 0; j < LQ_SIZE; j++) 2304 2304 for (i = 0; i < IWL_RATE_COUNT; i++) 2305 2305 rs_rate_scale_clear_window(&(lq_sta->lq_info[j].win[i])); ··· 2336 2332 } 2337 2333 2338 2334 /* Find highest tx rate supported by hardware and destination station */ 2339 - for (i = 0; i < mode->num_rates; i++) { 2340 - if ((sta->supp_rates & BIT(i)) && 2341 - (mode->rates[i].flags & IEEE80211_RATE_SUPPORTED)) 2342 - sta->txrate = i; 2343 - } 2344 - sta->last_txrate = sta->txrate; 2335 + for (i = 0; i < sband->n_bitrates; i++) 2336 + if (sta->supp_rates[sband->band] & BIT(i)) 2337 + sta->txrate_idx = i; 2338 + 2339 + sta->last_txrate_idx = sta->txrate_idx; 2340 + /* WTF is with this bogus comment? A doesn't have cck rates */ 2345 2341 /* For MODE_IEEE80211A, cck rates are at end of rate table */ 2346 - if (local->hw.conf.phymode == MODE_IEEE80211A) 2347 - sta->last_txrate += IWL_FIRST_OFDM_RATE; 2342 + if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) 2343 + sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 2348 2344 2349 2345 lq_sta->is_dup = 0; 2350 2346 lq_sta->valid_antenna = priv->valid_antenna; ··· 2353 2349 lq_sta->active_rate = priv->active_rate; 2354 2350 lq_sta->active_rate &= ~(0x1000); 2355 2351 lq_sta->active_rate_basic = priv->active_rate_basic; 2356 - lq_sta->phymode = priv->phymode; 2352 + lq_sta->band = priv->band; 2357 2353 #ifdef CONFIG_IWL4965_HT 2358 2354 /* 2359 2355 * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), ··· 2405 2401 rs_dbgfs_set_mcs(lq_sta, tx_mcs, index); 2406 2402 2407 2403 /* Interpret rate_n_flags */ 2408 - rs_get_tbl_info_from_mcs(tx_mcs, lq_sta->phymode, 2404 + rs_get_tbl_info_from_mcs(tx_mcs, lq_sta->band, 2409 2405 &tbl_type, &rate_idx); 2410 2406 2411 2407 /* How many times should we repeat the initial rate? */ ··· 2459 2455 index++; 2460 2456 } 2461 2457 2462 - rs_get_tbl_info_from_mcs(&new_rate, lq_sta->phymode, &tbl_type, 2458 + rs_get_tbl_info_from_mcs(&new_rate, lq_sta->band, &tbl_type, 2463 2459 &rate_idx); 2464 2460 2465 2461 /* Indicate to uCode which entries might be MIMO. ··· 2546 2542 { 2547 2543 u32 base_rate; 2548 2544 2549 - if (lq_sta->phymode == (u8) MODE_IEEE80211A) 2545 + if (lq_sta->band == IEEE80211_BAND_5GHZ) 2550 2546 base_rate = 0x800D; 2551 2547 else 2552 2548 base_rate = 0x820A; ··· 2806 2802 2807 2803 cnt += sprintf(&buf[cnt], "\nrate scale type %d antenna %d " 2808 2804 "active_search %d rate index %d\n", lq_type, antenna, 2809 - lq_sta->search_better_tbl, sta->last_txrate); 2805 + lq_sta->search_better_tbl, sta->last_txrate_idx); 2810 2806 2811 2807 sta_info_put(sta); 2812 2808 return cnt;
+21 -22
drivers/net/wireless/iwlwifi/iwl-4965.c
··· 339 339 * 340 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 344 const struct iwl4965_eeprom_channel *eeprom_ch, 344 345 u8 fat_extension_channel) 345 346 { 346 347 struct iwl4965_channel_info *ch_info; 347 348 348 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 352 if (!is_channel_valid(ch_info)) 352 353 return -1; ··· 1940 1939 } 1941 1940 1942 1941 static const struct iwl4965_channel_info * 1943 - iwl4965_get_channel_txpower_info(struct iwl4965_priv *priv, u8 phymode, u16 channel) 1942 + iwl4965_get_channel_txpower_info(struct iwl4965_priv *priv, 1943 + enum ieee80211_band band, u16 channel) 1944 1944 { 1945 1945 const struct iwl4965_channel_info *ch_info; 1946 1946 1947 - ch_info = iwl4965_get_channel_info(priv, phymode, channel); 1947 + ch_info = iwl4965_get_channel_info(priv, band, channel); 1948 1948 1949 1949 if (!is_channel_valid(ch_info)) 1950 1950 return NULL; ··· 2394 2392 2395 2393 /* Get current (RXON) channel, band, width */ 2396 2394 ch_info = 2397 - iwl4965_get_channel_txpower_info(priv, priv->phymode, channel); 2395 + iwl4965_get_channel_txpower_info(priv, priv->band, channel); 2398 2396 2399 2397 IWL_DEBUG_TXPOWER("chan %d band %d is_fat %d\n", channel, band, 2400 2398 is_fat); ··· 2621 2619 return -EAGAIN; 2622 2620 } 2623 2621 2624 - band = ((priv->phymode == MODE_IEEE80211B) || 2625 - (priv->phymode == MODE_IEEE80211G)); 2622 + band = priv->band == IEEE80211_BAND_2GHZ; 2626 2623 2627 2624 is_fat = is_fat_channel(priv->active_rxon.flags); 2628 2625 ··· 2651 2650 struct iwl4965_channel_switch_cmd cmd = { 0 }; 2652 2651 const struct iwl4965_channel_info *ch_info; 2653 2652 2654 - band = ((priv->phymode == MODE_IEEE80211B) || 2655 - (priv->phymode == MODE_IEEE80211G)); 2653 + band = priv->band == IEEE80211_BAND_2GHZ; 2656 2654 2657 - ch_info = iwl4965_get_channel_info(priv, priv->phymode, channel); 2655 + ch_info = iwl4965_get_channel_info(priv, priv->band, channel); 2658 2656 2659 2657 is_fat = is_fat_channel(priv->staging_rxon.flags); 2660 2658 ··· 2698 2698 u16 fc = le16_to_cpu(hdr->frame_control); 2699 2699 u8 rate_plcp; 2700 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 2703 rate_plcp = iwl4965_rates[rate_idx].plcp; 2704 2704 ··· 3178 3178 { 3179 3179 s8 signal = stats->ssi; 3180 3180 s8 noise = 0; 3181 - int rate = stats->rate; 3181 + int rate = stats->rate_idx; 3182 3182 u64 tsf = stats->mactime; 3183 3183 __le16 phy_flags_hw = rx_start->phy_flags; 3184 3184 struct iwl4965_rt_rx_hdr { ··· 3246 3246 IEEE80211_CHAN_2GHZ), 3247 3247 &iwl4965_rt->rt_chbitmask); 3248 3248 3249 - rate = iwl4965_rate_index_from_plcp(rate); 3250 3249 if (rate == -1) 3251 3250 iwl4965_rt->rt_rate = 0; 3252 3251 else ··· 3541 3542 u16 fc; 3542 3543 struct ieee80211_rx_status stats = { 3543 3544 .mactime = le64_to_cpu(rx_start->timestamp), 3544 - .channel = le16_to_cpu(rx_start->channel), 3545 - .phymode = 3545 + .freq = ieee80211chan2mhz(le16_to_cpu(rx_start->channel)), 3546 + .band = 3546 3547 (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 3547 - MODE_IEEE80211G : MODE_IEEE80211A, 3548 + IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ, 3548 3549 .antenna = 0, 3549 - .rate = iwl4965_hw_get_rate(rx_start->rate_n_flags), 3550 + .rate_idx = iwl4965_hw_get_rate( 3551 + le32_to_cpu(rx_start->rate_n_flags)), 3550 3552 .flag = 0, 3551 3553 }; 3552 3554 u8 network_packet; ··· 3597 3597 } 3598 3598 3599 3599 priv->ucode_beacon_time = le32_to_cpu(rx_start->beacon_time_stamp); 3600 - 3601 - stats.freq = ieee80211chan2mhz(stats.channel); 3602 3600 3603 3601 /* Find max signal strength (dBm) among 3 antenna/receiver chains */ 3604 3602 stats.ssi = iwl4965_calc_rssi(rx_start); ··· 4183 4185 * all the way down to 1M in IEEE order, and then spin on 1M */ 4184 4186 if (is_ap) 4185 4187 r = IWL_RATE_54M_INDEX; 4186 - else if (priv->phymode == MODE_IEEE80211A) 4188 + else if (priv->band == IEEE80211_BAND_5GHZ) 4187 4189 r = IWL_RATE_6M_INDEX; 4188 4190 else 4189 4191 r = IWL_RATE_1M_INDEX; ··· 4216 4218 4217 4219 #ifdef CONFIG_IWL4965_HT 4218 4220 4219 - static u8 iwl4965_is_channel_extension(struct iwl4965_priv *priv, int phymode, 4221 + static u8 iwl4965_is_channel_extension(struct iwl4965_priv *priv, 4222 + enum ieee80211_band band, 4220 4223 u16 channel, u8 extension_chan_offset) 4221 4224 { 4222 4225 const struct iwl4965_channel_info *ch_info; 4223 4226 4224 - ch_info = iwl4965_get_channel_info(priv, phymode, channel); 4227 + ch_info = iwl4965_get_channel_info(priv, band, channel); 4225 4228 if (!is_channel_valid(ch_info)) 4226 4229 return 0; 4227 4230
+8 -8
drivers/net/wireless/iwlwifi/iwl-4965.h
··· 206 206 207 207 u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */ 208 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 211 /* Radio/DSP gain settings for each "normal" data Tx rate. 212 212 * These include, in addition to RF and DSP gain, a few fields for ··· 764 764 extern void iwl4965_chain_noise_reset(struct iwl4965_priv *priv); 765 765 extern void iwl4965_init_sensitivity(struct iwl4965_priv *priv, u8 flags, 766 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 769 u16 channel, 769 770 const struct iwl4965_eeprom_channel *eeprom_ch, 770 771 u8 fat_extension_channel); ··· 978 977 struct list_head free_frames; 979 978 int frames_count; 980 979 981 - u8 phymode; 980 + enum ieee80211_band band; 982 981 int alloc_rxb_skb; 983 982 bool add_radiotap; 984 983 985 984 void (*rx_handlers[REPLY_MAX])(struct iwl4965_priv *priv, 986 985 struct iwl4965_rx_mem_buffer *rxb); 987 986 988 - const struct ieee80211_hw_mode *modes; 987 + struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; 989 988 990 989 #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT 991 990 /* spectrum measurement report caching */ ··· 1244 1243 1245 1244 static inline u8 is_channel_a_band(const struct iwl4965_channel_info *ch_info) 1246 1245 { 1247 - return ch_info->phymode == MODE_IEEE80211A; 1246 + return ch_info->band == IEEE80211_BAND_5GHZ; 1248 1247 } 1249 1248 1250 1249 static inline u8 is_channel_bg_band(const struct iwl4965_channel_info *ch_info) 1251 1250 { 1252 - return ((ch_info->phymode == MODE_IEEE80211B) || 1253 - (ch_info->phymode == MODE_IEEE80211G)); 1251 + return ch_info->band == IEEE80211_BAND_2GHZ; 1254 1252 } 1255 1253 1256 1254 static inline int is_channel_passive(const struct iwl4965_channel_info *ch) ··· 1263 1263 } 1264 1264 1265 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 1268 /* Requires full declaration of iwl4965_priv before including */ 1269 1269 #include "iwl-4965-io.h"
+122 -319
drivers/net/wireless/iwlwifi/iwl3945-base.c
··· 116 116 return NULL; 117 117 } 118 118 119 - static const struct ieee80211_hw_mode *iwl3945_get_hw_mode( 120 - struct iwl3945_priv *priv, int mode) 119 + static const struct ieee80211_supported_band *iwl3945_get_band( 120 + struct iwl3945_priv *priv, enum ieee80211_band band) 121 121 { 122 - int i; 123 - 124 - for (i = 0; i < 3; i++) 125 - if (priv->modes[i].mode == mode) 126 - return &priv->modes[i]; 127 - 128 - return NULL; 122 + return priv->hw->wiphy->bands[band]; 129 123 } 130 124 131 125 static int iwl3945_is_empty_essid(const char *essid, int essid_len) ··· 541 547 station->sta.sta.sta_id = index; 542 548 station->sta.station_flags = 0; 543 549 544 - if (priv->phymode == MODE_IEEE80211A) 550 + if (priv->band == IEEE80211_BAND_5GHZ) 545 551 rate = IWL_RATE_6M_PLCP; 546 552 else 547 553 rate = IWL_RATE_1M_PLCP; ··· 888 894 889 895 /** 890 896 * iwl3945_set_rxon_channel - Set the phymode and channel values in staging RXON 891 - * @phymode: MODE_IEEE80211A sets to 5.2GHz; all else set to 2.4GHz 892 - * @channel: Any channel valid for the requested phymode 897 + * @band: 2.4 or 5 GHz band 898 + * @channel: Any channel valid for the requested band 893 899 894 - * In addition to setting the staging RXON, priv->phymode is also set. 900 + * In addition to setting the staging RXON, priv->band is also set. 895 901 * 896 902 * NOTE: Does not commit to the hardware; it sets appropriate bit fields 897 - * in the staging RXON flag structure based on the phymode 903 + * in the staging RXON flag structure based on the band 898 904 */ 899 - static int iwl3945_set_rxon_channel(struct iwl3945_priv *priv, u8 phymode, u16 channel) 905 + static int iwl3945_set_rxon_channel(struct iwl3945_priv *priv, 906 + enum ieee80211_band band, 907 + u16 channel) 900 908 { 901 - if (!iwl3945_get_channel_info(priv, phymode, channel)) { 909 + if (!iwl3945_get_channel_info(priv, band, channel)) { 902 910 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", 903 - channel, phymode); 911 + channel, band); 904 912 return -EINVAL; 905 913 } 906 914 907 915 if ((le16_to_cpu(priv->staging_rxon.channel) == channel) && 908 - (priv->phymode == phymode)) 916 + (priv->band == band)) 909 917 return 0; 910 918 911 919 priv->staging_rxon.channel = cpu_to_le16(channel); 912 - if (phymode == MODE_IEEE80211A) 920 + if (band == IEEE80211_BAND_5GHZ) 913 921 priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK; 914 922 else 915 923 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; 916 924 917 - priv->phymode = phymode; 925 + priv->band = band; 918 926 919 - IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, phymode); 927 + IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band); 920 928 921 929 return 0; 922 930 } ··· 1206 1210 return -EIO; 1207 1211 } 1208 1212 1209 - /* Init the hardware's rate fallback order based on the 1210 - * phymode */ 1213 + /* Init the hardware's rate fallback order based on the band */ 1211 1214 rc = iwl3945_init_hw_rate_table(priv); 1212 1215 if (rc) { 1213 1216 IWL_ERROR("Error setting HW rate table: %02X\n", rc); ··· 2456 2461 return 0; 2457 2462 } 2458 2463 2459 - static void iwl3945_set_flags_for_phymode(struct iwl3945_priv *priv, u8 phymode) 2464 + static void iwl3945_set_flags_for_phymode(struct iwl3945_priv *priv, 2465 + enum ieee80211_band band) 2460 2466 { 2461 - if (phymode == MODE_IEEE80211A) { 2467 + if (band == IEEE80211_BAND_5GHZ) { 2462 2468 priv->staging_rxon.flags &= 2463 2469 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK 2464 2470 | RXON_FLG_CCK_MSK); ··· 2522 2526 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 2523 2527 #endif 2524 2528 2525 - ch_info = iwl3945_get_channel_info(priv, priv->phymode, 2529 + ch_info = iwl3945_get_channel_info(priv, priv->band, 2526 2530 le16_to_cpu(priv->staging_rxon.channel)); 2527 2531 2528 2532 if (!ch_info) ··· 2538 2542 2539 2543 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); 2540 2544 if (is_channel_a_band(ch_info)) 2541 - priv->phymode = MODE_IEEE80211A; 2545 + priv->band = IEEE80211_BAND_5GHZ; 2542 2546 else 2543 - priv->phymode = MODE_IEEE80211G; 2547 + priv->band = IEEE80211_BAND_2GHZ; 2544 2548 2545 - iwl3945_set_flags_for_phymode(priv, priv->phymode); 2549 + iwl3945_set_flags_for_phymode(priv, priv->band); 2546 2550 2547 2551 priv->staging_rxon.ofdm_basic_rates = 2548 2552 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; ··· 2556 2560 const struct iwl3945_channel_info *ch_info; 2557 2561 2558 2562 ch_info = iwl3945_get_channel_info(priv, 2559 - priv->phymode, 2563 + priv->band, 2560 2564 le16_to_cpu(priv->staging_rxon.channel)); 2561 2565 2562 2566 if (!ch_info || !is_channel_ibss(ch_info)) { ··· 2788 2792 goto drop_unlock; 2789 2793 } 2790 2794 2791 - if ((ctl->tx_rate & 0xFF) == IWL_INVALID_RATE) { 2795 + if ((ctl->tx_rate->hw_value & 0xFF) == IWL_INVALID_RATE) { 2792 2796 IWL_ERROR("ERROR: No TX rate available.\n"); 2793 2797 goto drop_unlock; 2794 2798 } ··· 2988 2992 2989 2993 static void iwl3945_set_rate(struct iwl3945_priv *priv) 2990 2994 { 2991 - const struct ieee80211_hw_mode *hw = NULL; 2995 + const struct ieee80211_supported_band *sband = NULL; 2992 2996 struct ieee80211_rate *rate; 2993 2997 int i; 2994 2998 2995 - hw = iwl3945_get_hw_mode(priv, priv->phymode); 2996 - if (!hw) { 2999 + sband = iwl3945_get_band(priv, priv->band); 3000 + if (!sband) { 2997 3001 IWL_ERROR("Failed to set rate: unable to get hw mode\n"); 2998 3002 return; 2999 3003 } ··· 3001 3005 priv->active_rate = 0; 3002 3006 priv->active_rate_basic = 0; 3003 3007 3004 - IWL_DEBUG_RATE("Setting rates for 802.11%c\n", 3005 - hw->mode == MODE_IEEE80211A ? 3006 - 'a' : ((hw->mode == MODE_IEEE80211B) ? 'b' : 'g')); 3008 + IWL_DEBUG_RATE("Setting rates for %s GHz\n", 3009 + sband->band == IEEE80211_BAND_2GHZ ? "2.4" : "5"); 3007 3010 3008 - for (i = 0; i < hw->num_rates; i++) { 3009 - rate = &(hw->rates[i]); 3010 - if ((rate->val < IWL_RATE_COUNT) && 3011 - (rate->flags & IEEE80211_RATE_SUPPORTED)) { 3012 - IWL_DEBUG_RATE("Adding rate index %d (plcp %d)%s\n", 3013 - rate->val, iwl3945_rates[rate->val].plcp, 3014 - (rate->flags & IEEE80211_RATE_BASIC) ? 3015 - "*" : ""); 3016 - priv->active_rate |= (1 << rate->val); 3017 - if (rate->flags & IEEE80211_RATE_BASIC) 3018 - priv->active_rate_basic |= (1 << rate->val); 3019 - } else 3020 - IWL_DEBUG_RATE("Not adding rate %d (plcp %d)\n", 3021 - rate->val, iwl3945_rates[rate->val].plcp); 3011 + for (i = 0; i < sband->n_bitrates; i++) { 3012 + rate = &sband->bitrates[i]; 3013 + if ((rate->hw_value < IWL_RATE_COUNT) && 3014 + !(rate->flags & IEEE80211_CHAN_DISABLED)) { 3015 + IWL_DEBUG_RATE("Adding rate index %d (plcp %d)\n", 3016 + rate->hw_value, iwl3945_rates[rate->hw_value].plcp); 3017 + priv->active_rate |= (1 << rate->hw_value); 3018 + } 3022 3019 } 3023 3020 3024 3021 IWL_DEBUG_RATE("Set active_rate = %0x, active_rate_basic = %0x\n", ··· 3424 3435 3425 3436 tx_status->flags = 3426 3437 iwl3945_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0; 3427 - 3428 - tx_status->control.tx_rate = iwl3945_rate_index_from_plcp(tx_resp->rate); 3429 3438 3430 3439 IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", 3431 3440 txq_id, iwl3945_get_tx_fail_reason(status), status, ··· 5013 5026 * Based on band and channel number. 5014 5027 */ 5015 5028 const struct iwl3945_channel_info *iwl3945_get_channel_info(const struct iwl3945_priv *priv, 5016 - int phymode, u16 channel) 5029 + enum ieee80211_band band, u16 channel) 5017 5030 { 5018 5031 int i; 5019 5032 5020 - switch (phymode) { 5021 - case MODE_IEEE80211A: 5033 + switch (band) { 5034 + case IEEE80211_BAND_5GHZ: 5022 5035 for (i = 14; i < priv->channel_count; i++) { 5023 5036 if (priv->channel_info[i].channel == channel) 5024 5037 return &priv->channel_info[i]; 5025 5038 } 5026 5039 break; 5027 5040 5028 - case MODE_IEEE80211B: 5029 - case MODE_IEEE80211G: 5041 + case IEEE80211_BAND_2GHZ: 5030 5042 if (channel >= 1 && channel <= 14) 5031 5043 return &priv->channel_info[channel - 1]; 5032 5044 break; 5033 - 5045 + case IEEE80211_NUM_BANDS: 5046 + WARN_ON(1); 5034 5047 } 5035 5048 5036 5049 return NULL; ··· 5093 5106 /* Loop through each band adding each of the channels */ 5094 5107 for (ch = 0; ch < eeprom_ch_count; ch++) { 5095 5108 ch_info->channel = eeprom_ch_index[ch]; 5096 - ch_info->phymode = (band == 1) ? MODE_IEEE80211B : 5097 - MODE_IEEE80211A; 5109 + ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : 5110 + IEEE80211_BAND_5GHZ; 5098 5111 5099 5112 /* permanently store EEPROM's channel regulatory flags 5100 5113 * and max power in channel info database. */ ··· 5190 5203 #define IWL_PASSIVE_DWELL_BASE (100) 5191 5204 #define IWL_CHANNEL_TUNE_TIME 5 5192 5205 5193 - static inline u16 iwl3945_get_active_dwell_time(struct iwl3945_priv *priv, int phymode) 5206 + static inline u16 iwl3945_get_active_dwell_time(struct iwl3945_priv *priv, 5207 + enum ieee80211_band band) 5194 5208 { 5195 - if (phymode == MODE_IEEE80211A) 5209 + if (band == IEEE80211_BAND_5GHZ) 5196 5210 return IWL_ACTIVE_DWELL_TIME_52; 5197 5211 else 5198 5212 return IWL_ACTIVE_DWELL_TIME_24; 5199 5213 } 5200 5214 5201 - static u16 iwl3945_get_passive_dwell_time(struct iwl3945_priv *priv, int phymode) 5215 + static u16 iwl3945_get_passive_dwell_time(struct iwl3945_priv *priv, 5216 + enum ieee80211_band band) 5202 5217 { 5203 - u16 active = iwl3945_get_active_dwell_time(priv, phymode); 5204 - u16 passive = (phymode != MODE_IEEE80211A) ? 5218 + u16 active = iwl3945_get_active_dwell_time(priv, band); 5219 + u16 passive = (band == IEEE80211_BAND_2GHZ) ? 5205 5220 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : 5206 5221 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; 5207 5222 ··· 5223 5234 return passive; 5224 5235 } 5225 5236 5226 - static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, int phymode, 5237 + static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, 5238 + enum ieee80211_band band, 5227 5239 u8 is_active, u8 direct_mask, 5228 5240 struct iwl3945_scan_channel *scan_ch) 5229 5241 { 5230 5242 const struct ieee80211_channel *channels = NULL; 5231 - const struct ieee80211_hw_mode *hw_mode; 5243 + const struct ieee80211_supported_band *sband; 5232 5244 const struct iwl3945_channel_info *ch_info; 5233 5245 u16 passive_dwell = 0; 5234 5246 u16 active_dwell = 0; 5235 5247 int added, i; 5236 5248 5237 - hw_mode = iwl3945_get_hw_mode(priv, phymode); 5238 - if (!hw_mode) 5249 + sband = iwl3945_get_band(priv, band); 5250 + if (!sband) 5239 5251 return 0; 5240 5252 5241 - channels = hw_mode->channels; 5253 + channels = sband->channels; 5242 5254 5243 - active_dwell = iwl3945_get_active_dwell_time(priv, phymode); 5244 - passive_dwell = iwl3945_get_passive_dwell_time(priv, phymode); 5255 + active_dwell = iwl3945_get_active_dwell_time(priv, band); 5256 + passive_dwell = iwl3945_get_passive_dwell_time(priv, band); 5245 5257 5246 - for (i = 0, added = 0; i < hw_mode->num_channels; i++) { 5247 - if (channels[i].chan == 5258 + for (i = 0, added = 0; i < sband->n_channels; i++) { 5259 + if (channels[i].hw_value == 5248 5260 le16_to_cpu(priv->active_rxon.channel)) { 5249 5261 if (iwl3945_is_associated(priv)) { 5250 5262 IWL_DEBUG_SCAN ··· 5256 5266 } else if (priv->only_active_channel) 5257 5267 continue; 5258 5268 5259 - scan_ch->channel = channels[i].chan; 5269 + scan_ch->channel = channels[i].hw_value; 5260 5270 5261 - ch_info = iwl3945_get_channel_info(priv, phymode, scan_ch->channel); 5271 + ch_info = iwl3945_get_channel_info(priv, band, scan_ch->channel); 5262 5272 if (!is_channel_valid(ch_info)) { 5263 5273 IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", 5264 5274 scan_ch->channel); ··· 5266 5276 } 5267 5277 5268 5278 if (!is_active || is_channel_passive(ch_info) || 5269 - !(channels[i].flag & IEEE80211_CHAN_W_ACTIVE_SCAN)) 5279 + (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) 5270 5280 scan_ch->type = 0; /* passive */ 5271 5281 else 5272 5282 scan_ch->type = 1; /* active */ ··· 5285 5295 /* scan_pwr_info->tpc.dsp_atten; */ 5286 5296 5287 5297 /*scan_pwr_info->tpc.tx_gain; */ 5288 - if (phymode == MODE_IEEE80211A) 5298 + if (band == IEEE80211_BAND_5GHZ) 5289 5299 scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; 5290 5300 else { 5291 5301 scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); ··· 5309 5319 return added; 5310 5320 } 5311 5321 5312 - static void iwl3945_reset_channel_flag(struct iwl3945_priv *priv) 5313 - { 5314 - int i, j; 5315 - for (i = 0; i < 3; i++) { 5316 - struct ieee80211_hw_mode *hw_mode = (void *)&priv->modes[i]; 5317 - for (j = 0; j < hw_mode->num_channels; j++) 5318 - hw_mode->channels[j].flag = hw_mode->channels[j].val; 5319 - } 5320 - } 5321 - 5322 5322 static void iwl3945_init_hw_rates(struct iwl3945_priv *priv, 5323 5323 struct ieee80211_rate *rates) 5324 5324 { 5325 5325 int i; 5326 5326 5327 5327 for (i = 0; i < IWL_RATE_COUNT; i++) { 5328 - rates[i].rate = iwl3945_rates[i].ieee * 5; 5329 - rates[i].val = i; /* Rate scaling will work on indexes */ 5330 - rates[i].val2 = i; 5331 - rates[i].flags = IEEE80211_RATE_SUPPORTED; 5332 - /* Only OFDM have the bits-per-symbol set */ 5333 - if ((i <= IWL_LAST_OFDM_RATE) && (i >= IWL_FIRST_OFDM_RATE)) 5334 - rates[i].flags |= IEEE80211_RATE_OFDM; 5335 - else { 5328 + rates[i].bitrate = iwl3945_rates[i].ieee * 5; 5329 + rates[i].hw_value = i; /* Rate scaling will work on indexes */ 5330 + rates[i].hw_value_short = i; 5331 + rates[i].flags = 0; 5332 + if ((i > IWL_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) { 5336 5333 /* 5337 - * If CCK 1M then set rate flag to CCK else CCK_2 5338 - * which is CCK | PREAMBLE2 5334 + * If CCK != 1M then set short preamble rate flag. 5339 5335 */ 5340 5336 rates[i].flags |= (iwl3945_rates[i].plcp == 10) ? 5341 - IEEE80211_RATE_CCK : IEEE80211_RATE_CCK_2; 5337 + 0 : IEEE80211_RATE_SHORT_PREAMBLE; 5342 5338 } 5343 - 5344 - /* Set up which ones are basic rates... */ 5345 - if (IWL_BASIC_RATES_MASK & (1 << i)) 5346 - rates[i].flags |= IEEE80211_RATE_BASIC; 5347 5339 } 5348 5340 } 5349 5341 ··· 5335 5363 static int iwl3945_init_geos(struct iwl3945_priv *priv) 5336 5364 { 5337 5365 struct iwl3945_channel_info *ch; 5338 - struct ieee80211_hw_mode *modes; 5366 + struct ieee80211_supported_band *band; 5339 5367 struct ieee80211_channel *channels; 5340 5368 struct ieee80211_channel *geo_ch; 5341 5369 struct ieee80211_rate *rates; 5342 5370 int i = 0; 5343 - enum { 5344 - A = 0, 5345 - B = 1, 5346 - G = 2, 5347 - }; 5348 - int mode_count = 3; 5349 5371 5350 - if (priv->modes) { 5372 + if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || 5373 + priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { 5351 5374 IWL_DEBUG_INFO("Geography modes already initialized.\n"); 5352 5375 set_bit(STATUS_GEO_CONFIGURED, &priv->status); 5353 5376 return 0; 5354 5377 } 5355 5378 5356 - modes = kzalloc(sizeof(struct ieee80211_hw_mode) * mode_count, 5357 - GFP_KERNEL); 5358 - if (!modes) 5359 - return -ENOMEM; 5360 - 5361 5379 channels = kzalloc(sizeof(struct ieee80211_channel) * 5362 5380 priv->channel_count, GFP_KERNEL); 5363 - if (!channels) { 5364 - kfree(modes); 5381 + if (!channels) 5365 5382 return -ENOMEM; 5366 - } 5367 5383 5368 5384 rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_MAX_RATES + 1)), 5369 5385 GFP_KERNEL); 5370 5386 if (!rates) { 5371 - kfree(modes); 5372 5387 kfree(channels); 5373 5388 return -ENOMEM; 5374 5389 } 5375 5390 5376 - /* 0 = 802.11a 5377 - * 1 = 802.11b 5378 - * 2 = 802.11g 5379 - */ 5380 - 5381 5391 /* 5.2GHz channels start after the 2.4GHz channels */ 5382 - modes[A].mode = MODE_IEEE80211A; 5383 - modes[A].channels = &channels[ARRAY_SIZE(iwl3945_eeprom_band_1)]; 5384 - modes[A].rates = &rates[4]; 5385 - modes[A].num_rates = 8; /* just OFDM */ 5386 - modes[A].num_channels = 0; 5392 + band = &priv->bands[IEEE80211_BAND_5GHZ]; 5393 + band->channels = &channels[ARRAY_SIZE(iwl3945_eeprom_band_1)]; 5394 + band->bitrates = &rates[4]; 5395 + band->n_bitrates = 8; /* just OFDM */ 5387 5396 5388 - modes[B].mode = MODE_IEEE80211B; 5389 - modes[B].channels = channels; 5390 - modes[B].rates = rates; 5391 - modes[B].num_rates = 4; /* just CCK */ 5392 - modes[B].num_channels = 0; 5393 - 5394 - modes[G].mode = MODE_IEEE80211G; 5395 - modes[G].channels = channels; 5396 - modes[G].rates = rates; 5397 - modes[G].num_rates = 12; /* OFDM & CCK */ 5398 - modes[G].num_channels = 0; 5397 + band = &priv->bands[IEEE80211_BAND_2GHZ]; 5398 + band->channels = channels; 5399 + band->bitrates = rates; 5400 + band->n_bitrates = 12; /* OFDM & CCK */ 5399 5401 5400 5402 priv->ieee_channels = channels; 5401 5403 priv->ieee_rates = rates; ··· 5388 5442 } 5389 5443 5390 5444 if (is_channel_a_band(ch)) 5391 - geo_ch = &modes[A].channels[modes[A].num_channels++]; 5392 - else { 5393 - geo_ch = &modes[B].channels[modes[B].num_channels++]; 5394 - modes[G].num_channels++; 5395 - } 5445 + geo_ch = &priv->bands[IEEE80211_BAND_5GHZ].channels[priv->bands[IEEE80211_BAND_5GHZ].n_channels++]; 5446 + else 5447 + geo_ch = &priv->bands[IEEE80211_BAND_2GHZ].channels[priv->bands[IEEE80211_BAND_2GHZ].n_channels++]; 5396 5448 5397 - geo_ch->freq = ieee80211chan2mhz(ch->channel); 5398 - geo_ch->chan = ch->channel; 5399 - geo_ch->power_level = ch->max_power_avg; 5400 - geo_ch->antenna_max = 0xff; 5449 + geo_ch->center_freq = ieee80211chan2mhz(ch->channel); 5450 + geo_ch->max_power = ch->max_power_avg; 5451 + geo_ch->max_antenna_gain = 0xff; 5401 5452 5402 5453 if (is_channel_valid(ch)) { 5403 - geo_ch->flag = IEEE80211_CHAN_W_SCAN; 5404 - if (ch->flags & EEPROM_CHANNEL_IBSS) 5405 - geo_ch->flag |= IEEE80211_CHAN_W_IBSS; 5454 + if (!(ch->flags & EEPROM_CHANNEL_IBSS)) 5455 + geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; 5406 5456 5407 - if (ch->flags & EEPROM_CHANNEL_ACTIVE) 5408 - geo_ch->flag |= IEEE80211_CHAN_W_ACTIVE_SCAN; 5457 + if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) 5458 + geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; 5409 5459 5410 5460 if (ch->flags & EEPROM_CHANNEL_RADAR) 5411 - geo_ch->flag |= IEEE80211_CHAN_W_RADAR_DETECT; 5461 + geo_ch->flags |= IEEE80211_CHAN_RADAR; 5412 5462 5413 5463 if (ch->max_power_avg > priv->max_channel_txpower_limit) 5414 5464 priv->max_channel_txpower_limit = 5415 5465 ch->max_power_avg; 5416 - } 5417 - 5418 - geo_ch->val = geo_ch->flag; 5466 + } else 5467 + geo_ch->flags |= IEEE80211_CHAN_DISABLED; 5419 5468 } 5420 5469 5421 - if ((modes[A].num_channels == 0) && priv->is_abg) { 5470 + if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && priv->is_abg) { 5422 5471 printk(KERN_INFO DRV_NAME 5423 5472 ": Incorrectly detected BG card as ABG. Please send " 5424 5473 "your PCI ID 0x%04X:0x%04X to maintainer.\n", ··· 5423 5482 5424 5483 printk(KERN_INFO DRV_NAME 5425 5484 ": Tunable channels: %d 802.11bg, %d 802.11a channels\n", 5426 - modes[G].num_channels, modes[A].num_channels); 5485 + priv->bands[IEEE80211_BAND_2GHZ].n_channels, 5486 + priv->bands[IEEE80211_BAND_5GHZ].n_channels); 5427 5487 5428 - /* 5429 - * NOTE: We register these in preference of order -- the 5430 - * stack doesn't currently (as of 7.0.6 / Apr 24 '07) pick 5431 - * a phymode based on rates or AP capabilities but seems to 5432 - * configure it purely on if the channel being configured 5433 - * is supported by a mode -- and the first match is taken 5434 - */ 5488 + priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->bands[IEEE80211_BAND_2GHZ]; 5489 + priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->bands[IEEE80211_BAND_5GHZ]; 5435 5490 5436 - if (modes[G].num_channels) 5437 - ieee80211_register_hwmode(priv->hw, &modes[G]); 5438 - if (modes[B].num_channels) 5439 - ieee80211_register_hwmode(priv->hw, &modes[B]); 5440 - if (modes[A].num_channels) 5441 - ieee80211_register_hwmode(priv->hw, &modes[A]); 5442 - 5443 - priv->modes = modes; 5444 5491 set_bit(STATUS_GEO_CONFIGURED, &priv->status); 5445 5492 5446 5493 return 0; ··· 5439 5510 */ 5440 5511 static void iwl3945_free_geos(struct iwl3945_priv *priv) 5441 5512 { 5442 - kfree(priv->modes); 5443 5513 kfree(priv->ieee_channels); 5444 5514 kfree(priv->ieee_rates); 5445 5515 clear_bit(STATUS_GEO_CONFIGURED, &priv->status); ··· 6447 6519 struct iwl3945_scan_cmd *scan; 6448 6520 struct ieee80211_conf *conf = NULL; 6449 6521 u8 direct_mask; 6450 - int phymode; 6522 + enum ieee80211_band band; 6451 6523 6452 6524 conf = ieee80211_get_hw_conf(priv->hw); 6453 6525 ··· 6579 6651 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; 6580 6652 scan->tx_cmd.rate = IWL_RATE_1M_PLCP; 6581 6653 scan->good_CRC_th = 0; 6582 - phymode = MODE_IEEE80211G; 6654 + band = IEEE80211_BAND_2GHZ; 6583 6655 break; 6584 6656 6585 6657 case 1: 6586 6658 scan->tx_cmd.rate = IWL_RATE_6M_PLCP; 6587 6659 scan->good_CRC_th = IWL_GOOD_CRC_TH; 6588 - phymode = MODE_IEEE80211A; 6660 + band = IEEE80211_BAND_5GHZ; 6589 6661 break; 6590 6662 6591 6663 default: ··· 6608 6680 6609 6681 scan->channel_count = 6610 6682 iwl3945_get_channels_for_scan( 6611 - priv, phymode, 1, /* active */ 6683 + priv, band, 1, /* active */ 6612 6684 direct_mask, 6613 6685 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 6614 6686 ··· 6753 6825 iwl3945_add_station(priv, iwl3945_broadcast_addr, 0, 0); 6754 6826 iwl3945_add_station(priv, priv->bssid, 0, 0); 6755 6827 iwl3945_sync_sta(priv, IWL_STA_ID, 6756 - (priv->phymode == MODE_IEEE80211A)? 6828 + (priv->band == IEEE80211_BAND_5GHZ) ? 6757 6829 IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP, 6758 6830 CMD_ASYNC); 6759 6831 iwl3945_rate_scale_init(priv->hw, IWL_STA_ID); ··· 6948 7020 } 6949 7021 6950 7022 IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 6951 - ctl->tx_rate); 7023 + ctl->tx_rate->bitrate); 6952 7024 6953 7025 if (iwl3945_tx_skb(priv, skb, ctl)) 6954 7026 dev_kfree_skb_any(skb); ··· 7007 7079 int ret = 0; 7008 7080 7009 7081 mutex_lock(&priv->mutex); 7010 - IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel); 7082 + IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); 7011 7083 7012 7084 priv->add_radiotap = !!(conf->flags & IEEE80211_CONF_RADIOTAP); 7013 7085 ··· 7027 7099 7028 7100 spin_lock_irqsave(&priv->lock, flags); 7029 7101 7030 - ch_info = iwl3945_get_channel_info(priv, conf->phymode, conf->channel); 7102 + ch_info = iwl3945_get_channel_info(priv, conf->channel->band, 7103 + conf->channel->hw_value); 7031 7104 if (!is_channel_valid(ch_info)) { 7032 7105 IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this SKU.\n", 7033 - conf->channel, conf->phymode); 7106 + conf->channel->hw_value, conf->channel->band); 7034 7107 IWL_DEBUG_MAC80211("leave - invalid channel\n"); 7035 7108 spin_unlock_irqrestore(&priv->lock, flags); 7036 7109 ret = -EINVAL; 7037 7110 goto out; 7038 7111 } 7039 7112 7040 - iwl3945_set_rxon_channel(priv, conf->phymode, conf->channel); 7113 + iwl3945_set_rxon_channel(priv, conf->channel->band, conf->channel->hw_value); 7041 7114 7042 - iwl3945_set_flags_for_phymode(priv, conf->phymode); 7115 + iwl3945_set_flags_for_phymode(priv, conf->channel->band); 7043 7116 7044 7117 /* The list of supported rates and rate mask can be different 7045 7118 * for each phymode; since the phymode may have changed, reset ··· 7821 7892 static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags, 7822 7893 store_filter_flags); 7823 7894 7824 - static ssize_t show_tune(struct device *d, 7825 - struct device_attribute *attr, char *buf) 7826 - { 7827 - struct iwl3945_priv *priv = (struct iwl3945_priv *)d->driver_data; 7828 - 7829 - return sprintf(buf, "0x%04X\n", 7830 - (priv->phymode << 8) | 7831 - le16_to_cpu(priv->active_rxon.channel)); 7832 - } 7833 - 7834 - static void iwl3945_set_flags_for_phymode(struct iwl3945_priv *priv, u8 phymode); 7835 - 7836 - static ssize_t store_tune(struct device *d, 7837 - struct device_attribute *attr, 7838 - const char *buf, size_t count) 7839 - { 7840 - struct iwl3945_priv *priv = (struct iwl3945_priv *)d->driver_data; 7841 - char *p = (char *)buf; 7842 - u16 tune = simple_strtoul(p, &p, 0); 7843 - u8 phymode = (tune >> 8) & 0xff; 7844 - u16 channel = tune & 0xff; 7845 - 7846 - IWL_DEBUG_INFO("Tune request to:%d channel:%d\n", phymode, channel); 7847 - 7848 - mutex_lock(&priv->mutex); 7849 - if ((le16_to_cpu(priv->staging_rxon.channel) != channel) || 7850 - (priv->phymode != phymode)) { 7851 - const struct iwl3945_channel_info *ch_info; 7852 - 7853 - ch_info = iwl3945_get_channel_info(priv, phymode, channel); 7854 - if (!ch_info) { 7855 - IWL_WARNING("Requested invalid phymode/channel " 7856 - "combination: %d %d\n", phymode, channel); 7857 - mutex_unlock(&priv->mutex); 7858 - return -EINVAL; 7859 - } 7860 - 7861 - /* Cancel any currently running scans... */ 7862 - if (iwl3945_scan_cancel_timeout(priv, 100)) 7863 - IWL_WARNING("Could not cancel scan.\n"); 7864 - else { 7865 - IWL_DEBUG_INFO("Committing phymode and " 7866 - "rxon.channel = %d %d\n", 7867 - phymode, channel); 7868 - 7869 - iwl3945_set_rxon_channel(priv, phymode, channel); 7870 - iwl3945_set_flags_for_phymode(priv, phymode); 7871 - 7872 - iwl3945_set_rate(priv); 7873 - iwl3945_commit_rxon(priv); 7874 - } 7875 - } 7876 - mutex_unlock(&priv->mutex); 7877 - 7878 - return count; 7879 - } 7880 - 7881 - static DEVICE_ATTR(tune, S_IWUSR | S_IRUGO, show_tune, store_tune); 7882 - 7883 7895 #ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT 7884 7896 7885 7897 static ssize_t show_measurement(struct device *d, ··· 8035 8165 static ssize_t show_channels(struct device *d, 8036 8166 struct device_attribute *attr, char *buf) 8037 8167 { 8038 - struct iwl3945_priv *priv = dev_get_drvdata(d); 8039 - int len = 0, i; 8040 - struct ieee80211_channel *channels = NULL; 8041 - const struct ieee80211_hw_mode *hw_mode = NULL; 8042 - int count = 0; 8043 - 8044 - if (!iwl3945_is_ready(priv)) 8045 - return -EAGAIN; 8046 - 8047 - hw_mode = iwl3945_get_hw_mode(priv, MODE_IEEE80211G); 8048 - if (!hw_mode) 8049 - hw_mode = iwl3945_get_hw_mode(priv, MODE_IEEE80211B); 8050 - if (hw_mode) { 8051 - channels = hw_mode->channels; 8052 - count = hw_mode->num_channels; 8053 - } 8054 - 8055 - len += 8056 - sprintf(&buf[len], 8057 - "Displaying %d channels in 2.4GHz band " 8058 - "(802.11bg):\n", count); 8059 - 8060 - for (i = 0; i < count; i++) 8061 - len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n", 8062 - channels[i].chan, 8063 - channels[i].power_level, 8064 - channels[i]. 8065 - flag & IEEE80211_CHAN_W_RADAR_DETECT ? 8066 - " (IEEE 802.11h required)" : "", 8067 - (!(channels[i].flag & IEEE80211_CHAN_W_IBSS) 8068 - || (channels[i]. 8069 - flag & 8070 - IEEE80211_CHAN_W_RADAR_DETECT)) ? "" : 8071 - ", IBSS", 8072 - channels[i]. 8073 - flag & IEEE80211_CHAN_W_ACTIVE_SCAN ? 8074 - "active/passive" : "passive only"); 8075 - 8076 - hw_mode = iwl3945_get_hw_mode(priv, MODE_IEEE80211A); 8077 - if (hw_mode) { 8078 - channels = hw_mode->channels; 8079 - count = hw_mode->num_channels; 8080 - } else { 8081 - channels = NULL; 8082 - count = 0; 8083 - } 8084 - 8085 - len += sprintf(&buf[len], "Displaying %d channels in 5.2GHz band " 8086 - "(802.11a):\n", count); 8087 - 8088 - for (i = 0; i < count; i++) 8089 - len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n", 8090 - channels[i].chan, 8091 - channels[i].power_level, 8092 - channels[i]. 8093 - flag & IEEE80211_CHAN_W_RADAR_DETECT ? 8094 - " (IEEE 802.11h required)" : "", 8095 - (!(channels[i].flag & IEEE80211_CHAN_W_IBSS) 8096 - || (channels[i]. 8097 - flag & 8098 - IEEE80211_CHAN_W_RADAR_DETECT)) ? "" : 8099 - ", IBSS", 8100 - channels[i]. 8101 - flag & IEEE80211_CHAN_W_ACTIVE_SCAN ? 8102 - "active/passive" : "passive only"); 8103 - 8104 - return len; 8168 + /* all this shit doesn't belong into sysfs anyway */ 8169 + return 0; 8105 8170 } 8106 8171 8107 8172 static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL); ··· 8216 8411 &dev_attr_statistics.attr, 8217 8412 &dev_attr_status.attr, 8218 8413 &dev_attr_temperature.attr, 8219 - &dev_attr_tune.attr, 8220 8414 &dev_attr_tx_power.attr, 8221 8415 8222 8416 NULL ··· 8336 8532 priv->data_retry_limit = -1; 8337 8533 priv->ieee_channels = NULL; 8338 8534 priv->ieee_rates = NULL; 8339 - priv->phymode = -1; 8535 + priv->band = IEEE80211_BAND_2GHZ; 8340 8536 8341 8537 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 8342 8538 if (!err) ··· 8418 8614 priv->qos_data.qos_cap.val = 0; 8419 8615 #endif /* CONFIG_IWL3945_QOS */ 8420 8616 8421 - iwl3945_set_rxon_channel(priv, MODE_IEEE80211G, 6); 8617 + iwl3945_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); 8422 8618 iwl3945_setup_deferred_work(priv); 8423 8619 iwl3945_setup_rx_handlers(priv); 8424 8620 ··· 8469 8665 IWL_ERROR("initializing geos failed: %d\n", err); 8470 8666 goto out_free_channel_map; 8471 8667 } 8472 - iwl3945_reset_channel_flag(priv); 8473 8668 8474 8669 iwl3945_rate_control_register(priv->hw); 8475 8670 err = ieee80211_register_hw(priv->hw);
+113 -325
drivers/net/wireless/iwlwifi/iwl4965-base.c
··· 115 115 return NULL; 116 116 } 117 117 118 - static const struct ieee80211_hw_mode *iwl4965_get_hw_mode( 119 - struct iwl4965_priv *priv, int mode) 118 + static const struct ieee80211_supported_band *iwl4965_get_hw_mode( 119 + struct iwl4965_priv *priv, enum ieee80211_band band) 120 120 { 121 - int i; 122 - 123 - for (i = 0; i < 3; i++) 124 - if (priv->modes[i].mode == mode) 125 - return &priv->modes[i]; 126 - 127 - return NULL; 121 + return priv->hw->wiphy->bands[band]; 128 122 } 129 123 130 124 static int iwl4965_is_empty_essid(const char *essid, int essid_len) ··· 931 937 * NOTE: Does not commit to the hardware; it sets appropriate bit fields 932 938 * in the staging RXON flag structure based on the phymode 933 939 */ 934 - static int iwl4965_set_rxon_channel(struct iwl4965_priv *priv, u8 phymode, 940 + static int iwl4965_set_rxon_channel(struct iwl4965_priv *priv, 941 + enum ieee80211_band band, 935 942 u16 channel) 936 943 { 937 - if (!iwl4965_get_channel_info(priv, phymode, channel)) { 944 + if (!iwl4965_get_channel_info(priv, band, channel)) { 938 945 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", 939 - channel, phymode); 946 + channel, band); 940 947 return -EINVAL; 941 948 } 942 949 943 950 if ((le16_to_cpu(priv->staging_rxon.channel) == channel) && 944 - (priv->phymode == phymode)) 951 + (priv->band == band)) 945 952 return 0; 946 953 947 954 priv->staging_rxon.channel = cpu_to_le16(channel); 948 - if (phymode == MODE_IEEE80211A) 955 + if (band == IEEE80211_BAND_5GHZ) 949 956 priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK; 950 957 else 951 958 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; 952 959 953 - priv->phymode = phymode; 960 + priv->band = band; 954 961 955 - IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, phymode); 962 + IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band); 956 963 957 964 return 0; 958 965 } ··· 2566 2571 return 0; 2567 2572 } 2568 2573 2569 - static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv, u8 phymode) 2574 + static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv, 2575 + enum ieee80211_band band) 2570 2576 { 2571 - if (phymode == MODE_IEEE80211A) { 2577 + if (band == IEEE80211_BAND_5GHZ) { 2572 2578 priv->staging_rxon.flags &= 2573 2579 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK 2574 2580 | RXON_FLG_CCK_MSK); ··· 2632 2636 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 2633 2637 #endif 2634 2638 2635 - ch_info = iwl4965_get_channel_info(priv, priv->phymode, 2639 + ch_info = iwl4965_get_channel_info(priv, priv->band, 2636 2640 le16_to_cpu(priv->staging_rxon.channel)); 2637 2641 2638 2642 if (!ch_info) ··· 2647 2651 ch_info = &priv->channel_info[0]; 2648 2652 2649 2653 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); 2650 - if (is_channel_a_band(ch_info)) 2651 - priv->phymode = MODE_IEEE80211A; 2652 - else 2653 - priv->phymode = MODE_IEEE80211G; 2654 + priv->band = ch_info->band; 2654 2655 2655 - iwl4965_set_flags_for_phymode(priv, priv->phymode); 2656 + iwl4965_set_flags_for_phymode(priv, priv->band); 2656 2657 2657 2658 priv->staging_rxon.ofdm_basic_rates = 2658 2659 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; ··· 2671 2678 const struct iwl4965_channel_info *ch_info; 2672 2679 2673 2680 ch_info = iwl4965_get_channel_info(priv, 2674 - priv->phymode, 2681 + priv->band, 2675 2682 le16_to_cpu(priv->staging_rxon.channel)); 2676 2683 2677 2684 if (!ch_info || !is_channel_ibss(ch_info)) { ··· 2911 2918 goto drop_unlock; 2912 2919 } 2913 2920 2914 - if ((ctl->tx_rate & 0xFF) == IWL_INVALID_RATE) { 2921 + if ((ctl->tx_rate->hw_value & 0xFF) == IWL_INVALID_RATE) { 2915 2922 IWL_ERROR("ERROR: No TX rate available.\n"); 2916 2923 goto drop_unlock; 2917 2924 } ··· 3118 3125 3119 3126 static void iwl4965_set_rate(struct iwl4965_priv *priv) 3120 3127 { 3121 - const struct ieee80211_hw_mode *hw = NULL; 3128 + const struct ieee80211_supported_band *hw = NULL; 3122 3129 struct ieee80211_rate *rate; 3123 3130 int i; 3124 3131 3125 - hw = iwl4965_get_hw_mode(priv, priv->phymode); 3132 + hw = iwl4965_get_hw_mode(priv, priv->band); 3126 3133 if (!hw) { 3127 3134 IWL_ERROR("Failed to set rate: unable to get hw mode\n"); 3128 3135 return; ··· 3131 3138 priv->active_rate = 0; 3132 3139 priv->active_rate_basic = 0; 3133 3140 3134 - IWL_DEBUG_RATE("Setting rates for 802.11%c\n", 3135 - hw->mode == MODE_IEEE80211A ? 3136 - 'a' : ((hw->mode == MODE_IEEE80211B) ? 'b' : 'g')); 3137 - 3138 - for (i = 0; i < hw->num_rates; i++) { 3139 - rate = &(hw->rates[i]); 3140 - if ((rate->val < IWL_RATE_COUNT) && 3141 - (rate->flags & IEEE80211_RATE_SUPPORTED)) { 3142 - IWL_DEBUG_RATE("Adding rate index %d (plcp %d)%s\n", 3143 - rate->val, iwl4965_rates[rate->val].plcp, 3144 - (rate->flags & IEEE80211_RATE_BASIC) ? 3145 - "*" : ""); 3146 - priv->active_rate |= (1 << rate->val); 3147 - if (rate->flags & IEEE80211_RATE_BASIC) 3148 - priv->active_rate_basic |= (1 << rate->val); 3149 - } else 3150 - IWL_DEBUG_RATE("Not adding rate %d (plcp %d)\n", 3151 - rate->val, iwl4965_rates[rate->val].plcp); 3141 + for (i = 0; i < hw->n_bitrates; i++) { 3142 + rate = &(hw->bitrates[i]); 3143 + if (rate->hw_value < IWL_RATE_COUNT) 3144 + priv->active_rate |= (1 << rate->hw_value); 3152 3145 } 3153 3146 3154 3147 IWL_DEBUG_RATE("Set active_rate = %0x, active_rate_basic = %0x\n", ··· 3753 3774 3754 3775 tx_status->flags = 3755 3776 iwl4965_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0; 3756 - 3757 - tx_status->control.tx_rate = 3758 - iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags); 3759 3777 3760 3778 IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " 3761 3779 "retries %d\n", txq_id, iwl4965_get_tx_fail_reason(status), ··· 5395 5419 * Based on band and channel number. 5396 5420 */ 5397 5421 const struct iwl4965_channel_info *iwl4965_get_channel_info(const struct iwl4965_priv *priv, 5398 - int phymode, u16 channel) 5422 + enum ieee80211_band band, u16 channel) 5399 5423 { 5400 5424 int i; 5401 5425 5402 - switch (phymode) { 5403 - case MODE_IEEE80211A: 5426 + switch (band) { 5427 + case IEEE80211_BAND_5GHZ: 5404 5428 for (i = 14; i < priv->channel_count; i++) { 5405 5429 if (priv->channel_info[i].channel == channel) 5406 5430 return &priv->channel_info[i]; 5407 5431 } 5408 5432 break; 5409 - 5410 - case MODE_IEEE80211B: 5411 - case MODE_IEEE80211G: 5433 + case IEEE80211_BAND_2GHZ: 5412 5434 if (channel >= 1 && channel <= 14) 5413 5435 return &priv->channel_info[channel - 1]; 5414 5436 break; 5415 - 5437 + default: 5438 + BUG(); 5416 5439 } 5417 5440 5418 5441 return NULL; ··· 5474 5499 /* Loop through each band adding each of the channels */ 5475 5500 for (ch = 0; ch < eeprom_ch_count; ch++) { 5476 5501 ch_info->channel = eeprom_ch_index[ch]; 5477 - ch_info->phymode = (band == 1) ? MODE_IEEE80211B : 5478 - MODE_IEEE80211A; 5502 + ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : 5503 + IEEE80211_BAND_5GHZ; 5479 5504 5480 5505 /* permanently store EEPROM's channel regulatory flags 5481 5506 * and max power in channel info database. */ ··· 5534 5559 5535 5560 /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */ 5536 5561 for (band = 6; band <= 7; band++) { 5537 - int phymode; 5562 + enum ieee80211_band ieeeband; 5538 5563 u8 fat_extension_chan; 5539 5564 5540 5565 iwl4965_init_band_reference(priv, band, &eeprom_ch_count, 5541 5566 &eeprom_ch_info, &eeprom_ch_index); 5542 5567 5543 5568 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ 5544 - phymode = (band == 6) ? MODE_IEEE80211B : MODE_IEEE80211A; 5569 + ieeeband = (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 5545 5570 5546 5571 /* Loop through each band adding each of the channels */ 5547 5572 for (ch = 0; ch < eeprom_ch_count; ch++) { ··· 5555 5580 fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE; 5556 5581 5557 5582 /* Set up driver's info for lower half */ 5558 - iwl4965_set_fat_chan_info(priv, phymode, 5583 + iwl4965_set_fat_chan_info(priv, ieeeband, 5559 5584 eeprom_ch_index[ch], 5560 5585 &(eeprom_ch_info[ch]), 5561 5586 fat_extension_chan); 5562 5587 5563 5588 /* Set up driver's info for upper half */ 5564 - iwl4965_set_fat_chan_info(priv, phymode, 5589 + iwl4965_set_fat_chan_info(priv, ieeeband, 5565 5590 (eeprom_ch_index[ch] + 4), 5566 5591 &(eeprom_ch_info[ch]), 5567 5592 HT_IE_EXT_CHANNEL_BELOW); ··· 5603 5628 #define IWL_PASSIVE_DWELL_BASE (100) 5604 5629 #define IWL_CHANNEL_TUNE_TIME 5 5605 5630 5606 - static inline u16 iwl4965_get_active_dwell_time(struct iwl4965_priv *priv, int phymode) 5631 + static inline u16 iwl4965_get_active_dwell_time(struct iwl4965_priv *priv, 5632 + enum ieee80211_band band) 5607 5633 { 5608 - if (phymode == MODE_IEEE80211A) 5634 + if (band == IEEE80211_BAND_5GHZ) 5609 5635 return IWL_ACTIVE_DWELL_TIME_52; 5610 5636 else 5611 5637 return IWL_ACTIVE_DWELL_TIME_24; 5612 5638 } 5613 5639 5614 - static u16 iwl4965_get_passive_dwell_time(struct iwl4965_priv *priv, int phymode) 5640 + static u16 iwl4965_get_passive_dwell_time(struct iwl4965_priv *priv, 5641 + enum ieee80211_band band) 5615 5642 { 5616 - u16 active = iwl4965_get_active_dwell_time(priv, phymode); 5617 - u16 passive = (phymode != MODE_IEEE80211A) ? 5643 + u16 active = iwl4965_get_active_dwell_time(priv, band); 5644 + u16 passive = (band != IEEE80211_BAND_5GHZ) ? 5618 5645 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : 5619 5646 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; 5620 5647 ··· 5636 5659 return passive; 5637 5660 } 5638 5661 5639 - static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode, 5662 + static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, 5663 + enum ieee80211_band band, 5640 5664 u8 is_active, u8 direct_mask, 5641 5665 struct iwl4965_scan_channel *scan_ch) 5642 5666 { 5643 5667 const struct ieee80211_channel *channels = NULL; 5644 - const struct ieee80211_hw_mode *hw_mode; 5668 + const struct ieee80211_supported_band *sband; 5645 5669 const struct iwl4965_channel_info *ch_info; 5646 5670 u16 passive_dwell = 0; 5647 5671 u16 active_dwell = 0; 5648 5672 int added, i; 5649 5673 5650 - hw_mode = iwl4965_get_hw_mode(priv, phymode); 5651 - if (!hw_mode) 5674 + sband = iwl4965_get_hw_mode(priv, band); 5675 + if (!sband) 5652 5676 return 0; 5653 5677 5654 - channels = hw_mode->channels; 5678 + channels = sband->channels; 5655 5679 5656 - active_dwell = iwl4965_get_active_dwell_time(priv, phymode); 5657 - passive_dwell = iwl4965_get_passive_dwell_time(priv, phymode); 5680 + active_dwell = iwl4965_get_active_dwell_time(priv, band); 5681 + passive_dwell = iwl4965_get_passive_dwell_time(priv, band); 5658 5682 5659 - for (i = 0, added = 0; i < hw_mode->num_channels; i++) { 5660 - if (channels[i].chan == 5683 + for (i = 0, added = 0; i < sband->n_channels; i++) { 5684 + if (ieee80211_frequency_to_channel(channels[i].center_freq) == 5661 5685 le16_to_cpu(priv->active_rxon.channel)) { 5662 5686 if (iwl4965_is_associated(priv)) { 5663 5687 IWL_DEBUG_SCAN ··· 5669 5691 } else if (priv->only_active_channel) 5670 5692 continue; 5671 5693 5672 - scan_ch->channel = channels[i].chan; 5694 + scan_ch->channel = ieee80211_frequency_to_channel(channels[i].center_freq); 5673 5695 5674 - ch_info = iwl4965_get_channel_info(priv, phymode, 5696 + ch_info = iwl4965_get_channel_info(priv, band, 5675 5697 scan_ch->channel); 5676 5698 if (!is_channel_valid(ch_info)) { 5677 5699 IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", ··· 5680 5702 } 5681 5703 5682 5704 if (!is_active || is_channel_passive(ch_info) || 5683 - !(channels[i].flag & IEEE80211_CHAN_W_ACTIVE_SCAN)) 5705 + (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) 5684 5706 scan_ch->type = 0; /* passive */ 5685 5707 else 5686 5708 scan_ch->type = 1; /* active */ ··· 5699 5721 /* scan_pwr_info->tpc.dsp_atten; */ 5700 5722 5701 5723 /*scan_pwr_info->tpc.tx_gain; */ 5702 - if (phymode == MODE_IEEE80211A) 5724 + if (band == IEEE80211_BAND_5GHZ) 5703 5725 scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; 5704 5726 else { 5705 5727 scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); ··· 5723 5745 return added; 5724 5746 } 5725 5747 5726 - static void iwl4965_reset_channel_flag(struct iwl4965_priv *priv) 5727 - { 5728 - int i, j; 5729 - for (i = 0; i < 3; i++) { 5730 - struct ieee80211_hw_mode *hw_mode = (void *)&priv->modes[i]; 5731 - for (j = 0; j < hw_mode->num_channels; j++) 5732 - hw_mode->channels[j].flag = hw_mode->channels[j].val; 5733 - } 5734 - } 5735 - 5736 5748 static void iwl4965_init_hw_rates(struct iwl4965_priv *priv, 5737 5749 struct ieee80211_rate *rates) 5738 5750 { 5739 5751 int i; 5740 5752 5741 5753 for (i = 0; i < IWL_RATE_COUNT; i++) { 5742 - rates[i].rate = iwl4965_rates[i].ieee * 5; 5743 - rates[i].val = i; /* Rate scaling will work on indexes */ 5744 - rates[i].val2 = i; 5745 - rates[i].flags = IEEE80211_RATE_SUPPORTED; 5746 - /* Only OFDM have the bits-per-symbol set */ 5747 - if ((i <= IWL_LAST_OFDM_RATE) && (i >= IWL_FIRST_OFDM_RATE)) 5748 - rates[i].flags |= IEEE80211_RATE_OFDM; 5749 - else { 5754 + rates[i].bitrate = iwl4965_rates[i].ieee * 5; 5755 + rates[i].hw_value = i; /* Rate scaling will work on indexes */ 5756 + rates[i].hw_value_short = i; 5757 + rates[i].flags = 0; 5758 + if ((i > IWL_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) { 5750 5759 /* 5751 - * If CCK 1M then set rate flag to CCK else CCK_2 5752 - * which is CCK | PREAMBLE2 5760 + * If CCK != 1M then set short preamble rate flag. 5753 5761 */ 5754 5762 rates[i].flags |= (iwl4965_rates[i].plcp == 10) ? 5755 - IEEE80211_RATE_CCK : IEEE80211_RATE_CCK_2; 5763 + 0 : IEEE80211_RATE_SHORT_PREAMBLE; 5756 5764 } 5757 - 5758 - /* Set up which ones are basic rates... */ 5759 - if (IWL_BASIC_RATES_MASK & (1 << i)) 5760 - rates[i].flags |= IEEE80211_RATE_BASIC; 5761 5765 } 5762 5766 } 5763 5767 ··· 5749 5789 static int iwl4965_init_geos(struct iwl4965_priv *priv) 5750 5790 { 5751 5791 struct iwl4965_channel_info *ch; 5752 - struct ieee80211_hw_mode *modes; 5792 + struct ieee80211_supported_band *band; 5753 5793 struct ieee80211_channel *channels; 5754 5794 struct ieee80211_channel *geo_ch; 5755 5795 struct ieee80211_rate *rates; 5756 5796 int i = 0; 5757 - enum { 5758 - A = 0, 5759 - B = 1, 5760 - G = 2, 5761 - }; 5762 - int mode_count = 3; 5763 5797 5764 - if (priv->modes) { 5798 + if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || 5799 + priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { 5765 5800 IWL_DEBUG_INFO("Geography modes already initialized.\n"); 5766 5801 set_bit(STATUS_GEO_CONFIGURED, &priv->status); 5767 5802 return 0; 5768 5803 } 5769 5804 5770 - modes = kzalloc(sizeof(struct ieee80211_hw_mode) * mode_count, 5771 - GFP_KERNEL); 5772 - if (!modes) 5773 - return -ENOMEM; 5774 - 5775 5805 channels = kzalloc(sizeof(struct ieee80211_channel) * 5776 5806 priv->channel_count, GFP_KERNEL); 5777 - if (!channels) { 5778 - kfree(modes); 5807 + if (!channels) 5779 5808 return -ENOMEM; 5780 - } 5781 5809 5782 5810 rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_MAX_RATES + 1)), 5783 5811 GFP_KERNEL); 5784 5812 if (!rates) { 5785 - kfree(modes); 5786 5813 kfree(channels); 5787 5814 return -ENOMEM; 5788 5815 } 5789 5816 5790 - /* 0 = 802.11a 5791 - * 1 = 802.11b 5792 - * 2 = 802.11g 5793 - */ 5794 - 5795 5817 /* 5.2GHz channels start after the 2.4GHz channels */ 5796 - modes[A].mode = MODE_IEEE80211A; 5797 - modes[A].channels = &channels[ARRAY_SIZE(iwl4965_eeprom_band_1)]; 5798 - modes[A].rates = rates; 5799 - modes[A].num_rates = 8; /* just OFDM */ 5800 - modes[A].rates = &rates[4]; 5801 - modes[A].num_channels = 0; 5802 5818 #ifdef CONFIG_IWL4965_HT 5803 5819 iwl4965_init_ht_hw_capab(&modes[A].ht_info, MODE_IEEE80211A); 5804 5820 #endif 5805 - 5806 - modes[B].mode = MODE_IEEE80211B; 5807 - modes[B].channels = channels; 5808 - modes[B].rates = rates; 5809 - modes[B].num_rates = 4; /* just CCK */ 5810 - modes[B].num_channels = 0; 5811 - 5812 - modes[G].mode = MODE_IEEE80211G; 5813 - modes[G].channels = channels; 5814 - modes[G].rates = rates; 5815 - modes[G].num_rates = 12; /* OFDM & CCK */ 5816 - modes[G].num_channels = 0; 5817 5821 #ifdef CONFIG_IWL4965_HT 5818 5822 iwl4965_init_ht_hw_capab(&modes[G].ht_info, MODE_IEEE80211G); 5819 5823 #endif 5824 + band = &priv->bands[IEEE80211_BAND_5GHZ]; 5825 + band->channels = &channels[ARRAY_SIZE(iwl4965_eeprom_band_1)]; 5826 + band->bitrates = &rates[4]; 5827 + band->n_bitrates = 8; /* just OFDM */ 5828 + 5829 + band = &priv->bands[IEEE80211_BAND_2GHZ]; 5830 + band->channels = channels; 5831 + band->bitrates = rates; 5832 + band->n_bitrates = 12; /* OFDM & CCK */ 5820 5833 5821 5834 priv->ieee_channels = channels; 5822 5835 priv->ieee_rates = rates; ··· 5808 5875 } 5809 5876 5810 5877 if (is_channel_a_band(ch)) { 5811 - geo_ch = &modes[A].channels[modes[A].num_channels++]; 5812 - } else { 5813 - geo_ch = &modes[B].channels[modes[B].num_channels++]; 5814 - modes[G].num_channels++; 5815 - } 5878 + geo_ch = &priv->bands[IEEE80211_BAND_5GHZ].channels[priv->bands[IEEE80211_BAND_5GHZ].n_channels++]; 5879 + } else 5880 + geo_ch = &priv->bands[IEEE80211_BAND_2GHZ].channels[priv->bands[IEEE80211_BAND_2GHZ].n_channels++]; 5816 5881 5817 - geo_ch->freq = ieee80211chan2mhz(ch->channel); 5818 - geo_ch->chan = ch->channel; 5819 - geo_ch->power_level = ch->max_power_avg; 5820 - geo_ch->antenna_max = 0xff; 5882 + geo_ch->center_freq = ieee80211chan2mhz(ch->channel); 5883 + geo_ch->max_power = ch->max_power_avg; 5884 + geo_ch->max_antenna_gain = 0xff; 5821 5885 5822 5886 if (is_channel_valid(ch)) { 5823 - geo_ch->flag = IEEE80211_CHAN_W_SCAN; 5824 - if (ch->flags & EEPROM_CHANNEL_IBSS) 5825 - geo_ch->flag |= IEEE80211_CHAN_W_IBSS; 5887 + if (!(ch->flags & EEPROM_CHANNEL_IBSS)) 5888 + geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; 5826 5889 5827 - if (ch->flags & EEPROM_CHANNEL_ACTIVE) 5828 - geo_ch->flag |= IEEE80211_CHAN_W_ACTIVE_SCAN; 5890 + if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) 5891 + geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; 5829 5892 5830 5893 if (ch->flags & EEPROM_CHANNEL_RADAR) 5831 - geo_ch->flag |= IEEE80211_CHAN_W_RADAR_DETECT; 5894 + geo_ch->flags |= IEEE80211_CHAN_RADAR; 5832 5895 5833 5896 if (ch->max_power_avg > priv->max_channel_txpower_limit) 5834 5897 priv->max_channel_txpower_limit = 5835 5898 ch->max_power_avg; 5836 - } 5837 - 5838 - geo_ch->val = geo_ch->flag; 5899 + } else 5900 + geo_ch->flags |= IEEE80211_CHAN_DISABLED; 5839 5901 } 5840 5902 5841 - if ((modes[A].num_channels == 0) && priv->is_abg) { 5903 + if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && priv->is_abg) { 5842 5904 printk(KERN_INFO DRV_NAME 5843 5905 ": Incorrectly detected BG card as ABG. Please send " 5844 5906 "your PCI ID 0x%04X:0x%04X to maintainer.\n", ··· 5843 5915 5844 5916 printk(KERN_INFO DRV_NAME 5845 5917 ": Tunable channels: %d 802.11bg, %d 802.11a channels\n", 5846 - modes[G].num_channels, modes[A].num_channels); 5918 + priv->bands[IEEE80211_BAND_2GHZ].n_channels, 5919 + priv->bands[IEEE80211_BAND_5GHZ].n_channels); 5847 5920 5848 - /* 5849 - * NOTE: We register these in preference of order -- the 5850 - * stack doesn't currently (as of 7.0.6 / Apr 24 '07) pick 5851 - * a phymode based on rates or AP capabilities but seems to 5852 - * configure it purely on if the channel being configured 5853 - * is supported by a mode -- and the first match is taken 5854 - */ 5921 + priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->bands[IEEE80211_BAND_2GHZ]; 5922 + priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->bands[IEEE80211_BAND_5GHZ]; 5855 5923 5856 - if (modes[G].num_channels) 5857 - ieee80211_register_hwmode(priv->hw, &modes[G]); 5858 - if (modes[B].num_channels) 5859 - ieee80211_register_hwmode(priv->hw, &modes[B]); 5860 - if (modes[A].num_channels) 5861 - ieee80211_register_hwmode(priv->hw, &modes[A]); 5862 - 5863 - priv->modes = modes; 5864 5924 set_bit(STATUS_GEO_CONFIGURED, &priv->status); 5865 5925 5866 5926 return 0; ··· 5859 5943 */ 5860 5944 static void iwl4965_free_geos(struct iwl4965_priv *priv) 5861 5945 { 5862 - kfree(priv->modes); 5863 5946 kfree(priv->ieee_channels); 5864 5947 kfree(priv->ieee_rates); 5865 5948 clear_bit(STATUS_GEO_CONFIGURED, &priv->status); ··· 6860 6945 struct iwl4965_scan_cmd *scan; 6861 6946 struct ieee80211_conf *conf = NULL; 6862 6947 u8 direct_mask; 6863 - int phymode; 6948 + enum ieee80211_band band; 6864 6949 6865 6950 conf = ieee80211_get_hw_conf(priv->hw); 6866 6951 ··· 6990 7075 RATE_MCS_ANT_B_MSK|RATE_MCS_CCK_MSK); 6991 7076 6992 7077 scan->good_CRC_th = 0; 6993 - phymode = MODE_IEEE80211G; 7078 + band = IEEE80211_BAND_2GHZ; 6994 7079 break; 6995 7080 6996 7081 case 1: ··· 6998 7083 iwl4965_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, 6999 7084 RATE_MCS_ANT_B_MSK); 7000 7085 scan->good_CRC_th = IWL_GOOD_CRC_TH; 7001 - phymode = MODE_IEEE80211A; 7086 + band = IEEE80211_BAND_5GHZ; 7002 7087 break; 7003 7088 7004 7089 default: ··· 7028 7113 7029 7114 scan->channel_count = 7030 7115 iwl4965_get_channels_for_scan( 7031 - priv, phymode, 1, /* active */ 7116 + priv, band, 1, /* active */ 7032 7117 direct_mask, 7033 7118 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 7034 7119 ··· 7378 7463 } 7379 7464 7380 7465 IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 7381 - ctl->tx_rate); 7466 + ctl->tx_rate->bitrate); 7382 7467 7383 7468 if (iwl4965_tx_skb(priv, skb, ctl)) 7384 7469 dev_kfree_skb_any(skb); ··· 7437 7522 int ret = 0; 7438 7523 7439 7524 mutex_lock(&priv->mutex); 7440 - IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel); 7525 + IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); 7441 7526 7442 7527 priv->add_radiotap = !!(conf->flags & IEEE80211_CONF_RADIOTAP); 7443 7528 ··· 7457 7542 7458 7543 spin_lock_irqsave(&priv->lock, flags); 7459 7544 7460 - ch_info = iwl4965_get_channel_info(priv, conf->phymode, conf->channel); 7545 + ch_info = iwl4965_get_channel_info(priv, conf->channel->band, 7546 + ieee80211_frequency_to_channel(conf->channel->center_freq)); 7461 7547 if (!is_channel_valid(ch_info)) { 7462 - IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this SKU.\n", 7463 - conf->channel, conf->phymode); 7464 7548 IWL_DEBUG_MAC80211("leave - invalid channel\n"); 7465 7549 spin_unlock_irqrestore(&priv->lock, flags); 7466 7550 ret = -EINVAL; ··· 7478 7564 priv->staging_rxon.flags = 0; 7479 7565 #endif /* CONFIG_IWL4965_HT */ 7480 7566 7481 - iwl4965_set_rxon_channel(priv, conf->phymode, conf->channel); 7567 + iwl4965_set_rxon_channel(priv, conf->channel->band, 7568 + ieee80211_frequency_to_channel(conf->channel->center_freq)); 7482 7569 7483 - iwl4965_set_flags_for_phymode(priv, conf->phymode); 7570 + iwl4965_set_flags_for_phymode(priv, conf->channel->band); 7484 7571 7485 7572 /* The list of supported rates and rate mask can be different 7486 - * for each phymode; since the phymode may have changed, reset 7573 + * for each band; since the band may have changed, reset 7487 7574 * the rate mask to what mac80211 lists */ 7488 7575 iwl4965_set_rate(priv); 7489 7576 ··· 7754 7839 } 7755 7840 7756 7841 if (changes & BSS_CHANGED_ERP_CTS_PROT) { 7757 - if (bss_conf->use_cts_prot && (priv->phymode != MODE_IEEE80211A)) 7842 + if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ)) 7758 7843 priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK; 7759 7844 else 7760 7845 priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK; ··· 8192 8277 u8 use_current_config) 8193 8278 { 8194 8279 struct ieee80211_conf *conf = &hw->conf; 8195 - struct ieee80211_hw_mode *mode = conf->mode; 8196 8280 8197 8281 if (use_current_config) { 8198 8282 ht_cap->cap_info = cpu_to_le16(conf->ht_conf.cap); ··· 8402 8488 static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags, 8403 8489 store_filter_flags); 8404 8490 8405 - static ssize_t show_tune(struct device *d, 8406 - struct device_attribute *attr, char *buf) 8407 - { 8408 - struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 8409 - 8410 - return sprintf(buf, "0x%04X\n", 8411 - (priv->phymode << 8) | 8412 - le16_to_cpu(priv->active_rxon.channel)); 8413 - } 8414 - 8415 - static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv, u8 phymode); 8416 - 8417 - static ssize_t store_tune(struct device *d, 8418 - struct device_attribute *attr, 8419 - const char *buf, size_t count) 8420 - { 8421 - struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data; 8422 - char *p = (char *)buf; 8423 - u16 tune = simple_strtoul(p, &p, 0); 8424 - u8 phymode = (tune >> 8) & 0xff; 8425 - u16 channel = tune & 0xff; 8426 - 8427 - IWL_DEBUG_INFO("Tune request to:%d channel:%d\n", phymode, channel); 8428 - 8429 - mutex_lock(&priv->mutex); 8430 - if ((le16_to_cpu(priv->staging_rxon.channel) != channel) || 8431 - (priv->phymode != phymode)) { 8432 - const struct iwl4965_channel_info *ch_info; 8433 - 8434 - ch_info = iwl4965_get_channel_info(priv, phymode, channel); 8435 - if (!ch_info) { 8436 - IWL_WARNING("Requested invalid phymode/channel " 8437 - "combination: %d %d\n", phymode, channel); 8438 - mutex_unlock(&priv->mutex); 8439 - return -EINVAL; 8440 - } 8441 - 8442 - /* Cancel any currently running scans... */ 8443 - if (iwl4965_scan_cancel_timeout(priv, 100)) 8444 - IWL_WARNING("Could not cancel scan.\n"); 8445 - else { 8446 - IWL_DEBUG_INFO("Committing phymode and " 8447 - "rxon.channel = %d %d\n", 8448 - phymode, channel); 8449 - 8450 - iwl4965_set_rxon_channel(priv, phymode, channel); 8451 - iwl4965_set_flags_for_phymode(priv, phymode); 8452 - 8453 - iwl4965_set_rate(priv); 8454 - iwl4965_commit_rxon(priv); 8455 - } 8456 - } 8457 - mutex_unlock(&priv->mutex); 8458 - 8459 - return count; 8460 - } 8461 - 8462 - static DEVICE_ATTR(tune, S_IWUSR | S_IRUGO, show_tune, store_tune); 8463 - 8464 8491 #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT 8465 8492 8466 8493 static ssize_t show_measurement(struct device *d, ··· 8591 8736 static ssize_t show_channels(struct device *d, 8592 8737 struct device_attribute *attr, char *buf) 8593 8738 { 8594 - struct iwl4965_priv *priv = dev_get_drvdata(d); 8595 - int len = 0, i; 8596 - struct ieee80211_channel *channels = NULL; 8597 - const struct ieee80211_hw_mode *hw_mode = NULL; 8598 - int count = 0; 8599 - 8600 - if (!iwl4965_is_ready(priv)) 8601 - return -EAGAIN; 8602 - 8603 - hw_mode = iwl4965_get_hw_mode(priv, MODE_IEEE80211G); 8604 - if (!hw_mode) 8605 - hw_mode = iwl4965_get_hw_mode(priv, MODE_IEEE80211B); 8606 - if (hw_mode) { 8607 - channels = hw_mode->channels; 8608 - count = hw_mode->num_channels; 8609 - } 8610 - 8611 - len += 8612 - sprintf(&buf[len], 8613 - "Displaying %d channels in 2.4GHz band " 8614 - "(802.11bg):\n", count); 8615 - 8616 - for (i = 0; i < count; i++) 8617 - len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n", 8618 - channels[i].chan, 8619 - channels[i].power_level, 8620 - channels[i]. 8621 - flag & IEEE80211_CHAN_W_RADAR_DETECT ? 8622 - " (IEEE 802.11h required)" : "", 8623 - (!(channels[i].flag & IEEE80211_CHAN_W_IBSS) 8624 - || (channels[i]. 8625 - flag & 8626 - IEEE80211_CHAN_W_RADAR_DETECT)) ? "" : 8627 - ", IBSS", 8628 - channels[i]. 8629 - flag & IEEE80211_CHAN_W_ACTIVE_SCAN ? 8630 - "active/passive" : "passive only"); 8631 - 8632 - hw_mode = iwl4965_get_hw_mode(priv, MODE_IEEE80211A); 8633 - if (hw_mode) { 8634 - channels = hw_mode->channels; 8635 - count = hw_mode->num_channels; 8636 - } else { 8637 - channels = NULL; 8638 - count = 0; 8639 - } 8640 - 8641 - len += sprintf(&buf[len], "Displaying %d channels in 5.2GHz band " 8642 - "(802.11a):\n", count); 8643 - 8644 - for (i = 0; i < count; i++) 8645 - len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n", 8646 - channels[i].chan, 8647 - channels[i].power_level, 8648 - channels[i]. 8649 - flag & IEEE80211_CHAN_W_RADAR_DETECT ? 8650 - " (IEEE 802.11h required)" : "", 8651 - (!(channels[i].flag & IEEE80211_CHAN_W_IBSS) 8652 - || (channels[i]. 8653 - flag & 8654 - IEEE80211_CHAN_W_RADAR_DETECT)) ? "" : 8655 - ", IBSS", 8656 - channels[i]. 8657 - flag & IEEE80211_CHAN_W_ACTIVE_SCAN ? 8658 - "active/passive" : "passive only"); 8659 - 8660 - return len; 8739 + /* all this shit doesn't belong into sysfs anyway */ 8740 + return 0; 8661 8741 } 8662 8742 8663 8743 static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL); ··· 8771 8981 &dev_attr_statistics.attr, 8772 8982 &dev_attr_status.attr, 8773 8983 &dev_attr_temperature.attr, 8774 - &dev_attr_tune.attr, 8775 8984 &dev_attr_tx_power.attr, 8776 8985 8777 8986 NULL ··· 8898 9109 priv->data_retry_limit = -1; 8899 9110 priv->ieee_channels = NULL; 8900 9111 priv->ieee_rates = NULL; 8901 - priv->phymode = -1; 9112 + priv->band = IEEE80211_BAND_2GHZ; 8902 9113 8903 9114 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 8904 9115 if (!err) ··· 8964 9175 priv->qos_data.qos_cap.val = 0; 8965 9176 #endif /* CONFIG_IWL4965_QOS */ 8966 9177 8967 - iwl4965_set_rxon_channel(priv, MODE_IEEE80211G, 6); 9178 + iwl4965_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); 8968 9179 iwl4965_setup_deferred_work(priv); 8969 9180 iwl4965_setup_rx_handlers(priv); 8970 9181 ··· 9015 9226 IWL_ERROR("initializing geos failed: %d\n", err); 9016 9227 goto out_free_channel_map; 9017 9228 } 9018 - iwl4965_reset_channel_flag(priv); 9019 9229 9020 9230 iwl4965_rate_control_register(priv->hw); 9021 9231 err = ieee80211_register_hw(priv->hw);
-4
drivers/net/wireless/p54.h
··· 64 64 unsigned int tx_hdr_len; 65 65 void *cached_vdcf; 66 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 67 struct ieee80211_tx_queue_stats tx_stats; 72 68 }; 73 69
+48 -26
drivers/net/wireless/p54common.c
··· 27 27 MODULE_LICENSE("GPL"); 28 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 70 void p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw) 31 71 { 32 72 struct p54_common *priv = dev->priv; ··· 348 308 u16 freq = le16_to_cpu(hdr->freq); 349 309 350 310 rx_status.ssi = hdr->rssi; 351 - rx_status.rate = hdr->rate & 0x1f; /* report short preambles & CCK too */ 352 - rx_status.channel = freq == 2484 ? 14 : (freq - 2407)/5; 311 + /* XX correct? */ 312 + rx_status.rate_idx = hdr->rate & 0xf; 353 313 rx_status.freq = freq; 354 - rx_status.phymode = MODE_IEEE80211G; 314 + rx_status.band = IEEE80211_BAND_2GHZ; 355 315 rx_status.antenna = hdr->antenna; 356 316 rx_status.mactime = le64_to_cpu(hdr->timestamp); 357 317 rx_status.flag |= RX_FLAG_TSFT; ··· 587 547 txhdr->padding2 = 0; 588 548 589 549 /* TODO: add support for alternate retry TX rates */ 590 - rate = control->tx_rate; 550 + rate = control->tx_rate->hw_value; 551 + if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) 552 + rate |= 0x10; 591 553 if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) 592 554 rate |= 0x40; 593 555 else if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) ··· 891 849 { 892 850 int ret; 893 851 894 - ret = p54_set_freq(dev, cpu_to_le16(conf->freq)); 852 + ret = p54_set_freq(dev, cpu_to_le16(conf->channel->center_freq)); 895 853 p54_set_vdcf(dev); 896 854 return ret; 897 855 } ··· 986 944 { 987 945 struct ieee80211_hw *dev; 988 946 struct p54_common *priv; 989 - int i; 990 947 991 948 dev = ieee80211_alloc_hw(priv_data_len, &p54_ops); 992 949 if (!dev) ··· 994 953 priv = dev->priv; 995 954 priv->mode = IEEE80211_IF_TYPE_INVALID; 996 955 skb_queue_head_init(&priv->tx_queue); 997 - memcpy(priv->channels, p54_channels, sizeof(p54_channels)); 998 - memcpy(priv->rates, p54_rates, sizeof(p54_rates)); 999 - priv->modes[1].mode = MODE_IEEE80211B; 1000 - priv->modes[1].num_rates = 4; 1001 - priv->modes[1].rates = priv->rates; 1002 - priv->modes[1].num_channels = ARRAY_SIZE(p54_channels); 1003 - priv->modes[1].channels = priv->channels; 1004 - priv->modes[0].mode = MODE_IEEE80211G; 1005 - priv->modes[0].num_rates = ARRAY_SIZE(p54_rates); 1006 - priv->modes[0].rates = priv->rates; 1007 - priv->modes[0].num_channels = ARRAY_SIZE(p54_channels); 1008 - priv->modes[0].channels = priv->channels; 956 + dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz; 1009 957 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | /* not sure */ 1010 958 IEEE80211_HW_RX_INCLUDES_FCS; 1011 959 dev->channel_change_time = 1000; /* TODO: find actual value */ ··· 1015 985 } 1016 986 1017 987 p54_init_vdcf(dev); 1018 - 1019 - for (i = 0; i < 2; i++) { 1020 - if (ieee80211_register_hwmode(dev, &priv->modes[i])) { 1021 - kfree(priv->cached_vdcf); 1022 - ieee80211_free_hw(dev); 1023 - return NULL; 1024 - } 1025 - } 1026 988 1027 989 return dev; 1028 990 }
-75
drivers/net/wireless/p54common.h
··· 251 251 __le16 frameburst; 252 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 254 #endif /* PRISM54COMMON_H */
+6 -5
drivers/net/wireless/rt2x00/rt2x00.h
··· 390 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 398 * Details about the supported modes, rates and channels 395 399 * of a particular chipset. This is used by rt2x00lib ··· 648 644 * IEEE80211 control structure. 649 645 */ 650 646 struct ieee80211_hw *hw; 651 - struct ieee80211_hw_mode *hwmodes; 652 - unsigned int curr_hwmode; 653 - #define HWMODE_B 0 654 - #define HWMODE_G 1 655 - #define HWMODE_A 2 647 + struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; 648 + enum ieee80211_band curr_band; 656 649 657 650 /* 658 651 * rfkill structure for RF state switching support.
+15 -18
drivers/net/wireless/rt2x00/rt2x00config.c
··· 152 152 struct ieee80211_conf *conf, const int force_config) 153 153 { 154 154 struct rt2x00lib_conf libconf; 155 - struct ieee80211_hw_mode *mode; 155 + struct ieee80211_supported_band *band; 156 156 struct ieee80211_rate *rate; 157 157 struct antenna_setup *default_ant = &rt2x00dev->default_ant; 158 158 struct antenna_setup *active_ant = &rt2x00dev->link.ant.active; ··· 172 172 * Check which configuration options have been 173 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 176 flags |= CONFIG_UPDATE_PHYMODE; 177 - if (rt2x00dev->rx_status.channel != conf->channel) 177 + if (rt2x00dev->rx_status.freq != conf->channel->center_freq) 178 178 flags |= CONFIG_UPDATE_CHANNEL; 179 179 if (rt2x00dev->tx_power != conf->power_level) 180 180 flags |= CONFIG_UPDATE_TXPOWER; ··· 229 229 memset(&libconf, 0, sizeof(libconf)); 230 230 231 231 if (flags & CONFIG_UPDATE_PHYMODE) { 232 - switch (conf->phymode) { 233 - case MODE_IEEE80211A: 232 + switch (conf->channel->band) { 233 + case IEEE80211_BAND_5GHZ: 234 234 libconf.phymode = HWMODE_A; 235 235 break; 236 - case MODE_IEEE80211B: 237 - libconf.phymode = HWMODE_B; 238 - break; 239 - case MODE_IEEE80211G: 236 + case IEEE80211_BAND_2GHZ: 237 + /* Uh oh. what about B? */ 240 238 libconf.phymode = HWMODE_G; 241 239 break; 242 240 default: 243 241 ERROR(rt2x00dev, 244 242 "Attempt to configure unsupported mode (%d)" 245 - "Defaulting to 802.11b", conf->phymode); 243 + "Defaulting to 802.11b", conf->channel->band); 246 244 libconf.phymode = HWMODE_B; 247 245 } 248 246 249 - mode = &rt2x00dev->hwmodes[libconf.phymode]; 250 - rate = &mode->rates[mode->num_rates - 1]; 247 + band = &rt2x00dev->bands[conf->channel->band]; 248 + rate = &band->bitrates[band->n_bitrates - 1]; 251 249 252 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 254 if (flags & CONFIG_UPDATE_CHANNEL) { 257 255 memcpy(&libconf.rf, 258 - &rt2x00dev->spec.channels[conf->channel_val], 256 + &rt2x00dev->spec.channels[conf->channel->hw_value], 259 257 sizeof(libconf.rf)); 260 258 } 261 259 ··· 299 301 rt2x00lib_reset_link_tuner(rt2x00dev); 300 302 301 303 if (flags & CONFIG_UPDATE_PHYMODE) { 302 - rt2x00dev->curr_hwmode = libconf.phymode; 303 - rt2x00dev->rx_status.phymode = conf->phymode; 304 + rt2x00dev->curr_band = conf->channel->band; 305 + rt2x00dev->rx_status.band = conf->channel->band; 304 306 } 305 307 306 - rt2x00dev->rx_status.freq = conf->freq; 307 - rt2x00dev->rx_status.channel = conf->channel; 308 + rt2x00dev->rx_status.freq = conf->channel->center_freq; 308 309 rt2x00dev->tx_power = conf->power_level; 309 310 310 311 if (flags & CONFIG_UPDATE_ANTENNA) {
+59 -90
drivers/net/wireless/rt2x00/rt2x00dev.c
··· 550 550 { 551 551 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 552 552 struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status; 553 - struct ieee80211_hw_mode *mode; 553 + struct ieee80211_supported_band *sband; 554 554 struct ieee80211_rate *rate; 555 555 struct ieee80211_hdr *hdr; 556 556 unsigned int i; 557 - int val = 0; 557 + int val = 0, idx = -1; 558 558 u16 fc; 559 559 560 560 /* 561 561 * Update RX statistics. 562 562 */ 563 - mode = &rt2x00dev->hwmodes[rt2x00dev->curr_hwmode]; 564 - for (i = 0; i < mode->num_rates; i++) { 565 - rate = &mode->rates[i]; 563 + sband = &rt2x00dev->bands[rt2x00dev->curr_band]; 564 + for (i = 0; i < sband->n_bitrates; i++) { 565 + rate = &sband->bitrates[i]; 566 566 567 567 /* 568 568 * When frame was received with an OFDM bitrate, ··· 570 570 * a CCK bitrate the signal is the rate in 0.5kbit/s. 571 571 */ 572 572 if (!rxdesc->ofdm) 573 - val = DEVICE_GET_RATE_FIELD(rate->val, RATE); 573 + val = DEVICE_GET_RATE_FIELD(rate->hw_value, RATE); 574 574 else 575 - val = DEVICE_GET_RATE_FIELD(rate->val, PLCP); 575 + val = DEVICE_GET_RATE_FIELD(rate->hw_value, PLCP); 576 576 577 577 if (val == rxdesc->signal) { 578 - val = rate->val; 578 + idx = i; 579 579 break; 580 580 } 581 581 } ··· 590 590 591 591 rt2x00dev->link.qual.rx_success++; 592 592 593 - rx_status->rate = val; 593 + rx_status->rate_idx = idx; 594 594 rx_status->signal = 595 595 rt2x00lib_calculate_link_signal(rt2x00dev, rxdesc->rssi); 596 596 rx_status->ssi = rxdesc->rssi; ··· 639 639 frame_control = le16_to_cpu(ieee80211hdr->frame_control); 640 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 645 * Check whether this frame is to be acked ··· 658 658 } else 659 659 __clear_bit(ENTRY_TXD_ACK, &txdesc.flags); 660 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 760 const int channel, const int tx_power, 761 761 const int value) 762 762 { 763 - entry->chan = channel; 764 763 if (channel <= 14) 765 - entry->freq = 2407 + (5 * channel); 764 + entry->center_freq = 2407 + (5 * channel); 766 765 else 767 - entry->freq = 5000 + (5 * channel); 768 - entry->val = value; 769 - entry->flag = 770 - IEEE80211_CHAN_W_IBSS | 771 - IEEE80211_CHAN_W_ACTIVE_SCAN | 772 - IEEE80211_CHAN_W_SCAN; 773 - entry->power_level = tx_power; 774 - entry->antenna_max = 0xff; 766 + entry->center_freq = 5000 + (5 * channel); 767 + entry->hw_value = value; 768 + entry->max_power = tx_power; 769 + entry->max_antenna_gain = 0xff; 775 770 } 776 771 777 772 static void rt2x00lib_rate(struct ieee80211_rate *entry, 778 773 const int rate, const int mask, 779 774 const int plcp, const int flags) 780 775 { 781 - entry->rate = rate; 782 - entry->val = 776 + entry->bitrate = rate; 777 + entry->hw_value = 783 778 DEVICE_SET_RATE_FIELD(rate, RATE) | 784 779 DEVICE_SET_RATE_FIELD(mask, RATEMASK) | 785 780 DEVICE_SET_RATE_FIELD(plcp, PLCP); 786 781 entry->flags = flags; 787 - entry->val2 = entry->val; 788 - if (entry->flags & IEEE80211_RATE_PREAMBLE2) 789 - entry->val2 |= DEVICE_SET_RATE_FIELD(1, PREAMBLE); 790 - entry->min_rssi_ack = 0; 791 - entry->min_rssi_ack_delta = 0; 782 + entry->hw_value_short = entry->hw_value; 783 + if (entry->flags & IEEE80211_RATE_SHORT_PREAMBLE) 784 + entry->hw_value_short |= DEVICE_SET_RATE_FIELD(1, PREAMBLE); 792 785 } 793 786 794 787 static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, 795 788 struct hw_mode_spec *spec) 796 789 { 797 790 struct ieee80211_hw *hw = rt2x00dev->hw; 798 - struct ieee80211_hw_mode *hwmodes; 791 + struct ieee80211_supported_band *sbands; 799 792 struct ieee80211_channel *channels; 800 793 struct ieee80211_rate *rates; 801 794 unsigned int i; 802 795 unsigned char tx_power; 803 796 804 - hwmodes = kzalloc(sizeof(*hwmodes) * spec->num_modes, GFP_KERNEL); 805 - if (!hwmodes) 806 - goto exit; 797 + sbands = &rt2x00dev->bands[0]; 807 798 808 799 channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL); 809 800 if (!channels) 810 - goto exit_free_modes; 801 + return -ENOMEM; 811 802 812 803 rates = kzalloc(sizeof(*rates) * spec->num_rates, GFP_KERNEL); 813 804 if (!rates) ··· 808 817 * Initialize Rate list. 809 818 */ 810 819 rt2x00lib_rate(&rates[0], 10, DEV_RATEMASK_1MB, 811 - 0x00, IEEE80211_RATE_CCK); 820 + 0x00, 0); 812 821 rt2x00lib_rate(&rates[1], 20, DEV_RATEMASK_2MB, 813 - 0x01, IEEE80211_RATE_CCK_2); 822 + 0x01, IEEE80211_RATE_SHORT_PREAMBLE); 814 823 rt2x00lib_rate(&rates[2], 55, DEV_RATEMASK_5_5MB, 815 - 0x02, IEEE80211_RATE_CCK_2); 824 + 0x02, IEEE80211_RATE_SHORT_PREAMBLE); 816 825 rt2x00lib_rate(&rates[3], 110, DEV_RATEMASK_11MB, 817 - 0x03, IEEE80211_RATE_CCK_2); 826 + 0x03, IEEE80211_RATE_SHORT_PREAMBLE); 818 827 819 828 if (spec->num_rates > 4) { 820 829 rt2x00lib_rate(&rates[4], 60, DEV_RATEMASK_6MB, 821 - 0x0b, IEEE80211_RATE_OFDM); 830 + 0x0b, 0); 822 831 rt2x00lib_rate(&rates[5], 90, DEV_RATEMASK_9MB, 823 - 0x0f, IEEE80211_RATE_OFDM); 832 + 0x0f, 0); 824 833 rt2x00lib_rate(&rates[6], 120, DEV_RATEMASK_12MB, 825 - 0x0a, IEEE80211_RATE_OFDM); 834 + 0x0a, 0); 826 835 rt2x00lib_rate(&rates[7], 180, DEV_RATEMASK_18MB, 827 - 0x0e, IEEE80211_RATE_OFDM); 836 + 0x0e, 0); 828 837 rt2x00lib_rate(&rates[8], 240, DEV_RATEMASK_24MB, 829 - 0x09, IEEE80211_RATE_OFDM); 838 + 0x09, 0); 830 839 rt2x00lib_rate(&rates[9], 360, DEV_RATEMASK_36MB, 831 - 0x0d, IEEE80211_RATE_OFDM); 840 + 0x0d, 0); 832 841 rt2x00lib_rate(&rates[10], 480, DEV_RATEMASK_48MB, 833 - 0x08, IEEE80211_RATE_OFDM); 842 + 0x08, 0); 834 843 rt2x00lib_rate(&rates[11], 540, DEV_RATEMASK_54MB, 835 - 0x0c, IEEE80211_RATE_OFDM); 844 + 0x0c, 0); 836 845 } 837 846 838 847 /* ··· 853 862 /* 854 863 * Intitialize 802.11b 855 864 * Rates: CCK. 856 - * Channels: OFDM. 865 + * Channels: 2.4 GHz 857 866 */ 858 867 if (spec->num_modes > HWMODE_B) { 859 - hwmodes[HWMODE_B].mode = MODE_IEEE80211B; 860 - hwmodes[HWMODE_B].num_channels = 14; 861 - hwmodes[HWMODE_B].num_rates = 4; 862 - hwmodes[HWMODE_B].channels = channels; 863 - hwmodes[HWMODE_B].rates = rates; 868 + sbands[IEEE80211_BAND_2GHZ].n_channels = 14; 869 + sbands[IEEE80211_BAND_2GHZ].n_bitrates = 4; 870 + sbands[IEEE80211_BAND_2GHZ].channels = channels; 871 + sbands[IEEE80211_BAND_2GHZ].bitrates = rates; 872 + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &rt2x00dev->bands[IEEE80211_BAND_2GHZ]; 864 873 } 865 874 866 875 /* 867 876 * Intitialize 802.11g 868 877 * Rates: CCK, OFDM. 869 - * Channels: OFDM. 878 + * Channels: 2.4 GHz 870 879 */ 871 880 if (spec->num_modes > HWMODE_G) { 872 - hwmodes[HWMODE_G].mode = MODE_IEEE80211G; 873 - hwmodes[HWMODE_G].num_channels = 14; 874 - hwmodes[HWMODE_G].num_rates = spec->num_rates; 875 - hwmodes[HWMODE_G].channels = channels; 876 - hwmodes[HWMODE_G].rates = rates; 881 + sbands[IEEE80211_BAND_2GHZ].n_channels = 14; 882 + sbands[IEEE80211_BAND_2GHZ].n_bitrates = spec->num_rates; 883 + sbands[IEEE80211_BAND_2GHZ].channels = channels; 884 + sbands[IEEE80211_BAND_2GHZ].bitrates = rates; 885 + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &rt2x00dev->bands[IEEE80211_BAND_2GHZ]; 877 886 } 878 887 879 888 /* ··· 882 891 * Channels: OFDM, UNII, HiperLAN2. 883 892 */ 884 893 if (spec->num_modes > HWMODE_A) { 885 - hwmodes[HWMODE_A].mode = MODE_IEEE80211A; 886 - hwmodes[HWMODE_A].num_channels = spec->num_channels - 14; 887 - hwmodes[HWMODE_A].num_rates = spec->num_rates - 4; 888 - hwmodes[HWMODE_A].channels = &channels[14]; 889 - hwmodes[HWMODE_A].rates = &rates[4]; 894 + sbands[IEEE80211_BAND_5GHZ].n_channels = spec->num_channels - 14; 895 + sbands[IEEE80211_BAND_5GHZ].n_bitrates = spec->num_rates - 4; 896 + sbands[IEEE80211_BAND_5GHZ].channels = &channels[14]; 897 + sbands[IEEE80211_BAND_5GHZ].bitrates = &rates[4]; 898 + hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &rt2x00dev->bands[IEEE80211_BAND_5GHZ]; 890 899 } 891 - 892 - if (spec->num_modes > HWMODE_G && 893 - ieee80211_register_hwmode(hw, &hwmodes[HWMODE_G])) 894 - goto exit_free_rates; 895 - 896 - if (spec->num_modes > HWMODE_B && 897 - ieee80211_register_hwmode(hw, &hwmodes[HWMODE_B])) 898 - goto exit_free_rates; 899 - 900 - if (spec->num_modes > HWMODE_A && 901 - ieee80211_register_hwmode(hw, &hwmodes[HWMODE_A])) 902 - goto exit_free_rates; 903 - 904 - rt2x00dev->hwmodes = hwmodes; 905 900 906 901 return 0; 907 902 908 - exit_free_rates: 909 - kfree(rates); 910 - 911 - exit_free_channels: 903 + exit_free_channels: 912 904 kfree(channels); 913 - 914 - exit_free_modes: 915 - kfree(hwmodes); 916 - 917 - exit: 918 905 ERROR(rt2x00dev, "Allocation ieee80211 modes failed.\n"); 919 906 return -ENOMEM; 920 907 } ··· 902 933 if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags)) 903 934 ieee80211_unregister_hw(rt2x00dev->hw); 904 935 905 - if (likely(rt2x00dev->hwmodes)) { 906 - kfree(rt2x00dev->hwmodes->channels); 907 - kfree(rt2x00dev->hwmodes->rates); 908 - kfree(rt2x00dev->hwmodes); 909 - rt2x00dev->hwmodes = NULL; 936 + if (likely(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ])) { 937 + kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels); 938 + kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->bitrates); 939 + rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; 940 + rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; 910 941 } 911 942 } 912 943
+12 -11
drivers/net/wireless/rt2x00/rt61pci.c
··· 426 426 case ANTENNA_HW_DIVERSITY: 427 427 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2); 428 428 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 429 - (rt2x00dev->curr_hwmode != HWMODE_A)); 429 + (rt2x00dev->curr_band != IEEE80211_BAND_5GHZ)); 430 430 break; 431 431 case ANTENNA_A: 432 432 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); 433 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 435 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); 436 436 else 437 437 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); ··· 446 446 case ANTENNA_B: 447 447 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); 448 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 450 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); 451 451 else 452 452 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); ··· 602 602 unsigned int i; 603 603 u32 reg; 604 604 605 - if (rt2x00dev->curr_hwmode == HWMODE_A) { 605 + if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) { 606 606 sel = antenna_sel_a; 607 607 lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); 608 608 } else { ··· 616 616 rt2x00pci_register_read(rt2x00dev, PHY_CSR0, &reg); 617 617 618 618 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG, 619 - (rt2x00dev->curr_hwmode == HWMODE_B || 620 - rt2x00dev->curr_hwmode == HWMODE_G)); 619 + rt2x00dev->curr_band == IEEE80211_BAND_2GHZ); 621 620 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A, 622 - (rt2x00dev->curr_hwmode == HWMODE_A)); 621 + rt2x00dev->curr_band == IEEE80211_BAND_5GHZ); 623 622 624 623 rt2x00pci_register_write(rt2x00dev, PHY_CSR0, reg); 625 624 ··· 697 698 698 699 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1); 699 700 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS, 700 - (rt2x00dev->rx_status.phymode == MODE_IEEE80211A)); 701 + rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ); 701 702 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS, 702 - (rt2x00dev->rx_status.phymode != MODE_IEEE80211A)); 703 + rt2x00dev->rx_status.band != IEEE80211_BAND_5GHZ); 703 704 704 705 arg0 = rt2x00dev->led_reg & 0xff; 705 706 arg1 = (rt2x00dev->led_reg >> 8) & 0xff; ··· 797 798 /* 798 799 * Determine r17 bounds. 799 800 */ 800 - if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { 801 + if (rt2x00dev->rx_status.band == IEEE80211_BAND_2GHZ) { 801 802 low_bound = 0x28; 802 803 up_bound = 0x48; 803 804 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) { ··· 1543 1544 rt2x00_desc_write(txd, 2, word); 1544 1545 1545 1546 rt2x00_desc_read(txd, 5, &word); 1547 + /* XXX: removed for now 1546 1548 rt2x00_set_field32(&word, TXD_W5_TX_POWER, 1547 1549 TXPOWER_TO_DEV(control->power_level)); 1550 + */ 1548 1551 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); 1549 1552 rt2x00_desc_write(txd, 5, word); 1550 1553 ··· 1638 1637 return 0; 1639 1638 } 1640 1639 1641 - if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { 1640 + if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) { 1642 1641 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) 1643 1642 offset += 14; 1644 1643
+12 -11
drivers/net/wireless/rt2x00/rt73usb.c
··· 439 439 case ANTENNA_HW_DIVERSITY: 440 440 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2); 441 441 temp = !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags) 442 - && (rt2x00dev->curr_hwmode != HWMODE_A); 442 + && (rt2x00dev->curr_band != IEEE80211_BAND_5GHZ); 443 443 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, temp); 444 444 break; 445 445 case ANTENNA_A: 446 446 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); 447 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 449 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); 450 450 else 451 451 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); ··· 460 460 case ANTENNA_B: 461 461 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); 462 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 464 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); 465 465 else 466 466 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); ··· 555 555 unsigned int i; 556 556 u32 reg; 557 557 558 - if (rt2x00dev->curr_hwmode == HWMODE_A) { 558 + if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) { 559 559 sel = antenna_sel_a; 560 560 lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); 561 561 } else { ··· 569 569 rt73usb_register_read(rt2x00dev, PHY_CSR0, &reg); 570 570 571 571 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG, 572 - (rt2x00dev->curr_hwmode == HWMODE_B || 573 - rt2x00dev->curr_hwmode == HWMODE_G)); 572 + (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ)); 574 573 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A, 575 - (rt2x00dev->curr_hwmode == HWMODE_A)); 574 + (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ)); 576 575 577 576 rt73usb_register_write(rt2x00dev, PHY_CSR0, reg); 578 577 ··· 643 644 644 645 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1); 645 646 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS, 646 - (rt2x00dev->rx_status.phymode == MODE_IEEE80211A)); 647 + (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ)); 647 648 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS, 648 - (rt2x00dev->rx_status.phymode != MODE_IEEE80211A)); 649 + (rt2x00dev->rx_status.band != IEEE80211_BAND_5GHZ)); 649 650 650 651 rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, 0x0000, 651 652 rt2x00dev->led_reg, REGISTER_TIMEOUT); ··· 735 736 /* 736 737 * Determine r17 bounds. 737 738 */ 738 - if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { 739 + if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) { 739 740 low_bound = 0x28; 740 741 up_bound = 0x48; 741 742 ··· 1277 1278 rt2x00_desc_write(txd, 2, word); 1278 1279 1279 1280 rt2x00_desc_read(txd, 5, &word); 1281 + /* XXX: removed for now 1280 1282 rt2x00_set_field32(&word, TXD_W5_TX_POWER, 1281 1283 TXPOWER_TO_DEV(control->power_level)); 1284 + */ 1282 1285 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); 1283 1286 rt2x00_desc_write(txd, 5, word); 1284 1287 ··· 1371 1370 return 0; 1372 1371 } 1373 1372 1374 - if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { 1373 + if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) { 1375 1374 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) { 1376 1375 if (lna == 3 || lna == 2) 1377 1376 offset += 10;
+1 -1
drivers/net/wireless/rtl8180.h
··· 102 102 struct rtl8180_tx_ring tx_ring[4]; 103 103 struct ieee80211_channel channels[14]; 104 104 struct ieee80211_rate rates[12]; 105 - struct ieee80211_hw_mode modes[2]; 105 + struct ieee80211_supported_band band; 106 106 struct pci_dev *pdev; 107 107 u32 rx_conf; 108 108
+62 -31
drivers/net/wireless/rtl8180_dev.c
··· 49 49 50 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 87 void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data) 53 88 { 54 89 struct rtl8180_priv *priv = dev->priv; ··· 134 99 /* TODO: improve signal/rssi reporting */ 135 100 rx_status.signal = flags2 & 0xFF; 136 101 rx_status.ssi = (flags2 >> 8) & 0x7F; 137 - rx_status.rate = (flags >> 20) & 0xF; 138 - rx_status.freq = dev->conf.freq; 139 - rx_status.channel = dev->conf.channel; 140 - rx_status.phymode = dev->conf.phymode; 102 + /* XXX: is this correct? */ 103 + rx_status.rate_idx = (flags >> 20) & 0xF; 104 + rx_status.freq = dev->conf.channel->center_freq; 105 + rx_status.band = dev->conf.channel->band; 141 106 rx_status.mactime = le64_to_cpu(entry->tsft); 142 107 rx_status.flag |= RX_FLAG_TSFT; 143 108 if (flags & RTL8180_RX_DESC_FLAG_CRC32_ERR) ··· 258 223 skb->len, PCI_DMA_TODEVICE); 259 224 260 225 tx_flags = RTL8180_TX_DESC_FLAG_OWN | RTL8180_TX_DESC_FLAG_FS | 261 - RTL8180_TX_DESC_FLAG_LS | (control->tx_rate << 24) | 262 - (control->rts_cts_rate << 19) | skb->len; 226 + RTL8180_TX_DESC_FLAG_LS | 227 + (control->tx_rate->hw_value << 24) | 228 + (control->rts_cts_rate->hw_value << 19) | skb->len; 263 229 264 230 if (priv->r8185) 265 231 tx_flags |= RTL8180_TX_DESC_FLAG_DMA | ··· 282 246 unsigned int remainder; 283 247 284 248 plcp_len = DIV_ROUND_UP(16 * (skb->len + 4), 285 - (control->rate->rate * 2) / 10); 249 + (control->tx_rate->bitrate * 2) / 10); 286 250 remainder = (16 * (skb->len + 4)) % 287 - ((control->rate->rate * 2) / 10); 251 + ((control->tx_rate->bitrate * 2) / 10); 288 252 if (remainder > 0 && remainder <= 6) 289 253 plcp_len |= 1 << 15; 290 254 } ··· 297 261 entry->plcp_len = cpu_to_le16(plcp_len); 298 262 entry->tx_buf = cpu_to_le32(mapping); 299 263 entry->frame_len = cpu_to_le32(skb->len); 300 - entry->flags2 = control->alt_retry_rate != -1 ? 301 - control->alt_retry_rate << 4 : 0; 264 + entry->flags2 = control->alt_retry_rate != NULL ? 265 + control->alt_retry_rate->bitrate << 4 : 0; 302 266 entry->retry_limit = control->retry_limit; 303 267 entry->flags = cpu_to_le32(tx_flags); 304 268 __skb_queue_tail(&ring->queue, skb); ··· 874 838 goto err_free_dev; 875 839 } 876 840 841 + BUILD_BUG_ON(sizeof(priv->channels) != sizeof(rtl818x_channels)); 842 + BUILD_BUG_ON(sizeof(priv->rates) != sizeof(rtl818x_rates)); 843 + 877 844 memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); 878 845 memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); 879 - priv->modes[0].mode = MODE_IEEE80211G; 880 - priv->modes[0].num_rates = ARRAY_SIZE(rtl818x_rates); 881 - priv->modes[0].rates = priv->rates; 882 - priv->modes[0].num_channels = ARRAY_SIZE(rtl818x_channels); 883 - priv->modes[0].channels = priv->channels; 884 - priv->modes[1].mode = MODE_IEEE80211B; 885 - priv->modes[1].num_rates = 4; 886 - priv->modes[1].rates = priv->rates; 887 - priv->modes[1].num_channels = ARRAY_SIZE(rtl818x_channels); 888 - priv->modes[1].channels = priv->channels; 889 - priv->mode = IEEE80211_IF_TYPE_INVALID; 846 + 847 + priv->band.band = IEEE80211_BAND_2GHZ; 848 + priv->band.channels = priv->channels; 849 + priv->band.n_channels = ARRAY_SIZE(rtl818x_channels); 850 + priv->band.bitrates = priv->rates; 851 + priv->band.n_bitrates = 4; 852 + dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band; 853 + 890 854 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 891 855 IEEE80211_HW_RX_INCLUDES_FCS; 892 856 dev->queues = 1; ··· 915 879 916 880 priv->r8185 = reg & RTL818X_TX_CONF_R8185_ABC; 917 881 if (priv->r8185) { 918 - if ((err = ieee80211_register_hwmode(dev, &priv->modes[0]))) 919 - goto err_iounmap; 920 - 882 + priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates); 921 883 pci_try_set_mwi(pdev); 922 884 } 923 - 924 - if ((err = ieee80211_register_hwmode(dev, &priv->modes[1]))) 925 - goto err_iounmap; 926 885 927 886 eeprom.data = dev; 928 887 eeprom.register_read = rtl8180_eeprom_register_read; ··· 981 950 for (i = 0; i < 14; i += 2) { 982 951 u16 txpwr; 983 952 eeprom_93cx6_read(&eeprom, 0x10 + (i >> 1), &txpwr); 984 - priv->channels[i].val = txpwr & 0xFF; 985 - priv->channels[i + 1].val = txpwr >> 8; 953 + priv->channels[i].hw_value = txpwr & 0xFF; 954 + priv->channels[i + 1].hw_value = txpwr >> 8; 986 955 } 987 956 988 957 /* OFDM TX power */ ··· 990 959 for (i = 0; i < 14; i += 2) { 991 960 u16 txpwr; 992 961 eeprom_93cx6_read(&eeprom, 0x20 + (i >> 1), &txpwr); 993 - priv->channels[i].val |= (txpwr & 0xFF) << 8; 994 - priv->channels[i + 1].val |= txpwr & 0xFF00; 962 + priv->channels[i].hw_value |= (txpwr & 0xFF) << 8; 963 + priv->channels[i + 1].hw_value |= txpwr & 0xFF00; 995 964 } 996 965 } 997 966
+3 -2
drivers/net/wireless/rtl8180_grf5101.c
··· 73 73 struct ieee80211_conf *conf) 74 74 { 75 75 struct rtl8180_priv *priv = dev->priv; 76 - u32 txpw = priv->channels[conf->channel - 1].val & 0xFF; 77 - u32 chan = conf->channel - 1; 76 + int channel = ieee80211_frequency_to_channel(conf->channel->center_freq); 77 + u32 txpw = priv->channels[channel - 1].hw_value & 0xFF; 78 + u32 chan = channel - 1; 78 79 79 80 /* set TX power */ 80 81 write_grf5101(dev, 0x15, 0x0);
+3 -2
drivers/net/wireless/rtl8180_max2820.c
··· 78 78 struct ieee80211_conf *conf) 79 79 { 80 80 struct rtl8180_priv *priv = dev->priv; 81 - unsigned int chan_idx = conf ? conf->channel - 1 : 0; 82 - u32 txpw = priv->channels[chan_idx].val & 0xFF; 81 + int channel = ieee80211_frequency_to_channel(conf->channel->center_freq); 82 + unsigned int chan_idx = channel - 1; 83 + u32 txpw = priv->channels[chan_idx].hw_value & 0xFF; 83 84 u32 chan = max2820_chan[chan_idx]; 84 85 85 86 /* While philips SA2400 drive the PA bias from
+8 -7
drivers/net/wireless/rtl8180_rtl8225.c
··· 261 261 u32 reg; 262 262 int i; 263 263 264 - cck_power = priv->channels[channel - 1].val & 0xFF; 265 - ofdm_power = priv->channels[channel - 1].val >> 8; 264 + cck_power = priv->channels[channel - 1].hw_value & 0xFF; 265 + ofdm_power = priv->channels[channel - 1].hw_value >> 8; 266 266 267 267 cck_power = min(cck_power, (u8)35); 268 268 ofdm_power = min(ofdm_power, (u8)35); ··· 476 476 const u8 *tmp; 477 477 int i; 478 478 479 - cck_power = priv->channels[channel - 1].val & 0xFF; 480 - ofdm_power = priv->channels[channel - 1].val >> 8; 479 + cck_power = priv->channels[channel - 1].hw_value & 0xFF; 480 + ofdm_power = priv->channels[channel - 1].hw_value >> 8; 481 481 482 482 if (channel == 14) 483 483 tmp = rtl8225z2_tx_power_cck_ch14; ··· 716 716 struct ieee80211_conf *conf) 717 717 { 718 718 struct rtl8180_priv *priv = dev->priv; 719 + int chan = ieee80211_frequency_to_channel(conf->channel->center_freq); 719 720 720 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 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 727 msleep(10); 727 728 728 729 if (conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME) {
+3 -2
drivers/net/wireless/rtl8180_sa2400.c
··· 80 80 struct ieee80211_conf *conf) 81 81 { 82 82 struct rtl8180_priv *priv = dev->priv; 83 - u32 txpw = priv->channels[conf->channel - 1].val & 0xFF; 84 - u32 chan = sa2400_chan[conf->channel - 1]; 83 + int channel = ieee80211_frequency_to_channel(conf->channel->center_freq); 84 + u32 txpw = priv->channels[channel - 1].hw_value & 0xFF; 85 + u32 chan = sa2400_chan[channel - 1]; 85 86 86 87 write_sa2400(dev, 7, txpw); 87 88
+1 -1
drivers/net/wireless/rtl8187.h
··· 71 71 /* rtl8187 specific */ 72 72 struct ieee80211_channel channels[14]; 73 73 struct ieee80211_rate rates[12]; 74 - struct ieee80211_hw_mode modes[2]; 74 + struct ieee80211_supported_band band; 75 75 struct usb_device *udev; 76 76 u32 rx_conf; 77 77 u16 txpwr_base;
+56 -26
drivers/net/wireless/rtl8187_dev.c
··· 45 45 46 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 80 static void rtl8187_iowrite_async_cb(struct urb *urb) 49 81 { 50 82 kfree(urb->context); ··· 178 146 179 147 flags = skb->len; 180 148 flags |= RTL8187_TX_FLAG_NO_ENCRYPT; 181 - flags |= control->rts_cts_rate << 19; 182 - flags |= control->tx_rate << 24; 149 + flags |= control->rts_cts_rate->hw_value << 19; 150 + flags |= control->tx_rate->hw_value << 24; 183 151 if (ieee80211_get_morefrag((struct ieee80211_hdr *)skb->data)) 184 152 flags |= RTL8187_TX_FLAG_MORE_FRAG; 185 153 if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) { ··· 257 225 rx_status.antenna = (hdr->signal >> 7) & 1; 258 226 rx_status.signal = 64 - min(hdr->noise, (u8)64); 259 227 rx_status.ssi = signal; 260 - rx_status.rate = rate; 261 - rx_status.freq = dev->conf.freq; 262 - rx_status.channel = dev->conf.channel; 263 - rx_status.phymode = dev->conf.phymode; 228 + rx_status.rate_idx = rate; 229 + rx_status.freq = dev->conf.channel->center_freq; 230 + rx_status.band = dev->conf.channel->band; 264 231 rx_status.mactime = le64_to_cpu(hdr->mac_time); 265 232 rx_status.flag |= RX_FLAG_TSFT; 266 233 if (flags & (1 << 13)) ··· 713 682 usb_get_dev(udev); 714 683 715 684 skb_queue_head_init(&priv->rx_queue); 685 + 686 + BUILD_BUG_ON(sizeof(priv->channels) != sizeof(rtl818x_channels)); 687 + BUILD_BUG_ON(sizeof(priv->rates) != sizeof(rtl818x_rates)); 688 + 716 689 memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); 717 690 memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); 718 691 priv->map = (struct rtl818x_csr *)0xFF00; 719 - priv->modes[0].mode = MODE_IEEE80211G; 720 - priv->modes[0].num_rates = ARRAY_SIZE(rtl818x_rates); 721 - priv->modes[0].rates = priv->rates; 722 - priv->modes[0].num_channels = ARRAY_SIZE(rtl818x_channels); 723 - priv->modes[0].channels = priv->channels; 724 - priv->modes[1].mode = MODE_IEEE80211B; 725 - priv->modes[1].num_rates = 4; 726 - priv->modes[1].rates = priv->rates; 727 - priv->modes[1].num_channels = ARRAY_SIZE(rtl818x_channels); 728 - priv->modes[1].channels = priv->channels; 692 + 693 + priv->band.band = IEEE80211_BAND_2GHZ; 694 + priv->band.channels = priv->channels; 695 + priv->band.n_channels = ARRAY_SIZE(rtl818x_channels); 696 + priv->band.bitrates = priv->rates; 697 + priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates); 698 + dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band; 699 + 700 + 729 701 priv->mode = IEEE80211_IF_TYPE_MNTR; 730 702 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 731 703 IEEE80211_HW_RX_INCLUDES_FCS; ··· 736 702 dev->queues = 1; 737 703 dev->max_rssi = 65; 738 704 dev->max_signal = 64; 739 - 740 - for (i = 0; i < 2; i++) 741 - if ((err = ieee80211_register_hwmode(dev, &priv->modes[i]))) 742 - goto err_free_dev; 743 705 744 706 eeprom.data = dev; 745 707 eeprom.register_read = rtl8187_eeprom_register_read; ··· 760 730 for (i = 0; i < 3; i++) { 761 731 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_1 + i, 762 732 &txpwr); 763 - (*channel++).val = txpwr & 0xFF; 764 - (*channel++).val = txpwr >> 8; 733 + (*channel++).hw_value = txpwr & 0xFF; 734 + (*channel++).hw_value = txpwr >> 8; 765 735 } 766 736 for (i = 0; i < 2; i++) { 767 737 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_4 + i, 768 738 &txpwr); 769 - (*channel++).val = txpwr & 0xFF; 770 - (*channel++).val = txpwr >> 8; 739 + (*channel++).hw_value = txpwr & 0xFF; 740 + (*channel++).hw_value = txpwr >> 8; 771 741 } 772 742 for (i = 0; i < 2; i++) { 773 743 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_6 + i, 774 744 &txpwr); 775 - (*channel++).val = txpwr & 0xFF; 776 - (*channel++).val = txpwr >> 8; 745 + (*channel++).hw_value = txpwr & 0xFF; 746 + (*channel++).hw_value = txpwr >> 8; 777 747 } 778 748 779 749 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_BASE,
+8 -7
drivers/net/wireless/rtl8187_rtl8225.c
··· 283 283 u32 reg; 284 284 int i; 285 285 286 - cck_power = priv->channels[channel - 1].val & 0xF; 287 - ofdm_power = priv->channels[channel - 1].val >> 4; 286 + cck_power = priv->channels[channel - 1].hw_value & 0xF; 287 + ofdm_power = priv->channels[channel - 1].hw_value >> 4; 288 288 289 289 cck_power = min(cck_power, (u8)11); 290 290 ofdm_power = min(ofdm_power, (u8)35); ··· 500 500 u32 reg; 501 501 int i; 502 502 503 - cck_power = priv->channels[channel - 1].val & 0xF; 504 - ofdm_power = priv->channels[channel - 1].val >> 4; 503 + cck_power = priv->channels[channel - 1].hw_value & 0xF; 504 + ofdm_power = priv->channels[channel - 1].hw_value >> 4; 505 505 506 506 cck_power = min(cck_power, (u8)15); 507 507 cck_power += priv->txpwr_base & 0xF; ··· 735 735 struct ieee80211_conf *conf) 736 736 { 737 737 struct rtl8187_priv *priv = dev->priv; 738 + int chan = ieee80211_frequency_to_channel(conf->channel->center_freq); 738 739 739 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 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 746 msleep(10); 746 747 } 747 748
-70
drivers/net/wireless/rtl818x.h
··· 175 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 178 #endif /* RTL818X_H */
+5 -10
drivers/net/wireless/zd1211rw/zd_chip.c
··· 986 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 991 u32 rates; 992 992 ZD_ASSERT(mutex_is_locked(&chip->mutex)); ··· 994 994 * that the device is supporting. Until further notice we should try 995 995 * to support 802.11g also for full speed USB. 996 996 */ 997 - switch (mode) { 998 - case MODE_IEEE80211B: 997 + if (!gmode) 999 998 rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M; 1000 - break; 1001 - case MODE_IEEE80211G: 999 + else 1002 1000 rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M| 1003 1001 CR_RATE_6M|CR_RATE_12M|CR_RATE_24M; 1004 - break; 1005 - default: 1006 - return -EINVAL; 1007 - } 1002 + 1008 1003 return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL); 1009 1004 } 1010 1005 ··· 1103 1108 * It might be discussed, whether we should suppport pure b mode for 1104 1109 * full speed USB. 1105 1110 */ 1106 - r = set_mandatory_rates(chip, MODE_IEEE80211G); 1111 + r = set_mandatory_rates(chip, 1); 1107 1112 if (r) 1108 1113 goto out; 1109 1114 /* Disabling interrupts is certainly a smart thing here.
+4 -7
drivers/net/wireless/zd1211rw/zd_ieee80211.c
··· 65 65 66 66 static void unmask_bg_channels(struct ieee80211_hw *hw, 67 67 const struct channel_range *range, 68 - struct ieee80211_hw_mode *mode) 68 + struct ieee80211_supported_band *sband) 69 69 { 70 70 u8 channel; 71 71 72 72 for (channel = range->start; channel < range->end; channel++) { 73 73 struct ieee80211_channel *chan = 74 - &mode->channels[CHAN_TO_IDX(channel)]; 75 - chan->flag |= IEEE80211_CHAN_W_SCAN | 76 - IEEE80211_CHAN_W_ACTIVE_SCAN | 77 - IEEE80211_CHAN_W_IBSS; 74 + &sband->channels[CHAN_TO_IDX(channel)]; 75 + chan->flags = 0; 78 76 } 79 77 } 80 78 ··· 95 97 range = zd_channel_range(ZD_REGDOMAIN_FCC); 96 98 } 97 99 98 - unmask_bg_channels(hw, range, &mac->modes[0]); 99 - unmask_bg_channels(hw, range, &mac->modes[1]); 100 + unmask_bg_channels(hw, range, &mac->band); 100 101 } 101 102
+74 -94
drivers/net/wireless/zd1211rw/zd_mac.c
··· 34 34 35 35 /* This table contains the hardware specific values for the modulation rates. */ 36 36 static const struct ieee80211_rate zd_rates[] = { 37 - { .rate = 10, 38 - .val = ZD_CCK_RATE_1M, 39 - .flags = IEEE80211_RATE_CCK }, 40 - { .rate = 20, 41 - .val = ZD_CCK_RATE_2M, 42 - .val2 = ZD_CCK_RATE_2M | ZD_CCK_PREA_SHORT, 43 - .flags = IEEE80211_RATE_CCK_2 }, 44 - { .rate = 55, 45 - .val = ZD_CCK_RATE_5_5M, 46 - .val2 = ZD_CCK_RATE_5_5M | ZD_CCK_PREA_SHORT, 47 - .flags = IEEE80211_RATE_CCK_2 }, 48 - { .rate = 110, 49 - .val = ZD_CCK_RATE_11M, 50 - .val2 = ZD_CCK_RATE_11M | ZD_CCK_PREA_SHORT, 51 - .flags = IEEE80211_RATE_CCK_2 }, 52 - { .rate = 60, 53 - .val = ZD_OFDM_RATE_6M, 54 - .flags = IEEE80211_RATE_OFDM }, 55 - { .rate = 90, 56 - .val = ZD_OFDM_RATE_9M, 57 - .flags = IEEE80211_RATE_OFDM }, 58 - { .rate = 120, 59 - .val = ZD_OFDM_RATE_12M, 60 - .flags = IEEE80211_RATE_OFDM }, 61 - { .rate = 180, 62 - .val = ZD_OFDM_RATE_18M, 63 - .flags = IEEE80211_RATE_OFDM }, 64 - { .rate = 240, 65 - .val = ZD_OFDM_RATE_24M, 66 - .flags = IEEE80211_RATE_OFDM }, 67 - { .rate = 360, 68 - .val = ZD_OFDM_RATE_36M, 69 - .flags = IEEE80211_RATE_OFDM }, 70 - { .rate = 480, 71 - .val = ZD_OFDM_RATE_48M, 72 - .flags = IEEE80211_RATE_OFDM }, 73 - { .rate = 540, 74 - .val = ZD_OFDM_RATE_54M, 75 - .flags = IEEE80211_RATE_OFDM }, 37 + { .bitrate = 10, 38 + .hw_value = ZD_CCK_RATE_1M, }, 39 + { .bitrate = 20, 40 + .hw_value = ZD_CCK_RATE_2M, 41 + .hw_value_short = ZD_CCK_RATE_2M | ZD_CCK_PREA_SHORT, 42 + .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 43 + { .bitrate = 55, 44 + .hw_value = ZD_CCK_RATE_5_5M, 45 + .hw_value_short = ZD_CCK_RATE_5_5M | ZD_CCK_PREA_SHORT, 46 + .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 47 + { .bitrate = 110, 48 + .hw_value = ZD_CCK_RATE_11M, 49 + .hw_value_short = ZD_CCK_RATE_11M | ZD_CCK_PREA_SHORT, 50 + .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 51 + { .bitrate = 60, 52 + .hw_value = ZD_OFDM_RATE_6M, 53 + .flags = 0 }, 54 + { .bitrate = 90, 55 + .hw_value = ZD_OFDM_RATE_9M, 56 + .flags = 0 }, 57 + { .bitrate = 120, 58 + .hw_value = ZD_OFDM_RATE_12M, 59 + .flags = 0 }, 60 + { .bitrate = 180, 61 + .hw_value = ZD_OFDM_RATE_18M, 62 + .flags = 0 }, 63 + { .bitrate = 240, 64 + .hw_value = ZD_OFDM_RATE_24M, 65 + .flags = 0 }, 66 + { .bitrate = 360, 67 + .hw_value = ZD_OFDM_RATE_36M, 68 + .flags = 0 }, 69 + { .bitrate = 480, 70 + .hw_value = ZD_OFDM_RATE_48M, 71 + .flags = 0 }, 72 + { .bitrate = 540, 73 + .hw_value = ZD_OFDM_RATE_54M, 74 + .flags = 0 }, 76 75 }; 77 76 78 77 static const struct ieee80211_channel zd_channels[] = { 79 - { .chan = 1, 80 - .freq = 2412}, 81 - { .chan = 2, 82 - .freq = 2417}, 83 - { .chan = 3, 84 - .freq = 2422}, 85 - { .chan = 4, 86 - .freq = 2427}, 87 - { .chan = 5, 88 - .freq = 2432}, 89 - { .chan = 6, 90 - .freq = 2437}, 91 - { .chan = 7, 92 - .freq = 2442}, 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} 78 + { .center_freq = 2412, .hw_value = 1 }, 79 + { .center_freq = 2417, .hw_value = 2 }, 80 + { .center_freq = 2422, .hw_value = 3 }, 81 + { .center_freq = 2427, .hw_value = 4 }, 82 + { .center_freq = 2432, .hw_value = 5 }, 83 + { .center_freq = 2437, .hw_value = 6 }, 84 + { .center_freq = 2442, .hw_value = 7 }, 85 + { .center_freq = 2447, .hw_value = 8 }, 86 + { .center_freq = 2452, .hw_value = 9 }, 87 + { .center_freq = 2457, .hw_value = 10 }, 88 + { .center_freq = 2462, .hw_value = 11 }, 89 + { .center_freq = 2467, .hw_value = 12 }, 90 + { .center_freq = 2472, .hw_value = 13 }, 91 + { .center_freq = 2484, .hw_value = 14 }, 107 92 }; 108 93 109 94 static void housekeeping_init(struct zd_mac *mac); ··· 488 503 489 504 ZD_ASSERT(frag_len <= 0xffff); 490 505 491 - cs->modulation = control->tx_rate; 506 + cs->modulation = control->tx_rate->hw_value; 507 + if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) 508 + cs->modulation = control->tx_rate->hw_value_short; 492 509 493 510 cs->tx_length = cpu_to_le16(frag_len); 494 511 ··· 618 631 int bad_frame = 0; 619 632 u16 fc; 620 633 bool is_qos, is_4addr, need_padding; 634 + int i; 635 + u8 rate; 621 636 622 637 if (length < ZD_PLCP_HEADER_SIZE + 10 /* IEEE80211_1ADDR_LEN */ + 623 638 FCS_LEN + sizeof(struct rx_status)) ··· 649 660 } 650 661 } 651 662 652 - stats.channel = _zd_chip_get_channel(&mac->chip); 653 - stats.freq = zd_channels[stats.channel - 1].freq; 654 - stats.phymode = MODE_IEEE80211G; 663 + stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; 664 + stats.band = IEEE80211_BAND_2GHZ; 655 665 stats.ssi = status->signal_strength; 656 666 stats.signal = zd_rx_qual_percent(buffer, 657 667 length - sizeof(struct rx_status), 658 668 status); 659 - stats.rate = zd_rx_rate(buffer, status); 669 + 670 + rate = zd_rx_rate(buffer, status); 671 + 672 + /* todo: return index in the big switches in zd_rx_rate instead */ 673 + for (i = 0; i < mac->band.n_bitrates; i++) 674 + if (rate == mac->band.bitrates[i].hw_value) 675 + stats.rate_idx = i; 660 676 661 677 length -= ZD_PLCP_HEADER_SIZE + sizeof(struct rx_status); 662 678 buffer += ZD_PLCP_HEADER_SIZE; ··· 730 736 static int zd_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 731 737 { 732 738 struct zd_mac *mac = zd_hw_mac(hw); 733 - return zd_chip_set_channel(&mac->chip, conf->channel); 739 + return zd_chip_set_channel(&mac->chip, conf->channel->hw_value); 734 740 } 735 741 736 742 static int zd_op_config_interface(struct ieee80211_hw *hw, ··· 888 894 { 889 895 struct zd_mac *mac; 890 896 struct ieee80211_hw *hw; 891 - int i; 892 897 893 898 hw = ieee80211_alloc_hw(sizeof(struct zd_mac), &zd_ops); 894 899 if (!hw) { ··· 905 912 906 913 memcpy(mac->channels, zd_channels, sizeof(zd_channels)); 907 914 memcpy(mac->rates, zd_rates, sizeof(zd_rates)); 908 - mac->modes[0].mode = MODE_IEEE80211G; 909 - mac->modes[0].num_rates = ARRAY_SIZE(zd_rates); 910 - mac->modes[0].rates = mac->rates; 911 - mac->modes[0].num_channels = ARRAY_SIZE(zd_channels); 912 - mac->modes[0].channels = mac->channels; 913 - mac->modes[1].mode = MODE_IEEE80211B; 914 - mac->modes[1].num_rates = 4; 915 - mac->modes[1].rates = mac->rates; 916 - mac->modes[1].num_channels = ARRAY_SIZE(zd_channels); 917 - mac->modes[1].channels = mac->channels; 915 + mac->band.n_bitrates = ARRAY_SIZE(zd_rates); 916 + mac->band.bitrates = mac->rates; 917 + mac->band.n_channels = ARRAY_SIZE(zd_channels); 918 + mac->band.channels = mac->channels; 918 919 919 - hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 920 - IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED; 920 + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; 921 + 922 + hw->flags = IEEE80211_HW_RX_INCLUDES_FCS; 921 923 hw->max_rssi = 100; 922 924 hw->max_signal = 100; 923 925 ··· 920 932 hw->extra_tx_headroom = sizeof(struct zd_ctrlset); 921 933 922 934 skb_queue_head_init(&mac->ack_wait_queue); 923 - 924 - for (i = 0; i < 2; i++) { 925 - if (ieee80211_register_hwmode(hw, &mac->modes[i])) { 926 - dev_dbg_f(&intf->dev, "cannot register hwmode\n"); 927 - ieee80211_free_hw(hw); 928 - return NULL; 929 - } 930 - } 931 935 932 936 zd_chip_init(&mac->chip, hw, intf); 933 937 housekeeping_init(mac);
+1 -1
drivers/net/wireless/zd1211rw/zd_mac.h
··· 185 185 struct sk_buff_head ack_wait_queue; 186 186 struct ieee80211_channel channels[14]; 187 187 struct ieee80211_rate rates[12]; 188 - struct ieee80211_hw_mode modes[2]; 188 + struct ieee80211_supported_band band; 189 189 190 190 /* Short preamble (used for RTS/CTS) */ 191 191 unsigned int short_preamble:1;
+34 -163
include/net/mac80211.h
··· 69 69 * not do so then mac80211 may add this under certain circumstances. 70 70 */ 71 71 72 - #define IEEE80211_CHAN_W_SCAN 0x00000001 73 - #define IEEE80211_CHAN_W_ACTIVE_SCAN 0x00000002 74 - #define IEEE80211_CHAN_W_IBSS 0x00000004 75 - 76 - /* Channel information structure. Low-level driver is expected to fill in chan, 77 - * freq, and val fields. Other fields will be filled in by 80211.o based on 78 - * hostapd information and low-level driver does not need to use them. The 79 - * limits for each channel will be provided in 'struct ieee80211_conf' when 80 - * configuring the low-level driver with hw->config callback. If a device has 81 - * a default regulatory domain, IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED 82 - * can be set to let the driver configure all fields */ 83 - struct ieee80211_channel { 84 - short chan; /* channel number (IEEE 802.11) */ 85 - short freq; /* frequency in MHz */ 86 - int val; /* hw specific value for the channel */ 87 - int flag; /* flag for hostapd use (IEEE80211_CHAN_*) */ 88 - unsigned char power_level; 89 - unsigned char antenna_max; 90 - }; 91 - 92 - #define IEEE80211_RATE_ERP 0x00000001 93 - #define IEEE80211_RATE_BASIC 0x00000002 94 - #define IEEE80211_RATE_PREAMBLE2 0x00000004 95 - #define IEEE80211_RATE_SUPPORTED 0x00000010 96 - #define IEEE80211_RATE_OFDM 0x00000020 97 - #define IEEE80211_RATE_CCK 0x00000040 98 - #define IEEE80211_RATE_MANDATORY 0x00000100 99 - 100 - #define IEEE80211_RATE_CCK_2 (IEEE80211_RATE_CCK | IEEE80211_RATE_PREAMBLE2) 101 - #define IEEE80211_RATE_MODULATION(f) \ 102 - (f & (IEEE80211_RATE_CCK | IEEE80211_RATE_OFDM)) 103 - 104 - /* Low-level driver should set PREAMBLE2, OFDM and CCK flags. 105 - * BASIC, SUPPORTED, ERP, and MANDATORY flags are set in 80211.o based on the 106 - * configuration. */ 107 - struct ieee80211_rate { 108 - int rate; /* rate in 100 kbps */ 109 - int val; /* hw specific value for the rate */ 110 - int flags; /* IEEE80211_RATE_ flags */ 111 - int val2; /* hw specific value for the rate when using short preamble 112 - * (only when IEEE80211_RATE_PREAMBLE2 flag is set, i.e., for 113 - * 2, 5.5, and 11 Mbps) */ 114 - signed char min_rssi_ack; 115 - unsigned char min_rssi_ack_delta; 116 - 117 - /* following fields are set by 80211.o and need not be filled by the 118 - * low-level driver */ 119 - int rate_inv; /* inverse of the rate (LCM(all rates) / rate) for 120 - * optimizing channel utilization estimates */ 121 - }; 122 - 123 - /** 124 - * enum ieee80211_phymode - PHY modes 125 - * 126 - * @MODE_IEEE80211A: 5GHz as defined by 802.11a/802.11h 127 - * @MODE_IEEE80211B: 2.4 GHz as defined by 802.11b 128 - * @MODE_IEEE80211G: 2.4 GHz as defined by 802.11g (with OFDM), 129 - * backwards compatible with 11b mode 130 - * @NUM_IEEE80211_MODES: internal 131 - */ 132 - enum ieee80211_phymode { 133 - MODE_IEEE80211A, 134 - MODE_IEEE80211B, 135 - MODE_IEEE80211G, 136 - 137 - /* keep last */ 138 - NUM_IEEE80211_MODES 139 - }; 140 - 141 - /** 142 - * struct ieee80211_ht_info - describing STA's HT capabilities 143 - * 144 - * This structure describes most essential parameters needed 145 - * to describe 802.11n HT capabilities for an STA. 146 - * 147 - * @ht_supported: is HT supported by STA, 0: no, 1: yes 148 - * @cap: HT capabilities map as described in 802.11n spec 149 - * @ampdu_factor: Maximum A-MPDU length factor 150 - * @ampdu_density: Minimum A-MPDU spacing 151 - * @supp_mcs_set: Supported MCS set as described in 802.11n spec 152 - */ 153 - struct ieee80211_ht_info { 154 - u8 ht_supported; 155 - u16 cap; /* use IEEE80211_HT_CAP_ */ 156 - u8 ampdu_factor; 157 - u8 ampdu_density; 158 - u8 supp_mcs_set[16]; 159 - }; 160 - 161 72 /** 162 73 * struct ieee80211_ht_bss_info - describing BSS's HT characteristics 163 74 * ··· 83 172 u8 primary_channel; 84 173 u8 bss_cap; /* use IEEE80211_HT_IE_CHA_ */ 85 174 u8 bss_op_mode; /* use IEEE80211_HT_IE_ */ 86 - }; 87 - 88 - /** 89 - * struct ieee80211_hw_mode - PHY mode definition 90 - * 91 - * This structure describes the capabilities supported by the device 92 - * in a single PHY mode. 93 - * 94 - * @list: internal 95 - * @channels: pointer to array of supported channels 96 - * @rates: pointer to array of supported bitrates 97 - * @mode: the PHY mode for this definition 98 - * @num_channels: number of supported channels 99 - * @num_rates: number of supported bitrates 100 - * @ht_info: PHY's 802.11n HT abilities for this mode 101 - */ 102 - struct ieee80211_hw_mode { 103 - struct list_head list; 104 - struct ieee80211_channel *channels; 105 - struct ieee80211_rate *rates; 106 - enum ieee80211_phymode mode; 107 - int num_channels; 108 - int num_rates; 109 - struct ieee80211_ht_info ht_info; 110 175 }; 111 176 112 177 /** ··· 207 320 208 321 struct ieee80211_tx_control { 209 322 struct ieee80211_vif *vif; 210 - int tx_rate; /* Transmit rate, given as the hw specific value for the 211 - * rate (from struct ieee80211_rate) */ 212 - int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw 213 - * specific value for the rate (from 214 - * struct ieee80211_rate) */ 323 + struct ieee80211_rate *tx_rate; 324 + 325 + /* Transmit rate for RTS/CTS frame */ 326 + struct ieee80211_rate *rts_cts_rate; 327 + 328 + /* retry rate for the last retries */ 329 + struct ieee80211_rate *alt_retry_rate; 215 330 216 331 #define IEEE80211_TXCTL_REQ_TX_STATUS (1<<0)/* request TX status callback for 217 332 * this frame */ ··· 232 343 #define IEEE80211_TXCTL_REQUEUE (1<<7) 233 344 #define IEEE80211_TXCTL_FIRST_FRAGMENT (1<<8) /* this is a first fragment of 234 345 * the frame */ 346 + #define IEEE80211_TXCTL_SHORT_PREAMBLE (1<<9) 235 347 #define IEEE80211_TXCTL_LONG_RETRY_LIMIT (1<<10) /* this frame should be send 236 348 * using the through 237 349 * set_retry_limit configured ··· 249 359 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, .. 250 360 * This could be used when set_retry_limit 251 361 * is not implemented by the driver */ 252 - u8 power_level; /* per-packet transmit power level, in dBm */ 253 362 u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */ 254 363 u8 icv_len; /* length of the ICV/MIC field in octets */ 255 364 u8 iv_len; /* length of the IV field in octets */ 256 365 u8 queue; /* hardware queue to use for this frame; 257 366 * 0 = highest, hw->queues-1 = lowest */ 258 - struct ieee80211_rate *rate; /* internal 80211.o rate */ 259 - struct ieee80211_rate *rts_rate; /* internal 80211.o rate 260 - * for RTS/CTS */ 261 - int alt_retry_rate; /* retry rate for the last retries, given as the 262 - * hw specific value for the rate (from 263 - * struct ieee80211_rate). To be used to limit 264 - * packet dropping when probing higher rates, if hw 265 - * supports multiple retry rates. -1 = not used */ 266 367 int type; /* internal */ 267 368 }; 268 369 ··· 296 415 * supported by hardware) to the 802.11 code with each received 297 416 * frame. 298 417 * @mactime: MAC timestamp as defined by 802.11 418 + * @band: the active band when this frame was received 299 419 * @freq: frequency the radio was tuned to when receiving this frame, in MHz 300 - * @channel: channel the radio was tuned to 301 - * @phymode: active PHY mode 302 420 * @ssi: signal strength when receiving this frame 303 421 * @signal: used as 'qual' in statistics reporting 304 422 * @noise: PHY noise when receiving this frame 305 423 * @antenna: antenna used 306 - * @rate: data rate 424 + * @rate_idx: index of data rate into band's supported rates 307 425 * @flag: %RX_FLAG_* 308 426 */ 309 427 struct ieee80211_rx_status { 310 428 u64 mactime; 429 + enum ieee80211_band band; 311 430 int freq; 312 - int channel; 313 - enum ieee80211_phymode phymode; 314 431 int ssi; 315 432 int signal; 316 433 int noise; 317 434 int antenna; 318 - int rate; 435 + int rate_idx; 319 436 int flag; 320 437 }; 321 438 ··· 388 509 * 389 510 * @radio_enabled: when zero, driver is required to switch off the radio. 390 511 * TODO make a flag 391 - * @channel: IEEE 802.11 channel number 392 - * @freq: frequency in MHz 393 - * @channel_val: hardware specific channel value for the channel 394 - * @phymode: PHY mode to activate (REMOVE) 395 - * @chan: channel to switch to, pointer to the channel information 396 - * @mode: pointer to mode definition 397 - * @regulatory_domain: ?? 398 512 * @beacon_int: beacon interval (TODO make interface config) 399 513 * @flags: configuration flags defined above 400 - * @power_level: transmit power limit for current regulatory domain in dBm 401 - * @antenna_max: maximum antenna gain 514 + * @power_level: requested transmit power (in dBm) 515 + * @max_antenna_gain: maximum antenna gain (in dBi) 402 516 * @antenna_sel_tx: transmit antenna selection, 0: default/diversity, 403 517 * 1/2: antenna 0/1 404 518 * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx 405 519 * @ht_conf: describes current self configuration of 802.11n HT capabilies 406 520 * @ht_bss_conf: describes current BSS configuration of 802.11n HT parameters 521 + * @channel: the channel to tune to 407 522 */ 408 523 struct ieee80211_conf { 409 - int channel; /* IEEE 802.11 channel number */ 410 - int freq; /* MHz */ 411 - int channel_val; /* hw specific value for the channel */ 412 - 413 - enum ieee80211_phymode phymode; 414 - struct ieee80211_channel *chan; 415 - struct ieee80211_hw_mode *mode; 416 524 unsigned int regulatory_domain; 417 525 int radio_enabled; 418 526 419 527 int beacon_int; 420 528 u32 flags; 421 - u8 power_level; 422 - u8 antenna_max; 529 + int power_level; 530 + int max_antenna_gain; 423 531 u8 antenna_sel_tx; 424 532 u8 antenna_sel_rx; 533 + 534 + struct ieee80211_channel *channel; 425 535 426 536 struct ieee80211_ht_info ht_conf; 427 537 struct ieee80211_ht_bss_info ht_bss_conf; ··· 632 764 * %IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE is also not set because 633 765 * otherwise the stack will not know when the DTIM beacon was sent. 634 766 * 635 - * @IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED: 636 - * Channels are already configured to the default regulatory domain 637 - * specified in the device's EEPROM 767 + * @IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE: 768 + * Hardware is not capable of short slot operation on the 2.4 GHz band. 769 + * 770 + * @IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE: 771 + * Hardware is not capable of receiving frames with short preamble on 772 + * the 2.4 GHz band. 638 773 */ 639 774 enum ieee80211_hw_flags { 640 775 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE = 1<<0, 641 776 IEEE80211_HW_RX_INCLUDES_FCS = 1<<1, 642 777 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 1<<2, 643 - IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED = 1<<3, 778 + IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE = 1<<3, 779 + IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE = 1<<4, 644 780 }; 645 781 646 782 /** ··· 656 784 * @wiphy: This points to the &struct wiphy allocated for this 657 785 * 802.11 PHY. You must fill in the @perm_addr and @dev 658 786 * members of this structure using SET_IEEE80211_DEV() 659 - * and SET_IEEE80211_PERM_ADDR(). 787 + * and SET_IEEE80211_PERM_ADDR(). Additionally, all supported 788 + * bands (with channels, bitrates) are registered here. 660 789 * 661 790 * @conf: &struct ieee80211_conf, device configuration, don't use. 662 791 * ··· 935 1062 * given local_address is enabled. 936 1063 * 937 1064 * @hw_scan: Ask the hardware to service the scan request, no need to start 938 - * the scan state machine in stack. 1065 + * the scan state machine in stack. The scan must honour the channel 1066 + * configuration done by the regulatory agent in the wiphy's registered 1067 + * bands. 939 1068 * 940 1069 * @get_stats: return low-level statistics 941 1070 * ··· 1159 1284 #endif 1160 1285 } 1161 1286 1162 - /* Register a new hardware PHYMODE capability to the stack. */ 1163 - int ieee80211_register_hwmode(struct ieee80211_hw *hw, 1164 - struct ieee80211_hw_mode *mode); 1165 - 1166 1287 /** 1167 1288 * ieee80211_unregister_hw - Unregister a hardware device 1168 1289 * ··· 1332 1461 * @hw: pointer obtained from ieee80211_alloc_hw(). 1333 1462 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. 1334 1463 * @frame_len: the length of the frame. 1335 - * @rate: the rate (in 100kbps) at which the frame is going to be transmitted. 1464 + * @rate: the rate at which the frame is going to be transmitted. 1336 1465 * 1337 1466 * Calculate the duration field of some generic frame, given its 1338 1467 * length and transmission rate (in 100kbps). ··· 1340 1469 __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, 1341 1470 struct ieee80211_vif *vif, 1342 1471 size_t frame_len, 1343 - int rate); 1472 + struct ieee80211_rate *rate); 1344 1473 1345 1474 /** 1346 1475 * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
+168
include/net/wireless.h
··· 13 13 #include <net/cfg80211.h> 14 14 15 15 /** 16 + * enum ieee80211_band - supported frequency bands 17 + * 18 + * The bands are assigned this way because the supported 19 + * bitrates differ in these bands. 20 + * 21 + * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band 22 + * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7) 23 + */ 24 + enum ieee80211_band { 25 + IEEE80211_BAND_2GHZ, 26 + IEEE80211_BAND_5GHZ, 27 + 28 + /* keep last */ 29 + IEEE80211_NUM_BANDS 30 + }; 31 + 32 + /** 33 + * enum ieee80211_channel_flags - channel flags 34 + * 35 + * Channel flags set by the regulatory control code. 36 + * 37 + * @IEEE80211_CHAN_DISABLED: This channel is disabled. 38 + * @IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted 39 + * on this channel. 40 + * @IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel. 41 + * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel. 42 + */ 43 + enum ieee80211_channel_flags { 44 + IEEE80211_CHAN_DISABLED = 1<<0, 45 + IEEE80211_CHAN_PASSIVE_SCAN = 1<<1, 46 + IEEE80211_CHAN_NO_IBSS = 1<<2, 47 + IEEE80211_CHAN_RADAR = 1<<3, 48 + }; 49 + 50 + /** 51 + * struct ieee80211_channel - channel definition 52 + * 53 + * This structure describes a single channel for use 54 + * with cfg80211. 55 + * 56 + * @center_freq: center frequency in MHz 57 + * @hw_value: hardware-specific value for the channel 58 + * @flags: channel flags from &enum ieee80211_channel_flags. 59 + * @orig_flags: channel flags at registration time, used by regulatory 60 + * code to support devices with additional restrictions 61 + * @band: band this channel belongs to. 62 + * @max_antenna_gain: maximum antenna gain in dBi 63 + * @max_power: maximum transmission power (in dBm) 64 + * @orig_mag: internal use 65 + * @orig_mpwr: internal use 66 + */ 67 + struct ieee80211_channel { 68 + enum ieee80211_band band; 69 + u16 center_freq; 70 + u16 hw_value; 71 + u32 flags; 72 + int max_antenna_gain; 73 + int max_power; 74 + u32 orig_flags; 75 + int orig_mag, orig_mpwr; 76 + }; 77 + 78 + /** 79 + * enum ieee80211_rate_flags - rate flags 80 + * 81 + * Hardware/specification flags for rates. These are structured 82 + * in a way that allows using the same bitrate structure for 83 + * different bands/PHY modes. 84 + * 85 + * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short 86 + * preamble on this bitrate; only relevant in 2.4GHz band and 87 + * with CCK rates. 88 + * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate 89 + * when used with 802.11a (on the 5 GHz band); filled by the 90 + * core code when registering the wiphy. 91 + * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate 92 + * when used with 802.11b (on the 2.4 GHz band); filled by the 93 + * core code when registering the wiphy. 94 + * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate 95 + * when used with 802.11g (on the 2.4 GHz band); filled by the 96 + * core code when registering the wiphy. 97 + * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode. 98 + */ 99 + enum ieee80211_rate_flags { 100 + IEEE80211_RATE_SHORT_PREAMBLE = 1<<0, 101 + IEEE80211_RATE_MANDATORY_A = 1<<1, 102 + IEEE80211_RATE_MANDATORY_B = 1<<2, 103 + IEEE80211_RATE_MANDATORY_G = 1<<3, 104 + IEEE80211_RATE_ERP_G = 1<<4, 105 + }; 106 + 107 + /** 108 + * struct ieee80211_rate - bitrate definition 109 + * 110 + * This structure describes a bitrate that an 802.11 PHY can 111 + * operate with. The two values @hw_value and @hw_value_short 112 + * are only for driver use when pointers to this structure are 113 + * passed around. 114 + * 115 + * @flags: rate-specific flags 116 + * @bitrate: bitrate in units of 100 Kbps 117 + * @hw_value: driver/hardware value for this rate 118 + * @hw_value_short: driver/hardware value for this rate when 119 + * short preamble is used 120 + */ 121 + struct ieee80211_rate { 122 + u32 flags; 123 + u16 bitrate; 124 + u16 hw_value, hw_value_short; 125 + }; 126 + 127 + /** 128 + * struct ieee80211_ht_info - describing STA's HT capabilities 129 + * 130 + * This structure describes most essential parameters needed 131 + * to describe 802.11n HT capabilities for an STA. 132 + * 133 + * @ht_supported: is HT supported by STA, 0: no, 1: yes 134 + * @cap: HT capabilities map as described in 802.11n spec 135 + * @ampdu_factor: Maximum A-MPDU length factor 136 + * @ampdu_density: Minimum A-MPDU spacing 137 + * @supp_mcs_set: Supported MCS set as described in 802.11n spec 138 + */ 139 + struct ieee80211_ht_info { 140 + u16 cap; /* use IEEE80211_HT_CAP_ */ 141 + u8 ht_supported; 142 + u8 ampdu_factor; 143 + u8 ampdu_density; 144 + u8 supp_mcs_set[16]; 145 + }; 146 + 147 + /** 148 + * struct ieee80211_supported_band - frequency band definition 149 + * 150 + * This structure describes a frequency band a wiphy 151 + * is able to operate in. 152 + * 153 + * @channels: Array of channels the hardware can operate in 154 + * in this band. 155 + * @band: the band this structure represents 156 + * @n_channels: Number of channels in @channels 157 + * @bitrates: Array of bitrates the hardware can operate with 158 + * in this band. Must be sorted to give a valid "supported 159 + * rates" IE, i.e. CCK rates first, then OFDM. 160 + * @n_bitrates: Number of bitrates in @bitrates 161 + */ 162 + struct ieee80211_supported_band { 163 + struct ieee80211_channel *channels; 164 + struct ieee80211_rate *bitrates; 165 + enum ieee80211_band band; 166 + int n_channels; 167 + int n_bitrates; 168 + struct ieee80211_ht_info ht_info; 169 + }; 170 + 171 + /** 16 172 * struct wiphy - wireless hardware description 17 173 * @idx: the wiphy index assigned to this item 18 174 * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name> ··· 185 29 * or not. Assign this to something global to your driver to 186 30 * help determine whether you own this wiphy or not. */ 187 31 void *privid; 32 + 33 + struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS]; 188 34 189 35 /* fields below are read-only, assigned by cfg80211 */ 190 36 ··· 293 135 * wiphy_free - free wiphy 294 136 */ 295 137 extern void wiphy_free(struct wiphy *wiphy); 138 + 139 + /** 140 + * ieee80211_channel_to_frequency - convert channel number to frequency 141 + */ 142 + extern int ieee80211_channel_to_frequency(int chan); 143 + 144 + /** 145 + * ieee80211_frequency_to_channel - convert frequency to channel number 146 + */ 147 + extern int ieee80211_frequency_to_channel(int freq); 296 148 297 149 #endif /* __NET_WIRELESS_H */
-1
net/mac80211/Makefile
··· 19 19 ieee80211_iface.o \ 20 20 ieee80211_rate.o \ 21 21 michael.o \ 22 - regdomain.o \ 23 22 tkip.o \ 24 23 aes_ccm.o \ 25 24 cfg.o \
+6 -5
net/mac80211/cfg.c
··· 498 498 { 499 499 u32 rates; 500 500 int i, j; 501 - struct ieee80211_hw_mode *mode; 501 + struct ieee80211_supported_band *sband; 502 502 503 503 if (params->station_flags & STATION_FLAG_CHANGED) { 504 504 sta->flags &= ~WLAN_STA_AUTHORIZED; ··· 525 525 526 526 if (params->supported_rates) { 527 527 rates = 0; 528 - mode = local->oper_hw_mode; 528 + sband = local->hw.wiphy->bands[local->oper_channel->band]; 529 + 529 530 for (i = 0; i < params->supported_rates_len; i++) { 530 531 int rate = (params->supported_rates[i] & 0x7f) * 5; 531 - for (j = 0; j < mode->num_rates; j++) { 532 - if (mode->rates[j].rate == rate) 532 + for (j = 0; j < sband->n_bitrates; j++) { 533 + if (sband->bitrates[j].bitrate == rate) 533 534 rates |= BIT(j); 534 535 } 535 536 } 536 - sta->supp_rates = rates; 537 + sta->supp_rates[local->oper_channel->band] = rates; 537 538 } 538 539 } 539 540
+1 -46
net/mac80211/debugfs.c
··· 19 19 return 0; 20 20 } 21 21 22 - static const char *ieee80211_mode_str(int mode) 23 - { 24 - switch (mode) { 25 - case MODE_IEEE80211A: 26 - return "IEEE 802.11a"; 27 - case MODE_IEEE80211B: 28 - return "IEEE 802.11b"; 29 - case MODE_IEEE80211G: 30 - return "IEEE 802.11g"; 31 - default: 32 - return "UNKNOWN"; 33 - } 34 - } 35 - 36 - static ssize_t modes_read(struct file *file, char __user *userbuf, 37 - size_t count, loff_t *ppos) 38 - { 39 - struct ieee80211_local *local = file->private_data; 40 - struct ieee80211_hw_mode *mode; 41 - char buf[150], *p = buf; 42 - 43 - /* FIXME: locking! */ 44 - list_for_each_entry(mode, &local->modes_list, list) { 45 - p += scnprintf(p, sizeof(buf)+buf-p, 46 - "%s\n", ieee80211_mode_str(mode->mode)); 47 - } 48 - 49 - return simple_read_from_buffer(userbuf, count, ppos, buf, p-buf); 50 - } 51 - 52 - static const struct file_operations modes_ops = { 53 - .read = modes_read, 54 - .open = mac80211_open_file_generic, 55 - }; 56 - 57 22 #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \ 58 23 static ssize_t name## _read(struct file *file, char __user *userbuf, \ 59 24 size_t count, loff_t *ppos) \ ··· 45 80 local->debugfs.name = NULL; 46 81 47 82 48 - DEBUGFS_READONLY_FILE(channel, 20, "%d", 49 - local->hw.conf.channel); 50 83 DEBUGFS_READONLY_FILE(frequency, 20, "%d", 51 - local->hw.conf.freq); 84 + local->hw.conf.channel->center_freq); 52 85 DEBUGFS_READONLY_FILE(antenna_sel_tx, 20, "%d", 53 86 local->hw.conf.antenna_sel_tx); 54 87 DEBUGFS_READONLY_FILE(antenna_sel_rx, 20, "%d", ··· 63 100 local->long_retry_limit); 64 101 DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d", 65 102 local->total_ps_buffered); 66 - DEBUGFS_READONLY_FILE(mode, 20, "%s", 67 - ieee80211_mode_str(local->hw.conf.phymode)); 68 103 DEBUGFS_READONLY_FILE(wep_iv, 20, "%#06x", 69 104 local->wep_iv & 0xffffff); 70 105 DEBUGFS_READONLY_FILE(rate_ctrl_alg, 100, "%s", ··· 255 294 local->debugfs.stations = debugfs_create_dir("stations", phyd); 256 295 local->debugfs.keys = debugfs_create_dir("keys", phyd); 257 296 258 - DEBUGFS_ADD(channel); 259 297 DEBUGFS_ADD(frequency); 260 298 DEBUGFS_ADD(antenna_sel_tx); 261 299 DEBUGFS_ADD(antenna_sel_rx); ··· 264 304 DEBUGFS_ADD(short_retry_limit); 265 305 DEBUGFS_ADD(long_retry_limit); 266 306 DEBUGFS_ADD(total_ps_buffered); 267 - DEBUGFS_ADD(mode); 268 307 DEBUGFS_ADD(wep_iv); 269 - DEBUGFS_ADD(modes); 270 308 271 309 statsd = debugfs_create_dir("statistics", phyd); 272 310 local->debugfs.statistics = statsd; ··· 314 356 315 357 void debugfs_hw_del(struct ieee80211_local *local) 316 358 { 317 - DEBUGFS_DEL(channel); 318 359 DEBUGFS_DEL(frequency); 319 360 DEBUGFS_DEL(antenna_sel_tx); 320 361 DEBUGFS_DEL(antenna_sel_rx); ··· 323 366 DEBUGFS_DEL(short_retry_limit); 324 367 DEBUGFS_DEL(long_retry_limit); 325 368 DEBUGFS_DEL(total_ps_buffered); 326 - DEBUGFS_DEL(mode); 327 369 DEBUGFS_DEL(wep_iv); 328 - DEBUGFS_DEL(modes); 329 370 330 371 DEBUGFS_STATS_DEL(transmitted_fragment_count); 331 372 DEBUGFS_STATS_DEL(multicast_transmitted_frame_count);
-18
net/mac80211/debugfs_sta.c
··· 33 33 #define STA_READ_LU(name, field) STA_READ(name, 20, field, "%lu\n") 34 34 #define STA_READ_S(name, field) STA_READ(name, 20, field, "%s\n") 35 35 36 - #define STA_READ_RATE(name, field) \ 37 - static ssize_t sta_##name##_read(struct file *file, \ 38 - char __user *userbuf, \ 39 - size_t count, loff_t *ppos) \ 40 - { \ 41 - struct sta_info *sta = file->private_data; \ 42 - struct ieee80211_local *local = wdev_priv(sta->dev->ieee80211_ptr);\ 43 - struct ieee80211_hw_mode *mode = local->oper_hw_mode; \ 44 - char buf[20]; \ 45 - int res = scnprintf(buf, sizeof(buf), "%d\n", \ 46 - (sta->field >= 0 && \ 47 - sta->field < mode->num_rates) ? \ 48 - mode->rates[sta->field].rate : -1); \ 49 - return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ 50 - } 51 - 52 36 #define STA_OPS(name) \ 53 37 static const struct file_operations sta_ ##name## _ops = { \ 54 38 .read = sta_##name##_read, \ ··· 61 77 STA_FILE(rx_dropped, rx_dropped, LU); 62 78 STA_FILE(tx_fragments, tx_fragments, LU); 63 79 STA_FILE(tx_filtered, tx_filtered_count, LU); 64 - STA_FILE(txrate, txrate, RATE); 65 - STA_FILE(last_txrate, last_txrate, RATE); 66 80 STA_FILE(tx_retry_failed, tx_retry_failed, LU); 67 81 STA_FILE(tx_retry_count, tx_retry_count, LU); 68 82 STA_FILE(last_rssi, last_rssi, D);
+40 -72
net/mac80211/ieee80211.c
··· 876 876 877 877 int ieee80211_hw_config(struct ieee80211_local *local) 878 878 { 879 - struct ieee80211_hw_mode *mode; 880 879 struct ieee80211_channel *chan; 881 880 int ret = 0; 882 881 883 - if (local->sta_sw_scanning) { 882 + if (local->sta_sw_scanning) 884 883 chan = local->scan_channel; 885 - mode = local->scan_hw_mode; 886 - } else { 884 + else 887 885 chan = local->oper_channel; 888 - mode = local->oper_hw_mode; 889 - } 890 886 891 - local->hw.conf.channel = chan->chan; 892 - local->hw.conf.channel_val = chan->val; 893 - if (!local->hw.conf.power_level) { 894 - local->hw.conf.power_level = chan->power_level; 895 - } else { 896 - local->hw.conf.power_level = min(chan->power_level, 897 - local->hw.conf.power_level); 898 - } 899 - local->hw.conf.freq = chan->freq; 900 - local->hw.conf.phymode = mode->mode; 901 - local->hw.conf.antenna_max = chan->antenna_max; 902 - local->hw.conf.chan = chan; 903 - local->hw.conf.mode = mode; 887 + local->hw.conf.channel = chan; 888 + 889 + if (!local->hw.conf.power_level) 890 + local->hw.conf.power_level = chan->max_power; 891 + else 892 + local->hw.conf.power_level = min(chan->max_power, 893 + local->hw.conf.power_level); 894 + 895 + local->hw.conf.max_antenna_gain = chan->max_antenna_gain; 904 896 905 897 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG 906 - printk(KERN_DEBUG "HW CONFIG: channel=%d freq=%d " 907 - "phymode=%d\n", local->hw.conf.channel, local->hw.conf.freq, 908 - local->hw.conf.phymode); 909 - #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ 898 + printk(KERN_DEBUG "%s: HW CONFIG: freq=%d\n", 899 + wiphy_name(local->hw.wiphy), chan->center_freq); 900 + #endif 910 901 911 902 if (local->open_count) 912 903 ret = local->ops->config(local_to_hw(local), &local->hw.conf); ··· 915 924 struct ieee80211_ht_bss_info *req_bss_cap) 916 925 { 917 926 struct ieee80211_conf *conf = &local->hw.conf; 918 - struct ieee80211_hw_mode *mode = conf->mode; 927 + struct ieee80211_supported_band *sband; 919 928 int i; 920 929 930 + sband = local->hw.wiphy->bands[conf->channel->band]; 931 + 921 932 /* HT is not supported */ 922 - if (!mode->ht_info.ht_supported) { 933 + if (!sband->ht_info.ht_supported) { 923 934 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE; 924 935 return -EOPNOTSUPP; 925 936 } ··· 931 938 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE; 932 939 } else { 933 940 conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE; 934 - conf->ht_conf.cap = req_ht_cap->cap & mode->ht_info.cap; 941 + conf->ht_conf.cap = req_ht_cap->cap & sband->ht_info.cap; 935 942 conf->ht_conf.cap &= ~(IEEE80211_HT_CAP_MIMO_PS); 936 943 conf->ht_conf.cap |= 937 - mode->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS; 944 + sband->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS; 938 945 conf->ht_bss_conf.primary_channel = 939 946 req_bss_cap->primary_channel; 940 947 conf->ht_bss_conf.bss_cap = req_bss_cap->bss_cap; 941 948 conf->ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode; 942 949 for (i = 0; i < SUPP_MCS_SET_LEN; i++) 943 950 conf->ht_conf.supp_mcs_set[i] = 944 - mode->ht_info.supp_mcs_set[i] & 951 + sband->ht_info.supp_mcs_set[i] & 945 952 req_ht_cap->supp_mcs_set[i]; 946 953 947 954 /* In STA mode, this gives us indication ··· 1411 1418 local->long_retry_limit = 4; 1412 1419 local->hw.conf.radio_enabled = 1; 1413 1420 1414 - local->enabled_modes = ~0; 1415 - 1416 - INIT_LIST_HEAD(&local->modes_list); 1417 - 1418 1421 INIT_LIST_HEAD(&local->interfaces); 1419 1422 1420 1423 INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work); ··· 1455 1466 struct ieee80211_local *local = hw_to_local(hw); 1456 1467 const char *name; 1457 1468 int result; 1469 + enum ieee80211_band band; 1470 + 1471 + /* 1472 + * generic code guarantees at least one band, 1473 + * set this very early because much code assumes 1474 + * that hw.conf.channel is assigned 1475 + */ 1476 + for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 1477 + struct ieee80211_supported_band *sband; 1478 + 1479 + sband = local->hw.wiphy->bands[band]; 1480 + if (sband) { 1481 + /* init channel we're on */ 1482 + local->hw.conf.channel = 1483 + local->oper_channel = 1484 + local->scan_channel = &sband->channels[0]; 1485 + break; 1486 + } 1487 + } 1458 1488 1459 1489 result = wiphy_register(local->hw.wiphy); 1460 1490 if (result < 0) ··· 1575 1567 } 1576 1568 EXPORT_SYMBOL(ieee80211_register_hw); 1577 1569 1578 - int ieee80211_register_hwmode(struct ieee80211_hw *hw, 1579 - struct ieee80211_hw_mode *mode) 1580 - { 1581 - struct ieee80211_local *local = hw_to_local(hw); 1582 - struct ieee80211_rate *rate; 1583 - int i; 1584 - 1585 - INIT_LIST_HEAD(&mode->list); 1586 - list_add_tail(&mode->list, &local->modes_list); 1587 - 1588 - local->hw_modes |= (1 << mode->mode); 1589 - for (i = 0; i < mode->num_rates; i++) { 1590 - rate = &(mode->rates[i]); 1591 - rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate; 1592 - } 1593 - ieee80211_prepare_rates(local, mode); 1594 - 1595 - if (!local->oper_hw_mode) { 1596 - /* Default to this mode */ 1597 - local->hw.conf.phymode = mode->mode; 1598 - local->oper_hw_mode = local->scan_hw_mode = mode; 1599 - local->oper_channel = local->scan_channel = &mode->channels[0]; 1600 - local->hw.conf.mode = local->oper_hw_mode; 1601 - local->hw.conf.chan = local->oper_channel; 1602 - } 1603 - 1604 - if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED)) 1605 - ieee80211_set_default_regdomain(mode); 1606 - 1607 - return 0; 1608 - } 1609 - EXPORT_SYMBOL(ieee80211_register_hwmode); 1610 - 1611 1570 void ieee80211_unregister_hw(struct ieee80211_hw *hw) 1612 1571 { 1613 1572 struct ieee80211_local *local = hw_to_local(hw); 1614 1573 struct ieee80211_sub_if_data *sdata, *tmp; 1615 - int i; 1616 1574 1617 1575 tasklet_kill(&local->tx_pending_tasklet); 1618 1576 tasklet_kill(&local->tasklet); ··· 1618 1644 sta_info_stop(local); 1619 1645 rate_control_deinitialize(local); 1620 1646 debugfs_hw_del(local); 1621 - 1622 - for (i = 0; i < NUM_IEEE80211_MODES; i++) { 1623 - kfree(local->supp_rates[i]); 1624 - kfree(local->basic_rates[i]); 1625 - } 1626 1647 1627 1648 if (skb_queue_len(&local->skb_queue) 1628 1649 || skb_queue_len(&local->skb_queue_unreliable)) ··· 1665 1696 } 1666 1697 1667 1698 ieee80211_debugfs_netdev_init(); 1668 - ieee80211_regdomain_init(); 1669 1699 1670 1700 return 0; 1671 1701
+13 -50
net/mac80211/ieee80211_i.h
··· 79 79 u8 ssid[IEEE80211_MAX_SSID_LEN]; 80 80 size_t ssid_len; 81 81 u16 capability; /* host byte order */ 82 - int hw_mode; 83 - int channel; 82 + enum ieee80211_band band; 84 83 int freq; 85 84 int rssi, signal, noise; 86 85 u8 *wpa_ie; ··· 135 136 union { 136 137 struct { 137 138 struct ieee80211_tx_control *control; 138 - struct ieee80211_hw_mode *mode; 139 + struct ieee80211_channel *channel; 139 140 struct ieee80211_rate *rate; 140 141 /* use this rate (if set) for last fragment; rate can 141 142 * be set to lower rate for the first fragments, e.g., 142 143 * when using CTS protection with IEEE 802.11g. */ 143 144 struct ieee80211_rate *last_frag_rate; 144 - int last_frag_hwrate; 145 145 146 146 /* Extra fragments (in addition to the first fragment 147 147 * in skb) */ ··· 149 151 } tx; 150 152 struct { 151 153 struct ieee80211_rx_status *status; 154 + struct ieee80211_rate *rate; 152 155 int sent_ps_buffered; 153 156 int queue; 154 157 int load; ··· 178 179 struct sk_buff *skb; 179 180 int num_extra_frag; 180 181 struct sk_buff **extra_frag; 181 - int last_frag_rateidx; 182 - int last_frag_hwrate; 183 182 struct ieee80211_rate *last_frag_rate; 184 183 unsigned int last_frag_rate_ctrl_probe; 185 184 }; ··· 280 283 281 284 unsigned long ibss_join_req; 282 285 struct sk_buff *probe_resp; /* ProbeResp template for IBSS */ 283 - u32 supp_rates_bits; 286 + u32 supp_rates_bits[IEEE80211_NUM_BANDS]; 284 287 285 288 int wmm_last_param_set; 286 289 }; ··· 290 293 #define IEEE80211_SDATA_ALLMULTI BIT(0) 291 294 #define IEEE80211_SDATA_PROMISC BIT(1) 292 295 #define IEEE80211_SDATA_USERSPACE_MLME BIT(2) 296 + #define IEEE80211_SDATA_OPERATING_GMODE BIT(3) 293 297 struct ieee80211_sub_if_data { 294 298 struct list_head list; 295 299 ··· 310 312 * drop packets to/from unauthorized port 311 313 */ 312 314 int ieee802_1x_pac; 315 + 316 + /* 317 + * basic rates of this AP or the AP we're associated to 318 + */ 319 + u64 basic_rates; 313 320 314 321 u16 sequence; 315 322 ··· 423 420 424 421 const struct ieee80211_ops *ops; 425 422 426 - /* List of registered struct ieee80211_hw_mode */ 427 - struct list_head modes_list; 428 - 429 423 struct net_device *mdev; /* wmaster# - "master" 802.11 device */ 430 424 int open_count; 431 425 int monitors; ··· 462 462 463 463 struct rate_control_ref *rate_ctrl; 464 464 465 - /* Supported and basic rate filters for different modes. These are 466 - * pointers to -1 terminated lists and rates in 100 kbps units. */ 467 - int *supp_rates[NUM_IEEE80211_MODES]; 468 - int *basic_rates[NUM_IEEE80211_MODES]; 469 - 470 465 int rts_threshold; 471 466 int fragmentation_threshold; 472 467 int short_retry_limit; /* dot11ShortRetryLimit */ ··· 483 488 bool sta_sw_scanning; 484 489 bool sta_hw_scanning; 485 490 int scan_channel_idx; 491 + enum ieee80211_band scan_band; 492 + 486 493 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state; 487 494 unsigned long last_scan_completed; 488 495 struct delayed_work scan_work; 489 496 struct net_device *scan_dev; 490 497 struct ieee80211_channel *oper_channel, *scan_channel; 491 - struct ieee80211_hw_mode *oper_hw_mode, *scan_hw_mode; 492 498 u8 scan_ssid[IEEE80211_MAX_SSID_LEN]; 493 499 size_t scan_ssid_len; 494 500 struct list_head sta_bss_list; ··· 558 562 int wifi_wme_noack_test; 559 563 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ 560 564 561 - unsigned int enabled_modes; /* bitfield of allowed modes; 562 - * (1 << MODE_*) */ 563 - unsigned int hw_modes; /* bitfield of supported hardware modes; 564 - * (1 << MODE_*) */ 565 - 566 565 #ifdef CONFIG_MAC80211_DEBUGFS 567 566 struct local_debugfsdentries { 568 - struct dentry *channel; 569 567 struct dentry *frequency; 570 568 struct dentry *antenna_sel_tx; 571 569 struct dentry *antenna_sel_rx; ··· 569 579 struct dentry *short_retry_limit; 570 580 struct dentry *long_retry_limit; 571 581 struct dentry *total_ps_buffered; 572 - struct dentry *mode; 573 582 struct dentry *wep_iv; 574 - struct dentry *modes; 575 583 struct dentry *statistics; 576 584 struct local_debugfsdentries_statsdentries { 577 585 struct dentry *transmitted_fragment_count; ··· 680 692 read_unlock_bh(&local->sta_lock); 681 693 } 682 694 683 - /** 684 - * ieee80211_is_erp_rate - Check if a rate is an ERP rate 685 - * @phymode: The PHY-mode for this rate (MODE_IEEE80211...) 686 - * @rate: Transmission rate to check, in 100 kbps 687 - * 688 - * Check if a given rate is an Extended Rate PHY (ERP) rate. 689 - */ 690 - static inline int ieee80211_is_erp_rate(int phymode, int rate) 691 - { 692 - if (phymode == MODE_IEEE80211G) { 693 - if (rate != 10 && rate != 20 && 694 - rate != 55 && rate != 110) 695 - return 1; 696 - } 697 - return 0; 698 - } 699 - 700 695 static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) 701 696 { 702 697 return compare_ether_addr(raddr, addr) == 0 || ··· 691 720 int ieee80211_hw_config(struct ieee80211_local *local); 692 721 int ieee80211_if_config(struct net_device *dev); 693 722 int ieee80211_if_config_beacon(struct net_device *dev); 694 - void ieee80211_prepare_rates(struct ieee80211_local *local, 695 - struct ieee80211_hw_mode *mode); 696 723 void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx); 697 724 int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr); 698 725 void ieee80211_if_setup(struct net_device *dev); 699 - struct ieee80211_rate *ieee80211_get_rate(struct ieee80211_local *local, 700 - int phymode, int hwrate); 701 726 int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht, 702 727 struct ieee80211_ht_info *req_ht_cap, 703 728 struct ieee80211_ht_bss_info *req_bss_cap); ··· 724 757 /* ieee80211_ioctl.c */ 725 758 int ieee80211_set_compression(struct ieee80211_local *local, 726 759 struct net_device *dev, struct sta_info *sta); 727 - int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq); 760 + int ieee80211_set_freq(struct ieee80211_local *local, int freq); 728 761 /* ieee80211_sta.c */ 729 762 void ieee80211_sta_timer(unsigned long data); 730 763 void ieee80211_sta_work(struct work_struct *work); ··· 776 809 int ieee80211_if_remove(struct net_device *dev, const char *name, int id); 777 810 void ieee80211_if_free(struct net_device *dev); 778 811 void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata); 779 - 780 - /* regdomain.c */ 781 - void ieee80211_regdomain_init(void); 782 - void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode); 783 812 784 813 /* rx handling */ 785 814 extern ieee80211_rx_handler ieee80211_rx_handlers[];
+2
net/mac80211/ieee80211_iface.c
··· 118 118 sdata->bss = NULL; 119 119 sdata->vif.type = type; 120 120 121 + sdata->basic_rates = 0; 122 + 121 123 switch (type) { 122 124 case IEEE80211_IF_TYPE_WDS: 123 125 /* nothing special */
+66 -61
net/mac80211/ieee80211_ioctl.c
··· 129 129 struct iw_request_info *info, 130 130 char *name, char *extra) 131 131 { 132 - struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 133 - 134 - switch (local->hw.conf.phymode) { 135 - case MODE_IEEE80211A: 136 - strcpy(name, "IEEE 802.11a"); 137 - break; 138 - case MODE_IEEE80211B: 139 - strcpy(name, "IEEE 802.11b"); 140 - break; 141 - case MODE_IEEE80211G: 142 - strcpy(name, "IEEE 802.11g"); 143 - break; 144 - default: 145 - strcpy(name, "IEEE 802.11"); 146 - break; 147 - } 132 + strcpy(name, "IEEE 802.11"); 148 133 149 134 return 0; 150 135 } ··· 141 156 { 142 157 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 143 158 struct iw_range *range = (struct iw_range *) extra; 144 - struct ieee80211_hw_mode *mode = NULL; 159 + enum ieee80211_band band; 145 160 int c = 0; 146 161 147 162 data->length = sizeof(struct iw_range); ··· 176 191 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | 177 192 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; 178 193 179 - list_for_each_entry(mode, &local->modes_list, list) { 180 - int i = 0; 181 194 182 - if (!(local->enabled_modes & (1 << mode->mode)) || 183 - (local->hw_modes & local->enabled_modes & 184 - (1 << MODE_IEEE80211G) && mode->mode == MODE_IEEE80211B)) 195 + for (band = 0; band < IEEE80211_NUM_BANDS; band ++) { 196 + int i; 197 + struct ieee80211_supported_band *sband; 198 + 199 + sband = local->hw.wiphy->bands[band]; 200 + 201 + if (!sband) 185 202 continue; 186 203 187 - while (i < mode->num_channels && c < IW_MAX_FREQUENCIES) { 188 - struct ieee80211_channel *chan = &mode->channels[i]; 204 + for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) { 205 + struct ieee80211_channel *chan = &sband->channels[i]; 189 206 190 - if (chan->flag & IEEE80211_CHAN_W_SCAN) { 191 - range->freq[c].i = chan->chan; 192 - range->freq[c].m = chan->freq * 100000; 193 - range->freq[c].e = 1; 207 + if (!(chan->flags & IEEE80211_CHAN_DISABLED)) { 208 + range->freq[c].i = 209 + ieee80211_frequency_to_channel( 210 + chan->center_freq); 211 + range->freq[c].m = chan->center_freq; 212 + range->freq[c].e = 6; 194 213 c++; 195 214 } 196 - i++; 197 215 } 198 216 } 199 217 range->num_channels = c; ··· 282 294 return 0; 283 295 } 284 296 285 - int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq) 297 + int ieee80211_set_freq(struct ieee80211_local *local, int freqMHz) 286 298 { 287 - struct ieee80211_hw_mode *mode; 288 - int c, set = 0; 299 + int set = 0; 289 300 int ret = -EINVAL; 301 + enum ieee80211_band band; 302 + struct ieee80211_supported_band *sband; 303 + int i; 290 304 291 - list_for_each_entry(mode, &local->modes_list, list) { 292 - if (!(local->enabled_modes & (1 << mode->mode))) 305 + for (band = 0; band < IEEE80211_NUM_BANDS; band ++) { 306 + sband = local->hw.wiphy->bands[band]; 307 + 308 + if (!sband) 293 309 continue; 294 - for (c = 0; c < mode->num_channels; c++) { 295 - struct ieee80211_channel *chan = &mode->channels[c]; 296 - if (chan->flag & IEEE80211_CHAN_W_SCAN && 297 - ((chan->chan == channel) || (chan->freq == freq))) { 298 - local->oper_channel = chan; 299 - local->oper_hw_mode = mode; 310 + 311 + for (i = 0; i < sband->n_channels; i++) { 312 + struct ieee80211_channel *chan = &sband->channels[i]; 313 + 314 + if (chan->flags & IEEE80211_CHAN_DISABLED) 315 + continue; 316 + 317 + if (chan->center_freq == freqMHz) { 300 318 set = 1; 319 + local->oper_channel = chan; 301 320 break; 302 321 } 303 322 } ··· 342 347 IEEE80211_STA_AUTO_CHANNEL_SEL; 343 348 return 0; 344 349 } else 345 - return ieee80211_set_channel(local, freq->m, -1); 350 + return ieee80211_set_freq(local, 351 + ieee80211_channel_to_frequency(freq->m)); 346 352 } else { 347 353 int i, div = 1000000; 348 354 for (i = 0; i < freq->e; i++) 349 355 div /= 10; 350 356 if (div > 0) 351 - return ieee80211_set_channel(local, -1, freq->m / div); 357 + return ieee80211_set_freq(local, freq->m / div); 352 358 else 353 359 return -EINVAL; 354 360 } ··· 362 366 { 363 367 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 364 368 365 - /* TODO: in station mode (Managed/Ad-hoc) might need to poll low-level 366 - * driver for the current channel with firmware-based management */ 367 - 368 - freq->m = local->hw.conf.freq; 369 + freq->m = local->hw.conf.channel->center_freq; 369 370 freq->e = 6; 370 371 371 372 return 0; ··· 559 566 struct iw_param *rate, char *extra) 560 567 { 561 568 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 562 - struct ieee80211_hw_mode *mode; 563 - int i; 569 + int i, err = -EINVAL; 564 570 u32 target_rate = rate->value / 100000; 565 571 struct ieee80211_sub_if_data *sdata; 572 + struct ieee80211_supported_band *sband; 566 573 567 574 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 568 575 if (!sdata->bss) 569 576 return -ENODEV; 570 - mode = local->oper_hw_mode; 577 + 578 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 579 + 571 580 /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates 572 581 * target_rate = X, rate->fixed = 1 means only rate X 573 582 * target_rate = X, rate->fixed = 0 means all rates <= X */ ··· 577 582 sdata->bss->force_unicast_rateidx = -1; 578 583 if (rate->value < 0) 579 584 return 0; 580 - for (i=0; i < mode->num_rates; i++) { 581 - struct ieee80211_rate *rates = &mode->rates[i]; 582 - int this_rate = rates->rate; 585 + 586 + for (i=0; i< sband->n_bitrates; i++) { 587 + struct ieee80211_rate *brate = &sband->bitrates[i]; 588 + int this_rate = brate->bitrate; 583 589 584 590 if (target_rate == this_rate) { 585 591 sdata->bss->max_ratectrl_rateidx = i; 586 592 if (rate->fixed) 587 593 sdata->bss->force_unicast_rateidx = i; 588 - return 0; 594 + err = 0; 595 + break; 589 596 } 590 597 } 591 - return -EINVAL; 598 + return err; 592 599 } 593 600 594 601 static int ieee80211_ioctl_giwrate(struct net_device *dev, ··· 600 603 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 601 604 struct sta_info *sta; 602 605 struct ieee80211_sub_if_data *sdata; 606 + struct ieee80211_supported_band *sband; 603 607 604 608 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 609 + 605 610 if (sdata->vif.type == IEEE80211_IF_TYPE_STA) 606 611 sta = sta_info_get(local, sdata->u.sta.bssid); 607 612 else 608 613 return -EOPNOTSUPP; 609 614 if (!sta) 610 615 return -ENODEV; 611 - if (sta->txrate < local->oper_hw_mode->num_rates) 612 - rate->value = local->oper_hw_mode->rates[sta->txrate].rate * 100000; 616 + 617 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 618 + 619 + if (sta->txrate_idx < sband->n_bitrates) 620 + rate->value = sband->bitrates[sta->txrate_idx].bitrate; 613 621 else 614 622 rate->value = 0; 623 + rate->value *= 100000; 615 624 sta_info_put(sta); 616 625 return 0; 617 626 } ··· 628 625 { 629 626 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 630 627 bool need_reconfig = 0; 631 - u8 new_power_level; 628 + int new_power_level; 632 629 633 630 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) 634 631 return -EINVAL; ··· 638 635 if (data->txpower.fixed) { 639 636 new_power_level = data->txpower.value; 640 637 } else { 641 - /* Automatic power level. Get the px power from the current 642 - * channel. */ 643 - struct ieee80211_channel* chan = local->oper_channel; 638 + /* 639 + * Automatic power level. Use maximum power for the current 640 + * channel. Should be part of rate control. 641 + */ 642 + struct ieee80211_channel* chan = local->hw.conf.channel; 644 643 if (!chan) 645 644 return -EINVAL; 646 645 647 - new_power_level = chan->power_level; 646 + new_power_level = chan->max_power; 648 647 } 649 648 650 649 if (local->hw.conf.power_level != new_power_level) {
+8 -7
net/mac80211/ieee80211_rate.c
··· 163 163 } 164 164 165 165 void rate_control_get_rate(struct net_device *dev, 166 - struct ieee80211_hw_mode *mode, struct sk_buff *skb, 166 + struct ieee80211_supported_band *sband, 167 + struct sk_buff *skb, 167 168 struct rate_selection *sel) 168 169 { 169 170 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); ··· 175 174 176 175 memset(sel, 0, sizeof(struct rate_selection)); 177 176 178 - ref->ops->get_rate(ref->priv, dev, mode, skb, sel); 177 + ref->ops->get_rate(ref->priv, dev, sband, skb, sel); 179 178 180 179 /* Select a non-ERP backup rate. */ 181 180 if (!sel->nonerp) { 182 - for (i = 0; i < mode->num_rates - 1; i++) { 183 - struct ieee80211_rate *rate = &mode->rates[i]; 184 - if (sel->rate->rate < rate->rate) 181 + for (i = 0; i < sband->n_bitrates; i++) { 182 + struct ieee80211_rate *rate = &sband->bitrates[i]; 183 + if (sel->rate->bitrate < rate->bitrate) 185 184 break; 186 185 187 - if (rate_supported(sta, mode, i) && 188 - !(rate->flags & IEEE80211_RATE_ERP)) 186 + if (rate_supported(sta, sband->band, i) && 187 + !(rate->flags & IEEE80211_RATE_ERP_G)) 189 188 sel->nonerp = rate; 190 189 } 191 190 }
+16 -12
net/mac80211/ieee80211_rate.h
··· 18 18 #include "ieee80211_i.h" 19 19 #include "sta_info.h" 20 20 21 + /* TODO: kdoc */ 21 22 struct rate_selection { 22 23 /* Selected transmission rate */ 23 24 struct ieee80211_rate *rate; ··· 35 34 struct sk_buff *skb, 36 35 struct ieee80211_tx_status *status); 37 36 void (*get_rate)(void *priv, struct net_device *dev, 38 - struct ieee80211_hw_mode *mode, struct sk_buff *skb, 37 + struct ieee80211_supported_band *band, 38 + struct sk_buff *skb, 39 39 struct rate_selection *sel); 40 40 void (*rate_init)(void *priv, void *priv_sta, 41 41 struct ieee80211_local *local, struct sta_info *sta); ··· 68 66 struct rate_control_ref *rate_control_alloc(const char *name, 69 67 struct ieee80211_local *local); 70 68 void rate_control_get_rate(struct net_device *dev, 71 - struct ieee80211_hw_mode *mode, struct sk_buff *skb, 69 + struct ieee80211_supported_band *sband, 70 + struct sk_buff *skb, 72 71 struct rate_selection *sel); 73 72 struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); 74 73 void rate_control_put(struct rate_control_ref *ref); ··· 130 127 #endif 131 128 } 132 129 133 - static inline int 134 - rate_supported(struct sta_info *sta, struct ieee80211_hw_mode *mode, int index) 130 + static inline int rate_supported(struct sta_info *sta, 131 + enum ieee80211_band band, 132 + int index) 135 133 { 136 - return (sta == NULL || sta->supp_rates & BIT(index)) && 137 - (mode->rates[index].flags & IEEE80211_RATE_SUPPORTED); 134 + return (sta == NULL || sta->supp_rates[band] & BIT(index)); 138 135 } 139 136 140 137 static inline int 141 - rate_lowest_index(struct ieee80211_local *local, struct ieee80211_hw_mode *mode, 138 + rate_lowest_index(struct ieee80211_local *local, 139 + struct ieee80211_supported_band *sband, 142 140 struct sta_info *sta) 143 141 { 144 142 int i; 145 143 146 - for (i = 0; i < mode->num_rates; i++) { 147 - if (rate_supported(sta, mode, i)) 144 + for (i = 0; i < sband->n_bitrates; i++) 145 + if (rate_supported(sta, sband->band, i)) 148 146 return i; 149 - } 150 147 151 148 /* warn when we cannot find a rate. */ 152 149 WARN_ON(1); ··· 155 152 } 156 153 157 154 static inline struct ieee80211_rate * 158 - rate_lowest(struct ieee80211_local *local, struct ieee80211_hw_mode *mode, 155 + rate_lowest(struct ieee80211_local *local, 156 + struct ieee80211_supported_band *sband, 159 157 struct sta_info *sta) 160 158 { 161 - return &mode->rates[rate_lowest_index(local, mode, sta)]; 159 + return &sband->bitrates[rate_lowest_index(local, sband, sta)]; 162 160 } 163 161 164 162
+208 -176
net/mac80211/ieee80211_sta.c
··· 74 74 static void ieee80211_send_probe_req(struct net_device *dev, u8 *dst, 75 75 u8 *ssid, size_t ssid_len); 76 76 static struct ieee80211_sta_bss * 77 - ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int channel, 77 + ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int freq, 78 78 u8 *ssid, u8 ssid_len); 79 79 static void ieee80211_rx_bss_put(struct net_device *dev, 80 80 struct ieee80211_sta_bss *bss); ··· 466 466 return; 467 467 468 468 bss = ieee80211_rx_bss_get(dev, ifsta->bssid, 469 - local->hw.conf.channel, 469 + local->hw.conf.channel->center_freq, 470 470 ifsta->ssid, ifsta->ssid_len); 471 471 if (bss) { 472 472 if (bss->has_erp_value) ··· 593 593 struct ieee80211_if_sta *ifsta) 594 594 { 595 595 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 596 - struct ieee80211_hw_mode *mode; 597 596 struct sk_buff *skb; 598 597 struct ieee80211_mgmt *mgmt; 599 598 u8 *pos, *ies; ··· 600 601 u16 capab; 601 602 struct ieee80211_sta_bss *bss; 602 603 int wmm = 0; 604 + struct ieee80211_supported_band *sband; 603 605 604 606 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 605 607 sizeof(*mgmt) + 200 + ifsta->extra_ie_len + ··· 612 612 } 613 613 skb_reserve(skb, local->hw.extra_tx_headroom); 614 614 615 - mode = local->oper_hw_mode; 615 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 616 + 616 617 capab = ifsta->capab; 617 - if (mode->mode == MODE_IEEE80211G) { 618 - capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME | 619 - WLAN_CAPABILITY_SHORT_PREAMBLE; 618 + 619 + if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ) { 620 + if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) 621 + capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; 622 + if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) 623 + capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; 620 624 } 621 - bss = ieee80211_rx_bss_get(dev, ifsta->bssid, local->hw.conf.channel, 625 + 626 + bss = ieee80211_rx_bss_get(dev, ifsta->bssid, 627 + local->hw.conf.channel->center_freq, 622 628 ifsta->ssid, ifsta->ssid_len); 623 629 if (bss) { 624 630 if (bss->capability & WLAN_CAPABILITY_PRIVACY) ··· 663 657 *pos++ = ifsta->ssid_len; 664 658 memcpy(pos, ifsta->ssid, ifsta->ssid_len); 665 659 666 - len = mode->num_rates; 660 + len = sband->n_bitrates; 667 661 if (len > 8) 668 662 len = 8; 669 663 pos = skb_put(skb, len + 2); 670 664 *pos++ = WLAN_EID_SUPP_RATES; 671 665 *pos++ = len; 672 666 for (i = 0; i < len; i++) { 673 - int rate = mode->rates[i].rate; 667 + int rate = sband->bitrates[i].bitrate; 674 668 *pos++ = (u8) (rate / 5); 675 669 } 676 670 677 - if (mode->num_rates > len) { 678 - pos = skb_put(skb, mode->num_rates - len + 2); 671 + if (sband->n_bitrates > len) { 672 + pos = skb_put(skb, sband->n_bitrates - len + 2); 679 673 *pos++ = WLAN_EID_EXT_SUPP_RATES; 680 - *pos++ = mode->num_rates - len; 681 - for (i = len; i < mode->num_rates; i++) { 682 - int rate = mode->rates[i].rate; 674 + *pos++ = sband->n_bitrates - len; 675 + for (i = len; i < sband->n_bitrates; i++) { 676 + int rate = sband->bitrates[i].bitrate; 683 677 *pos++ = (u8) (rate / 5); 684 678 } 685 679 } ··· 702 696 *pos++ = 0; 703 697 } 704 698 /* wmm support is a must to HT */ 705 - if (wmm && mode->ht_info.ht_supported) { 706 - __le16 tmp = cpu_to_le16(mode->ht_info.cap); 699 + if (wmm && sband->ht_info.ht_supported) { 700 + __le16 tmp = cpu_to_le16(sband->ht_info.cap); 707 701 pos = skb_put(skb, sizeof(struct ieee80211_ht_cap)+2); 708 702 *pos++ = WLAN_EID_HT_CAPABILITY; 709 703 *pos++ = sizeof(struct ieee80211_ht_cap); 710 704 memset(pos, 0, sizeof(struct ieee80211_ht_cap)); 711 705 memcpy(pos, &tmp, sizeof(u16)); 712 706 pos += sizeof(u16); 713 - *pos++ = (mode->ht_info.ampdu_factor | 714 - (mode->ht_info.ampdu_density << 2)); 715 - memcpy(pos, mode->ht_info.supp_mcs_set, 16); 707 + /* TODO: needs a define here for << 2 */ 708 + *pos++ = sband->ht_info.ampdu_factor | 709 + (sband->ht_info.ampdu_density << 2); 710 + memcpy(pos, sband->ht_info.supp_mcs_set, 16); 716 711 } 717 712 718 713 kfree(ifsta->assocreq_ies); ··· 796 789 if (!ifsta || (ifsta->flags & IEEE80211_STA_MIXED_CELL)) 797 790 return 0; 798 791 799 - bss = ieee80211_rx_bss_get(dev, ifsta->bssid, local->hw.conf.channel, 792 + bss = ieee80211_rx_bss_get(dev, ifsta->bssid, 793 + local->hw.conf.channel->center_freq, 800 794 ifsta->ssid, ifsta->ssid_len); 801 795 if (!bss) 802 796 return 0; ··· 907 899 u8 *ssid, size_t ssid_len) 908 900 { 909 901 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 910 - struct ieee80211_hw_mode *mode; 902 + struct ieee80211_supported_band *sband; 911 903 struct sk_buff *skb; 912 904 struct ieee80211_mgmt *mgmt; 913 905 u8 *pos, *supp_rates, *esupp_rates = NULL; ··· 941 933 supp_rates = skb_put(skb, 2); 942 934 supp_rates[0] = WLAN_EID_SUPP_RATES; 943 935 supp_rates[1] = 0; 944 - mode = local->oper_hw_mode; 945 - for (i = 0; i < mode->num_rates; i++) { 946 - struct ieee80211_rate *rate = &mode->rates[i]; 947 - if (!(rate->flags & IEEE80211_RATE_SUPPORTED)) 948 - continue; 936 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 937 + 938 + for (i = 0; i < sband->n_bitrates; i++) { 939 + struct ieee80211_rate *rate = &sband->bitrates[i]; 949 940 if (esupp_rates) { 950 941 pos = skb_put(skb, 1); 951 942 esupp_rates[1]++; ··· 957 950 pos = skb_put(skb, 1); 958 951 supp_rates[1]++; 959 952 } 960 - *pos = rate->rate / 5; 953 + *pos = rate->bitrate / 5; 961 954 } 962 955 963 956 ieee80211_sta_tx(dev, skb, 0); ··· 1153 1146 } 1154 1147 /* determine default buffer size */ 1155 1148 if (buf_size == 0) { 1156 - struct ieee80211_hw_mode *mode = conf->mode; 1149 + struct ieee80211_supported_band *sband; 1150 + 1151 + sband = local->hw.wiphy->bands[conf->channel->band]; 1157 1152 buf_size = IEEE80211_MIN_AMPDU_BUF; 1158 - buf_size = buf_size << mode->ht_info.ampdu_factor; 1153 + buf_size = buf_size << sband->ht_info.ampdu_factor; 1159 1154 } 1160 1155 1161 1156 tid_agg_rx = &sta->ampdu_mlme.tid_rx[tid]; ··· 1727 1718 { 1728 1719 struct ieee80211_local *local = sdata->local; 1729 1720 struct net_device *dev = sdata->dev; 1730 - struct ieee80211_hw_mode *mode; 1721 + struct ieee80211_supported_band *sband; 1731 1722 struct sta_info *sta; 1732 - u32 rates; 1723 + u64 rates, basic_rates; 1733 1724 u16 capab_info, status_code, aid; 1734 1725 struct ieee802_11_elems elems; 1735 1726 struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf; 1736 1727 u8 *pos; 1737 1728 int i, j; 1738 1729 DECLARE_MAC_BUF(mac); 1730 + bool have_higher_than_11mbit = false; 1739 1731 1740 1732 /* AssocResp and ReassocResp have identical structure, so process both 1741 1733 * of them in this function. */ ··· 1806 1796 if (ifsta->assocresp_ies) 1807 1797 memcpy(ifsta->assocresp_ies, pos, ifsta->assocresp_ies_len); 1808 1798 1809 - /* set AID, ieee80211_set_associated() will tell the driver */ 1810 - bss_conf->aid = aid; 1811 - ieee80211_set_associated(dev, ifsta, 1); 1812 - 1813 1799 /* Add STA entry for the AP */ 1814 1800 sta = sta_info_get(local, ifsta->bssid); 1815 1801 if (!sta) { ··· 1817 1811 return; 1818 1812 } 1819 1813 bss = ieee80211_rx_bss_get(dev, ifsta->bssid, 1820 - local->hw.conf.channel, 1814 + local->hw.conf.channel->center_freq, 1821 1815 ifsta->ssid, ifsta->ssid_len); 1822 1816 if (bss) { 1823 1817 sta->last_rssi = bss->rssi; ··· 1831 1825 sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_AP; 1832 1826 1833 1827 rates = 0; 1834 - mode = local->oper_hw_mode; 1828 + basic_rates = 0; 1829 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1830 + 1835 1831 for (i = 0; i < elems.supp_rates_len; i++) { 1836 1832 int rate = (elems.supp_rates[i] & 0x7f) * 5; 1837 - for (j = 0; j < mode->num_rates; j++) 1838 - if (mode->rates[j].rate == rate) 1833 + 1834 + if (rate > 110) 1835 + have_higher_than_11mbit = true; 1836 + 1837 + for (j = 0; j < sband->n_bitrates; j++) { 1838 + if (sband->bitrates[j].bitrate == rate) 1839 1839 rates |= BIT(j); 1840 + if (elems.supp_rates[i] & 0x80) 1841 + basic_rates |= BIT(j); 1842 + } 1840 1843 } 1844 + 1841 1845 for (i = 0; i < elems.ext_supp_rates_len; i++) { 1842 1846 int rate = (elems.ext_supp_rates[i] & 0x7f) * 5; 1843 - for (j = 0; j < mode->num_rates; j++) 1844 - if (mode->rates[j].rate == rate) 1847 + 1848 + if (rate > 110) 1849 + have_higher_than_11mbit = true; 1850 + 1851 + for (j = 0; j < sband->n_bitrates; j++) { 1852 + if (sband->bitrates[j].bitrate == rate) 1845 1853 rates |= BIT(j); 1854 + if (elems.ext_supp_rates[i] & 0x80) 1855 + basic_rates |= BIT(j); 1856 + } 1846 1857 } 1847 - sta->supp_rates = rates; 1858 + 1859 + sta->supp_rates[local->hw.conf.channel->band] = rates; 1860 + sdata->basic_rates = basic_rates; 1861 + 1862 + /* cf. IEEE 802.11 9.2.12 */ 1863 + if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && 1864 + have_higher_than_11mbit) 1865 + sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; 1866 + else 1867 + sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; 1848 1868 1849 1869 if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && 1850 1870 local->ops->conf_ht) { ··· 1893 1861 elems.wmm_param_len); 1894 1862 } 1895 1863 1864 + /* set AID, ieee80211_set_associated() will tell the driver */ 1865 + bss_conf->aid = aid; 1866 + ieee80211_set_associated(dev, ifsta, 1); 1896 1867 1897 1868 sta_info_put(sta); 1898 1869 ··· 1936 1901 1937 1902 1938 1903 static struct ieee80211_sta_bss * 1939 - ieee80211_rx_bss_add(struct net_device *dev, u8 *bssid, int channel, 1904 + ieee80211_rx_bss_add(struct net_device *dev, u8 *bssid, int freq, 1940 1905 u8 *ssid, u8 ssid_len) 1941 1906 { 1942 1907 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); ··· 1948 1913 atomic_inc(&bss->users); 1949 1914 atomic_inc(&bss->users); 1950 1915 memcpy(bss->bssid, bssid, ETH_ALEN); 1951 - bss->channel = channel; 1916 + bss->freq = freq; 1952 1917 if (ssid && ssid_len <= IEEE80211_MAX_SSID_LEN) { 1953 1918 memcpy(bss->ssid, ssid, ssid_len); 1954 1919 bss->ssid_len = ssid_len; ··· 1964 1929 1965 1930 1966 1931 static struct ieee80211_sta_bss * 1967 - ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int channel, 1932 + ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int freq, 1968 1933 u8 *ssid, u8 ssid_len) 1969 1934 { 1970 1935 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); ··· 1974 1939 bss = local->sta_bss_hash[STA_HASH(bssid)]; 1975 1940 while (bss) { 1976 1941 if (!memcmp(bss->bssid, bssid, ETH_ALEN) && 1977 - bss->channel == channel && 1942 + bss->freq == freq && 1978 1943 bss->ssid_len == ssid_len && 1979 1944 (ssid_len == 0 || !memcmp(bss->ssid, ssid, ssid_len))) { 1980 1945 atomic_inc(&bss->users); ··· 2039 2004 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 2040 2005 struct ieee802_11_elems elems; 2041 2006 size_t baselen; 2042 - int channel, clen; 2007 + int freq, clen; 2043 2008 struct ieee80211_sta_bss *bss; 2044 2009 struct sta_info *sta; 2045 2010 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); ··· 2090 2055 if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates && 2091 2056 memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 && 2092 2057 (sta = sta_info_get(local, mgmt->sa))) { 2093 - struct ieee80211_hw_mode *mode; 2094 - struct ieee80211_rate *rates; 2058 + struct ieee80211_supported_band *sband; 2059 + struct ieee80211_rate *bitrates; 2095 2060 size_t num_rates; 2096 - u32 supp_rates, prev_rates; 2061 + u64 supp_rates, prev_rates; 2097 2062 int i, j; 2098 2063 2099 - mode = local->sta_sw_scanning ? 2100 - local->scan_hw_mode : local->oper_hw_mode; 2064 + sband = local->hw.wiphy->bands[rx_status->band]; 2101 2065 2102 - if (local->sta_hw_scanning) { 2103 - /* search for the correct mode matches the beacon */ 2104 - list_for_each_entry(mode, &local->modes_list, list) 2105 - if (mode->mode == rx_status->phymode) 2106 - break; 2107 - 2108 - if (mode == NULL) 2109 - mode = local->oper_hw_mode; 2066 + if (!sband) { 2067 + WARN_ON(1); 2068 + sband = local->hw.wiphy->bands[ 2069 + local->hw.conf.channel->band]; 2110 2070 } 2111 - rates = mode->rates; 2112 - num_rates = mode->num_rates; 2071 + 2072 + bitrates = sband->bitrates; 2073 + num_rates = sband->n_bitrates; 2113 2074 2114 2075 supp_rates = 0; 2115 2076 for (i = 0; i < elems.supp_rates_len + ··· 2119 2088 [i - elems.supp_rates_len]; 2120 2089 own_rate = 5 * (rate & 0x7f); 2121 2090 for (j = 0; j < num_rates; j++) 2122 - if (rates[j].rate == own_rate) 2091 + if (bitrates[j].bitrate == own_rate) 2123 2092 supp_rates |= BIT(j); 2124 2093 } 2125 2094 2126 - prev_rates = sta->supp_rates; 2127 - sta->supp_rates &= supp_rates; 2128 - if (sta->supp_rates == 0) { 2095 + prev_rates = sta->supp_rates[rx_status->band]; 2096 + sta->supp_rates[rx_status->band] &= supp_rates; 2097 + if (sta->supp_rates[rx_status->band] == 0) { 2129 2098 /* No matching rates - this should not really happen. 2130 2099 * Make sure that at least one rate is marked 2131 2100 * supported to avoid issues with TX rate ctrl. */ 2132 - sta->supp_rates = sdata->u.sta.supp_rates_bits; 2101 + sta->supp_rates[rx_status->band] = 2102 + sdata->u.sta.supp_rates_bits[rx_status->band]; 2133 2103 } 2134 - if (sta->supp_rates != prev_rates) { 2104 + if (sta->supp_rates[rx_status->band] != prev_rates) { 2135 2105 printk(KERN_DEBUG "%s: updated supp_rates set for " 2136 - "%s based on beacon info (0x%x & 0x%x -> " 2137 - "0x%x)\n", 2138 - dev->name, print_mac(mac, sta->addr), prev_rates, 2139 - supp_rates, sta->supp_rates); 2106 + "%s based on beacon info (0x%llx & 0x%llx -> " 2107 + "0x%llx)\n", 2108 + dev->name, print_mac(mac, sta->addr), 2109 + (unsigned long long) prev_rates, 2110 + (unsigned long long) supp_rates, 2111 + (unsigned long long) sta->supp_rates[rx_status->band]); 2140 2112 } 2141 2113 sta_info_put(sta); 2142 2114 } ··· 2148 2114 return; 2149 2115 2150 2116 if (elems.ds_params && elems.ds_params_len == 1) 2151 - channel = elems.ds_params[0]; 2117 + freq = ieee80211_channel_to_frequency(elems.ds_params[0]); 2152 2118 else 2153 - channel = rx_status->channel; 2119 + freq = rx_status->freq; 2154 2120 2155 - bss = ieee80211_rx_bss_get(dev, mgmt->bssid, channel, 2121 + bss = ieee80211_rx_bss_get(dev, mgmt->bssid, freq, 2156 2122 elems.ssid, elems.ssid_len); 2157 2123 if (!bss) { 2158 - bss = ieee80211_rx_bss_add(dev, mgmt->bssid, channel, 2124 + bss = ieee80211_rx_bss_add(dev, mgmt->bssid, freq, 2159 2125 elems.ssid, elems.ssid_len); 2160 2126 if (!bss) 2161 2127 return; ··· 2167 2133 spin_unlock_bh(&local->sta_bss_lock); 2168 2134 #endif 2169 2135 } 2136 + 2137 + bss->band = rx_status->band; 2170 2138 2171 2139 if (bss->probe_resp && beacon) { 2172 2140 /* Do not allow beacon to override data from Probe Response. */ ··· 2268 2232 bss->ht_ie_len = 0; 2269 2233 } 2270 2234 2271 - bss->hw_mode = rx_status->phymode; 2272 - bss->freq = rx_status->freq; 2273 - if (channel != rx_status->channel && 2274 - (bss->hw_mode == MODE_IEEE80211G || 2275 - bss->hw_mode == MODE_IEEE80211B) && 2276 - channel >= 1 && channel <= 14) { 2277 - static const int freq_list[] = { 2278 - 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2279 - 2447, 2452, 2457, 2462, 2467, 2472, 2484 2280 - }; 2281 - /* IEEE 802.11g/b mode can receive packets from neighboring 2282 - * channels, so map the channel into frequency. */ 2283 - bss->freq = freq_list[channel - 1]; 2284 - } 2285 2235 bss->timestamp = timestamp; 2286 2236 bss->last_update = jiffies; 2287 2237 bss->rssi = rx_status->ssi; ··· 2839 2817 } 2840 2818 2841 2819 spin_lock_bh(&local->sta_bss_lock); 2842 - freq = local->oper_channel->freq; 2820 + freq = local->oper_channel->center_freq; 2843 2821 list_for_each_entry(bss, &local->sta_bss_list, list) { 2844 2822 if (!(bss->capability & WLAN_CAPABILITY_ESS)) 2845 2823 continue; ··· 2870 2848 spin_unlock_bh(&local->sta_bss_lock); 2871 2849 2872 2850 if (selected) { 2873 - ieee80211_set_channel(local, -1, selected->freq); 2851 + ieee80211_set_freq(local, selected->freq); 2874 2852 if (!(ifsta->flags & IEEE80211_STA_SSID_SET)) 2875 2853 ieee80211_sta_set_ssid(dev, selected->ssid, 2876 2854 selected->ssid_len); ··· 2903 2881 struct sk_buff *skb; 2904 2882 struct ieee80211_mgmt *mgmt; 2905 2883 struct ieee80211_tx_control control; 2906 - struct ieee80211_hw_mode *mode; 2907 2884 struct rate_selection ratesel; 2908 2885 u8 *pos; 2909 2886 struct ieee80211_sub_if_data *sdata; 2887 + struct ieee80211_supported_band *sband; 2888 + 2889 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 2910 2890 2911 2891 /* Remove possible STA entries from other IBSS networks. */ 2912 2892 sta_info_flush(local, NULL); ··· 2928 2904 sdata->drop_unencrypted = bss->capability & 2929 2905 WLAN_CAPABILITY_PRIVACY ? 1 : 0; 2930 2906 2931 - res = ieee80211_set_channel(local, -1, bss->freq); 2907 + res = ieee80211_set_freq(local, bss->freq); 2932 2908 2933 - if (!(local->oper_channel->flag & IEEE80211_CHAN_W_IBSS)) { 2934 - printk(KERN_DEBUG "%s: IBSS not allowed on channel %d " 2935 - "(%d MHz)\n", dev->name, local->hw.conf.channel, 2936 - local->hw.conf.freq); 2909 + if (local->oper_channel->flags & IEEE80211_CHAN_NO_IBSS) { 2910 + printk(KERN_DEBUG "%s: IBSS not allowed on frequency " 2911 + "%d MHz\n", dev->name, local->oper_channel->center_freq); 2937 2912 return -1; 2938 2913 } 2939 2914 ··· 2969 2946 *pos++ = rates; 2970 2947 memcpy(pos, bss->supp_rates, rates); 2971 2948 2972 - pos = skb_put(skb, 2 + 1); 2973 - *pos++ = WLAN_EID_DS_PARAMS; 2974 - *pos++ = 1; 2975 - *pos++ = bss->channel; 2949 + if (bss->band == IEEE80211_BAND_2GHZ) { 2950 + pos = skb_put(skb, 2 + 1); 2951 + *pos++ = WLAN_EID_DS_PARAMS; 2952 + *pos++ = 1; 2953 + *pos++ = ieee80211_frequency_to_channel(bss->freq); 2954 + } 2976 2955 2977 2956 pos = skb_put(skb, 2 + 2); 2978 2957 *pos++ = WLAN_EID_IBSS_PARAMS; ··· 2992 2967 } 2993 2968 2994 2969 memset(&control, 0, sizeof(control)); 2995 - rate_control_get_rate(dev, local->oper_hw_mode, skb, &ratesel); 2970 + rate_control_get_rate(dev, sband, skb, &ratesel); 2996 2971 if (!ratesel.rate) { 2997 2972 printk(KERN_DEBUG "%s: Failed to determine TX rate " 2998 2973 "for IBSS beacon\n", dev->name); 2999 2974 break; 3000 2975 } 3001 2976 control.vif = &sdata->vif; 3002 - control.tx_rate = 3003 - (sdata->bss_conf.use_short_preamble && 3004 - (ratesel.rate->flags & IEEE80211_RATE_PREAMBLE2)) ? 3005 - ratesel.rate->val2 : ratesel.rate->val; 2977 + control.tx_rate = ratesel.rate; 2978 + if (sdata->bss_conf.use_short_preamble && 2979 + ratesel.rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) 2980 + control.flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; 3006 2981 control.antenna_sel_tx = local->hw.conf.antenna_sel_tx; 3007 - control.power_level = local->hw.conf.power_level; 3008 2982 control.flags |= IEEE80211_TXCTL_NO_ACK; 3009 2983 control.retry_limit = 1; 3010 2984 ··· 3028 3004 } 3029 3005 3030 3006 rates = 0; 3031 - mode = local->oper_hw_mode; 3007 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 3032 3008 for (i = 0; i < bss->supp_rates_len; i++) { 3033 3009 int bitrate = (bss->supp_rates[i] & 0x7f) * 5; 3034 - for (j = 0; j < mode->num_rates; j++) 3035 - if (mode->rates[j].rate == bitrate) 3010 + for (j = 0; j < sband->n_bitrates; j++) 3011 + if (sband->bitrates[j].bitrate == bitrate) 3036 3012 rates |= BIT(j); 3037 3013 } 3038 - ifsta->supp_rates_bits = rates; 3014 + ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; 3039 3015 } while (0); 3040 3016 3041 3017 if (skb) { ··· 3059 3035 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 3060 3036 struct ieee80211_sta_bss *bss; 3061 3037 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3062 - struct ieee80211_hw_mode *mode; 3038 + struct ieee80211_supported_band *sband; 3063 3039 u8 bssid[ETH_ALEN], *pos; 3064 3040 int i; 3065 3041 DECLARE_MAC_BUF(mac); ··· 3081 3057 printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %s\n", 3082 3058 dev->name, print_mac(mac, bssid)); 3083 3059 3084 - bss = ieee80211_rx_bss_add(dev, bssid, local->hw.conf.channel, 3060 + bss = ieee80211_rx_bss_add(dev, bssid, 3061 + local->hw.conf.channel->center_freq, 3085 3062 sdata->u.sta.ssid, sdata->u.sta.ssid_len); 3086 3063 if (!bss) 3087 3064 return -ENOMEM; 3088 3065 3089 - mode = local->oper_hw_mode; 3066 + bss->band = local->hw.conf.channel->band; 3067 + sband = local->hw.wiphy->bands[bss->band]; 3090 3068 3091 3069 if (local->hw.conf.beacon_int == 0) 3092 3070 local->hw.conf.beacon_int = 100; 3093 3071 bss->beacon_int = local->hw.conf.beacon_int; 3094 - bss->hw_mode = local->hw.conf.phymode; 3095 - bss->freq = local->hw.conf.freq; 3096 3072 bss->last_update = jiffies; 3097 3073 bss->capability = WLAN_CAPABILITY_IBSS; 3098 3074 if (sdata->default_key) { 3099 3075 bss->capability |= WLAN_CAPABILITY_PRIVACY; 3100 3076 } else 3101 3077 sdata->drop_unencrypted = 0; 3102 - bss->supp_rates_len = mode->num_rates; 3078 + bss->supp_rates_len = sband->n_bitrates; 3103 3079 pos = bss->supp_rates; 3104 - for (i = 0; i < mode->num_rates; i++) { 3105 - int rate = mode->rates[i].rate; 3080 + for (i = 0; i < sband->n_bitrates; i++) { 3081 + int rate = sband->bitrates[i].bitrate; 3106 3082 *pos++ = (u8) (rate / 5); 3107 3083 } 3108 3084 ··· 3151 3127 "%s\n", print_mac(mac, bssid), print_mac(mac2, ifsta->bssid)); 3152 3128 #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 3153 3129 if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0 && 3154 - (bss = ieee80211_rx_bss_get(dev, bssid, local->hw.conf.channel, 3130 + (bss = ieee80211_rx_bss_get(dev, bssid, 3131 + local->hw.conf.channel->center_freq, 3155 3132 ifsta->ssid, ifsta->ssid_len))) { 3156 3133 printk(KERN_DEBUG "%s: Selected IBSS BSSID %s" 3157 3134 " based on configured SSID\n", ··· 3180 3155 if (time_after(jiffies, ifsta->ibss_join_req + 3181 3156 IEEE80211_IBSS_JOIN_TIMEOUT)) { 3182 3157 if ((ifsta->flags & IEEE80211_STA_CREATE_IBSS) && 3183 - local->oper_channel->flag & IEEE80211_CHAN_W_IBSS) 3158 + (!(local->oper_channel->flags & 3159 + IEEE80211_CHAN_NO_IBSS))) 3184 3160 return ieee80211_sta_create_ibss(dev, ifsta); 3185 3161 if (ifsta->flags & IEEE80211_STA_CREATE_IBSS) { 3186 - printk(KERN_DEBUG "%s: IBSS not allowed on the" 3187 - " configured channel %d (%d MHz)\n", 3188 - dev->name, local->hw.conf.channel, 3189 - local->hw.conf.freq); 3162 + printk(KERN_DEBUG "%s: IBSS not allowed on" 3163 + " %d MHz\n", dev->name, 3164 + local->hw.conf.channel->center_freq); 3190 3165 } 3191 3166 3192 3167 /* No IBSS found - decrease scan interval and continue ··· 3205 3180 3206 3181 int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len) 3207 3182 { 3208 - struct ieee80211_sub_if_data *sdata; 3183 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3209 3184 struct ieee80211_if_sta *ifsta; 3210 3185 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 3211 3186 ··· 3219 3194 int i; 3220 3195 3221 3196 memset(&qparam, 0, sizeof(qparam)); 3222 - /* TODO: are these ok defaults for all hw_modes? */ 3197 + 3223 3198 qparam.aifs = 2; 3224 - qparam.cw_min = 3225 - local->hw.conf.phymode == MODE_IEEE80211B ? 31 : 15; 3199 + 3200 + if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && 3201 + !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE)) 3202 + qparam.cw_min = 31; 3203 + else 3204 + qparam.cw_min = 15; 3205 + 3226 3206 qparam.cw_max = 1023; 3227 3207 qparam.burst_time = 0; 3208 + 3228 3209 for (i = IEEE80211_TX_QUEUE_DATA0; i < NUM_TX_DATA_QUEUES; i++) 3229 - { 3230 3210 local->ops->conf_tx(local_to_hw(local), 3231 3211 i + IEEE80211_TX_QUEUE_DATA0, 3232 3212 &qparam); 3233 - } 3213 + 3234 3214 /* IBSS uses different parameters for Beacon sending */ 3235 3215 qparam.cw_min++; 3236 3216 qparam.cw_min *= 2; ··· 3244 3214 IEEE80211_TX_QUEUE_BEACON, &qparam); 3245 3215 } 3246 3216 3247 - sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3248 3217 ifsta = &sdata->u.sta; 3249 3218 3250 3219 if (ifsta->ssid_len != len || memcmp(ifsta->ssid, ssid, len) != 0) ··· 3402 3373 container_of(work, struct ieee80211_local, scan_work.work); 3403 3374 struct net_device *dev = local->scan_dev; 3404 3375 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3405 - struct ieee80211_hw_mode *mode; 3376 + struct ieee80211_supported_band *sband; 3406 3377 struct ieee80211_channel *chan; 3407 3378 int skip; 3408 3379 unsigned long next_delay = 0; ··· 3412 3383 3413 3384 switch (local->scan_state) { 3414 3385 case SCAN_SET_CHANNEL: 3415 - mode = local->scan_hw_mode; 3416 - if (local->scan_hw_mode->list.next == &local->modes_list && 3417 - local->scan_channel_idx >= mode->num_channels) { 3386 + /* get current scan band */ 3387 + if (local->scan_band < IEEE80211_NUM_BANDS) 3388 + sband = local->hw.wiphy->bands[local->scan_band]; 3389 + else 3390 + sband = NULL; 3391 + 3392 + /* if we started at an unsupported one, advance */ 3393 + while (!sband && local->scan_band < IEEE80211_NUM_BANDS) { 3394 + local->scan_band++; 3395 + sband = local->hw.wiphy->bands[local->scan_band]; 3396 + local->scan_channel_idx = 0; 3397 + } 3398 + 3399 + if (!sband || 3400 + (local->scan_channel_idx >= sband->n_channels && 3401 + local->scan_band >= IEEE80211_NUM_BANDS)) { 3418 3402 ieee80211_scan_completed(local_to_hw(local)); 3419 3403 return; 3420 3404 } 3421 - skip = !(local->enabled_modes & (1 << mode->mode)); 3422 - chan = &mode->channels[local->scan_channel_idx]; 3423 - if (!(chan->flag & IEEE80211_CHAN_W_SCAN) || 3405 + skip = 0; 3406 + chan = &sband->channels[local->scan_channel_idx]; 3407 + 3408 + if (chan->flags & IEEE80211_CHAN_DISABLED || 3424 3409 (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && 3425 - !(chan->flag & IEEE80211_CHAN_W_IBSS)) || 3426 - (local->hw_modes & local->enabled_modes & 3427 - (1 << MODE_IEEE80211G) && mode->mode == MODE_IEEE80211B)) 3410 + chan->flags & IEEE80211_CHAN_NO_IBSS)) 3428 3411 skip = 1; 3429 3412 3430 3413 if (!skip) { 3431 - #if 0 3432 - printk(KERN_DEBUG "%s: scan channel %d (%d MHz)\n", 3433 - dev->name, chan->chan, chan->freq); 3434 - #endif 3435 - 3436 3414 local->scan_channel = chan; 3437 3415 if (ieee80211_hw_config(local)) { 3438 - printk(KERN_DEBUG "%s: failed to set channel " 3439 - "%d (%d MHz) for scan\n", dev->name, 3440 - chan->chan, chan->freq); 3416 + printk(KERN_DEBUG "%s: failed to set freq to " 3417 + "%d MHz for scan\n", dev->name, 3418 + chan->center_freq); 3441 3419 skip = 1; 3442 3420 } 3443 3421 } 3444 3422 3445 3423 local->scan_channel_idx++; 3446 - if (local->scan_channel_idx >= local->scan_hw_mode->num_channels) { 3447 - if (local->scan_hw_mode->list.next != &local->modes_list) { 3448 - local->scan_hw_mode = list_entry(local->scan_hw_mode->list.next, 3449 - struct ieee80211_hw_mode, 3450 - list); 3451 - local->scan_channel_idx = 0; 3452 - } 3424 + if (local->scan_channel_idx >= sband->n_channels) { 3425 + local->scan_band++; 3426 + local->scan_channel_idx = 0; 3453 3427 } 3454 3428 3455 3429 if (skip) ··· 3463 3431 local->scan_state = SCAN_SEND_PROBE; 3464 3432 break; 3465 3433 case SCAN_SEND_PROBE: 3466 - if (local->scan_channel->flag & IEEE80211_CHAN_W_ACTIVE_SCAN) { 3467 - ieee80211_send_probe_req(dev, NULL, local->scan_ssid, 3468 - local->scan_ssid_len); 3469 - next_delay = IEEE80211_CHANNEL_TIME; 3470 - } else 3471 - next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; 3434 + next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; 3472 3435 local->scan_state = SCAN_SET_CHANNEL; 3436 + 3437 + if (local->scan_channel->flags & IEEE80211_CHAN_PASSIVE_SCAN) 3438 + break; 3439 + ieee80211_send_probe_req(dev, NULL, local->scan_ssid, 3440 + local->scan_ssid_len); 3441 + next_delay = IEEE80211_CHANNEL_TIME; 3473 3442 break; 3474 3443 } 3475 3444 ··· 3545 3512 } else 3546 3513 local->scan_ssid_len = 0; 3547 3514 local->scan_state = SCAN_SET_CHANNEL; 3548 - local->scan_hw_mode = list_entry(local->modes_list.next, 3549 - struct ieee80211_hw_mode, 3550 - list); 3551 3515 local->scan_channel_idx = 0; 3516 + local->scan_band = IEEE80211_BAND_2GHZ; 3552 3517 local->scan_dev = dev; 3553 3518 3554 3519 netif_tx_lock_bh(local->mdev); ··· 3601 3570 bss->last_update + IEEE80211_SCAN_RESULT_EXPIRE)) 3602 3571 return current_ev; 3603 3572 3604 - if (!(local->enabled_modes & (1 << bss->hw_mode))) 3605 - return current_ev; 3606 - 3607 3573 memset(&iwe, 0, sizeof(iwe)); 3608 3574 iwe.cmd = SIOCGIWAP; 3609 3575 iwe.u.ap_addr.sa_family = ARPHRD_ETHER; ··· 3628 3600 3629 3601 memset(&iwe, 0, sizeof(iwe)); 3630 3602 iwe.cmd = SIOCGIWFREQ; 3631 - iwe.u.freq.m = bss->channel; 3632 - iwe.u.freq.e = 0; 3603 + iwe.u.freq.m = bss->freq; 3604 + iwe.u.freq.e = 6; 3633 3605 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, 3634 3606 IW_EV_FREQ_LEN); 3635 - iwe.u.freq.m = bss->freq * 100000; 3636 - iwe.u.freq.e = 1; 3607 + 3608 + memset(&iwe, 0, sizeof(iwe)); 3609 + iwe.cmd = SIOCGIWFREQ; 3610 + iwe.u.freq.m = ieee80211_frequency_to_channel(bss->freq); 3611 + iwe.u.freq.e = 0; 3637 3612 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, 3638 3613 IW_EV_FREQ_LEN); 3639 3614 ··· 3779 3748 if (!sta) 3780 3749 return NULL; 3781 3750 3782 - sta->supp_rates = sdata->u.sta.supp_rates_bits; 3751 + sta->supp_rates[local->hw.conf.channel->band] = 3752 + sdata->u.sta.supp_rates_bits[local->hw.conf.channel->band]; 3783 3753 3784 3754 rate_control_rate_init(sta, local); 3785 3755
+41 -35
net/mac80211/rc80211_pid_algo.c
··· 102 102 struct rc_pid_rateinfo *rinfo) 103 103 { 104 104 struct ieee80211_sub_if_data *sdata; 105 - struct ieee80211_hw_mode *mode; 105 + struct ieee80211_supported_band *sband; 106 106 int newidx; 107 107 int maxrate; 108 108 int back = (adj > 0) ? 1 : -1; 109 109 110 110 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); 111 111 112 - mode = local->oper_hw_mode; 112 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 113 113 maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1; 114 114 115 - newidx = rate_control_pid_shift_adjust(rinfo, adj, sta->txrate, 116 - mode->num_rates); 115 + newidx = rate_control_pid_shift_adjust(rinfo, adj, sta->txrate_idx, 116 + sband->n_bitrates); 117 117 118 - while (newidx != sta->txrate) { 119 - if (rate_supported(sta, mode, newidx) && 118 + while (newidx != sta->txrate_idx) { 119 + if (rate_supported(sta, sband->band, newidx) && 120 120 (maxrate < 0 || newidx <= maxrate)) { 121 - sta->txrate = newidx; 121 + sta->txrate_idx = newidx; 122 122 break; 123 123 } 124 124 ··· 128 128 #ifdef CONFIG_MAC80211_DEBUGFS 129 129 rate_control_pid_event_rate_change( 130 130 &((struct rc_pid_sta_info *)sta->rate_ctrl_priv)->events, 131 - newidx, mode->rates[newidx].rate); 131 + newidx, sband->bitrates[newidx].bitrate); 132 132 #endif 133 133 } 134 134 ··· 155 155 { 156 156 struct rc_pid_sta_info *spinfo = sta->rate_ctrl_priv; 157 157 struct rc_pid_rateinfo *rinfo = pinfo->rinfo; 158 - struct ieee80211_hw_mode *mode; 158 + struct ieee80211_supported_band *sband; 159 159 u32 pf; 160 160 s32 err_avg; 161 161 u32 err_prop; ··· 164 164 int adj, i, j, tmp; 165 165 unsigned long period; 166 166 167 - mode = local->oper_hw_mode; 167 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 168 168 spinfo = sta->rate_ctrl_priv; 169 169 170 170 /* In case nothing happened during the previous control interval, turn ··· 190 190 spinfo->tx_num_failed = 0; 191 191 192 192 /* If we just switched rate, update the rate behaviour info. */ 193 - if (pinfo->oldrate != sta->txrate) { 193 + if (pinfo->oldrate != sta->txrate_idx) { 194 194 195 195 i = rinfo[pinfo->oldrate].rev_index; 196 - j = rinfo[sta->txrate].rev_index; 196 + j = rinfo[sta->txrate_idx].rev_index; 197 197 198 198 tmp = (pf - spinfo->last_pf); 199 199 tmp = RC_PID_DO_ARITH_RIGHT_SHIFT(tmp, RC_PID_ARITH_SHIFT); 200 200 201 201 rinfo[j].diff = rinfo[i].diff + tmp; 202 - pinfo->oldrate = sta->txrate; 202 + pinfo->oldrate = sta->txrate_idx; 203 203 } 204 - rate_control_pid_normalize(pinfo, mode->num_rates); 204 + rate_control_pid_normalize(pinfo, sband->n_bitrates); 205 205 206 206 /* Compute the proportional, integral and derivative errors. */ 207 207 err_prop = (pinfo->target << RC_PID_ARITH_SHIFT) - pf; ··· 242 242 struct sta_info *sta; 243 243 struct rc_pid_sta_info *spinfo; 244 244 unsigned long period; 245 + struct ieee80211_supported_band *sband; 245 246 246 247 sta = sta_info_get(local, hdr->addr1); 248 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 247 249 248 250 if (!sta) 249 251 return; ··· 253 251 /* Don't update the state if we're not controlling the rate. */ 254 252 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); 255 253 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) { 256 - sta->txrate = sdata->bss->max_ratectrl_rateidx; 254 + sta->txrate_idx = sdata->bss->max_ratectrl_rateidx; 257 255 return; 258 256 } 259 257 260 258 /* Ignore all frames that were sent with a different rate than the rate 261 259 * we currently advise mac80211 to use. */ 262 - if (status->control.rate != &local->oper_hw_mode->rates[sta->txrate]) 260 + if (status->control.tx_rate != &sband->bitrates[sta->txrate_idx]) 263 261 goto ignore; 264 262 265 263 spinfo = sta->rate_ctrl_priv; ··· 306 304 } 307 305 308 306 static void rate_control_pid_get_rate(void *priv, struct net_device *dev, 309 - struct ieee80211_hw_mode *mode, 307 + struct ieee80211_supported_band *sband, 310 308 struct sk_buff *skb, 311 309 struct rate_selection *sel) 312 310 { ··· 324 322 fc = le16_to_cpu(hdr->frame_control); 325 323 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || 326 324 is_multicast_ether_addr(hdr->addr1) || !sta) { 327 - sel->rate = rate_lowest(local, mode, sta); 325 + sel->rate = rate_lowest(local, sband, sta); 328 326 if (sta) 329 327 sta_info_put(sta); 330 328 return; ··· 333 331 /* If a forced rate is in effect, select it. */ 334 332 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 335 333 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) 336 - sta->txrate = sdata->bss->force_unicast_rateidx; 334 + sta->txrate_idx = sdata->bss->force_unicast_rateidx; 337 335 338 - rateidx = sta->txrate; 336 + rateidx = sta->txrate_idx; 339 337 340 - if (rateidx >= mode->num_rates) 341 - rateidx = mode->num_rates - 1; 338 + if (rateidx >= sband->n_bitrates) 339 + rateidx = sband->n_bitrates - 1; 342 340 343 - sta->last_txrate = rateidx; 341 + sta->last_txrate_idx = rateidx; 344 342 345 343 sta_info_put(sta); 346 344 347 - sel->rate = &mode->rates[rateidx]; 345 + sel->rate = &sband->bitrates[rateidx]; 348 346 349 347 #ifdef CONFIG_MAC80211_DEBUGFS 350 348 rate_control_pid_event_tx_rate( 351 349 &((struct rc_pid_sta_info *) sta->rate_ctrl_priv)->events, 352 - rateidx, mode->rates[rateidx].rate); 350 + rateidx, sband->bitrates[rateidx].bitrate); 353 351 #endif 354 352 } 355 353 ··· 361 359 * as we need to have IEEE 802.1X auth succeed immediately after assoc.. 362 360 * Until that method is implemented, we will use the lowest supported 363 361 * rate as a workaround. */ 364 - sta->txrate = rate_lowest_index(local, local->oper_hw_mode, sta); 362 + struct ieee80211_supported_band *sband; 363 + 364 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 365 + sta->txrate_idx = rate_lowest_index(local, sband, sta); 365 366 } 366 367 367 368 static void *rate_control_pid_alloc(struct ieee80211_local *local) 368 369 { 369 370 struct rc_pid_info *pinfo; 370 371 struct rc_pid_rateinfo *rinfo; 371 - struct ieee80211_hw_mode *mode; 372 + struct ieee80211_supported_band *sband; 372 373 int i, j, tmp; 373 374 bool s; 374 375 #ifdef CONFIG_MAC80211_DEBUGFS 375 376 struct rc_pid_debugfs_entries *de; 376 377 #endif 377 378 379 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 380 + 378 381 pinfo = kmalloc(sizeof(*pinfo), GFP_ATOMIC); 379 382 if (!pinfo) 380 383 return NULL; 381 384 382 - /* We can safely assume that oper_hw_mode won't change unless we get 385 + /* We can safely assume that sband won't change unless we get 383 386 * reinitialized. */ 384 - mode = local->oper_hw_mode; 385 - rinfo = kmalloc(sizeof(*rinfo) * mode->num_rates, GFP_ATOMIC); 387 + rinfo = kmalloc(sizeof(*rinfo) * sband->n_bitrates, GFP_ATOMIC); 386 388 if (!rinfo) { 387 389 kfree(pinfo); 388 390 return NULL; ··· 395 389 /* Sort the rates. This is optimized for the most common case (i.e. 396 390 * almost-sorted CCK+OFDM rates). Kind of bubble-sort with reversed 397 391 * mapping too. */ 398 - for (i = 0; i < mode->num_rates; i++) { 392 + for (i = 0; i < sband->n_bitrates; i++) { 399 393 rinfo[i].index = i; 400 394 rinfo[i].rev_index = i; 401 395 if (pinfo->fast_start) ··· 403 397 else 404 398 rinfo[i].diff = i * pinfo->norm_offset; 405 399 } 406 - for (i = 1; i < mode->num_rates; i++) { 400 + for (i = 1; i < sband->n_bitrates; i++) { 407 401 s = 0; 408 - for (j = 0; j < mode->num_rates - i; j++) 409 - if (unlikely(mode->rates[rinfo[j].index].rate > 410 - mode->rates[rinfo[j + 1].index].rate)) { 402 + for (j = 0; j < sband->n_bitrates - i; j++) 403 + if (unlikely(sband->bitrates[rinfo[j].index].bitrate > 404 + sband->bitrates[rinfo[j + 1].index].bitrate)) { 411 405 tmp = rinfo[j].index; 412 406 rinfo[j].index = rinfo[j + 1].index; 413 407 rinfo[j + 1].index = tmp;
+29 -37
net/mac80211/rc80211_simple.c
··· 35 35 struct sta_info *sta) 36 36 { 37 37 struct ieee80211_sub_if_data *sdata; 38 - struct ieee80211_hw_mode *mode; 39 - int i = sta->txrate; 38 + struct ieee80211_supported_band *sband; 39 + int i = sta->txrate_idx; 40 40 int maxrate; 41 41 42 42 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); ··· 45 45 return; 46 46 } 47 47 48 - mode = local->oper_hw_mode; 48 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 49 49 maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1; 50 50 51 - if (i > mode->num_rates) 52 - i = mode->num_rates - 2; 51 + if (i > sband->n_bitrates) 52 + i = sband->n_bitrates - 2; 53 53 54 - while (i + 1 < mode->num_rates) { 54 + while (i + 1 < sband->n_bitrates) { 55 55 i++; 56 - if (sta->supp_rates & BIT(i) && 57 - mode->rates[i].flags & IEEE80211_RATE_SUPPORTED && 56 + if (rate_supported(sta, sband->band, i) && 58 57 (maxrate < 0 || i <= maxrate)) { 59 - sta->txrate = i; 58 + sta->txrate_idx = i; 60 59 break; 61 60 } 62 61 } ··· 66 67 struct sta_info *sta) 67 68 { 68 69 struct ieee80211_sub_if_data *sdata; 69 - struct ieee80211_hw_mode *mode; 70 - int i = sta->txrate; 70 + struct ieee80211_supported_band *sband; 71 + int i = sta->txrate_idx; 71 72 72 73 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); 73 74 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) { ··· 75 76 return; 76 77 } 77 78 78 - mode = local->oper_hw_mode; 79 - if (i > mode->num_rates) 80 - i = mode->num_rates; 79 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 80 + if (i > sband->n_bitrates) 81 + i = sband->n_bitrates; 81 82 82 83 while (i > 0) { 83 84 i--; 84 - if (sta->supp_rates & BIT(i) && 85 - mode->rates[i].flags & IEEE80211_RATE_SUPPORTED) { 86 - sta->txrate = i; 85 + if (rate_supported(sta, sband->band, i)) { 86 + sta->txrate_idx = i; 87 87 break; 88 88 } 89 89 } ··· 166 168 } else if (per_failed < RATE_CONTROL_NUM_UP) { 167 169 rate_control_rate_inc(local, sta); 168 170 } 169 - srctrl->tx_avg_rate_sum += status->control.rate->rate; 171 + srctrl->tx_avg_rate_sum += status->control.tx_rate->bitrate; 170 172 srctrl->tx_avg_rate_num++; 171 173 srctrl->tx_num_failures = 0; 172 174 srctrl->tx_num_xmit = 0; ··· 199 201 200 202 static void 201 203 rate_control_simple_get_rate(void *priv, struct net_device *dev, 202 - struct ieee80211_hw_mode *mode, 204 + struct ieee80211_supported_band *sband, 203 205 struct sk_buff *skb, 204 206 struct rate_selection *sel) 205 207 { ··· 217 219 fc = le16_to_cpu(hdr->frame_control); 218 220 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || 219 221 is_multicast_ether_addr(hdr->addr1) || !sta) { 220 - sel->rate = rate_lowest(local, mode, sta); 222 + sel->rate = rate_lowest(local, sband, sta); 221 223 if (sta) 222 224 sta_info_put(sta); 223 225 return; ··· 226 228 /* If a forced rate is in effect, select it. */ 227 229 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 228 230 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) 229 - sta->txrate = sdata->bss->force_unicast_rateidx; 231 + sta->txrate_idx = sdata->bss->force_unicast_rateidx; 230 232 231 - rateidx = sta->txrate; 233 + rateidx = sta->txrate_idx; 232 234 233 - if (rateidx >= mode->num_rates) 234 - rateidx = mode->num_rates - 1; 235 + if (rateidx >= sband->n_bitrates) 236 + rateidx = sband->n_bitrates - 1; 235 237 236 - sta->last_txrate = rateidx; 238 + sta->last_txrate_idx = rateidx; 237 239 238 240 sta_info_put(sta); 239 241 240 - sel->rate = &mode->rates[rateidx]; 242 + sel->rate = &sband->bitrates[rateidx]; 241 243 } 242 244 243 245 ··· 245 247 struct ieee80211_local *local, 246 248 struct sta_info *sta) 247 249 { 248 - struct ieee80211_hw_mode *mode; 249 - int i; 250 - sta->txrate = 0; 251 - mode = local->oper_hw_mode; 250 + struct ieee80211_supported_band *sband; 251 + 252 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 253 + 252 254 /* TODO: This routine should consider using RSSI from previous packets 253 255 * as we need to have IEEE 802.1X auth succeed immediately after assoc.. 254 256 * Until that method is implemented, we will use the lowest supported rate 255 257 * as a workaround, */ 256 - for (i = 0; i < mode->num_rates; i++) { 257 - if ((sta->supp_rates & BIT(i)) && 258 - (mode->rates[i].flags & IEEE80211_RATE_SUPPORTED)) { 259 - sta->txrate = i; 260 - break; 261 - } 262 - } 258 + sta->txrate_idx = rate_lowest_index(local, sband, sta); 263 259 } 264 260 265 261
-152
net/mac80211/regdomain.c
··· 1 - /* 2 - * Copyright 2002-2005, Instant802 Networks, Inc. 3 - * Copyright 2005-2006, Devicescape Software, Inc. 4 - * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 8 - */ 9 - 10 - /* 11 - * This regulatory domain control implementation is known to be incomplete 12 - * and confusing. mac80211 regulatory domain control will be significantly 13 - * reworked in the not-too-distant future. 14 - * 15 - * For now, drivers wishing to control which channels are and aren't available 16 - * are advised as follows: 17 - * - set the IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED flag 18 - * - continue to include *ALL* possible channels in the modes registered 19 - * through ieee80211_register_hwmode() 20 - * - for each allowable ieee80211_channel structure registered in the above 21 - * call, set the flag member to some meaningful value such as 22 - * IEEE80211_CHAN_W_SCAN | IEEE80211_CHAN_W_ACTIVE_SCAN | 23 - * IEEE80211_CHAN_W_IBSS. 24 - * - leave flag as 0 for non-allowable channels 25 - * 26 - * The usual implementation is for a driver to read a device EEPROM to 27 - * determine which regulatory domain it should be operating under, then 28 - * looking up the allowable channels in a driver-local table, then performing 29 - * the above. 30 - */ 31 - 32 - #include <linux/module.h> 33 - #include <linux/netdevice.h> 34 - #include <net/mac80211.h> 35 - #include "ieee80211_i.h" 36 - 37 - static int ieee80211_regdom = 0x10; /* FCC */ 38 - module_param(ieee80211_regdom, int, 0444); 39 - MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK"); 40 - 41 - /* 42 - * If firmware is upgraded by the vendor, additional channels can be used based 43 - * on the new Japanese regulatory rules. This is indicated by setting 44 - * ieee80211_japan_5ghz module parameter to one when loading the 80211 kernel 45 - * module. 46 - */ 47 - static int ieee80211_japan_5ghz /* = 0 */; 48 - module_param(ieee80211_japan_5ghz, int, 0444); 49 - MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz"); 50 - 51 - 52 - struct ieee80211_channel_range { 53 - short start_freq; 54 - short end_freq; 55 - unsigned char power_level; 56 - unsigned char antenna_max; 57 - }; 58 - 59 - static const struct ieee80211_channel_range ieee80211_fcc_channels[] = { 60 - { 2412, 2462, 27, 6 } /* IEEE 802.11b/g, channels 1..11 */, 61 - { 5180, 5240, 17, 6 } /* IEEE 802.11a, channels 36..48 */, 62 - { 5260, 5320, 23, 6 } /* IEEE 802.11a, channels 52..64 */, 63 - { 5745, 5825, 30, 6 } /* IEEE 802.11a, channels 149..165, outdoor */, 64 - { 0 } 65 - }; 66 - 67 - static const struct ieee80211_channel_range ieee80211_mkk_channels[] = { 68 - { 2412, 2472, 20, 6 } /* IEEE 802.11b/g, channels 1..13 */, 69 - { 5170, 5240, 20, 6 } /* IEEE 802.11a, channels 34..48 */, 70 - { 5260, 5320, 20, 6 } /* IEEE 802.11a, channels 52..64 */, 71 - { 0 } 72 - }; 73 - 74 - 75 - static const struct ieee80211_channel_range *channel_range = 76 - ieee80211_fcc_channels; 77 - 78 - 79 - static void ieee80211_unmask_channel(int mode, struct ieee80211_channel *chan) 80 - { 81 - int i; 82 - 83 - chan->flag = 0; 84 - 85 - for (i = 0; channel_range[i].start_freq; i++) { 86 - const struct ieee80211_channel_range *r = &channel_range[i]; 87 - if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) { 88 - if (ieee80211_regdom == 64 && !ieee80211_japan_5ghz && 89 - chan->freq >= 5260 && chan->freq <= 5320) { 90 - /* 91 - * Skip new channels in Japan since the 92 - * firmware was not marked having been upgraded 93 - * by the vendor. 94 - */ 95 - continue; 96 - } 97 - 98 - if (ieee80211_regdom == 0x10 && 99 - (chan->freq == 5190 || chan->freq == 5210 || 100 - chan->freq == 5230)) { 101 - /* Skip MKK channels when in FCC domain. */ 102 - continue; 103 - } 104 - 105 - chan->flag |= IEEE80211_CHAN_W_SCAN | 106 - IEEE80211_CHAN_W_ACTIVE_SCAN | 107 - IEEE80211_CHAN_W_IBSS; 108 - chan->power_level = r->power_level; 109 - chan->antenna_max = r->antenna_max; 110 - 111 - if (ieee80211_regdom == 64 && 112 - (chan->freq == 5170 || chan->freq == 5190 || 113 - chan->freq == 5210 || chan->freq == 5230)) { 114 - /* 115 - * New regulatory rules in Japan have backwards 116 - * compatibility with old channels in 5.15-5.25 117 - * GHz band, but the station is not allowed to 118 - * use active scan on these old channels. 119 - */ 120 - chan->flag &= ~IEEE80211_CHAN_W_ACTIVE_SCAN; 121 - } 122 - 123 - if (ieee80211_regdom == 64 && 124 - (chan->freq == 5260 || chan->freq == 5280 || 125 - chan->freq == 5300 || chan->freq == 5320)) { 126 - /* 127 - * IBSS is not allowed on 5.25-5.35 GHz band 128 - * due to radar detection requirements. 129 - */ 130 - chan->flag &= ~IEEE80211_CHAN_W_IBSS; 131 - } 132 - 133 - break; 134 - } 135 - } 136 - } 137 - 138 - 139 - void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode) 140 - { 141 - int c; 142 - for (c = 0; c < mode->num_channels; c++) 143 - ieee80211_unmask_channel(mode->mode, &mode->channels[c]); 144 - } 145 - 146 - 147 - void ieee80211_regdomain_init(void) 148 - { 149 - if (ieee80211_regdom == 0x40) 150 - channel_range = ieee80211_mkk_channels; 151 - } 152 -
+47 -35
net/mac80211/rx.c
··· 82 82 */ 83 83 static struct sk_buff * 84 84 ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, 85 - struct ieee80211_rx_status *status) 85 + struct ieee80211_rx_status *status, 86 + struct ieee80211_rate *rate) 86 87 { 87 88 struct ieee80211_sub_if_data *sdata; 88 - struct ieee80211_rate *rate; 89 89 int needed_headroom = 0; 90 90 struct ieee80211_radiotap_header *rthdr; 91 91 __le64 *rttsft = NULL; ··· 194 194 rtfixed->rx_flags |= 195 195 cpu_to_le16(IEEE80211_RADIOTAP_F_RX_BADFCS); 196 196 197 - rate = ieee80211_get_rate(local, status->phymode, 198 - status->rate); 199 - if (rate) 200 - rtfixed->rate = rate->rate / 5; 197 + rtfixed->rate = rate->bitrate / 5; 201 198 202 199 rtfixed->chan_freq = cpu_to_le16(status->freq); 203 200 204 - if (status->phymode == MODE_IEEE80211A) 201 + if (status->band == IEEE80211_BAND_5GHZ) 205 202 rtfixed->chan_flags = 206 203 cpu_to_le16(IEEE80211_CHAN_OFDM | 207 204 IEEE80211_CHAN_5GHZ); ··· 317 320 318 321 319 322 static u32 ieee80211_rx_load_stats(struct ieee80211_local *local, 320 - struct sk_buff *skb, 321 - struct ieee80211_rx_status *status) 323 + struct sk_buff *skb, 324 + struct ieee80211_rx_status *status, 325 + struct ieee80211_rate *rate) 322 326 { 323 327 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 324 328 u32 load = 0, hdrtime; 325 - struct ieee80211_rate *rate; 326 - struct ieee80211_hw_mode *mode = local->hw.conf.mode; 327 - int i; 328 329 329 330 /* Estimate total channel use caused by this frame */ 330 - 331 - if (unlikely(mode->num_rates < 0)) 332 - return TXRX_CONTINUE; 333 - 334 - rate = &mode->rates[0]; 335 - for (i = 0; i < mode->num_rates; i++) { 336 - if (mode->rates[i].val == status->rate) { 337 - rate = &mode->rates[i]; 338 - break; 339 - } 340 - } 341 331 342 332 /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values, 343 333 * 1 usec = 1/8 * (1080 / 10) = 13.5 */ 344 334 345 - if (mode->mode == MODE_IEEE80211A || 346 - (mode->mode == MODE_IEEE80211G && 347 - rate->flags & IEEE80211_RATE_ERP)) 335 + if (status->band == IEEE80211_BAND_5GHZ || 336 + (status->band == IEEE80211_BAND_5GHZ && 337 + rate->flags & IEEE80211_RATE_ERP_G)) 348 338 hdrtime = CHAN_UTIL_HDR_SHORT; 349 339 else 350 340 hdrtime = CHAN_UTIL_HDR_LONG; ··· 340 356 if (!is_multicast_ether_addr(hdr->addr1)) 341 357 load += hdrtime; 342 358 343 - load += skb->len * rate->rate_inv; 359 + /* TODO: optimise again */ 360 + load += skb->len * CHAN_UTIL_RATE_LCM / rate->bitrate; 344 361 345 362 /* Divide channel_use by 8 to avoid wrapping around the counter */ 346 363 load >>= CHAN_UTIL_SHIFT; ··· 1670 1685 static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, 1671 1686 struct sk_buff *skb, 1672 1687 struct ieee80211_rx_status *status, 1673 - u32 load) 1688 + u32 load, 1689 + struct ieee80211_rate *rate) 1674 1690 { 1675 1691 struct ieee80211_local *local = hw_to_local(hw); 1676 1692 struct ieee80211_sub_if_data *sdata; ··· 1691 1705 1692 1706 rx.u.rx.status = status; 1693 1707 rx.u.rx.load = load; 1708 + rx.u.rx.rate = rate; 1694 1709 rx.fc = le16_to_cpu(hdr->frame_control); 1695 1710 type = rx.fc & IEEE80211_FCTL_FTYPE; 1696 1711 ··· 1824 1837 u16 head_seq_num, buf_size; 1825 1838 int index; 1826 1839 u32 pkt_load; 1840 + struct ieee80211_supported_band *sband; 1841 + struct ieee80211_rate *rate; 1827 1842 1828 1843 buf_size = tid_agg_rx->buf_size; 1829 1844 head_seq_num = tid_agg_rx->head_seq_num; ··· 1856 1867 memcpy(&status, 1857 1868 tid_agg_rx->reorder_buf[index]->cb, 1858 1869 sizeof(status)); 1870 + sband = local->hw.wiphy->bands[status.band]; 1871 + rate = &sband->bitrates[status.rate_idx]; 1859 1872 pkt_load = ieee80211_rx_load_stats(local, 1860 1873 tid_agg_rx->reorder_buf[index], 1861 - &status); 1874 + &status, rate); 1862 1875 __ieee80211_rx_handle_packet(hw, 1863 1876 tid_agg_rx->reorder_buf[index], 1864 - &status, pkt_load); 1877 + &status, pkt_load, rate); 1865 1878 tid_agg_rx->stored_mpdu_num--; 1866 1879 tid_agg_rx->reorder_buf[index] = NULL; 1867 1880 } ··· 1903 1912 /* release the reordered frame back to stack */ 1904 1913 memcpy(&status, tid_agg_rx->reorder_buf[index]->cb, 1905 1914 sizeof(status)); 1915 + sband = local->hw.wiphy->bands[status.band]; 1916 + rate = &sband->bitrates[status.rate_idx]; 1906 1917 pkt_load = ieee80211_rx_load_stats(local, 1907 1918 tid_agg_rx->reorder_buf[index], 1908 - &status); 1919 + &status, rate); 1909 1920 __ieee80211_rx_handle_packet(hw, tid_agg_rx->reorder_buf[index], 1910 - &status, pkt_load); 1921 + &status, pkt_load, rate); 1911 1922 tid_agg_rx->stored_mpdu_num--; 1912 1923 tid_agg_rx->reorder_buf[index] = NULL; 1913 1924 tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); ··· 1990 1997 { 1991 1998 struct ieee80211_local *local = hw_to_local(hw); 1992 1999 u32 pkt_load; 2000 + struct ieee80211_rate *rate = NULL; 2001 + struct ieee80211_supported_band *sband; 2002 + 2003 + if (status->band < 0 || 2004 + status->band > IEEE80211_NUM_BANDS) { 2005 + WARN_ON(1); 2006 + return; 2007 + } 2008 + 2009 + sband = local->hw.wiphy->bands[status->band]; 2010 + 2011 + if (!sband || 2012 + status->rate_idx < 0 || 2013 + status->rate_idx >= sband->n_bitrates) { 2014 + WARN_ON(1); 2015 + return; 2016 + } 2017 + 2018 + rate = &sband->bitrates[status->rate_idx]; 1993 2019 1994 2020 /* 1995 2021 * key references and virtual interfaces are protected using RCU ··· 2023 2011 * if it was previously present. 2024 2012 * Also, frames with less than 16 bytes are dropped. 2025 2013 */ 2026 - skb = ieee80211_rx_monitor(local, skb, status); 2014 + skb = ieee80211_rx_monitor(local, skb, status, rate); 2027 2015 if (!skb) { 2028 2016 rcu_read_unlock(); 2029 2017 return; 2030 2018 } 2031 2019 2032 - pkt_load = ieee80211_rx_load_stats(local, skb, status); 2020 + pkt_load = ieee80211_rx_load_stats(local, skb, status, rate); 2033 2021 local->channel_use_raw += pkt_load; 2034 2022 2035 2023 if (!ieee80211_rx_reorder_ampdu(local, skb)) 2036 - __ieee80211_rx_handle_packet(hw, skb, status, pkt_load); 2024 + __ieee80211_rx_handle_packet(hw, skb, status, pkt_load, rate); 2037 2025 2038 2026 rcu_read_unlock(); 2039 2027 }
-24
net/mac80211/sta_info.c
··· 74 74 } 75 75 EXPORT_SYMBOL(sta_info_get); 76 76 77 - int sta_info_min_txrate_get(struct ieee80211_local *local) 78 - { 79 - struct sta_info *sta; 80 - struct ieee80211_hw_mode *mode; 81 - int min_txrate = 9999999; 82 - int i; 83 - 84 - read_lock_bh(&local->sta_lock); 85 - mode = local->oper_hw_mode; 86 - for (i = 0; i < STA_HASH_SIZE; i++) { 87 - sta = local->sta_hash[i]; 88 - while (sta) { 89 - if (sta->txrate < min_txrate) 90 - min_txrate = sta->txrate; 91 - sta = sta->hnext; 92 - } 93 - } 94 - read_unlock_bh(&local->sta_lock); 95 - if (min_txrate == 9999999) 96 - min_txrate = 0; 97 - 98 - return mode->rates[min_txrate].rate; 99 - } 100 - 101 77 102 78 static void sta_info_release(struct kref *kref) 103 79 {
+5 -5
net/mac80211/sta_info.h
··· 133 133 unsigned int wep_weak_iv_count; /* number of RX frames with weak IV */ 134 134 135 135 unsigned long last_rx; 136 - u32 supp_rates; /* bitmap of supported rates in local->curr_rates */ 137 - int txrate; /* index in local->curr_rates */ 138 - int last_txrate; /* last rate used to send a frame to this STA */ 139 - int last_nonerp_idx; 136 + /* bitmap of supported rates per band */ 137 + u64 supp_rates[IEEE80211_NUM_BANDS]; 138 + int txrate_idx; 139 + /* last rates used to send a frame to this STA */ 140 + int last_txrate_idx, last_nonerp_txrate_idx; 140 141 141 142 struct net_device *dev; /* which net device is this station associated 142 143 * to */ ··· 223 222 } 224 223 225 224 struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr); 226 - int sta_info_min_txrate_get(struct ieee80211_local *local); 227 225 void sta_info_put(struct sta_info *sta); 228 226 struct sta_info * sta_info_add(struct ieee80211_local *local, 229 227 struct net_device *dev, u8 *addr, gfp_t gfp);
+101 -61
net/mac80211/tx.c
··· 92 92 int rate, mrate, erp, dur, i; 93 93 struct ieee80211_rate *txrate = tx->u.tx.rate; 94 94 struct ieee80211_local *local = tx->local; 95 - struct ieee80211_hw_mode *mode = tx->u.tx.mode; 95 + struct ieee80211_supported_band *sband; 96 96 97 - erp = txrate->flags & IEEE80211_RATE_ERP; 97 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 98 + 99 + erp = 0; 100 + if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) 101 + erp = txrate->flags & IEEE80211_RATE_ERP_G; 98 102 99 103 /* 100 104 * data and mgmt (except PS Poll): ··· 154 150 * Mandatory rates for IEEE 802.11g PHY: 1, 2, 5.5, 11, 6, 12, 24 Mbps 155 151 */ 156 152 rate = -1; 157 - mrate = 10; /* use 1 Mbps if everything fails */ 158 - for (i = 0; i < mode->num_rates; i++) { 159 - struct ieee80211_rate *r = &mode->rates[i]; 160 - if (r->rate > txrate->rate) 153 + /* use lowest available if everything fails */ 154 + mrate = sband->bitrates[0].bitrate; 155 + for (i = 0; i < sband->n_bitrates; i++) { 156 + struct ieee80211_rate *r = &sband->bitrates[i]; 157 + 158 + if (r->bitrate > txrate->bitrate) 161 159 break; 162 160 163 - if (IEEE80211_RATE_MODULATION(txrate->flags) != 164 - IEEE80211_RATE_MODULATION(r->flags)) 165 - continue; 161 + if (tx->sdata->basic_rates & BIT(i)) 162 + rate = r->bitrate; 166 163 167 - if (r->flags & IEEE80211_RATE_BASIC) 168 - rate = r->rate; 169 - else if (r->flags & IEEE80211_RATE_MANDATORY) 170 - mrate = r->rate; 164 + switch (sband->band) { 165 + case IEEE80211_BAND_2GHZ: { 166 + u32 flag; 167 + if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) 168 + flag = IEEE80211_RATE_MANDATORY_G; 169 + else 170 + flag = IEEE80211_RATE_MANDATORY_B; 171 + if (r->flags & flag) 172 + mrate = r->bitrate; 173 + break; 174 + } 175 + case IEEE80211_BAND_5GHZ: 176 + if (r->flags & IEEE80211_RATE_MANDATORY_A) 177 + mrate = r->bitrate; 178 + break; 179 + case IEEE80211_NUM_BANDS: 180 + WARN_ON(1); 181 + break; 182 + } 171 183 } 172 184 if (rate == -1) { 173 185 /* No matching basic rate found; use highest suitable mandatory ··· 204 184 dur *= 2; /* ACK + SIFS */ 205 185 /* next fragment */ 206 186 dur += ieee80211_frame_duration(local, next_frag_len, 207 - txrate->rate, erp, 187 + txrate->bitrate, erp, 208 188 tx->sdata->bss_conf.use_short_preamble); 209 189 } 210 190 ··· 605 585 ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx) 606 586 { 607 587 struct rate_selection rsel; 588 + struct ieee80211_supported_band *sband; 589 + 590 + sband = tx->local->hw.wiphy->bands[tx->local->hw.conf.channel->band]; 608 591 609 592 if (likely(!tx->u.tx.rate)) { 610 - rate_control_get_rate(tx->dev, tx->u.tx.mode, tx->skb, &rsel); 593 + rate_control_get_rate(tx->dev, sband, tx->skb, &rsel); 611 594 tx->u.tx.rate = rsel.rate; 612 - if (unlikely(rsel.probe != NULL)) { 595 + if (unlikely(rsel.probe)) { 613 596 tx->u.tx.control->flags |= 614 597 IEEE80211_TXCTL_RATE_CTRL_PROBE; 615 598 tx->flags |= IEEE80211_TXRXD_TXPROBE_LAST_FRAG; 616 - tx->u.tx.control->alt_retry_rate = tx->u.tx.rate->val; 599 + tx->u.tx.control->alt_retry_rate = tx->u.tx.rate; 617 600 tx->u.tx.rate = rsel.probe; 618 601 } else 619 - tx->u.tx.control->alt_retry_rate = -1; 602 + tx->u.tx.control->alt_retry_rate = NULL; 620 603 621 604 if (!tx->u.tx.rate) 622 605 return TXRX_DROP; 623 606 } else 624 - tx->u.tx.control->alt_retry_rate = -1; 607 + tx->u.tx.control->alt_retry_rate = NULL; 625 608 626 - if (tx->u.tx.mode->mode == MODE_IEEE80211G && 627 - tx->sdata->bss_conf.use_cts_prot && 609 + if (tx->sdata->bss_conf.use_cts_prot && 628 610 (tx->flags & IEEE80211_TXRXD_FRAGMENTED) && rsel.nonerp) { 629 611 tx->u.tx.last_frag_rate = tx->u.tx.rate; 630 612 if (rsel.probe) ··· 634 612 else 635 613 tx->flags |= IEEE80211_TXRXD_TXPROBE_LAST_FRAG; 636 614 tx->u.tx.rate = rsel.nonerp; 637 - tx->u.tx.control->rate = rsel.nonerp; 615 + tx->u.tx.control->tx_rate = rsel.nonerp; 638 616 tx->u.tx.control->flags &= ~IEEE80211_TXCTL_RATE_CTRL_PROBE; 639 617 } else { 640 618 tx->u.tx.last_frag_rate = tx->u.tx.rate; 641 - tx->u.tx.control->rate = tx->u.tx.rate; 619 + tx->u.tx.control->tx_rate = tx->u.tx.rate; 642 620 } 643 - tx->u.tx.control->tx_rate = tx->u.tx.rate->val; 621 + tx->u.tx.control->tx_rate = tx->u.tx.rate; 644 622 645 623 return TXRX_CONTINUE; 646 624 } ··· 652 630 u16 fc = le16_to_cpu(hdr->frame_control); 653 631 u16 dur; 654 632 struct ieee80211_tx_control *control = tx->u.tx.control; 655 - struct ieee80211_hw_mode *mode = tx->u.tx.mode; 656 633 657 634 if (!control->retry_limit) { 658 635 if (!is_multicast_ether_addr(hdr->addr1)) { ··· 678 657 * frames. 679 658 * TODO: The last fragment could still use multiple retry 680 659 * rates. */ 681 - control->alt_retry_rate = -1; 660 + control->alt_retry_rate = NULL; 682 661 } 683 662 684 663 /* Use CTS protection for unicast frames sent using extended rates if 685 664 * there are associated non-ERP stations and RTS/CTS is not configured 686 665 * for the frame. */ 687 - if (mode->mode == MODE_IEEE80211G && 688 - (tx->u.tx.rate->flags & IEEE80211_RATE_ERP) && 666 + if ((tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) && 667 + (tx->u.tx.rate->flags & IEEE80211_RATE_ERP_G) && 689 668 (tx->flags & IEEE80211_TXRXD_TXUNICAST) && 690 669 tx->sdata->bss_conf.use_cts_prot && 691 670 !(control->flags & IEEE80211_TXCTL_USE_RTS_CTS)) ··· 695 674 * short preambles at the selected rate and short preambles are 696 675 * available on the network at the current point in time. */ 697 676 if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && 698 - (tx->u.tx.rate->flags & IEEE80211_RATE_PREAMBLE2) && 677 + (tx->u.tx.rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) && 699 678 tx->sdata->bss_conf.use_short_preamble && 700 679 (!tx->sta || (tx->sta->flags & WLAN_STA_SHORT_PREAMBLE))) { 701 - tx->u.tx.control->tx_rate = tx->u.tx.rate->val2; 680 + tx->u.tx.control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; 702 681 } 703 682 704 683 /* Setup duration field for the first fragment of the frame. Duration ··· 711 690 712 691 if ((control->flags & IEEE80211_TXCTL_USE_RTS_CTS) || 713 692 (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) { 714 - struct ieee80211_rate *rate; 693 + struct ieee80211_supported_band *sband; 694 + struct ieee80211_rate *rate, *baserate; 695 + int idx; 696 + 697 + sband = tx->local->hw.wiphy->bands[ 698 + tx->local->hw.conf.channel->band]; 715 699 716 700 /* Do not use multiple retry rates when using RTS/CTS */ 717 - control->alt_retry_rate = -1; 701 + control->alt_retry_rate = NULL; 718 702 719 703 /* Use min(data rate, max base rate) as CTS/RTS rate */ 720 704 rate = tx->u.tx.rate; 721 - while (rate > mode->rates && 722 - !(rate->flags & IEEE80211_RATE_BASIC)) 723 - rate--; 705 + baserate = NULL; 724 706 725 - control->rts_cts_rate = rate->val; 726 - control->rts_rate = rate; 707 + for (idx = 0; idx < sband->n_bitrates; idx++) { 708 + if (sband->bitrates[idx].bitrate > rate->bitrate) 709 + continue; 710 + if (tx->sdata->basic_rates & BIT(idx) && 711 + (!baserate || 712 + (baserate->bitrate < sband->bitrates[idx].bitrate))) 713 + baserate = &sband->bitrates[idx]; 714 + } 715 + 716 + if (baserate) 717 + control->rts_cts_rate = baserate; 718 + else 719 + control->rts_cts_rate = &sband->bitrates[0]; 727 720 } 728 721 729 722 if (tx->sta) { ··· 761 726 ieee80211_tx_h_load_stats(struct ieee80211_txrx_data *tx) 762 727 { 763 728 struct ieee80211_local *local = tx->local; 764 - struct ieee80211_hw_mode *mode = tx->u.tx.mode; 765 729 struct sk_buff *skb = tx->skb; 766 730 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 767 731 u32 load = 0, hdrtime; 732 + struct ieee80211_rate *rate = tx->u.tx.rate; 768 733 769 734 /* TODO: this could be part of tx_status handling, so that the number 770 735 * of retries would be known; TX rate should in that case be stored ··· 775 740 /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values, 776 741 * 1 usec = 1/8 * (1080 / 10) = 13.5 */ 777 742 778 - if (mode->mode == MODE_IEEE80211A || 779 - (mode->mode == MODE_IEEE80211G && 780 - tx->u.tx.rate->flags & IEEE80211_RATE_ERP)) 743 + if (tx->u.tx.channel->band == IEEE80211_BAND_5GHZ || 744 + (tx->u.tx.channel->band == IEEE80211_BAND_2GHZ && 745 + rate->flags & IEEE80211_RATE_ERP_G)) 781 746 hdrtime = CHAN_UTIL_HDR_SHORT; 782 747 else 783 748 hdrtime = CHAN_UTIL_HDR_LONG; ··· 791 756 else if (tx->u.tx.control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) 792 757 load += hdrtime; 793 758 794 - load += skb->len * tx->u.tx.rate->rate_inv; 759 + /* TODO: optimise again */ 760 + load += skb->len * CHAN_UTIL_RATE_LCM / rate->bitrate; 795 761 796 762 if (tx->u.tx.extra_frag) { 797 763 int i; 798 764 for (i = 0; i < tx->u.tx.num_extra_frag; i++) { 799 765 load += 2 * hdrtime; 800 766 load += tx->u.tx.extra_frag[i]->len * 801 - tx->u.tx.rate->rate; 767 + tx->u.tx.rate->bitrate; 802 768 } 803 769 } 804 770 ··· 852 816 struct ieee80211_radiotap_iterator iterator; 853 817 struct ieee80211_radiotap_header *rthdr = 854 818 (struct ieee80211_radiotap_header *) skb->data; 855 - struct ieee80211_hw_mode *mode = tx->local->hw.conf.mode; 819 + struct ieee80211_supported_band *sband; 856 820 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); 857 821 struct ieee80211_tx_control *control = tx->u.tx.control; 822 + 823 + sband = tx->local->hw.wiphy->bands[tx->local->hw.conf.channel->band]; 858 824 859 825 control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; 860 826 tx->flags |= IEEE80211_TXRXD_TX_INJECTED; ··· 890 852 * ieee80211 rate int is in 100kbps units eg, 0x0a=1Mbps 891 853 */ 892 854 target_rate = (*iterator.this_arg) * 5; 893 - for (i = 0; i < mode->num_rates; i++) { 894 - struct ieee80211_rate *r = &mode->rates[i]; 855 + for (i = 0; i < sband->n_bitrates; i++) { 856 + struct ieee80211_rate *r; 895 857 896 - if (r->rate == target_rate) { 858 + r = &sband->bitrates[i]; 859 + 860 + if (r->bitrate == target_rate) { 897 861 tx->u.tx.rate = r; 898 862 break; 899 863 } ··· 910 870 control->antenna_sel_tx = (*iterator.this_arg) + 1; 911 871 break; 912 872 873 + #if 0 913 874 case IEEE80211_RADIOTAP_DBM_TX_POWER: 914 875 control->power_level = *iterator.this_arg; 915 876 break; 877 + #endif 916 878 917 879 case IEEE80211_RADIOTAP_FLAGS: 918 880 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) { ··· 1096 1054 if (__ieee80211_queue_stopped(local, control->queue)) 1097 1055 return IEEE80211_TX_FRAG_AGAIN; 1098 1056 if (i == tx->u.tx.num_extra_frag) { 1099 - control->tx_rate = tx->u.tx.last_frag_hwrate; 1100 - control->rate = tx->u.tx.last_frag_rate; 1057 + control->tx_rate = tx->u.tx.last_frag_rate; 1058 + 1101 1059 if (tx->flags & IEEE80211_TXRXD_TXPROBE_LAST_FRAG) 1102 1060 control->flags |= 1103 1061 IEEE80211_TXCTL_RATE_CTRL_PROBE; ··· 1156 1114 rcu_read_lock(); 1157 1115 1158 1116 sta = tx.sta; 1159 - tx.u.tx.mode = local->hw.conf.mode; 1117 + tx.u.tx.channel = local->hw.conf.channel; 1160 1118 1161 1119 for (handler = local->tx_handlers; *handler != NULL; 1162 1120 handler++) { ··· 1193 1151 } else { 1194 1152 next_len = 0; 1195 1153 tx.u.tx.rate = tx.u.tx.last_frag_rate; 1196 - tx.u.tx.last_frag_hwrate = tx.u.tx.rate->val; 1197 1154 } 1198 1155 dur = ieee80211_duration(&tx, 0, next_len); 1199 1156 hdr->duration_id = cpu_to_le16(dur); ··· 1229 1188 store->skb = skb; 1230 1189 store->extra_frag = tx.u.tx.extra_frag; 1231 1190 store->num_extra_frag = tx.u.tx.num_extra_frag; 1232 - store->last_frag_hwrate = tx.u.tx.last_frag_hwrate; 1233 1191 store->last_frag_rate = tx.u.tx.last_frag_rate; 1234 1192 store->last_frag_rate_ctrl_probe = 1235 1193 !!(tx.flags & IEEE80211_TXRXD_TXPROBE_LAST_FRAG); ··· 1649 1609 tx.u.tx.control = &store->control; 1650 1610 tx.u.tx.extra_frag = store->extra_frag; 1651 1611 tx.u.tx.num_extra_frag = store->num_extra_frag; 1652 - tx.u.tx.last_frag_hwrate = store->last_frag_hwrate; 1653 1612 tx.u.tx.last_frag_rate = store->last_frag_rate; 1654 1613 tx.flags = 0; 1655 1614 if (store->last_frag_rate_ctrl_probe) ··· 1751 1712 struct ieee80211_if_ap *ap = NULL; 1752 1713 struct rate_selection rsel; 1753 1714 struct beacon_data *beacon; 1715 + struct ieee80211_supported_band *sband; 1716 + 1717 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1754 1718 1755 1719 rcu_read_lock(); 1756 1720 ··· 1792 1750 beacon->tail_len); 1793 1751 1794 1752 if (control) { 1795 - rate_control_get_rate(local->mdev, local->oper_hw_mode, skb, 1796 - &rsel); 1753 + rate_control_get_rate(local->mdev, sband, skb, &rsel); 1797 1754 if (!rsel.rate) { 1798 1755 if (net_ratelimit()) { 1799 1756 printk(KERN_DEBUG "%s: ieee80211_beacon_get: " ··· 1805 1764 } 1806 1765 1807 1766 control->vif = vif; 1808 - control->tx_rate = 1809 - (sdata->bss_conf.use_short_preamble && 1810 - (rsel.rate->flags & IEEE80211_RATE_PREAMBLE2)) ? 1811 - rsel.rate->val2 : rsel.rate->val; 1767 + control->tx_rate = rsel.rate; 1768 + if (sdata->bss_conf.use_short_preamble && 1769 + rsel.rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) 1770 + control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; 1812 1771 control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; 1813 - control->power_level = local->hw.conf.power_level; 1814 1772 control->flags |= IEEE80211_TXCTL_NO_ACK; 1815 1773 control->retry_limit = 1; 1816 1774 control->flags |= IEEE80211_TXCTL_CLEAR_DST_MASK; ··· 1914 1874 } 1915 1875 sta = tx.sta; 1916 1876 tx.flags |= IEEE80211_TXRXD_TXPS_BUFFERED; 1917 - tx.u.tx.mode = local->hw.conf.mode; 1877 + tx.u.tx.channel = local->hw.conf.channel; 1918 1878 1919 1879 for (handler = local->tx_handlers; *handler != NULL; handler++) { 1920 1880 res = (*handler)(&tx);
+22 -120
net/mac80211/util.c
··· 41 41 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; 42 42 43 43 44 - static int rate_list_match(const int *rate_list, int rate) 45 - { 46 - int i; 47 - 48 - if (!rate_list) 49 - return 0; 50 - 51 - for (i = 0; rate_list[i] >= 0; i++) 52 - if (rate_list[i] == rate) 53 - return 1; 54 - 55 - return 0; 56 - } 57 - 58 - void ieee80211_prepare_rates(struct ieee80211_local *local, 59 - struct ieee80211_hw_mode *mode) 60 - { 61 - int i; 62 - 63 - for (i = 0; i < mode->num_rates; i++) { 64 - struct ieee80211_rate *rate = &mode->rates[i]; 65 - 66 - rate->flags &= ~(IEEE80211_RATE_SUPPORTED | 67 - IEEE80211_RATE_BASIC); 68 - 69 - if (local->supp_rates[mode->mode]) { 70 - if (!rate_list_match(local->supp_rates[mode->mode], 71 - rate->rate)) 72 - continue; 73 - } 74 - 75 - rate->flags |= IEEE80211_RATE_SUPPORTED; 76 - 77 - /* Use configured basic rate set if it is available. If not, 78 - * use defaults that are sane for most cases. */ 79 - if (local->basic_rates[mode->mode]) { 80 - if (rate_list_match(local->basic_rates[mode->mode], 81 - rate->rate)) 82 - rate->flags |= IEEE80211_RATE_BASIC; 83 - } else switch (mode->mode) { 84 - case MODE_IEEE80211A: 85 - if (rate->rate == 60 || rate->rate == 120 || 86 - rate->rate == 240) 87 - rate->flags |= IEEE80211_RATE_BASIC; 88 - break; 89 - case MODE_IEEE80211B: 90 - if (rate->rate == 10 || rate->rate == 20) 91 - rate->flags |= IEEE80211_RATE_BASIC; 92 - break; 93 - case MODE_IEEE80211G: 94 - if (rate->rate == 10 || rate->rate == 20 || 95 - rate->rate == 55 || rate->rate == 110) 96 - rate->flags |= IEEE80211_RATE_BASIC; 97 - break; 98 - case NUM_IEEE80211_MODES: 99 - /* not useful */ 100 - break; 101 - } 102 - 103 - /* Set ERP and MANDATORY flags based on phymode */ 104 - switch (mode->mode) { 105 - case MODE_IEEE80211A: 106 - if (rate->rate == 60 || rate->rate == 120 || 107 - rate->rate == 240) 108 - rate->flags |= IEEE80211_RATE_MANDATORY; 109 - break; 110 - case MODE_IEEE80211B: 111 - if (rate->rate == 10) 112 - rate->flags |= IEEE80211_RATE_MANDATORY; 113 - break; 114 - case MODE_IEEE80211G: 115 - if (rate->rate == 10 || rate->rate == 20 || 116 - rate->rate == 55 || rate->rate == 110 || 117 - rate->rate == 60 || rate->rate == 120 || 118 - rate->rate == 240) 119 - rate->flags |= IEEE80211_RATE_MANDATORY; 120 - break; 121 - case NUM_IEEE80211_MODES: 122 - /* not useful */ 123 - break; 124 - } 125 - if (ieee80211_is_erp_rate(mode->mode, rate->rate)) 126 - rate->flags |= IEEE80211_RATE_ERP; 127 - } 128 - } 129 - 130 44 u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len, 131 45 enum ieee80211_if_types type) 132 46 { ··· 176 262 * DIV_ROUND_UP() operations. 177 263 */ 178 264 179 - if (local->hw.conf.phymode == MODE_IEEE80211A || erp) { 265 + if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ || erp) { 180 266 /* 181 267 * OFDM: 182 268 * ··· 218 304 /* Exported duration function for driver use */ 219 305 __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, 220 306 struct ieee80211_vif *vif, 221 - size_t frame_len, int rate) 307 + size_t frame_len, 308 + struct ieee80211_rate *rate) 222 309 { 223 310 struct ieee80211_local *local = hw_to_local(hw); 224 311 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 225 312 u16 dur; 226 313 int erp; 227 314 228 - erp = ieee80211_is_erp_rate(hw->conf.phymode, rate); 229 - dur = ieee80211_frame_duration(local, frame_len, rate, erp, 315 + erp = 0; 316 + if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) 317 + erp = rate->flags & IEEE80211_RATE_ERP_G; 318 + 319 + dur = ieee80211_frame_duration(local, frame_len, rate->bitrate, erp, 230 320 sdata->bss_conf.use_short_preamble); 231 321 232 322 return cpu_to_le16(dur); ··· 250 332 251 333 short_preamble = sdata->bss_conf.use_short_preamble; 252 334 253 - rate = frame_txctl->rts_rate; 254 - erp = !!(rate->flags & IEEE80211_RATE_ERP); 335 + rate = frame_txctl->rts_cts_rate; 336 + 337 + erp = 0; 338 + if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) 339 + erp = rate->flags & IEEE80211_RATE_ERP_G; 255 340 256 341 /* CTS duration */ 257 - dur = ieee80211_frame_duration(local, 10, rate->rate, 342 + dur = ieee80211_frame_duration(local, 10, rate->bitrate, 258 343 erp, short_preamble); 259 344 /* Data frame duration */ 260 - dur += ieee80211_frame_duration(local, frame_len, rate->rate, 345 + dur += ieee80211_frame_duration(local, frame_len, rate->bitrate, 261 346 erp, short_preamble); 262 347 /* ACK duration */ 263 - dur += ieee80211_frame_duration(local, 10, rate->rate, 348 + dur += ieee80211_frame_duration(local, 10, rate->bitrate, 264 349 erp, short_preamble); 265 350 266 351 return cpu_to_le16(dur); ··· 284 363 285 364 short_preamble = sdata->bss_conf.use_short_preamble; 286 365 287 - rate = frame_txctl->rts_rate; 288 - erp = !!(rate->flags & IEEE80211_RATE_ERP); 366 + rate = frame_txctl->rts_cts_rate; 367 + erp = 0; 368 + if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) 369 + erp = rate->flags & IEEE80211_RATE_ERP_G; 289 370 290 371 /* Data frame duration */ 291 - dur = ieee80211_frame_duration(local, frame_len, rate->rate, 372 + dur = ieee80211_frame_duration(local, frame_len, rate->bitrate, 292 373 erp, short_preamble); 293 374 if (!(frame_txctl->flags & IEEE80211_TXCTL_NO_ACK)) { 294 375 /* ACK duration */ 295 - dur += ieee80211_frame_duration(local, 10, rate->rate, 376 + dur += ieee80211_frame_duration(local, 10, rate->bitrate, 296 377 erp, short_preamble); 297 378 } 298 379 299 380 return cpu_to_le16(dur); 300 381 } 301 382 EXPORT_SYMBOL(ieee80211_ctstoself_duration); 302 - 303 - struct ieee80211_rate * 304 - ieee80211_get_rate(struct ieee80211_local *local, int phymode, int hw_rate) 305 - { 306 - struct ieee80211_hw_mode *mode; 307 - int r; 308 - 309 - list_for_each_entry(mode, &local->modes_list, list) { 310 - if (mode->mode != phymode) 311 - continue; 312 - for (r = 0; r < mode->num_rates; r++) { 313 - struct ieee80211_rate *rate = &mode->rates[r]; 314 - if (rate->val == hw_rate || 315 - (rate->flags & IEEE80211_RATE_PREAMBLE2 && 316 - rate->val2 == hw_rate)) 317 - return rate; 318 - } 319 - } 320 - 321 - return NULL; 322 - } 323 383 324 384 void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue) 325 385 {
+1 -1
net/wireless/Makefile
··· 1 1 obj-$(CONFIG_WIRELESS_EXT) += wext.o 2 2 obj-$(CONFIG_CFG80211) += cfg80211.o 3 3 4 - cfg80211-y += core.o sysfs.o radiotap.o 4 + cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o 5 5 cfg80211-$(CONFIG_NL80211) += nl80211.o
+41
net/wireless/core.c
··· 232 232 { 233 233 struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy); 234 234 int res; 235 + enum ieee80211_band band; 236 + struct ieee80211_supported_band *sband; 237 + bool have_band = false; 238 + int i; 239 + 240 + /* sanity check supported bands/channels */ 241 + for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 242 + sband = wiphy->bands[band]; 243 + if (!sband) 244 + continue; 245 + 246 + sband->band = band; 247 + 248 + if (!sband->n_channels || !sband->n_bitrates) { 249 + WARN_ON(1); 250 + return -EINVAL; 251 + } 252 + 253 + for (i = 0; i < sband->n_channels; i++) { 254 + sband->channels[i].orig_flags = 255 + sband->channels[i].flags; 256 + sband->channels[i].orig_mag = 257 + sband->channels[i].max_antenna_gain; 258 + sband->channels[i].orig_mpwr = 259 + sband->channels[i].max_power; 260 + sband->channels[i].band = band; 261 + } 262 + 263 + have_band = true; 264 + } 265 + 266 + if (!have_band) { 267 + WARN_ON(1); 268 + return -EINVAL; 269 + } 270 + 271 + /* check and set up bitrates */ 272 + ieee80211_set_bitrate_flags(wiphy); 273 + 274 + /* set up regulatory info */ 275 + wiphy_update_regulatory(wiphy); 235 276 236 277 mutex_lock(&cfg80211_drv_mutex); 237 278
+3
net/wireless/core.h
··· 78 78 extern int cfg80211_dev_rename(struct cfg80211_registered_device *drv, 79 79 char *newname); 80 80 81 + void ieee80211_set_bitrate_flags(struct wiphy *wiphy); 82 + void wiphy_update_regulatory(struct wiphy *wiphy); 83 + 81 84 #endif /* __NET_WIRELESS_CORE_H */
+153
net/wireless/reg.c
··· 1 + /* 2 + * Copyright 2002-2005, Instant802 Networks, Inc. 3 + * Copyright 2005-2006, Devicescape Software, Inc. 4 + * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + 11 + /* 12 + * This regulatory domain control implementation is highly incomplete, it 13 + * only exists for the purpose of not regressing mac80211. 14 + * 15 + * For now, drivers can restrict the set of allowed channels by either 16 + * not registering those channels or setting the IEEE80211_CHAN_DISABLED 17 + * flag; that flag will only be *set* by this code, never *cleared. 18 + * 19 + * The usual implementation is for a driver to read a device EEPROM to 20 + * determine which regulatory domain it should be operating under, then 21 + * looking up the allowable channels in a driver-local table and finally 22 + * registering those channels in the wiphy structure. 23 + * 24 + * Alternatively, drivers that trust the regulatory domain control here 25 + * will register a complete set of capabilities and the control code 26 + * will restrict the set by setting the IEEE80211_CHAN_* flags. 27 + */ 28 + #include <linux/kernel.h> 29 + #include <net/wireless.h> 30 + #include "core.h" 31 + 32 + static char *ieee80211_regdom = "US"; 33 + module_param(ieee80211_regdom, charp, 0444); 34 + MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code"); 35 + 36 + struct ieee80211_channel_range { 37 + short start_freq; 38 + short end_freq; 39 + int max_power; 40 + int max_antenna_gain; 41 + u32 flags; 42 + }; 43 + 44 + struct ieee80211_regdomain { 45 + const char *code; 46 + const struct ieee80211_channel_range *ranges; 47 + int n_ranges; 48 + }; 49 + 50 + #define RANGE_PWR(_start, _end, _pwr, _ag, _flags) \ 51 + { _start, _end, _pwr, _ag, _flags } 52 + 53 + 54 + /* 55 + * Ideally, in the future, these definitions will be loaded from a 56 + * userspace table via some daemon. 57 + */ 58 + static const struct ieee80211_channel_range ieee80211_US_channels[] = { 59 + /* IEEE 802.11b/g, channels 1..11 */ 60 + RANGE_PWR(2412, 2462, 27, 6, 0), 61 + /* IEEE 802.11a, channels 52..64 */ 62 + RANGE_PWR(5260, 5320, 23, 6, 0), 63 + /* IEEE 802.11a, channels 149..165, outdoor */ 64 + RANGE_PWR(5745, 5825, 30, 6, 0), 65 + }; 66 + 67 + static const struct ieee80211_channel_range ieee80211_JP_channels[] = { 68 + /* IEEE 802.11b/g, channels 1..14 */ 69 + RANGE_PWR(2412, 2484, 20, 6, 0), 70 + /* IEEE 802.11a, channels 34..48 */ 71 + RANGE_PWR(5170, 5240, 20, 6, IEEE80211_CHAN_PASSIVE_SCAN), 72 + /* IEEE 802.11a, channels 52..64 */ 73 + RANGE_PWR(5260, 5320, 20, 6, IEEE80211_CHAN_NO_IBSS | 74 + IEEE80211_CHAN_RADAR), 75 + }; 76 + 77 + #define REGDOM(_code) \ 78 + { \ 79 + .code = __stringify(_code), \ 80 + .ranges = ieee80211_ ##_code## _channels, \ 81 + .n_ranges = ARRAY_SIZE(ieee80211_ ##_code## _channels), \ 82 + } 83 + 84 + static const struct ieee80211_regdomain ieee80211_regdoms[] = { 85 + REGDOM(US), 86 + REGDOM(JP), 87 + }; 88 + 89 + 90 + static const struct ieee80211_regdomain *get_regdom(void) 91 + { 92 + static const struct ieee80211_channel_range 93 + ieee80211_world_channels[] = { 94 + /* IEEE 802.11b/g, channels 1..11 */ 95 + RANGE_PWR(2412, 2462, 27, 6, 0), 96 + }; 97 + static const struct ieee80211_regdomain regdom_world = REGDOM(world); 98 + int i; 99 + 100 + for (i = 0; i < ARRAY_SIZE(ieee80211_regdoms); i++) 101 + if (strcmp(ieee80211_regdom, ieee80211_regdoms[i].code) == 0) 102 + return &ieee80211_regdoms[i]; 103 + 104 + return &regdom_world; 105 + } 106 + 107 + 108 + static void handle_channel(struct ieee80211_channel *chan, 109 + const struct ieee80211_regdomain *rd) 110 + { 111 + int i; 112 + u32 flags = chan->orig_flags; 113 + const struct ieee80211_channel_range *rg = NULL; 114 + 115 + for (i = 0; i < rd->n_ranges; i++) { 116 + if (rd->ranges[i].start_freq <= chan->center_freq && 117 + chan->center_freq <= rd->ranges[i].end_freq) { 118 + rg = &rd->ranges[i]; 119 + break; 120 + } 121 + } 122 + 123 + if (!rg) { 124 + /* not found */ 125 + flags |= IEEE80211_CHAN_DISABLED; 126 + chan->flags = flags; 127 + return; 128 + } 129 + 130 + chan->flags = flags; 131 + chan->max_antenna_gain = min(chan->orig_mag, 132 + rg->max_antenna_gain); 133 + chan->max_power = min(chan->orig_mpwr, rg->max_power); 134 + } 135 + 136 + static void handle_band(struct ieee80211_supported_band *sband, 137 + const struct ieee80211_regdomain *rd) 138 + { 139 + int i; 140 + 141 + for (i = 0; i < sband->n_channels; i++) 142 + handle_channel(&sband->channels[i], rd); 143 + } 144 + 145 + void wiphy_update_regulatory(struct wiphy *wiphy) 146 + { 147 + enum ieee80211_band band; 148 + const struct ieee80211_regdomain *rd = get_regdom(); 149 + 150 + for (band = 0; band < IEEE80211_NUM_BANDS; band++) 151 + if (wiphy->bands[band]) 152 + handle_band(wiphy->bands[band], rd); 153 + }
+98
net/wireless/util.c
··· 1 + /* 2 + * Wireless utility functions 3 + * 4 + * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> 5 + */ 6 + #include <net/wireless.h> 7 + #include <asm/bitops.h> 8 + #include "core.h" 9 + 10 + int ieee80211_channel_to_frequency(int chan) 11 + { 12 + if (chan < 14) 13 + return 2407 + chan * 5; 14 + 15 + if (chan == 14) 16 + return 2484; 17 + 18 + /* FIXME: 802.11j 17.3.8.3.2 */ 19 + return (chan + 1000) * 5; 20 + } 21 + EXPORT_SYMBOL(ieee80211_channel_to_frequency); 22 + 23 + int ieee80211_frequency_to_channel(int freq) 24 + { 25 + if (freq == 2484) 26 + return 14; 27 + 28 + if (freq < 2484) 29 + return (freq - 2407) / 5; 30 + 31 + /* FIXME: 802.11j 17.3.8.3.2 */ 32 + return freq/5 - 1000; 33 + } 34 + EXPORT_SYMBOL(ieee80211_frequency_to_channel); 35 + 36 + static void set_mandatory_flags_band(struct ieee80211_supported_band *sband, 37 + enum ieee80211_band band) 38 + { 39 + int i, want; 40 + 41 + switch (band) { 42 + case IEEE80211_BAND_5GHZ: 43 + want = 3; 44 + for (i = 0; i < sband->n_bitrates; i++) { 45 + if (sband->bitrates[i].bitrate == 60 || 46 + sband->bitrates[i].bitrate == 120 || 47 + sband->bitrates[i].bitrate == 240) { 48 + sband->bitrates[i].flags |= 49 + IEEE80211_RATE_MANDATORY_A; 50 + want--; 51 + } 52 + } 53 + WARN_ON(want); 54 + break; 55 + case IEEE80211_BAND_2GHZ: 56 + want = 7; 57 + for (i = 0; i < sband->n_bitrates; i++) { 58 + if (sband->bitrates[i].bitrate == 10) { 59 + sband->bitrates[i].flags |= 60 + IEEE80211_RATE_MANDATORY_B | 61 + IEEE80211_RATE_MANDATORY_G; 62 + want--; 63 + } 64 + 65 + if (sband->bitrates[i].bitrate == 20 || 66 + sband->bitrates[i].bitrate == 55 || 67 + sband->bitrates[i].bitrate == 110 || 68 + sband->bitrates[i].bitrate == 60 || 69 + sband->bitrates[i].bitrate == 120 || 70 + sband->bitrates[i].bitrate == 240) { 71 + sband->bitrates[i].flags |= 72 + IEEE80211_RATE_MANDATORY_G; 73 + want--; 74 + } 75 + 76 + if (sband->bitrates[i].bitrate == 10 || 77 + sband->bitrates[i].bitrate == 20 || 78 + sband->bitrates[i].bitrate == 55 || 79 + sband->bitrates[i].bitrate == 110) 80 + sband->bitrates[i].flags |= 81 + IEEE80211_RATE_ERP_G; 82 + } 83 + WARN_ON(want != 0 && want != 6); 84 + break; 85 + case IEEE80211_NUM_BANDS: 86 + WARN_ON(1); 87 + break; 88 + } 89 + } 90 + 91 + void ieee80211_set_bitrate_flags(struct wiphy *wiphy) 92 + { 93 + enum ieee80211_band band; 94 + 95 + for (band = 0; band < IEEE80211_NUM_BANDS; band++) 96 + if (wiphy->bands[band]) 97 + set_mandatory_flags_band(wiphy->bands[band], band); 98 + }