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

Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/linville/wireless-next-2.6

+3877 -2997
+67
Documentation/networking/mac80211_hwsim/README
··· 1 + mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211 2 + Copyright (c) 2008, Jouni Malinen <j@w1.fi> 3 + 4 + This program is free software; you can redistribute it and/or modify 5 + it under the terms of the GNU General Public License version 2 as 6 + published by the Free Software Foundation. 7 + 8 + 9 + Introduction 10 + 11 + mac80211_hwsim is a Linux kernel module that can be used to simulate 12 + arbitrary number of IEEE 802.11 radios for mac80211. It can be used to 13 + test most of the mac80211 functionality and user space tools (e.g., 14 + hostapd and wpa_supplicant) in a way that matches very closely with 15 + the normal case of using real WLAN hardware. From the mac80211 view 16 + point, mac80211_hwsim is yet another hardware driver, i.e., no changes 17 + to mac80211 are needed to use this testing tool. 18 + 19 + The main goal for mac80211_hwsim is to make it easier for developers 20 + to test their code and work with new features to mac80211, hostapd, 21 + and wpa_supplicant. The simulated radios do not have the limitations 22 + of real hardware, so it is easy to generate an arbitrary test setup 23 + and always reproduce the same setup for future tests. In addition, 24 + since all radio operation is simulated, any channel can be used in 25 + tests regardless of regulatory rules. 26 + 27 + mac80211_hwsim kernel module has a parameter 'radios' that can be used 28 + to select how many radios are simulated (default 2). This allows 29 + configuration of both very simply setups (e.g., just a single access 30 + point and a station) or large scale tests (multiple access points with 31 + hundreds of stations). 32 + 33 + mac80211_hwsim works by tracking the current channel of each virtual 34 + radio and copying all transmitted frames to all other radios that are 35 + currently enabled and on the same channel as the transmitting 36 + radio. Software encryption in mac80211 is used so that the frames are 37 + actually encrypted over the virtual air interface to allow more 38 + complete testing of encryption. 39 + 40 + A global monitoring netdev, hwsim#, is created independent of 41 + mac80211. This interface can be used to monitor all transmitted frames 42 + regardless of channel. 43 + 44 + 45 + Simple example 46 + 47 + This example shows how to use mac80211_hwsim to simulate two radios: 48 + one to act as an access point and the other as a station that 49 + associates with the AP. hostapd and wpa_supplicant are used to take 50 + care of WPA2-PSK authentication. In addition, hostapd is also 51 + processing access point side of association. 52 + 53 + Please note that the current Linux kernel does not enable AP mode, so a 54 + simple patch is needed to enable AP mode selection: 55 + http://johannes.sipsolutions.net/patches/kernel/all/LATEST/006-allow-ap-vlan-modes.patch 56 + 57 + 58 + # Build mac80211_hwsim as part of kernel configuration 59 + 60 + # Load the module 61 + modprobe mac80211_hwsim 62 + 63 + # Run hostapd (AP) for wlan0 64 + hostapd hostapd.conf 65 + 66 + # Run wpa_supplicant (station) for wlan1 67 + wpa_supplicant -Dwext -iwlan1 -c wpa_supplicant.conf
+11
Documentation/networking/mac80211_hwsim/hostapd.conf
··· 1 + interface=wlan0 2 + driver=nl80211 3 + 4 + hw_mode=g 5 + channel=1 6 + ssid=mac80211 test 7 + 8 + wpa=2 9 + wpa_key_mgmt=WPA-PSK 10 + wpa_pairwise=CCMP 11 + wpa_passphrase=12345678
+10
Documentation/networking/mac80211_hwsim/wpa_supplicant.conf
··· 1 + ctrl_interface=/var/run/wpa_supplicant 2 + 3 + network={ 4 + ssid="mac80211 test" 5 + psk="12345678" 6 + key_mgmt=WPA-PSK 7 + proto=WPA2 8 + pairwise=CCMP 9 + group=CCMP 10 + }
+13
drivers/net/wireless/Kconfig
··· 673 673 674 674 Thanks to Infineon-ADMtek for their support of this driver. 675 675 676 + config MAC80211_HWSIM 677 + tristate "Simulated radio testing tool for mac80211" 678 + depends on MAC80211 && WLAN_80211 679 + ---help--- 680 + This driver is a developer testing tool that can be used to test 681 + IEEE 802.11 networking stack (mac80211) functionality. This is not 682 + needed for normal wireless LAN usage and is only for testing. See 683 + Documentation/networking/mac80211_hwsim for more information on how 684 + to use this tool. 685 + 686 + To compile this driver as a module, choose M here: the module will be 687 + called mac80211_hwsim. If unsure, say N. 688 + 676 689 source "drivers/net/wireless/p54/Kconfig" 677 690 source "drivers/net/wireless/ath5k/Kconfig" 678 691 source "drivers/net/wireless/iwlwifi/Kconfig"
+2
drivers/net/wireless/Makefile
··· 62 62 obj-$(CONFIG_P54_COMMON) += p54/ 63 63 64 64 obj-$(CONFIG_ATH5K) += ath5k/ 65 + 66 + obj-$(CONFIG_MAC80211_HWSIM) += mac80211_hwsim.o
+3 -12
drivers/net/wireless/airo.c
··· 4561 4561 size_t len, 4562 4562 loff_t *offset ) 4563 4563 { 4564 - loff_t pos = *offset; 4565 - struct proc_data *priv = (struct proc_data*)file->private_data; 4564 + struct proc_data *priv = file->private_data; 4566 4565 4567 4566 if (!priv->rbuffer) 4568 4567 return -EINVAL; 4569 4568 4570 - if (pos < 0) 4571 - return -EINVAL; 4572 - if (pos >= priv->readlen) 4573 - return 0; 4574 - if (len > priv->readlen - pos) 4575 - len = priv->readlen - pos; 4576 - if (copy_to_user(buffer, priv->rbuffer + pos, len)) 4577 - return -EFAULT; 4578 - *offset = pos + len; 4579 - return len; 4569 + return simple_read_from_buffer(buffer, len, offset, priv->rbuffer, 4570 + priv->readlen); 4580 4571 } 4581 4572 4582 4573 /*
-36
drivers/net/wireless/iwlwifi/Kconfig
··· 14 14 bool 15 15 default n 16 16 17 - config IWLWIFI_RUN_TIME_CALIB 18 - bool 19 - depends on IWLCORE 20 - default n 21 - ---help--- 22 - This option will enable run time calibration for the iwlwifi driver. 23 - These calibrations are Sensitivity and Chain Noise. 24 - 25 - 26 17 config IWLWIFI_RFKILL 27 18 boolean "IWLWIFI RF kill support" 28 19 depends on IWLCORE ··· 45 54 say M here and read <file:Documentation/kbuild/modules.txt>. The 46 55 module will be called iwl4965.ko. 47 56 48 - config IWL4965_HT 49 - bool "Enable 802.11n HT features in iwl4965 driver" 50 - depends on EXPERIMENTAL 51 - depends on IWL4965 52 - ---help--- 53 - This option enables IEEE 802.11n High Throughput features 54 - for the iwl4965 driver. 55 - 56 57 config IWL4965_LEDS 57 58 bool "Enable LEDS features in iwl4965 driver" 58 59 depends on IWL4965 ··· 58 75 depends on IWL4965 59 76 ---help--- 60 77 This option will enable spectrum measurement for the iwl4965 driver. 61 - 62 - config IWL4965_RUN_TIME_CALIB 63 - bool "Enable run time Calibration for 4965 NIC" 64 - select IWLWIFI_RUN_TIME_CALIB 65 - depends on IWL4965 66 - default y 67 - ---help--- 68 - This option will enable run time calibration for the iwl4965 driver. 69 - These calibrations are Sensitivity and Chain Noise. If unsure, say yes 70 78 71 79 config IWLWIFI_DEBUG 72 80 bool "Enable full debugging output in iwl4965 driver" ··· 91 117 ---help--- 92 118 This option enables support for Intel Wireless WiFi Link 5000AGN Family 93 119 Dependency on 4965 is temporary 94 - 95 - config IWL5000_RUN_TIME_CALIB 96 - bool "Enable run time Calibration for 5000 NIC" 97 - select IWLWIFI_RUN_TIME_CALIB 98 - depends on IWL5000 99 - default y 100 - ---help--- 101 - This option will enable run time calibration for the iwl5000 driver. 102 - These calibrations are Sensitivity and Chain Noise. If unsure, say yes 103 - 104 120 105 121 config IWLWIFI_DEBUGFS 106 122 bool "Iwlwifi debugfs support"
+2 -2
drivers/net/wireless/iwlwifi/Makefile
··· 1 1 obj-$(CONFIG_IWLCORE) += iwlcore.o 2 2 iwlcore-objs := iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o 3 - iwlcore-objs += iwl-rx.o iwl-tx.o iwl-sta.o 3 + iwlcore-objs += iwl-rx.o iwl-tx.o iwl-sta.o iwl-calib.o 4 + iwlcore-objs += iwl-scan.o 4 5 iwlcore-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o 5 6 iwlcore-$(CONFIG_IWLWIFI_LEDS) += iwl-led.o 6 7 iwlcore-$(CONFIG_IWLWIFI_RFKILL) += iwl-rfkill.o 7 - iwlcore-$(CONFIG_IWLWIFI_RUN_TIME_CALIB) += iwl-calib.o 8 8 9 9 obj-$(CONFIG_IWL3945) += iwl3945.o 10 10 iwl3945-objs := iwl3945-base.o iwl-3945.o iwl-3945-rs.o
+18 -18
drivers/net/wireless/iwlwifi/iwl-3945.c
··· 388 388 u32 print_dump = 0; /* set to 1 to dump all frames' contents */ 389 389 u32 hundred = 0; 390 390 u32 dataframe = 0; 391 - u16 fc; 391 + __le16 fc; 392 392 u16 seq_ctl; 393 393 u16 channel; 394 394 u16 phy_flags; ··· 407 407 u8 *data = IWL_RX_DATA(pkt); 408 408 409 409 /* MAC header */ 410 - fc = le16_to_cpu(header->frame_control); 410 + fc = header->frame_control; 411 411 seq_ctl = le16_to_cpu(header->seq_ctrl); 412 412 413 413 /* metadata */ ··· 431 431 432 432 /* if data frame is to us and all is good, 433 433 * (optionally) print summary for only 1 out of every 100 */ 434 - if (to_us && (fc & ~IEEE80211_FCTL_PROTECTED) == 435 - (IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) { 434 + if (to_us && (fc & ~cpu_to_le16(IEEE80211_FCTL_PROTECTED)) == 435 + cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) { 436 436 dataframe = 1; 437 437 if (!group100) 438 438 print_summary = 1; /* print each frame */ ··· 455 455 456 456 if (hundred) 457 457 title = "100Frames"; 458 - else if (fc & IEEE80211_FCTL_RETRY) 458 + else if (ieee80211_has_retry(fc)) 459 459 title = "Retry"; 460 - else if (ieee80211_is_assoc_response(fc)) 460 + else if (ieee80211_is_assoc_resp(fc)) 461 461 title = "AscRsp"; 462 - else if (ieee80211_is_reassoc_response(fc)) 462 + else if (ieee80211_is_reassoc_resp(fc)) 463 463 title = "RasRsp"; 464 - else if (ieee80211_is_probe_response(fc)) { 464 + else if (ieee80211_is_probe_resp(fc)) { 465 465 title = "PrbRsp"; 466 466 print_dump = 1; /* dump frame contents */ 467 467 } else if (ieee80211_is_beacon(fc)) { ··· 490 490 if (dataframe) 491 491 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, " 492 492 "len=%u, rssi=%d, chnl=%d, rate=%u, \n", 493 - title, fc, header->addr1[5], 493 + title, le16_to_cpu(fc), header->addr1[5], 494 494 length, rssi, channel, rate); 495 495 else { 496 496 /* src/dst addresses assume managed mode */ 497 497 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, " 498 498 "src=0x%02x, rssi=%u, tim=%lu usec, " 499 499 "phy=0x%02x, chnl=%d\n", 500 - title, fc, header->addr1[5], 500 + title, le16_to_cpu(fc), header->addr1[5], 501 501 header->addr3[5], rssi, 502 502 tsf_low - priv->scan_start_tsf, 503 503 phy_flags, channel); ··· 971 971 u8 rts_retry_limit; 972 972 u8 data_retry_limit; 973 973 __le32 tx_flags; 974 - u16 fc = le16_to_cpu(hdr->frame_control); 974 + __le16 fc = hdr->frame_control; 975 975 976 976 rate = iwl3945_rates[rate_index].plcp; 977 977 tx_flags = cmd->cmd.tx.tx_flags; ··· 996 996 else 997 997 rts_retry_limit = 7; 998 998 999 - if (ieee80211_is_probe_response(fc)) { 999 + if (ieee80211_is_probe_resp(fc)) { 1000 1000 data_retry_limit = 3; 1001 1001 if (data_retry_limit < rts_retry_limit) 1002 1002 rts_retry_limit = data_retry_limit; ··· 1006 1006 if (priv->data_retry_limit != -1) 1007 1007 data_retry_limit = priv->data_retry_limit; 1008 1008 1009 - if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { 1010 - switch (fc & IEEE80211_FCTL_STYPE) { 1011 - case IEEE80211_STYPE_AUTH: 1012 - case IEEE80211_STYPE_DEAUTH: 1013 - case IEEE80211_STYPE_ASSOC_REQ: 1014 - case IEEE80211_STYPE_REASSOC_REQ: 1009 + if (ieee80211_is_mgmt(fc)) { 1010 + switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { 1011 + case cpu_to_le16(IEEE80211_STYPE_AUTH): 1012 + case cpu_to_le16(IEEE80211_STYPE_DEAUTH): 1013 + case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): 1014 + case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): 1015 1015 if (tx_flags & TX_CMD_FLG_RTS_MSK) { 1016 1016 tx_flags &= ~TX_CMD_FLG_RTS_MSK; 1017 1017 tx_flags |= TX_CMD_FLG_CTS_MSK;
+1 -14
drivers/net/wireless/iwlwifi/iwl-4965-hw.h
··· 82 82 */ 83 83 #define IWL_CMD_QUEUE_NUM 4 84 84 #define IWL_CMD_FIFO_NUM 4 85 - #define IWL_BACK_QUEUE_FIRST_ID 7 85 + #define IWL49_FIRST_AMPDU_QUEUE 7 86 86 87 87 /* Tx rates */ 88 88 #define IWL_CCK_RATES 4 ··· 792 792 }; 793 793 794 794 /********************* END TXPOWER *****************************************/ 795 - 796 - static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags) 797 - { 798 - return le32_to_cpu(rate_n_flags) & 0xFF; 799 - } 800 - static inline u32 iwl4965_hw_get_rate_n_flags(__le32 rate_n_flags) 801 - { 802 - return le32_to_cpu(rate_n_flags) & 0x1FFFF; 803 - } 804 - static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u16 flags) 805 - { 806 - return cpu_to_le32(flags|(u16)rate); 807 - } 808 795 809 796 810 797 /**
+28 -75
drivers/net/wireless/iwlwifi/iwl-4965-rs.c
··· 38 38 #include "../net/mac80211/rate.h" 39 39 40 40 #include "iwl-dev.h" 41 + #include "iwl-sta.h" 41 42 #include "iwl-core.h" 42 43 #include "iwl-helpers.h" 43 44 ··· 106 105 struct iwl4965_rate_scale_data win[IWL_RATE_COUNT]; /* rate histories */ 107 106 }; 108 107 109 - #ifdef CONFIG_IWL4965_HT 110 - 111 108 struct iwl4965_traffic_load { 112 109 unsigned long time_stamp; /* age of the oldest statistics */ 113 110 u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time ··· 116 117 * been used since the last cleanup */ 117 118 u8 head; /* start of the circular buffer */ 118 119 }; 119 - 120 - #endif /* CONFIG_IWL4965_HT */ 121 120 122 121 /** 123 122 * struct iwl4965_lq_sta -- driver's rate scaling private structure ··· 154 157 155 158 struct iwl_link_quality_cmd lq; 156 159 struct iwl4965_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ 157 - #ifdef CONFIG_IWL4965_HT 158 160 struct iwl4965_traffic_load load[TID_MAX_LOAD_COUNT]; 159 161 u8 tx_agg_tid_en; 160 - #endif 161 162 #ifdef CONFIG_MAC80211_DEBUGFS 162 163 struct dentry *rs_sta_dbgfs_scale_table_file; 163 164 struct dentry *rs_sta_dbgfs_stats_table_file; 164 - #ifdef CONFIG_IWL4965_HT 165 165 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; 166 - #endif 167 166 u32 dbg_fixed_rate; 168 167 #endif 169 168 struct iwl_priv *drv; ··· 249 256 return ((ant_type & valid_antenna) == ant_type); 250 257 } 251 258 252 - #ifdef CONFIG_IWL4965_HT 253 259 /* 254 260 * removes the old data from the statistics. All data that is older than 255 261 * TID_MAX_TIME_DIFF, will be deleted. ··· 274 282 * increment traffic load value for tid and also remove 275 283 * any old values if passed the certain time period 276 284 */ 277 - static void rs_tl_add_packet(struct iwl4965_lq_sta *lq_data, 278 - struct ieee80211_hdr *hdr) 285 + static u8 rs_tl_add_packet(struct iwl4965_lq_sta *lq_data, 286 + struct ieee80211_hdr *hdr) 279 287 { 280 288 u32 curr_time = jiffies_to_msecs(jiffies); 281 289 u32 time_diff; 282 290 s32 index; 283 291 struct iwl4965_traffic_load *tl = NULL; 284 - u16 fc = le16_to_cpu(hdr->frame_control); 292 + __le16 fc = hdr->frame_control; 285 293 u8 tid; 286 294 287 - if (ieee80211_is_qos_data(fc)) { 288 - u8 *qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); 295 + if (ieee80211_is_data_qos(fc)) { 296 + u8 *qc = ieee80211_get_qos_ctl(hdr); 289 297 tid = qc[0] & 0xf; 290 298 } else 291 - return; 299 + return MAX_TID_COUNT; 292 300 293 301 tl = &lq_data->load[tid]; 294 302 ··· 301 309 tl->queue_count = 1; 302 310 tl->head = 0; 303 311 tl->packet_count[0] = 1; 304 - return; 312 + return MAX_TID_COUNT; 305 313 } 306 314 307 315 time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); ··· 318 326 319 327 if ((index + 1) > tl->queue_count) 320 328 tl->queue_count = index + 1; 329 + 330 + return tid; 321 331 } 322 332 323 333 /* ··· 382 388 for (tid = 0; tid < TID_MAX_LOAD_COUNT; tid++) 383 389 rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); 384 390 } 385 - 386 - #endif /* CONFIG_IWLWIFI_HT */ 387 391 388 392 static inline int get_num_of_ant_from_rate(u32 rate_n_flags) 389 393 { ··· 537 545 u8 num_of_ant = get_num_of_ant_from_rate(rate_n_flags); 538 546 u8 mcs; 539 547 540 - *rate_idx = iwl4965_hwrate_to_plcp_idx(rate_n_flags); 548 + *rate_idx = iwl_hwrate_to_plcp_idx(rate_n_flags); 541 549 542 550 if (*rate_idx == IWL_RATE_INVALID) { 543 551 *rate_idx = -1; ··· 618 626 619 627 /* FIXME:RS: in 4965 we don't use greenfield at all */ 620 628 /* FIXME:RS: don't use greenfield for now in TX */ 621 - /* #ifdef CONFIG_IWL4965_HT */ 622 629 #if 0 623 630 static inline u8 rs_use_green(struct iwl_priv *priv, struct ieee80211_conf *conf) 624 631 { ··· 625 634 priv->current_ht_config.is_green_field && 626 635 !priv->current_ht_config.non_GF_STA_present); 627 636 } 628 - #else 637 + #endif 629 638 static inline u8 rs_use_green(struct iwl_priv *priv, struct ieee80211_conf *conf) 630 639 { 631 640 return 0; 632 641 } 633 - #endif /* CONFIG_IWL4965_HT */ 634 642 635 643 /** 636 644 * rs_get_supported_rates - get the available rates ··· 794 804 struct iwl4965_scale_tbl_info tbl_type; 795 805 struct iwl4965_scale_tbl_info *curr_tbl, *search_tbl; 796 806 u8 active_index = 0; 797 - u16 fc = le16_to_cpu(hdr->frame_control); 807 + __le16 fc = hdr->frame_control; 798 808 s32 tpt = 0; 799 809 800 810 IWL_DEBUG_RATE_LIMIT("get frame ack response, update rate scale window\n"); ··· 1040 1050 tbl->expected_tpt = expected_tpt_G; 1041 1051 } 1042 1052 1043 - #ifdef CONFIG_IWL4965_HT 1044 1053 /* 1045 1054 * Find starting rate for new "search" high-throughput mode of modulation. 1046 1055 * Goal is to find lowest expected rate (under perfect conditions) that is ··· 1141 1152 1142 1153 return new_rate; 1143 1154 } 1144 - #endif /* CONFIG_IWL4965_HT */ 1145 1155 1146 1156 /* 1147 1157 * Set up search table for MIMO 1148 1158 */ 1149 - #ifdef CONFIG_IWL4965_HT 1150 1159 static int rs_switch_to_mimo2(struct iwl_priv *priv, 1151 1160 struct iwl4965_lq_sta *lq_sta, 1152 1161 struct ieee80211_conf *conf, ··· 1208 1221 tbl->current_rate, is_green); 1209 1222 return 0; 1210 1223 } 1211 - #else 1212 - static int rs_switch_to_mimo2(struct iwl_priv *priv, 1213 - struct iwl4965_lq_sta *lq_sta, 1214 - struct ieee80211_conf *conf, 1215 - struct sta_info *sta, 1216 - struct iwl4965_scale_tbl_info *tbl, int index) 1217 - { 1218 - return -1; 1219 - } 1220 - #endif /*CONFIG_IWL4965_HT */ 1221 1224 1222 1225 /* 1223 1226 * Set up search table for SISO ··· 1218 1241 struct sta_info *sta, 1219 1242 struct iwl4965_scale_tbl_info *tbl, int index) 1220 1243 { 1221 - #ifdef CONFIG_IWL4965_HT 1222 1244 u16 rate_mask; 1223 1245 u8 is_green = lq_sta->is_green; 1224 1246 s32 rate; ··· 1267 1291 IWL_DEBUG_RATE("LQ: Switch to new mcs %X index is green %X\n", 1268 1292 tbl->current_rate, is_green); 1269 1293 return 0; 1270 - #else 1271 - return -1; 1272 - #endif /*CONFIG_IWL4965_HT */ 1273 1294 } 1274 1295 1275 1296 /* ··· 1651 1678 int high_tpt = IWL_INVALID_VALUE; 1652 1679 u32 fail_count; 1653 1680 s8 scale_action = 0; 1654 - u16 fc, rate_mask; 1681 + __le16 fc; 1682 + u16 rate_mask; 1655 1683 u8 update_lq = 0; 1656 1684 struct iwl4965_lq_sta *lq_sta; 1657 1685 struct iwl4965_scale_tbl_info *tbl, *tbl1; ··· 1663 1689 u8 done_search = 0; 1664 1690 u16 high_low; 1665 1691 s32 sr; 1666 - #ifdef CONFIG_IWL4965_HT 1667 1692 u8 tid = MAX_TID_COUNT; 1668 - #endif 1669 1693 1670 1694 IWL_DEBUG_RATE("rate scale calculate new rate for skb\n"); 1671 1695 1672 - fc = le16_to_cpu(hdr->frame_control); 1696 + fc = hdr->frame_control; 1673 1697 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) { 1674 1698 /* Send management frames and broadcast/multicast data using 1675 1699 * lowest rate. */ ··· 1684 1712 } 1685 1713 lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; 1686 1714 1687 - #ifdef CONFIG_IWL4965_HT 1688 - rs_tl_add_packet(lq_sta, hdr); 1689 - #endif 1715 + tid = rs_tl_add_packet(lq_sta, hdr); 1716 + 1690 1717 /* 1691 1718 * Select rate-scale / modulation-mode table to work with in 1692 1719 * the rest of this function: "search" if searching for better ··· 1813 1842 tbl = &(lq_sta->lq_info[active_tbl]); 1814 1843 1815 1844 /* Revert to "active" rate and throughput info */ 1816 - index = iwl4965_hwrate_to_plcp_idx( 1817 - tbl->current_rate); 1845 + index = iwl_hwrate_to_plcp_idx(tbl->current_rate); 1818 1846 current_tpt = lq_sta->last_tpt; 1819 1847 1820 1848 /* Need to set up a new rate table in uCode */ ··· 1967 1997 rs_rate_scale_clear_window(&(tbl->win[i])); 1968 1998 1969 1999 /* Use new "search" start rate */ 1970 - index = iwl4965_hwrate_to_plcp_idx( 1971 - tbl->current_rate); 2000 + index = iwl_hwrate_to_plcp_idx(tbl->current_rate); 1972 2001 1973 2002 IWL_DEBUG_RATE("Switch current mcs: %X index: %d\n", 1974 2003 tbl->current_rate, index); ··· 1982 2013 * before next round of mode comparisons. */ 1983 2014 tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); 1984 2015 if (is_legacy(tbl1->lq_type) && 1985 - #ifdef CONFIG_IWL4965_HT 1986 2016 (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE)) && 1987 - #endif 1988 2017 (lq_sta->action_counter >= 1)) { 1989 2018 lq_sta->action_counter = 0; 1990 2019 IWL_DEBUG_RATE("LQ: STAY in legacy table\n"); ··· 1994 2027 * mode for a while before next round of mode comparisons. */ 1995 2028 if (lq_sta->enable_counter && 1996 2029 (lq_sta->action_counter >= IWL_ACTION_LIMIT)) { 1997 - #ifdef CONFIG_IWL4965_HT 1998 2030 if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) && 1999 2031 (lq_sta->tx_agg_tid_en & (1 << tid)) && 2000 2032 (tid != MAX_TID_COUNT)) { 2001 2033 IWL_DEBUG_RATE("try to aggregate tid %d\n", tid); 2002 2034 rs_tl_turn_on_agg(priv, tid, lq_sta, sta); 2003 2035 } 2004 - #endif /*CONFIG_IWL4965_HT */ 2005 2036 lq_sta->action_counter = 0; 2006 2037 rs_set_stay_in_table(priv, 0, lq_sta); 2007 2038 } ··· 2101 2136 struct ieee80211_conf *conf = &local->hw.conf; 2102 2137 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 2103 2138 struct sta_info *sta; 2104 - u16 fc; 2139 + __le16 fc; 2105 2140 struct iwl_priv *priv = (struct iwl_priv *)priv_rate; 2106 2141 struct iwl4965_lq_sta *lq_sta; 2107 2142 ··· 2113 2148 2114 2149 /* Send management frames and broadcast/multicast data using lowest 2115 2150 * rate. */ 2116 - fc = le16_to_cpu(hdr->frame_control); 2151 + fc = hdr->frame_control; 2117 2152 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || 2118 2153 !sta || !sta->rate_ctrl_priv) { 2119 2154 sel->rate_idx = rate_lowest_index(local, sband, sta); ··· 2244 2279 lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000); 2245 2280 lq_sta->active_rate_basic = priv->active_rate_basic; 2246 2281 lq_sta->band = priv->band; 2247 - #ifdef CONFIG_IWL4965_HT 2248 2282 /* 2249 2283 * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), 2250 2284 * supp_rates[] does not; shift to convert format, force 9 MBits off. 2251 2285 */ 2252 - lq_sta->active_siso_rate = 2253 - priv->current_ht_config.supp_mcs_set[0] << 1; 2254 - lq_sta->active_siso_rate |= 2255 - priv->current_ht_config.supp_mcs_set[0] & 0x1; 2286 + lq_sta->active_siso_rate = conf->ht_conf.supp_mcs_set[0] << 1; 2287 + lq_sta->active_siso_rate |= conf->ht_conf.supp_mcs_set[0] & 0x1; 2256 2288 lq_sta->active_siso_rate &= ~((u16)0x2); 2257 2289 lq_sta->active_siso_rate <<= IWL_FIRST_OFDM_RATE; 2258 2290 2259 2291 /* Same here */ 2260 - lq_sta->active_mimo2_rate = 2261 - priv->current_ht_config.supp_mcs_set[1] << 1; 2262 - lq_sta->active_mimo2_rate |= 2263 - priv->current_ht_config.supp_mcs_set[1] & 0x1; 2292 + lq_sta->active_mimo2_rate = conf->ht_conf.supp_mcs_set[1] << 1; 2293 + lq_sta->active_mimo2_rate |= conf->ht_conf.supp_mcs_set[1] & 0x1; 2264 2294 lq_sta->active_mimo2_rate &= ~((u16)0x2); 2265 2295 lq_sta->active_mimo2_rate <<= IWL_FIRST_OFDM_RATE; 2266 2296 2267 - lq_sta->active_mimo3_rate = 2268 - priv->current_ht_config.supp_mcs_set[2] << 1; 2269 - lq_sta->active_mimo3_rate |= 2270 - priv->current_ht_config.supp_mcs_set[2] & 0x1; 2297 + lq_sta->active_mimo3_rate = conf->ht_conf.supp_mcs_set[2] << 1; 2298 + lq_sta->active_mimo3_rate |= conf->ht_conf.supp_mcs_set[2] & 0x1; 2271 2299 lq_sta->active_mimo3_rate &= ~((u16)0x2); 2272 2300 lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE; 2273 2301 ··· 2275 2317 2276 2318 /* as default allow aggregation for all tids */ 2277 2319 lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; 2278 - #endif /*CONFIG_IWL4965_HT*/ 2279 2320 #ifdef CONFIG_MAC80211_DEBUGFS 2280 2321 lq_sta->drv = priv; 2281 2322 #endif ··· 2592 2635 lq_sta->rs_sta_dbgfs_stats_table_file = 2593 2636 debugfs_create_file("rate_stats_table", 0600, dir, 2594 2637 lq_sta, &rs_sta_dbgfs_stats_table_ops); 2595 - #ifdef CONFIG_IWL4965_HT 2596 2638 lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = 2597 2639 debugfs_create_u8("tx_agg_tid_enable", 0600, dir, 2598 2640 &lq_sta->tx_agg_tid_en); 2599 - #endif 2600 2641 2601 2642 } 2602 2643 ··· 2603 2648 struct iwl4965_lq_sta *lq_sta = priv_sta; 2604 2649 debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); 2605 2650 debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); 2606 - #ifdef CONFIG_IWL4965_HT 2607 2651 debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file); 2608 - #endif 2609 2652 } 2610 2653 #endif 2611 2654
-2
drivers/net/wireless/iwlwifi/iwl-4965-rs.h
··· 286 286 return rate; 287 287 } 288 288 289 - extern int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags); 290 - 291 289 /** 292 290 * iwl4965_fill_rs_info - Fill an output text buffer with the rate representation 293 291 *
+90 -292
drivers/net/wireless/iwlwifi/iwl-4965.c
··· 46 46 #include "iwl-calib.h" 47 47 #include "iwl-sta.h" 48 48 49 + static int iwl4965_send_tx_power(struct iwl_priv *priv); 50 + static int iwl4965_hw_get_temperature(const struct iwl_priv *priv); 51 + 49 52 /* module parameters */ 50 53 static struct iwl_mod_params iwl4965_mod_params = { 51 54 .num_of_queues = IWL49_NUM_QUEUES, ··· 284 281 } 285 282 286 283 /* Calculate temperature */ 287 - priv->temperature = iwl4965_get_temperature(priv); 284 + priv->temperature = iwl4965_hw_get_temperature(priv); 288 285 289 286 /* Send pointers to protocol/runtime uCode image ... init code will 290 287 * load and launch runtime uCode, which will send us another "Alive" ··· 306 303 { 307 304 return (rxon_flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK) || 308 305 (rxon_flags & RXON_FLG_CHANNEL_MODE_MIXED_MSK); 309 - } 310 - 311 - int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags) 312 - { 313 - int idx = 0; 314 - 315 - /* 4965 HT rate format */ 316 - if (rate_n_flags & RATE_MCS_HT_MSK) { 317 - idx = (rate_n_flags & 0xff); 318 - 319 - if (idx >= IWL_RATE_MIMO2_6M_PLCP) 320 - idx = idx - IWL_RATE_MIMO2_6M_PLCP; 321 - 322 - idx += IWL_FIRST_OFDM_RATE; 323 - /* skip 9M not supported in ht*/ 324 - if (idx >= IWL_RATE_9M_INDEX) 325 - idx += 1; 326 - if ((idx >= IWL_FIRST_OFDM_RATE) && (idx <= IWL_LAST_OFDM_RATE)) 327 - return idx; 328 - 329 - /* 4965 legacy rate format, search for match in table */ 330 - } else { 331 - for (idx = 0; idx < ARRAY_SIZE(iwl_rates); idx++) 332 - if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF)) 333 - return idx; 334 - } 335 - 336 - return -1; 337 - } 338 - 339 - /** 340 - * translate ucode response to mac80211 tx status control values 341 - */ 342 - void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, 343 - struct ieee80211_tx_info *control) 344 - { 345 - int rate_index; 346 - 347 - control->antenna_sel_tx = 348 - ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); 349 - if (rate_n_flags & RATE_MCS_HT_MSK) 350 - control->flags |= IEEE80211_TX_CTL_OFDM_HT; 351 - if (rate_n_flags & RATE_MCS_GF_MSK) 352 - control->flags |= IEEE80211_TX_CTL_GREEN_FIELD; 353 - if (rate_n_flags & RATE_MCS_FAT_MSK) 354 - control->flags |= IEEE80211_TX_CTL_40_MHZ_WIDTH; 355 - if (rate_n_flags & RATE_MCS_DUP_MSK) 356 - control->flags |= IEEE80211_TX_CTL_DUP_DATA; 357 - if (rate_n_flags & RATE_MCS_SGI_MSK) 358 - control->flags |= IEEE80211_TX_CTL_SHORT_GI; 359 - rate_index = iwl4965_hwrate_to_plcp_idx(rate_n_flags); 360 - if (control->band == IEEE80211_BAND_5GHZ) 361 - rate_index -= IWL_FIRST_OFDM_RATE; 362 - control->tx_rate_idx = rate_index; 363 306 } 364 307 365 308 /* ··· 557 608 558 609 #define REG_RECALIB_PERIOD (60) 559 610 560 - /** 561 - * iwl4965_bg_statistics_periodic - Timer callback to queue statistics 562 - * 563 - * This callback is provided in order to send a statistics request. 564 - * 565 - * This timer function is continually reset to execute within 566 - * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION 567 - * was received. We need to ensure we receive the statistics in order 568 - * to update the temperature used for calibrating the TXPOWER. 569 - */ 570 - static void iwl4965_bg_statistics_periodic(unsigned long data) 571 - { 572 - struct iwl_priv *priv = (struct iwl_priv *)data; 573 - 574 - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 575 - return; 576 - 577 - iwl_send_statistics_request(priv, CMD_ASYNC); 578 - } 579 - 580 - void iwl4965_rf_kill_ct_config(struct iwl_priv *priv) 581 - { 582 - struct iwl4965_ct_kill_config cmd; 583 - unsigned long flags; 584 - int ret = 0; 585 - 586 - spin_lock_irqsave(&priv->lock, flags); 587 - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, 588 - CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); 589 - spin_unlock_irqrestore(&priv->lock, flags); 590 - 591 - cmd.critical_temperature_R = 592 - cpu_to_le32(priv->hw_params.ct_kill_threshold); 593 - 594 - ret = iwl_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, 595 - sizeof(cmd), &cmd); 596 - if (ret) 597 - IWL_ERROR("REPLY_CT_KILL_CONFIG_CMD failed\n"); 598 - else 599 - IWL_DEBUG_INFO("REPLY_CT_KILL_CONFIG_CMD succeeded, " 600 - "critical temperature is %d\n", 601 - cmd.critical_temperature_R); 602 - } 603 - 604 - #ifdef CONFIG_IWL4965_RUN_TIME_CALIB 605 - 606 611 /* Reset differential Rx gains in NIC to prepare for chain noise calibration. 607 612 * Called after every association, but this runs only once! 608 613 * ... once chain noise is calibrated the first time, it's good forever. */ ··· 644 741 data->beacon_count = 0; 645 742 } 646 743 647 - static void iwl4965_bg_sensitivity_work(struct work_struct *work) 648 - { 649 - struct iwl_priv *priv = container_of(work, struct iwl_priv, 650 - sensitivity_work); 651 - 652 - mutex_lock(&priv->mutex); 653 - 654 - if (test_bit(STATUS_EXIT_PENDING, &priv->status) || 655 - test_bit(STATUS_SCANNING, &priv->status)) { 656 - mutex_unlock(&priv->mutex); 657 - return; 658 - } 659 - 660 - if (priv->start_calib) { 661 - iwl_chain_noise_calibration(priv, &priv->statistics); 662 - 663 - iwl_sensitivity_calibration(priv, &priv->statistics); 664 - } 665 - 666 - mutex_unlock(&priv->mutex); 667 - return; 668 - } 669 - #endif /*CONFIG_IWL4965_RUN_TIME_CALIB*/ 670 - 671 744 static void iwl4965_bg_txpower_work(struct work_struct *work) 672 745 { 673 746 struct iwl_priv *priv = container_of(work, struct iwl_priv, ··· 662 783 /* Regardless of if we are assocaited, we must reconfigure the 663 784 * TX power since frames can be sent on non-radar channels while 664 785 * not associated */ 665 - iwl4965_hw_reg_send_txpower(priv); 786 + iwl4965_send_tx_power(priv); 666 787 667 788 /* Update last_temperature to keep is_calib_needed from running 668 789 * when it isn't needed... */ ··· 722 843 IWL_TX_FIFO_HCCA_2 723 844 }; 724 845 725 - int iwl4965_alive_notify(struct iwl_priv *priv) 846 + static int iwl4965_alive_notify(struct iwl_priv *priv) 726 847 { 727 848 u32 a; 728 849 int i = 0; ··· 799 920 return ret; 800 921 } 801 922 802 - #ifdef CONFIG_IWL4965_RUN_TIME_CALIB 803 923 static struct iwl_sensitivity_ranges iwl4965_sensitivity = { 804 924 .min_nrg_cck = 97, 805 925 .max_nrg_cck = 0, ··· 821 943 .nrg_th_cck = 100, 822 944 .nrg_th_ofdm = 100, 823 945 }; 824 - #endif 825 946 826 947 /** 827 948 * iwl4965_hw_set_hw_params 828 949 * 829 950 * Called when initializing driver 830 951 */ 831 - int iwl4965_hw_set_hw_params(struct iwl_priv *priv) 952 + static int iwl4965_hw_set_hw_params(struct iwl_priv *priv) 832 953 { 833 954 834 955 if ((priv->cfg->mod_params->num_of_queues > IWL49_NUM_QUEUES) || ··· 838 961 } 839 962 840 963 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; 964 + priv->hw_params.first_ampdu_q = IWL49_FIRST_AMPDU_QUEUE; 841 965 priv->hw_params.sw_crypto = priv->cfg->mod_params->sw_crypto; 842 966 priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; 843 967 priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; ··· 861 983 priv->hw_params.valid_rx_ant = ANT_A | ANT_B; 862 984 priv->hw_params.ct_kill_threshold = CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD); 863 985 864 - #ifdef CONFIG_IWL4965_RUN_TIME_CALIB 865 986 priv->hw_params.sens = &iwl4965_sensitivity; 866 - #endif 867 987 868 988 return 0; 869 989 } ··· 876 1000 sizeof(struct iwl4965_powertable_cmd), 877 1001 cmd, NULL); 878 1002 return ret; 879 - } 880 - int iwl4965_hw_reg_set_txpower(struct iwl_priv *priv, s8 power) 881 - { 882 - IWL_ERROR("TODO: Implement iwl4965_hw_reg_set_txpower!\n"); 883 - return -EINVAL; 884 1003 } 885 1004 886 1005 static s32 iwl4965_math_div_round(s32 num, s32 denom, s32 *res) ··· 925 1054 comp = 0; 926 1055 927 1056 return comp; 928 - } 929 - 930 - static const struct iwl_channel_info * 931 - iwl4965_get_channel_txpower_info(struct iwl_priv *priv, 932 - enum ieee80211_band band, u16 channel) 933 - { 934 - const struct iwl_channel_info *ch_info; 935 - 936 - ch_info = iwl_get_channel_info(priv, band, channel); 937 - 938 - if (!is_channel_valid(ch_info)) 939 - return NULL; 940 - 941 - return ch_info; 942 1057 } 943 1058 944 1059 static s32 iwl4965_get_tx_atten_grp(u16 channel) ··· 1350 1493 s32 factory_actual_pwr[2]; 1351 1494 s32 power_index; 1352 1495 1353 - /* Sanity check requested level (dBm) */ 1354 - if (priv->user_txpower_limit < IWL_TX_POWER_TARGET_POWER_MIN) { 1355 - IWL_WARNING("Requested user TXPOWER %d below limit.\n", 1356 - priv->user_txpower_limit); 1357 - return -EINVAL; 1358 - } 1359 - if (priv->user_txpower_limit > IWL_TX_POWER_TARGET_POWER_MAX) { 1360 - IWL_WARNING("Requested user TXPOWER %d above limit.\n", 1361 - priv->user_txpower_limit); 1362 - return -EINVAL; 1363 - } 1364 - 1365 1496 /* user_txpower_limit is in dBm, convert to half-dBm (half-dB units 1366 1497 * are used for indexing into txpower table) */ 1367 - user_target_power = 2 * priv->user_txpower_limit; 1498 + user_target_power = 2 * priv->tx_power_user_lmt; 1368 1499 1369 1500 /* Get current (RXON) channel, band, width */ 1370 - ch_info = 1371 - iwl4965_get_channel_txpower_info(priv, priv->band, channel); 1372 - 1373 1501 IWL_DEBUG_TXPOWER("chan %d band %d is_fat %d\n", channel, band, 1374 1502 is_fat); 1375 1503 1376 - if (!ch_info) 1504 + ch_info = iwl_get_channel_info(priv, priv->band, channel); 1505 + 1506 + if (!is_channel_valid(ch_info)) 1377 1507 return -EINVAL; 1378 1508 1379 1509 /* get txatten group, used to select 1) thermal txpower adjustment ··· 1561 1717 } 1562 1718 1563 1719 /** 1564 - * iwl4965_hw_reg_send_txpower - Configure the TXPOWER level user limit 1720 + * iwl4965_send_tx_power - Configure the TXPOWER level user limit 1565 1721 * 1566 1722 * Uses the active RXON for channel, band, and characteristics (fat, high) 1567 - * The power limit is taken from priv->user_txpower_limit. 1723 + * The power limit is taken from priv->tx_power_user_lmt. 1568 1724 */ 1569 - int iwl4965_hw_reg_send_txpower(struct iwl_priv *priv) 1725 + static int iwl4965_send_tx_power(struct iwl_priv *priv) 1570 1726 { 1571 1727 struct iwl4965_txpowertable_cmd cmd = { 0 }; 1572 1728 int ret; ··· 1692 1848 return le32_to_cpu(s->rb_closed) & 0xFFF; 1693 1849 } 1694 1850 1695 - int iwl4965_hw_get_temperature(struct iwl_priv *priv) 1696 - { 1697 - return priv->temperature; 1698 - } 1699 - 1700 1851 unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, 1701 1852 struct iwl_frame *frame, u8 rate) 1702 1853 { ··· 1714 1875 1715 1876 if ((rate == IWL_RATE_1M_PLCP) || (rate >= IWL_RATE_2M_PLCP)) 1716 1877 tx_beacon_cmd->tx.rate_n_flags = 1717 - iwl4965_hw_set_rate_n_flags(rate, RATE_MCS_CCK_MSK); 1878 + iwl_hw_set_rate_n_flags(rate, RATE_MCS_CCK_MSK); 1718 1879 else 1719 1880 tx_beacon_cmd->tx.rate_n_flags = 1720 - iwl4965_hw_set_rate_n_flags(rate, 0); 1881 + iwl_hw_set_rate_n_flags(rate, 0); 1721 1882 1722 1883 tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | 1723 1884 TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK); ··· 1789 1950 } 1790 1951 1791 1952 /** 1792 - * iwl4965_get_temperature - return the calibrated temperature (in Kelvin) 1953 + * iwl4965_hw_get_temperature - return the calibrated temperature (in Kelvin) 1793 1954 * @statistics: Provides the temperature reading from the uCode 1794 1955 * 1795 1956 * A return of <0 indicates bogus data in the statistics 1796 1957 */ 1797 - int iwl4965_get_temperature(const struct iwl_priv *priv) 1958 + static int iwl4965_hw_get_temperature(const struct iwl_priv *priv) 1798 1959 { 1799 1960 s32 temperature; 1800 1961 s32 vt; ··· 1829 1990 vt = sign_extend( 1830 1991 le32_to_cpu(priv->statistics.general.temperature), 23); 1831 1992 1832 - IWL_DEBUG_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", 1833 - R1, R2, R3, vt); 1993 + IWL_DEBUG_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); 1834 1994 1835 1995 if (R3 == R1) { 1836 1996 IWL_ERROR("Calibration conflict R1 == R3\n"); ··· 1840 2002 * Add offset to center the adjustment around 0 degrees Centigrade. */ 1841 2003 temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2); 1842 2004 temperature /= (R3 - R1); 1843 - temperature = (temperature * 97) / 100 + 1844 - TEMPERATURE_CALIB_KELVIN_OFFSET; 2005 + temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; 1845 2006 1846 - IWL_DEBUG_TEMP("Calibrated temperature: %dK, %dC\n", temperature, 1847 - KELVIN_TO_CELSIUS(temperature)); 2007 + IWL_DEBUG_TEMP("Calibrated temperature: %dK, %dC\n", 2008 + temperature, KELVIN_TO_CELSIUS(temperature)); 1848 2009 1849 2010 return temperature; 1850 2011 } ··· 1960 2123 if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && 1961 2124 (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { 1962 2125 iwl4965_rx_calc_noise(priv); 1963 - #ifdef CONFIG_IWL4965_RUN_TIME_CALIB 1964 - queue_work(priv->workqueue, &priv->sensitivity_work); 1965 - #endif 2126 + queue_work(priv->workqueue, &priv->run_time_calib_work); 1966 2127 } 1967 2128 1968 2129 iwl_leds_background(priv); ··· 1971 2136 if (!change) 1972 2137 return; 1973 2138 1974 - temp = iwl4965_get_temperature(priv); 2139 + temp = iwl4965_hw_get_temperature(priv); 1975 2140 if (temp < 0) 1976 2141 return; 1977 2142 ··· 1990 2155 priv->temperature = temp; 1991 2156 set_bit(STATUS_TEMPERATURE, &priv->status); 1992 2157 1993 - if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && 1994 - iwl4965_is_temp_calib_needed(priv)) 2158 + if (!priv->disable_tx_power_cal && 2159 + unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && 2160 + iwl4965_is_temp_calib_needed(priv)) 1995 2161 queue_work(priv->workqueue, &priv->txpower_work); 1996 2162 } 1997 2163 ··· 2388 2552 u32 print_dump = 0; /* set to 1 to dump all frames' contents */ 2389 2553 u32 hundred = 0; 2390 2554 u32 dataframe = 0; 2391 - u16 fc; 2555 + __le16 fc; 2392 2556 u16 seq_ctl; 2393 2557 u16 channel; 2394 2558 u16 phy_flags; ··· 2411 2575 return; 2412 2576 2413 2577 /* MAC header */ 2414 - fc = le16_to_cpu(header->frame_control); 2578 + fc = header->frame_control; 2415 2579 seq_ctl = le16_to_cpu(header->seq_ctrl); 2416 2580 2417 2581 /* metadata */ ··· 2436 2600 2437 2601 /* if data frame is to us and all is good, 2438 2602 * (optionally) print summary for only 1 out of every 100 */ 2439 - if (to_us && (fc & ~IEEE80211_FCTL_PROTECTED) == 2440 - (IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) { 2603 + if (to_us && (fc & ~cpu_to_le16(IEEE80211_FCTL_PROTECTED)) == 2604 + cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) { 2441 2605 dataframe = 1; 2442 2606 if (!group100) 2443 2607 print_summary = 1; /* print each frame */ ··· 2461 2625 2462 2626 if (hundred) 2463 2627 title = "100Frames"; 2464 - else if (fc & IEEE80211_FCTL_RETRY) 2628 + else if (ieee80211_has_retry(fc)) 2465 2629 title = "Retry"; 2466 - else if (ieee80211_is_assoc_response(fc)) 2630 + else if (ieee80211_is_assoc_resp(fc)) 2467 2631 title = "AscRsp"; 2468 - else if (ieee80211_is_reassoc_response(fc)) 2632 + else if (ieee80211_is_reassoc_resp(fc)) 2469 2633 title = "RasRsp"; 2470 - else if (ieee80211_is_probe_response(fc)) { 2634 + else if (ieee80211_is_probe_resp(fc)) { 2471 2635 title = "PrbRsp"; 2472 2636 print_dump = 1; /* dump frame contents */ 2473 2637 } else if (ieee80211_is_beacon(fc)) { ··· 2484 2648 else 2485 2649 title = "Frame"; 2486 2650 2487 - rate_idx = iwl4965_hwrate_to_plcp_idx(rate_sym); 2651 + rate_idx = iwl_hwrate_to_plcp_idx(rate_sym); 2488 2652 if (unlikely(rate_idx == -1)) 2489 2653 bitrate = 0; 2490 2654 else ··· 2496 2660 if (dataframe) 2497 2661 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, " 2498 2662 "len=%u, rssi=%d, chnl=%d, rate=%u, \n", 2499 - title, fc, header->addr1[5], 2663 + title, le16_to_cpu(fc), header->addr1[5], 2500 2664 length, rssi, channel, bitrate); 2501 2665 else { 2502 2666 /* src/dst addresses assume managed mode */ 2503 2667 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, " 2504 2668 "src=0x%02x, rssi=%u, tim=%lu usec, " 2505 2669 "phy=0x%02x, chnl=%d\n", 2506 - title, fc, header->addr1[5], 2670 + title, le16_to_cpu(fc), header->addr1[5], 2507 2671 header->addr3[5], rssi, 2508 2672 tsf_low - priv->scan_start_tsf, 2509 2673 phy_flags, channel); ··· 2549 2713 rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 2550 2714 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 2551 2715 rx_status.rate_idx = 2552 - iwl4965_hwrate_to_plcp_idx(le32_to_cpu(rx_start->rate_n_flags)); 2716 + iwl_hwrate_to_plcp_idx(le32_to_cpu(rx_start->rate_n_flags)); 2553 2717 if (rx_status.band == IEEE80211_BAND_5GHZ) 2554 2718 rx_status.rate_idx -= IWL_FIRST_OFDM_RATE; 2555 2719 ··· 2655 2819 break; 2656 2820 2657 2821 case IEEE80211_FTYPE_CTL: 2658 - #ifdef CONFIG_IWL4965_HT 2659 2822 switch (fc & IEEE80211_FCTL_STYPE) { 2660 2823 case IEEE80211_STYPE_BACK_REQ: 2661 2824 IWL_DEBUG_HT("IEEE80211_STYPE_BACK_REQ arrived\n"); ··· 2664 2829 default: 2665 2830 break; 2666 2831 } 2667 - #endif 2668 2832 break; 2669 2833 2670 2834 case IEEE80211_FTYPE_DATA: { ··· 2696 2862 2697 2863 } 2698 2864 } 2699 - 2700 - #ifdef CONFIG_IWL4965_HT 2701 2865 2702 2866 /** 2703 2867 * iwl4965_tx_status_reply_compressed_ba - Update tx status from block-ack ··· 2758 2926 info->flags |= IEEE80211_TX_STAT_AMPDU; 2759 2927 info->status.ampdu_ack_map = successes; 2760 2928 info->status.ampdu_ack_len = agg->frame_count; 2761 - iwl4965_hwrate_to_tx_control(priv, agg->rate_n_flags, info); 2929 + iwl_hwrate_to_tx_control(priv, agg->rate_n_flags, info); 2762 2930 2763 2931 IWL_DEBUG_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); 2764 2932 ··· 2780 2948 } 2781 2949 2782 2950 /** 2783 - * txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID 2951 + * txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE 2784 2952 * priv->lock must be held by the caller 2785 2953 */ 2786 2954 static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id, ··· 2788 2956 { 2789 2957 int ret = 0; 2790 2958 2791 - if (IWL_BACK_QUEUE_FIRST_ID > txq_id) { 2959 + if (IWL49_FIRST_AMPDU_QUEUE > txq_id) { 2792 2960 IWL_WARNING("queue number too small: %d, must be > %d\n", 2793 - txq_id, IWL_BACK_QUEUE_FIRST_ID); 2961 + txq_id, IWL49_FIRST_AMPDU_QUEUE); 2794 2962 return -EINVAL; 2795 2963 } 2796 2964 ··· 2878 3046 if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { 2879 3047 /* calculate mac80211 ampdu sw queue to wake */ 2880 3048 int ampdu_q = 2881 - scd_flow - IWL_BACK_QUEUE_FIRST_ID + priv->hw->queues; 3049 + scd_flow - priv->hw_params.first_ampdu_q + priv->hw->queues; 2882 3050 int freed = iwl_tx_queue_reclaim(priv, scd_flow, index); 2883 3051 priv->stations[ba_resp->sta_id]. 2884 3052 tid[ba_resp->tid].tfds_in_queue -= freed; ··· 2923 3091 /** 2924 3092 * iwl4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue 2925 3093 * 2926 - * NOTE: txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID, 3094 + * NOTE: txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE, 2927 3095 * i.e. it must be one of the higher queues used for aggregation 2928 3096 */ 2929 3097 static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, ··· 2933 3101 int ret; 2934 3102 u16 ra_tid; 2935 3103 2936 - if (IWL_BACK_QUEUE_FIRST_ID > txq_id) 3104 + if (IWL49_FIRST_AMPDU_QUEUE > txq_id) 2937 3105 IWL_WARNING("queue number too small: %d, must be > %d\n", 2938 - txq_id, IWL_BACK_QUEUE_FIRST_ID); 3106 + txq_id, IWL49_FIRST_AMPDU_QUEUE); 2939 3107 2940 3108 ra_tid = BUILD_RAxTID(sta_id, tid); 2941 3109 ··· 2986 3154 return 0; 2987 3155 } 2988 3156 2989 - #endif /* CONFIG_IWL4965_HT */ 2990 - 2991 - 2992 - #ifdef CONFIG_IWL4965_HT 2993 3157 static int iwl4965_rx_agg_start(struct iwl_priv *priv, 2994 3158 const u8 *addr, int tid, u16 ssn) 2995 3159 { ··· 3059 3231 } 3060 3232 return 0; 3061 3233 } 3062 - #endif /* CONFIG_IWL4965_HT */ 3063 - 3064 3234 3065 3235 static u16 iwl4965_get_hcmd_size(u8 cmd_id, u16 len) 3066 3236 { ··· 3088 3262 return (u16)sizeof(struct iwl4965_addsta_cmd); 3089 3263 } 3090 3264 3091 - #ifdef CONFIG_IWL4965_HT 3092 3265 static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp) 3093 3266 { 3094 - __le32 *scd_ssn = (__le32 *)((u32 *)&tx_resp->status + 3095 - tx_resp->frame_count); 3096 - return le32_to_cpu(*scd_ssn) & MAX_SN; 3097 - 3267 + return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; 3098 3268 } 3099 3269 3100 3270 /** ··· 3098 3276 */ 3099 3277 static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, 3100 3278 struct iwl_ht_agg *agg, 3101 - struct iwl4965_tx_resp_agg *tx_resp, 3102 - u16 start_idx) 3279 + struct iwl4965_tx_resp *tx_resp, 3280 + int txq_id, u16 start_idx) 3103 3281 { 3104 3282 u16 status; 3105 - struct agg_tx_status *frame_status = &tx_resp->status; 3283 + struct agg_tx_status *frame_status = tx_resp->u.agg_status; 3106 3284 struct ieee80211_tx_info *info = NULL; 3107 3285 struct ieee80211_hdr *hdr = NULL; 3108 - int i, sh; 3109 - int txq_id, idx; 3286 + u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); 3287 + int i, sh, idx; 3110 3288 u16 seq; 3111 - 3112 3289 if (agg->wait_for_ba) 3113 3290 IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n"); 3114 3291 3115 3292 agg->frame_count = tx_resp->frame_count; 3116 3293 agg->start_idx = start_idx; 3117 - agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); 3294 + agg->rate_n_flags = rate_n_flags; 3118 3295 agg->bitmap = 0; 3119 3296 3120 3297 /* # frames attempted by Tx command */ 3121 3298 if (agg->frame_count == 1) { 3122 3299 /* Only one frame was attempted; no block-ack will arrive */ 3123 3300 status = le16_to_cpu(frame_status[0].status); 3124 - seq = le16_to_cpu(frame_status[0].sequence); 3125 - idx = SEQ_TO_INDEX(seq); 3126 - txq_id = SEQ_TO_QUEUE(seq); 3301 + idx = start_idx; 3127 3302 3128 3303 /* FIXME: code repetition */ 3129 3304 IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", ··· 3131 3312 info->flags &= ~IEEE80211_TX_CTL_AMPDU; 3132 3313 info->flags |= iwl_is_tx_success(status)? 3133 3314 IEEE80211_TX_STAT_ACK : 0; 3134 - iwl4965_hwrate_to_tx_control(priv, 3135 - le32_to_cpu(tx_resp->rate_n_flags), 3136 - info); 3315 + iwl_hwrate_to_tx_control(priv, rate_n_flags, info); 3137 3316 /* FIXME: code repetition end */ 3138 3317 3139 3318 IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", 3140 3319 status & 0xff, tx_resp->failure_frame); 3141 - IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", 3142 - iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags)); 3320 + IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); 3143 3321 3144 3322 agg->wait_for_ba = 0; 3145 3323 } else { ··· 3194 3378 3195 3379 agg->bitmap = bitmap; 3196 3380 agg->start_idx = start; 3197 - agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); 3198 3381 IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", 3199 3382 agg->frame_count, agg->start_idx, 3200 3383 (unsigned long long)agg->bitmap); ··· 3203 3388 } 3204 3389 return 0; 3205 3390 } 3206 - #endif 3207 3391 3208 3392 /** 3209 3393 * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response ··· 3217 3403 struct iwl_tx_queue *txq = &priv->txq[txq_id]; 3218 3404 struct ieee80211_tx_info *info; 3219 3405 struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; 3220 - u32 status = le32_to_cpu(tx_resp->status); 3221 - #ifdef CONFIG_IWL4965_HT 3406 + u32 status = le32_to_cpu(tx_resp->u.status); 3222 3407 int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION; 3223 - u16 fc; 3408 + __le16 fc; 3224 3409 struct ieee80211_hdr *hdr; 3225 3410 u8 *qc = NULL; 3226 - #endif 3227 3411 3228 3412 if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) { 3229 3413 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " ··· 3234 3422 info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]); 3235 3423 memset(&info->status, 0, sizeof(info->status)); 3236 3424 3237 - #ifdef CONFIG_IWL4965_HT 3238 3425 hdr = iwl_tx_queue_get_hdr(priv, txq_id, index); 3239 - fc = le16_to_cpu(hdr->frame_control); 3240 - if (ieee80211_is_qos_data(fc)) { 3241 - qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); 3426 + fc = hdr->frame_control; 3427 + if (ieee80211_is_data_qos(fc)) { 3428 + qc = ieee80211_get_qos_ctl(hdr); 3242 3429 tid = qc[0] & 0xf; 3243 3430 } 3244 3431 ··· 3256 3445 3257 3446 agg = &priv->stations[sta_id].tid[tid].agg; 3258 3447 3259 - iwl4965_tx_status_reply_tx(priv, agg, 3260 - (struct iwl4965_tx_resp_agg *)tx_resp, index); 3448 + iwl4965_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); 3261 3449 3262 3450 if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status)) { 3263 3451 /* TODO: send BAR */ ··· 3274 3464 txq_id >= 0 && priv->mac80211_registered && 3275 3465 agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) { 3276 3466 /* calculate mac80211 ampdu sw queue to wake */ 3277 - ampdu_q = txq_id - IWL_BACK_QUEUE_FIRST_ID + 3467 + ampdu_q = txq_id - IWL49_FIRST_AMPDU_QUEUE + 3278 3468 priv->hw->queues; 3279 3469 if (agg->state == IWL_AGG_OFF) 3280 3470 ieee80211_wake_queue(priv->hw, txq_id); ··· 3284 3474 iwl_txq_check_empty(priv, sta_id, tid, txq_id); 3285 3475 } 3286 3476 } else { 3287 - #endif /* CONFIG_IWL4965_HT */ 3477 + info->status.retry_count = tx_resp->failure_frame; 3478 + info->flags |= 3479 + iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0; 3480 + iwl_hwrate_to_tx_control(priv, 3481 + le32_to_cpu(tx_resp->rate_n_flags), 3482 + info); 3288 3483 3289 - info->status.retry_count = tx_resp->failure_frame; 3290 - info->flags |= iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0; 3291 - iwl4965_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), 3292 - info); 3484 + IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags " 3485 + "0x%x retries %d\n", txq_id, 3486 + iwl_get_tx_fail_reason(status), 3487 + status, le32_to_cpu(tx_resp->rate_n_flags), 3488 + tx_resp->failure_frame); 3293 3489 3294 - IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " 3295 - "retries %d\n", txq_id, iwl_get_tx_fail_reason(status), 3296 - status, le32_to_cpu(tx_resp->rate_n_flags), 3297 - tx_resp->failure_frame); 3490 + IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); 3298 3491 3299 - IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); 3300 - #ifdef CONFIG_IWL4965_HT 3301 - if (index != -1) { 3302 - int freed = iwl_tx_queue_reclaim(priv, txq_id, index); 3303 - if (tid != MAX_TID_COUNT) 3492 + if (index != -1) { 3493 + int freed = iwl_tx_queue_reclaim(priv, txq_id, index); 3494 + if (tid != MAX_TID_COUNT) 3304 3495 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 3305 - if (iwl_queue_space(&txq->q) > txq->q.low_mark && 3496 + if (iwl_queue_space(&txq->q) > txq->q.low_mark && 3306 3497 (txq_id >= 0) && priv->mac80211_registered) 3307 3498 ieee80211_wake_queue(priv->hw, txq_id); 3308 - if (tid != MAX_TID_COUNT) 3499 + if (tid != MAX_TID_COUNT) 3309 3500 iwl_txq_check_empty(priv, sta_id, tid, txq_id); 3501 + } 3310 3502 } 3311 - } 3312 - #endif /* CONFIG_IWL4965_HT */ 3313 3503 3314 3504 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) 3315 3505 IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n"); ··· 3323 3513 priv->rx_handlers[REPLY_RX] = iwl4965_rx_reply_rx; 3324 3514 /* Tx response */ 3325 3515 priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx; 3326 - 3327 - #ifdef CONFIG_IWL4965_HT 3516 + /* block ack */ 3328 3517 priv->rx_handlers[REPLY_COMPRESSED_BA] = iwl4965_rx_reply_compressed_ba; 3329 - #endif /* CONFIG_IWL4965_HT */ 3330 3518 } 3331 3519 3332 - void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv) 3520 + static void iwl4965_setup_deferred_work(struct iwl_priv *priv) 3333 3521 { 3334 3522 INIT_WORK(&priv->txpower_work, iwl4965_bg_txpower_work); 3335 - #ifdef CONFIG_IWL4965_RUN_TIME_CALIB 3336 - INIT_WORK(&priv->sensitivity_work, iwl4965_bg_sensitivity_work); 3337 - #endif 3338 - init_timer(&priv->statistics_periodic); 3339 - priv->statistics_periodic.data = (unsigned long)priv; 3340 - priv->statistics_periodic.function = iwl4965_bg_statistics_periodic; 3341 3523 } 3342 3524 3343 - void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv) 3525 + static void iwl4965_cancel_deferred_work(struct iwl_priv *priv) 3344 3526 { 3345 - del_timer_sync(&priv->statistics_periodic); 3346 - 3347 - cancel_delayed_work(&priv->init_alive_start); 3527 + cancel_work_sync(&priv->txpower_work); 3348 3528 } 3349 3529 3350 3530 ··· 3345 3545 static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = { 3346 3546 .get_hcmd_size = iwl4965_get_hcmd_size, 3347 3547 .build_addsta_hcmd = iwl4965_build_addsta_hcmd, 3348 - #ifdef CONFIG_IWL4965_RUN_TIME_CALIB 3349 3548 .chain_noise_reset = iwl4965_chain_noise_reset, 3350 3549 .gain_computation = iwl4965_gain_computation, 3351 - #endif 3352 3550 }; 3353 3551 3354 3552 static struct iwl_lib_ops iwl4965_lib = { ··· 3356 3558 .shared_mem_rx_idx = iwl4965_shared_mem_rx_idx, 3357 3559 .txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl, 3358 3560 .txq_set_sched = iwl4965_txq_set_sched, 3359 - #ifdef CONFIG_IWL4965_HT 3360 3561 .txq_agg_enable = iwl4965_txq_agg_enable, 3361 3562 .txq_agg_disable = iwl4965_txq_agg_disable, 3362 - #endif 3363 3563 .rx_handler_setup = iwl4965_rx_handler_setup, 3564 + .setup_deferred_work = iwl4965_setup_deferred_work, 3565 + .cancel_deferred_work = iwl4965_cancel_deferred_work, 3364 3566 .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr, 3365 3567 .alive_notify = iwl4965_alive_notify, 3366 3568 .init_alive_start = iwl4965_init_alive_start, ··· 3388 3590 .check_version = iwl4965_eeprom_check_version, 3389 3591 .query_addr = iwlcore_eeprom_query_addr, 3390 3592 }, 3391 - .radio_kill_sw = iwl4965_radio_kill_sw, 3392 3593 .set_power = iwl4965_set_power, 3594 + .send_tx_power = iwl4965_send_tx_power, 3393 3595 .update_chain_flags = iwl4965_update_chain_flags, 3394 3596 }; 3395 3597
+1 -1
drivers/net/wireless/iwlwifi/iwl-5000-hw.h
··· 81 81 #define IWL50_QUEUE_SIZE 256 82 82 #define IWL50_CMD_FIFO_NUM 7 83 83 #define IWL50_NUM_QUEUES 20 84 - #define IWL50_BACK_QUEUE_FIRST_ID 10 84 + #define IWL50_FIRST_AMPDU_QUEUE 10 85 85 86 86 #define IWL_sta_id_POS 12 87 87 #define IWL_sta_id_LEN 4
+186 -56
drivers/net/wireless/iwlwifi/iwl-5000.c
··· 41 41 #include "iwl-dev.h" 42 42 #include "iwl-core.h" 43 43 #include "iwl-io.h" 44 + #include "iwl-sta.h" 44 45 #include "iwl-helpers.h" 45 46 #include "iwl-5000-hw.h" 46 47 ··· 301 300 302 301 } 303 302 304 - #ifdef CONFIG_IWL5000_RUN_TIME_CALIB 305 - 306 303 static void iwl5000_gain_computation(struct iwl_priv *priv, 307 304 u32 average_noise[NUM_RX_CHAINS], 308 305 u16 min_average_noise_antenna_i, ··· 353 354 data->beacon_count = 0; 354 355 } 355 356 356 - 357 357 static void iwl5000_chain_noise_reset(struct iwl_priv *priv) 358 358 { 359 359 struct iwl_chain_noise_data *data = &priv->chain_noise_data; ··· 390 392 .nrg_th_cck = 95, 391 393 .nrg_th_ofdm = 95, 392 394 }; 393 - 394 - #endif /* CONFIG_IWL5000_RUN_TIME_CALIB */ 395 - 396 - 397 395 398 396 static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv, 399 397 size_t offset) ··· 826 832 } 827 833 828 834 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; 835 + priv->hw_params.first_ampdu_q = IWL50_FIRST_AMPDU_QUEUE; 829 836 priv->hw_params.sw_crypto = priv->cfg->mod_params->sw_crypto; 830 837 priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; 831 838 priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; ··· 842 847 priv->hw_params.max_bsm_size = BSM_SRAM_SIZE; 843 848 priv->hw_params.fat_channel = BIT(IEEE80211_BAND_2GHZ) | 844 849 BIT(IEEE80211_BAND_5GHZ); 845 - #ifdef CONFIG_IWL5000_RUN_TIME_CALIB 846 850 priv->hw_params.sens = &iwl5000_sensitivity; 847 - #endif 848 851 849 852 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { 850 853 case CSR_HW_REV_TYPE_5100: ··· 977 984 } 978 985 } 979 986 987 + static int iwl5000_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid, 988 + u16 txq_id) 989 + { 990 + u32 tbl_dw_addr; 991 + u32 tbl_dw; 992 + u16 scd_q2ratid; 993 + 994 + scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; 995 + 996 + tbl_dw_addr = priv->scd_base_addr + 997 + IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); 998 + 999 + tbl_dw = iwl_read_targ_mem(priv, tbl_dw_addr); 1000 + 1001 + if (txq_id & 0x1) 1002 + tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF); 1003 + else 1004 + tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000); 1005 + 1006 + iwl_write_targ_mem(priv, tbl_dw_addr, tbl_dw); 1007 + 1008 + return 0; 1009 + } 1010 + static void iwl5000_tx_queue_stop_scheduler(struct iwl_priv *priv, u16 txq_id) 1011 + { 1012 + /* Simply stop the queue, but don't change any configuration; 1013 + * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ 1014 + iwl_write_prph(priv, 1015 + IWL50_SCD_QUEUE_STATUS_BITS(txq_id), 1016 + (0 << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE)| 1017 + (1 << IWL50_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); 1018 + } 1019 + 1020 + static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id, 1021 + int tx_fifo, int sta_id, int tid, u16 ssn_idx) 1022 + { 1023 + unsigned long flags; 1024 + int ret; 1025 + u16 ra_tid; 1026 + 1027 + if (IWL50_FIRST_AMPDU_QUEUE > txq_id) 1028 + IWL_WARNING("queue number too small: %d, must be > %d\n", 1029 + txq_id, IWL50_FIRST_AMPDU_QUEUE); 1030 + 1031 + ra_tid = BUILD_RAxTID(sta_id, tid); 1032 + 1033 + /* Modify device's station table to Tx this TID */ 1034 + iwl_sta_modify_enable_tid_tx(priv, sta_id, tid); 1035 + 1036 + spin_lock_irqsave(&priv->lock, flags); 1037 + ret = iwl_grab_nic_access(priv); 1038 + if (ret) { 1039 + spin_unlock_irqrestore(&priv->lock, flags); 1040 + return ret; 1041 + } 1042 + 1043 + /* Stop this Tx queue before configuring it */ 1044 + iwl5000_tx_queue_stop_scheduler(priv, txq_id); 1045 + 1046 + /* Map receiver-address / traffic-ID to this queue */ 1047 + iwl5000_tx_queue_set_q2ratid(priv, ra_tid, txq_id); 1048 + 1049 + /* Set this queue as a chain-building queue */ 1050 + iwl_set_bits_prph(priv, IWL50_SCD_QUEUECHAIN_SEL, (1<<txq_id)); 1051 + 1052 + /* enable aggregations for the queue */ 1053 + iwl_set_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1<<txq_id)); 1054 + 1055 + /* Place first TFD at index corresponding to start sequence number. 1056 + * Assumes that ssn_idx is valid (!= 0xFFF) */ 1057 + priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); 1058 + priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); 1059 + iwl5000_set_wr_ptrs(priv, txq_id, ssn_idx); 1060 + 1061 + /* Set up Tx window size and frame limit for this queue */ 1062 + iwl_write_targ_mem(priv, priv->scd_base_addr + 1063 + IWL50_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + 1064 + sizeof(u32), 1065 + ((SCD_WIN_SIZE << 1066 + IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) & 1067 + IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) | 1068 + ((SCD_FRAME_LIMIT << 1069 + IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & 1070 + IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK)); 1071 + 1072 + iwl_set_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id)); 1073 + 1074 + /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ 1075 + iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1); 1076 + 1077 + iwl_release_nic_access(priv); 1078 + spin_unlock_irqrestore(&priv->lock, flags); 1079 + 1080 + return 0; 1081 + } 1082 + 1083 + static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id, 1084 + u16 ssn_idx, u8 tx_fifo) 1085 + { 1086 + int ret; 1087 + 1088 + if (IWL50_FIRST_AMPDU_QUEUE > txq_id) { 1089 + IWL_WARNING("queue number too small: %d, must be > %d\n", 1090 + txq_id, IWL50_FIRST_AMPDU_QUEUE); 1091 + return -EINVAL; 1092 + } 1093 + 1094 + ret = iwl_grab_nic_access(priv); 1095 + if (ret) 1096 + return ret; 1097 + 1098 + iwl5000_tx_queue_stop_scheduler(priv, txq_id); 1099 + 1100 + iwl_clear_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1 << txq_id)); 1101 + 1102 + priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); 1103 + priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); 1104 + /* supposes that ssn_idx is valid (!= 0xFFF) */ 1105 + iwl5000_set_wr_ptrs(priv, txq_id, ssn_idx); 1106 + 1107 + iwl_clear_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id)); 1108 + iwl_txq_ctx_deactivate(priv, txq_id); 1109 + iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0); 1110 + 1111 + iwl_release_nic_access(priv); 1112 + 1113 + return 0; 1114 + } 1115 + 980 1116 static u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) 981 1117 { 982 1118 u16 size = (u16)sizeof(struct iwl_addsta_cmd); ··· 1126 1004 1127 1005 static inline u32 iwl5000_get_scd_ssn(struct iwl5000_tx_resp *tx_resp) 1128 1006 { 1129 - __le32 *scd_ssn = (__le32 *)((u32 *)&tx_resp->status + 1130 - tx_resp->frame_count); 1131 - return le32_to_cpu(*scd_ssn) & MAX_SN; 1132 - 1007 + return le32_to_cpup((__le32*)&tx_resp->status + 1008 + tx_resp->frame_count) & MAX_SN; 1133 1009 } 1134 1010 1135 1011 static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv, 1136 1012 struct iwl_ht_agg *agg, 1137 1013 struct iwl5000_tx_resp *tx_resp, 1138 - u16 start_idx) 1014 + int txq_id, u16 start_idx) 1139 1015 { 1140 1016 u16 status; 1141 1017 struct agg_tx_status *frame_status = &tx_resp->status; 1142 1018 struct ieee80211_tx_info *info = NULL; 1143 1019 struct ieee80211_hdr *hdr = NULL; 1144 - int i, sh; 1145 - int txq_id, idx; 1020 + u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); 1021 + int i, sh, idx; 1146 1022 u16 seq; 1147 1023 1148 1024 if (agg->wait_for_ba) ··· 1148 1028 1149 1029 agg->frame_count = tx_resp->frame_count; 1150 1030 agg->start_idx = start_idx; 1151 - agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); 1031 + agg->rate_n_flags = rate_n_flags; 1152 1032 agg->bitmap = 0; 1153 1033 1154 1034 /* # frames attempted by Tx command */ 1155 1035 if (agg->frame_count == 1) { 1156 1036 /* Only one frame was attempted; no block-ack will arrive */ 1157 1037 status = le16_to_cpu(frame_status[0].status); 1158 - seq = le16_to_cpu(frame_status[0].sequence); 1159 - idx = SEQ_TO_INDEX(seq); 1160 - txq_id = SEQ_TO_QUEUE(seq); 1038 + idx = start_idx; 1161 1039 1162 1040 /* FIXME: code repetition */ 1163 1041 IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", ··· 1166 1048 info->flags &= ~IEEE80211_TX_CTL_AMPDU; 1167 1049 info->flags |= iwl_is_tx_success(status)? 1168 1050 IEEE80211_TX_STAT_ACK : 0; 1169 - iwl4965_hwrate_to_tx_control(priv, 1170 - le32_to_cpu(tx_resp->rate_n_flags), 1171 - info); 1051 + iwl_hwrate_to_tx_control(priv, rate_n_flags, info); 1052 + 1172 1053 /* FIXME: code repetition end */ 1173 1054 1174 1055 IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", 1175 1056 status & 0xff, tx_resp->failure_frame); 1176 - IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", 1177 - iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags)); 1057 + IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); 1178 1058 1179 1059 agg->wait_for_ba = 0; 1180 1060 } else { ··· 1230 1114 1231 1115 agg->bitmap = bitmap; 1232 1116 agg->start_idx = start; 1233 - agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); 1234 1117 IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", 1235 1118 agg->frame_count, agg->start_idx, 1236 1119 (unsigned long long)agg->bitmap); ··· 1251 1136 struct ieee80211_tx_info *info; 1252 1137 struct iwl5000_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; 1253 1138 u32 status = le16_to_cpu(tx_resp->status.status); 1254 - #ifdef CONFIG_IWL4965_HT 1255 1139 int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION; 1256 - u16 fc; 1257 1140 struct ieee80211_hdr *hdr; 1258 1141 u8 *qc = NULL; 1259 - #endif 1260 1142 1261 1143 if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) { 1262 1144 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " ··· 1266 1154 info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]); 1267 1155 memset(&info->status, 0, sizeof(info->status)); 1268 1156 1269 - #ifdef CONFIG_IWL4965_HT 1270 1157 hdr = iwl_tx_queue_get_hdr(priv, txq_id, index); 1271 - fc = le16_to_cpu(hdr->frame_control); 1272 - if (ieee80211_is_qos_data(fc)) { 1273 - qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); 1158 + if (ieee80211_is_data_qos(hdr->frame_control)) { 1159 + qc = ieee80211_get_qos_ctl(hdr); 1274 1160 tid = qc[0] & 0xf; 1275 1161 } 1276 1162 ··· 1287 1177 1288 1178 agg = &priv->stations[sta_id].tid[tid].agg; 1289 1179 1290 - iwl5000_tx_status_reply_tx(priv, agg, tx_resp, index); 1180 + iwl5000_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); 1291 1181 1292 1182 if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status)) { 1293 1183 /* TODO: send BAR */ ··· 1305 1195 txq_id >= 0 && priv->mac80211_registered && 1306 1196 agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) { 1307 1197 /* calculate mac80211 ampdu sw queue to wake */ 1308 - ampdu_q = txq_id - IWL_BACK_QUEUE_FIRST_ID + 1198 + ampdu_q = txq_id - IWL50_FIRST_AMPDU_QUEUE + 1309 1199 priv->hw->queues; 1310 1200 if (agg->state == IWL_AGG_OFF) 1311 1201 ieee80211_wake_queue(priv->hw, txq_id); ··· 1315 1205 iwl_txq_check_empty(priv, sta_id, tid, txq_id); 1316 1206 } 1317 1207 } else { 1318 - #endif /* CONFIG_IWL4965_HT */ 1208 + info->status.retry_count = tx_resp->failure_frame; 1209 + info->flags = 1210 + iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0; 1211 + iwl_hwrate_to_tx_control(priv, 1212 + le32_to_cpu(tx_resp->rate_n_flags), 1213 + info); 1319 1214 1320 - info->status.retry_count = tx_resp->failure_frame; 1321 - info->flags = iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0; 1322 - iwl4965_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), 1323 - info); 1215 + IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags " 1216 + "0x%x retries %d\n", txq_id, 1217 + iwl_get_tx_fail_reason(status), 1218 + status, le32_to_cpu(tx_resp->rate_n_flags), 1219 + tx_resp->failure_frame); 1324 1220 1325 - IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " 1326 - "retries %d\n", txq_id, iwl_get_tx_fail_reason(status), 1327 - status, le32_to_cpu(tx_resp->rate_n_flags), 1328 - tx_resp->failure_frame); 1329 - 1330 - IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); 1331 - #ifdef CONFIG_IWL4965_HT 1332 - if (index != -1) { 1333 - int freed = iwl_tx_queue_reclaim(priv, txq_id, index); 1334 - if (tid != MAX_TID_COUNT) 1221 + IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); 1222 + if (index != -1) { 1223 + int freed = iwl_tx_queue_reclaim(priv, txq_id, index); 1224 + if (tid != MAX_TID_COUNT) 1335 1225 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 1336 - if (iwl_queue_space(&txq->q) > txq->q.low_mark && 1226 + if (iwl_queue_space(&txq->q) > txq->q.low_mark && 1337 1227 (txq_id >= 0) && priv->mac80211_registered) 1338 1228 ieee80211_wake_queue(priv->hw, txq_id); 1339 - if (tid != MAX_TID_COUNT) 1229 + if (tid != MAX_TID_COUNT) 1340 1230 iwl_txq_check_empty(priv, sta_id, tid, txq_id); 1231 + } 1341 1232 } 1342 - } 1343 - #endif /* CONFIG_IWL4965_HT */ 1344 1233 1345 1234 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) 1346 1235 IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n"); ··· 1349 1240 static u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len) 1350 1241 { 1351 1242 return len; 1243 + } 1244 + 1245 + static void iwl5000_setup_deferred_work(struct iwl_priv *priv) 1246 + { 1247 + /* in 5000 the tx power calibration is done in uCode */ 1248 + priv->disable_tx_power_cal = 1; 1352 1249 } 1353 1250 1354 1251 static void iwl5000_rx_handler_setup(struct iwl_priv *priv) ··· 1420 1305 1421 1306 return ret; 1422 1307 } 1308 + static int iwl5000_send_tx_power(struct iwl_priv *priv) 1309 + { 1310 + struct iwl5000_tx_power_dbm_cmd tx_power_cmd; 1311 + 1312 + /* half dBm need to multiply */ 1313 + tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt); 1314 + tx_power_cmd.flags = 0; 1315 + tx_power_cmd.srv_chan_lmt = IWL50_TX_POWER_AUTO; 1316 + return iwl_send_cmd_pdu_async(priv, REPLY_TX_POWER_DBM_CMD, 1317 + sizeof(tx_power_cmd), &tx_power_cmd, 1318 + NULL); 1319 + } 1320 + 1423 1321 1424 1322 static struct iwl_hcmd_ops iwl5000_hcmd = { 1425 1323 .rxon_assoc = iwl5000_send_rxon_assoc, ··· 1441 1313 static struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = { 1442 1314 .get_hcmd_size = iwl5000_get_hcmd_size, 1443 1315 .build_addsta_hcmd = iwl5000_build_addsta_hcmd, 1444 - #ifdef CONFIG_IWL5000_RUN_TIME_CALIB 1445 1316 .gain_computation = iwl5000_gain_computation, 1446 1317 .chain_noise_reset = iwl5000_chain_noise_reset, 1447 - #endif 1448 1318 }; 1449 1319 1450 1320 static struct iwl_lib_ops iwl5000_lib = { ··· 1453 1327 .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl, 1454 1328 .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl, 1455 1329 .txq_set_sched = iwl5000_txq_set_sched, 1330 + .txq_agg_enable = iwl5000_txq_agg_enable, 1331 + .txq_agg_disable = iwl5000_txq_agg_disable, 1456 1332 .rx_handler_setup = iwl5000_rx_handler_setup, 1333 + .setup_deferred_work = iwl5000_setup_deferred_work, 1457 1334 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr, 1458 1335 .load_ucode = iwl5000_load_ucode, 1459 1336 .init_alive_start = iwl5000_init_alive_start, 1460 1337 .alive_notify = iwl5000_alive_notify, 1338 + .send_tx_power = iwl5000_send_tx_power, 1461 1339 .apm_ops = { 1462 1340 .init = iwl5000_apm_init, 1463 1341 .reset = iwl5000_apm_reset,
-4
drivers/net/wireless/iwlwifi/iwl-calib.c
··· 60 60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61 61 *****************************************************************************/ 62 62 63 - #include <linux/kernel.h> 64 63 #include <net/mac80211.h> 65 64 66 65 #include "iwl-dev.h" 67 66 #include "iwl-core.h" 68 67 #include "iwl-calib.h" 69 - #include "iwl-eeprom.h" 70 68 71 69 /* "false alarms" are signals that our DSP tries to lock onto, 72 70 * but then determines that they are either noise, or transmissions ··· 433 435 data = &(priv->sensitivity_data); 434 436 435 437 if (ranges == NULL) 436 - /* can happen if IWLWIFI_RUN_TIME_CALIB is selected 437 - * but no IWLXXXX_RUN_TIME_CALIB for specific is selected */ 438 438 return; 439 439 440 440 memset(data, 0, sizeof(struct iwl_sensitivity_data));
+2 -27
drivers/net/wireless/iwlwifi/iwl-calib.h
··· 62 62 #ifndef __iwl_calib_h__ 63 63 #define __iwl_calib_h__ 64 64 65 - #include <linux/kernel.h> 66 - #include <linux/module.h> 67 - #include <linux/version.h> 68 - 69 - #include <net/mac80211.h> 70 - #include "iwl-eeprom.h" 71 - #include "iwl-core.h" 72 65 #include "iwl-dev.h" 66 + #include "iwl-core.h" 67 + #include "iwl-commands.h" 73 68 74 - #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB 75 69 void iwl_chain_noise_calibration(struct iwl_priv *priv, 76 70 struct iwl4965_notif_statistics *stat_resp); 77 71 void iwl_sensitivity_calibration(struct iwl_priv *priv, ··· 80 86 priv->cfg->ops->utils->chain_noise_reset) 81 87 priv->cfg->ops->utils->chain_noise_reset(priv); 82 88 } 83 - #else 84 - static inline void iwl_chain_noise_calibration(struct iwl_priv *priv, 85 - struct iwl4965_notif_statistics *stat_resp) 86 - { 87 - } 88 - static inline void iwl_sensitivity_calibration(struct iwl_priv *priv, 89 - struct iwl4965_notif_statistics *resp) 90 - { 91 - } 92 - static inline void iwl_init_sensitivity(struct iwl_priv *priv) 93 - { 94 - } 95 - static inline void iwl_chain_noise_reset(struct iwl_priv *priv) 96 - { 97 - } 98 - static inline void iwl_reset_run_time_calib(struct iwl_priv *priv) 99 - { 100 - } 101 - #endif 102 89 103 90 #endif /* __iwl_calib_h__ */
+33 -39
drivers/net/wireless/iwlwifi/iwl-commands.h
··· 126 126 /* Miscellaneous commands */ 127 127 QUIET_NOTIFICATION = 0x96, /* not used */ 128 128 REPLY_TX_PWR_TABLE_CMD = 0x97, 129 + REPLY_TX_POWER_DBM_CMD = 0x98, 129 130 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */ 130 131 131 132 /* Bluetooth device coexistance config command */ ··· 281 280 #define RATE_MCS_ANT_C_MSK 0x10000 282 281 #define RATE_MCS_ANT_ABC_MSK 0x1C000 283 282 284 - 285 - /** 286 - * struct iwl4965_tx_power - txpower format used in REPLY_SCAN_CMD 287 - * 288 - * Scan uses only one transmitter, so only one analog/dsp gain pair is needed. 289 - */ 290 - struct iwl4965_tx_power { 291 - u8 tx_gain; /* gain for analog radio */ 292 - u8 dsp_atten; /* gain for DSP */ 293 - } __attribute__ ((packed)); 283 + #define RATE_MCS_ANT_INIT_IND 1 294 284 295 285 #define POWER_TABLE_NUM_ENTRIES 33 296 286 #define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32 ··· 331 339 struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES]; 332 340 } __attribute__ ((packed)); 333 341 342 + /** 343 + * Commad REPLY_TX_POWER_DBM_CMD = 0x98 344 + * struct iwl5000_tx_power_dbm_cmd 345 + */ 346 + #define IWL50_TX_POWER_AUTO 0x7f 347 + struct iwl5000_tx_power_dbm_cmd { 348 + s8 global_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */ 349 + u8 flags; 350 + s8 srv_chan_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */ 351 + u8 reserved; 352 + } __attribute__ ((packed)); 334 353 335 354 /****************************************************************************** 336 355 * (0a) ··· 993 990 #define WEP_KEY_WEP_TYPE 1 994 991 #define WEP_KEYS_MAX 4 995 992 #define WEP_INVALID_OFFSET 0xff 993 + #define WEP_KEY_LEN_64 5 996 994 #define WEP_KEY_LEN_128 13 997 995 998 996 /****************************************************************************** ··· 1485 1481 * table entry used for all frames in the new agg. 1486 1482 * 31-16: Sequence # for this frame's Tx cmd (not SSN!) 1487 1483 */ 1488 - __le32 status; /* TX status (for aggregation status of 1st frame) */ 1489 - } __attribute__ ((packed)); 1490 - 1491 - struct iwl4965_tx_resp_agg { 1492 - u8 frame_count; /* 1 no aggregation, >1 aggregation */ 1493 - u8 reserved1; 1494 - u8 failure_rts; 1495 - u8 failure_frame; 1496 - __le32 rate_n_flags; 1497 - __le16 wireless_media_time; 1498 - __le16 reserved3; 1499 - __le32 pa_power1; 1500 - __le32 pa_power2; 1501 - struct agg_tx_status status; /* TX status (for aggregation status */ 1502 - /* of 1st frame) */ 1484 + union { 1485 + __le32 status; 1486 + struct agg_tx_status agg_status[0]; /* for each agg frame */ 1487 + } u; 1503 1488 } __attribute__ ((packed)); 1504 1489 1505 1490 struct iwl5000_tx_resp { ··· 2078 2085 #define RF_CARD_DISABLED 0x04 2079 2086 #define RXON_CARD_DISABLED 0x10 2080 2087 2081 - struct iwl4965_ct_kill_config { 2088 + struct iwl_ct_kill_config { 2082 2089 __le32 reserved; 2083 2090 __le32 critical_temperature_M; 2084 2091 __le32 critical_temperature_R; ··· 2091 2098 *****************************************************************************/ 2092 2099 2093 2100 /** 2094 - * struct iwl4965_scan_channel - entry in REPLY_SCAN_CMD channel table 2101 + * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table 2095 2102 * 2096 2103 * One for each channel in the scan list. 2097 2104 * Each channel can independently select: ··· 2101 2108 * quiet_plcp_th, good_CRC_th) 2102 2109 * 2103 2110 * To avoid uCode errors, make sure the following are true (see comments 2104 - * under struct iwl4965_scan_cmd about max_out_time and quiet_time): 2111 + * under struct iwl_scan_cmd about max_out_time and quiet_time): 2105 2112 * 1) If using passive_dwell (i.e. passive_dwell != 0): 2106 2113 * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0) 2107 2114 * 2) quiet_time <= active_dwell ··· 2109 2116 * passive_dwell < max_out_time 2110 2117 * active_dwell < max_out_time 2111 2118 */ 2112 - struct iwl4965_scan_channel { 2119 + struct iwl_scan_channel { 2113 2120 /* 2114 2121 * type is defined as: 2115 2122 * 0:0 1 = active, 0 = passive ··· 2119 2126 */ 2120 2127 u8 type; 2121 2128 u8 channel; /* band is selected by iwl4965_scan_cmd "flags" field */ 2122 - struct iwl4965_tx_power tpc; 2129 + u8 tx_gain; /* gain for analog radio */ 2130 + u8 dsp_atten; /* gain for DSP */ 2123 2131 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ 2124 2132 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ 2125 2133 } __attribute__ ((packed)); 2126 2134 2127 2135 /** 2128 - * struct iwl4965_ssid_ie - directed scan network information element 2136 + * struct iwl_ssid_ie - directed scan network information element 2129 2137 * 2130 2138 * Up to 4 of these may appear in REPLY_SCAN_CMD, selected by "type" field 2131 2139 * in struct iwl4965_scan_channel; each channel may select different ssids from 2132 2140 * among the 4 entries. SSID IEs get transmitted in reverse order of entry. 2133 2141 */ 2134 - struct iwl4965_ssid_ie { 2142 + struct iwl_ssid_ie { 2135 2143 u8 id; 2136 2144 u8 len; 2137 2145 u8 ssid[32]; ··· 2193 2199 * Driver must use separate scan commands for 2.4 vs. 5 GHz bands. 2194 2200 * 2195 2201 * To avoid uCode errors, see timing restrictions described under 2196 - * struct iwl4965_scan_channel. 2202 + * struct iwl_scan_channel. 2197 2203 */ 2198 - struct iwl4965_scan_cmd { 2204 + struct iwl_scan_cmd { 2199 2205 __le16 len; 2200 2206 u8 reserved0; 2201 2207 u8 channel_count; /* # channels in channel list */ ··· 2219 2225 struct iwl_tx_cmd tx_cmd; 2220 2226 2221 2227 /* For directed active scans (set to all-0s otherwise) */ 2222 - struct iwl4965_ssid_ie direct_scan[PROBE_OPTION_MAX]; 2228 + struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX]; 2223 2229 2224 2230 /* 2225 2231 * Probe request frame, followed by channel list. ··· 2247 2253 /* 2248 2254 * REPLY_SCAN_CMD = 0x80 (response) 2249 2255 */ 2250 - struct iwl4965_scanreq_notification { 2256 + struct iwl_scanreq_notification { 2251 2257 __le32 status; /* 1: okay, 2: cannot fulfill request */ 2252 2258 } __attribute__ ((packed)); 2253 2259 2254 2260 /* 2255 2261 * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command) 2256 2262 */ 2257 - struct iwl4965_scanstart_notification { 2263 + struct iwl_scanstart_notification { 2258 2264 __le32 tsf_low; 2259 2265 __le32 tsf_high; 2260 2266 __le32 beacon_timer; ··· 2271 2277 /* 2272 2278 * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command) 2273 2279 */ 2274 - struct iwl4965_scanresults_notification { 2280 + struct iwl_scanresults_notification { 2275 2281 u8 channel; 2276 2282 u8 band; 2277 2283 u8 reserved[2]; ··· 2283 2289 /* 2284 2290 * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command) 2285 2291 */ 2286 - struct iwl4965_scancomplete_notification { 2292 + struct iwl_scancomplete_notification { 2287 2293 u8 scanned_channels; 2288 2294 u8 status; 2289 2295 u8 reserved;
+218 -85
drivers/net/wireless/iwlwifi/iwl-core.c
··· 85 85 }; 86 86 EXPORT_SYMBOL(iwl_rates); 87 87 88 + /** 89 + * translate ucode response to mac80211 tx status control values 90 + */ 91 + void iwl_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, 92 + struct ieee80211_tx_info *control) 93 + { 94 + int rate_index; 95 + 96 + control->antenna_sel_tx = 97 + ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); 98 + if (rate_n_flags & RATE_MCS_HT_MSK) 99 + control->flags |= IEEE80211_TX_CTL_OFDM_HT; 100 + if (rate_n_flags & RATE_MCS_GF_MSK) 101 + control->flags |= IEEE80211_TX_CTL_GREEN_FIELD; 102 + if (rate_n_flags & RATE_MCS_FAT_MSK) 103 + control->flags |= IEEE80211_TX_CTL_40_MHZ_WIDTH; 104 + if (rate_n_flags & RATE_MCS_DUP_MSK) 105 + control->flags |= IEEE80211_TX_CTL_DUP_DATA; 106 + if (rate_n_flags & RATE_MCS_SGI_MSK) 107 + control->flags |= IEEE80211_TX_CTL_SHORT_GI; 108 + rate_index = iwl_hwrate_to_plcp_idx(rate_n_flags); 109 + if (control->band == IEEE80211_BAND_5GHZ) 110 + rate_index -= IWL_FIRST_OFDM_RATE; 111 + control->tx_rate_idx = rate_index; 112 + } 113 + EXPORT_SYMBOL(iwl_hwrate_to_tx_control); 114 + 115 + int iwl_hwrate_to_plcp_idx(u32 rate_n_flags) 116 + { 117 + int idx = 0; 118 + 119 + /* HT rate format */ 120 + if (rate_n_flags & RATE_MCS_HT_MSK) { 121 + idx = (rate_n_flags & 0xff); 122 + 123 + if (idx >= IWL_RATE_MIMO2_6M_PLCP) 124 + idx = idx - IWL_RATE_MIMO2_6M_PLCP; 125 + 126 + idx += IWL_FIRST_OFDM_RATE; 127 + /* skip 9M not supported in ht*/ 128 + if (idx >= IWL_RATE_9M_INDEX) 129 + idx += 1; 130 + if ((idx >= IWL_FIRST_OFDM_RATE) && (idx <= IWL_LAST_OFDM_RATE)) 131 + return idx; 132 + 133 + /* legacy rate format, search for match in table */ 134 + } else { 135 + for (idx = 0; idx < ARRAY_SIZE(iwl_rates); idx++) 136 + if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF)) 137 + return idx; 138 + } 139 + 140 + return -1; 141 + } 142 + EXPORT_SYMBOL(iwl_hwrate_to_plcp_idx); 143 + 144 + 88 145 89 146 const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 90 147 EXPORT_SYMBOL(iwl_bcast_addr); ··· 378 321 } 379 322 EXPORT_SYMBOL(iwl_reset_qos); 380 323 381 - #ifdef CONFIG_IWL4965_HT 382 324 #define MAX_BIT_RATE_40_MHZ 0x96; /* 150 Mbps */ 383 325 #define MAX_BIT_RATE_20_MHZ 0x48; /* 72 Mbps */ 384 326 static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, ··· 430 374 ht_info->supp_mcs_set[12] |= ((tx_chains_num - 1) << 2); 431 375 } 432 376 } 433 - #else 434 - static inline void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, 435 - struct ieee80211_ht_info *ht_info, 436 - enum ieee80211_band band) 437 - { 438 - } 439 - #endif /* CONFIG_IWL4965_HT */ 440 377 441 378 static void iwlcore_init_hw_rates(struct iwl_priv *priv, 442 379 struct ieee80211_rate *rates) ··· 535 486 if (ch->flags & EEPROM_CHANNEL_RADAR) 536 487 geo_ch->flags |= IEEE80211_CHAN_RADAR; 537 488 538 - switch (ch->fat_extension_channel) { 539 - case HT_IE_EXT_CHANNEL_ABOVE: 540 - /* only above is allowed, disable below */ 541 - geo_ch->flags |= IEEE80211_CHAN_NO_FAT_BELOW; 542 - break; 543 - case HT_IE_EXT_CHANNEL_BELOW: 544 - /* only below is allowed, disable above */ 545 - geo_ch->flags |= IEEE80211_CHAN_NO_FAT_ABOVE; 546 - break; 547 - case HT_IE_EXT_CHANNEL_NONE: 548 - /* fat not allowed: disable both*/ 549 - geo_ch->flags |= (IEEE80211_CHAN_NO_FAT_ABOVE | 550 - IEEE80211_CHAN_NO_FAT_BELOW); 551 - break; 552 - case HT_IE_EXT_CHANNEL_MAX: 553 - /* both above and below are permitted */ 554 - break; 555 - } 489 + geo_ch->flags |= ch->fat_extension_channel; 556 490 557 - if (ch->max_power_avg > priv->max_channel_txpower_limit) 558 - priv->max_channel_txpower_limit = 559 - ch->max_power_avg; 491 + if (ch->max_power_avg > priv->tx_power_channel_lmt) 492 + priv->tx_power_channel_lmt = ch->max_power_avg; 560 493 } else { 561 494 geo_ch->flags |= IEEE80211_CHAN_DISABLED; 562 495 } ··· 546 515 /* Save flags for reg domain usage */ 547 516 geo_ch->orig_flags = geo_ch->flags; 548 517 549 - IWL_DEBUG_INFO("Channel %d Freq=%d[%sGHz] %s flag=0%X\n", 518 + IWL_DEBUG_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", 550 519 ch->channel, geo_ch->center_freq, 551 520 is_channel_a_band(ch) ? "5.2" : "2.4", 552 521 geo_ch->flags & IEEE80211_CHAN_DISABLED ? ··· 584 553 clear_bit(STATUS_GEO_CONFIGURED, &priv->status); 585 554 } 586 555 587 - #ifdef CONFIG_IWL4965_HT 588 556 static u8 is_single_rx_stream(struct iwl_priv *priv) 589 557 { 590 558 return !priv->current_ht_config.is_ht || ··· 591 561 (priv->current_ht_config.supp_mcs_set[2] == 0)) || 592 562 priv->ps_mode == IWL_MIMO_PS_STATIC; 593 563 } 564 + 594 565 static u8 iwl_is_channel_extension(struct iwl_priv *priv, 595 566 enum ieee80211_band band, 596 567 u16 channel, u8 extension_chan_offset) ··· 602 571 if (!is_channel_valid(ch_info)) 603 572 return 0; 604 573 605 - if (extension_chan_offset == IWL_EXT_CHANNEL_OFFSET_NONE) 606 - return 0; 607 - 608 - if ((ch_info->fat_extension_channel == extension_chan_offset) || 609 - (ch_info->fat_extension_channel == HT_IE_EXT_CHANNEL_MAX)) 610 - return 1; 574 + if (extension_chan_offset == IEEE80211_HT_IE_CHA_SEC_ABOVE) 575 + return !(ch_info->fat_extension_channel & 576 + IEEE80211_CHAN_NO_FAT_ABOVE); 577 + else if (extension_chan_offset == IEEE80211_HT_IE_CHA_SEC_BELOW) 578 + return !(ch_info->fat_extension_channel & 579 + IEEE80211_CHAN_NO_FAT_BELOW); 611 580 612 581 return 0; 613 582 } ··· 619 588 620 589 if ((!iwl_ht_conf->is_ht) || 621 590 (iwl_ht_conf->supported_chan_width != IWL_CHANNEL_WIDTH_40MHZ) || 622 - (iwl_ht_conf->extension_chan_offset == IWL_EXT_CHANNEL_OFFSET_NONE)) 591 + (iwl_ht_conf->extension_chan_offset == IEEE80211_HT_IE_CHA_SEC_NONE)) 623 592 return 0; 624 593 625 594 if (sta_ht_inf) { ··· 653 622 IWL_DEBUG_ASSOC("control diff than current %d %d\n", 654 623 le16_to_cpu(rxon->channel), 655 624 ht_info->control_channel); 656 - rxon->channel = cpu_to_le16(ht_info->control_channel); 657 625 return; 658 626 } 659 627 660 628 /* Note: control channel is opposite of extension channel */ 661 629 switch (ht_info->extension_chan_offset) { 662 - case IWL_EXT_CHANNEL_OFFSET_ABOVE: 630 + case IEEE80211_HT_IE_CHA_SEC_ABOVE: 663 631 rxon->flags &= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); 664 632 break; 665 - case IWL_EXT_CHANNEL_OFFSET_BELOW: 633 + case IEEE80211_HT_IE_CHA_SEC_BELOW: 666 634 rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; 667 635 break; 668 - case IWL_EXT_CHANNEL_OFFSET_NONE: 636 + case IEEE80211_HT_IE_CHA_SEC_NONE: 669 637 default: 670 638 rxon->flags &= ~RXON_FLG_CHANNEL_MODE_MIXED_MSK; 671 639 break; ··· 689 659 return; 690 660 } 691 661 EXPORT_SYMBOL(iwl_set_rxon_ht); 692 - 693 - #else 694 - static inline u8 is_single_rx_stream(struct iwl_priv *priv) 695 - { 696 - return 1; 697 - } 698 - #endif /*CONFIG_IWL4965_HT */ 699 662 700 663 /* 701 664 * Determine how many receiver/antenna chains to use. ··· 814 791 IEEE80211_HW_NOISE_DBM; 815 792 /* Default value; 4 EDCA QOS priorities */ 816 793 hw->queues = 4; 817 - #ifdef CONFIG_IWL4965_HT 818 794 /* Enhanced value; more queues, to support 11n aggregation */ 819 795 hw->ampdu_queues = 12; 820 - #endif /* CONFIG_IWL4965_HT */ 821 796 822 797 hw->conf.beacon_int = 100; 823 798 ··· 874 853 875 854 /* Choose which receivers/antennas to use */ 876 855 iwl_set_rxon_chain(priv); 856 + iwl_init_scan_params(priv); 877 857 878 858 if (priv->cfg->mod_params->enable_qos) 879 859 priv->qos_data.qos_enable = 1; ··· 889 867 priv->rates_mask = IWL_RATES_MASK; 890 868 /* If power management is turned on, default to AC mode */ 891 869 priv->power_mode = IWL_POWER_AC; 892 - priv->user_txpower_limit = IWL_DEFAULT_TX_POWER; 870 + priv->tx_power_user_lmt = IWL_TX_POWER_TARGET_POWER_MAX; 893 871 894 872 ret = iwl_init_channel_map(priv); 895 873 if (ret) { ··· 928 906 } 929 907 EXPORT_SYMBOL(iwl_free_calib_results); 930 908 909 + int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) 910 + { 911 + int ret = 0; 912 + if (tx_power < IWL_TX_POWER_TARGET_POWER_MIN) { 913 + IWL_WARNING("Requested user TXPOWER %d below limit.\n", 914 + priv->tx_power_user_lmt); 915 + return -EINVAL; 916 + } 917 + 918 + if (tx_power > IWL_TX_POWER_TARGET_POWER_MAX) { 919 + IWL_WARNING("Requested user TXPOWER %d above limit.\n", 920 + priv->tx_power_user_lmt); 921 + return -EINVAL; 922 + } 923 + 924 + if (priv->tx_power_user_lmt != tx_power) 925 + force = true; 926 + 927 + priv->tx_power_user_lmt = tx_power; 928 + 929 + if (force && priv->cfg->ops->lib->send_tx_power) 930 + ret = priv->cfg->ops->lib->send_tx_power(priv); 931 + 932 + return ret; 933 + } 934 + EXPORT_SYMBOL(iwl_set_tx_power); 935 + 936 + 931 937 void iwl_uninit_drv(struct iwl_priv *priv) 932 938 { 933 939 iwl_free_calib_results(priv); ··· 964 914 kfree(priv->scan); 965 915 } 966 916 EXPORT_SYMBOL(iwl_uninit_drv); 967 - 968 - /* Low level driver call this function to update iwlcore with 969 - * driver status. 970 - */ 971 - int iwlcore_low_level_notify(struct iwl_priv *priv, 972 - enum iwlcore_card_notify notify) 973 - { 974 - int ret; 975 - switch (notify) { 976 - case IWLCORE_INIT_EVT: 977 - ret = iwl_rfkill_init(priv); 978 - if (ret) 979 - IWL_ERROR("Unable to initialize RFKILL system. " 980 - "Ignoring error: %d\n", ret); 981 - iwl_power_initialize(priv); 982 - break; 983 - case IWLCORE_START_EVT: 984 - iwl_power_update_mode(priv, 1); 985 - break; 986 - case IWLCORE_STOP_EVT: 987 - break; 988 - case IWLCORE_REMOVE_EVT: 989 - iwl_rfkill_unregister(priv); 990 - break; 991 - } 992 - 993 - return 0; 994 - } 995 - EXPORT_SYMBOL(iwlcore_low_level_notify); 996 917 997 918 int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags) 998 919 { ··· 1225 1204 ptr += sizeof(u32); 1226 1205 time = iwl_read_targ_mem(priv, ptr); 1227 1206 ptr += sizeof(u32); 1228 - if (mode == 0) 1229 - IWL_ERROR("0x%08x\t%04u\n", time, ev); /* data, ev */ 1230 - else { 1207 + if (mode == 0) { 1208 + /* data, ev */ 1209 + IWL_ERROR("EVT_LOG:0x%08x:%04u\n", time, ev); 1210 + } else { 1231 1211 data = iwl_read_targ_mem(priv, ptr); 1232 1212 ptr += sizeof(u32); 1233 - IWL_ERROR("%010u\t0x%08x\t%04u\n", time, data, ev); 1213 + IWL_ERROR("EVT_LOGT:%010u:0x%08x:%04u\n", 1214 + time, data, ev); 1234 1215 } 1235 1216 } 1236 1217 } ··· 1295 1272 } 1296 1273 EXPORT_SYMBOL(iwl_dump_nic_event_log); 1297 1274 1275 + void iwl_rf_kill_ct_config(struct iwl_priv *priv) 1276 + { 1277 + struct iwl_ct_kill_config cmd; 1278 + unsigned long flags; 1279 + int ret = 0; 1298 1280 1281 + spin_lock_irqsave(&priv->lock, flags); 1282 + iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, 1283 + CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); 1284 + spin_unlock_irqrestore(&priv->lock, flags); 1285 + 1286 + cmd.critical_temperature_R = 1287 + cpu_to_le32(priv->hw_params.ct_kill_threshold); 1288 + 1289 + ret = iwl_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, 1290 + sizeof(cmd), &cmd); 1291 + if (ret) 1292 + IWL_ERROR("REPLY_CT_KILL_CONFIG_CMD failed\n"); 1293 + else 1294 + IWL_DEBUG_INFO("REPLY_CT_KILL_CONFIG_CMD succeeded, " 1295 + "critical temperature is %d\n", 1296 + cmd.critical_temperature_R); 1297 + } 1298 + EXPORT_SYMBOL(iwl_rf_kill_ct_config); 1299 + 1300 + /* 1301 + * CARD_STATE_CMD 1302 + * 1303 + * Use: Sets the device's internal card state to enable, disable, or halt 1304 + * 1305 + * When in the 'enable' state the card operates as normal. 1306 + * When in the 'disable' state, the card enters into a low power mode. 1307 + * When in the 'halt' state, the card is shut down and must be fully 1308 + * restarted to come back on. 1309 + */ 1310 + static int iwl_send_card_state(struct iwl_priv *priv, u32 flags, u8 meta_flag) 1311 + { 1312 + struct iwl_host_cmd cmd = { 1313 + .id = REPLY_CARD_STATE_CMD, 1314 + .len = sizeof(u32), 1315 + .data = &flags, 1316 + .meta.flags = meta_flag, 1317 + }; 1318 + 1319 + return iwl_send_cmd(priv, &cmd); 1320 + } 1321 + 1322 + void iwl_radio_kill_sw_disable_radio(struct iwl_priv *priv) 1323 + { 1324 + unsigned long flags; 1325 + 1326 + if (test_bit(STATUS_RF_KILL_SW, &priv->status)) 1327 + return; 1328 + 1329 + IWL_DEBUG_RF_KILL("Manual SW RF KILL set to: RADIO OFF\n"); 1330 + 1331 + iwl_scan_cancel(priv); 1332 + /* FIXME: This is a workaround for AP */ 1333 + if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { 1334 + spin_lock_irqsave(&priv->lock, flags); 1335 + iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, 1336 + CSR_UCODE_SW_BIT_RFKILL); 1337 + spin_unlock_irqrestore(&priv->lock, flags); 1338 + /* call the host command only if no hw rf-kill set */ 1339 + if (!test_bit(STATUS_RF_KILL_HW, &priv->status) && 1340 + iwl_is_ready(priv)) 1341 + iwl_send_card_state(priv, 1342 + CARD_STATE_CMD_DISABLE, 0); 1343 + set_bit(STATUS_RF_KILL_SW, &priv->status); 1344 + /* make sure mac80211 stop sending Tx frame */ 1345 + if (priv->mac80211_registered) 1346 + ieee80211_stop_queues(priv->hw); 1347 + } 1348 + } 1349 + EXPORT_SYMBOL(iwl_radio_kill_sw_disable_radio); 1350 + 1351 + int iwl_radio_kill_sw_enable_radio(struct iwl_priv *priv) 1352 + { 1353 + unsigned long flags; 1354 + 1355 + if (!test_bit(STATUS_RF_KILL_SW, &priv->status)) 1356 + return 0; 1357 + 1358 + IWL_DEBUG_RF_KILL("Manual SW RF KILL set to: RADIO ON\n"); 1359 + 1360 + spin_lock_irqsave(&priv->lock, flags); 1361 + iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); 1362 + 1363 + clear_bit(STATUS_RF_KILL_SW, &priv->status); 1364 + spin_unlock_irqrestore(&priv->lock, flags); 1365 + 1366 + /* wake up ucode */ 1367 + msleep(10); 1368 + 1369 + spin_lock_irqsave(&priv->lock, flags); 1370 + iwl_read32(priv, CSR_UCODE_DRV_GP1); 1371 + if (!iwl_grab_nic_access(priv)) 1372 + iwl_release_nic_access(priv); 1373 + spin_unlock_irqrestore(&priv->lock, flags); 1374 + 1375 + if (test_bit(STATUS_RF_KILL_HW, &priv->status)) { 1376 + IWL_DEBUG_RF_KILL("Can not turn radio back on - " 1377 + "disabled by HW switch\n"); 1378 + return 0; 1379 + } 1380 + 1381 + if (priv->is_open) 1382 + queue_work(priv->workqueue, &priv->restart); 1383 + return 1; 1384 + } 1385 + EXPORT_SYMBOL(iwl_radio_kill_sw_enable_radio);
+52 -19
drivers/net/wireless/iwlwifi/iwl-core.h
··· 88 88 struct iwl_hcmd_utils_ops { 89 89 u16 (*get_hcmd_size)(u8 cmd_id, u16 len); 90 90 u16 (*build_addsta_hcmd)(const struct iwl_addsta_cmd *cmd, u8 *data); 91 - #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB 92 91 void (*gain_computation)(struct iwl_priv *priv, 93 92 u32 *average_noise, 94 93 u16 min_average_noise_antennat_i, 95 94 u32 min_average_noise); 96 95 void (*chain_noise_reset)(struct iwl_priv *priv); 97 - #endif 98 96 }; 99 97 100 98 struct iwl_lib_ops { ··· 109 111 void (*txq_inval_byte_cnt_tbl)(struct iwl_priv *priv, 110 112 struct iwl_tx_queue *txq); 111 113 void (*txq_set_sched)(struct iwl_priv *priv, u32 mask); 112 - #ifdef CONFIG_IWL4965_HT 113 114 /* aggregations */ 114 115 int (*txq_agg_enable)(struct iwl_priv *priv, int txq_id, int tx_fifo, 115 116 int sta_id, int tid, u16 ssn_idx); 116 117 int (*txq_agg_disable)(struct iwl_priv *priv, u16 txq_id, u16 ssn_idx, 117 118 u8 tx_fifo); 118 - #endif /* CONFIG_IWL4965_HT */ 119 119 /* setup Rx handler */ 120 120 void (*rx_handler_setup)(struct iwl_priv *priv); 121 + /* setup deferred work */ 122 + void (*setup_deferred_work)(struct iwl_priv *priv); 123 + /* cancel deferred work */ 124 + void (*cancel_deferred_work)(struct iwl_priv *priv); 121 125 /* alive notification after init uCode load */ 122 126 void (*init_alive_start)(struct iwl_priv *priv); 123 127 /* alive notification */ ··· 128 128 int (*is_valid_rtc_data_addr)(u32 addr); 129 129 /* 1st ucode load */ 130 130 int (*load_ucode)(struct iwl_priv *priv); 131 - /* rfkill */ 132 - void (*radio_kill_sw)(struct iwl_priv *priv, int disable_radio); 133 131 /* power management */ 134 132 struct { 135 133 int (*init)(struct iwl_priv *priv); ··· 138 140 } apm_ops; 139 141 /* power */ 140 142 int (*set_power)(struct iwl_priv *priv, void *cmd); 143 + int (*send_tx_power) (struct iwl_priv *priv); 141 144 void (*update_chain_flags)(struct iwl_priv *priv); 142 145 /* eeprom operations (as defined in iwl-eeprom.h) */ 143 146 struct iwl_eeprom_ops eeprom_ops; ··· 232 233 int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *tfd, 233 234 dma_addr_t addr, u16 len); 234 235 int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq); 235 - #ifdef CONFIG_IWL4965_HT 236 236 int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn); 237 237 int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid); 238 238 int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id); 239 - #endif 239 + 240 + /***************************************************** 241 + * TX power 242 + ****************************************************/ 243 + int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force); 244 + 245 + /***************************************************** 246 + * RF -Kill - here and not in iwl-rfkill.h to be available when 247 + * RF-kill subsystem is not compiled. 248 + ****************************************************/ 249 + void iwl_radio_kill_sw_disable_radio(struct iwl_priv *priv); 250 + int iwl_radio_kill_sw_enable_radio(struct iwl_priv *priv); 251 + 252 + /******************************************************************************* 253 + * Rate 254 + ******************************************************************************/ 255 + 256 + void iwl_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, 257 + struct ieee80211_tx_info *info); 258 + int iwl_hwrate_to_plcp_idx(u32 rate_n_flags); 259 + 260 + static inline u8 iwl_hw_get_rate(__le32 rate_n_flags) 261 + { 262 + return le32_to_cpu(rate_n_flags) & 0xFF; 263 + } 264 + static inline u32 iwl_hw_get_rate_n_flags(__le32 rate_n_flags) 265 + { 266 + return le32_to_cpu(rate_n_flags) & 0x1FFFF; 267 + } 268 + static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags) 269 + { 270 + return cpu_to_le32(flags|(u32)rate); 271 + } 272 + 273 + /******************************************************************************* 274 + * Scanning 275 + ******************************************************************************/ 276 + void iwl_init_scan_params(struct iwl_priv *priv); 277 + int iwl_scan_cancel(struct iwl_priv *priv); 278 + int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); 279 + const char *iwl_escape_essid(const char *essid, u8 essid_len); 280 + int iwl_scan_initiate(struct iwl_priv *priv); 281 + void iwl_setup_rx_scan_handlers(struct iwl_priv *priv); 282 + void iwl_setup_scan_deferred_work(struct iwl_priv *priv); 240 283 241 284 /***************************************************** 242 285 * S e n d i n g H o s t C o m m a n d s * ··· 327 286 #define STATUS_POWER_PMI 16 328 287 #define STATUS_FW_ERROR 17 329 288 #define STATUS_CONF_PENDING 18 289 + #define STATUS_MODE_PENDING 19 330 290 331 291 332 292 static inline int iwl_is_ready(struct iwl_priv *priv) ··· 364 322 return iwl_is_ready(priv); 365 323 } 366 324 367 - 368 - enum iwlcore_card_notify { 369 - IWLCORE_INIT_EVT = 0, 370 - IWLCORE_START_EVT = 1, 371 - IWLCORE_STOP_EVT = 2, 372 - IWLCORE_REMOVE_EVT = 3, 373 - }; 374 - 375 - int iwlcore_low_level_notify(struct iwl_priv *priv, 376 - enum iwlcore_card_notify notify); 325 + extern void iwl_rf_kill_ct_config(struct iwl_priv *priv); 377 326 extern int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags); 378 327 extern int iwl_verify_ucode(struct iwl_priv *priv); 379 - int iwl_send_lq_cmd(struct iwl_priv *priv, 328 + extern int iwl_send_lq_cmd(struct iwl_priv *priv, 380 329 struct iwl_link_quality_cmd *lq, u8 flags); 381 330 382 331 static inline int iwl_send_rxon_assoc(struct iwl_priv *priv)
+1 -2
drivers/net/wireless/iwlwifi/iwl-debug.h
··· 55 55 struct dentry *file_log_event; 56 56 } dbgfs_data_files; 57 57 struct dir_rf_files { 58 - #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB 59 58 struct dentry *file_disable_sensitivity; 60 59 struct dentry *file_disable_chain_noise; 61 - #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ 60 + struct dentry *file_disable_tx_power; 62 61 } dbgfs_rf_files; 63 62 u32 sram_offset; 64 63 u32 sram_len;
+2 -8
drivers/net/wireless/iwlwifi/iwl-debugfs.c
··· 255 255 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n"); 256 256 pos += scnprintf(buf + pos, bufsz - pos, 257 257 "seq_num\t\ttxq_id"); 258 - #ifdef CONFIG_IWL4965_HT 259 258 pos += scnprintf(buf + pos, bufsz - pos, 260 259 "\tframe_count\twait_for_ba\t"); 261 260 pos += scnprintf(buf + pos, bufsz - pos, 262 261 "start_idx\tbitmap0\t"); 263 262 pos += scnprintf(buf + pos, bufsz - pos, 264 263 "bitmap1\trate_n_flags"); 265 - #endif 266 264 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 267 265 268 266 for (j = 0; j < MAX_TID_COUNT; j++) { 269 267 pos += scnprintf(buf + pos, bufsz - pos, 270 268 "[%d]:\t\t%u", j, 271 269 station->tid[j].seq_number); 272 - #ifdef CONFIG_IWL4965_HT 273 270 pos += scnprintf(buf + pos, bufsz - pos, 274 271 "\t%u\t\t%u\t\t%u\t\t", 275 272 station->tid[j].agg.txq_id, ··· 277 280 station->tid[j].agg.start_idx, 278 281 (unsigned long long)station->tid[j].agg.bitmap, 279 282 station->tid[j].agg.rate_n_flags); 280 - #endif 281 283 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 282 284 } 283 285 pos += scnprintf(buf + pos, bufsz - pos, "\n"); ··· 385 389 DEBUGFS_ADD_FILE(stations, data); 386 390 DEBUGFS_ADD_FILE(rx_statistics, data); 387 391 DEBUGFS_ADD_FILE(tx_statistics, data); 388 - #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB 389 392 DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); 390 393 DEBUGFS_ADD_BOOL(disable_chain_noise, rf, 391 394 &priv->disable_chain_noise_cal); 392 - #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ 395 + DEBUGFS_ADD_BOOL(disable_tx_power, rf, &priv->disable_tx_power_cal); 393 396 return 0; 394 397 395 398 err: ··· 414 419 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event); 415 420 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations); 416 421 DEBUGFS_REMOVE(priv->dbgfs->dir_data); 417 - #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB 418 422 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity); 419 423 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise); 420 - #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ 424 + DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power); 421 425 DEBUGFS_REMOVE(priv->dbgfs->dir_rf); 422 426 DEBUGFS_REMOVE(priv->dbgfs->dir_drv); 423 427 kfree(priv->dbgfs);
+13 -148
drivers/net/wireless/iwlwifi/iwl-dev.h
··· 29 29 * Please use iwl-4965-hw.h for hardware-related definitions. 30 30 */ 31 31 32 - #ifndef __iwl_4965_h__ 33 - #define __iwl_4965_h__ 32 + #ifndef __iwl_dev_h__ 33 + #define __iwl_dev_h__ 34 34 35 35 #include <linux/pci.h> /* for struct pci_device_id */ 36 36 #include <linux/kernel.h> ··· 157 157 s64 last_radar_time; 158 158 }; 159 159 160 - /* current Tx power values to use, one for each rate for each channel. 161 - * requested power is limited by: 162 - * -- regulatory EEPROM limits for this channel 163 - * -- hardware capabilities (clip-powers) 164 - * -- spectrum management 165 - * -- user preference (e.g. iwconfig) 166 - * when requested power is set, base power index must also be set. */ 167 - struct iwl4965_channel_power_info { 168 - struct iwl4965_tx_power tpc; /* actual radio and DSP gain settings */ 169 - s8 power_table_index; /* actual (compenst'd) index into gain table */ 170 - s8 base_power_index; /* gain index for power at factory temp. */ 171 - s8 requested_power; /* power (dBm) requested for this chnl/rate */ 172 - }; 173 - 174 - /* current scan Tx power values to use, one for each scan rate for each 175 - * channel. */ 176 - struct iwl4965_scan_power_info { 177 - struct iwl4965_tx_power tpc; /* actual radio and DSP gain settings */ 178 - s8 power_table_index; /* actual (compenst'd) index into gain table */ 179 - s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */ 180 - }; 181 - 182 - /* For fat_extension_channel */ 183 - enum { 184 - HT_IE_EXT_CHANNEL_NONE = 0, 185 - HT_IE_EXT_CHANNEL_ABOVE, 186 - HT_IE_EXT_CHANNEL_INVALID, 187 - HT_IE_EXT_CHANNEL_BELOW, 188 - HT_IE_EXT_CHANNEL_MAX 189 - }; 190 - 191 160 /* 192 161 * One for each channel, holds all channel setup data 193 162 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant 194 163 * with one another! 195 164 */ 196 - #define IWL4965_MAX_RATE (33) 197 - 198 165 struct iwl_channel_info { 199 166 struct iwl4965_channel_tgd_info tgd; 200 167 struct iwl4965_channel_tgh_info tgh; ··· 180 213 u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */ 181 214 enum ieee80211_band band; 182 215 183 - /* Radio/DSP gain settings for each "normal" data Tx rate. 184 - * These include, in addition to RF and DSP gain, a few fields for 185 - * remembering/modifying gain settings (indexes). */ 186 - struct iwl4965_channel_power_info power_info[IWL4965_MAX_RATE]; 187 - 188 216 /* FAT channel info */ 189 217 s8 fat_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ 190 218 s8 fat_curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */ ··· 187 225 s8 fat_scan_power; /* (dBm) eeprom, direct scans, any rate */ 188 226 u8 fat_flags; /* flags copied from EEPROM */ 189 227 u8 fat_extension_channel; /* HT_IE_EXT_CHANNEL_* */ 190 - 191 - /* Radio/DSP gain settings for each scan rate, for directed scans. */ 192 - struct iwl4965_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES]; 193 228 }; 194 229 195 230 struct iwl4965_clip_group { ··· 360 401 #define IWL_INVALID_RATE 0xFF 361 402 #define IWL_INVALID_VALUE -1 362 403 363 - #ifdef CONFIG_IWL4965_HT 364 404 /** 365 405 * struct iwl_ht_agg -- aggregation status while waiting for block-ack 366 406 * @txq_id: Tx queue used for Tx attempt ··· 388 430 u8 state; 389 431 }; 390 432 391 - #endif /* CONFIG_IWL4965_HT */ 392 433 393 434 struct iwl_tid_data { 394 435 u16 seq_number; 395 436 u16 tfds_in_queue; 396 - #ifdef CONFIG_IWL4965_HT 397 437 struct iwl_ht_agg agg; 398 - #endif /* CONFIG_IWL4965_HT */ 399 438 }; 400 439 401 440 struct iwl_hw_key { ··· 480 525 }; 481 526 482 527 /* uCode file layout */ 483 - struct iwl4965_ucode { 528 + struct iwl_ucode { 484 529 __le32 ver; /* major/minor/subminor */ 485 530 __le32 inst_size; /* bytes of runtime instructions */ 486 531 __le32 data_size; /* bytes of runtime data */ ··· 542 587 * @max_xxx_size: for ucode uses 543 588 * @ct_kill_threshold: temperature threshold 544 589 * @struct iwl_sensitivity_ranges: range of sensitivity values 590 + * @first_ampdu_q: first HW queue available for ampdu 545 591 */ 546 592 struct iwl_hw_params { 547 593 u16 max_txq_num; ··· 562 606 u32 max_data_size; 563 607 u32 max_bsm_size; 564 608 u32 ct_kill_threshold; /* value in hw-dependent units */ 565 - #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB 566 609 const struct iwl_sensitivity_ranges *sens; 567 - #endif 610 + u8 first_ampdu_q; 568 611 }; 569 612 570 613 #define HT_SHORT_GI_20MHZ (1 << 0) ··· 593 638 u8 flags, struct ieee80211_ht_info *ht_info); 594 639 extern int iwl4965_is_network_packet(struct iwl_priv *priv, 595 640 struct ieee80211_hdr *header); 596 - extern int iwl4965_power_init_handle(struct iwl_priv *priv); 597 - extern void iwl4965_handle_data_packet_monitor(struct iwl_priv *priv, 598 - struct iwl_rx_mem_buffer *rxb, 599 - void *data, short len, 600 - struct ieee80211_rx_status *stats, 601 - u16 phy_flags); 602 641 extern int iwl4965_is_duplicate_packet(struct iwl_priv *priv, 603 642 struct ieee80211_hdr *header); 604 - extern int iwl4965_calc_db_from_ratio(int sig_ratio); 605 643 extern int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm); 606 644 extern unsigned int iwl4965_fill_beacon_frame(struct iwl_priv *priv, 607 645 struct ieee80211_hdr *hdr, ··· 602 654 extern void iwl4965_update_chain_flags(struct iwl_priv *priv); 603 655 int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src); 604 656 605 - int iwl4965_init_geos(struct iwl_priv *priv); 606 - void iwl4965_free_geos(struct iwl_priv *priv); 607 - 608 657 extern const u8 iwl_bcast_addr[ETH_ALEN]; 609 - int iwl4965_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); 610 - 611 - /* 612 - * Currently used by iwl-3945-rs... look at restructuring so that it doesn't 613 - * call this... todo... fix that. 614 - */ 615 - extern u8 iwl4965_sync_station(struct iwl_priv *priv, int sta_id, 616 - u16 tx_rate, u8 flags); 617 658 618 659 /****************************************************************************** 619 660 * ··· 620 683 * iwl4965_mac_ <-- mac80211 callback 621 684 * 622 685 ****************************************************************************/ 623 - extern void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv); 624 - extern void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv); 625 - extern int iwl4965_hw_set_hw_params(struct iwl_priv *priv); 626 686 extern int iwl_rxq_stop(struct iwl_priv *priv); 627 687 extern void iwl_txq_ctx_stop(struct iwl_priv *priv); 628 - extern int iwl4965_hw_get_temperature(struct iwl_priv *priv); 629 688 extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, 630 689 struct iwl_frame *frame, u8 rate); 631 - extern void iwl4965_hw_build_tx_cmd_rate(struct iwl_priv *priv, 632 - struct iwl_cmd *cmd, 633 - struct ieee80211_tx_info *info, 634 - struct ieee80211_hdr *hdr, 635 - int sta_id, int tx_id); 636 - extern int iwl4965_hw_reg_send_txpower(struct iwl_priv *priv); 637 - extern int iwl4965_hw_reg_set_txpower(struct iwl_priv *priv, s8 power); 638 690 extern void iwl4965_hw_rx_statistics(struct iwl_priv *priv, 639 691 struct iwl_rx_mem_buffer *rxb); 640 692 extern void iwl4965_disable_events(struct iwl_priv *priv); 641 - extern int iwl4965_get_temperature(const struct iwl_priv *priv); 642 693 extern void iwl4965_rx_reply_rx(struct iwl_priv *priv, 643 694 struct iwl_rx_mem_buffer *rxb); 644 - 645 - /** 646 - * iwl_find_station - Find station id for a given BSSID 647 - * @bssid: MAC address of station ID to find 648 - * 649 - * NOTE: This should not be hardware specific but the code has 650 - * not yet been merged into a single common layer for managing the 651 - * station tables. 652 - */ 653 - extern u8 iwl_find_station(struct iwl_priv *priv, const u8 *bssid); 654 695 655 696 extern int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel); 656 697 extern int iwl_queue_space(const struct iwl_queue *q); ··· 653 738 654 739 struct iwl_priv; 655 740 656 - extern void iwl4965_radio_kill_sw(struct iwl_priv *priv, int disable_radio); 657 741 /* 658 742 * Forward declare iwl-4965.c functions for iwl-base.c 659 743 */ 660 - extern int iwl4965_tx_queue_update_wr_ptr(struct iwl_priv *priv, 661 - struct iwl_tx_queue *txq, 662 - u16 byte_cnt); 663 - extern int iwl4965_alive_notify(struct iwl_priv *priv); 664 - extern void iwl4965_update_rate_scaling(struct iwl_priv *priv, u8 mode); 665 744 extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv); 666 - extern void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, 667 - u32 rate_n_flags, 668 - struct ieee80211_tx_info *info); 669 745 670 - #ifdef CONFIG_IWL4965_HT 671 - extern void iwl4965_init_ht_hw_capab(const struct iwl_priv *priv, 672 - struct ieee80211_ht_info *ht_info, 673 - enum ieee80211_band band); 674 - void iwl4965_set_rxon_ht(struct iwl_priv *priv, 675 - struct iwl_ht_info *ht_info); 676 746 int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, 677 747 enum ieee80211_ampdu_mlme_action action, 678 748 const u8 *addr, u16 tid, u16 *ssn); 679 749 int iwl4965_check_empty_hw_queue(struct iwl_priv *priv, int sta_id, 680 750 u8 tid, int txq_id); 681 - #else 682 - static inline void iwl4965_init_ht_hw_capab(const struct iwl_priv *priv, 683 - struct ieee80211_ht_info *ht_info, 684 - enum ieee80211_band band) {} 685 751 686 - #endif /*CONFIG_IWL4965_HT */ 687 752 /* Structures, enum, and defines specific to the 4965 */ 688 753 689 754 #define IWL_KW_SIZE 0x1000 /*4k */ ··· 686 791 #define IWL_OPERATION_MODE_HT_ONLY 1 687 792 #define IWL_OPERATION_MODE_MIXED 2 688 793 #define IWL_OPERATION_MODE_20MHZ 3 689 - 690 - #define IWL_EXT_CHANNEL_OFFSET_NONE 0 691 - #define IWL_EXT_CHANNEL_OFFSET_ABOVE 1 692 - #define IWL_EXT_CHANNEL_OFFSET_RESERVE1 2 693 - #define IWL_EXT_CHANNEL_OFFSET_BELOW 3 694 794 695 795 #define IWL_TX_CRC_SIZE 4 696 796 #define IWL_TX_DELIMITER_SIZE 4 ··· 782 892 UCODE_RT 783 893 }; 784 894 785 - #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB 786 895 /* Sensitivity calib data */ 787 896 struct iwl_sensitivity_data { 788 897 u32 auto_corr_ofdm; ··· 823 934 u8 delta_gain_code[NUM_RX_CHAINS]; 824 935 u8 radio_write; 825 936 }; 826 - #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ 827 937 828 938 #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ 829 939 #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ ··· 894 1006 int one_direct_scan; 895 1007 u8 direct_ssid_len; 896 1008 u8 direct_ssid[IW_ESSID_MAX_SIZE]; 897 - struct iwl4965_scan_cmd *scan; 1009 + struct iwl_scan_cmd *scan; 1010 + u32 scan_tx_ant[IEEE80211_NUM_BANDS]; 898 1011 899 1012 /* spinlock */ 900 1013 spinlock_t lock; /* protect general shared data */ ··· 956 1067 u8 assoc_station_added; 957 1068 u8 use_ant_b_for_management_frame; /* Tx antenna selection */ 958 1069 u8 start_calib; 959 - #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB 960 1070 struct iwl_sensitivity_data sensitivity_data; 961 1071 struct iwl_chain_noise_data chain_noise_data; 962 1072 __le16 sensitivity_tbl[HD_TABLE_SIZE]; 963 - #endif /*CONFIG_IWLWIFI_RUN_TIME_CALIB*/ 964 1073 965 - #ifdef CONFIG_IWL4965_HT 966 1074 struct iwl_ht_info current_ht_config; 967 - #endif 968 1075 u8 last_phy_res[100]; 969 1076 970 1077 /* Rate scaling data */ ··· 1082 1197 1083 1198 struct delayed_work init_alive_start; 1084 1199 struct delayed_work alive_start; 1085 - struct delayed_work activity_timer; 1086 - struct delayed_work thermal_periodic; 1087 - struct delayed_work gather_stats; 1088 1200 struct delayed_work scan_check; 1089 1201 struct delayed_work post_associate; 1090 - 1091 - #define IWL_DEFAULT_TX_POWER 0x0F 1092 - s8 user_txpower_limit; 1093 - s8 max_channel_txpower_limit; 1202 + /* TX Power */ 1203 + s8 tx_power_user_lmt; 1204 + s8 tx_power_channel_lmt; 1094 1205 1095 1206 #ifdef CONFIG_PM 1096 1207 u32 pm_state[16]; ··· 1104 1223 #endif /* CONFIG_IWLWIFI_DEBUG */ 1105 1224 1106 1225 struct work_struct txpower_work; 1107 - #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB 1108 1226 u32 disable_sens_cal; 1109 1227 u32 disable_chain_noise_cal; 1110 - #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ 1111 - #ifdef CONFIG_IWL4965_RUN_TIME_CALIB 1112 - struct work_struct sensitivity_work; 1113 - #endif /* CONFIG_IWL4965_RUN_TIME_CALIB */ 1228 + u32 disable_tx_power_cal; 1229 + struct work_struct run_time_calib_work; 1114 1230 struct timer_list statistics_periodic; 1115 1231 }; /*iwl_priv */ 1116 1232 ··· 1128 1250 #endif 1129 1251 1130 1252 1131 - #ifdef CONFIG_IWL4965_HT 1132 - static inline int iwl_get_ra_sta_id(struct iwl_priv *priv, 1133 - struct ieee80211_hdr *hdr) 1134 - { 1135 - if (priv->iw_mode == IEEE80211_IF_TYPE_STA) { 1136 - return IWL_AP_ID; 1137 - } else { 1138 - u8 *da = ieee80211_get_DA(hdr); 1139 - return iwl_find_station(priv, da); 1140 - } 1141 - } 1142 - 1143 1253 static inline struct ieee80211_hdr *iwl_tx_queue_get_hdr(struct iwl_priv *priv, 1144 1254 int txq_id, int idx) 1145 1255 { ··· 1136 1270 txb[idx].skb[0]->data; 1137 1271 return NULL; 1138 1272 } 1139 - #endif 1140 1273 1141 1274 1142 1275 static inline int iwl_is_associated(struct iwl_priv *priv) ··· 1197 1332 1198 1333 /* Requires full declaration of iwl_priv before including */ 1199 1334 1200 - #endif /* __iwl4965_4965_h__ */ 1335 + #endif /* __iwl_dev_h__ */
+19 -12
drivers/net/wireless/iwlwifi/iwl-eeprom.c
··· 382 382 if (!is_channel_valid(ch_info)) 383 383 return -1; 384 384 385 - IWL_DEBUG_INFO("FAT Ch. %d [%sGHz] %s%s%s%s%s(0x%02x" 386 - " %ddBm): Ad-Hoc %ssupported\n", 385 + IWL_DEBUG_INFO("FAT Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" 386 + " Ad-Hoc %ssupported\n", 387 387 ch_info->channel, 388 388 is_channel_a_band(ch_info) ? 389 389 "5.2" : "2.4", ··· 470 470 /* Copy the run-time flags so they are there even on 471 471 * invalid channels */ 472 472 ch_info->flags = eeprom_ch_info[ch].flags; 473 + /* First write that fat is not enabled, and then enable 474 + * one by one */ 475 + ch_info->fat_extension_channel = 476 + (IEEE80211_CHAN_NO_FAT_ABOVE | 477 + IEEE80211_CHAN_NO_FAT_BELOW); 473 478 474 479 if (!(is_channel_valid(ch_info))) { 475 480 IWL_DEBUG_INFO("Ch. %d Flags %x [%sGHz] - " ··· 493 488 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; 494 489 ch_info->min_power = 0; 495 490 496 - IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x" 497 - " %ddBm): Ad-Hoc %ssupported\n", 491 + IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x %ddBm):" 492 + " Ad-Hoc %ssupported\n", 498 493 ch_info->channel, 499 494 is_channel_a_band(ch_info) ? 500 495 "5.2" : "2.4", ··· 515 510 /* Set the user_txpower_limit to the highest power 516 511 * supported by any channel */ 517 512 if (eeprom_ch_info[ch].max_power_avg > 518 - priv->user_txpower_limit) 519 - priv->user_txpower_limit = 513 + priv->tx_power_user_lmt) 514 + priv->tx_power_user_lmt = 520 515 eeprom_ch_info[ch].max_power_avg; 521 516 522 517 ch_info++; ··· 539 534 for (ch = 0; ch < eeprom_ch_count; ch++) { 540 535 541 536 if ((band == 6) && 542 - ((eeprom_ch_index[ch] == 5) || 543 - (eeprom_ch_index[ch] == 6) || 544 - (eeprom_ch_index[ch] == 7))) 545 - fat_extension_chan = HT_IE_EXT_CHANNEL_MAX; 537 + ((eeprom_ch_index[ch] == 5) || 538 + (eeprom_ch_index[ch] == 6) || 539 + (eeprom_ch_index[ch] == 7))) 540 + /* both are allowed: above and below */ 541 + fat_extension_chan = 0; 546 542 else 547 - fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE; 543 + fat_extension_chan = 544 + IEEE80211_CHAN_NO_FAT_BELOW; 548 545 549 546 /* Set up driver's info for lower half */ 550 547 iwl_set_fat_chan_info(priv, ieeeband, ··· 558 551 iwl_set_fat_chan_info(priv, ieeeband, 559 552 (eeprom_ch_index[ch] + 4), 560 553 &(eeprom_ch_info[ch]), 561 - HT_IE_EXT_CHANNEL_BELOW); 554 + IEEE80211_CHAN_NO_FAT_ABOVE); 562 555 } 563 556 } 564 557
-111
drivers/net/wireless/iwlwifi/iwl-helpers.h
··· 139 139 #define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) 140 140 141 141 142 - #define IEEE80211_CHAN_W_RADAR_DETECT 0x00000010 143 - 144 142 static inline struct ieee80211_conf *ieee80211_get_hw_conf( 145 143 struct ieee80211_hw *hw) 146 144 { 147 145 return &hw->conf; 148 - } 149 - 150 - #define QOS_CONTROL_LEN 2 151 - 152 - 153 - static inline int ieee80211_is_management(u16 fc) 154 - { 155 - return (fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT; 156 - } 157 - 158 - static inline int ieee80211_is_control(u16 fc) 159 - { 160 - return (fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL; 161 - } 162 - 163 - static inline int ieee80211_is_data(u16 fc) 164 - { 165 - return (fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA; 166 - } 167 - 168 - static inline int ieee80211_is_back_request(u16 fc) 169 - { 170 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && 171 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BACK_REQ); 172 - } 173 - 174 - static inline int ieee80211_is_probe_response(u16 fc) 175 - { 176 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 177 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP); 178 - } 179 - 180 - static inline int ieee80211_is_probe_request(u16 fc) 181 - { 182 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 183 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_REQ); 184 - } 185 - 186 - static inline int ieee80211_is_beacon(u16 fc) 187 - { 188 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 189 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON); 190 - } 191 - 192 - static inline int ieee80211_is_atim(u16 fc) 193 - { 194 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 195 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ATIM); 196 - } 197 - 198 - static inline int ieee80211_is_assoc_request(u16 fc) 199 - { 200 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 201 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ); 202 - } 203 - 204 - static inline int ieee80211_is_assoc_response(u16 fc) 205 - { 206 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 207 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_RESP); 208 - } 209 - 210 - static inline int ieee80211_is_auth(u16 fc) 211 - { 212 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 213 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ); 214 - } 215 - 216 - static inline int ieee80211_is_deauth(u16 fc) 217 - { 218 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 219 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ); 220 - } 221 - 222 - static inline int ieee80211_is_disassoc(u16 fc) 223 - { 224 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 225 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ); 226 - } 227 - 228 - static inline int ieee80211_is_reassoc_request(u16 fc) 229 - { 230 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 231 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ); 232 - } 233 - 234 - static inline int ieee80211_is_reassoc_response(u16 fc) 235 - { 236 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && 237 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_RESP); 238 - } 239 - 240 - static inline int ieee80211_is_qos_data(u16 fc) 241 - { 242 - return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && 243 - ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_QOS_DATA); 244 - } 245 - /** 246 - * ieee80211_get_qos_ctrl - get pointer to the QoS control field 247 - * 248 - * This function returns the pointer to 802.11 header QoS field (2 bytes) 249 - * This function doesn't check whether hdr is a QoS hdr, use with care 250 - * @hdr: struct ieee80211_hdr *hdr 251 - * @hdr_len: header length 252 - */ 253 - 254 - static inline u8 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr, int hdr_len) 255 - { 256 - return ((u8 *) hdr + hdr_len - QOS_CONTROL_LEN); 257 146 } 258 147 259 148 static inline int iwl_check_bits(unsigned long field, unsigned long mask)
+2 -2
drivers/net/wireless/iwlwifi/iwl-rfkill.c
··· 55 55 56 56 switch (state) { 57 57 case RFKILL_STATE_ON: 58 - priv->cfg->ops->lib->radio_kill_sw(priv, 0); 58 + iwl_radio_kill_sw_enable_radio(priv); 59 59 /* if HW rf-kill is set dont allow ON state */ 60 60 if (iwl_is_rfkill(priv)) 61 61 err = -EBUSY; 62 62 break; 63 63 case RFKILL_STATE_OFF: 64 - priv->cfg->ops->lib->radio_kill_sw(priv, 1); 64 + iwl_radio_kill_sw_disable_radio(priv); 65 65 if (!iwl_is_rfkill(priv)) 66 66 err = -EBUSY; 67 67 break;
-1
drivers/net/wireless/iwlwifi/iwl-rfkill.h
··· 33 33 #include <linux/rfkill.h> 34 34 #include <linux/input.h> 35 35 36 - 37 36 #ifdef CONFIG_IWLWIFI_RFKILL 38 37 struct iwl_rfkill_mngr { 39 38 struct rfkill *rfkill;
-2
drivers/net/wireless/iwlwifi/iwl-rx.c
··· 451 451 struct iwl_rx_mem_buffer *rxb) 452 452 453 453 { 454 - #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB 455 454 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 456 455 struct iwl4965_missed_beacon_notif *missed_beacon; 457 456 ··· 464 465 if (!test_bit(STATUS_SCANNING, &priv->status)) 465 466 iwl_init_sensitivity(priv); 466 467 } 467 - #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ 468 468 } 469 469 EXPORT_SYMBOL(iwl_rx_missed_beacon_notif);
+921
drivers/net/wireless/iwlwifi/iwl-scan.c
··· 1 + /****************************************************************************** 2 + * 3 + * GPL LICENSE SUMMARY 4 + * 5 + * Copyright(c) 2008 Intel Corporation. All rights reserved. 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of version 2 of the GNU General Public License as 9 + * published by the Free Software Foundation. 10 + * 11 + * This program is distributed in the hope that it will be useful, but 12 + * WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 + * General Public License for more details. 15 + * 16 + * You should have received a copy of the GNU General Public License 17 + * along with this program; if not, write to the Free Software 18 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, 19 + * USA 20 + * 21 + * The full GNU General Public License is included in this distribution 22 + * in the file called LICENSE.GPL. 23 + * 24 + * Contact Information: 25 + * Tomas Winkler <tomas.winkler@intel.com> 26 + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 27 + *****************************************************************************/ 28 + #include <net/mac80211.h> 29 + #include <linux/etherdevice.h> 30 + 31 + #include "iwl-eeprom.h" 32 + #include "iwl-dev.h" 33 + #include "iwl-core.h" 34 + #include "iwl-sta.h" 35 + #include "iwl-io.h" 36 + #include "iwl-helpers.h" 37 + 38 + /* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after 39 + * sending probe req. This should be set long enough to hear probe responses 40 + * from more than one AP. */ 41 + #define IWL_ACTIVE_DWELL_TIME_24 (20) /* all times in msec */ 42 + #define IWL_ACTIVE_DWELL_TIME_52 (10) 43 + 44 + /* For faster active scanning, scan will move to the next channel if fewer than 45 + * PLCP_QUIET_THRESH packets are heard on this channel within 46 + * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell 47 + * time if it's a quiet channel (nothing responded to our probe, and there's 48 + * no other traffic). 49 + * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ 50 + #define IWL_PLCP_QUIET_THRESH __constant_cpu_to_le16(1) /* packets */ 51 + #define IWL_ACTIVE_QUIET_TIME __constant_cpu_to_le16(5) /* msec */ 52 + 53 + /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. 54 + * Must be set longer than active dwell time. 55 + * For the most reliable scan, set > AP beacon interval (typically 100msec). */ 56 + #define IWL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ 57 + #define IWL_PASSIVE_DWELL_TIME_52 (10) 58 + #define IWL_PASSIVE_DWELL_BASE (100) 59 + #define IWL_CHANNEL_TUNE_TIME 5 60 + 61 + static int scan_tx_ant[3] = { 62 + RATE_MCS_ANT_A_MSK, RATE_MCS_ANT_B_MSK, RATE_MCS_ANT_C_MSK 63 + }; 64 + 65 + static int iwl_is_empty_essid(const char *essid, int essid_len) 66 + { 67 + /* Single white space is for Linksys APs */ 68 + if (essid_len == 1 && essid[0] == ' ') 69 + return 1; 70 + 71 + /* Otherwise, if the entire essid is 0, we assume it is hidden */ 72 + while (essid_len) { 73 + essid_len--; 74 + if (essid[essid_len] != '\0') 75 + return 0; 76 + } 77 + 78 + return 1; 79 + } 80 + 81 + 82 + 83 + const char *iwl_escape_essid(const char *essid, u8 essid_len) 84 + { 85 + static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; 86 + const char *s = essid; 87 + char *d = escaped; 88 + 89 + if (iwl_is_empty_essid(essid, essid_len)) { 90 + memcpy(escaped, "<hidden>", sizeof("<hidden>")); 91 + return escaped; 92 + } 93 + 94 + essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE); 95 + while (essid_len--) { 96 + if (*s == '\0') { 97 + *d++ = '\\'; 98 + *d++ = '0'; 99 + s++; 100 + } else 101 + *d++ = *s++; 102 + } 103 + *d = '\0'; 104 + return escaped; 105 + } 106 + EXPORT_SYMBOL(iwl_escape_essid); 107 + 108 + /** 109 + * iwl_scan_cancel - Cancel any currently executing HW scan 110 + * 111 + * NOTE: priv->mutex is not required before calling this function 112 + */ 113 + int iwl_scan_cancel(struct iwl_priv *priv) 114 + { 115 + if (!test_bit(STATUS_SCAN_HW, &priv->status)) { 116 + clear_bit(STATUS_SCANNING, &priv->status); 117 + return 0; 118 + } 119 + 120 + if (test_bit(STATUS_SCANNING, &priv->status)) { 121 + if (!test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 122 + IWL_DEBUG_SCAN("Queuing scan abort.\n"); 123 + set_bit(STATUS_SCAN_ABORTING, &priv->status); 124 + queue_work(priv->workqueue, &priv->abort_scan); 125 + 126 + } else 127 + IWL_DEBUG_SCAN("Scan abort already in progress.\n"); 128 + 129 + return test_bit(STATUS_SCANNING, &priv->status); 130 + } 131 + 132 + return 0; 133 + } 134 + EXPORT_SYMBOL(iwl_scan_cancel); 135 + /** 136 + * iwl_scan_cancel_timeout - Cancel any currently executing HW scan 137 + * @ms: amount of time to wait (in milliseconds) for scan to abort 138 + * 139 + * NOTE: priv->mutex must be held before calling this function 140 + */ 141 + int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) 142 + { 143 + unsigned long now = jiffies; 144 + int ret; 145 + 146 + ret = iwl_scan_cancel(priv); 147 + if (ret && ms) { 148 + mutex_unlock(&priv->mutex); 149 + while (!time_after(jiffies, now + msecs_to_jiffies(ms)) && 150 + test_bit(STATUS_SCANNING, &priv->status)) 151 + msleep(1); 152 + mutex_lock(&priv->mutex); 153 + 154 + return test_bit(STATUS_SCANNING, &priv->status); 155 + } 156 + 157 + return ret; 158 + } 159 + EXPORT_SYMBOL(iwl_scan_cancel_timeout); 160 + 161 + static int iwl_send_scan_abort(struct iwl_priv *priv) 162 + { 163 + int ret = 0; 164 + struct iwl_rx_packet *res; 165 + struct iwl_host_cmd cmd = { 166 + .id = REPLY_SCAN_ABORT_CMD, 167 + .meta.flags = CMD_WANT_SKB, 168 + }; 169 + 170 + /* If there isn't a scan actively going on in the hardware 171 + * then we are in between scan bands and not actually 172 + * actively scanning, so don't send the abort command */ 173 + if (!test_bit(STATUS_SCAN_HW, &priv->status)) { 174 + clear_bit(STATUS_SCAN_ABORTING, &priv->status); 175 + return 0; 176 + } 177 + 178 + ret = iwl_send_cmd_sync(priv, &cmd); 179 + if (ret) { 180 + clear_bit(STATUS_SCAN_ABORTING, &priv->status); 181 + return ret; 182 + } 183 + 184 + res = (struct iwl_rx_packet *)cmd.meta.u.skb->data; 185 + if (res->u.status != CAN_ABORT_STATUS) { 186 + /* The scan abort will return 1 for success or 187 + * 2 for "failure". A failure condition can be 188 + * due to simply not being in an active scan which 189 + * can occur if we send the scan abort before we 190 + * the microcode has notified us that a scan is 191 + * completed. */ 192 + IWL_DEBUG_INFO("SCAN_ABORT returned %d.\n", res->u.status); 193 + clear_bit(STATUS_SCAN_ABORTING, &priv->status); 194 + clear_bit(STATUS_SCAN_HW, &priv->status); 195 + } 196 + 197 + dev_kfree_skb_any(cmd.meta.u.skb); 198 + 199 + return ret; 200 + } 201 + 202 + 203 + /* Service response to REPLY_SCAN_CMD (0x80) */ 204 + static void iwl_rx_reply_scan(struct iwl_priv *priv, 205 + struct iwl_rx_mem_buffer *rxb) 206 + { 207 + #ifdef CONFIG_IWLWIFI_DEBUG 208 + struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 209 + struct iwl_scanreq_notification *notif = 210 + (struct iwl_scanreq_notification *)pkt->u.raw; 211 + 212 + IWL_DEBUG_RX("Scan request status = 0x%x\n", notif->status); 213 + #endif 214 + } 215 + 216 + /* Service SCAN_START_NOTIFICATION (0x82) */ 217 + static void iwl_rx_scan_start_notif(struct iwl_priv *priv, 218 + struct iwl_rx_mem_buffer *rxb) 219 + { 220 + struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 221 + struct iwl_scanstart_notification *notif = 222 + (struct iwl_scanstart_notification *)pkt->u.raw; 223 + priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); 224 + IWL_DEBUG_SCAN("Scan start: " 225 + "%d [802.11%s] " 226 + "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", 227 + notif->channel, 228 + notif->band ? "bg" : "a", 229 + notif->tsf_high, 230 + notif->tsf_low, notif->status, notif->beacon_timer); 231 + } 232 + 233 + /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ 234 + static void iwl_rx_scan_results_notif(struct iwl_priv *priv, 235 + struct iwl_rx_mem_buffer *rxb) 236 + { 237 + #ifdef CONFIG_IWLWIFI_DEBUG 238 + struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 239 + struct iwl_scanresults_notification *notif = 240 + (struct iwl_scanresults_notification *)pkt->u.raw; 241 + 242 + IWL_DEBUG_SCAN("Scan ch.res: " 243 + "%d [802.11%s] " 244 + "(TSF: 0x%08X:%08X) - %d " 245 + "elapsed=%lu usec (%dms since last)\n", 246 + notif->channel, 247 + notif->band ? "bg" : "a", 248 + le32_to_cpu(notif->tsf_high), 249 + le32_to_cpu(notif->tsf_low), 250 + le32_to_cpu(notif->statistics[0]), 251 + le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf, 252 + jiffies_to_msecs(elapsed_jiffies 253 + (priv->last_scan_jiffies, jiffies))); 254 + #endif 255 + 256 + priv->last_scan_jiffies = jiffies; 257 + priv->next_scan_jiffies = 0; 258 + } 259 + 260 + /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ 261 + static void iwl_rx_scan_complete_notif(struct iwl_priv *priv, 262 + struct iwl_rx_mem_buffer *rxb) 263 + { 264 + struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 265 + struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw; 266 + 267 + IWL_DEBUG_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", 268 + scan_notif->scanned_channels, 269 + scan_notif->tsf_low, 270 + scan_notif->tsf_high, scan_notif->status); 271 + 272 + /* The HW is no longer scanning */ 273 + clear_bit(STATUS_SCAN_HW, &priv->status); 274 + 275 + /* The scan completion notification came in, so kill that timer... */ 276 + cancel_delayed_work(&priv->scan_check); 277 + 278 + IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", 279 + (priv->scan_bands == 2) ? "2.4" : "5.2", 280 + jiffies_to_msecs(elapsed_jiffies 281 + (priv->scan_pass_start, jiffies))); 282 + 283 + /* Remove this scanned band from the list 284 + * of pending bands to scan */ 285 + priv->scan_bands--; 286 + 287 + /* If a request to abort was given, or the scan did not succeed 288 + * then we reset the scan state machine and terminate, 289 + * re-queuing another scan if one has been requested */ 290 + if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 291 + IWL_DEBUG_INFO("Aborted scan completed.\n"); 292 + clear_bit(STATUS_SCAN_ABORTING, &priv->status); 293 + } else { 294 + /* If there are more bands on this scan pass reschedule */ 295 + if (priv->scan_bands > 0) 296 + goto reschedule; 297 + } 298 + 299 + priv->last_scan_jiffies = jiffies; 300 + priv->next_scan_jiffies = 0; 301 + IWL_DEBUG_INFO("Setting scan to off\n"); 302 + 303 + clear_bit(STATUS_SCANNING, &priv->status); 304 + 305 + IWL_DEBUG_INFO("Scan took %dms\n", 306 + jiffies_to_msecs(elapsed_jiffies(priv->scan_start, jiffies))); 307 + 308 + queue_work(priv->workqueue, &priv->scan_completed); 309 + 310 + return; 311 + 312 + reschedule: 313 + priv->scan_pass_start = jiffies; 314 + queue_work(priv->workqueue, &priv->request_scan); 315 + } 316 + 317 + void iwl_setup_rx_scan_handlers(struct iwl_priv *priv) 318 + { 319 + /* scan handlers */ 320 + priv->rx_handlers[REPLY_SCAN_CMD] = iwl_rx_reply_scan; 321 + priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl_rx_scan_start_notif; 322 + priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = 323 + iwl_rx_scan_results_notif; 324 + priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = 325 + iwl_rx_scan_complete_notif; 326 + } 327 + EXPORT_SYMBOL(iwl_setup_rx_scan_handlers); 328 + 329 + static inline u16 iwl_get_active_dwell_time(struct iwl_priv *priv, 330 + enum ieee80211_band band) 331 + { 332 + if (band == IEEE80211_BAND_5GHZ) 333 + return IWL_ACTIVE_DWELL_TIME_52; 334 + else 335 + return IWL_ACTIVE_DWELL_TIME_24; 336 + } 337 + 338 + static u16 iwl_get_passive_dwell_time(struct iwl_priv *priv, 339 + enum ieee80211_band band) 340 + { 341 + u16 active = iwl_get_active_dwell_time(priv, band); 342 + u16 passive = (band != IEEE80211_BAND_5GHZ) ? 343 + IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : 344 + IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; 345 + 346 + if (iwl_is_associated(priv)) { 347 + /* If we're associated, we clamp the maximum passive 348 + * dwell time to be 98% of the beacon interval (minus 349 + * 2 * channel tune time) */ 350 + passive = priv->beacon_int; 351 + if ((passive > IWL_PASSIVE_DWELL_BASE) || !passive) 352 + passive = IWL_PASSIVE_DWELL_BASE; 353 + passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2; 354 + } 355 + 356 + if (passive <= active) 357 + passive = active + 1; 358 + 359 + return passive; 360 + } 361 + 362 + static int iwl_get_channels_for_scan(struct iwl_priv *priv, 363 + enum ieee80211_band band, 364 + u8 is_active, u8 direct_mask, 365 + struct iwl_scan_channel *scan_ch) 366 + { 367 + const struct ieee80211_channel *channels = NULL; 368 + const struct ieee80211_supported_band *sband; 369 + const struct iwl_channel_info *ch_info; 370 + u16 passive_dwell = 0; 371 + u16 active_dwell = 0; 372 + int added, i; 373 + 374 + sband = iwl_get_hw_mode(priv, band); 375 + if (!sband) 376 + return 0; 377 + 378 + channels = sband->channels; 379 + 380 + active_dwell = iwl_get_active_dwell_time(priv, band); 381 + passive_dwell = iwl_get_passive_dwell_time(priv, band); 382 + 383 + for (i = 0, added = 0; i < sband->n_channels; i++) { 384 + if (channels[i].flags & IEEE80211_CHAN_DISABLED) 385 + continue; 386 + 387 + scan_ch->channel = 388 + ieee80211_frequency_to_channel(channels[i].center_freq); 389 + 390 + ch_info = iwl_get_channel_info(priv, band, scan_ch->channel); 391 + if (!is_channel_valid(ch_info)) { 392 + IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", 393 + scan_ch->channel); 394 + continue; 395 + } 396 + 397 + if (!is_active || is_channel_passive(ch_info) || 398 + (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) 399 + scan_ch->type = 0; 400 + else 401 + scan_ch->type = 1; 402 + 403 + if (scan_ch->type & 1) 404 + scan_ch->type |= (direct_mask << 1); 405 + 406 + scan_ch->active_dwell = cpu_to_le16(active_dwell); 407 + scan_ch->passive_dwell = cpu_to_le16(passive_dwell); 408 + 409 + /* Set txpower levels to defaults */ 410 + scan_ch->dsp_atten = 110; 411 + 412 + if (band == IEEE80211_BAND_5GHZ) 413 + scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3; 414 + else { 415 + scan_ch->tx_gain = ((1 << 5) | (5 << 3)); 416 + /* NOTE: if we were doing 6Mb OFDM for scans we'd use 417 + * power level: 418 + * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3; 419 + */ 420 + } 421 + 422 + IWL_DEBUG_SCAN("Scanning %d [%s %d]\n", 423 + scan_ch->channel, 424 + (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", 425 + (scan_ch->type & 1) ? 426 + active_dwell : passive_dwell); 427 + 428 + scan_ch++; 429 + added++; 430 + } 431 + 432 + IWL_DEBUG_SCAN("total channels to scan %d \n", added); 433 + return added; 434 + } 435 + 436 + void iwl_init_scan_params(struct iwl_priv *priv) 437 + { 438 + if (!priv->scan_tx_ant[IEEE80211_BAND_5GHZ]) 439 + priv->scan_tx_ant[IEEE80211_BAND_5GHZ] = RATE_MCS_ANT_INIT_IND; 440 + if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ]) 441 + priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = RATE_MCS_ANT_INIT_IND; 442 + } 443 + 444 + int iwl_scan_initiate(struct iwl_priv *priv) 445 + { 446 + if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 447 + IWL_ERROR("APs don't scan.\n"); 448 + return 0; 449 + } 450 + 451 + if (!iwl_is_ready_rf(priv)) { 452 + IWL_DEBUG_SCAN("Aborting scan due to not ready.\n"); 453 + return -EIO; 454 + } 455 + 456 + if (test_bit(STATUS_SCANNING, &priv->status)) { 457 + IWL_DEBUG_SCAN("Scan already in progress.\n"); 458 + return -EAGAIN; 459 + } 460 + 461 + if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 462 + IWL_DEBUG_SCAN("Scan request while abort pending. " 463 + "Queuing.\n"); 464 + return -EAGAIN; 465 + } 466 + 467 + IWL_DEBUG_INFO("Starting scan...\n"); 468 + priv->scan_bands = 2; 469 + set_bit(STATUS_SCANNING, &priv->status); 470 + priv->scan_start = jiffies; 471 + priv->scan_pass_start = priv->scan_start; 472 + 473 + queue_work(priv->workqueue, &priv->request_scan); 474 + 475 + return 0; 476 + } 477 + EXPORT_SYMBOL(iwl_scan_initiate); 478 + 479 + #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) 480 + 481 + static void iwl_bg_scan_check(struct work_struct *data) 482 + { 483 + struct iwl_priv *priv = 484 + container_of(data, struct iwl_priv, scan_check.work); 485 + 486 + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 487 + return; 488 + 489 + mutex_lock(&priv->mutex); 490 + if (test_bit(STATUS_SCANNING, &priv->status) || 491 + test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 492 + IWL_DEBUG(IWL_DL_SCAN, "Scan completion watchdog resetting " 493 + "adapter (%dms)\n", 494 + jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); 495 + 496 + if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) 497 + iwl_send_scan_abort(priv); 498 + } 499 + mutex_unlock(&priv->mutex); 500 + } 501 + /** 502 + * iwl_supported_rate_to_ie - fill in the supported rate in IE field 503 + * 504 + * return : set the bit for each supported rate insert in ie 505 + */ 506 + static u16 iwl_supported_rate_to_ie(u8 *ie, u16 supported_rate, 507 + u16 basic_rate, int *left) 508 + { 509 + u16 ret_rates = 0, bit; 510 + int i; 511 + u8 *cnt = ie; 512 + u8 *rates = ie + 1; 513 + 514 + for (bit = 1, i = 0; i < IWL_RATE_COUNT; i++, bit <<= 1) { 515 + if (bit & supported_rate) { 516 + ret_rates |= bit; 517 + rates[*cnt] = iwl_rates[i].ieee | 518 + ((bit & basic_rate) ? 0x80 : 0x00); 519 + (*cnt)++; 520 + (*left)--; 521 + if ((*left <= 0) || 522 + (*cnt >= IWL_SUPPORTED_RATES_IE_LEN)) 523 + break; 524 + } 525 + } 526 + 527 + return ret_rates; 528 + } 529 + 530 + 531 + static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband, 532 + u8 *pos, int *left) 533 + { 534 + struct ieee80211_ht_cap *ht_cap; 535 + 536 + if (!sband || !sband->ht_info.ht_supported) 537 + return; 538 + 539 + if (*left < sizeof(struct ieee80211_ht_cap)) 540 + return; 541 + 542 + *pos++ = sizeof(struct ieee80211_ht_cap); 543 + ht_cap = (struct ieee80211_ht_cap *) pos; 544 + 545 + ht_cap->cap_info = cpu_to_le16(sband->ht_info.cap); 546 + memcpy(ht_cap->supp_mcs_set, sband->ht_info.supp_mcs_set, 16); 547 + ht_cap->ampdu_params_info = 548 + (sband->ht_info.ampdu_factor & IEEE80211_HT_CAP_AMPDU_FACTOR) | 549 + ((sband->ht_info.ampdu_density << 2) & 550 + IEEE80211_HT_CAP_AMPDU_DENSITY); 551 + *left -= sizeof(struct ieee80211_ht_cap); 552 + } 553 + 554 + /** 555 + * iwl_fill_probe_req - fill in all required fields and IE for probe request 556 + */ 557 + 558 + static u16 iwl_fill_probe_req(struct iwl_priv *priv, 559 + enum ieee80211_band band, 560 + struct ieee80211_mgmt *frame, 561 + int left) 562 + { 563 + int len = 0; 564 + u8 *pos = NULL; 565 + u16 active_rates, ret_rates, cck_rates, active_rate_basic; 566 + const struct ieee80211_supported_band *sband = 567 + iwl_get_hw_mode(priv, band); 568 + 569 + 570 + /* Make sure there is enough space for the probe request, 571 + * two mandatory IEs and the data */ 572 + left -= 24; 573 + if (left < 0) 574 + return 0; 575 + 576 + frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); 577 + memcpy(frame->da, iwl_bcast_addr, ETH_ALEN); 578 + memcpy(frame->sa, priv->mac_addr, ETH_ALEN); 579 + memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN); 580 + frame->seq_ctrl = 0; 581 + 582 + len += 24; 583 + 584 + /* ...next IE... */ 585 + pos = &frame->u.probe_req.variable[0]; 586 + 587 + /* fill in our indirect SSID IE */ 588 + left -= 2; 589 + if (left < 0) 590 + return 0; 591 + *pos++ = WLAN_EID_SSID; 592 + *pos++ = 0; 593 + 594 + len += 2; 595 + 596 + /* fill in supported rate */ 597 + left -= 2; 598 + if (left < 0) 599 + return 0; 600 + 601 + *pos++ = WLAN_EID_SUPP_RATES; 602 + *pos = 0; 603 + 604 + /* exclude 60M rate */ 605 + active_rates = priv->rates_mask; 606 + active_rates &= ~IWL_RATE_60M_MASK; 607 + 608 + active_rate_basic = active_rates & IWL_BASIC_RATES_MASK; 609 + 610 + cck_rates = IWL_CCK_RATES_MASK & active_rates; 611 + ret_rates = iwl_supported_rate_to_ie(pos, cck_rates, 612 + active_rate_basic, &left); 613 + active_rates &= ~ret_rates; 614 + 615 + ret_rates = iwl_supported_rate_to_ie(pos, active_rates, 616 + active_rate_basic, &left); 617 + active_rates &= ~ret_rates; 618 + 619 + len += 2 + *pos; 620 + pos += (*pos) + 1; 621 + 622 + if (active_rates == 0) 623 + goto fill_end; 624 + 625 + /* fill in supported extended rate */ 626 + /* ...next IE... */ 627 + left -= 2; 628 + if (left < 0) 629 + return 0; 630 + /* ... fill it in... */ 631 + *pos++ = WLAN_EID_EXT_SUPP_RATES; 632 + *pos = 0; 633 + iwl_supported_rate_to_ie(pos, active_rates, active_rate_basic, &left); 634 + if (*pos > 0) { 635 + len += 2 + *pos; 636 + pos += (*pos) + 1; 637 + } else { 638 + pos--; 639 + } 640 + 641 + fill_end: 642 + 643 + left -= 2; 644 + if (left < 0) 645 + return 0; 646 + 647 + *pos++ = WLAN_EID_HT_CAPABILITY; 648 + *pos = 0; 649 + iwl_ht_cap_to_ie(sband, pos, &left); 650 + if (*pos > 0) 651 + len += 2 + *pos; 652 + 653 + return (u16)len; 654 + } 655 + 656 + static u32 iwl_scan_tx_ant(struct iwl_priv *priv, enum ieee80211_band band) 657 + { 658 + int i, ind; 659 + 660 + ind = priv->scan_tx_ant[band]; 661 + for (i = 0; i < priv->hw_params.tx_chains_num; i++) { 662 + ind = (ind+1) >= priv->hw_params.tx_chains_num ? 0 : ind+1; 663 + if (priv->hw_params.valid_tx_ant & (1 << ind)) { 664 + priv->scan_tx_ant[band] = ind; 665 + break; 666 + } 667 + } 668 + 669 + return scan_tx_ant[ind]; 670 + } 671 + 672 + 673 + static void iwl_bg_request_scan(struct work_struct *data) 674 + { 675 + struct iwl_priv *priv = 676 + container_of(data, struct iwl_priv, request_scan); 677 + struct iwl_host_cmd cmd = { 678 + .id = REPLY_SCAN_CMD, 679 + .len = sizeof(struct iwl_scan_cmd), 680 + .meta.flags = CMD_SIZE_HUGE, 681 + }; 682 + struct iwl_scan_cmd *scan; 683 + struct ieee80211_conf *conf = NULL; 684 + int ret = 0; 685 + u32 tx_ant; 686 + u16 cmd_len; 687 + enum ieee80211_band band; 688 + u8 direct_mask; 689 + u8 rx_chain = 0x7; /* bitmap: ABC chains */ 690 + 691 + conf = ieee80211_get_hw_conf(priv->hw); 692 + 693 + mutex_lock(&priv->mutex); 694 + 695 + if (!iwl_is_ready(priv)) { 696 + IWL_WARNING("request scan called when driver not ready.\n"); 697 + goto done; 698 + } 699 + 700 + /* Make sure the scan wasn't cancelled before this queued work 701 + * was given the chance to run... */ 702 + if (!test_bit(STATUS_SCANNING, &priv->status)) 703 + goto done; 704 + 705 + /* This should never be called or scheduled if there is currently 706 + * a scan active in the hardware. */ 707 + if (test_bit(STATUS_SCAN_HW, &priv->status)) { 708 + IWL_DEBUG_INFO("Multiple concurrent scan requests in parallel. " 709 + "Ignoring second request.\n"); 710 + ret = -EIO; 711 + goto done; 712 + } 713 + 714 + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { 715 + IWL_DEBUG_SCAN("Aborting scan due to device shutdown\n"); 716 + goto done; 717 + } 718 + 719 + if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 720 + IWL_DEBUG_HC("Scan request while abort pending. Queuing.\n"); 721 + goto done; 722 + } 723 + 724 + if (iwl_is_rfkill(priv)) { 725 + IWL_DEBUG_HC("Aborting scan due to RF Kill activation\n"); 726 + goto done; 727 + } 728 + 729 + if (!test_bit(STATUS_READY, &priv->status)) { 730 + IWL_DEBUG_HC("Scan request while uninitialized. Queuing.\n"); 731 + goto done; 732 + } 733 + 734 + if (!priv->scan_bands) { 735 + IWL_DEBUG_HC("Aborting scan due to no requested bands\n"); 736 + goto done; 737 + } 738 + 739 + if (!priv->scan) { 740 + priv->scan = kmalloc(sizeof(struct iwl_scan_cmd) + 741 + IWL_MAX_SCAN_SIZE, GFP_KERNEL); 742 + if (!priv->scan) { 743 + ret = -ENOMEM; 744 + goto done; 745 + } 746 + } 747 + scan = priv->scan; 748 + memset(scan, 0, sizeof(struct iwl_scan_cmd) + IWL_MAX_SCAN_SIZE); 749 + 750 + scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; 751 + scan->quiet_time = IWL_ACTIVE_QUIET_TIME; 752 + 753 + if (iwl_is_associated(priv)) { 754 + u16 interval = 0; 755 + u32 extra; 756 + u32 suspend_time = 100; 757 + u32 scan_suspend_time = 100; 758 + unsigned long flags; 759 + 760 + IWL_DEBUG_INFO("Scanning while associated...\n"); 761 + 762 + spin_lock_irqsave(&priv->lock, flags); 763 + interval = priv->beacon_int; 764 + spin_unlock_irqrestore(&priv->lock, flags); 765 + 766 + scan->suspend_time = 0; 767 + scan->max_out_time = cpu_to_le32(200 * 1024); 768 + if (!interval) 769 + interval = suspend_time; 770 + 771 + extra = (suspend_time / interval) << 22; 772 + scan_suspend_time = (extra | 773 + ((suspend_time % interval) * 1024)); 774 + scan->suspend_time = cpu_to_le32(scan_suspend_time); 775 + IWL_DEBUG_SCAN("suspend_time 0x%X beacon interval %d\n", 776 + scan_suspend_time, interval); 777 + } 778 + 779 + /* We should add the ability for user to lock to PASSIVE ONLY */ 780 + if (priv->one_direct_scan) { 781 + IWL_DEBUG_SCAN("Start direct scan for '%s'\n", 782 + iwl_escape_essid(priv->direct_ssid, 783 + priv->direct_ssid_len)); 784 + scan->direct_scan[0].id = WLAN_EID_SSID; 785 + scan->direct_scan[0].len = priv->direct_ssid_len; 786 + memcpy(scan->direct_scan[0].ssid, 787 + priv->direct_ssid, priv->direct_ssid_len); 788 + direct_mask = 1; 789 + } else if (!iwl_is_associated(priv) && priv->essid_len) { 790 + IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n", 791 + iwl_escape_essid(priv->essid, priv->essid_len)); 792 + scan->direct_scan[0].id = WLAN_EID_SSID; 793 + scan->direct_scan[0].len = priv->essid_len; 794 + memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); 795 + direct_mask = 1; 796 + } else { 797 + IWL_DEBUG_SCAN("Start indirect scan.\n"); 798 + direct_mask = 0; 799 + } 800 + 801 + scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; 802 + scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id; 803 + scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 804 + 805 + 806 + switch (priv->scan_bands) { 807 + case 2: 808 + band = IEEE80211_BAND_2GHZ; 809 + scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; 810 + tx_ant = iwl_scan_tx_ant(priv, band); 811 + if (priv->active_rxon.flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK) 812 + scan->tx_cmd.rate_n_flags = 813 + iwl_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, 814 + tx_ant); 815 + else 816 + scan->tx_cmd.rate_n_flags = 817 + iwl_hw_set_rate_n_flags(IWL_RATE_1M_PLCP, 818 + tx_ant | 819 + RATE_MCS_CCK_MSK); 820 + scan->good_CRC_th = 0; 821 + break; 822 + 823 + case 1: 824 + band = IEEE80211_BAND_5GHZ; 825 + tx_ant = iwl_scan_tx_ant(priv, band); 826 + scan->tx_cmd.rate_n_flags = 827 + iwl_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, 828 + tx_ant); 829 + scan->good_CRC_th = IWL_GOOD_CRC_TH; 830 + 831 + /* Force use of chains B and C (0x6) for scan Rx for 4965 832 + * Avoid A (0x1) because of its off-channel reception on A-band. 833 + * MIMO is not used here, but value is required */ 834 + if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) 835 + rx_chain = 0x6; 836 + 837 + break; 838 + default: 839 + IWL_WARNING("Invalid scan band count\n"); 840 + goto done; 841 + } 842 + 843 + scan->rx_chain = RXON_RX_CHAIN_DRIVER_FORCE_MSK | 844 + cpu_to_le16((0x7 << RXON_RX_CHAIN_VALID_POS) | 845 + (rx_chain << RXON_RX_CHAIN_FORCE_SEL_POS) | 846 + (0x7 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS)); 847 + 848 + cmd_len = iwl_fill_probe_req(priv, band, 849 + (struct ieee80211_mgmt *)scan->data, 850 + IWL_MAX_SCAN_SIZE - sizeof(*scan)); 851 + 852 + scan->tx_cmd.len = cpu_to_le16(cmd_len); 853 + 854 + if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) 855 + scan->filter_flags = RXON_FILTER_PROMISC_MSK; 856 + 857 + scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | 858 + RXON_FILTER_BCON_AWARE_MSK); 859 + 860 + if (direct_mask) 861 + scan->channel_count = 862 + iwl_get_channels_for_scan(priv, band, 1, /* active */ 863 + direct_mask, 864 + (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 865 + else 866 + scan->channel_count = 867 + iwl_get_channels_for_scan(priv, band, 0, /* passive */ 868 + direct_mask, 869 + (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 870 + if (scan->channel_count == 0) { 871 + IWL_DEBUG_SCAN("channel count %d\n", scan->channel_count); 872 + goto done; 873 + } 874 + 875 + cmd.len += le16_to_cpu(scan->tx_cmd.len) + 876 + scan->channel_count * sizeof(struct iwl_scan_channel); 877 + cmd.data = scan; 878 + scan->len = cpu_to_le16(cmd.len); 879 + 880 + set_bit(STATUS_SCAN_HW, &priv->status); 881 + ret = iwl_send_cmd_sync(priv, &cmd); 882 + if (ret) 883 + goto done; 884 + 885 + queue_delayed_work(priv->workqueue, &priv->scan_check, 886 + IWL_SCAN_CHECK_WATCHDOG); 887 + 888 + mutex_unlock(&priv->mutex); 889 + return; 890 + 891 + done: 892 + /* inform mac80211 scan aborted */ 893 + queue_work(priv->workqueue, &priv->scan_completed); 894 + mutex_unlock(&priv->mutex); 895 + } 896 + 897 + static void iwl_bg_abort_scan(struct work_struct *work) 898 + { 899 + struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); 900 + 901 + if (!iwl_is_ready(priv)) 902 + return; 903 + 904 + mutex_lock(&priv->mutex); 905 + 906 + set_bit(STATUS_SCAN_ABORTING, &priv->status); 907 + iwl_send_scan_abort(priv); 908 + 909 + mutex_unlock(&priv->mutex); 910 + } 911 + 912 + void iwl_setup_scan_deferred_work(struct iwl_priv *priv) 913 + { 914 + /* FIXME: move here when resolved PENDING 915 + * INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); */ 916 + INIT_WORK(&priv->request_scan, iwl_bg_request_scan); 917 + INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); 918 + INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); 919 + } 920 + EXPORT_SYMBOL(iwl_setup_scan_deferred_work); 921 +
+31 -22
drivers/net/wireless/iwlwifi/iwl-sta.c
··· 30 30 #include <net/mac80211.h> 31 31 #include <linux/etherdevice.h> 32 32 33 - #include "iwl-eeprom.h" 34 33 #include "iwl-dev.h" 35 34 #include "iwl-core.h" 36 35 #include "iwl-sta.h" 37 - #include "iwl-io.h" 38 36 #include "iwl-helpers.h" 39 37 40 38 ··· 72 74 } 73 75 EXPORT_SYMBOL(iwl_find_station); 74 76 77 + int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr) 78 + { 79 + if (priv->iw_mode == IEEE80211_IF_TYPE_STA) { 80 + return IWL_AP_ID; 81 + } else { 82 + u8 *da = ieee80211_get_DA(hdr); 83 + return iwl_find_station(priv, da); 84 + } 85 + } 86 + EXPORT_SYMBOL(iwl_get_ra_sta_id); 87 + 75 88 static int iwl_add_sta_callback(struct iwl_priv *priv, 76 89 struct iwl_cmd *cmd, struct sk_buff *skb) 77 90 { ··· 113 104 /* We didn't cache the SKB; let the caller free it */ 114 105 return 1; 115 106 } 116 - 117 - 118 107 119 108 int iwl_send_add_sta(struct iwl_priv *priv, 120 109 struct iwl_addsta_cmd *sta, u8 flags) ··· 163 156 } 164 157 EXPORT_SYMBOL(iwl_send_add_sta); 165 158 166 - #ifdef CONFIG_IWL4965_HT 167 - 168 159 static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, 169 160 struct ieee80211_ht_info *sta_ht_inf) 170 161 { ··· 207 202 done: 208 203 return; 209 204 } 210 - #else 211 - static inline void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, 212 - struct ieee80211_ht_info *sta_ht_info) 213 - { 214 - } 215 - #endif 216 205 217 206 /** 218 207 * iwl_add_station_flags - Add station to tables in driver and device ··· 278 279 279 280 } 280 281 EXPORT_SYMBOL(iwl_add_station_flags); 281 - 282 282 283 283 static int iwl_sta_ucode_deactivate(struct iwl_priv *priv, const char *addr) 284 284 { ··· 382 384 383 385 return ret; 384 386 } 387 + 385 388 /** 386 389 * iwl_remove_station - Remove driver's knowledge of station. 387 - * 388 390 */ 389 391 u8 iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap) 390 392 { ··· 424 426 return 0; 425 427 } 426 428 EXPORT_SYMBOL(iwl_remove_station); 427 - int iwl_get_free_ucode_key_index(struct iwl_priv *priv) 429 + static int iwl_get_free_ucode_key_index(struct iwl_priv *priv) 428 430 { 429 431 int i; 430 432 ··· 494 496 priv->default_wep_key--; 495 497 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0])); 496 498 ret = iwl_send_static_wepkey_cmd(priv, 1); 499 + IWL_DEBUG_WEP("Remove default WEP key: idx=%d ret=%d\n", 500 + keyconf->keyidx, ret); 497 501 spin_unlock_irqrestore(&priv->sta_lock, flags); 498 502 499 503 return ret; ··· 507 507 { 508 508 int ret; 509 509 unsigned long flags; 510 + 511 + if (keyconf->keylen != WEP_KEY_LEN_128 && 512 + keyconf->keylen != WEP_KEY_LEN_64) { 513 + IWL_DEBUG_WEP("Bad WEP key length %d\n", keyconf->keylen); 514 + return -EINVAL; 515 + } 510 516 511 517 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; 512 518 keyconf->hw_key_idx = HW_KEY_DEFAULT; ··· 530 524 keyconf->keylen); 531 525 532 526 ret = iwl_send_static_wepkey_cmd(priv, 0); 527 + IWL_DEBUG_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", 528 + keyconf->keylen, keyconf->keyidx, ret); 533 529 spin_unlock_irqrestore(&priv->sta_lock, flags); 534 530 535 531 return ret; ··· 678 670 key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); 679 671 keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; 680 672 673 + IWL_DEBUG_WEP("Remove dynamic key: idx=%d sta=%d\n", 674 + keyconf->keyidx, sta_id); 675 + 681 676 if (keyconf->keyidx != keyidx) { 682 677 /* We need to remove a key with index different that the one 683 678 * in the uCode. This means that the key we need to remove has ··· 705 694 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; 706 695 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; 707 696 708 - IWL_DEBUG_INFO("hwcrypto: clear ucode station key info\n"); 709 697 ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); 710 698 spin_unlock_irqrestore(&priv->sta_lock, flags); 711 699 return ret; ··· 733 723 IWL_ERROR("Unknown alg: %s alg = %d\n", __func__, keyconf->alg); 734 724 ret = -EINVAL; 735 725 } 726 + 727 + IWL_DEBUG_WEP("Set dynamic key: alg= %d len=%d idx=%d sta=%d ret=%d\n", 728 + keyconf->alg, keyconf->keylen, keyconf->keyidx, 729 + sta_id, ret); 736 730 737 731 return ret; 738 732 } ··· 830 816 rate_flags |= RATE_MCS_ANT_B_MSK; /*FIXME:RS*/ 831 817 832 818 link_cmd.rs_table[i].rate_n_flags = 833 - iwl4965_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags); 819 + iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags); 834 820 r = iwl4965_get_prev_ieee_rate(r); 835 821 } 836 822 ··· 856 842 u8 sta_id; 857 843 858 844 /* Add station to device's station table */ 859 - #ifdef CONFIG_IWL4965_HT 860 845 struct ieee80211_conf *conf = &priv->hw->conf; 861 846 struct ieee80211_ht_info *cur_ht_config = &conf->ht_conf; 862 847 ··· 865 852 sta_id = iwl_add_station_flags(priv, addr, is_ap, 866 853 0, cur_ht_config); 867 854 else 868 - #endif /* CONFIG_IWL4965_HT */ 869 855 sta_id = iwl_add_station_flags(priv, addr, is_ap, 870 856 0, NULL); 871 857 ··· 874 862 return sta_id; 875 863 } 876 864 EXPORT_SYMBOL(iwl_rxon_add_station); 877 - 878 865 879 866 /** 880 867 * iwl_get_sta_id - Find station's index within station table ··· 932 921 } 933 922 EXPORT_SYMBOL(iwl_get_sta_id); 934 923 935 - 936 924 /** 937 925 * iwl_sta_modify_enable_tid_tx - Enable Tx for this TID in station table 938 926 */ ··· 949 939 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); 950 940 } 951 941 EXPORT_SYMBOL(iwl_sta_modify_enable_tid_tx); 952 - 953 942
+11 -5
drivers/net/wireless/iwlwifi/iwl-sta.h
··· 32 32 #define HW_KEY_DYNAMIC 0 33 33 #define HW_KEY_DEFAULT 1 34 34 35 - int iwl_get_free_ucode_key_index(struct iwl_priv *priv); 35 + /** 36 + * iwl_find_station - Find station id for a given BSSID 37 + * @bssid: MAC address of station ID to find 38 + */ 39 + u8 iwl_find_station(struct iwl_priv *priv, const u8 *bssid); 40 + 36 41 int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty); 37 42 int iwl_remove_default_wep_key(struct iwl_priv *priv, 38 - struct ieee80211_key_conf *key); 43 + struct ieee80211_key_conf *key); 39 44 int iwl_set_default_wep_key(struct iwl_priv *priv, 40 - struct ieee80211_key_conf *key); 45 + struct ieee80211_key_conf *key); 41 46 int iwl_set_dynamic_key(struct iwl_priv *priv, 42 - struct ieee80211_key_conf *key, u8 sta_id); 47 + struct ieee80211_key_conf *key, u8 sta_id); 43 48 int iwl_remove_dynamic_key(struct iwl_priv *priv, 44 - struct ieee80211_key_conf *key, u8 sta_id); 49 + struct ieee80211_key_conf *key, u8 sta_id); 45 50 int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap); 46 51 u8 iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap); 47 52 int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr); 48 53 void iwl_sta_modify_enable_tid_tx(struct iwl_priv *priv, int sta_id, int tid); 54 + int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr); 49 55 #endif /* __iwl_sta_h__ */
+27 -38
drivers/net/wireless/iwlwifi/iwl-tx.c
··· 36 36 #include "iwl-io.h" 37 37 #include "iwl-helpers.h" 38 38 39 - #ifdef CONFIG_IWL4965_HT 40 - 41 39 static const u16 default_tid_to_tx_fifo[] = { 42 40 IWL_TX_FIFO_AC1, 43 41 IWL_TX_FIFO_AC0, ··· 55 57 IWL_TX_FIFO_NONE, 56 58 IWL_TX_FIFO_AC3 57 59 }; 58 - 59 - #endif /*CONFIG_IWL4965_HT */ 60 - 61 60 62 61 63 62 /** ··· 569 574 struct ieee80211_hdr *hdr, 570 575 int is_unicast, u8 std_id) 571 576 { 572 - u16 fc = le16_to_cpu(hdr->frame_control); 577 + __le16 fc = hdr->frame_control; 573 578 __le32 tx_flags = tx_cmd->tx_flags; 574 579 575 580 tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 576 581 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { 577 582 tx_flags |= TX_CMD_FLG_ACK_MSK; 578 - if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) 583 + if (ieee80211_is_mgmt(fc)) 579 584 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 580 - if (ieee80211_is_probe_response(fc) && 585 + if (ieee80211_is_probe_resp(fc) && 581 586 !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) 582 587 tx_flags |= TX_CMD_FLG_TSF_MSK; 583 588 } else { ··· 585 590 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 586 591 } 587 592 588 - if (ieee80211_is_back_request(fc)) 593 + if (ieee80211_is_back_req(fc)) 589 594 tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; 590 595 591 596 592 597 tx_cmd->sta_id = std_id; 593 - if (ieee80211_get_morefrag(hdr)) 598 + if (ieee80211_has_morefrags(fc)) 594 599 tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; 595 600 596 - if (ieee80211_is_qos_data(fc)) { 597 - u8 *qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); 601 + if (ieee80211_is_data_qos(fc)) { 602 + u8 *qc = ieee80211_get_qos_ctl(hdr); 598 603 tx_cmd->tid_tspec = qc[0] & 0xf; 599 604 tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; 600 605 } else { ··· 613 618 tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; 614 619 615 620 tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); 616 - if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { 617 - if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ || 618 - (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ) 621 + if (ieee80211_is_mgmt(fc)) { 622 + if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) 619 623 tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); 620 624 else 621 625 tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); ··· 633 639 static void iwl_tx_cmd_build_rate(struct iwl_priv *priv, 634 640 struct iwl_tx_cmd *tx_cmd, 635 641 struct ieee80211_tx_info *info, 636 - u16 fc, int sta_id, 642 + __le16 fc, int sta_id, 637 643 int is_hcca) 638 644 { 639 645 u8 rts_retry_limit = 0; ··· 654 660 rate_flags |= RATE_MCS_CCK_MSK; 655 661 656 662 657 - if (ieee80211_is_probe_response(fc)) { 663 + if (ieee80211_is_probe_resp(fc)) { 658 664 data_retry_limit = 3; 659 665 if (data_retry_limit < rts_retry_limit) 660 666 rts_retry_limit = data_retry_limit; ··· 669 675 tx_cmd->initial_rate_index = 0; 670 676 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; 671 677 } else { 672 - switch (fc & IEEE80211_FCTL_STYPE) { 673 - case IEEE80211_STYPE_AUTH: 674 - case IEEE80211_STYPE_DEAUTH: 675 - case IEEE80211_STYPE_ASSOC_REQ: 676 - case IEEE80211_STYPE_REASSOC_REQ: 678 + switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { 679 + case cpu_to_le16(IEEE80211_STYPE_AUTH): 680 + case cpu_to_le16(IEEE80211_STYPE_DEAUTH): 681 + case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): 682 + case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): 677 683 if (tx_cmd->tx_flags & TX_CMD_FLG_RTS_MSK) { 678 684 tx_cmd->tx_flags &= ~TX_CMD_FLG_RTS_MSK; 679 685 tx_cmd->tx_flags |= TX_CMD_FLG_CTS_MSK; ··· 695 701 696 702 tx_cmd->rts_retry_limit = rts_retry_limit; 697 703 tx_cmd->data_retry_limit = data_retry_limit; 698 - tx_cmd->rate_n_flags = iwl4965_hw_set_rate_n_flags(rate_plcp, rate_flags); 704 + tx_cmd->rate_n_flags = iwl_hw_set_rate_n_flags(rate_plcp, rate_flags); 699 705 } 700 706 701 707 static void iwl_tx_cmd_build_hwcrypto(struct iwl_priv *priv, ··· 770 776 u16 seq_number = 0; 771 777 u8 id, hdr_len, unicast; 772 778 u8 sta_id; 773 - u16 fc; 779 + __le16 fc; 774 780 u8 wait_write_ptr = 0; 775 781 u8 tid = 0; 776 782 u8 *qc = NULL; ··· 797 803 unicast = !is_multicast_ether_addr(hdr->addr1); 798 804 id = 0; 799 805 800 - fc = le16_to_cpu(hdr->frame_control); 806 + fc = hdr->frame_control; 801 807 802 808 #ifdef CONFIG_IWLWIFI_DEBUG 803 809 if (ieee80211_is_auth(fc)) 804 810 IWL_DEBUG_TX("Sending AUTH frame\n"); 805 - else if (ieee80211_is_assoc_request(fc)) 811 + else if (ieee80211_is_assoc_req(fc)) 806 812 IWL_DEBUG_TX("Sending ASSOC frame\n"); 807 - else if (ieee80211_is_reassoc_request(fc)) 813 + else if (ieee80211_is_reassoc_req(fc)) 808 814 IWL_DEBUG_TX("Sending REASSOC frame\n"); 809 815 #endif 810 816 811 817 /* drop all data frame if we are not associated */ 812 - if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && 818 + if (ieee80211_is_data(fc) && 813 819 (!iwl_is_associated(priv) || 814 820 ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id) || 815 821 !priv->assoc_station_added)) { ··· 819 825 820 826 spin_unlock_irqrestore(&priv->lock, flags); 821 827 822 - hdr_len = ieee80211_get_hdrlen(fc); 828 + hdr_len = ieee80211_get_hdrlen(le16_to_cpu(fc)); 823 829 824 830 /* Find (or create) index into station table for destination station */ 825 831 sta_id = iwl_get_sta_id(priv, hdr); ··· 833 839 834 840 IWL_DEBUG_TX("station Id %d\n", sta_id); 835 841 836 - if (ieee80211_is_qos_data(fc)) { 837 - qc = ieee80211_get_qos_ctrl(hdr, hdr_len); 842 + if (ieee80211_is_data_qos(fc)) { 843 + qc = ieee80211_get_qos_ctl(hdr); 838 844 tid = qc[0] & 0xf; 839 845 seq_number = priv->stations[sta_id].tid[tid].seq_number & 840 846 IEEE80211_SCTL_SEQ; ··· 842 848 (hdr->seq_ctrl & 843 849 __constant_cpu_to_le16(IEEE80211_SCTL_FRAG)); 844 850 seq_number += 0x10; 845 - #ifdef CONFIG_IWL4965_HT 846 851 /* aggregation is on for this <sta,tid> */ 847 852 if (info->flags & IEEE80211_TX_CTL_AMPDU) 848 853 txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; 849 854 priv->stations[sta_id].tid[tid].tfds_in_queue++; 850 - #endif /* CONFIG_IWL4965_HT */ 851 855 } 852 856 853 857 /* Descriptor for chosen Tx queue */ ··· 937 945 /* set is_hcca to 0; it probably will never be implemented */ 938 946 iwl_tx_cmd_build_rate(priv, tx_cmd, info, fc, sta_id, 0); 939 947 940 - iwl_update_tx_stats(priv, fc, len); 948 + iwl_update_tx_stats(priv, le16_to_cpu(fc), len); 941 949 942 950 scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) + 943 951 offsetof(struct iwl_tx_cmd, scratch); 944 952 tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); 945 953 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_address(scratch_phys); 946 954 947 - if (!ieee80211_get_morefrag(hdr)) { 955 + if (!ieee80211_has_morefrags(hdr->frame_control)) { 948 956 txq->need_update = 1; 949 957 if (qc) 950 958 priv->stations[sta_id].tid[tid].seq_number = seq_number; ··· 1188 1196 } 1189 1197 EXPORT_SYMBOL(iwl_tx_cmd_complete); 1190 1198 1191 - 1192 - #ifdef CONFIG_IWL4965_HT 1193 1199 /* 1194 1200 * Find first available (lowest unused) Tx Queue, mark it "active". 1195 1201 * Called only when finding queue for aggregation. ··· 1349 1359 return 0; 1350 1360 } 1351 1361 EXPORT_SYMBOL(iwl_txq_check_empty); 1352 - #endif /* CONFIG_IWL4965_HT */ 1353 1362 1354 1363 #ifdef CONFIG_IWLWIF_DEBUG 1355 1364 #define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x
+20 -20
drivers/net/wireless/iwlwifi/iwl3945-base.c
··· 2431 2431 struct ieee80211_hdr *hdr, 2432 2432 int is_unicast, u8 std_id) 2433 2433 { 2434 - u16 fc = le16_to_cpu(hdr->frame_control); 2434 + __le16 fc = hdr->frame_control; 2435 2435 __le32 tx_flags = cmd->cmd.tx.tx_flags; 2436 2436 2437 2437 cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 2438 2438 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { 2439 2439 tx_flags |= TX_CMD_FLG_ACK_MSK; 2440 - if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) 2440 + if (ieee80211_is_mgmt(fc)) 2441 2441 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 2442 - if (ieee80211_is_probe_response(fc) && 2442 + if (ieee80211_is_probe_resp(fc) && 2443 2443 !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) 2444 2444 tx_flags |= TX_CMD_FLG_TSF_MSK; 2445 2445 } else { ··· 2448 2448 } 2449 2449 2450 2450 cmd->cmd.tx.sta_id = std_id; 2451 - if (ieee80211_get_morefrag(hdr)) 2451 + if (ieee80211_has_morefrags(fc)) 2452 2452 tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; 2453 2453 2454 - if (ieee80211_is_qos_data(fc)) { 2455 - u8 *qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); 2454 + if (ieee80211_is_data_qos(fc)) { 2455 + u8 *qc = ieee80211_get_qos_ctl(hdr); 2456 2456 cmd->cmd.tx.tid_tspec = qc[0] & 0xf; 2457 2457 tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; 2458 2458 } else { ··· 2471 2471 tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; 2472 2472 2473 2473 tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); 2474 - if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { 2475 - if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ || 2476 - (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ) 2474 + if (ieee80211_is_mgmt(fc)) { 2475 + if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) 2477 2476 cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3); 2478 2477 else 2479 2478 cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2); ··· 2563 2564 u8 sta_id; 2564 2565 u8 tid = 0; 2565 2566 u16 seq_number = 0; 2566 - u16 fc; 2567 + __le16 fc; 2567 2568 u8 wait_write_ptr = 0; 2568 2569 u8 *qc = NULL; 2569 2570 unsigned long flags; ··· 2588 2589 unicast = !is_multicast_ether_addr(hdr->addr1); 2589 2590 id = 0; 2590 2591 2591 - fc = le16_to_cpu(hdr->frame_control); 2592 + fc = hdr->frame_control; 2592 2593 2593 2594 #ifdef CONFIG_IWL3945_DEBUG 2594 2595 if (ieee80211_is_auth(fc)) 2595 2596 IWL_DEBUG_TX("Sending AUTH frame\n"); 2596 - else if (ieee80211_is_assoc_request(fc)) 2597 + else if (ieee80211_is_assoc_req(fc)) 2597 2598 IWL_DEBUG_TX("Sending ASSOC frame\n"); 2598 - else if (ieee80211_is_reassoc_request(fc)) 2599 + else if (ieee80211_is_reassoc_req(fc)) 2599 2600 IWL_DEBUG_TX("Sending REASSOC frame\n"); 2600 2601 #endif 2601 2602 2602 2603 /* drop all data frame if we are not associated */ 2603 2604 if ((!iwl3945_is_associated(priv) || 2604 2605 ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id)) && 2605 - ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)) { 2606 + ieee80211_is_data(fc)) { 2606 2607 IWL_DEBUG_DROP("Dropping - !iwl3945_is_associated\n"); 2607 2608 goto drop_unlock; 2608 2609 } 2609 2610 2610 2611 spin_unlock_irqrestore(&priv->lock, flags); 2611 2612 2612 - hdr_len = ieee80211_get_hdrlen(fc); 2613 + hdr_len = ieee80211_get_hdrlen(le16_to_cpu(fc)); 2613 2614 2614 2615 /* Find (or create) index into station table for destination station */ 2615 2616 sta_id = iwl3945_get_sta_id(priv, hdr); ··· 2623 2624 2624 2625 IWL_DEBUG_RATE("station Id %d\n", sta_id); 2625 2626 2626 - if (ieee80211_is_qos_data(fc)) { 2627 - qc = ieee80211_get_qos_ctrl(hdr, hdr_len); 2627 + if (ieee80211_is_data_qos(fc)) { 2628 + qc = ieee80211_get_qos_ctl(hdr); 2628 2629 tid = qc[0] & 0xf; 2629 2630 seq_number = priv->stations[sta_id].tid[tid].seq_number & 2630 2631 IEEE80211_SCTL_SEQ; ··· 2731 2732 out_cmd->cmd.tx.tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; 2732 2733 out_cmd->cmd.tx.tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; 2733 2734 2734 - if (!ieee80211_get_morefrag(hdr)) { 2735 + if (!ieee80211_has_morefrags(hdr->frame_control)) { 2735 2736 txq->need_update = 1; 2736 2737 if (qc) { 2737 2738 priv->stations[sta_id].tid[tid].seq_number = seq_number; ··· 2745 2746 sizeof(out_cmd->cmd.tx)); 2746 2747 2747 2748 iwl3945_print_hex_dump(IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr, 2748 - ieee80211_get_hdrlen(fc)); 2749 + ieee80211_get_hdrlen(le16_to_cpu(fc))); 2749 2750 2750 2751 /* Tell device the write index *just past* this latest filled TFD */ 2751 2752 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); ··· 2874 2875 return; 2875 2876 } 2876 2877 2877 - queue_work(priv->workqueue, &priv->restart); 2878 + if (priv->is_open) 2879 + queue_work(priv->workqueue, &priv->restart); 2878 2880 return; 2879 2881 } 2880 2882
+197 -1050
drivers/net/wireless/iwlwifi/iwl4965-base.c
··· 87 87 MODULE_AUTHOR(DRV_COPYRIGHT); 88 88 MODULE_LICENSE("GPL"); 89 89 90 - static int iwl4965_is_empty_essid(const char *essid, int essid_len) 91 - { 92 - /* Single white space is for Linksys APs */ 93 - if (essid_len == 1 && essid[0] == ' ') 94 - return 1; 95 - 96 - /* Otherwise, if the entire essid is 0, we assume it is hidden */ 97 - while (essid_len) { 98 - essid_len--; 99 - if (essid[essid_len] != '\0') 100 - return 0; 101 - } 102 - 103 - return 1; 104 - } 105 - 106 - static const char *iwl4965_escape_essid(const char *essid, u8 essid_len) 107 - { 108 - static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; 109 - const char *s = essid; 110 - char *d = escaped; 111 - 112 - if (iwl4965_is_empty_essid(essid, essid_len)) { 113 - memcpy(escaped, "<hidden>", sizeof("<hidden>")); 114 - return escaped; 115 - } 116 - 117 - essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE); 118 - while (essid_len--) { 119 - if (*s == '\0') { 120 - *d++ = '\\'; 121 - *d++ = '0'; 122 - s++; 123 - } else 124 - *d++ = *s++; 125 - } 126 - *d = '\0'; 127 - return escaped; 128 - } 129 - 130 90 /*************** STATION TABLE MANAGEMENT **** 131 91 * mac80211 should be examined to determine if sta_info is duplicating 132 92 * the functionality provided here ··· 327 367 328 368 /* If we issue a new RXON command which required a tune then we must 329 369 * send a new TXPOWER command or we won't be able to Tx any frames */ 330 - rc = iwl4965_hw_reg_send_txpower(priv); 370 + rc = iwl_set_tx_power(priv, priv->tx_power_user_lmt, true); 331 371 if (rc) { 332 - IWL_ERROR("Error setting Tx power (%d).\n", rc); 372 + IWL_ERROR("Error sending TX power (%d).\n", rc); 333 373 return rc; 334 374 } 335 375 ··· 377 417 378 418 return iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG, 379 419 sizeof(struct iwl4965_bt_cmd), &bt_cmd); 380 - } 381 - 382 - static int iwl4965_send_scan_abort(struct iwl_priv *priv) 383 - { 384 - int ret = 0; 385 - struct iwl_rx_packet *res; 386 - struct iwl_host_cmd cmd = { 387 - .id = REPLY_SCAN_ABORT_CMD, 388 - .meta.flags = CMD_WANT_SKB, 389 - }; 390 - 391 - /* If there isn't a scan actively going on in the hardware 392 - * then we are in between scan bands and not actually 393 - * actively scanning, so don't send the abort command */ 394 - if (!test_bit(STATUS_SCAN_HW, &priv->status)) { 395 - clear_bit(STATUS_SCAN_ABORTING, &priv->status); 396 - return 0; 397 - } 398 - 399 - ret = iwl_send_cmd_sync(priv, &cmd); 400 - if (ret) { 401 - clear_bit(STATUS_SCAN_ABORTING, &priv->status); 402 - return ret; 403 - } 404 - 405 - res = (struct iwl_rx_packet *)cmd.meta.u.skb->data; 406 - if (res->u.status != CAN_ABORT_STATUS) { 407 - /* The scan abort will return 1 for success or 408 - * 2 for "failure". A failure condition can be 409 - * due to simply not being in an active scan which 410 - * can occur if we send the scan abort before we 411 - * the microcode has notified us that a scan is 412 - * completed. */ 413 - IWL_DEBUG_INFO("SCAN_ABORT returned %d.\n", res->u.status); 414 - clear_bit(STATUS_SCAN_ABORTING, &priv->status); 415 - clear_bit(STATUS_SCAN_HW, &priv->status); 416 - } 417 - 418 - dev_kfree_skb_any(cmd.meta.u.skb); 419 - 420 - return ret; 421 - } 422 - 423 - /* 424 - * CARD_STATE_CMD 425 - * 426 - * Use: Sets the device's internal card state to enable, disable, or halt 427 - * 428 - * When in the 'enable' state the card operates as normal. 429 - * When in the 'disable' state, the card enters into a low power mode. 430 - * When in the 'halt' state, the card is shut down and must be fully 431 - * restarted to come back on. 432 - */ 433 - static int iwl4965_send_card_state(struct iwl_priv *priv, u32 flags, u8 meta_flag) 434 - { 435 - struct iwl_host_cmd cmd = { 436 - .id = REPLY_CARD_STATE_CMD, 437 - .len = sizeof(u32), 438 - .data = &flags, 439 - .meta.flags = meta_flag, 440 - }; 441 - 442 - return iwl_send_cmd(priv, &cmd); 443 420 } 444 421 445 422 static void iwl_clear_free_frames(struct iwl_priv *priv) ··· 502 605 * 503 606 ******************************************************************************/ 504 607 505 - /** 506 - * iwl4965_supported_rate_to_ie - fill in the supported rate in IE field 507 - * 508 - * return : set the bit for each supported rate insert in ie 509 - */ 510 - static u16 iwl4965_supported_rate_to_ie(u8 *ie, u16 supported_rate, 511 - u16 basic_rate, int *left) 512 - { 513 - u16 ret_rates = 0, bit; 514 - int i; 515 - u8 *cnt = ie; 516 - u8 *rates = ie + 1; 517 - 518 - for (bit = 1, i = 0; i < IWL_RATE_COUNT; i++, bit <<= 1) { 519 - if (bit & supported_rate) { 520 - ret_rates |= bit; 521 - rates[*cnt] = iwl_rates[i].ieee | 522 - ((bit & basic_rate) ? 0x80 : 0x00); 523 - (*cnt)++; 524 - (*left)--; 525 - if ((*left <= 0) || 526 - (*cnt >= IWL_SUPPORTED_RATES_IE_LEN)) 527 - break; 528 - } 529 - } 530 - 531 - return ret_rates; 532 - } 533 - 534 - #ifdef CONFIG_IWL4965_HT 535 608 static void iwl4965_ht_conf(struct iwl_priv *priv, 536 609 struct ieee80211_bss_conf *bss_conf) 537 610 { ··· 532 665 iwl_conf->extension_chan_offset = 533 666 ht_bss_conf->bss_cap & IEEE80211_HT_IE_CHA_SEC_OFFSET; 534 667 /* If no above or below channel supplied disable FAT channel */ 535 - if (iwl_conf->extension_chan_offset != IWL_EXT_CHANNEL_OFFSET_ABOVE && 536 - iwl_conf->extension_chan_offset != IWL_EXT_CHANNEL_OFFSET_BELOW) 668 + if (iwl_conf->extension_chan_offset != IEEE80211_HT_IE_CHA_SEC_ABOVE && 669 + iwl_conf->extension_chan_offset != IEEE80211_HT_IE_CHA_SEC_BELOW) { 670 + iwl_conf->extension_chan_offset = IEEE80211_HT_IE_CHA_SEC_NONE; 537 671 iwl_conf->supported_chan_width = 0; 672 + } 538 673 539 674 iwl_conf->tx_mimo_ps_mode = 540 675 (u8)((ht_conf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2); ··· 552 683 553 684 IWL_DEBUG_MAC80211("control channel %d\n", iwl_conf->control_channel); 554 685 IWL_DEBUG_MAC80211("leave\n"); 555 - } 556 - 557 - static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband, 558 - u8 *pos, int *left) 559 - { 560 - struct ieee80211_ht_cap *ht_cap; 561 - 562 - if (!sband || !sband->ht_info.ht_supported) 563 - return; 564 - 565 - if (*left < sizeof(struct ieee80211_ht_cap)) 566 - return; 567 - 568 - *pos++ = sizeof(struct ieee80211_ht_cap); 569 - ht_cap = (struct ieee80211_ht_cap *) pos; 570 - 571 - ht_cap->cap_info = cpu_to_le16(sband->ht_info.cap); 572 - memcpy(ht_cap->supp_mcs_set, sband->ht_info.supp_mcs_set, 16); 573 - ht_cap->ampdu_params_info = 574 - (sband->ht_info.ampdu_factor & IEEE80211_HT_CAP_AMPDU_FACTOR) | 575 - ((sband->ht_info.ampdu_density << 2) & 576 - IEEE80211_HT_CAP_AMPDU_DENSITY); 577 - *left -= sizeof(struct ieee80211_ht_cap); 578 - } 579 - #else 580 - static inline void iwl4965_ht_conf(struct iwl_priv *priv, 581 - struct ieee80211_bss_conf *bss_conf) 582 - { 583 - } 584 - static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband, 585 - u8 *pos, int *left) 586 - { 587 - } 588 - #endif 589 - 590 - 591 - /** 592 - * iwl4965_fill_probe_req - fill in all required fields and IE for probe request 593 - */ 594 - static u16 iwl4965_fill_probe_req(struct iwl_priv *priv, 595 - enum ieee80211_band band, 596 - struct ieee80211_mgmt *frame, 597 - int left, int is_direct) 598 - { 599 - int len = 0; 600 - u8 *pos = NULL; 601 - u16 active_rates, ret_rates, cck_rates, active_rate_basic; 602 - const struct ieee80211_supported_band *sband = 603 - iwl_get_hw_mode(priv, band); 604 - 605 - /* Make sure there is enough space for the probe request, 606 - * two mandatory IEs and the data */ 607 - left -= 24; 608 - if (left < 0) 609 - return 0; 610 - len += 24; 611 - 612 - frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); 613 - memcpy(frame->da, iwl_bcast_addr, ETH_ALEN); 614 - memcpy(frame->sa, priv->mac_addr, ETH_ALEN); 615 - memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN); 616 - frame->seq_ctrl = 0; 617 - 618 - /* fill in our indirect SSID IE */ 619 - /* ...next IE... */ 620 - 621 - left -= 2; 622 - if (left < 0) 623 - return 0; 624 - len += 2; 625 - pos = &(frame->u.probe_req.variable[0]); 626 - *pos++ = WLAN_EID_SSID; 627 - *pos++ = 0; 628 - 629 - /* fill in our direct SSID IE... */ 630 - if (is_direct) { 631 - /* ...next IE... */ 632 - left -= 2 + priv->essid_len; 633 - if (left < 0) 634 - return 0; 635 - /* ... fill it in... */ 636 - *pos++ = WLAN_EID_SSID; 637 - *pos++ = priv->essid_len; 638 - memcpy(pos, priv->essid, priv->essid_len); 639 - pos += priv->essid_len; 640 - len += 2 + priv->essid_len; 641 - } 642 - 643 - /* fill in supported rate */ 644 - /* ...next IE... */ 645 - left -= 2; 646 - if (left < 0) 647 - return 0; 648 - 649 - /* ... fill it in... */ 650 - *pos++ = WLAN_EID_SUPP_RATES; 651 - *pos = 0; 652 - 653 - /* exclude 60M rate */ 654 - active_rates = priv->rates_mask; 655 - active_rates &= ~IWL_RATE_60M_MASK; 656 - 657 - active_rate_basic = active_rates & IWL_BASIC_RATES_MASK; 658 - 659 - cck_rates = IWL_CCK_RATES_MASK & active_rates; 660 - ret_rates = iwl4965_supported_rate_to_ie(pos, cck_rates, 661 - active_rate_basic, &left); 662 - active_rates &= ~ret_rates; 663 - 664 - ret_rates = iwl4965_supported_rate_to_ie(pos, active_rates, 665 - active_rate_basic, &left); 666 - active_rates &= ~ret_rates; 667 - 668 - len += 2 + *pos; 669 - pos += (*pos) + 1; 670 - if (active_rates == 0) 671 - goto fill_end; 672 - 673 - /* fill in supported extended rate */ 674 - /* ...next IE... */ 675 - left -= 2; 676 - if (left < 0) 677 - return 0; 678 - /* ... fill it in... */ 679 - *pos++ = WLAN_EID_EXT_SUPP_RATES; 680 - *pos = 0; 681 - iwl4965_supported_rate_to_ie(pos, active_rates, 682 - active_rate_basic, &left); 683 - if (*pos > 0) 684 - len += 2 + *pos; 685 - 686 - fill_end: 687 - /* fill in HT IE */ 688 - left -= 2; 689 - if (left < 0) 690 - return 0; 691 - 692 - *pos++ = WLAN_EID_HT_CAPABILITY; 693 - *pos = 0; 694 - 695 - iwl_ht_cap_to_ie(sband, pos, &left); 696 - 697 - if (*pos > 0) 698 - len += 2 + *pos; 699 - return (u16)len; 700 686 } 701 687 702 688 /* ··· 586 862 priv->qos_data.def_qos_parm.qos_flags |= 587 863 QOS_PARAM_FLG_UPDATE_EDCA_MSK; 588 864 589 - #ifdef CONFIG_IWL4965_HT 590 865 if (priv->current_ht_config.is_ht) 591 866 priv->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; 592 - #endif /* CONFIG_IWL4965_HT */ 593 867 594 868 spin_unlock_irqrestore(&priv->lock, flags); 595 869 ··· 631 909 return 1; 632 910 } 633 911 634 - 635 - 636 - /** 637 - * iwl4965_scan_cancel - Cancel any currently executing HW scan 638 - * 639 - * NOTE: priv->mutex is not required before calling this function 640 - */ 641 - static int iwl4965_scan_cancel(struct iwl_priv *priv) 642 - { 643 - if (!test_bit(STATUS_SCAN_HW, &priv->status)) { 644 - clear_bit(STATUS_SCANNING, &priv->status); 645 - return 0; 646 - } 647 - 648 - if (test_bit(STATUS_SCANNING, &priv->status)) { 649 - if (!test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 650 - IWL_DEBUG_SCAN("Queuing scan abort.\n"); 651 - set_bit(STATUS_SCAN_ABORTING, &priv->status); 652 - queue_work(priv->workqueue, &priv->abort_scan); 653 - 654 - } else 655 - IWL_DEBUG_SCAN("Scan abort already in progress.\n"); 656 - 657 - return test_bit(STATUS_SCANNING, &priv->status); 658 - } 659 - 660 - return 0; 661 - } 662 - 663 - /** 664 - * iwl4965_scan_cancel_timeout - Cancel any currently executing HW scan 665 - * @ms: amount of time to wait (in milliseconds) for scan to abort 666 - * 667 - * NOTE: priv->mutex must be held before calling this function 668 - */ 669 - static int iwl4965_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) 670 - { 671 - unsigned long now = jiffies; 672 - int ret; 673 - 674 - ret = iwl4965_scan_cancel(priv); 675 - if (ret && ms) { 676 - mutex_unlock(&priv->mutex); 677 - while (!time_after(jiffies, now + msecs_to_jiffies(ms)) && 678 - test_bit(STATUS_SCANNING, &priv->status)) 679 - msleep(1); 680 - mutex_lock(&priv->mutex); 681 - 682 - return test_bit(STATUS_SCANNING, &priv->status); 683 - } 684 - 685 - return ret; 686 - } 687 - 688 912 static void iwl4965_sequence_reset(struct iwl_priv *priv) 689 913 { 690 914 /* Reset ieee stats */ ··· 642 974 priv->last_frag_num = -1; 643 975 priv->last_packet_time = 0; 644 976 645 - iwl4965_scan_cancel(priv); 977 + iwl_scan_cancel(priv); 646 978 } 647 979 648 980 #define MAX_UCODE_BEACON_INTERVAL 4096 ··· 716 1048 le32_to_cpu(priv->rxon_timing.beacon_init_val), 717 1049 le16_to_cpu(priv->rxon_timing.atim_window)); 718 1050 } 719 - 720 - static int iwl4965_scan_initiate(struct iwl_priv *priv) 721 - { 722 - if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 723 - IWL_ERROR("APs don't scan.\n"); 724 - return 0; 725 - } 726 - 727 - if (!iwl_is_ready_rf(priv)) { 728 - IWL_DEBUG_SCAN("Aborting scan due to not ready.\n"); 729 - return -EIO; 730 - } 731 - 732 - if (test_bit(STATUS_SCANNING, &priv->status)) { 733 - IWL_DEBUG_SCAN("Scan already in progress.\n"); 734 - return -EAGAIN; 735 - } 736 - 737 - if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 738 - IWL_DEBUG_SCAN("Scan request while abort pending. " 739 - "Queuing.\n"); 740 - return -EAGAIN; 741 - } 742 - 743 - IWL_DEBUG_INFO("Starting scan...\n"); 744 - priv->scan_bands = 2; 745 - set_bit(STATUS_SCANNING, &priv->status); 746 - priv->scan_start = jiffies; 747 - priv->scan_pass_start = priv->scan_start; 748 - 749 - queue_work(priv->workqueue, &priv->request_scan); 750 - 751 - return 0; 752 - } 753 - 754 1051 755 1052 static void iwl_set_flags_for_band(struct iwl_priv *priv, 756 1053 enum ieee80211_band band) ··· 821 1188 822 1189 static int iwl4965_set_mode(struct iwl_priv *priv, int mode) 823 1190 { 824 - if (mode == IEEE80211_IF_TYPE_IBSS) { 825 - const struct iwl_channel_info *ch_info; 826 - 827 - ch_info = iwl_get_channel_info(priv, 828 - priv->band, 829 - le16_to_cpu(priv->staging_rxon.channel)); 830 - 831 - if (!ch_info || !is_channel_ibss(ch_info)) { 832 - IWL_ERROR("channel %d not IBSS channel\n", 833 - le16_to_cpu(priv->staging_rxon.channel)); 834 - return -EINVAL; 835 - } 836 - } 837 - 838 1191 priv->iw_mode = mode; 1192 + 1193 + /* init channel/phymode to values given at driver init */ 1194 + iwl_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); 839 1195 840 1196 iwl4965_connection_init_rx_config(priv); 841 1197 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); ··· 836 1214 return -EAGAIN; 837 1215 838 1216 cancel_delayed_work(&priv->scan_check); 839 - if (iwl4965_scan_cancel_timeout(priv, 100)) { 1217 + if (iwl_scan_cancel_timeout(priv, 100)) { 840 1218 IWL_WARNING("Aborted scan still in progress after 100ms\n"); 841 1219 IWL_DEBUG_MAC80211("leaving - scan abort failed.\n"); 842 1220 return -EAGAIN; ··· 892 1270 else 893 1271 priv->staging_rxon.ofdm_basic_rates = 894 1272 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; 895 - } 896 - 897 - void iwl4965_radio_kill_sw(struct iwl_priv *priv, int disable_radio) 898 - { 899 - unsigned long flags; 900 - 901 - if (!!disable_radio == test_bit(STATUS_RF_KILL_SW, &priv->status)) 902 - return; 903 - 904 - IWL_DEBUG_RF_KILL("Manual SW RF KILL set to: RADIO %s\n", 905 - disable_radio ? "OFF" : "ON"); 906 - 907 - if (disable_radio) { 908 - iwl4965_scan_cancel(priv); 909 - /* FIXME: This is a workaround for AP */ 910 - if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { 911 - spin_lock_irqsave(&priv->lock, flags); 912 - iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, 913 - CSR_UCODE_SW_BIT_RFKILL); 914 - spin_unlock_irqrestore(&priv->lock, flags); 915 - /* call the host command only if no hw rf-kill set */ 916 - if (!test_bit(STATUS_RF_KILL_HW, &priv->status) && 917 - iwl_is_ready(priv)) 918 - iwl4965_send_card_state(priv, 919 - CARD_STATE_CMD_DISABLE, 920 - 0); 921 - set_bit(STATUS_RF_KILL_SW, &priv->status); 922 - 923 - /* make sure mac80211 stop sending Tx frame */ 924 - if (priv->mac80211_registered) 925 - ieee80211_stop_queues(priv->hw); 926 - } 927 - return; 928 - } 929 - 930 - spin_lock_irqsave(&priv->lock, flags); 931 - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); 932 - 933 - clear_bit(STATUS_RF_KILL_SW, &priv->status); 934 - spin_unlock_irqrestore(&priv->lock, flags); 935 - 936 - /* wake up ucode */ 937 - msleep(10); 938 - 939 - spin_lock_irqsave(&priv->lock, flags); 940 - iwl_read32(priv, CSR_UCODE_DRV_GP1); 941 - if (!iwl_grab_nic_access(priv)) 942 - iwl_release_nic_access(priv); 943 - spin_unlock_irqrestore(&priv->lock, flags); 944 - 945 - if (test_bit(STATUS_RF_KILL_HW, &priv->status)) { 946 - IWL_DEBUG_RF_KILL("Can not turn radio back on - " 947 - "disabled by HW switch\n"); 948 - return; 949 - } 950 - 951 - queue_work(priv->workqueue, &priv->restart); 952 - return; 953 1273 } 954 1274 955 1275 #define IWL_PACKET_RETRY_TIME HZ ··· 1225 1661 iwl4965_send_beacon_cmd(priv); 1226 1662 } 1227 1663 1664 + /** 1665 + * iwl4965_bg_statistics_periodic - Timer callback to queue statistics 1666 + * 1667 + * This callback is provided in order to send a statistics request. 1668 + * 1669 + * This timer function is continually reset to execute within 1670 + * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION 1671 + * was received. We need to ensure we receive the statistics in order 1672 + * to update the temperature used for calibrating the TXPOWER. 1673 + */ 1674 + static void iwl4965_bg_statistics_periodic(unsigned long data) 1675 + { 1676 + struct iwl_priv *priv = (struct iwl_priv *)data; 1677 + 1678 + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 1679 + return; 1680 + 1681 + iwl_send_statistics_request(priv, CMD_ASYNC); 1682 + } 1683 + 1228 1684 static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, 1229 1685 struct iwl_rx_mem_buffer *rxb) 1230 1686 { 1231 1687 #ifdef CONFIG_IWLWIFI_DEBUG 1232 1688 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1233 1689 struct iwl4965_beacon_notif *beacon = &(pkt->u.beacon_status); 1234 - u8 rate = iwl4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); 1690 + u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); 1235 1691 1236 1692 IWL_DEBUG_RX("beacon status %x retries %d iss %d " 1237 1693 "tsf %d %d rate %d\n", 1238 - le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, 1694 + le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, 1239 1695 beacon->beacon_notify_hdr.failure_frame, 1240 1696 le32_to_cpu(beacon->ibss_mgr_status), 1241 1697 le32_to_cpu(beacon->high_tsf), ··· 1265 1681 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) && 1266 1682 (!test_bit(STATUS_EXIT_PENDING, &priv->status))) 1267 1683 queue_work(priv->workqueue, &priv->beacon_update); 1268 - } 1269 - 1270 - /* Service response to REPLY_SCAN_CMD (0x80) */ 1271 - static void iwl4965_rx_reply_scan(struct iwl_priv *priv, 1272 - struct iwl_rx_mem_buffer *rxb) 1273 - { 1274 - #ifdef CONFIG_IWLWIFI_DEBUG 1275 - struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1276 - struct iwl4965_scanreq_notification *notif = 1277 - (struct iwl4965_scanreq_notification *)pkt->u.raw; 1278 - 1279 - IWL_DEBUG_RX("Scan request status = 0x%x\n", notif->status); 1280 - #endif 1281 - } 1282 - 1283 - /* Service SCAN_START_NOTIFICATION (0x82) */ 1284 - static void iwl4965_rx_scan_start_notif(struct iwl_priv *priv, 1285 - struct iwl_rx_mem_buffer *rxb) 1286 - { 1287 - struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1288 - struct iwl4965_scanstart_notification *notif = 1289 - (struct iwl4965_scanstart_notification *)pkt->u.raw; 1290 - priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); 1291 - IWL_DEBUG_SCAN("Scan start: " 1292 - "%d [802.11%s] " 1293 - "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", 1294 - notif->channel, 1295 - notif->band ? "bg" : "a", 1296 - notif->tsf_high, 1297 - notif->tsf_low, notif->status, notif->beacon_timer); 1298 - } 1299 - 1300 - /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ 1301 - static void iwl4965_rx_scan_results_notif(struct iwl_priv *priv, 1302 - struct iwl_rx_mem_buffer *rxb) 1303 - { 1304 - struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1305 - struct iwl4965_scanresults_notification *notif = 1306 - (struct iwl4965_scanresults_notification *)pkt->u.raw; 1307 - 1308 - IWL_DEBUG_SCAN("Scan ch.res: " 1309 - "%d [802.11%s] " 1310 - "(TSF: 0x%08X:%08X) - %d " 1311 - "elapsed=%lu usec (%dms since last)\n", 1312 - notif->channel, 1313 - notif->band ? "bg" : "a", 1314 - le32_to_cpu(notif->tsf_high), 1315 - le32_to_cpu(notif->tsf_low), 1316 - le32_to_cpu(notif->statistics[0]), 1317 - le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf, 1318 - jiffies_to_msecs(elapsed_jiffies 1319 - (priv->last_scan_jiffies, jiffies))); 1320 - 1321 - priv->last_scan_jiffies = jiffies; 1322 - priv->next_scan_jiffies = 0; 1323 - } 1324 - 1325 - /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ 1326 - static void iwl4965_rx_scan_complete_notif(struct iwl_priv *priv, 1327 - struct iwl_rx_mem_buffer *rxb) 1328 - { 1329 - struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1330 - struct iwl4965_scancomplete_notification *scan_notif = (void *)pkt->u.raw; 1331 - 1332 - IWL_DEBUG_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", 1333 - scan_notif->scanned_channels, 1334 - scan_notif->tsf_low, 1335 - scan_notif->tsf_high, scan_notif->status); 1336 - 1337 - /* The HW is no longer scanning */ 1338 - clear_bit(STATUS_SCAN_HW, &priv->status); 1339 - 1340 - /* The scan completion notification came in, so kill that timer... */ 1341 - cancel_delayed_work(&priv->scan_check); 1342 - 1343 - IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", 1344 - (priv->scan_bands == 2) ? "2.4" : "5.2", 1345 - jiffies_to_msecs(elapsed_jiffies 1346 - (priv->scan_pass_start, jiffies))); 1347 - 1348 - /* Remove this scanned band from the list 1349 - * of pending bands to scan */ 1350 - priv->scan_bands--; 1351 - 1352 - /* If a request to abort was given, or the scan did not succeed 1353 - * then we reset the scan state machine and terminate, 1354 - * re-queuing another scan if one has been requested */ 1355 - if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 1356 - IWL_DEBUG_INFO("Aborted scan completed.\n"); 1357 - clear_bit(STATUS_SCAN_ABORTING, &priv->status); 1358 - } else { 1359 - /* If there are more bands on this scan pass reschedule */ 1360 - if (priv->scan_bands > 0) 1361 - goto reschedule; 1362 - } 1363 - 1364 - priv->last_scan_jiffies = jiffies; 1365 - priv->next_scan_jiffies = 0; 1366 - IWL_DEBUG_INFO("Setting scan to off\n"); 1367 - 1368 - clear_bit(STATUS_SCANNING, &priv->status); 1369 - 1370 - IWL_DEBUG_INFO("Scan took %dms\n", 1371 - jiffies_to_msecs(elapsed_jiffies(priv->scan_start, jiffies))); 1372 - 1373 - queue_work(priv->workqueue, &priv->scan_completed); 1374 - 1375 - return; 1376 - 1377 - reschedule: 1378 - priv->scan_pass_start = jiffies; 1379 - queue_work(priv->workqueue, &priv->request_scan); 1380 1684 } 1381 1685 1382 1686 /* Handle notification from uCode that card's power state is changing ··· 1327 1855 clear_bit(STATUS_RF_KILL_SW, &priv->status); 1328 1856 1329 1857 if (!(flags & RXON_CARD_DISABLED)) 1330 - iwl4965_scan_cancel(priv); 1858 + iwl_scan_cancel(priv); 1331 1859 1332 1860 if ((test_bit(STATUS_RF_KILL_HW, &status) != 1333 1861 test_bit(STATUS_RF_KILL_HW, &priv->status)) || ··· 1377 1905 */ 1378 1906 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_hw_rx_statistics; 1379 1907 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_hw_rx_statistics; 1380 - /* scan handlers */ 1381 - priv->rx_handlers[REPLY_SCAN_CMD] = iwl4965_rx_reply_scan; 1382 - priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl4965_rx_scan_start_notif; 1383 - priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = 1384 - iwl4965_rx_scan_results_notif; 1385 - priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = 1386 - iwl4965_rx_scan_complete_notif; 1908 + 1909 + iwl_setup_rx_scan_handlers(priv); 1910 + 1387 1911 /* status change handler */ 1388 1912 priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif; 1389 1913 ··· 1516 2048 /* Backtrack one entry */ 1517 2049 priv->rxq.read = i; 1518 2050 iwl_rx_queue_restock(priv); 1519 - } 1520 - /* Convert linear signal-to-noise ratio into dB */ 1521 - static u8 ratio2dB[100] = { 1522 - /* 0 1 2 3 4 5 6 7 8 9 */ 1523 - 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ 1524 - 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ 1525 - 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ 1526 - 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ 1527 - 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ 1528 - 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ 1529 - 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ 1530 - 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ 1531 - 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ 1532 - 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ 1533 - }; 1534 - 1535 - /* Calculates a relative dB value from a ratio of linear 1536 - * (i.e. not dB) signal levels. 1537 - * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ 1538 - int iwl4965_calc_db_from_ratio(int sig_ratio) 1539 - { 1540 - /* 1000:1 or higher just report as 60 dB */ 1541 - if (sig_ratio >= 1000) 1542 - return 60; 1543 - 1544 - /* 100:1 or higher, divide by 10 and use table, 1545 - * add 20 dB to make up for divide by 10 */ 1546 - if (sig_ratio >= 100) 1547 - return (20 + (int)ratio2dB[sig_ratio/10]); 1548 - 1549 - /* We shouldn't see this */ 1550 - if (sig_ratio < 1) 1551 - return 0; 1552 - 1553 - /* Use table for ratios 1:1 - 99:1 */ 1554 - return (int)ratio2dB[sig_ratio]; 1555 2051 } 1556 2052 1557 2053 #define PERFECT_RSSI (-20) /* dBm */ ··· 1891 2459 return IRQ_NONE; 1892 2460 } 1893 2461 1894 - /* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after 1895 - * sending probe req. This should be set long enough to hear probe responses 1896 - * from more than one AP. */ 1897 - #define IWL_ACTIVE_DWELL_TIME_24 (20) /* all times in msec */ 1898 - #define IWL_ACTIVE_DWELL_TIME_52 (10) 1899 - 1900 - /* For faster active scanning, scan will move to the next channel if fewer than 1901 - * PLCP_QUIET_THRESH packets are heard on this channel within 1902 - * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell 1903 - * time if it's a quiet channel (nothing responded to our probe, and there's 1904 - * no other traffic). 1905 - * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ 1906 - #define IWL_PLCP_QUIET_THRESH __constant_cpu_to_le16(1) /* packets */ 1907 - #define IWL_ACTIVE_QUIET_TIME __constant_cpu_to_le16(5) /* msec */ 1908 - 1909 - /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. 1910 - * Must be set longer than active dwell time. 1911 - * For the most reliable scan, set > AP beacon interval (typically 100msec). */ 1912 - #define IWL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ 1913 - #define IWL_PASSIVE_DWELL_TIME_52 (10) 1914 - #define IWL_PASSIVE_DWELL_BASE (100) 1915 - #define IWL_CHANNEL_TUNE_TIME 5 1916 - 1917 - static inline u16 iwl4965_get_active_dwell_time(struct iwl_priv *priv, 1918 - enum ieee80211_band band) 1919 - { 1920 - if (band == IEEE80211_BAND_5GHZ) 1921 - return IWL_ACTIVE_DWELL_TIME_52; 1922 - else 1923 - return IWL_ACTIVE_DWELL_TIME_24; 1924 - } 1925 - 1926 - static u16 iwl4965_get_passive_dwell_time(struct iwl_priv *priv, 1927 - enum ieee80211_band band) 1928 - { 1929 - u16 active = iwl4965_get_active_dwell_time(priv, band); 1930 - u16 passive = (band != IEEE80211_BAND_5GHZ) ? 1931 - IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : 1932 - IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; 1933 - 1934 - if (iwl_is_associated(priv)) { 1935 - /* If we're associated, we clamp the maximum passive 1936 - * dwell time to be 98% of the beacon interval (minus 1937 - * 2 * channel tune time) */ 1938 - passive = priv->beacon_int; 1939 - if ((passive > IWL_PASSIVE_DWELL_BASE) || !passive) 1940 - passive = IWL_PASSIVE_DWELL_BASE; 1941 - passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2; 1942 - } 1943 - 1944 - if (passive <= active) 1945 - passive = active + 1; 1946 - 1947 - return passive; 1948 - } 1949 - 1950 - static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, 1951 - enum ieee80211_band band, 1952 - u8 is_active, u8 direct_mask, 1953 - struct iwl4965_scan_channel *scan_ch) 1954 - { 1955 - const struct ieee80211_channel *channels = NULL; 1956 - const struct ieee80211_supported_band *sband; 1957 - const struct iwl_channel_info *ch_info; 1958 - u16 passive_dwell = 0; 1959 - u16 active_dwell = 0; 1960 - int added, i; 1961 - 1962 - sband = iwl_get_hw_mode(priv, band); 1963 - if (!sband) 1964 - return 0; 1965 - 1966 - channels = sband->channels; 1967 - 1968 - active_dwell = iwl4965_get_active_dwell_time(priv, band); 1969 - passive_dwell = iwl4965_get_passive_dwell_time(priv, band); 1970 - 1971 - for (i = 0, added = 0; i < sband->n_channels; i++) { 1972 - if (channels[i].flags & IEEE80211_CHAN_DISABLED) 1973 - continue; 1974 - 1975 - scan_ch->channel = ieee80211_frequency_to_channel(channels[i].center_freq); 1976 - 1977 - ch_info = iwl_get_channel_info(priv, band, 1978 - scan_ch->channel); 1979 - if (!is_channel_valid(ch_info)) { 1980 - IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", 1981 - scan_ch->channel); 1982 - continue; 1983 - } 1984 - 1985 - if (!is_active || is_channel_passive(ch_info) || 1986 - (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) 1987 - scan_ch->type = 0; /* passive */ 1988 - else 1989 - scan_ch->type = 1; /* active */ 1990 - 1991 - if (scan_ch->type & 1) 1992 - scan_ch->type |= (direct_mask << 1); 1993 - 1994 - scan_ch->active_dwell = cpu_to_le16(active_dwell); 1995 - scan_ch->passive_dwell = cpu_to_le16(passive_dwell); 1996 - 1997 - /* Set txpower levels to defaults */ 1998 - scan_ch->tpc.dsp_atten = 110; 1999 - /* scan_pwr_info->tpc.dsp_atten; */ 2000 - 2001 - /*scan_pwr_info->tpc.tx_gain; */ 2002 - if (band == IEEE80211_BAND_5GHZ) 2003 - scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; 2004 - else { 2005 - scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); 2006 - /* NOTE: if we were doing 6Mb OFDM for scans we'd use 2007 - * power level: 2008 - * scan_ch->tpc.tx_gain = ((1 << 5) | (2 << 3)) | 3; 2009 - */ 2010 - } 2011 - 2012 - IWL_DEBUG_SCAN("Scanning %d [%s %d]\n", 2013 - scan_ch->channel, 2014 - (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", 2015 - (scan_ch->type & 1) ? 2016 - active_dwell : passive_dwell); 2017 - 2018 - scan_ch++; 2019 - added++; 2020 - } 2021 - 2022 - IWL_DEBUG_SCAN("total channels to scan %d \n", added); 2023 - return added; 2024 - } 2025 - 2026 2462 /****************************************************************************** 2027 2463 * 2028 2464 * uCode download functions ··· 1921 2621 */ 1922 2622 static int iwl4965_read_ucode(struct iwl_priv *priv) 1923 2623 { 1924 - struct iwl4965_ucode *ucode; 2624 + struct iwl_ucode *ucode; 1925 2625 int ret; 1926 2626 const struct firmware *ucode_raw; 1927 2627 const char *name = priv->cfg->fw_name; ··· 2149 2849 /* After the ALIVE response, we can send host commands to 4965 uCode */ 2150 2850 set_bit(STATUS_ALIVE, &priv->status); 2151 2851 2152 - /* Clear out the uCode error bit if it is set */ 2153 - clear_bit(STATUS_FW_ERROR, &priv->status); 2154 - 2155 2852 if (iwl_is_rfkill(priv)) 2156 2853 return; 2157 2854 ··· 2179 2882 iwl4965_commit_rxon(priv); 2180 2883 2181 2884 /* At this point, the NIC is initialized and operational */ 2182 - iwl4965_rf_kill_ct_config(priv); 2885 + iwl_rf_kill_ct_config(priv); 2183 2886 2184 2887 iwl_leds_register(priv); 2185 2888 ··· 2190 2893 if (priv->error_recovering) 2191 2894 iwl4965_error_recovery(priv); 2192 2895 2193 - iwlcore_low_level_notify(priv, IWLCORE_START_EVT); 2896 + iwl_power_update_mode(priv, 1); 2194 2897 ieee80211_notify_mac(priv->hw, IEEE80211_NOTIFY_RE_ASSOC); 2898 + 2899 + if (test_and_clear_bit(STATUS_MODE_PENDING, &priv->status)) 2900 + iwl4965_set_mode(priv, priv->iw_mode); 2901 + 2195 2902 return; 2196 2903 2197 2904 restart: 2198 2905 queue_work(priv->workqueue, &priv->restart); 2199 2906 } 2200 2907 2201 - static void iwl4965_cancel_deferred_work(struct iwl_priv *priv); 2908 + static void iwl_cancel_deferred_work(struct iwl_priv *priv); 2202 2909 2203 2910 static void __iwl4965_down(struct iwl_priv *priv) 2204 2911 { ··· 2215 2914 set_bit(STATUS_EXIT_PENDING, &priv->status); 2216 2915 2217 2916 iwl_leds_unregister(priv); 2218 - 2219 - iwlcore_low_level_notify(priv, IWLCORE_STOP_EVT); 2220 2917 2221 2918 iwlcore_clear_stations_table(priv); 2222 2919 ··· 2304 3005 __iwl4965_down(priv); 2305 3006 mutex_unlock(&priv->mutex); 2306 3007 2307 - iwl4965_cancel_deferred_work(priv); 3008 + iwl_cancel_deferred_work(priv); 2308 3009 } 2309 3010 2310 3011 #define MAX_HW_RESTARTS 5 ··· 2317 3018 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { 2318 3019 IWL_WARNING("Exit pending; will not bring the NIC up\n"); 2319 3020 return -EIO; 2320 - } 2321 - 2322 - if (test_bit(STATUS_RF_KILL_SW, &priv->status)) { 2323 - IWL_WARNING("Radio disabled by SW RF kill (module " 2324 - "parameter)\n"); 2325 - iwl_rfkill_set_hw_state(priv); 2326 - return -ENODEV; 2327 3021 } 2328 3022 2329 3023 if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) { ··· 2372 3080 priv->ucode_data.len); 2373 3081 2374 3082 /* We return success when we resume from suspend and rf_kill is on. */ 2375 - if (test_bit(STATUS_RF_KILL_HW, &priv->status)) 3083 + if (test_bit(STATUS_RF_KILL_HW, &priv->status) || 3084 + test_bit(STATUS_RF_KILL_SW, &priv->status)) 2376 3085 return 0; 2377 3086 2378 3087 for (i = 0; i < MAX_HW_RESTARTS; i++) { ··· 2390 3097 continue; 2391 3098 } 2392 3099 3100 + /* Clear out the uCode error bit if it is set */ 3101 + clear_bit(STATUS_FW_ERROR, &priv->status); 3102 + 2393 3103 /* start card; "initialize" will load runtime ucode */ 2394 3104 iwl4965_nic_start(priv); 2395 3105 ··· 2403 3107 2404 3108 set_bit(STATUS_EXIT_PENDING, &priv->status); 2405 3109 __iwl4965_down(priv); 3110 + clear_bit(STATUS_EXIT_PENDING, &priv->status); 2406 3111 2407 3112 /* tried to restart and config the device for as long as our 2408 3113 * patience could withstand */ ··· 2483 3186 { 2484 3187 struct iwl_priv *priv = container_of(work, 2485 3188 struct iwl_priv, set_monitor); 3189 + int ret; 2486 3190 2487 3191 IWL_DEBUG(IWL_DL_STATE, "setting monitor mode\n"); 2488 3192 2489 3193 mutex_lock(&priv->mutex); 2490 3194 2491 - if (!iwl_is_ready(priv)) 2492 - IWL_DEBUG(IWL_DL_STATE, "leave - not ready\n"); 2493 - else 2494 - if (iwl4965_set_mode(priv, IEEE80211_IF_TYPE_MNTR) != 0) 2495 - IWL_ERROR("iwl4965_set_mode() failed\n"); 3195 + ret = iwl4965_set_mode(priv, IEEE80211_IF_TYPE_MNTR); 3196 + 3197 + if (ret) { 3198 + if (ret == -EAGAIN) 3199 + IWL_DEBUG(IWL_DL_STATE, "leave - not ready\n"); 3200 + else 3201 + IWL_ERROR("iwl4965_set_mode() failed ret = %d\n", ret); 3202 + } 2496 3203 2497 3204 mutex_unlock(&priv->mutex); 2498 3205 } 2499 3206 2500 - #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) 2501 - 2502 - static void iwl4965_bg_scan_check(struct work_struct *data) 3207 + static void iwl_bg_run_time_calib_work(struct work_struct *work) 2503 3208 { 2504 - struct iwl_priv *priv = 2505 - container_of(data, struct iwl_priv, scan_check.work); 3209 + struct iwl_priv *priv = container_of(work, struct iwl_priv, 3210 + run_time_calib_work); 2506 3211 2507 - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3212 + mutex_lock(&priv->mutex); 3213 + 3214 + if (test_bit(STATUS_EXIT_PENDING, &priv->status) || 3215 + test_bit(STATUS_SCANNING, &priv->status)) { 3216 + mutex_unlock(&priv->mutex); 2508 3217 return; 2509 - 2510 - mutex_lock(&priv->mutex); 2511 - if (test_bit(STATUS_SCANNING, &priv->status) || 2512 - test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 2513 - IWL_DEBUG(IWL_DL_SCAN, "Scan completion watchdog resetting " 2514 - "adapter (%dms)\n", 2515 - jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); 2516 - 2517 - if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) 2518 - iwl4965_send_scan_abort(priv); 2519 - } 2520 - mutex_unlock(&priv->mutex); 2521 - } 2522 - 2523 - static void iwl4965_bg_request_scan(struct work_struct *data) 2524 - { 2525 - struct iwl_priv *priv = 2526 - container_of(data, struct iwl_priv, request_scan); 2527 - struct iwl_host_cmd cmd = { 2528 - .id = REPLY_SCAN_CMD, 2529 - .len = sizeof(struct iwl4965_scan_cmd), 2530 - .meta.flags = CMD_SIZE_HUGE, 2531 - }; 2532 - struct iwl4965_scan_cmd *scan; 2533 - struct ieee80211_conf *conf = NULL; 2534 - u16 cmd_len; 2535 - enum ieee80211_band band; 2536 - u8 direct_mask; 2537 - int ret = 0; 2538 - 2539 - conf = ieee80211_get_hw_conf(priv->hw); 2540 - 2541 - mutex_lock(&priv->mutex); 2542 - 2543 - if (!iwl_is_ready(priv)) { 2544 - IWL_WARNING("request scan called when driver not ready.\n"); 2545 - goto done; 2546 3218 } 2547 3219 2548 - /* Make sure the scan wasn't cancelled before this queued work 2549 - * was given the chance to run... */ 2550 - if (!test_bit(STATUS_SCANNING, &priv->status)) 2551 - goto done; 3220 + if (priv->start_calib) { 3221 + iwl_chain_noise_calibration(priv, &priv->statistics); 2552 3222 2553 - /* This should never be called or scheduled if there is currently 2554 - * a scan active in the hardware. */ 2555 - if (test_bit(STATUS_SCAN_HW, &priv->status)) { 2556 - IWL_DEBUG_INFO("Multiple concurrent scan requests in parallel. " 2557 - "Ignoring second request.\n"); 2558 - ret = -EIO; 2559 - goto done; 3223 + iwl_sensitivity_calibration(priv, &priv->statistics); 2560 3224 } 2561 - 2562 - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { 2563 - IWL_DEBUG_SCAN("Aborting scan due to device shutdown\n"); 2564 - goto done; 2565 - } 2566 - 2567 - if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 2568 - IWL_DEBUG_HC("Scan request while abort pending. Queuing.\n"); 2569 - goto done; 2570 - } 2571 - 2572 - if (iwl_is_rfkill(priv)) { 2573 - IWL_DEBUG_HC("Aborting scan due to RF Kill activation\n"); 2574 - goto done; 2575 - } 2576 - 2577 - if (!test_bit(STATUS_READY, &priv->status)) { 2578 - IWL_DEBUG_HC("Scan request while uninitialized. Queuing.\n"); 2579 - goto done; 2580 - } 2581 - 2582 - if (!priv->scan_bands) { 2583 - IWL_DEBUG_HC("Aborting scan due to no requested bands\n"); 2584 - goto done; 2585 - } 2586 - 2587 - if (!priv->scan) { 2588 - priv->scan = kmalloc(sizeof(struct iwl4965_scan_cmd) + 2589 - IWL_MAX_SCAN_SIZE, GFP_KERNEL); 2590 - if (!priv->scan) { 2591 - ret = -ENOMEM; 2592 - goto done; 2593 - } 2594 - } 2595 - scan = priv->scan; 2596 - memset(scan, 0, sizeof(struct iwl4965_scan_cmd) + IWL_MAX_SCAN_SIZE); 2597 - 2598 - scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; 2599 - scan->quiet_time = IWL_ACTIVE_QUIET_TIME; 2600 - 2601 - if (iwl_is_associated(priv)) { 2602 - u16 interval = 0; 2603 - u32 extra; 2604 - u32 suspend_time = 100; 2605 - u32 scan_suspend_time = 100; 2606 - unsigned long flags; 2607 - 2608 - IWL_DEBUG_INFO("Scanning while associated...\n"); 2609 - 2610 - spin_lock_irqsave(&priv->lock, flags); 2611 - interval = priv->beacon_int; 2612 - spin_unlock_irqrestore(&priv->lock, flags); 2613 - 2614 - scan->suspend_time = 0; 2615 - scan->max_out_time = cpu_to_le32(200 * 1024); 2616 - if (!interval) 2617 - interval = suspend_time; 2618 - 2619 - extra = (suspend_time / interval) << 22; 2620 - scan_suspend_time = (extra | 2621 - ((suspend_time % interval) * 1024)); 2622 - scan->suspend_time = cpu_to_le32(scan_suspend_time); 2623 - IWL_DEBUG_SCAN("suspend_time 0x%X beacon interval %d\n", 2624 - scan_suspend_time, interval); 2625 - } 2626 - 2627 - /* We should add the ability for user to lock to PASSIVE ONLY */ 2628 - if (priv->one_direct_scan) { 2629 - IWL_DEBUG_SCAN 2630 - ("Kicking off one direct scan for '%s'\n", 2631 - iwl4965_escape_essid(priv->direct_ssid, 2632 - priv->direct_ssid_len)); 2633 - scan->direct_scan[0].id = WLAN_EID_SSID; 2634 - scan->direct_scan[0].len = priv->direct_ssid_len; 2635 - memcpy(scan->direct_scan[0].ssid, 2636 - priv->direct_ssid, priv->direct_ssid_len); 2637 - direct_mask = 1; 2638 - } else if (!iwl_is_associated(priv) && priv->essid_len) { 2639 - IWL_DEBUG_SCAN 2640 - ("Kicking off one direct scan for '%s' when not associated\n", 2641 - iwl4965_escape_essid(priv->essid, priv->essid_len)); 2642 - scan->direct_scan[0].id = WLAN_EID_SSID; 2643 - scan->direct_scan[0].len = priv->essid_len; 2644 - memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); 2645 - direct_mask = 1; 2646 - } else { 2647 - IWL_DEBUG_SCAN("Kicking off one indirect scan.\n"); 2648 - direct_mask = 0; 2649 - } 2650 - 2651 - scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; 2652 - scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id; 2653 - scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 2654 - 2655 - 2656 - switch (priv->scan_bands) { 2657 - case 2: 2658 - scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; 2659 - scan->tx_cmd.rate_n_flags = 2660 - iwl4965_hw_set_rate_n_flags(IWL_RATE_1M_PLCP, 2661 - RATE_MCS_ANT_B_MSK|RATE_MCS_CCK_MSK); 2662 - 2663 - scan->good_CRC_th = 0; 2664 - band = IEEE80211_BAND_2GHZ; 2665 - break; 2666 - 2667 - case 1: 2668 - scan->tx_cmd.rate_n_flags = 2669 - iwl4965_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, 2670 - RATE_MCS_ANT_B_MSK); 2671 - scan->good_CRC_th = IWL_GOOD_CRC_TH; 2672 - band = IEEE80211_BAND_5GHZ; 2673 - break; 2674 - 2675 - default: 2676 - IWL_WARNING("Invalid scan band count\n"); 2677 - goto done; 2678 - } 2679 - 2680 - /* We don't build a direct scan probe request; the uCode will do 2681 - * that based on the direct_mask added to each channel entry */ 2682 - cmd_len = iwl4965_fill_probe_req(priv, band, 2683 - (struct ieee80211_mgmt *)scan->data, 2684 - IWL_MAX_SCAN_SIZE - sizeof(*scan), 0); 2685 - 2686 - scan->tx_cmd.len = cpu_to_le16(cmd_len); 2687 - /* select Rx chains */ 2688 - 2689 - /* Force use of chains B and C (0x6) for scan Rx. 2690 - * Avoid A (0x1) because of its off-channel reception on A-band. 2691 - * MIMO is not used here, but value is required to make uCode happy. */ 2692 - scan->rx_chain = RXON_RX_CHAIN_DRIVER_FORCE_MSK | 2693 - cpu_to_le16((0x7 << RXON_RX_CHAIN_VALID_POS) | 2694 - (0x6 << RXON_RX_CHAIN_FORCE_SEL_POS) | 2695 - (0x7 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS)); 2696 - 2697 - if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) 2698 - scan->filter_flags = RXON_FILTER_PROMISC_MSK; 2699 - 2700 - if (direct_mask) 2701 - scan->channel_count = 2702 - iwl4965_get_channels_for_scan( 2703 - priv, band, 1, /* active */ 2704 - direct_mask, 2705 - (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 2706 - else 2707 - scan->channel_count = 2708 - iwl4965_get_channels_for_scan( 2709 - priv, band, 0, /* passive */ 2710 - direct_mask, 2711 - (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 2712 - 2713 - scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | 2714 - RXON_FILTER_BCON_AWARE_MSK); 2715 - cmd.len += le16_to_cpu(scan->tx_cmd.len) + 2716 - scan->channel_count * sizeof(struct iwl4965_scan_channel); 2717 - cmd.data = scan; 2718 - scan->len = cpu_to_le16(cmd.len); 2719 - 2720 - set_bit(STATUS_SCAN_HW, &priv->status); 2721 - ret = iwl_send_cmd_sync(priv, &cmd); 2722 - if (ret) 2723 - goto done; 2724 - 2725 - queue_delayed_work(priv->workqueue, &priv->scan_check, 2726 - IWL_SCAN_CHECK_WATCHDOG); 2727 3225 2728 3226 mutex_unlock(&priv->mutex); 2729 3227 return; 2730 - 2731 - done: 2732 - /* inform mac80211 scan aborted */ 2733 - queue_work(priv->workqueue, &priv->scan_completed); 2734 - mutex_unlock(&priv->mutex); 2735 3228 } 2736 3229 2737 3230 static void iwl4965_bg_up(struct work_struct *data) ··· 2585 3498 if (!priv->vif || !priv->is_open) 2586 3499 return; 2587 3500 2588 - iwl4965_scan_cancel_timeout(priv, 200); 3501 + iwl_scan_cancel_timeout(priv, 200); 2589 3502 2590 3503 conf = ieee80211_get_hw_conf(priv->hw); 2591 3504 ··· 2602 3515 2603 3516 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 2604 3517 2605 - #ifdef CONFIG_IWL4965_HT 2606 3518 if (priv->current_ht_config.is_ht) 2607 3519 iwl_set_rxon_ht(priv, &priv->current_ht_config); 2608 - #endif /* CONFIG_IWL4965_HT*/ 3520 + 2609 3521 iwl_set_rxon_chain(priv); 2610 3522 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 2611 3523 ··· 2636 3550 2637 3551 case IEEE80211_IF_TYPE_IBSS: 2638 3552 2639 - /* clear out the station table */ 2640 - iwlcore_clear_stations_table(priv); 3553 + /* assume default assoc id */ 3554 + priv->assoc_id = 1; 2641 3555 2642 - iwl_rxon_add_station(priv, iwl_bcast_addr, 0); 2643 3556 iwl_rxon_add_station(priv, priv->bssid, 0); 2644 3557 iwl4965_rate_scale_init(priv->hw, IWL_STA_ID); 2645 3558 iwl4965_send_beacon_cmd(priv); ··· 2679 3594 2680 3595 } 2681 3596 2682 - static void iwl4965_bg_abort_scan(struct work_struct *work) 2683 - { 2684 - struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); 2685 - 2686 - if (!iwl_is_ready(priv)) 2687 - return; 2688 - 2689 - mutex_lock(&priv->mutex); 2690 - 2691 - set_bit(STATUS_SCAN_ABORTING, &priv->status); 2692 - iwl4965_send_scan_abort(priv); 2693 - 2694 - mutex_unlock(&priv->mutex); 2695 - } 2696 - 2697 3597 static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf); 2698 3598 2699 - static void iwl4965_bg_scan_completed(struct work_struct *work) 3599 + static void iwl_bg_scan_completed(struct work_struct *work) 2700 3600 { 2701 3601 struct iwl_priv *priv = 2702 3602 container_of(work, struct iwl_priv, scan_completed); 2703 3603 2704 - IWL_DEBUG(IWL_DL_SCAN, "SCAN complete scan\n"); 3604 + IWL_DEBUG_SCAN("SCAN complete scan\n"); 2705 3605 2706 3606 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2707 3607 return; ··· 2699 3629 /* Since setting the TXPOWER may have been deferred while 2700 3630 * performing the scan, fire one off */ 2701 3631 mutex_lock(&priv->mutex); 2702 - iwl4965_hw_reg_send_txpower(priv); 3632 + iwl_set_tx_power(priv, priv->tx_power_user_lmt, true); 2703 3633 mutex_unlock(&priv->mutex); 2704 3634 } 2705 3635 ··· 2808 3738 * RXON_FILTER_ASSOC_MSK BIT 2809 3739 */ 2810 3740 mutex_lock(&priv->mutex); 2811 - iwl4965_scan_cancel_timeout(priv, 100); 3741 + iwl_scan_cancel_timeout(priv, 100); 2812 3742 cancel_delayed_work(&priv->post_associate); 2813 3743 mutex_unlock(&priv->mutex); 2814 3744 } ··· 2871 3801 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN); 2872 3802 } 2873 3803 2874 - if (iwl_is_ready(priv)) 2875 - iwl4965_set_mode(priv, conf->type); 3804 + if (iwl4965_set_mode(priv, conf->type) == -EAGAIN) 3805 + /* we are not ready, will run again when ready */ 3806 + set_bit(STATUS_MODE_PENDING, &priv->status); 2876 3807 2877 3808 mutex_unlock(&priv->mutex); 2878 3809 ··· 2901 3830 2902 3831 priv->add_radiotap = !!(conf->flags & IEEE80211_CONF_RADIOTAP); 2903 3832 3833 + if (conf->radio_enabled && iwl_radio_kill_sw_enable_radio(priv)) { 3834 + IWL_DEBUG_MAC80211("leave - RF-KILL - waiting for uCode\n"); 3835 + goto out; 3836 + } 3837 + 3838 + if (!conf->radio_enabled) 3839 + iwl_radio_kill_sw_disable_radio(priv); 3840 + 2904 3841 if (!iwl_is_ready(priv)) { 2905 3842 IWL_DEBUG_MAC80211("leave - not ready\n"); 2906 3843 ret = -EIO; ··· 2931 3852 goto out; 2932 3853 } 2933 3854 3855 + if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS && 3856 + !is_channel_ibss(ch_info)) { 3857 + IWL_ERROR("channel %d in band %d not IBSS channel\n", 3858 + conf->channel->hw_value, conf->channel->band); 3859 + ret = -EINVAL; 3860 + goto out; 3861 + } 3862 + 2934 3863 spin_lock_irqsave(&priv->lock, flags); 2935 3864 2936 - #ifdef CONFIG_IWL4965_HT 2937 3865 /* if we are switching from ht to 2.4 clear flags 2938 3866 * from any ht related info since 2.4 does not 2939 3867 * support ht */ ··· 2950 3864 #endif 2951 3865 ) 2952 3866 priv->staging_rxon.flags = 0; 2953 - #endif /* CONFIG_IWL4965_HT */ 2954 3867 2955 3868 iwl_set_rxon_channel(priv, conf->channel->band, channel); 2956 3869 ··· 2969 3884 } 2970 3885 #endif 2971 3886 2972 - if (priv->cfg->ops->lib->radio_kill_sw) 2973 - priv->cfg->ops->lib->radio_kill_sw(priv, !conf->radio_enabled); 2974 - 2975 3887 if (!conf->radio_enabled) { 2976 3888 IWL_DEBUG_MAC80211("leave - radio disabled\n"); 2977 3889 goto out; ··· 2979 3897 ret = -EIO; 2980 3898 goto out; 2981 3899 } 3900 + 3901 + IWL_DEBUG_MAC80211("TX Power old=%d new=%d\n", 3902 + priv->tx_power_user_lmt, conf->power_level); 3903 + 3904 + iwl_set_tx_power(priv, conf->power_level, false); 2982 3905 2983 3906 iwl4965_set_rate(priv); 2984 3907 ··· 3121 4034 !is_multicast_ether_addr(conf->bssid)) { 3122 4035 /* If there is currently a HW scan going on in the background 3123 4036 * then we need to cancel it else the RXON below will fail. */ 3124 - if (iwl4965_scan_cancel_timeout(priv, 100)) { 4037 + if (iwl_scan_cancel_timeout(priv, 100)) { 3125 4038 IWL_WARNING("Aborted scan still in progress " 3126 4039 "after 100ms\n"); 3127 4040 IWL_DEBUG_MAC80211("leaving - scan abort failed.\n"); ··· 3146 4059 } 3147 4060 3148 4061 } else { 3149 - iwl4965_scan_cancel_timeout(priv, 100); 4062 + iwl_scan_cancel_timeout(priv, 100); 3150 4063 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3151 4064 iwl4965_commit_rxon(priv); 3152 4065 } ··· 3204 4117 mutex_lock(&priv->mutex); 3205 4118 3206 4119 if (iwl_is_ready_rf(priv)) { 3207 - iwl4965_scan_cancel_timeout(priv, 100); 4120 + iwl_scan_cancel_timeout(priv, 100); 3208 4121 cancel_delayed_work(&priv->post_associate); 3209 4122 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3210 4123 iwl4965_commit_rxon(priv); ··· 3318 4231 } 3319 4232 if (len) { 3320 4233 IWL_DEBUG_SCAN("direct scan for %s [%d]\n ", 3321 - iwl4965_escape_essid(ssid, len), (int)len); 4234 + iwl_escape_essid(ssid, len), (int)len); 3322 4235 3323 4236 priv->one_direct_scan = 1; 3324 4237 priv->direct_ssid_len = (u8) ··· 3327 4240 } else 3328 4241 priv->one_direct_scan = 0; 3329 4242 3330 - rc = iwl4965_scan_initiate(priv); 4243 + rc = iwl_scan_initiate(priv); 3331 4244 3332 4245 IWL_DEBUG_MAC80211("leave\n"); 3333 4246 ··· 3358 4271 return; 3359 4272 } 3360 4273 3361 - iwl4965_scan_cancel_timeout(priv, 100); 4274 + iwl_scan_cancel_timeout(priv, 100); 3362 4275 3363 4276 key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK); 3364 4277 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); ··· 3416 4329 } 3417 4330 3418 4331 mutex_lock(&priv->mutex); 3419 - iwl4965_scan_cancel_timeout(priv, 100); 4332 + iwl_scan_cancel_timeout(priv, 100); 3420 4333 mutex_unlock(&priv->mutex); 3421 4334 3422 4335 /* If we are getting WEP group key and we didn't receive any key mapping ··· 3576 4489 IWL_DEBUG_MAC80211("enter\n"); 3577 4490 3578 4491 priv->lq_mngr.lq_ready = 0; 3579 - #ifdef CONFIG_IWL4965_HT 3580 4492 spin_lock_irqsave(&priv->lock, flags); 3581 4493 memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_info)); 3582 4494 spin_unlock_irqrestore(&priv->lock, flags); 3583 - #endif /* CONFIG_IWL4965_HT */ 3584 4495 3585 4496 iwl_reset_qos(priv); 3586 4497 ··· 3612 4527 * clear RXON_FILTER_ASSOC_MSK bit 3613 4528 */ 3614 4529 if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { 3615 - iwl4965_scan_cancel_timeout(priv, 100); 4530 + iwl_scan_cancel_timeout(priv, 100); 3616 4531 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3617 4532 iwl4965_commit_rxon(priv); 3618 4533 } ··· 3668 4583 3669 4584 iwl_reset_qos(priv); 3670 4585 3671 - queue_work(priv->workqueue, &priv->post_associate.work); 4586 + iwl4965_post_associate(priv); 3672 4587 3673 4588 mutex_unlock(&priv->mutex); 3674 4589 ··· 3750 4665 if (!iwl_is_alive(priv)) 3751 4666 return -EAGAIN; 3752 4667 3753 - return sprintf(buf, "%d\n", iwl4965_hw_get_temperature(priv)); 4668 + return sprintf(buf, "%d\n", priv->temperature); 3754 4669 } 3755 4670 3756 4671 static DEVICE_ATTR(temperature, S_IRUGO, show_temperature, NULL); ··· 3768 4683 struct device_attribute *attr, char *buf) 3769 4684 { 3770 4685 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data; 3771 - return sprintf(buf, "%d\n", priv->user_txpower_limit); 4686 + return sprintf(buf, "%d\n", priv->tx_power_user_lmt); 3772 4687 } 3773 4688 3774 4689 static ssize_t store_tx_power(struct device *d, ··· 3784 4699 printk(KERN_INFO DRV_NAME 3785 4700 ": %s is not in decimal form.\n", buf); 3786 4701 else 3787 - iwl4965_hw_reg_set_txpower(priv, val); 4702 + iwl_set_tx_power(priv, val, false); 3788 4703 3789 4704 return count; 3790 4705 } ··· 3809 4724 mutex_lock(&priv->mutex); 3810 4725 if (le32_to_cpu(priv->staging_rxon.flags) != flags) { 3811 4726 /* Cancel any currently running scans... */ 3812 - if (iwl4965_scan_cancel_timeout(priv, 100)) 4727 + if (iwl_scan_cancel_timeout(priv, 100)) 3813 4728 IWL_WARNING("Could not cancel scan.\n"); 3814 4729 else { 3815 4730 IWL_DEBUG_INFO("Committing rxon.flags = 0x%04X\n", ··· 3844 4759 mutex_lock(&priv->mutex); 3845 4760 if (le32_to_cpu(priv->staging_rxon.filter_flags) != filter_flags) { 3846 4761 /* Cancel any currently running scans... */ 3847 - if (iwl4965_scan_cancel_timeout(priv, 100)) 4762 + if (iwl_scan_cancel_timeout(priv, 100)) 3848 4763 IWL_WARNING("Could not cancel scan.\n"); 3849 4764 else { 3850 4765 IWL_DEBUG_INFO("Committing rxon.filter_flags = " ··· 4042 4957 static ssize_t show_channels(struct device *d, 4043 4958 struct device_attribute *attr, char *buf) 4044 4959 { 4045 - /* all this shit doesn't belong into sysfs anyway */ 4046 - return 0; 4960 + 4961 + struct iwl_priv *priv = dev_get_drvdata(d); 4962 + struct ieee80211_channel *channels = NULL; 4963 + const struct ieee80211_supported_band *supp_band = NULL; 4964 + int len = 0, i; 4965 + int count = 0; 4966 + 4967 + if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) 4968 + return -EAGAIN; 4969 + 4970 + supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); 4971 + channels = supp_band->channels; 4972 + count = supp_band->n_channels; 4973 + 4974 + len += sprintf(&buf[len], 4975 + "Displaying %d channels in 2.4GHz band " 4976 + "(802.11bg):\n", count); 4977 + 4978 + for (i = 0; i < count; i++) 4979 + len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n", 4980 + ieee80211_frequency_to_channel( 4981 + channels[i].center_freq), 4982 + channels[i].max_power, 4983 + channels[i].flags & IEEE80211_CHAN_RADAR ? 4984 + " (IEEE 802.11h required)" : "", 4985 + (!(channels[i].flags & IEEE80211_CHAN_NO_IBSS) 4986 + || (channels[i].flags & 4987 + IEEE80211_CHAN_RADAR)) ? "" : 4988 + ", IBSS", 4989 + channels[i].flags & 4990 + IEEE80211_CHAN_PASSIVE_SCAN ? 4991 + "passive only" : "active/passive"); 4992 + 4993 + supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); 4994 + channels = supp_band->channels; 4995 + count = supp_band->n_channels; 4996 + 4997 + len += sprintf(&buf[len], "Displaying %d channels in 5.2GHz band " 4998 + "(802.11a):\n", count); 4999 + 5000 + for (i = 0; i < count; i++) 5001 + len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n", 5002 + ieee80211_frequency_to_channel( 5003 + channels[i].center_freq), 5004 + channels[i].max_power, 5005 + channels[i].flags & IEEE80211_CHAN_RADAR ? 5006 + " (IEEE 802.11h required)" : "", 5007 + ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) 5008 + || (channels[i].flags & 5009 + IEEE80211_CHAN_RADAR)) ? "" : 5010 + ", IBSS", 5011 + channels[i].flags & 5012 + IEEE80211_CHAN_PASSIVE_SCAN ? 5013 + "passive only" : "active/passive"); 5014 + 5015 + return len; 4047 5016 } 4048 5017 4049 5018 static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL); ··· 4157 5018 * 4158 5019 *****************************************************************************/ 4159 5020 4160 - static void iwl4965_setup_deferred_work(struct iwl_priv *priv) 5021 + static void iwl_setup_deferred_work(struct iwl_priv *priv) 4161 5022 { 4162 5023 priv->workqueue = create_workqueue(DRV_NAME); 4163 5024 ··· 4166 5027 INIT_WORK(&priv->up, iwl4965_bg_up); 4167 5028 INIT_WORK(&priv->restart, iwl4965_bg_restart); 4168 5029 INIT_WORK(&priv->rx_replenish, iwl4965_bg_rx_replenish); 4169 - INIT_WORK(&priv->scan_completed, iwl4965_bg_scan_completed); 4170 - INIT_WORK(&priv->request_scan, iwl4965_bg_request_scan); 4171 - INIT_WORK(&priv->abort_scan, iwl4965_bg_abort_scan); 4172 5030 INIT_WORK(&priv->rf_kill, iwl4965_bg_rf_kill); 4173 5031 INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); 4174 5032 INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor); 5033 + INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work); 4175 5034 INIT_DELAYED_WORK(&priv->post_associate, iwl4965_bg_post_associate); 4176 5035 INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start); 4177 5036 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start); 4178 - INIT_DELAYED_WORK(&priv->scan_check, iwl4965_bg_scan_check); 4179 5037 4180 - iwl4965_hw_setup_deferred_work(priv); 5038 + /* FIXME : remove when resolved PENDING */ 5039 + INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); 5040 + iwl_setup_scan_deferred_work(priv); 5041 + 5042 + if (priv->cfg->ops->lib->setup_deferred_work) 5043 + priv->cfg->ops->lib->setup_deferred_work(priv); 5044 + 5045 + init_timer(&priv->statistics_periodic); 5046 + priv->statistics_periodic.data = (unsigned long)priv; 5047 + priv->statistics_periodic.function = iwl4965_bg_statistics_periodic; 4181 5048 4182 5049 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 4183 5050 iwl4965_irq_tasklet, (unsigned long)priv); 4184 5051 } 4185 5052 4186 - static void iwl4965_cancel_deferred_work(struct iwl_priv *priv) 5053 + static void iwl_cancel_deferred_work(struct iwl_priv *priv) 4187 5054 { 4188 - iwl4965_hw_cancel_deferred_work(priv); 5055 + if (priv->cfg->ops->lib->cancel_deferred_work) 5056 + priv->cfg->ops->lib->cancel_deferred_work(priv); 4189 5057 4190 5058 cancel_delayed_work_sync(&priv->init_alive_start); 4191 5059 cancel_delayed_work(&priv->scan_check); 4192 5060 cancel_delayed_work(&priv->alive_start); 4193 5061 cancel_delayed_work(&priv->post_associate); 4194 5062 cancel_work_sync(&priv->beacon_update); 5063 + del_timer_sync(&priv->statistics_periodic); 4195 5064 } 4196 5065 4197 5066 static struct attribute *iwl4965_sysfs_entries[] = { ··· 4247 5100 .reset_tsf = iwl4965_mac_reset_tsf, 4248 5101 .beacon_update = iwl4965_mac_beacon_update, 4249 5102 .bss_info_changed = iwl4965_bss_info_changed, 4250 - #ifdef CONFIG_IWL4965_HT 4251 5103 .ampdu_action = iwl4965_mac_ampdu_action, 4252 - #endif /* CONFIG_IWL4965_HT */ 4253 5104 .hw_scan = iwl4965_mac_hw_scan 4254 5105 }; 4255 5106 ··· 4411 5266 } 4412 5267 4413 5268 4414 - iwl4965_setup_deferred_work(priv); 5269 + iwl_setup_deferred_work(priv); 4415 5270 iwl4965_setup_rx_handlers(priv); 4416 5271 4417 5272 /******************** ··· 4432 5287 if (err) 4433 5288 IWL_ERROR("failed to create debugfs files\n"); 4434 5289 4435 - /* notify iwlcore to init */ 4436 - iwlcore_low_level_notify(priv, IWLCORE_INIT_EVT); 5290 + err = iwl_rfkill_init(priv); 5291 + if (err) 5292 + IWL_ERROR("Unable to initialize RFKILL system. " 5293 + "Ignoring error: %d\n", err); 5294 + iwl_power_initialize(priv); 4437 5295 return 0; 4438 5296 4439 5297 out_remove_sysfs: ··· 4499 5351 } 4500 5352 } 4501 5353 4502 - iwlcore_low_level_notify(priv, IWLCORE_REMOVE_EVT); 4503 - 5354 + iwl_rfkill_unregister(priv); 4504 5355 iwl4965_dealloc_ucode_pci(priv); 4505 5356 4506 5357 if (priv->rxq.bd)
+122 -40
drivers/net/wireless/libertas/if_cs.c
··· 159 159 160 160 161 161 162 - /* First the bitmasks for the host/card interrupt/status registers: */ 162 + /* 163 + * First the bitmasks for the host/card interrupt/status registers: 164 + */ 163 165 #define IF_CS_BIT_TX 0x0001 164 166 #define IF_CS_BIT_RX 0x0002 165 167 #define IF_CS_BIT_COMMAND 0x0004 ··· 169 167 #define IF_CS_BIT_EVENT 0x0010 170 168 #define IF_CS_BIT_MASK 0x001f 171 169 172 - /* And now the individual registers and assorted masks */ 170 + 171 + 172 + /* 173 + * It's not really clear to me what the host status register is for. It 174 + * needs to be set almost in union with "host int cause". The following 175 + * bits from above are used: 176 + * 177 + * IF_CS_BIT_TX driver downloaded a data packet 178 + * IF_CS_BIT_RX driver got a data packet 179 + * IF_CS_BIT_COMMAND driver downloaded a command 180 + * IF_CS_BIT_RESP not used (has some meaning with powerdown) 181 + * IF_CS_BIT_EVENT driver read a host event 182 + */ 173 183 #define IF_CS_HOST_STATUS 0x00000000 174 184 185 + /* 186 + * With the host int cause register can the host (that is, Linux) cause 187 + * an interrupt in the firmware, to tell the firmware about those events: 188 + * 189 + * IF_CS_BIT_TX a data packet has been downloaded 190 + * IF_CS_BIT_RX a received data packet has retrieved 191 + * IF_CS_BIT_COMMAND a firmware block or a command has been downloaded 192 + * IF_CS_BIT_RESP not used (has some meaning with powerdown) 193 + * IF_CS_BIT_EVENT a host event (link lost etc) has been retrieved 194 + */ 175 195 #define IF_CS_HOST_INT_CAUSE 0x00000002 176 196 197 + /* 198 + * The host int mask register is used to enable/disable interrupt. However, 199 + * I have the suspicion that disabled interrupts are lost. 200 + */ 177 201 #define IF_CS_HOST_INT_MASK 0x00000004 178 202 179 - #define IF_CS_HOST_WRITE 0x00000016 180 - #define IF_CS_HOST_WRITE_LEN 0x00000014 181 - 182 - #define IF_CS_HOST_CMD 0x0000001A 183 - #define IF_CS_HOST_CMD_LEN 0x00000018 184 - 203 + /* 204 + * Used to send or receive data packets: 205 + */ 206 + #define IF_CS_WRITE 0x00000016 207 + #define IF_CS_WRITE_LEN 0x00000014 185 208 #define IF_CS_READ 0x00000010 186 209 #define IF_CS_READ_LEN 0x00000024 187 210 188 - #define IF_CS_CARD_CMD 0x00000012 189 - #define IF_CS_CARD_CMD_LEN 0x00000030 211 + /* 212 + * Used to send commands (and to send firmware block) and to 213 + * receive command responses: 214 + */ 215 + #define IF_CS_CMD 0x0000001A 216 + #define IF_CS_CMD_LEN 0x00000018 217 + #define IF_CS_RESP 0x00000012 218 + #define IF_CS_RESP_LEN 0x00000030 190 219 220 + /* 221 + * The card status registers shows what the card/firmware actually 222 + * accepts: 223 + * 224 + * IF_CS_BIT_TX you may send a data packet 225 + * IF_CS_BIT_RX you may retrieve a data packet 226 + * IF_CS_BIT_COMMAND you may send a command 227 + * IF_CS_BIT_RESP you may retrieve a command response 228 + * IF_CS_BIT_EVENT the card has a event for use (link lost, snr low etc) 229 + * 230 + * When reading this register several times, you will get back the same 231 + * results --- with one exception: the IF_CS_BIT_EVENT clear itself 232 + * automatically. 233 + * 234 + * Not that we don't rely on BIT_RX,_BIT_RESP or BIT_EVENT because 235 + * we handle this via the card int cause register. 236 + */ 191 237 #define IF_CS_CARD_STATUS 0x00000020 192 238 #define IF_CS_CARD_STATUS_MASK 0x7f00 193 239 240 + /* 241 + * The card int cause register is used by the card/firmware to notify us 242 + * about the following events: 243 + * 244 + * IF_CS_BIT_TX a data packet has successfully been sentx 245 + * IF_CS_BIT_RX a data packet has been received and can be retrieved 246 + * IF_CS_BIT_COMMAND not used 247 + * IF_CS_BIT_RESP the firmware has a command response for us 248 + * IF_CS_BIT_EVENT the card has a event for use (link lost, snr low etc) 249 + */ 194 250 #define IF_CS_CARD_INT_CAUSE 0x00000022 195 251 196 - #define IF_CS_CARD_SQ_READ_LOW 0x00000028 197 - #define IF_CS_CARD_SQ_HELPER_OK 0x10 252 + /* 253 + * This is used to for handshaking with the card's bootloader/helper image 254 + * to synchronize downloading of firmware blocks. 255 + */ 256 + #define IF_CS_SQ_READ_LOW 0x00000028 257 + #define IF_CS_SQ_HELPER_OK 0x10 198 258 259 + /* 260 + * The scratch register tells us ... 261 + * 262 + * IF_CS_SCRATCH_BOOT_OK the bootloader runs 263 + * IF_CS_SCRATCH_HELPER_OK the helper firmware already runs 264 + */ 199 265 #define IF_CS_SCRATCH 0x0000003F 266 + #define IF_CS_SCRATCH_BOOT_OK 0x00 267 + #define IF_CS_SCRATCH_HELPER_OK 0x5a 200 268 269 + /* 270 + * Used to detect ancient chips: 271 + */ 272 + #define IF_CS_PRODUCT_ID 0x0000001C 273 + #define IF_CS_CF8385_B1_REV 0x12 201 274 202 275 203 276 /********************************************************************/ ··· 305 228 306 229 /* Is hardware ready? */ 307 230 while (1) { 308 - u16 val = if_cs_read16(card, IF_CS_CARD_STATUS); 309 - if (val & IF_CS_BIT_COMMAND) 231 + u16 status = if_cs_read16(card, IF_CS_CARD_STATUS); 232 + if (status & IF_CS_BIT_COMMAND) 310 233 break; 311 234 if (++loops > 100) { 312 235 lbs_pr_err("card not ready for commands\n"); ··· 315 238 mdelay(1); 316 239 } 317 240 318 - if_cs_write16(card, IF_CS_HOST_CMD_LEN, nb); 241 + if_cs_write16(card, IF_CS_CMD_LEN, nb); 319 242 320 - if_cs_write16_rep(card, IF_CS_HOST_CMD, buf, nb / 2); 243 + if_cs_write16_rep(card, IF_CS_CMD, buf, nb / 2); 321 244 /* Are we supposed to transfer an odd amount of bytes? */ 322 245 if (nb & 1) 323 - if_cs_write8(card, IF_CS_HOST_CMD, buf[nb-1]); 246 + if_cs_write8(card, IF_CS_CMD, buf[nb-1]); 324 247 325 248 /* "Assert the download over interrupt command in the Host 326 249 * status register" */ ··· 351 274 status = if_cs_read16(card, IF_CS_CARD_STATUS); 352 275 BUG_ON((status & IF_CS_BIT_TX) == 0); 353 276 354 - if_cs_write16(card, IF_CS_HOST_WRITE_LEN, nb); 277 + if_cs_write16(card, IF_CS_WRITE_LEN, nb); 355 278 356 279 /* write even number of bytes, then odd byte if necessary */ 357 - if_cs_write16_rep(card, IF_CS_HOST_WRITE, buf, nb / 2); 280 + if_cs_write16_rep(card, IF_CS_WRITE, buf, nb / 2); 358 281 if (nb & 1) 359 - if_cs_write8(card, IF_CS_HOST_WRITE, buf[nb-1]); 282 + if_cs_write8(card, IF_CS_WRITE, buf[nb-1]); 360 283 361 284 if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_TX); 362 285 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_TX); ··· 384 307 goto out; 385 308 } 386 309 387 - *len = if_cs_read16(priv->card, IF_CS_CARD_CMD_LEN); 310 + *len = if_cs_read16(priv->card, IF_CS_RESP_LEN); 388 311 if ((*len == 0) || (*len > LBS_CMD_BUFFER_SIZE)) { 389 312 lbs_pr_err("card cmd buffer has invalid # of bytes (%d)\n", *len); 390 313 goto out; 391 314 } 392 315 393 316 /* read even number of bytes, then odd byte if necessary */ 394 - if_cs_read16_rep(priv->card, IF_CS_CARD_CMD, data, *len/sizeof(u16)); 317 + if_cs_read16_rep(priv->card, IF_CS_RESP, data, *len/sizeof(u16)); 395 318 if (*len & 1) 396 - data[*len-1] = if_cs_read8(priv->card, IF_CS_CARD_CMD); 319 + data[*len-1] = if_cs_read8(priv->card, IF_CS_RESP); 397 320 398 321 /* This is a workaround for a firmware that reports too much 399 322 * bytes */ ··· 456 379 457 380 /* Ask card interrupt cause register if there is something for us */ 458 381 cause = if_cs_read16(card, IF_CS_CARD_INT_CAUSE); 382 + lbs_deb_cs("cause 0x%04x\n", cause); 383 + 459 384 if (cause == 0) { 460 385 /* Not for us */ 461 386 return IRQ_NONE; ··· 468 389 card->priv->surpriseremoved = 1; 469 390 return IRQ_HANDLED; 470 391 } 471 - 472 - /* Clear interrupt cause */ 473 - if_cs_write16(card, IF_CS_CARD_INT_CAUSE, cause & IF_CS_BIT_MASK); 474 - lbs_deb_cs("cause 0x%04x\n", cause); 475 392 476 393 if (cause & IF_CS_BIT_RX) { 477 394 struct sk_buff *skb; ··· 501 426 } 502 427 503 428 if (cause & IF_CS_BIT_EVENT) { 504 - u16 event = if_cs_read16(priv->card, IF_CS_CARD_STATUS) 505 - & IF_CS_CARD_STATUS_MASK; 429 + u16 status = if_cs_read16(priv->card, IF_CS_CARD_STATUS); 506 430 if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE, 507 431 IF_CS_BIT_EVENT); 508 - lbs_deb_cs("host event 0x%04x\n", event); 509 - lbs_queue_event(priv, event >> 8 & 0xff); 432 + lbs_queue_event(priv, (status & IF_CS_CARD_STATUS_MASK) >> 8); 510 433 } 434 + 435 + /* Clear interrupt cause */ 436 + if_cs_write16(card, IF_CS_CARD_INT_CAUSE, cause & IF_CS_BIT_MASK); 511 437 512 438 lbs_deb_leave(LBS_DEB_CS); 513 439 return IRQ_HANDLED; ··· 540 464 /* "If the value is 0x5a, the firmware is already 541 465 * downloaded successfully" 542 466 */ 543 - if (scratch == 0x5a) 467 + if (scratch == IF_CS_SCRATCH_HELPER_OK) 544 468 goto done; 545 469 546 470 /* "If the value is != 00, it is invalid value of register */ 547 - if (scratch != 0x00) { 471 + if (scratch != IF_CS_SCRATCH_BOOT_OK) { 548 472 ret = -ENODEV; 549 473 goto done; 550 474 } ··· 572 496 573 497 /* "write the number of bytes to be sent to the I/O Command 574 498 * write length register" */ 575 - if_cs_write16(card, IF_CS_HOST_CMD_LEN, count); 499 + if_cs_write16(card, IF_CS_CMD_LEN, count); 576 500 577 501 /* "write this to I/O Command port register as 16 bit writes */ 578 502 if (count) 579 - if_cs_write16_rep(card, IF_CS_HOST_CMD, 503 + if_cs_write16_rep(card, IF_CS_CMD, 580 504 &fw->data[sent], 581 505 count >> 1); 582 506 ··· 633 557 } 634 558 lbs_deb_cs("fw size %td\n", fw->size); 635 559 636 - ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_SQ_READ_LOW, 637 - IF_CS_CARD_SQ_HELPER_OK); 560 + ret = if_cs_poll_while_fw_download(card, IF_CS_SQ_READ_LOW, 561 + IF_CS_SQ_HELPER_OK); 638 562 if (ret < 0) { 639 563 lbs_pr_err("helper firmware doesn't answer\n"); 640 564 goto err_release; 641 565 } 642 566 643 567 for (sent = 0; sent < fw->size; sent += len) { 644 - len = if_cs_read16(card, IF_CS_CARD_SQ_READ_LOW); 568 + len = if_cs_read16(card, IF_CS_SQ_READ_LOW); 645 569 if (len & 1) { 646 570 retry++; 647 571 lbs_pr_info("odd, need to retry this firmware block\n"); ··· 659 583 } 660 584 661 585 662 - if_cs_write16(card, IF_CS_HOST_CMD_LEN, len); 586 + if_cs_write16(card, IF_CS_CMD_LEN, len); 663 587 664 - if_cs_write16_rep(card, IF_CS_HOST_CMD, 588 + if_cs_write16_rep(card, IF_CS_CMD, 665 589 &fw->data[sent], 666 590 (len+1) >> 1); 667 591 if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND); ··· 865 789 p_dev->irq.AssignedIRQ, p_dev->io.BasePort1, 866 790 p_dev->io.BasePort1 + p_dev->io.NumPorts1 - 1); 867 791 792 + /* Check if we have a current silicon */ 793 + if (if_cs_read8(card, IF_CS_PRODUCT_ID) < IF_CS_CF8385_B1_REV) { 794 + lbs_pr_err("old chips like 8385 rev B1 aren't supported\n"); 795 + ret = -ENODEV; 796 + goto out2; 797 + } 868 798 869 799 /* Load the firmware early, before calling into libertas.ko */ 870 800 ret = if_cs_prog_helper(card);
+514
drivers/net/wireless/mac80211_hwsim.c
··· 1 + /* 2 + * mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211 3 + * Copyright (c) 2008, Jouni Malinen <j@w1.fi> 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 + * TODO: 12 + * - IBSS mode simulation (Beacon transmission with competition for "air time") 13 + * - IEEE 802.11a and 802.11n modes 14 + * - RX filtering based on filter configuration (data->rx_filter) 15 + */ 16 + 17 + #include <net/mac80211.h> 18 + #include <net/ieee80211_radiotap.h> 19 + #include <linux/if_arp.h> 20 + #include <linux/rtnetlink.h> 21 + #include <linux/etherdevice.h> 22 + 23 + MODULE_AUTHOR("Jouni Malinen"); 24 + MODULE_DESCRIPTION("Software simulator of 802.11 radio(s) for mac80211"); 25 + MODULE_LICENSE("GPL"); 26 + 27 + static int radios = 2; 28 + module_param(radios, int, 0444); 29 + MODULE_PARM_DESC(radios, "Number of simulated radios"); 30 + 31 + 32 + static struct class *hwsim_class; 33 + 34 + static struct ieee80211_hw **hwsim_radios; 35 + static int hwsim_radio_count; 36 + static struct net_device *hwsim_mon; /* global monitor netdev */ 37 + 38 + 39 + static const struct ieee80211_channel hwsim_channels[] = { 40 + { .center_freq = 2412 }, 41 + { .center_freq = 2417 }, 42 + { .center_freq = 2422 }, 43 + { .center_freq = 2427 }, 44 + { .center_freq = 2432 }, 45 + { .center_freq = 2437 }, 46 + { .center_freq = 2442 }, 47 + { .center_freq = 2447 }, 48 + { .center_freq = 2452 }, 49 + { .center_freq = 2457 }, 50 + { .center_freq = 2462 }, 51 + { .center_freq = 2467 }, 52 + { .center_freq = 2472 }, 53 + { .center_freq = 2484 }, 54 + }; 55 + 56 + static const struct ieee80211_rate hwsim_rates[] = { 57 + { .bitrate = 10 }, 58 + { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 59 + { .bitrate = 55, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 60 + { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 61 + { .bitrate = 60 }, 62 + { .bitrate = 90 }, 63 + { .bitrate = 120 }, 64 + { .bitrate = 180 }, 65 + { .bitrate = 240 }, 66 + { .bitrate = 360 }, 67 + { .bitrate = 480 }, 68 + { .bitrate = 540 } 69 + }; 70 + 71 + struct mac80211_hwsim_data { 72 + struct device *dev; 73 + struct ieee80211_supported_band band; 74 + struct ieee80211_channel channels[ARRAY_SIZE(hwsim_channels)]; 75 + struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)]; 76 + 77 + struct ieee80211_channel *channel; 78 + int radio_enabled; 79 + unsigned long beacon_int; /* in jiffies unit */ 80 + unsigned int rx_filter; 81 + int started; 82 + struct timer_list beacon_timer; 83 + }; 84 + 85 + 86 + struct hwsim_radiotap_hdr { 87 + struct ieee80211_radiotap_header hdr; 88 + u8 rt_flags; 89 + u8 rt_rate; 90 + __le16 rt_channel; 91 + __le16 rt_chbitmask; 92 + } __attribute__ ((packed)); 93 + 94 + 95 + static int hwsim_mon_xmit(struct sk_buff *skb, struct net_device *dev) 96 + { 97 + /* TODO: allow packet injection */ 98 + dev_kfree_skb(skb); 99 + return 0; 100 + } 101 + 102 + 103 + static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw, 104 + struct sk_buff *tx_skb) 105 + { 106 + struct mac80211_hwsim_data *data = hw->priv; 107 + struct sk_buff *skb; 108 + struct hwsim_radiotap_hdr *hdr; 109 + u16 flags; 110 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_skb); 111 + struct ieee80211_rate *txrate = ieee80211_get_tx_rate(hw, info); 112 + 113 + if (!netif_running(hwsim_mon)) 114 + return; 115 + 116 + skb = skb_copy_expand(tx_skb, sizeof(*hdr), 0, GFP_ATOMIC); 117 + if (skb == NULL) 118 + return; 119 + 120 + hdr = (struct hwsim_radiotap_hdr *) skb_push(skb, sizeof(*hdr)); 121 + hdr->hdr.it_version = PKTHDR_RADIOTAP_VERSION; 122 + hdr->hdr.it_pad = 0; 123 + hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr)); 124 + hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | 125 + (1 << IEEE80211_RADIOTAP_RATE) | 126 + (1 << IEEE80211_RADIOTAP_CHANNEL)); 127 + hdr->rt_flags = 0; 128 + hdr->rt_rate = txrate->bitrate / 5; 129 + hdr->rt_channel = data->channel->center_freq; 130 + flags = IEEE80211_CHAN_2GHZ; 131 + if (txrate->flags & IEEE80211_RATE_ERP_G) 132 + flags |= IEEE80211_CHAN_OFDM; 133 + else 134 + flags |= IEEE80211_CHAN_CCK; 135 + hdr->rt_chbitmask = cpu_to_le16(flags); 136 + 137 + skb->dev = hwsim_mon; 138 + skb_set_mac_header(skb, 0); 139 + skb->ip_summed = CHECKSUM_UNNECESSARY; 140 + skb->pkt_type = PACKET_OTHERHOST; 141 + skb->protocol = htons(ETH_P_802_2); 142 + memset(skb->cb, 0, sizeof(skb->cb)); 143 + netif_rx(skb); 144 + } 145 + 146 + 147 + static int mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, 148 + struct sk_buff *skb) 149 + { 150 + struct mac80211_hwsim_data *data = hw->priv; 151 + int i, ack = 0; 152 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 153 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 154 + struct ieee80211_rx_status rx_status; 155 + 156 + memset(&rx_status, 0, sizeof(rx_status)); 157 + /* TODO: set mactime */ 158 + rx_status.freq = data->channel->center_freq; 159 + rx_status.band = data->channel->band; 160 + rx_status.rate_idx = info->tx_rate_idx; 161 + /* TODO: simulate signal strength (and optional packet drop) */ 162 + 163 + /* Copy skb to all enabled radios that are on the current frequency */ 164 + for (i = 0; i < hwsim_radio_count; i++) { 165 + struct mac80211_hwsim_data *data2; 166 + struct sk_buff *nskb; 167 + 168 + if (hwsim_radios[i] == NULL || hwsim_radios[i] == hw) 169 + continue; 170 + data2 = hwsim_radios[i]->priv; 171 + if (!data2->started || !data2->radio_enabled || 172 + data->channel->center_freq != data2->channel->center_freq) 173 + continue; 174 + 175 + nskb = skb_copy(skb, GFP_ATOMIC); 176 + if (nskb == NULL) 177 + continue; 178 + 179 + if (memcmp(hdr->addr1, hwsim_radios[i]->wiphy->perm_addr, 180 + ETH_ALEN) == 0) 181 + ack = 1; 182 + ieee80211_rx_irqsafe(hwsim_radios[i], nskb, &rx_status); 183 + } 184 + 185 + return ack; 186 + } 187 + 188 + 189 + static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 190 + { 191 + struct mac80211_hwsim_data *data = hw->priv; 192 + int ack; 193 + struct ieee80211_tx_info *txi; 194 + 195 + mac80211_hwsim_monitor_rx(hw, skb); 196 + 197 + if (skb->len < 10) { 198 + /* Should not happen; just a sanity check for addr1 use */ 199 + dev_kfree_skb(skb); 200 + return NETDEV_TX_OK; 201 + } 202 + 203 + if (!data->radio_enabled) { 204 + printk(KERN_DEBUG "%s: dropped TX frame since radio " 205 + "disabled\n", wiphy_name(hw->wiphy)); 206 + dev_kfree_skb(skb); 207 + return NETDEV_TX_OK; 208 + } 209 + 210 + ack = mac80211_hwsim_tx_frame(hw, skb); 211 + 212 + txi = IEEE80211_SKB_CB(skb); 213 + memset(&txi->status, 0, sizeof(txi->status)); 214 + if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) { 215 + if (ack) 216 + txi->flags |= IEEE80211_TX_STAT_ACK; 217 + else 218 + txi->status.excessive_retries = 1; 219 + } 220 + ieee80211_tx_status_irqsafe(hw, skb); 221 + return NETDEV_TX_OK; 222 + } 223 + 224 + 225 + static int mac80211_hwsim_start(struct ieee80211_hw *hw) 226 + { 227 + struct mac80211_hwsim_data *data = hw->priv; 228 + printk(KERN_DEBUG "%s:%s\n", wiphy_name(hw->wiphy), __func__); 229 + data->started = 1; 230 + return 0; 231 + } 232 + 233 + 234 + static void mac80211_hwsim_stop(struct ieee80211_hw *hw) 235 + { 236 + struct mac80211_hwsim_data *data = hw->priv; 237 + data->started = 0; 238 + printk(KERN_DEBUG "%s:%s\n", wiphy_name(hw->wiphy), __func__); 239 + } 240 + 241 + 242 + static int mac80211_hwsim_add_interface(struct ieee80211_hw *hw, 243 + struct ieee80211_if_init_conf *conf) 244 + { 245 + DECLARE_MAC_BUF(mac); 246 + printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n", 247 + wiphy_name(hw->wiphy), __func__, conf->type, 248 + print_mac(mac, conf->mac_addr)); 249 + return 0; 250 + } 251 + 252 + 253 + static void mac80211_hwsim_remove_interface( 254 + struct ieee80211_hw *hw, struct ieee80211_if_init_conf *conf) 255 + { 256 + DECLARE_MAC_BUF(mac); 257 + printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n", 258 + wiphy_name(hw->wiphy), __func__, conf->type, 259 + print_mac(mac, conf->mac_addr)); 260 + } 261 + 262 + 263 + static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, 264 + struct ieee80211_vif *vif) 265 + { 266 + struct ieee80211_hw *hw = arg; 267 + struct sk_buff *skb; 268 + struct ieee80211_tx_info *info; 269 + 270 + if (vif->type != IEEE80211_IF_TYPE_AP) 271 + return; 272 + 273 + skb = ieee80211_beacon_get(hw, vif); 274 + if (skb == NULL) 275 + return; 276 + info = IEEE80211_SKB_CB(skb); 277 + 278 + mac80211_hwsim_monitor_rx(hw, skb); 279 + mac80211_hwsim_tx_frame(hw, skb); 280 + dev_kfree_skb(skb); 281 + } 282 + 283 + 284 + static void mac80211_hwsim_beacon(unsigned long arg) 285 + { 286 + struct ieee80211_hw *hw = (struct ieee80211_hw *) arg; 287 + struct mac80211_hwsim_data *data = hw->priv; 288 + 289 + if (!data->started || !data->radio_enabled) 290 + return; 291 + 292 + ieee80211_iterate_active_interfaces_atomic( 293 + hw, mac80211_hwsim_beacon_tx, hw); 294 + 295 + data->beacon_timer.expires = jiffies + data->beacon_int; 296 + add_timer(&data->beacon_timer); 297 + } 298 + 299 + 300 + static int mac80211_hwsim_config(struct ieee80211_hw *hw, 301 + struct ieee80211_conf *conf) 302 + { 303 + struct mac80211_hwsim_data *data = hw->priv; 304 + 305 + printk(KERN_DEBUG "%s:%s (freq=%d radio_enabled=%d beacon_int=%d)\n", 306 + wiphy_name(hw->wiphy), __func__, 307 + conf->channel->center_freq, conf->radio_enabled, 308 + conf->beacon_int); 309 + 310 + data->channel = conf->channel; 311 + data->radio_enabled = conf->radio_enabled; 312 + data->beacon_int = 1024 * conf->beacon_int / 1000 * HZ / 1000; 313 + if (data->beacon_int < 1) 314 + data->beacon_int = 1; 315 + 316 + if (!data->started || !data->radio_enabled) 317 + del_timer(&data->beacon_timer); 318 + else 319 + mod_timer(&data->beacon_timer, jiffies + data->beacon_int); 320 + 321 + return 0; 322 + } 323 + 324 + 325 + static void mac80211_hwsim_configure_filter(struct ieee80211_hw *hw, 326 + unsigned int changed_flags, 327 + unsigned int *total_flags, 328 + int mc_count, 329 + struct dev_addr_list *mc_list) 330 + { 331 + struct mac80211_hwsim_data *data = hw->priv; 332 + 333 + printk(KERN_DEBUG "%s:%s\n", wiphy_name(hw->wiphy), __func__); 334 + 335 + data->rx_filter = 0; 336 + if (*total_flags & FIF_PROMISC_IN_BSS) 337 + data->rx_filter |= FIF_PROMISC_IN_BSS; 338 + if (*total_flags & FIF_ALLMULTI) 339 + data->rx_filter |= FIF_ALLMULTI; 340 + 341 + *total_flags = data->rx_filter; 342 + } 343 + 344 + 345 + 346 + static const struct ieee80211_ops mac80211_hwsim_ops = 347 + { 348 + .tx = mac80211_hwsim_tx, 349 + .start = mac80211_hwsim_start, 350 + .stop = mac80211_hwsim_stop, 351 + .add_interface = mac80211_hwsim_add_interface, 352 + .remove_interface = mac80211_hwsim_remove_interface, 353 + .config = mac80211_hwsim_config, 354 + .configure_filter = mac80211_hwsim_configure_filter, 355 + }; 356 + 357 + 358 + static void mac80211_hwsim_free(void) 359 + { 360 + int i; 361 + 362 + for (i = 0; i < hwsim_radio_count; i++) { 363 + if (hwsim_radios[i]) { 364 + struct mac80211_hwsim_data *data; 365 + data = hwsim_radios[i]->priv; 366 + ieee80211_unregister_hw(hwsim_radios[i]); 367 + if (!IS_ERR(data->dev)) 368 + device_unregister(data->dev); 369 + ieee80211_free_hw(hwsim_radios[i]); 370 + } 371 + } 372 + kfree(hwsim_radios); 373 + class_destroy(hwsim_class); 374 + } 375 + 376 + 377 + static struct device_driver mac80211_hwsim_driver = { 378 + .name = "mac80211_hwsim" 379 + }; 380 + 381 + 382 + static void hwsim_mon_setup(struct net_device *dev) 383 + { 384 + dev->hard_start_xmit = hwsim_mon_xmit; 385 + dev->destructor = free_netdev; 386 + ether_setup(dev); 387 + dev->tx_queue_len = 0; 388 + dev->type = ARPHRD_IEEE80211_RADIOTAP; 389 + memset(dev->dev_addr, 0, ETH_ALEN); 390 + dev->dev_addr[0] = 0x12; 391 + } 392 + 393 + 394 + static int __init init_mac80211_hwsim(void) 395 + { 396 + int i, err = 0; 397 + u8 addr[ETH_ALEN]; 398 + struct mac80211_hwsim_data *data; 399 + struct ieee80211_hw *hw; 400 + DECLARE_MAC_BUF(mac); 401 + 402 + if (radios < 1 || radios > 65535) 403 + return -EINVAL; 404 + 405 + hwsim_radio_count = radios; 406 + hwsim_radios = kcalloc(hwsim_radio_count, 407 + sizeof(struct ieee80211_hw *), GFP_KERNEL); 408 + if (hwsim_radios == NULL) 409 + return -ENOMEM; 410 + 411 + hwsim_class = class_create(THIS_MODULE, "mac80211_hwsim"); 412 + if (IS_ERR(hwsim_class)) { 413 + kfree(hwsim_radios); 414 + return PTR_ERR(hwsim_class); 415 + } 416 + 417 + memset(addr, 0, ETH_ALEN); 418 + addr[0] = 0x02; 419 + 420 + for (i = 0; i < hwsim_radio_count; i++) { 421 + printk(KERN_DEBUG "mac80211_hwsim: Initializing radio %d\n", 422 + i); 423 + hw = ieee80211_alloc_hw(sizeof(*data), &mac80211_hwsim_ops); 424 + if (hw == NULL) { 425 + printk(KERN_DEBUG "mac80211_hwsim: ieee80211_alloc_hw " 426 + "failed\n"); 427 + err = -ENOMEM; 428 + goto failed; 429 + } 430 + hwsim_radios[i] = hw; 431 + 432 + data = hw->priv; 433 + data->dev = device_create(hwsim_class, NULL, 0, "hwsim%d", i); 434 + if (IS_ERR(data->dev)) { 435 + printk(KERN_DEBUG "mac80211_hwsim: device_create " 436 + "failed (%ld)\n", PTR_ERR(data->dev)); 437 + err = -ENOMEM; 438 + goto failed; 439 + } 440 + data->dev->driver = &mac80211_hwsim_driver; 441 + dev_set_drvdata(data->dev, hw); 442 + 443 + SET_IEEE80211_DEV(hw, data->dev); 444 + addr[3] = i >> 8; 445 + addr[4] = i; 446 + SET_IEEE80211_PERM_ADDR(hw, addr); 447 + 448 + hw->channel_change_time = 1; 449 + hw->queues = 1; 450 + 451 + memcpy(data->channels, hwsim_channels, sizeof(hwsim_channels)); 452 + memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); 453 + data->band.channels = data->channels; 454 + data->band.n_channels = ARRAY_SIZE(hwsim_channels); 455 + data->band.bitrates = data->rates; 456 + data->band.n_bitrates = ARRAY_SIZE(hwsim_rates); 457 + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &data->band; 458 + 459 + err = ieee80211_register_hw(hw); 460 + if (err < 0) { 461 + printk(KERN_DEBUG "mac80211_hwsim: " 462 + "ieee80211_register_hw failed (%d)\n", err); 463 + goto failed; 464 + } 465 + 466 + printk(KERN_DEBUG "%s: hwaddr %s registered\n", 467 + wiphy_name(hw->wiphy), 468 + print_mac(mac, hw->wiphy->perm_addr)); 469 + 470 + setup_timer(&data->beacon_timer, mac80211_hwsim_beacon, 471 + (unsigned long) hw); 472 + } 473 + 474 + hwsim_mon = alloc_netdev(0, "hwsim%d", hwsim_mon_setup); 475 + if (hwsim_mon == NULL) 476 + goto failed; 477 + 478 + rtnl_lock(); 479 + 480 + err = dev_alloc_name(hwsim_mon, hwsim_mon->name); 481 + if (err < 0) { 482 + goto failed_mon; 483 + } 484 + 485 + err = register_netdevice(hwsim_mon); 486 + if (err < 0) 487 + goto failed_mon; 488 + 489 + rtnl_unlock(); 490 + 491 + return 0; 492 + 493 + failed_mon: 494 + rtnl_unlock(); 495 + free_netdev(hwsim_mon); 496 + 497 + failed: 498 + mac80211_hwsim_free(); 499 + return err; 500 + } 501 + 502 + 503 + static void __exit exit_mac80211_hwsim(void) 504 + { 505 + printk(KERN_DEBUG "mac80211_hwsim: unregister %d radios\n", 506 + hwsim_radio_count); 507 + 508 + unregister_netdev(hwsim_mon); 509 + mac80211_hwsim_free(); 510 + } 511 + 512 + 513 + module_init(init_mac80211_hwsim); 514 + module_exit(exit_mac80211_hwsim);
+95 -72
drivers/net/wireless/rndis_wlan.c
··· 310 310 #define CAP_MODE_MASK 7 311 311 #define CAP_SUPPORT_TXPOWER 8 312 312 313 - #define WORK_CONNECTION_EVENT (1<<0) 314 - #define WORK_SET_MULTICAST_LIST (1<<1) 313 + #define WORK_LINK_UP (1<<0) 314 + #define WORK_LINK_DOWN (1<<1) 315 + #define WORK_SET_MULTICAST_LIST (1<<2) 316 + 317 + #define COMMAND_BUFFER_SIZE (CONTROL_BUFFER_SIZE + sizeof(struct rndis_set)) 315 318 316 319 /* RNDIS device private data */ 317 320 struct rndis_wext_private { ··· 364 361 u8 *wpa_ie; 365 362 int wpa_cipher_pair; 366 363 int wpa_cipher_group; 364 + 365 + u8 command_buffer[COMMAND_BUFFER_SIZE]; 367 366 }; 368 367 369 368 ··· 432 427 buflen = *len + sizeof(*u.get); 433 428 if (buflen < CONTROL_BUFFER_SIZE) 434 429 buflen = CONTROL_BUFFER_SIZE; 435 - u.buf = kmalloc(buflen, GFP_KERNEL); 436 - if (!u.buf) 437 - return -ENOMEM; 430 + 431 + if (buflen > COMMAND_BUFFER_SIZE) { 432 + u.buf = kmalloc(buflen, GFP_KERNEL); 433 + if (!u.buf) 434 + return -ENOMEM; 435 + } else { 436 + u.buf = priv->command_buffer; 437 + } 438 + 439 + mutex_lock(&priv->command_lock); 440 + 438 441 memset(u.get, 0, sizeof *u.get); 439 442 u.get->msg_type = RNDIS_MSG_QUERY; 440 443 u.get->msg_len = ccpu2(sizeof *u.get); 441 444 u.get->oid = oid; 442 445 443 - mutex_lock(&priv->command_lock); 444 446 ret = rndis_command(dev, u.header); 445 - mutex_unlock(&priv->command_lock); 446 - 447 447 if (ret == 0) { 448 448 ret = le32_to_cpu(u.get_c->len); 449 449 *len = (*len > ret) ? ret : *len; ··· 456 446 ret = rndis_error_status(u.get_c->status); 457 447 } 458 448 459 - kfree(u.buf); 449 + mutex_unlock(&priv->command_lock); 450 + 451 + if (u.buf != priv->command_buffer) 452 + kfree(u.buf); 460 453 return ret; 461 454 } 462 455 ··· 478 465 buflen = len + sizeof(*u.set); 479 466 if (buflen < CONTROL_BUFFER_SIZE) 480 467 buflen = CONTROL_BUFFER_SIZE; 481 - u.buf = kmalloc(buflen, GFP_KERNEL); 482 - if (!u.buf) 483 - return -ENOMEM; 468 + 469 + if (buflen > COMMAND_BUFFER_SIZE) { 470 + u.buf = kmalloc(buflen, GFP_KERNEL); 471 + if (!u.buf) 472 + return -ENOMEM; 473 + } else { 474 + u.buf = priv->command_buffer; 475 + } 476 + 477 + mutex_lock(&priv->command_lock); 484 478 485 479 memset(u.set, 0, sizeof *u.set); 486 480 u.set->msg_type = RNDIS_MSG_SET; ··· 498 478 u.set->handle = ccpu2(0); 499 479 memcpy(u.buf + sizeof(*u.set), data, len); 500 480 501 - mutex_lock(&priv->command_lock); 502 481 ret = rndis_command(dev, u.header); 503 - mutex_unlock(&priv->command_lock); 504 - 505 482 if (ret == 0) 506 483 ret = rndis_error_status(u.set_c->status); 507 484 508 - kfree(u.buf); 485 + mutex_unlock(&priv->command_lock); 486 + 487 + if (u.buf != priv->command_buffer) 488 + kfree(u.buf); 509 489 return ret; 510 490 } 511 491 ··· 640 620 static int freq_to_dsconfig(struct iw_freq *freq, unsigned int *dsconfig) 641 621 { 642 622 if (freq->m < 1000 && freq->e == 0) { 643 - if (freq->m >= 1 && 644 - freq->m <= (sizeof(freq_chan) / sizeof(freq_chan[0]))) 623 + if (freq->m >= 1 && freq->m <= ARRAY_SIZE(freq_chan)) 645 624 *dsconfig = freq_chan[freq->m - 1] * 1000; 646 625 else 647 626 return -1; ··· 1178 1159 range->throughput = 11 * 1000 * 1000 / 2; 1179 1160 } 1180 1161 1181 - range->num_channels = (sizeof(freq_chan)/sizeof(freq_chan[0])); 1162 + range->num_channels = ARRAY_SIZE(freq_chan); 1182 1163 1183 - for (i = 0; i < (sizeof(freq_chan)/sizeof(freq_chan[0])) && 1184 - i < IW_MAX_FREQUENCIES; i++) { 1164 + for (i = 0; i < ARRAY_SIZE(freq_chan) && i < IW_MAX_FREQUENCIES; i++) { 1185 1165 range->freq[i].i = i + 1; 1186 1166 range->freq[i].m = freq_chan[i] * 100000; 1187 1167 range->freq[i].e = 1; ··· 2231 2213 int assoc_size = sizeof(*info) + IW_CUSTOM_MAX + 32; 2232 2214 int ret, offset; 2233 2215 2234 - if (test_and_clear_bit(WORK_CONNECTION_EVENT, &priv->work_pending)) { 2216 + if (test_and_clear_bit(WORK_LINK_UP, &priv->work_pending)) { 2217 + netif_carrier_on(usbdev->net); 2218 + 2235 2219 info = kzalloc(assoc_size, GFP_KERNEL); 2236 2220 if (!info) 2237 2221 goto get_bssid; ··· 2271 2251 } 2272 2252 } 2273 2253 2254 + if (test_and_clear_bit(WORK_LINK_DOWN, &priv->work_pending)) { 2255 + netif_carrier_off(usbdev->net); 2256 + 2257 + evt.data.flags = 0; 2258 + evt.data.length = 0; 2259 + memset(evt.ap_addr.sa_data, 0, ETH_ALEN); 2260 + wireless_send_event(usbdev->net, SIOCGIWAP, &evt, NULL); 2261 + } 2262 + 2274 2263 if (test_and_clear_bit(WORK_SET_MULTICAST_LIST, &priv->work_pending)) 2275 2264 set_multicast_list(usbdev); 2276 2265 } ··· 2289 2260 struct usbnet *usbdev = dev->priv; 2290 2261 struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 2291 2262 2263 + if (test_bit(WORK_SET_MULTICAST_LIST, &priv->work_pending)) 2264 + return; 2265 + 2292 2266 set_bit(WORK_SET_MULTICAST_LIST, &priv->work_pending); 2293 2267 queue_work(priv->workqueue, &priv->work); 2294 2268 } 2295 2269 2296 - static void rndis_wext_link_change(struct usbnet *dev, int state) 2270 + static void rndis_wext_link_change(struct usbnet *usbdev, int state) 2297 2271 { 2298 - struct rndis_wext_private *priv = get_rndis_wext_priv(dev); 2299 - union iwreq_data evt; 2272 + struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 2300 2273 2301 - if (state) { 2302 - /* queue work to avoid recursive calls into rndis_command */ 2303 - set_bit(WORK_CONNECTION_EVENT, &priv->work_pending); 2304 - queue_work(priv->workqueue, &priv->work); 2305 - } else { 2306 - evt.data.flags = 0; 2307 - evt.data.length = 0; 2308 - memset(evt.ap_addr.sa_data, 0, ETH_ALEN); 2309 - wireless_send_event(dev->net, SIOCGIWAP, &evt, NULL); 2310 - } 2274 + /* queue work to avoid recursive calls into rndis_command */ 2275 + set_bit(state ? WORK_LINK_UP : WORK_LINK_DOWN, &priv->work_pending); 2276 + queue_work(priv->workqueue, &priv->work); 2311 2277 } 2312 2278 2313 2279 2314 - static int rndis_wext_get_caps(struct usbnet *dev) 2280 + static int rndis_wext_get_caps(struct usbnet *usbdev) 2315 2281 { 2316 2282 struct { 2317 2283 __le32 num_items; ··· 2314 2290 } networks_supported; 2315 2291 int len, retval, i, n; 2316 2292 __le32 tx_power; 2317 - struct rndis_wext_private *priv = get_rndis_wext_priv(dev); 2293 + struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 2318 2294 2319 2295 /* determine if supports setting txpower */ 2320 2296 len = sizeof(tx_power); 2321 - retval = rndis_query_oid(dev, OID_802_11_TX_POWER_LEVEL, &tx_power, 2322 - &len); 2297 + retval = rndis_query_oid(usbdev, OID_802_11_TX_POWER_LEVEL, &tx_power, 2298 + &len); 2323 2299 if (retval == 0 && le32_to_cpu(tx_power) != 0xFF) 2324 2300 priv->caps |= CAP_SUPPORT_TXPOWER; 2325 2301 2326 2302 /* determine supported modes */ 2327 2303 len = sizeof(networks_supported); 2328 - retval = rndis_query_oid(dev, OID_802_11_NETWORK_TYPES_SUPPORTED, 2304 + retval = rndis_query_oid(usbdev, OID_802_11_NETWORK_TYPES_SUPPORTED, 2329 2305 &networks_supported, &len); 2330 2306 if (retval >= 0) { 2331 2307 n = le32_to_cpu(networks_supported.num_items); ··· 2464 2440 } 2465 2441 2466 2442 2467 - static int bcm4320_early_init(struct usbnet *dev) 2443 + static int bcm4320_early_init(struct usbnet *usbdev) 2468 2444 { 2469 - struct rndis_wext_private *priv = get_rndis_wext_priv(dev); 2445 + struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 2470 2446 char buf[8]; 2471 2447 2472 2448 /* Early initialization settings, setting these won't have effect ··· 2514 2490 else 2515 2491 priv->param_workaround_interval = modparam_workaround_interval; 2516 2492 2517 - rndis_set_config_parameter_str(dev, "Country", priv->param_country); 2518 - rndis_set_config_parameter_str(dev, "FrameBursting", 2493 + rndis_set_config_parameter_str(usbdev, "Country", priv->param_country); 2494 + rndis_set_config_parameter_str(usbdev, "FrameBursting", 2519 2495 priv->param_frameburst ? "1" : "0"); 2520 - rndis_set_config_parameter_str(dev, "Afterburner", 2496 + rndis_set_config_parameter_str(usbdev, "Afterburner", 2521 2497 priv->param_afterburner ? "1" : "0"); 2522 2498 sprintf(buf, "%d", priv->param_power_save); 2523 - rndis_set_config_parameter_str(dev, "PowerSaveMode", buf); 2499 + rndis_set_config_parameter_str(usbdev, "PowerSaveMode", buf); 2524 2500 sprintf(buf, "%d", priv->param_power_output); 2525 - rndis_set_config_parameter_str(dev, "PwrOut", buf); 2501 + rndis_set_config_parameter_str(usbdev, "PwrOut", buf); 2526 2502 sprintf(buf, "%d", priv->param_roamtrigger); 2527 - rndis_set_config_parameter_str(dev, "RoamTrigger", buf); 2503 + rndis_set_config_parameter_str(usbdev, "RoamTrigger", buf); 2528 2504 sprintf(buf, "%d", priv->param_roamdelta); 2529 - rndis_set_config_parameter_str(dev, "RoamDelta", buf); 2505 + rndis_set_config_parameter_str(usbdev, "RoamDelta", buf); 2530 2506 2531 2507 return 0; 2532 2508 } 2533 2509 2534 2510 2535 - static int rndis_wext_bind(struct usbnet *dev, struct usb_interface *intf) 2511 + static int rndis_wext_bind(struct usbnet *usbdev, struct usb_interface *intf) 2536 2512 { 2537 - struct net_device *net = dev->net; 2538 2513 struct rndis_wext_private *priv; 2539 2514 int retval, len; 2540 2515 __le32 tmp; 2541 2516 2542 2517 /* allocate rndis private data */ 2543 - priv = kmalloc(sizeof(struct rndis_wext_private), GFP_KERNEL); 2518 + priv = kzalloc(sizeof(struct rndis_wext_private), GFP_KERNEL); 2544 2519 if (!priv) 2545 2520 return -ENOMEM; 2546 2521 2547 2522 /* These have to be initialized before calling generic_rndis_bind(). 2548 2523 * Otherwise we'll be in big trouble in rndis_wext_early_init(). 2549 2524 */ 2550 - dev->driver_priv = priv; 2551 - memset(priv, 0, sizeof(*priv)); 2552 - memset(priv->name, 0, sizeof(priv->name)); 2525 + usbdev->driver_priv = priv; 2553 2526 strcpy(priv->name, "IEEE802.11"); 2554 - net->wireless_handlers = &rndis_iw_handlers; 2555 - priv->usbdev = dev; 2527 + usbdev->net->wireless_handlers = &rndis_iw_handlers; 2528 + priv->usbdev = usbdev; 2556 2529 2557 2530 mutex_init(&priv->command_lock); 2558 2531 spin_lock_init(&priv->stats_lock); 2559 2532 2560 2533 /* try bind rndis_host */ 2561 - retval = generic_rndis_bind(dev, intf, FLAG_RNDIS_PHYM_WIRELESS); 2534 + retval = generic_rndis_bind(usbdev, intf, FLAG_RNDIS_PHYM_WIRELESS); 2562 2535 if (retval < 0) 2563 2536 goto fail; 2564 2537 ··· 2566 2545 * rndis_host wants to avoid all OID as much as possible 2567 2546 * so do promisc/multicast handling in rndis_wext. 2568 2547 */ 2569 - dev->net->set_multicast_list = rndis_wext_set_multicast_list; 2548 + usbdev->net->set_multicast_list = rndis_wext_set_multicast_list; 2570 2549 tmp = RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_BROADCAST; 2571 - retval = rndis_set_oid(dev, OID_GEN_CURRENT_PACKET_FILTER, &tmp, 2550 + retval = rndis_set_oid(usbdev, OID_GEN_CURRENT_PACKET_FILTER, &tmp, 2572 2551 sizeof(tmp)); 2573 2552 2574 2553 len = sizeof(tmp); 2575 - retval = rndis_query_oid(dev, OID_802_3_MAXIMUM_LIST_SIZE, &tmp, &len); 2554 + retval = rndis_query_oid(usbdev, OID_802_3_MAXIMUM_LIST_SIZE, &tmp, 2555 + &len); 2576 2556 priv->multicast_size = le32_to_cpu(tmp); 2577 2557 if (retval < 0 || priv->multicast_size < 0) 2578 2558 priv->multicast_size = 0; 2579 2559 if (priv->multicast_size > 0) 2580 - dev->net->flags |= IFF_MULTICAST; 2560 + usbdev->net->flags |= IFF_MULTICAST; 2581 2561 else 2582 - dev->net->flags &= ~IFF_MULTICAST; 2562 + usbdev->net->flags &= ~IFF_MULTICAST; 2583 2563 2584 2564 priv->iwstats.qual.qual = 0; 2585 2565 priv->iwstats.qual.level = 0; ··· 2590 2568 | IW_QUAL_QUAL_INVALID 2591 2569 | IW_QUAL_LEVEL_INVALID; 2592 2570 2593 - rndis_wext_get_caps(dev); 2594 - set_default_iw_params(dev); 2571 + rndis_wext_get_caps(usbdev); 2572 + set_default_iw_params(usbdev); 2595 2573 2596 2574 /* turn radio on */ 2597 2575 priv->radio_on = 1; 2598 - disassociate(dev, 1); 2576 + disassociate(usbdev, 1); 2577 + netif_carrier_off(usbdev->net); 2599 2578 2600 2579 /* because rndis_command() sleeps we need to use workqueue */ 2601 2580 priv->workqueue = create_singlethread_workqueue("rndis_wlan"); ··· 2613 2590 } 2614 2591 2615 2592 2616 - static void rndis_wext_unbind(struct usbnet *dev, struct usb_interface *intf) 2593 + static void rndis_wext_unbind(struct usbnet *usbdev, struct usb_interface *intf) 2617 2594 { 2618 - struct rndis_wext_private *priv = get_rndis_wext_priv(dev); 2595 + struct rndis_wext_private *priv = get_rndis_wext_priv(usbdev); 2619 2596 2620 2597 /* turn radio off */ 2621 - disassociate(dev, 0); 2598 + disassociate(usbdev, 0); 2622 2599 2623 2600 cancel_delayed_work_sync(&priv->stats_work); 2624 2601 cancel_work_sync(&priv->work); ··· 2629 2606 kfree(priv->wpa_ie); 2630 2607 kfree(priv); 2631 2608 2632 - rndis_unbind(dev, intf); 2609 + rndis_unbind(usbdev, intf); 2633 2610 } 2634 2611 2635 2612 2636 - static int rndis_wext_reset(struct usbnet *dev) 2613 + static int rndis_wext_reset(struct usbnet *usbdev) 2637 2614 { 2638 - return deauthenticate(dev); 2615 + return deauthenticate(usbdev); 2639 2616 } 2640 2617 2641 2618
+49 -56
drivers/net/wireless/rt2x00/rt2400pci.c
··· 277 277 278 278 return 0; 279 279 } 280 + 281 + static void rt2400pci_init_led(struct rt2x00_dev *rt2x00dev, 282 + struct rt2x00_led *led, 283 + enum led_type type) 284 + { 285 + led->rt2x00dev = rt2x00dev; 286 + led->type = type; 287 + led->led_dev.brightness_set = rt2400pci_brightness_set; 288 + led->led_dev.blink_set = rt2400pci_blink_set; 289 + led->flags = LED_INITIALIZED; 290 + } 280 291 #endif /* CONFIG_RT2400PCI_LEDS */ 281 292 282 293 /* ··· 792 781 return 0; 793 782 } 794 783 784 + static int rt2400pci_wait_bbp_ready(struct rt2x00_dev *rt2x00dev) 785 + { 786 + unsigned int i; 787 + u8 value; 788 + 789 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 790 + rt2400pci_bbp_read(rt2x00dev, 0, &value); 791 + if ((value != 0xff) && (value != 0x00)) 792 + return 0; 793 + udelay(REGISTER_BUSY_DELAY); 794 + } 795 + 796 + ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 797 + return -EACCES; 798 + } 799 + 795 800 static int rt2400pci_init_bbp(struct rt2x00_dev *rt2x00dev) 796 801 { 797 802 unsigned int i; ··· 815 788 u8 reg_id; 816 789 u8 value; 817 790 818 - for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 819 - rt2400pci_bbp_read(rt2x00dev, 0, &value); 820 - if ((value != 0xff) && (value != 0x00)) 821 - goto continue_csr_init; 822 - NOTICE(rt2x00dev, "Waiting for BBP register.\n"); 823 - udelay(REGISTER_BUSY_DELAY); 824 - } 791 + if (unlikely(rt2400pci_wait_bbp_ready(rt2x00dev))) 792 + return -EACCES; 825 793 826 - ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 827 - return -EACCES; 828 - 829 - continue_csr_init: 830 794 rt2400pci_bbp_write(rt2x00dev, 1, 0x00); 831 795 rt2400pci_bbp_write(rt2x00dev, 3, 0x27); 832 796 rt2400pci_bbp_write(rt2x00dev, 4, 0x08); ··· 856 838 857 839 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg); 858 840 rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX, 859 - state == STATE_RADIO_RX_OFF); 841 + (state == STATE_RADIO_RX_OFF) || 842 + (state == STATE_RADIO_RX_OFF_LINK)); 860 843 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg); 861 844 } 862 845 ··· 894 875 /* 895 876 * Initialize all registers. 896 877 */ 897 - if (rt2400pci_init_queues(rt2x00dev) || 898 - rt2400pci_init_registers(rt2x00dev) || 899 - rt2400pci_init_bbp(rt2x00dev)) { 900 - ERROR(rt2x00dev, "Register initialization failed.\n"); 878 + if (unlikely(rt2400pci_init_queues(rt2x00dev) || 879 + rt2400pci_init_registers(rt2x00dev) || 880 + rt2400pci_init_bbp(rt2x00dev))) 901 881 return -EIO; 902 - } 903 - 904 - /* 905 - * Enable interrupts. 906 - */ 907 - rt2400pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON); 908 882 909 883 return 0; 910 884 } ··· 919 907 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg); 920 908 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1); 921 909 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg); 922 - 923 - /* 924 - * Disable interrupts. 925 - */ 926 - rt2400pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_OFF); 927 910 } 928 911 929 912 static int rt2400pci_set_state(struct rt2x00_dev *rt2x00dev, ··· 953 946 msleep(10); 954 947 } 955 948 956 - NOTICE(rt2x00dev, "Device failed to enter state %d, " 957 - "current device state: bbp %d and rf %d.\n", 958 - state, bbp_state, rf_state); 959 - 960 949 return -EBUSY; 961 950 } 962 951 ··· 970 967 break; 971 968 case STATE_RADIO_RX_ON: 972 969 case STATE_RADIO_RX_ON_LINK: 973 - rt2400pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); 974 - break; 975 970 case STATE_RADIO_RX_OFF: 976 971 case STATE_RADIO_RX_OFF_LINK: 977 - rt2400pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 972 + rt2400pci_toggle_rx(rt2x00dev, state); 973 + break; 974 + case STATE_RADIO_IRQ_ON: 975 + case STATE_RADIO_IRQ_OFF: 976 + rt2400pci_toggle_irq(rt2x00dev, state); 978 977 break; 979 978 case STATE_DEEP_SLEEP: 980 979 case STATE_SLEEP: ··· 988 983 retval = -ENOTSUPP; 989 984 break; 990 985 } 986 + 987 + if (unlikely(retval)) 988 + ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n", 989 + state, retval); 991 990 992 991 return retval; 993 992 } ··· 1016 1007 rt2x00_desc_write(entry_priv->desc, 1, word); 1017 1008 1018 1009 rt2x00_desc_read(txd, 2, &word); 1019 - rt2x00_set_field32(&word, TXD_W2_BUFFER_LENGTH, skbdesc->data_len); 1020 - rt2x00_set_field32(&word, TXD_W2_DATABYTE_COUNT, skbdesc->data_len); 1010 + rt2x00_set_field32(&word, TXD_W2_BUFFER_LENGTH, skb->len); 1011 + rt2x00_set_field32(&word, TXD_W2_DATABYTE_COUNT, skb->len); 1021 1012 rt2x00_desc_write(txd, 2, word); 1022 1013 1023 1014 rt2x00_desc_read(txd, 3, &word); ··· 1309 1300 #ifdef CONFIG_RT2400PCI_LEDS 1310 1301 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1311 1302 1312 - rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 1313 - rt2x00dev->led_radio.type = LED_TYPE_RADIO; 1314 - rt2x00dev->led_radio.led_dev.brightness_set = 1315 - rt2400pci_brightness_set; 1316 - rt2x00dev->led_radio.led_dev.blink_set = 1317 - rt2400pci_blink_set; 1318 - rt2x00dev->led_radio.flags = LED_INITIALIZED; 1319 - 1320 - if (value == LED_MODE_TXRX_ACTIVITY) { 1321 - rt2x00dev->led_qual.rt2x00dev = rt2x00dev; 1322 - rt2x00dev->led_qual.type = LED_TYPE_ACTIVITY; 1323 - rt2x00dev->led_qual.led_dev.brightness_set = 1324 - rt2400pci_brightness_set; 1325 - rt2x00dev->led_qual.led_dev.blink_set = 1326 - rt2400pci_blink_set; 1327 - rt2x00dev->led_qual.flags = LED_INITIALIZED; 1328 - } 1303 + rt2400pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); 1304 + if (value == LED_MODE_TXRX_ACTIVITY) 1305 + rt2400pci_init_led(rt2x00dev, &rt2x00dev->led_qual, 1306 + LED_TYPE_ACTIVITY); 1329 1307 #endif /* CONFIG_RT2400PCI_LEDS */ 1330 1308 1331 1309 /* ··· 1507 1511 */ 1508 1512 skbdesc = get_skb_frame_desc(skb); 1509 1513 memset(skbdesc, 0, sizeof(*skbdesc)); 1510 - skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; 1511 - skbdesc->data = skb->data; 1512 - skbdesc->data_len = skb->len; 1513 1514 skbdesc->desc = entry_priv->desc; 1514 1515 skbdesc->desc_len = intf->beacon->queue->desc_size; 1515 1516 skbdesc->entry = intf->beacon;
-2
drivers/net/wireless/rt2x00/rt2400pci.h
··· 37 37 * Signal information. 38 38 * Defaul offset is required for RSSI <-> dBm conversion. 39 39 */ 40 - #define MAX_SIGNAL 100 41 - #define MAX_RX_SSI -1 42 40 #define DEFAULT_RSSI_OFFSET 100 43 41 44 42 /*
+47 -54
drivers/net/wireless/rt2x00/rt2500pci.c
··· 277 277 278 278 return 0; 279 279 } 280 + 281 + static void rt2500pci_init_led(struct rt2x00_dev *rt2x00dev, 282 + struct rt2x00_led *led, 283 + enum led_type type) 284 + { 285 + led->rt2x00dev = rt2x00dev; 286 + led->type = type; 287 + led->led_dev.brightness_set = rt2500pci_brightness_set; 288 + led->led_dev.blink_set = rt2500pci_blink_set; 289 + led->flags = LED_INITIALIZED; 290 + } 280 291 #endif /* CONFIG_RT2500PCI_LEDS */ 281 292 282 293 /* ··· 935 924 return 0; 936 925 } 937 926 927 + static int rt2500pci_wait_bbp_ready(struct rt2x00_dev *rt2x00dev) 928 + { 929 + unsigned int i; 930 + u8 value; 931 + 932 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 933 + rt2500pci_bbp_read(rt2x00dev, 0, &value); 934 + if ((value != 0xff) && (value != 0x00)) 935 + return 0; 936 + udelay(REGISTER_BUSY_DELAY); 937 + } 938 + 939 + ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 940 + return -EACCES; 941 + } 942 + 938 943 static int rt2500pci_init_bbp(struct rt2x00_dev *rt2x00dev) 939 944 { 940 945 unsigned int i; ··· 958 931 u8 reg_id; 959 932 u8 value; 960 933 961 - for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 962 - rt2500pci_bbp_read(rt2x00dev, 0, &value); 963 - if ((value != 0xff) && (value != 0x00)) 964 - goto continue_csr_init; 965 - NOTICE(rt2x00dev, "Waiting for BBP register.\n"); 966 - udelay(REGISTER_BUSY_DELAY); 967 - } 934 + if (unlikely(rt2500pci_wait_bbp_ready(rt2x00dev))) 935 + return -EACCES; 968 936 969 - ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 970 - return -EACCES; 971 - 972 - continue_csr_init: 973 937 rt2500pci_bbp_write(rt2x00dev, 3, 0x02); 974 938 rt2500pci_bbp_write(rt2x00dev, 4, 0x19); 975 939 rt2500pci_bbp_write(rt2x00dev, 14, 0x1c); ··· 1015 997 1016 998 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg); 1017 999 rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX, 1018 - state == STATE_RADIO_RX_OFF); 1000 + (state == STATE_RADIO_RX_OFF) || 1001 + (state == STATE_RADIO_RX_OFF_LINK)); 1019 1002 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg); 1020 1003 } 1021 1004 ··· 1053 1034 /* 1054 1035 * Initialize all registers. 1055 1036 */ 1056 - if (rt2500pci_init_queues(rt2x00dev) || 1057 - rt2500pci_init_registers(rt2x00dev) || 1058 - rt2500pci_init_bbp(rt2x00dev)) { 1059 - ERROR(rt2x00dev, "Register initialization failed.\n"); 1037 + if (unlikely(rt2500pci_init_queues(rt2x00dev) || 1038 + rt2500pci_init_registers(rt2x00dev) || 1039 + rt2500pci_init_bbp(rt2x00dev))) 1060 1040 return -EIO; 1061 - } 1062 - 1063 - /* 1064 - * Enable interrupts. 1065 - */ 1066 - rt2500pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON); 1067 1041 1068 1042 return 0; 1069 1043 } ··· 1078 1066 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg); 1079 1067 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1); 1080 1068 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg); 1081 - 1082 - /* 1083 - * Disable interrupts. 1084 - */ 1085 - rt2500pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_OFF); 1086 1069 } 1087 1070 1088 1071 static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev, ··· 1112 1105 msleep(10); 1113 1106 } 1114 1107 1115 - NOTICE(rt2x00dev, "Device failed to enter state %d, " 1116 - "current device state: bbp %d and rf %d.\n", 1117 - state, bbp_state, rf_state); 1118 - 1119 1108 return -EBUSY; 1120 1109 } 1121 1110 ··· 1129 1126 break; 1130 1127 case STATE_RADIO_RX_ON: 1131 1128 case STATE_RADIO_RX_ON_LINK: 1132 - rt2500pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); 1133 - break; 1134 1129 case STATE_RADIO_RX_OFF: 1135 1130 case STATE_RADIO_RX_OFF_LINK: 1136 - rt2500pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 1131 + rt2500pci_toggle_rx(rt2x00dev, state); 1132 + break; 1133 + case STATE_RADIO_IRQ_ON: 1134 + case STATE_RADIO_IRQ_OFF: 1135 + rt2500pci_toggle_irq(rt2x00dev, state); 1137 1136 break; 1138 1137 case STATE_DEEP_SLEEP: 1139 1138 case STATE_SLEEP: ··· 1147 1142 retval = -ENOTSUPP; 1148 1143 break; 1149 1144 } 1145 + 1146 + if (unlikely(retval)) 1147 + ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n", 1148 + state, retval); 1150 1149 1151 1150 return retval; 1152 1151 } ··· 1487 1478 #ifdef CONFIG_RT2500PCI_LEDS 1488 1479 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1489 1480 1490 - rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 1491 - rt2x00dev->led_radio.type = LED_TYPE_RADIO; 1492 - rt2x00dev->led_radio.led_dev.brightness_set = 1493 - rt2500pci_brightness_set; 1494 - rt2x00dev->led_radio.led_dev.blink_set = 1495 - rt2500pci_blink_set; 1496 - rt2x00dev->led_radio.flags = LED_INITIALIZED; 1497 - 1498 - if (value == LED_MODE_TXRX_ACTIVITY) { 1499 - rt2x00dev->led_qual.rt2x00dev = rt2x00dev; 1500 - rt2x00dev->led_qual.type = LED_TYPE_ACTIVITY; 1501 - rt2x00dev->led_qual.led_dev.brightness_set = 1502 - rt2500pci_brightness_set; 1503 - rt2x00dev->led_qual.led_dev.blink_set = 1504 - rt2500pci_blink_set; 1505 - rt2x00dev->led_qual.flags = LED_INITIALIZED; 1506 - } 1481 + rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); 1482 + if (value == LED_MODE_TXRX_ACTIVITY) 1483 + rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_qual, 1484 + LED_TYPE_ACTIVITY); 1507 1485 #endif /* CONFIG_RT2500PCI_LEDS */ 1508 1486 1509 1487 /* ··· 1823 1827 */ 1824 1828 skbdesc = get_skb_frame_desc(skb); 1825 1829 memset(skbdesc, 0, sizeof(*skbdesc)); 1826 - skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; 1827 - skbdesc->data = skb->data; 1828 - skbdesc->data_len = skb->len; 1829 1830 skbdesc->desc = entry_priv->desc; 1830 1831 skbdesc->desc_len = intf->beacon->queue->desc_size; 1831 1832 skbdesc->entry = intf->beacon;
-2
drivers/net/wireless/rt2x00/rt2500pci.h
··· 48 48 * Signal information. 49 49 * Defaul offset is required for RSSI <-> dBm conversion. 50 50 */ 51 - #define MAX_SIGNAL 100 52 - #define MAX_RX_SSI -1 53 51 #define DEFAULT_RSSI_OFFSET 121 54 52 55 53 /*
+54 -54
drivers/net/wireless/rt2x00/rt2500usb.c
··· 316 316 317 317 return 0; 318 318 } 319 + 320 + static void rt2500usb_init_led(struct rt2x00_dev *rt2x00dev, 321 + struct rt2x00_led *led, 322 + enum led_type type) 323 + { 324 + led->rt2x00dev = rt2x00dev; 325 + led->type = type; 326 + led->led_dev.brightness_set = rt2500usb_brightness_set; 327 + led->led_dev.blink_set = rt2500usb_blink_set; 328 + led->flags = LED_INITIALIZED; 329 + } 319 330 #endif /* CONFIG_RT2500USB_LEDS */ 320 331 321 332 /* ··· 858 847 return 0; 859 848 } 860 849 850 + static int rt2500usb_wait_bbp_ready(struct rt2x00_dev *rt2x00dev) 851 + { 852 + unsigned int i; 853 + u8 value; 854 + 855 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 856 + rt2500usb_bbp_read(rt2x00dev, 0, &value); 857 + if ((value != 0xff) && (value != 0x00)) 858 + return 0; 859 + udelay(REGISTER_BUSY_DELAY); 860 + } 861 + 862 + ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 863 + return -EACCES; 864 + } 865 + 861 866 static int rt2500usb_init_bbp(struct rt2x00_dev *rt2x00dev) 862 867 { 863 868 unsigned int i; ··· 881 854 u8 value; 882 855 u8 reg_id; 883 856 884 - for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 885 - rt2500usb_bbp_read(rt2x00dev, 0, &value); 886 - if ((value != 0xff) && (value != 0x00)) 887 - goto continue_csr_init; 888 - NOTICE(rt2x00dev, "Waiting for BBP register.\n"); 889 - udelay(REGISTER_BUSY_DELAY); 890 - } 857 + if (unlikely(rt2500usb_wait_bbp_ready(rt2x00dev))) 858 + return -EACCES; 891 859 892 - ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 893 - return -EACCES; 894 - 895 - continue_csr_init: 896 860 rt2500usb_bbp_write(rt2x00dev, 3, 0x02); 897 861 rt2500usb_bbp_write(rt2x00dev, 4, 0x19); 898 862 rt2500usb_bbp_write(rt2x00dev, 14, 0x1c); ··· 939 921 940 922 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg); 941 923 rt2x00_set_field16(&reg, TXRX_CSR2_DISABLE_RX, 942 - state == STATE_RADIO_RX_OFF); 924 + (state == STATE_RADIO_RX_OFF) || 925 + (state == STATE_RADIO_RX_OFF_LINK)); 943 926 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg); 944 927 } 945 928 ··· 949 930 /* 950 931 * Initialize all registers. 951 932 */ 952 - if (rt2500usb_init_registers(rt2x00dev) || 953 - rt2500usb_init_bbp(rt2x00dev)) { 954 - ERROR(rt2x00dev, "Register initialization failed.\n"); 933 + if (unlikely(rt2500usb_init_registers(rt2x00dev) || 934 + rt2500usb_init_bbp(rt2x00dev))) 955 935 return -EIO; 956 - } 957 936 958 937 return 0; 959 938 } ··· 1004 987 msleep(30); 1005 988 } 1006 989 1007 - NOTICE(rt2x00dev, "Device failed to enter state %d, " 1008 - "current device state: bbp %d and rf %d.\n", 1009 - state, bbp_state, rf_state); 1010 - 1011 990 return -EBUSY; 1012 991 } 1013 992 ··· 1021 1008 break; 1022 1009 case STATE_RADIO_RX_ON: 1023 1010 case STATE_RADIO_RX_ON_LINK: 1024 - rt2500usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); 1025 - break; 1026 1011 case STATE_RADIO_RX_OFF: 1027 1012 case STATE_RADIO_RX_OFF_LINK: 1028 - rt2500usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 1013 + rt2500usb_toggle_rx(rt2x00dev, state); 1014 + break; 1015 + case STATE_RADIO_IRQ_ON: 1016 + case STATE_RADIO_IRQ_OFF: 1017 + /* No support, but no error either */ 1029 1018 break; 1030 1019 case STATE_DEEP_SLEEP: 1031 1020 case STATE_SLEEP: ··· 1039 1024 retval = -ENOTSUPP; 1040 1025 break; 1041 1026 } 1027 + 1028 + if (unlikely(retval)) 1029 + ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n", 1030 + state, retval); 1042 1031 1043 1032 return retval; 1044 1033 } ··· 1088 1069 rt2x00_set_field32(&word, TXD_W0_NEW_SEQ, 1089 1070 test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)); 1090 1071 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); 1091 - rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); 1072 + rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, 1073 + skb->len - skbdesc->desc_len); 1092 1074 rt2x00_set_field32(&word, TXD_W0_CIPHER, CIPHER_NONE); 1093 1075 rt2x00_desc_write(txd, 0, word); 1094 1076 } ··· 1117 1097 { 1118 1098 u16 reg; 1119 1099 1120 - if (queue != QID_BEACON) 1100 + if (queue != QID_BEACON) { 1101 + rt2x00usb_kick_tx_queue(rt2x00dev, queue); 1121 1102 return; 1103 + } 1122 1104 1123 1105 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg); 1124 1106 if (!rt2x00_get_field16(reg, TXRX_CSR19_BEACON_GEN)) { ··· 1156 1134 u32 word1; 1157 1135 1158 1136 /* 1159 - * Copy descriptor to the skb->cb array, this has 2 benefits: 1160 - * 1) Each descriptor word is 4 byte aligned. 1161 - * 2) Descriptor is safe from moving of frame data in rt2x00usb. 1137 + * Copy descriptor to the skbdesc->desc buffer, making it safe from moving of 1138 + * frame data in rt2x00usb. 1162 1139 */ 1163 - skbdesc->desc_len = 1164 - min_t(u16, entry->queue->desc_size, sizeof(entry->skb->cb)); 1165 - memcpy(entry->skb->cb, rxd, skbdesc->desc_len); 1166 - skbdesc->desc = entry->skb->cb; 1140 + memcpy(skbdesc->desc, rxd, skbdesc->desc_len); 1167 1141 rxd = (__le32 *)skbdesc->desc; 1168 1142 1169 1143 /* ··· 1193 1175 * Adjust the skb memory window to the frame boundaries. 1194 1176 */ 1195 1177 skb_trim(entry->skb, rxdesc->size); 1196 - skbdesc->data = entry->skb->data; 1197 - skbdesc->data_len = rxdesc->size; 1198 1178 } 1199 1179 1200 1180 /* ··· 1393 1377 #ifdef CONFIG_RT2500USB_LEDS 1394 1378 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1395 1379 1396 - rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 1397 - rt2x00dev->led_radio.type = LED_TYPE_RADIO; 1398 - rt2x00dev->led_radio.led_dev.brightness_set = 1399 - rt2500usb_brightness_set; 1400 - rt2x00dev->led_radio.led_dev.blink_set = 1401 - rt2500usb_blink_set; 1402 - rt2x00dev->led_radio.flags = LED_INITIALIZED; 1403 - 1404 - if (value == LED_MODE_TXRX_ACTIVITY) { 1405 - rt2x00dev->led_qual.rt2x00dev = rt2x00dev; 1406 - rt2x00dev->led_qual.type = LED_TYPE_ACTIVITY; 1407 - rt2x00dev->led_qual.led_dev.brightness_set = 1408 - rt2500usb_brightness_set; 1409 - rt2x00dev->led_qual.led_dev.blink_set = 1410 - rt2500usb_blink_set; 1411 - rt2x00dev->led_qual.flags = LED_INITIALIZED; 1412 - } 1380 + rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); 1381 + if (value == LED_MODE_TXRX_ACTIVITY) 1382 + rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_qual, 1383 + LED_TYPE_ACTIVITY); 1413 1384 #endif /* CONFIG_RT2500USB_LEDS */ 1414 1385 1415 1386 /* ··· 1706 1703 */ 1707 1704 skbdesc = get_skb_frame_desc(skb); 1708 1705 memset(skbdesc, 0, sizeof(*skbdesc)); 1709 - skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; 1710 - skbdesc->data = skb->data + intf->beacon->queue->desc_size; 1711 - skbdesc->data_len = skb->len - intf->beacon->queue->desc_size; 1712 1706 skbdesc->desc = skb->data; 1713 1707 skbdesc->desc_len = intf->beacon->queue->desc_size; 1714 1708 skbdesc->entry = intf->beacon;
-2
drivers/net/wireless/rt2x00/rt2500usb.h
··· 48 48 * Signal information. 49 49 * Defaul offset is required for RSSI <-> dBm conversion. 50 50 */ 51 - #define MAX_SIGNAL 100 52 - #define MAX_RX_SSI -1 53 51 #define DEFAULT_RSSI_OFFSET 120 54 52 55 53 /*
+9 -4
drivers/net/wireless/rt2x00/rt2x00.h
··· 44 44 /* 45 45 * Module information. 46 46 */ 47 - #define DRV_VERSION "2.1.6" 47 + #define DRV_VERSION "2.1.7" 48 48 #define DRV_PROJECT "http://rt2x00.serialmonkey.com" 49 49 50 50 /* ··· 546 546 void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev, 547 547 struct sk_buff *skb, 548 548 struct txentry_desc *txdesc); 549 - int (*write_tx_data) (struct rt2x00_dev *rt2x00dev, 550 - struct data_queue *queue, struct sk_buff *skb); 549 + int (*write_tx_data) (struct queue_entry *entry); 551 550 int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, 552 551 struct sk_buff *skb); 553 552 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev, ··· 826 827 * The Beacon array also contains the Atim queue 827 828 * if that is supported by the device. 828 829 */ 829 - int data_queues; 830 + unsigned int data_queues; 830 831 struct data_queue *rx; 831 832 struct data_queue *tx; 832 833 struct data_queue *bcn; ··· 928 929 { 929 930 return ((size * 8 * 10) % rate); 930 931 } 932 + 933 + /** 934 + * rt2x00queue_alloc_rxskb - allocate a skb for RX purposes. 935 + * @queue: The queue for which the skb will be applicable. 936 + */ 937 + struct sk_buff *rt2x00queue_alloc_rxskb(struct data_queue *queue); 931 938 932 939 /** 933 940 * rt2x00queue_create_tx_descriptor - Create TX descriptor from mac80211 input
+3 -3
drivers/net/wireless/rt2x00/rt2x00debug.c
··· 133 133 return; 134 134 } 135 135 136 - skbcopy = alloc_skb(sizeof(*dump_hdr) + desc->desc_len + desc->data_len, 136 + skbcopy = alloc_skb(sizeof(*dump_hdr) + desc->desc_len + skb->len, 137 137 GFP_ATOMIC); 138 138 if (!skbcopy) { 139 139 DEBUG(rt2x00dev, "Failed to copy skb for dump.\n"); ··· 144 144 dump_hdr->version = cpu_to_le32(DUMP_HEADER_VERSION); 145 145 dump_hdr->header_length = cpu_to_le32(sizeof(*dump_hdr)); 146 146 dump_hdr->desc_length = cpu_to_le32(desc->desc_len); 147 - dump_hdr->data_length = cpu_to_le32(desc->data_len); 147 + dump_hdr->data_length = cpu_to_le32(skb->len); 148 148 dump_hdr->chip_rt = cpu_to_le16(rt2x00dev->chip.rt); 149 149 dump_hdr->chip_rf = cpu_to_le16(rt2x00dev->chip.rf); 150 150 dump_hdr->chip_rev = cpu_to_le32(rt2x00dev->chip.rev); ··· 155 155 dump_hdr->timestamp_usec = cpu_to_le32(timestamp.tv_usec); 156 156 157 157 memcpy(skb_put(skbcopy, desc->desc_len), desc->desc, desc->desc_len); 158 - memcpy(skb_put(skbcopy, desc->data_len), desc->data, desc->data_len); 158 + memcpy(skb_put(skbcopy, skb->len), skb->data, skb->len); 159 159 160 160 skb_queue_tail(&intf->frame_dump_skbqueue, skbcopy); 161 161 wake_up_interruptible(&intf->frame_dump_waitqueue);
+21
drivers/net/wireless/rt2x00/rt2x00dev.c
··· 112 112 if (status) 113 113 return status; 114 114 115 + rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_IRQ_ON); 116 + 115 117 rt2x00leds_led_radio(rt2x00dev, true); 116 118 rt2x00led_led_activity(rt2x00dev, true); 117 119 ··· 159 157 * Disable radio. 160 158 */ 161 159 rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_OFF); 160 + rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_IRQ_OFF); 162 161 rt2x00led_led_activity(rt2x00dev, false); 163 162 rt2x00leds_led_radio(rt2x00dev, false); 164 163 } ··· 554 551 { 555 552 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 556 553 struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status; 554 + unsigned int header_size = ieee80211_get_hdrlen_from_skb(entry->skb); 557 555 struct ieee80211_supported_band *sband; 558 556 struct ieee80211_hdr *hdr; 559 557 const struct rt2x00_rate *rate; 558 + unsigned int align; 560 559 unsigned int i; 561 560 int idx = -1; 562 561 u16 fc; 562 + 563 + /* 564 + * The data behind the ieee80211 header must be 565 + * aligned on a 4 byte boundary. 566 + */ 567 + align = ((unsigned long)(entry->skb->data + header_size)) & 3; 568 + 569 + if (align) { 570 + skb_push(entry->skb, align); 571 + /* Move entire frame in 1 command */ 572 + memmove(entry->skb->data, entry->skb->data + align, 573 + rxdesc->size); 574 + } 575 + 576 + /* Update data pointers, trim buffer to correct size */ 577 + skb_trim(entry->skb, rxdesc->size); 563 578 564 579 /* 565 580 * Update RX statistics.
+1
drivers/net/wireless/rt2x00/rt2x00lib.h
··· 101 101 /* 102 102 * Queue handlers. 103 103 */ 104 + int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb); 104 105 void rt2x00queue_init_rx(struct rt2x00_dev *rt2x00dev); 105 106 void rt2x00queue_init_tx(struct rt2x00_dev *rt2x00dev); 106 107 int rt2x00queue_initialize(struct rt2x00_dev *rt2x00dev);
+9 -21
drivers/net/wireless/rt2x00/rt2x00mac.c
··· 34 34 struct sk_buff *frag_skb) 35 35 { 36 36 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(frag_skb); 37 - struct skb_frame_desc *skbdesc; 38 37 struct ieee80211_tx_info *rts_info; 39 38 struct sk_buff *skb; 40 39 int size; ··· 64 65 memcpy(skb->cb, frag_skb->cb, sizeof(skb->cb)); 65 66 rts_info = IEEE80211_SKB_CB(skb); 66 67 rts_info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; 68 + rts_info->flags &= ~IEEE80211_TX_CTL_USE_RTS_CTS; 67 69 rts_info->flags &= ~IEEE80211_TX_CTL_USE_CTS_PROTECT; 68 70 rts_info->flags &= ~IEEE80211_TX_CTL_REQ_TX_STATUS; 69 71 ··· 82 82 frag_skb->data, size, tx_info, 83 83 (struct ieee80211_rts *)(skb->data)); 84 84 85 - /* 86 - * Initialize skb descriptor 87 - */ 88 - skbdesc = get_skb_frame_desc(skb); 89 - memset(skbdesc, 0, sizeof(*skbdesc)); 90 - skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; 91 - 92 - if (rt2x00dev->ops->lib->write_tx_data(rt2x00dev, queue, skb)) { 85 + if (rt2x00queue_write_tx_frame(queue, skb)) { 93 86 WARNING(rt2x00dev, "Failed to send RTS/CTS frame.\n"); 94 87 return NETDEV_TX_BUSY; 95 88 } ··· 128 135 } 129 136 130 137 /* 131 - * If CTS/RTS is required. and this frame is not CTS or RTS, 132 - * create and queue that frame first. But make sure we have 133 - * at least enough entries available to send this CTS/RTS 134 - * frame as well as the data frame. 138 + * If CTS/RTS is required. create and queue that frame first. 139 + * Make sure we have at least enough entries available to send 140 + * this CTS/RTS frame as well as the data frame. 135 141 * Note that when the driver has set the set_rts_threshold() 136 142 * callback function it doesn't need software generation of 137 - * neither RTS or CTS-to-self frames and handles everything 143 + * either RTS or CTS-to-self frame and handles everything 138 144 * inside the hardware. 139 145 */ 140 146 frame_control = le16_to_cpu(ieee80211hdr->frame_control); 141 - if (!is_rts_frame(frame_control) && !is_cts_frame(frame_control) && 142 - (tx_info->flags & (IEEE80211_TX_CTL_USE_RTS_CTS | 147 + if ((tx_info->flags & (IEEE80211_TX_CTL_USE_RTS_CTS | 143 148 IEEE80211_TX_CTL_USE_CTS_PROTECT)) && 144 149 !rt2x00dev->ops->hw->set_rts_threshold) { 145 150 if (rt2x00queue_available(queue) <= 1) { ··· 151 160 } 152 161 } 153 162 154 - if (rt2x00dev->ops->lib->write_tx_data(rt2x00dev, queue, skb)) { 163 + if (rt2x00queue_write_tx_frame(queue, skb)) { 155 164 ieee80211_stop_queue(rt2x00dev->hw, qid); 156 165 return NETDEV_TX_BUSY; 157 166 } 158 167 159 - if (rt2x00queue_full(queue)) 168 + if (rt2x00queue_threshold(queue)) 160 169 ieee80211_stop_queue(rt2x00dev->hw, qid); 161 - 162 - if (rt2x00dev->ops->lib->kick_tx_queue) 163 - rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, qid); 164 170 165 171 return NETDEV_TX_OK; 166 172 }
+21 -51
drivers/net/wireless/rt2x00/rt2x00pci.c
··· 34 34 /* 35 35 * TX data handlers. 36 36 */ 37 - int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev, 38 - struct data_queue *queue, struct sk_buff *skb) 37 + int rt2x00pci_write_tx_data(struct queue_entry *entry) 39 38 { 40 - struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); 41 39 struct queue_entry_priv_pci *entry_priv = entry->priv_data; 42 40 struct skb_frame_desc *skbdesc; 43 - struct txentry_desc txdesc; 44 41 u32 word; 45 - 46 - if (rt2x00queue_full(queue)) 47 - return -EINVAL; 48 42 49 43 rt2x00_desc_read(entry_priv->desc, 0, &word); 50 44 51 - if (rt2x00_get_field32(word, TXD_ENTRY_OWNER_NIC) || 52 - rt2x00_get_field32(word, TXD_ENTRY_VALID)) { 53 - ERROR(rt2x00dev, 54 - "Arrived at non-free entry in the non-full queue %d.\n" 45 + /* 46 + * This should not happen, we already checked the entry 47 + * was ours. When the hardware disagrees there has been 48 + * a queue corruption! 49 + */ 50 + if (unlikely(rt2x00_get_field32(word, TXD_ENTRY_OWNER_NIC) || 51 + rt2x00_get_field32(word, TXD_ENTRY_VALID))) { 52 + ERROR(entry->queue->rt2x00dev, 53 + "Corrupt queue %d, accessing entry which is not ours.\n" 55 54 "Please file bug report to %s.\n", 56 55 entry->queue->qid, DRV_PROJECT); 57 56 return -EINVAL; 58 57 } 59 58 60 59 /* 61 - * Copy all TX descriptor information into txdesc, 62 - * after that we are free to use the skb->cb array 63 - * for our information. 64 - */ 65 - entry->skb = skb; 66 - rt2x00queue_create_tx_descriptor(entry, &txdesc); 67 - 68 - /* 69 60 * Fill in skb descriptor 70 61 */ 71 - skbdesc = get_skb_frame_desc(skb); 62 + skbdesc = get_skb_frame_desc(entry->skb); 72 63 memset(skbdesc, 0, sizeof(*skbdesc)); 73 - skbdesc->data = skb->data; 74 - skbdesc->data_len = skb->len; 75 64 skbdesc->desc = entry_priv->desc; 76 - skbdesc->desc_len = queue->desc_size; 65 + skbdesc->desc_len = entry->queue->desc_size; 77 66 skbdesc->entry = entry; 78 67 79 - memcpy(entry_priv->data, skb->data, skb->len); 80 - 81 - rt2x00queue_write_tx_descriptor(entry, &txdesc); 82 - rt2x00queue_index_inc(queue, Q_INDEX); 68 + memcpy(entry_priv->data, entry->skb->data, entry->skb->len); 83 69 84 70 return 0; 85 71 } ··· 79 93 struct data_queue *queue = rt2x00dev->rx; 80 94 struct queue_entry *entry; 81 95 struct queue_entry_priv_pci *entry_priv; 82 - struct ieee80211_hdr *hdr; 83 96 struct skb_frame_desc *skbdesc; 84 97 struct rxdone_entry_desc rxdesc; 85 - int header_size; 86 - int align; 87 98 u32 word; 88 99 89 100 while (1) { ··· 94 111 memset(&rxdesc, 0, sizeof(rxdesc)); 95 112 rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); 96 113 97 - hdr = (struct ieee80211_hdr *)entry_priv->data; 98 - header_size = 99 - ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)); 100 - 101 114 /* 102 - * The data behind the ieee80211 header must be 103 - * aligned on a 4 byte boundary. 115 + * Allocate the sk_buffer and copy all data into it. 104 116 */ 105 - align = header_size % 4; 106 - 107 - /* 108 - * Allocate the sk_buffer, initialize it and copy 109 - * all data into it. 110 - */ 111 - entry->skb = dev_alloc_skb(rxdesc.size + align); 117 + entry->skb = rt2x00queue_alloc_rxskb(queue); 112 118 if (!entry->skb) 113 119 return; 114 120 115 - skb_reserve(entry->skb, align); 116 - memcpy(skb_put(entry->skb, rxdesc.size), 117 - entry_priv->data, rxdesc.size); 121 + memcpy(entry->skb->data, entry_priv->data, rxdesc.size); 122 + skb_trim(entry->skb, rxdesc.size); 118 123 119 124 /* 120 125 * Fill in skb descriptor 121 126 */ 122 127 skbdesc = get_skb_frame_desc(entry->skb); 123 128 memset(skbdesc, 0, sizeof(*skbdesc)); 124 - skbdesc->data = entry->skb->data; 125 - skbdesc->data_len = entry->skb->len; 126 129 skbdesc->desc = entry_priv->desc; 127 130 skbdesc->desc_len = queue->desc_size; 128 131 skbdesc->entry = entry; ··· 147 178 rt2x00_set_field32(&word, TXD_ENTRY_VALID, 0); 148 179 rt2x00_desc_write(entry_priv->desc, 0, word); 149 180 181 + __clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); 150 182 rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); 151 183 152 184 /* 153 - * If the data queue was full before the txdone handler 154 - * we must make sure the packet queue in the mac80211 stack 185 + * If the data queue was below the threshold before the txdone 186 + * handler we must make sure the packet queue in the mac80211 stack 155 187 * is reenabled when the txdone handler has finished. 156 188 */ 157 - if (!rt2x00queue_full(entry->queue)) 189 + if (!rt2x00queue_threshold(entry->queue)) 158 190 ieee80211_wake_queue(rt2x00dev->hw, qid); 159 191 160 192 }
+7 -4
drivers/net/wireless/rt2x00/rt2x00pci.h
··· 87 87 memcpy_toio(rt2x00dev->csr.base + offset, value, length); 88 88 } 89 89 90 - /* 91 - * TX data handlers. 90 + /** 91 + * rt2x00pci_write_tx_data - Initialize data for TX operation 92 + * @entry: The entry where the frame is located 93 + * 94 + * This function will initialize the DMA and skb descriptor 95 + * to prepare the entry for the actual TX operation. 92 96 */ 93 - int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev, 94 - struct data_queue *queue, struct sk_buff *skb); 97 + int rt2x00pci_write_tx_data(struct queue_entry *entry); 95 98 96 99 /** 97 100 * struct queue_entry_priv_pci: Per entry PCI specific information
+98 -15
drivers/net/wireless/rt2x00/rt2x00queue.c
··· 29 29 #include "rt2x00.h" 30 30 #include "rt2x00lib.h" 31 31 32 + struct sk_buff *rt2x00queue_alloc_rxskb(struct data_queue *queue) 33 + { 34 + struct sk_buff *skb; 35 + unsigned int frame_size; 36 + unsigned int reserved_size; 37 + 38 + /* 39 + * The frame size includes descriptor size, because the 40 + * hardware directly receive the frame into the skbuffer. 41 + */ 42 + frame_size = queue->data_size + queue->desc_size; 43 + 44 + /* 45 + * For the allocation we should keep a few things in mind: 46 + * 1) 4byte alignment of 802.11 payload 47 + * 48 + * For (1) we need at most 4 bytes to guarentee the correct 49 + * alignment. We are going to optimize the fact that the chance 50 + * that the 802.11 header_size % 4 == 2 is much bigger then 51 + * anything else. However since we need to move the frame up 52 + * to 3 bytes to the front, which means we need to preallocate 53 + * 6 bytes. 54 + */ 55 + reserved_size = 6; 56 + 57 + /* 58 + * Allocate skbuffer. 59 + */ 60 + skb = dev_alloc_skb(frame_size + reserved_size); 61 + if (!skb) 62 + return NULL; 63 + 64 + skb_reserve(skb, reserved_size); 65 + skb_put(skb, frame_size); 66 + 67 + return skb; 68 + } 69 + EXPORT_SYMBOL_GPL(rt2x00queue_alloc_rxskb); 70 + 32 71 void rt2x00queue_create_tx_descriptor(struct queue_entry *entry, 33 72 struct txentry_desc *txdesc) 34 73 { ··· 130 91 /* 131 92 * Check if more fragments are pending 132 93 */ 133 - if (ieee80211_get_morefrag(hdr)) { 94 + if (ieee80211_has_morefrags(hdr->frame_control)) { 134 95 __set_bit(ENTRY_TXD_BURST, &txdesc->flags); 135 96 __set_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags); 136 97 } ··· 202 163 void rt2x00queue_write_tx_descriptor(struct queue_entry *entry, 203 164 struct txentry_desc *txdesc) 204 165 { 205 - struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 206 - struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); 166 + struct data_queue *queue = entry->queue; 167 + struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; 207 168 208 169 rt2x00dev->ops->lib->write_tx_desc(rt2x00dev, entry->skb, txdesc); 209 170 ··· 214 175 rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TX, entry->skb); 215 176 216 177 /* 217 - * We are done writing the frame to the queue entry, 218 - * also kick the queue in case the correct flags are set, 219 - * note that this will automatically filter beacons and 220 - * RTS/CTS frames since those frames don't have this flag 221 - * set. 178 + * Check if we need to kick the queue, there are however a few rules 179 + * 1) Don't kick beacon queue 180 + * 2) Don't kick unless this is the last in frame in a burst. 181 + * When the burst flag is set, this frame is always followed 182 + * by another frame which in some way are related to eachother. 183 + * This is true for fragments, RTS or CTS-to-self frames. 184 + * 3) Rule 2 can be broken when the available entries 185 + * in the queue are less then a certain threshold. 222 186 */ 223 - if (rt2x00dev->ops->lib->kick_tx_queue && 224 - !(skbdesc->flags & FRAME_DESC_DRIVER_GENERATED)) 225 - rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, 226 - entry->queue->qid); 187 + if (entry->queue->qid == QID_BEACON) 188 + return; 189 + 190 + if (rt2x00queue_threshold(queue) || 191 + !test_bit(ENTRY_TXD_BURST, &txdesc->flags)) 192 + rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, queue->qid); 227 193 } 228 194 EXPORT_SYMBOL_GPL(rt2x00queue_write_tx_descriptor); 195 + 196 + int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb) 197 + { 198 + struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); 199 + struct txentry_desc txdesc; 200 + 201 + if (unlikely(rt2x00queue_full(queue))) 202 + return -EINVAL; 203 + 204 + if (__test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) { 205 + ERROR(queue->rt2x00dev, 206 + "Arrived at non-free entry in the non-full queue %d.\n" 207 + "Please file bug report to %s.\n", 208 + queue->qid, DRV_PROJECT); 209 + return -EINVAL; 210 + } 211 + 212 + /* 213 + * Copy all TX descriptor information into txdesc, 214 + * after that we are free to use the skb->cb array 215 + * for our information. 216 + */ 217 + entry->skb = skb; 218 + rt2x00queue_create_tx_descriptor(entry, &txdesc); 219 + 220 + if (unlikely(queue->rt2x00dev->ops->lib->write_tx_data(entry))) { 221 + __clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); 222 + return -EIO; 223 + } 224 + 225 + __set_bit(ENTRY_DATA_PENDING, &entry->flags); 226 + 227 + rt2x00queue_index_inc(queue, Q_INDEX); 228 + rt2x00queue_write_tx_descriptor(entry, &txdesc); 229 + 230 + return 0; 231 + } 229 232 230 233 struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev, 231 234 const enum data_queue_qid queue) ··· 393 312 rt2x00queue_reset(queue); 394 313 395 314 queue->limit = qdesc->entry_num; 315 + queue->threshold = DIV_ROUND_UP(qdesc->entry_num, 10); 396 316 queue->data_size = qdesc->data_size; 397 317 queue->desc_size = qdesc->desc_size; 398 318 ··· 521 439 * TX: qid = QID_AC_BE + index 522 440 * TX: cw_min: 2^5 = 32. 523 441 * TX: cw_max: 2^10 = 1024. 524 - * BCN & Atim: qid = QID_MGMT 442 + * BCN: qid = QID_BEACON 443 + * ATIM: qid = QID_ATIM 525 444 */ 526 445 rt2x00queue_init(rt2x00dev, rt2x00dev->rx, QID_RX); 527 446 ··· 530 447 tx_queue_for_each(rt2x00dev, queue) 531 448 rt2x00queue_init(rt2x00dev, queue, qid++); 532 449 533 - rt2x00queue_init(rt2x00dev, &rt2x00dev->bcn[0], QID_MGMT); 450 + rt2x00queue_init(rt2x00dev, &rt2x00dev->bcn[0], QID_BEACON); 534 451 if (req_atim) 535 - rt2x00queue_init(rt2x00dev, &rt2x00dev->bcn[1], QID_MGMT); 452 + rt2x00queue_init(rt2x00dev, &rt2x00dev->bcn[1], QID_ATIM); 536 453 537 454 return 0; 538 455 }
+18 -9
drivers/net/wireless/rt2x00/rt2x00queue.h
··· 82 82 /** 83 83 * enum skb_frame_desc_flags: Flags for &struct skb_frame_desc 84 84 * 85 - * @FRAME_DESC_DRIVER_GENERATED: Frame was generated inside driver 86 - * and should not be reported back to mac80211 during txdone. 87 85 */ 88 - enum skb_frame_desc_flags { 89 - FRAME_DESC_DRIVER_GENERATED = 1 << 0, 90 - }; 86 + //enum skb_frame_desc_flags { 87 + // TEMPORARILY EMPTY 88 + //}; 91 89 92 90 /** 93 91 * struct skb_frame_desc: Descriptor information for the skb buffer ··· 105 107 struct skb_frame_desc { 106 108 unsigned int flags; 107 109 108 - unsigned short data_len; 109 - unsigned short desc_len; 110 - 111 - void *data; 112 110 void *desc; 111 + unsigned int desc_len; 113 112 114 113 struct queue_entry *entry; 115 114 }; ··· 255 260 * @ENTRY_OWNER_DEVICE_CRYPTO: This entry is owned by the device for data 256 261 * encryption or decryption. The entry should only be touched after 257 262 * the device has signaled it is done with it. 263 + * @ENTRY_DATA_PENDING: This entry contains a valid frame and is waiting 264 + * for the signal to start sending. 258 265 */ 259 266 enum queue_entry_flags { 260 267 ENTRY_BCN_ASSIGNED, 261 268 ENTRY_OWNER_DEVICE_DATA, 262 269 ENTRY_OWNER_DEVICE_CRYPTO, 270 + ENTRY_DATA_PENDING, 263 271 }; 264 272 265 273 /** ··· 320 322 * index corruption due to concurrency. 321 323 * @count: Number of frames handled in the queue. 322 324 * @limit: Maximum number of entries in the queue. 325 + * @threshold: Minimum number of free entries before queue is kicked by force. 323 326 * @length: Number of frames in queue. 324 327 * @index: Index pointers to entry positions in the queue, 325 328 * use &enum queue_index to get a specific index field. ··· 339 340 spinlock_t lock; 340 341 unsigned int count; 341 342 unsigned short limit; 343 + unsigned short threshold; 342 344 unsigned short length; 343 345 unsigned short index[Q_INDEX_MAX]; 344 346 ··· 461 461 static inline int rt2x00queue_available(struct data_queue *queue) 462 462 { 463 463 return queue->limit - queue->length; 464 + } 465 + 466 + /** 467 + * rt2x00queue_threshold - Check if the queue is below threshold 468 + * @queue: Queue to check. 469 + */ 470 + static inline int rt2x00queue_threshold(struct data_queue *queue) 471 + { 472 + return rt2x00queue_available(queue) < queue->threshold; 464 473 } 465 474 466 475 /**
+75 -51
drivers/net/wireless/rt2x00/rt2x00reg.h
··· 130 130 131 131 /* 132 132 * Power of two check, this will check 133 - * if the mask that has been given contains 134 - * and contiguous set of bits. 133 + * if the mask that has been given contains and contiguous set of bits. 134 + * Note that we cannot use the is_power_of_2() function since this 135 + * check must be done at compile-time. 135 136 */ 136 137 #define is_power_of_two(x) ( !((x) & ((x)-1)) ) 137 138 #define low_bit_mask(x) ( ((x)-1) & ~(x) ) 138 139 #define is_valid_mask(x) is_power_of_two(1 + (x) + low_bit_mask(x)) 139 140 141 + /* 142 + * Macro's to find first set bit in a variable. 143 + * These macro's behaves the same as the __ffs() function with 144 + * the most important difference that this is done during 145 + * compile-time rather then run-time. 146 + */ 147 + #define compile_ffs2(__x) \ 148 + __builtin_choose_expr(((__x) & 0x1), 0, 1) 149 + 150 + #define compile_ffs4(__x) \ 151 + __builtin_choose_expr(((__x) & 0x3), \ 152 + (compile_ffs2((__x))), \ 153 + (compile_ffs2((__x) >> 2) + 2)) 154 + 155 + #define compile_ffs8(__x) \ 156 + __builtin_choose_expr(((__x) & 0xf), \ 157 + (compile_ffs4((__x))), \ 158 + (compile_ffs4((__x) >> 4) + 4)) 159 + 160 + #define compile_ffs16(__x) \ 161 + __builtin_choose_expr(((__x) & 0xff), \ 162 + (compile_ffs8((__x))), \ 163 + (compile_ffs8((__x) >> 8) + 8)) 164 + 165 + #define compile_ffs32(__x) \ 166 + __builtin_choose_expr(((__x) & 0xffff), \ 167 + (compile_ffs16((__x))), \ 168 + (compile_ffs16((__x) >> 16) + 16)) 169 + 170 + /* 171 + * This macro will check the requirements for the FIELD{8,16,32} macros 172 + * The mask should be a constant non-zero contiguous set of bits which 173 + * does not exceed the given typelimit. 174 + */ 175 + #define FIELD_CHECK(__mask, __type) \ 176 + BUILD_BUG_ON(!__builtin_constant_p(__mask) || \ 177 + !(__mask) || \ 178 + !is_valid_mask(__mask) || \ 179 + (__mask) != (__type)(__mask)) \ 180 + 140 181 #define FIELD8(__mask) \ 141 182 ({ \ 142 - BUILD_BUG_ON(!(__mask) || \ 143 - !is_valid_mask(__mask) || \ 144 - (__mask) != (u8)(__mask)); \ 183 + FIELD_CHECK(__mask, u8); \ 145 184 (struct rt2x00_field8) { \ 146 - __ffs(__mask), (__mask) \ 185 + compile_ffs8(__mask), (__mask) \ 147 186 }; \ 148 187 }) 149 188 150 189 #define FIELD16(__mask) \ 151 190 ({ \ 152 - BUILD_BUG_ON(!(__mask) || \ 153 - !is_valid_mask(__mask) || \ 154 - (__mask) != (u16)(__mask));\ 191 + FIELD_CHECK(__mask, u16); \ 155 192 (struct rt2x00_field16) { \ 156 - __ffs(__mask), (__mask) \ 193 + compile_ffs16(__mask), (__mask) \ 157 194 }; \ 158 195 }) 159 196 160 197 #define FIELD32(__mask) \ 161 198 ({ \ 162 - BUILD_BUG_ON(!(__mask) || \ 163 - !is_valid_mask(__mask) || \ 164 - (__mask) != (u32)(__mask));\ 199 + FIELD_CHECK(__mask, u32); \ 165 200 (struct rt2x00_field32) { \ 166 - __ffs(__mask), (__mask) \ 201 + compile_ffs32(__mask), (__mask) \ 167 202 }; \ 168 203 }) 169 204 170 - static inline void rt2x00_set_field32(u32 *reg, 171 - const struct rt2x00_field32 field, 172 - const u32 value) 173 - { 174 - *reg &= ~(field.bit_mask); 175 - *reg |= (value << field.bit_offset) & field.bit_mask; 176 - } 205 + #define SET_FIELD(__reg, __type, __field, __value)\ 206 + ({ \ 207 + typecheck(__type, __field); \ 208 + *(__reg) &= ~((__field).bit_mask); \ 209 + *(__reg) |= ((__value) << \ 210 + ((__field).bit_offset)) & \ 211 + ((__field).bit_mask); \ 212 + }) 177 213 178 - static inline u32 rt2x00_get_field32(const u32 reg, 179 - const struct rt2x00_field32 field) 180 - { 181 - return (reg & field.bit_mask) >> field.bit_offset; 182 - } 214 + #define GET_FIELD(__reg, __type, __field) \ 215 + ({ \ 216 + typecheck(__type, __field); \ 217 + ((__reg) & ((__field).bit_mask)) >> \ 218 + ((__field).bit_offset); \ 219 + }) 183 220 184 - static inline void rt2x00_set_field16(u16 *reg, 185 - const struct rt2x00_field16 field, 186 - const u16 value) 187 - { 188 - *reg &= ~(field.bit_mask); 189 - *reg |= (value << field.bit_offset) & field.bit_mask; 190 - } 221 + #define rt2x00_set_field32(__reg, __field, __value) \ 222 + SET_FIELD(__reg, struct rt2x00_field32, __field, __value) 223 + #define rt2x00_get_field32(__reg, __field) \ 224 + GET_FIELD(__reg, struct rt2x00_field32, __field) 191 225 192 - static inline u16 rt2x00_get_field16(const u16 reg, 193 - const struct rt2x00_field16 field) 194 - { 195 - return (reg & field.bit_mask) >> field.bit_offset; 196 - } 226 + #define rt2x00_set_field16(__reg, __field, __value) \ 227 + SET_FIELD(__reg, struct rt2x00_field16, __field, __value) 228 + #define rt2x00_get_field16(__reg, __field) \ 229 + GET_FIELD(__reg, struct rt2x00_field16, __field) 197 230 198 - static inline void rt2x00_set_field8(u8 *reg, 199 - const struct rt2x00_field8 field, 200 - const u8 value) 201 - { 202 - *reg &= ~(field.bit_mask); 203 - *reg |= (value << field.bit_offset) & field.bit_mask; 204 - } 205 - 206 - static inline u8 rt2x00_get_field8(const u8 reg, 207 - const struct rt2x00_field8 field) 208 - { 209 - return (reg & field.bit_mask) >> field.bit_offset; 210 - } 231 + #define rt2x00_set_field8(__reg, __field, __value) \ 232 + SET_FIELD(__reg, struct rt2x00_field8, __field, __value) 233 + #define rt2x00_get_field8(__reg, __field) \ 234 + GET_FIELD(__reg, struct rt2x00_field8, __field) 211 235 212 236 #endif /* RT2X00REG_H */
+65 -114
drivers/net/wireless/rt2x00/rt2x00usb.c
··· 130 130 struct queue_entry *entry = (struct queue_entry *)urb->context; 131 131 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 132 132 struct txdone_entry_desc txdesc; 133 - __le32 *txd = (__le32 *)entry->skb->data; 134 133 enum data_queue_qid qid = skb_get_queue_mapping(entry->skb); 135 - u32 word; 136 134 137 135 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || 138 136 !__test_and_clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) 139 137 return; 140 - 141 - rt2x00_desc_read(txd, 0, &word); 142 138 143 139 /* 144 140 * Remove the descriptor data from the buffer. ··· 165 169 rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); 166 170 167 171 /* 168 - * If the data queue was full before the txdone handler 169 - * we must make sure the packet queue in the mac80211 stack 172 + * If the data queue was below the threshold before the txdone 173 + * handler we must make sure the packet queue in the mac80211 stack 170 174 * is reenabled when the txdone handler has finished. 171 175 */ 172 - if (!rt2x00queue_full(entry->queue)) 176 + if (!rt2x00queue_threshold(entry->queue)) 173 177 ieee80211_wake_queue(rt2x00dev->hw, qid); 174 178 } 175 179 176 - int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, 177 - struct data_queue *queue, struct sk_buff *skb) 180 + int rt2x00usb_write_tx_data(struct queue_entry *entry) 178 181 { 182 + struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 179 183 struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); 180 - struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); 181 184 struct queue_entry_priv_usb *entry_priv = entry->priv_data; 182 185 struct skb_frame_desc *skbdesc; 183 - struct txentry_desc txdesc; 184 186 u32 length; 185 - 186 - if (rt2x00queue_full(queue)) 187 - return -EINVAL; 188 - 189 - if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) { 190 - ERROR(rt2x00dev, 191 - "Arrived at non-free entry in the non-full queue %d.\n" 192 - "Please file bug report to %s.\n", 193 - entry->queue->qid, DRV_PROJECT); 194 - return -EINVAL; 195 - } 196 - 197 - /* 198 - * Copy all TX descriptor information into txdesc, 199 - * after that we are free to use the skb->cb array 200 - * for our information. 201 - */ 202 - entry->skb = skb; 203 - rt2x00queue_create_tx_descriptor(entry, &txdesc); 204 187 205 188 /* 206 189 * Add the descriptor in front of the skb. 207 190 */ 208 - skb_push(skb, queue->desc_size); 209 - memset(skb->data, 0, queue->desc_size); 191 + skb_push(entry->skb, entry->queue->desc_size); 192 + memset(entry->skb->data, 0, entry->queue->desc_size); 210 193 211 194 /* 212 195 * Fill in skb descriptor 213 196 */ 214 - skbdesc = get_skb_frame_desc(skb); 197 + skbdesc = get_skb_frame_desc(entry->skb); 215 198 memset(skbdesc, 0, sizeof(*skbdesc)); 216 - skbdesc->data = skb->data + queue->desc_size; 217 - skbdesc->data_len = skb->len - queue->desc_size; 218 - skbdesc->desc = skb->data; 219 - skbdesc->desc_len = queue->desc_size; 199 + skbdesc->desc = entry->skb->data; 200 + skbdesc->desc_len = entry->queue->desc_size; 220 201 skbdesc->entry = entry; 221 - 222 - rt2x00queue_write_tx_descriptor(entry, &txdesc); 223 202 224 203 /* 225 204 * USB devices cannot blindly pass the skb->len as the 226 205 * length of the data to usb_fill_bulk_urb. Pass the skb 227 206 * to the driver to determine what the length should be. 228 207 */ 229 - length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev, skb); 208 + length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev, entry->skb); 230 209 231 - /* 232 - * Initialize URB and send the frame to the device. 233 - */ 234 - __set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); 235 - usb_fill_bulk_urb(entry_priv->urb, usb_dev, usb_sndbulkpipe(usb_dev, 1), 236 - skb->data, length, rt2x00usb_interrupt_txdone, entry); 237 - usb_submit_urb(entry_priv->urb, GFP_ATOMIC); 238 - 239 - rt2x00queue_index_inc(queue, Q_INDEX); 210 + usb_fill_bulk_urb(entry_priv->urb, usb_dev, 211 + usb_sndbulkpipe(usb_dev, 1), 212 + entry->skb->data, length, 213 + rt2x00usb_interrupt_txdone, entry); 240 214 241 215 return 0; 242 216 } 243 217 EXPORT_SYMBOL_GPL(rt2x00usb_write_tx_data); 244 218 219 + static inline void rt2x00usb_kick_tx_entry(struct queue_entry *entry) 220 + { 221 + struct queue_entry_priv_usb *entry_priv = entry->priv_data; 222 + 223 + if (__test_and_clear_bit(ENTRY_DATA_PENDING, &entry->flags)) 224 + usb_submit_urb(entry_priv->urb, GFP_ATOMIC); 225 + } 226 + 227 + void rt2x00usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev, 228 + const enum data_queue_qid qid) 229 + { 230 + struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, qid); 231 + unsigned long irqflags; 232 + unsigned int index; 233 + unsigned int index_done; 234 + unsigned int i; 235 + 236 + /* 237 + * Only protect the range we are going to loop over, 238 + * if during our loop a extra entry is set to pending 239 + * it should not be kicked during this run, since it 240 + * is part of another TX operation. 241 + */ 242 + spin_lock_irqsave(&queue->lock, irqflags); 243 + index = queue->index[Q_INDEX]; 244 + index_done = queue->index[Q_INDEX_DONE]; 245 + spin_unlock_irqrestore(&queue->lock, irqflags); 246 + 247 + /* 248 + * Start from the TX done pointer, this guarentees that we will 249 + * send out all frames in the correct order. 250 + */ 251 + if (index_done < index) { 252 + for (i = index_done; i < index; i++) 253 + rt2x00usb_kick_tx_entry(&queue->entries[i]); 254 + } else { 255 + for (i = index_done; i < queue->limit; i++) 256 + rt2x00usb_kick_tx_entry(&queue->entries[i]); 257 + 258 + for (i = 0; i < index; i++) 259 + rt2x00usb_kick_tx_entry(&queue->entries[i]); 260 + } 261 + } 262 + EXPORT_SYMBOL_GPL(rt2x00usb_kick_tx_queue); 263 + 245 264 /* 246 265 * RX data handlers. 247 266 */ 248 - static struct sk_buff* rt2x00usb_alloc_rxskb(struct data_queue *queue) 249 - { 250 - struct sk_buff *skb; 251 - unsigned int frame_size; 252 - unsigned int reserved_size; 253 - 254 - /* 255 - * The frame size includes descriptor size, because the 256 - * hardware directly receive the frame into the skbuffer. 257 - */ 258 - frame_size = queue->data_size + queue->desc_size; 259 - 260 - /* 261 - * For the allocation we should keep a few things in mind: 262 - * 1) 4byte alignment of 802.11 payload 263 - * 264 - * For (1) we need at most 4 bytes to guarentee the correct 265 - * alignment. We are going to optimize the fact that the chance 266 - * that the 802.11 header_size % 4 == 2 is much bigger then 267 - * anything else. However since we need to move the frame up 268 - * to 3 bytes to the front, which means we need to preallocate 269 - * 6 bytes. 270 - */ 271 - reserved_size = 6; 272 - 273 - /* 274 - * Allocate skbuffer. 275 - */ 276 - skb = dev_alloc_skb(frame_size + reserved_size); 277 - if (!skb) 278 - return NULL; 279 - 280 - skb_reserve(skb, reserved_size); 281 - skb_put(skb, frame_size); 282 - 283 - return skb; 284 - } 285 - 286 267 static void rt2x00usb_interrupt_rxdone(struct urb *urb) 287 268 { 288 269 struct queue_entry *entry = (struct queue_entry *)urb->context; ··· 267 294 struct sk_buff *skb; 268 295 struct skb_frame_desc *skbdesc; 269 296 struct rxdone_entry_desc rxdesc; 270 - unsigned int header_size; 271 - unsigned int align; 297 + u8 rxd[32]; 272 298 273 299 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || 274 300 !test_and_clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) ··· 287 315 skbdesc = get_skb_frame_desc(entry->skb); 288 316 memset(skbdesc, 0, sizeof(*skbdesc)); 289 317 skbdesc->entry = entry; 318 + skbdesc->desc = rxd; 319 + skbdesc->desc_len = entry->queue->desc_size; 290 320 291 321 memset(&rxdesc, 0, sizeof(rxdesc)); 292 322 rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); 293 - 294 - header_size = ieee80211_get_hdrlen_from_skb(entry->skb); 295 - 296 - /* 297 - * The data behind the ieee80211 header must be 298 - * aligned on a 4 byte boundary. We already reserved 299 - * 2 bytes for header_size % 4 == 2 optimization. 300 - * To determine the number of bytes which the data 301 - * should be moved to the left, we must add these 302 - * 2 bytes to the header_size. 303 - */ 304 - align = (header_size + 2) % 4; 305 - 306 - if (align) { 307 - skb_push(entry->skb, align); 308 - /* Move entire frame in 1 command */ 309 - memmove(entry->skb->data, entry->skb->data + align, 310 - rxdesc.size); 311 - } 312 - 313 - /* Update data pointers, trim buffer to correct size */ 314 - skbdesc->data = entry->skb->data; 315 - skb_trim(entry->skb, rxdesc.size); 316 323 317 324 /* 318 325 * Allocate a new sk buffer to replace the current one. 319 326 * If allocation fails, we should drop the current frame 320 327 * so we can recycle the existing sk buffer for the new frame. 321 328 */ 322 - skb = rt2x00usb_alloc_rxskb(entry->queue); 329 + skb = rt2x00queue_alloc_rxskb(entry->queue); 323 330 if (!skb) 324 331 goto skip_entry; 325 332 ··· 470 519 */ 471 520 entry_size = rt2x00dev->rx->data_size + rt2x00dev->rx->desc_size; 472 521 for (i = 0; i < rt2x00dev->rx->limit; i++) { 473 - skb = rt2x00usb_alloc_rxskb(rt2x00dev->rx); 522 + skb = rt2x00queue_alloc_rxskb(rt2x00dev->rx); 474 523 if (!skb) 475 524 goto exit; 476 525
+18 -4
drivers/net/wireless/rt2x00/rt2x00usb.h
··· 212 212 */ 213 213 void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev); 214 214 215 - /* 216 - * TX data handlers. 215 + /** 216 + * rt2x00usb_write_tx_data - Initialize URB for TX operation 217 + * @entry: The entry where the frame is located 218 + * 219 + * This function will initialize the URB and skb descriptor 220 + * to prepare the entry for the actual TX operation. 217 221 */ 218 - int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, 219 - struct data_queue *queue, struct sk_buff *skb); 222 + int rt2x00usb_write_tx_data(struct queue_entry *entry); 220 223 221 224 /** 222 225 * struct queue_entry_priv_usb: Per entry USB specific information ··· 247 244 unsigned int guardian_data; 248 245 struct urb *guardian_urb; 249 246 }; 247 + 248 + /** 249 + * rt2x00usb_kick_tx_queue - Kick data queue 250 + * @rt2x00dev: Pointer to &struct rt2x00_dev 251 + * @qid: Data queue to kick 252 + * 253 + * This will walk through all entries of the queue and push all pending 254 + * frames to the hardware as a single burst. 255 + */ 256 + void rt2x00usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev, 257 + const enum data_queue_qid qid); 250 258 251 259 /* 252 260 * Device initialization handlers.
+53 -68
drivers/net/wireless/rt2x00/rt61pci.c
··· 330 330 331 331 return 0; 332 332 } 333 + 334 + static void rt61pci_init_led(struct rt2x00_dev *rt2x00dev, 335 + struct rt2x00_led *led, 336 + enum led_type type) 337 + { 338 + led->rt2x00dev = rt2x00dev; 339 + led->type = type; 340 + led->led_dev.brightness_set = rt61pci_brightness_set; 341 + led->led_dev.blink_set = rt61pci_blink_set; 342 + led->flags = LED_INITIALIZED; 343 + } 333 344 #endif /* CONFIG_RT61PCI_LEDS */ 334 345 335 346 /* ··· 1281 1270 return 0; 1282 1271 } 1283 1272 1273 + static int rt61pci_wait_bbp_ready(struct rt2x00_dev *rt2x00dev) 1274 + { 1275 + unsigned int i; 1276 + u8 value; 1277 + 1278 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 1279 + rt61pci_bbp_read(rt2x00dev, 0, &value); 1280 + if ((value != 0xff) && (value != 0x00)) 1281 + return 0; 1282 + udelay(REGISTER_BUSY_DELAY); 1283 + } 1284 + 1285 + ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 1286 + return -EACCES; 1287 + } 1288 + 1284 1289 static int rt61pci_init_bbp(struct rt2x00_dev *rt2x00dev) 1285 1290 { 1286 1291 unsigned int i; ··· 1304 1277 u8 reg_id; 1305 1278 u8 value; 1306 1279 1307 - for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 1308 - rt61pci_bbp_read(rt2x00dev, 0, &value); 1309 - if ((value != 0xff) && (value != 0x00)) 1310 - goto continue_csr_init; 1311 - NOTICE(rt2x00dev, "Waiting for BBP register.\n"); 1312 - udelay(REGISTER_BUSY_DELAY); 1313 - } 1280 + if (unlikely(rt61pci_wait_bbp_ready(rt2x00dev))) 1281 + return -EACCES; 1314 1282 1315 - ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 1316 - return -EACCES; 1317 - 1318 - continue_csr_init: 1319 1283 rt61pci_bbp_write(rt2x00dev, 3, 0x00); 1320 1284 rt61pci_bbp_write(rt2x00dev, 15, 0x30); 1321 1285 rt61pci_bbp_write(rt2x00dev, 21, 0xc8); ··· 1355 1337 1356 1338 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg); 1357 1339 rt2x00_set_field32(&reg, TXRX_CSR0_DISABLE_RX, 1358 - state == STATE_RADIO_RX_OFF); 1340 + (state == STATE_RADIO_RX_OFF) || 1341 + (state == STATE_RADIO_RX_OFF_LINK)); 1359 1342 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg); 1360 1343 } 1361 1344 ··· 1408 1389 /* 1409 1390 * Initialize all registers. 1410 1391 */ 1411 - if (rt61pci_init_queues(rt2x00dev) || 1412 - rt61pci_init_registers(rt2x00dev) || 1413 - rt61pci_init_bbp(rt2x00dev)) { 1414 - ERROR(rt2x00dev, "Register initialization failed.\n"); 1392 + if (unlikely(rt61pci_init_queues(rt2x00dev) || 1393 + rt61pci_init_registers(rt2x00dev) || 1394 + rt61pci_init_bbp(rt2x00dev))) 1415 1395 return -EIO; 1416 - } 1417 - 1418 - /* 1419 - * Enable interrupts. 1420 - */ 1421 - rt61pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON); 1422 1396 1423 1397 /* 1424 1398 * Enable RX. ··· 1443 1431 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC2, 1); 1444 1432 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC3, 1); 1445 1433 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg); 1446 - 1447 - /* 1448 - * Disable interrupts. 1449 - */ 1450 - rt61pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_OFF); 1451 1434 } 1452 1435 1453 1436 static int rt61pci_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state) ··· 1450 1443 u32 reg; 1451 1444 unsigned int i; 1452 1445 char put_to_sleep; 1453 - char current_state; 1454 1446 1455 1447 put_to_sleep = (state != STATE_AWAKE); 1456 1448 ··· 1465 1459 */ 1466 1460 for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 1467 1461 rt2x00pci_register_read(rt2x00dev, MAC_CSR12, &reg); 1468 - current_state = 1469 - rt2x00_get_field32(reg, MAC_CSR12_BBP_CURRENT_STATE); 1470 - if (current_state == !put_to_sleep) 1462 + state = rt2x00_get_field32(reg, MAC_CSR12_BBP_CURRENT_STATE); 1463 + if (state == !put_to_sleep) 1471 1464 return 0; 1472 1465 msleep(10); 1473 1466 } 1474 - 1475 - NOTICE(rt2x00dev, "Device failed to enter state %d, " 1476 - "current device state %d.\n", !put_to_sleep, current_state); 1477 1467 1478 1468 return -EBUSY; 1479 1469 } ··· 1488 1486 break; 1489 1487 case STATE_RADIO_RX_ON: 1490 1488 case STATE_RADIO_RX_ON_LINK: 1491 - rt61pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); 1492 - break; 1493 1489 case STATE_RADIO_RX_OFF: 1494 1490 case STATE_RADIO_RX_OFF_LINK: 1495 - rt61pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 1491 + rt61pci_toggle_rx(rt2x00dev, state); 1492 + break; 1493 + case STATE_RADIO_IRQ_ON: 1494 + case STATE_RADIO_IRQ_OFF: 1495 + rt61pci_toggle_irq(rt2x00dev, state); 1496 1496 break; 1497 1497 case STATE_DEEP_SLEEP: 1498 1498 case STATE_SLEEP: ··· 1506 1502 retval = -ENOTSUPP; 1507 1503 break; 1508 1504 } 1505 + 1506 + if (unlikely(retval)) 1507 + ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n", 1508 + state, retval); 1509 1509 1510 1510 return retval; 1511 1511 } ··· 1562 1554 1563 1555 if (skbdesc->desc_len > TXINFO_SIZE) { 1564 1556 rt2x00_desc_read(txd, 11, &word); 1565 - rt2x00_set_field32(&word, TXD_W11_BUFFER_LENGTH0, skbdesc->data_len); 1557 + rt2x00_set_field32(&word, TXD_W11_BUFFER_LENGTH0, skb->len); 1566 1558 rt2x00_desc_write(txd, 11, word); 1567 1559 } 1568 1560 ··· 1581 1573 rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, 1582 1574 test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags)); 1583 1575 rt2x00_set_field32(&word, TXD_W0_TKIP_MIC, 0); 1584 - rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); 1576 + rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skb->len); 1585 1577 rt2x00_set_field32(&word, TXD_W0_BURST, 1586 1578 test_bit(ENTRY_TXD_BURST, &txdesc->flags)); 1587 1579 rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, CIPHER_NONE); ··· 2075 2067 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom); 2076 2068 value = rt2x00_get_field16(eeprom, EEPROM_LED_LED_MODE); 2077 2069 2078 - rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 2079 - rt2x00dev->led_radio.type = LED_TYPE_RADIO; 2080 - rt2x00dev->led_radio.led_dev.brightness_set = 2081 - rt61pci_brightness_set; 2082 - rt2x00dev->led_radio.led_dev.blink_set = 2083 - rt61pci_blink_set; 2084 - rt2x00dev->led_radio.flags = LED_INITIALIZED; 2085 - 2086 - rt2x00dev->led_assoc.rt2x00dev = rt2x00dev; 2087 - rt2x00dev->led_assoc.type = LED_TYPE_ASSOC; 2088 - rt2x00dev->led_assoc.led_dev.brightness_set = 2089 - rt61pci_brightness_set; 2090 - rt2x00dev->led_assoc.led_dev.blink_set = 2091 - rt61pci_blink_set; 2092 - rt2x00dev->led_assoc.flags = LED_INITIALIZED; 2093 - 2094 - if (value == LED_MODE_SIGNAL_STRENGTH) { 2095 - rt2x00dev->led_qual.rt2x00dev = rt2x00dev; 2096 - rt2x00dev->led_qual.type = LED_TYPE_QUALITY; 2097 - rt2x00dev->led_qual.led_dev.brightness_set = 2098 - rt61pci_brightness_set; 2099 - rt2x00dev->led_qual.led_dev.blink_set = 2100 - rt61pci_blink_set; 2101 - rt2x00dev->led_qual.flags = LED_INITIALIZED; 2102 - } 2070 + rt61pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); 2071 + rt61pci_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); 2072 + if (value == LED_MODE_SIGNAL_STRENGTH) 2073 + rt61pci_init_led(rt2x00dev, &rt2x00dev->led_qual, 2074 + LED_TYPE_QUALITY); 2103 2075 2104 2076 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value); 2105 2077 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0, ··· 2375 2387 */ 2376 2388 skbdesc = get_skb_frame_desc(skb); 2377 2389 memset(skbdesc, 0, sizeof(*skbdesc)); 2378 - skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; 2379 - skbdesc->data = skb->data; 2380 - skbdesc->data_len = skb->len; 2381 2390 skbdesc->desc = entry_priv->desc; 2382 2391 skbdesc->desc_len = intf->beacon->queue->desc_size; 2383 2392 skbdesc->entry = intf->beacon; ··· 2399 2414 skbdesc->desc, skbdesc->desc_len); 2400 2415 rt2x00pci_register_multiwrite(rt2x00dev, 2401 2416 beacon_base + skbdesc->desc_len, 2402 - skbdesc->data, skbdesc->data_len); 2417 + skb->data, skb->len); 2403 2418 rt61pci_kick_tx_queue(rt2x00dev, QID_BEACON); 2404 2419 2405 2420 return 0;
-2
drivers/net/wireless/rt2x00/rt61pci.h
··· 39 39 * Signal information. 40 40 * Defaul offset is required for RSSI <-> dBm conversion. 41 41 */ 42 - #define MAX_SIGNAL 100 43 - #define MAX_RX_SSI -1 44 42 #define DEFAULT_RSSI_OFFSET 120 45 43 46 44 /*
+57 -65
drivers/net/wireless/rt2x00/rt73usb.c
··· 335 335 336 336 return 0; 337 337 } 338 + 339 + static void rt73usb_init_led(struct rt2x00_dev *rt2x00dev, 340 + struct rt2x00_led *led, 341 + enum led_type type) 342 + { 343 + led->rt2x00dev = rt2x00dev; 344 + led->type = type; 345 + led->led_dev.brightness_set = rt73usb_brightness_set; 346 + led->led_dev.blink_set = rt73usb_blink_set; 347 + led->flags = LED_INITIALIZED; 348 + } 338 349 #endif /* CONFIG_RT73USB_LEDS */ 339 350 340 351 /* ··· 1095 1084 return 0; 1096 1085 } 1097 1086 1087 + static int rt73usb_wait_bbp_ready(struct rt2x00_dev *rt2x00dev) 1088 + { 1089 + unsigned int i; 1090 + u8 value; 1091 + 1092 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 1093 + rt73usb_bbp_read(rt2x00dev, 0, &value); 1094 + if ((value != 0xff) && (value != 0x00)) 1095 + return 0; 1096 + udelay(REGISTER_BUSY_DELAY); 1097 + } 1098 + 1099 + ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 1100 + return -EACCES; 1101 + } 1102 + 1098 1103 static int rt73usb_init_bbp(struct rt2x00_dev *rt2x00dev) 1099 1104 { 1100 1105 unsigned int i; ··· 1118 1091 u8 reg_id; 1119 1092 u8 value; 1120 1093 1121 - for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 1122 - rt73usb_bbp_read(rt2x00dev, 0, &value); 1123 - if ((value != 0xff) && (value != 0x00)) 1124 - goto continue_csr_init; 1125 - NOTICE(rt2x00dev, "Waiting for BBP register.\n"); 1126 - udelay(REGISTER_BUSY_DELAY); 1127 - } 1094 + if (unlikely(rt73usb_wait_bbp_ready(rt2x00dev))) 1095 + return -EACCES; 1128 1096 1129 - ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 1130 - return -EACCES; 1131 - 1132 - continue_csr_init: 1133 1097 rt73usb_bbp_write(rt2x00dev, 3, 0x80); 1134 1098 rt73usb_bbp_write(rt2x00dev, 15, 0x30); 1135 1099 rt73usb_bbp_write(rt2x00dev, 21, 0xc8); ··· 1170 1152 1171 1153 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg); 1172 1154 rt2x00_set_field32(&reg, TXRX_CSR0_DISABLE_RX, 1173 - state == STATE_RADIO_RX_OFF); 1155 + (state == STATE_RADIO_RX_OFF) || 1156 + (state == STATE_RADIO_RX_OFF_LINK)); 1174 1157 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg); 1175 1158 } 1176 1159 ··· 1180 1161 /* 1181 1162 * Initialize all registers. 1182 1163 */ 1183 - if (rt73usb_init_registers(rt2x00dev) || 1184 - rt73usb_init_bbp(rt2x00dev)) { 1185 - ERROR(rt2x00dev, "Register initialization failed.\n"); 1164 + if (unlikely(rt73usb_init_registers(rt2x00dev) || 1165 + rt73usb_init_bbp(rt2x00dev))) 1186 1166 return -EIO; 1187 - } 1188 1167 1189 1168 return 0; 1190 1169 } ··· 1204 1187 u32 reg; 1205 1188 unsigned int i; 1206 1189 char put_to_sleep; 1207 - char current_state; 1208 1190 1209 1191 put_to_sleep = (state != STATE_AWAKE); 1210 1192 ··· 1219 1203 */ 1220 1204 for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 1221 1205 rt73usb_register_read(rt2x00dev, MAC_CSR12, &reg); 1222 - current_state = 1223 - rt2x00_get_field32(reg, MAC_CSR12_BBP_CURRENT_STATE); 1224 - if (current_state == !put_to_sleep) 1206 + state = rt2x00_get_field32(reg, MAC_CSR12_BBP_CURRENT_STATE); 1207 + if (state == !put_to_sleep) 1225 1208 return 0; 1226 1209 msleep(10); 1227 1210 } 1228 - 1229 - NOTICE(rt2x00dev, "Device failed to enter state %d, " 1230 - "current device state %d.\n", !put_to_sleep, current_state); 1231 1211 1232 1212 return -EBUSY; 1233 1213 } ··· 1242 1230 break; 1243 1231 case STATE_RADIO_RX_ON: 1244 1232 case STATE_RADIO_RX_ON_LINK: 1245 - rt73usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); 1246 - break; 1247 1233 case STATE_RADIO_RX_OFF: 1248 1234 case STATE_RADIO_RX_OFF_LINK: 1249 - rt73usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 1235 + rt73usb_toggle_rx(rt2x00dev, state); 1236 + break; 1237 + case STATE_RADIO_IRQ_ON: 1238 + case STATE_RADIO_IRQ_OFF: 1239 + /* No support, but no error either */ 1250 1240 break; 1251 1241 case STATE_DEEP_SLEEP: 1252 1242 case STATE_SLEEP: ··· 1260 1246 retval = -ENOTSUPP; 1261 1247 break; 1262 1248 } 1249 + 1250 + if (unlikely(retval)) 1251 + ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n", 1252 + state, retval); 1263 1253 1264 1254 return retval; 1265 1255 } ··· 1320 1302 rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, 1321 1303 test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags)); 1322 1304 rt2x00_set_field32(&word, TXD_W0_TKIP_MIC, 0); 1323 - rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); 1305 + rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, 1306 + skb->len - skbdesc->desc_len); 1324 1307 rt2x00_set_field32(&word, TXD_W0_BURST2, 1325 1308 test_bit(ENTRY_TXD_BURST, &txdesc->flags)); 1326 1309 rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, CIPHER_NONE); ··· 1351 1332 { 1352 1333 u32 reg; 1353 1334 1354 - if (queue != QID_BEACON) 1335 + if (queue != QID_BEACON) { 1336 + rt2x00usb_kick_tx_queue(rt2x00dev, queue); 1355 1337 return; 1338 + } 1356 1339 1357 1340 /* 1358 1341 * For Wi-Fi faily generated beacons between participating stations. ··· 1428 1407 u32 word1; 1429 1408 1430 1409 /* 1431 - * Copy descriptor to the skb->cb array, this has 2 benefits: 1432 - * 1) Each descriptor word is 4 byte aligned. 1433 - * 2) Descriptor is safe from moving of frame data in rt2x00usb. 1410 + * Copy descriptor to the skbdesc->desc buffer, making it safe from moving of 1411 + * frame data in rt2x00usb. 1434 1412 */ 1435 - skbdesc->desc_len = 1436 - min_t(u16, entry->queue->desc_size, sizeof(entry->skb->cb)); 1437 - memcpy(entry->skb->cb, rxd, skbdesc->desc_len); 1438 - skbdesc->desc = entry->skb->cb; 1413 + memcpy(skbdesc->desc, rxd, skbdesc->desc_len); 1439 1414 rxd = (__le32 *)skbdesc->desc; 1440 1415 1441 1416 /* ··· 1463 1446 */ 1464 1447 skb_pull(entry->skb, entry->queue->desc_size); 1465 1448 skb_trim(entry->skb, rxdesc->size); 1466 - skbdesc->data = entry->skb->data; 1467 - skbdesc->data_len = rxdesc->size; 1468 1449 } 1469 1450 1470 1451 /* ··· 1635 1620 #ifdef CONFIG_RT73USB_LEDS 1636 1621 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom); 1637 1622 1638 - rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 1639 - rt2x00dev->led_radio.type = LED_TYPE_RADIO; 1640 - rt2x00dev->led_radio.led_dev.brightness_set = 1641 - rt73usb_brightness_set; 1642 - rt2x00dev->led_radio.led_dev.blink_set = 1643 - rt73usb_blink_set; 1644 - rt2x00dev->led_radio.flags = LED_INITIALIZED; 1645 - 1646 - rt2x00dev->led_assoc.rt2x00dev = rt2x00dev; 1647 - rt2x00dev->led_assoc.type = LED_TYPE_ASSOC; 1648 - rt2x00dev->led_assoc.led_dev.brightness_set = 1649 - rt73usb_brightness_set; 1650 - rt2x00dev->led_assoc.led_dev.blink_set = 1651 - rt73usb_blink_set; 1652 - rt2x00dev->led_assoc.flags = LED_INITIALIZED; 1653 - 1654 - if (value == LED_MODE_SIGNAL_STRENGTH) { 1655 - rt2x00dev->led_qual.rt2x00dev = rt2x00dev; 1656 - rt2x00dev->led_qual.type = LED_TYPE_QUALITY; 1657 - rt2x00dev->led_qual.led_dev.brightness_set = 1658 - rt73usb_brightness_set; 1659 - rt2x00dev->led_qual.led_dev.blink_set = 1660 - rt73usb_blink_set; 1661 - rt2x00dev->led_qual.flags = LED_INITIALIZED; 1662 - } 1623 + rt73usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); 1624 + rt73usb_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); 1625 + if (value == LED_MODE_SIGNAL_STRENGTH) 1626 + rt73usb_init_led(rt2x00dev, &rt2x00dev->led_qual, 1627 + LED_TYPE_QUALITY); 1663 1628 1664 1629 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value); 1665 1630 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0, ··· 1975 1980 */ 1976 1981 skbdesc = get_skb_frame_desc(skb); 1977 1982 memset(skbdesc, 0, sizeof(*skbdesc)); 1978 - skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; 1979 - skbdesc->data = skb->data + intf->beacon->queue->desc_size; 1980 - skbdesc->data_len = skb->len - intf->beacon->queue->desc_size; 1981 1983 skbdesc->desc = skb->data; 1982 1984 skbdesc->desc_len = intf->beacon->queue->desc_size; 1983 1985 skbdesc->entry = intf->beacon;
-2
drivers/net/wireless/rt2x00/rt73usb.h
··· 39 39 * Signal information. 40 40 * Defaul offset is required for RSSI <-> dBm conversion. 41 41 */ 42 - #define MAX_SIGNAL 100 43 - #define MAX_RX_SSI -1 44 42 #define DEFAULT_RSSI_OFFSET 120 45 43 46 44 /*
+1 -1
drivers/net/wireless/rtl8187_dev.c
··· 181 181 flags |= RTL8187_TX_FLAG_NO_ENCRYPT; 182 182 183 183 flags |= ieee80211_get_tx_rate(dev, info)->hw_value << 24; 184 - if (ieee80211_get_morefrag((struct ieee80211_hdr *)skb->data)) 184 + if (ieee80211_has_morefrags(((struct ieee80211_hdr *)skb->data)->frame_control)) 185 185 flags |= RTL8187_TX_FLAG_MORE_FRAG; 186 186 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { 187 187 flags |= RTL8187_TX_FLAG_RTS;
+375 -32
include/linux/ieee80211.h
··· 98 98 99 99 #define IEEE80211_MAX_SSID_LEN 32 100 100 #define IEEE80211_MAX_MESH_ID_LEN 32 101 + #define IEEE80211_QOS_CTL_LEN 2 101 102 102 103 struct ieee80211_hdr { 103 104 __le16 frame_control; ··· 110 109 u8 addr4[6]; 111 110 } __attribute__ ((packed)); 112 111 112 + /** 113 + * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set 114 + * @fc: frame control bytes in little-endian byteorder 115 + */ 116 + static inline int ieee80211_has_tods(__le16 fc) 117 + { 118 + return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0; 119 + } 120 + 121 + /** 122 + * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set 123 + * @fc: frame control bytes in little-endian byteorder 124 + */ 125 + static inline int ieee80211_has_fromds(__le16 fc) 126 + { 127 + return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0; 128 + } 129 + 130 + /** 131 + * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set 132 + * @fc: frame control bytes in little-endian byteorder 133 + */ 134 + static inline int ieee80211_has_a4(__le16 fc) 135 + { 136 + __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS); 137 + return (fc & tmp) == tmp; 138 + } 139 + 140 + /** 141 + * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set 142 + * @fc: frame control bytes in little-endian byteorder 143 + */ 144 + static inline int ieee80211_has_morefrags(__le16 fc) 145 + { 146 + return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0; 147 + } 148 + 149 + /** 150 + * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set 151 + * @fc: frame control bytes in little-endian byteorder 152 + */ 153 + static inline int ieee80211_has_retry(__le16 fc) 154 + { 155 + return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0; 156 + } 157 + 158 + /** 159 + * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set 160 + * @fc: frame control bytes in little-endian byteorder 161 + */ 162 + static inline int ieee80211_has_pm(__le16 fc) 163 + { 164 + return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0; 165 + } 166 + 167 + /** 168 + * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set 169 + * @fc: frame control bytes in little-endian byteorder 170 + */ 171 + static inline int ieee80211_has_moredata(__le16 fc) 172 + { 173 + return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0; 174 + } 175 + 176 + /** 177 + * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set 178 + * @fc: frame control bytes in little-endian byteorder 179 + */ 180 + static inline int ieee80211_has_protected(__le16 fc) 181 + { 182 + return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0; 183 + } 184 + 185 + /** 186 + * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set 187 + * @fc: frame control bytes in little-endian byteorder 188 + */ 189 + static inline int ieee80211_has_order(__le16 fc) 190 + { 191 + return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0; 192 + } 193 + 194 + /** 195 + * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT 196 + * @fc: frame control bytes in little-endian byteorder 197 + */ 198 + static inline int ieee80211_is_mgmt(__le16 fc) 199 + { 200 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 201 + cpu_to_le16(IEEE80211_FTYPE_MGMT); 202 + } 203 + 204 + /** 205 + * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL 206 + * @fc: frame control bytes in little-endian byteorder 207 + */ 208 + static inline int ieee80211_is_ctl(__le16 fc) 209 + { 210 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 211 + cpu_to_le16(IEEE80211_FTYPE_CTL); 212 + } 213 + 214 + /** 215 + * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA 216 + * @fc: frame control bytes in little-endian byteorder 217 + */ 218 + static inline int ieee80211_is_data(__le16 fc) 219 + { 220 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 221 + cpu_to_le16(IEEE80211_FTYPE_DATA); 222 + } 223 + 224 + /** 225 + * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set 226 + * @fc: frame control bytes in little-endian byteorder 227 + */ 228 + static inline int ieee80211_is_data_qos(__le16 fc) 229 + { 230 + /* 231 + * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need 232 + * to check the one bit 233 + */ 234 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) == 235 + cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA); 236 + } 237 + 238 + /** 239 + * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data 240 + * @fc: frame control bytes in little-endian byteorder 241 + */ 242 + static inline int ieee80211_is_data_present(__le16 fc) 243 + { 244 + /* 245 + * mask with 0x40 and test that that bit is clear to only return true 246 + * for the data-containing substypes. 247 + */ 248 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) == 249 + cpu_to_le16(IEEE80211_FTYPE_DATA); 250 + } 251 + 252 + /** 253 + * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ 254 + * @fc: frame control bytes in little-endian byteorder 255 + */ 256 + static inline int ieee80211_is_assoc_req(__le16 fc) 257 + { 258 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 259 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ); 260 + } 261 + 262 + /** 263 + * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP 264 + * @fc: frame control bytes in little-endian byteorder 265 + */ 266 + static inline int ieee80211_is_assoc_resp(__le16 fc) 267 + { 268 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 269 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP); 270 + } 271 + 272 + /** 273 + * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ 274 + * @fc: frame control bytes in little-endian byteorder 275 + */ 276 + static inline int ieee80211_is_reassoc_req(__le16 fc) 277 + { 278 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 279 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ); 280 + } 281 + 282 + /** 283 + * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP 284 + * @fc: frame control bytes in little-endian byteorder 285 + */ 286 + static inline int ieee80211_is_reassoc_resp(__le16 fc) 287 + { 288 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 289 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP); 290 + } 291 + 292 + /** 293 + * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ 294 + * @fc: frame control bytes in little-endian byteorder 295 + */ 296 + static inline int ieee80211_is_probe_req(__le16 fc) 297 + { 298 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 299 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ); 300 + } 301 + 302 + /** 303 + * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP 304 + * @fc: frame control bytes in little-endian byteorder 305 + */ 306 + static inline int ieee80211_is_probe_resp(__le16 fc) 307 + { 308 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 309 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); 310 + } 311 + 312 + /** 313 + * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON 314 + * @fc: frame control bytes in little-endian byteorder 315 + */ 316 + static inline int ieee80211_is_beacon(__le16 fc) 317 + { 318 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 319 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); 320 + } 321 + 322 + /** 323 + * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM 324 + * @fc: frame control bytes in little-endian byteorder 325 + */ 326 + static inline int ieee80211_is_atim(__le16 fc) 327 + { 328 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 329 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM); 330 + } 331 + 332 + /** 333 + * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC 334 + * @fc: frame control bytes in little-endian byteorder 335 + */ 336 + static inline int ieee80211_is_disassoc(__le16 fc) 337 + { 338 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 339 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC); 340 + } 341 + 342 + /** 343 + * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH 344 + * @fc: frame control bytes in little-endian byteorder 345 + */ 346 + static inline int ieee80211_is_auth(__le16 fc) 347 + { 348 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 349 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH); 350 + } 351 + 352 + /** 353 + * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH 354 + * @fc: frame control bytes in little-endian byteorder 355 + */ 356 + static inline int ieee80211_is_deauth(__le16 fc) 357 + { 358 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 359 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH); 360 + } 361 + 362 + /** 363 + * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION 364 + * @fc: frame control bytes in little-endian byteorder 365 + */ 366 + static inline int ieee80211_is_action(__le16 fc) 367 + { 368 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 369 + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); 370 + } 371 + 372 + /** 373 + * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ 374 + * @fc: frame control bytes in little-endian byteorder 375 + */ 376 + static inline int ieee80211_is_back_req(__le16 fc) 377 + { 378 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 379 + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ); 380 + } 381 + 382 + /** 383 + * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK 384 + * @fc: frame control bytes in little-endian byteorder 385 + */ 386 + static inline int ieee80211_is_back(__le16 fc) 387 + { 388 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 389 + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK); 390 + } 391 + 392 + /** 393 + * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL 394 + * @fc: frame control bytes in little-endian byteorder 395 + */ 396 + static inline int ieee80211_is_pspoll(__le16 fc) 397 + { 398 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 399 + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); 400 + } 401 + 402 + /** 403 + * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS 404 + * @fc: frame control bytes in little-endian byteorder 405 + */ 406 + static inline int ieee80211_is_rts(__le16 fc) 407 + { 408 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 409 + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); 410 + } 411 + 412 + /** 413 + * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS 414 + * @fc: frame control bytes in little-endian byteorder 415 + */ 416 + static inline int ieee80211_is_cts(__le16 fc) 417 + { 418 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 419 + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS); 420 + } 421 + 422 + /** 423 + * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK 424 + * @fc: frame control bytes in little-endian byteorder 425 + */ 426 + static inline int ieee80211_is_ack(__le16 fc) 427 + { 428 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 429 + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK); 430 + } 431 + 432 + /** 433 + * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND 434 + * @fc: frame control bytes in little-endian byteorder 435 + */ 436 + static inline int ieee80211_is_cfend(__le16 fc) 437 + { 438 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 439 + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND); 440 + } 441 + 442 + /** 443 + * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK 444 + * @fc: frame control bytes in little-endian byteorder 445 + */ 446 + static inline int ieee80211_is_cfendack(__le16 fc) 447 + { 448 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 449 + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK); 450 + } 451 + 452 + /** 453 + * ieee80211_is_nullfunc - check if FTYPE=IEEE80211_FTYPE_DATA and STYPE=IEEE80211_STYPE_NULLFUNC 454 + * @fc: frame control bytes in little-endian byteorder 455 + */ 456 + static inline int ieee80211_is_nullfunc(__le16 fc) 457 + { 458 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 459 + cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC); 460 + } 113 461 114 462 struct ieee80211s_hdr { 115 463 u8 flags; ··· 670 320 #define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10 671 321 /* 802.11n HT IE masks */ 672 322 #define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03 323 + #define IEEE80211_HT_IE_CHA_SEC_NONE 0x00 673 324 #define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01 674 325 #define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03 675 326 #define IEEE80211_HT_IE_CHA_WIDTH 0x04 ··· 903 552 #define WLAN_MAX_KEY_LEN 32 904 553 905 554 /** 555 + * ieee80211_get_qos_ctl - get pointer to qos control bytes 556 + * @hdr: the frame 557 + * 558 + * The qos ctrl bytes come after the frame_control, duration, seq_num 559 + * and 3 or 4 addresses of length ETH_ALEN. 560 + * 3 addr: 2 + 2 + 2 + 3*6 = 24 561 + * 4 addr: 2 + 2 + 2 + 4*6 = 30 562 + */ 563 + static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr) 564 + { 565 + if (ieee80211_has_a4(hdr->frame_control)) 566 + return (u8 *)hdr + 30; 567 + else 568 + return (u8 *)hdr + 24; 569 + } 570 + 571 + /** 906 572 * ieee80211_get_SA - get pointer to SA 573 + * @hdr: the frame 907 574 * 908 575 * Given an 802.11 frame, this function returns the offset 909 576 * to the source address (SA). It does not verify that the 910 577 * header is long enough to contain the address, and the 911 578 * header must be long enough to contain the frame control 912 579 * field. 913 - * 914 - * @hdr: the frame 915 580 */ 916 581 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr) 917 582 { 918 - __le16 fc = hdr->frame_control; 919 - fc &= cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS); 920 - 921 - switch (fc) { 922 - case __constant_cpu_to_le16(IEEE80211_FCTL_FROMDS): 923 - return hdr->addr3; 924 - case __constant_cpu_to_le16(IEEE80211_FCTL_TODS|IEEE80211_FCTL_FROMDS): 583 + if (ieee80211_has_a4(hdr->frame_control)) 925 584 return hdr->addr4; 926 - default: 927 - return hdr->addr2; 928 - } 585 + if (ieee80211_has_fromds(hdr->frame_control)) 586 + return hdr->addr3; 587 + return hdr->addr2; 929 588 } 930 589 931 590 /** 932 591 * ieee80211_get_DA - get pointer to DA 592 + * @hdr: the frame 933 593 * 934 594 * Given an 802.11 frame, this function returns the offset 935 595 * to the destination address (DA). It does not verify that 936 596 * the header is long enough to contain the address, and the 937 597 * header must be long enough to contain the frame control 938 598 * field. 939 - * 940 - * @hdr: the frame 941 599 */ 942 600 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr) 943 601 { 944 - __le16 fc = hdr->frame_control; 945 - fc &= cpu_to_le16(IEEE80211_FCTL_TODS); 946 - 947 - if (fc) 602 + if (ieee80211_has_tods(hdr->frame_control)) 948 603 return hdr->addr3; 949 604 else 950 605 return hdr->addr1; 951 - } 952 - 953 - /** 954 - * ieee80211_get_morefrag - determine whether the MOREFRAGS bit is set 955 - * 956 - * This function determines whether the "more fragments" bit is set 957 - * in the frame. 958 - * 959 - * @hdr: the frame 960 - */ 961 - static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr) 962 - { 963 - __le16 fc = hdr->frame_control; 964 - return !!(fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)); 965 606 } 966 607 967 608 #endif /* IEEE80211_H */
+4 -4
include/linux/nl80211.h
··· 122 122 NL80211_CMD_NEW_STATION, 123 123 NL80211_CMD_DEL_STATION, 124 124 125 - /* add commands here */ 126 - 127 125 NL80211_CMD_GET_MPATH, 128 126 NL80211_CMD_SET_MPATH, 129 127 NL80211_CMD_NEW_MPATH, 130 128 NL80211_CMD_DEL_MPATH, 129 + 130 + /* add commands here */ 131 131 132 132 /* used to define NL80211_CMD_MAX below */ 133 133 __NL80211_CMD_AFTER_LAST, ··· 230 230 231 231 NL80211_ATTR_MNTR_FLAGS, 232 232 233 - /* add attributes here, update the policy in nl80211.c */ 234 - 235 233 NL80211_ATTR_MESH_ID, 236 234 NL80211_ATTR_STA_PLINK_ACTION, 237 235 NL80211_ATTR_MPATH_NEXT_HOP, 238 236 NL80211_ATTR_MPATH_INFO, 237 + 238 + /* add attributes here, update the policy in nl80211.c */ 239 239 240 240 __NL80211_ATTR_AFTER_LAST, 241 241 NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
+7 -1
include/net/mac80211.h
··· 1535 1535 * 1536 1536 * @skb: the frame 1537 1537 */ 1538 - int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb); 1538 + unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb); 1539 1539 1540 1540 /** 1541 1541 * ieee80211_get_hdrlen - get header length from frame control ··· 1546 1546 * @fc: the frame control field (in CPU endianness) 1547 1547 */ 1548 1548 int ieee80211_get_hdrlen(u16 fc); 1549 + 1550 + /** 1551 + * ieee80211_hdrlen - get header length in bytes from frame control 1552 + * @fc: frame control field in little-endian format 1553 + */ 1554 + unsigned int ieee80211_hdrlen(__le16 fc); 1549 1555 1550 1556 /** 1551 1557 * ieee80211_get_tkip_key - get a TKIP rc4 for skb
+1 -1
net/mac80211/ieee80211_i.h
··· 876 876 int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len); 877 877 struct sta_info *ieee80211_ibss_add_sta(struct net_device *dev, 878 878 struct sk_buff *skb, u8 *bssid, 879 - u8 *addr); 879 + u8 *addr, u64 supp_rates); 880 880 int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason); 881 881 int ieee80211_sta_disassociate(struct net_device *dev, u16 reason); 882 882 void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
+2 -1
net/mac80211/main.c
··· 1707 1707 1708 1708 debugfs_hw_add(local); 1709 1709 1710 - local->hw.conf.beacon_int = 1000; 1710 + if (local->hw.conf.beacon_int < 10) 1711 + local->hw.conf.beacon_int = 100; 1711 1712 1712 1713 local->wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC | 1713 1714 IEEE80211_HW_SIGNAL_DB |
+12 -5
net/mac80211/mlme.c
··· 2863 2863 dev->name, print_mac(mac, mgmt->bssid)); 2864 2864 ieee80211_sta_join_ibss(dev, &sdata->u.sta, bss); 2865 2865 ieee80211_ibss_add_sta(dev, NULL, 2866 - mgmt->bssid, mgmt->sa); 2866 + mgmt->bssid, mgmt->sa, 2867 + BIT(rx_status->rate_idx)); 2867 2868 } 2868 2869 } 2869 2870 ··· 3584 3583 sband = local->hw.wiphy->bands[bss->band]; 3585 3584 3586 3585 if (local->hw.conf.beacon_int == 0) 3587 - local->hw.conf.beacon_int = 10000; 3586 + local->hw.conf.beacon_int = 100; 3588 3587 bss->beacon_int = local->hw.conf.beacon_int; 3589 3588 bss->last_update = jiffies; 3590 3589 bss->capability = WLAN_CAPABILITY_IBSS; ··· 4308 4307 4309 4308 struct sta_info *ieee80211_ibss_add_sta(struct net_device *dev, 4310 4309 struct sk_buff *skb, u8 *bssid, 4311 - u8 *addr) 4310 + u8 *addr, u64 supp_rates) 4312 4311 { 4313 4312 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 4314 4313 struct sta_info *sta; 4315 4314 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4316 4315 DECLARE_MAC_BUF(mac); 4316 + int band = local->hw.conf.channel->band; 4317 4317 4318 4318 /* TODO: Could consider removing the least recently used entry and 4319 4319 * allow new one to be added. */ ··· 4326 4324 return NULL; 4327 4325 } 4328 4326 4327 + if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) 4328 + return NULL; 4329 + 4329 4330 printk(KERN_DEBUG "%s: Adding new IBSS station %s (dev=%s)\n", 4330 4331 wiphy_name(local->hw.wiphy), print_mac(mac, addr), dev->name); 4331 4332 ··· 4338 4333 4339 4334 set_sta_flags(sta, WLAN_STA_AUTHORIZED); 4340 4335 4341 - sta->supp_rates[local->hw.conf.channel->band] = 4342 - sdata->u.sta.supp_rates_bits[local->hw.conf.channel->band]; 4336 + if (supp_rates) 4337 + sta->supp_rates[band] = supp_rates; 4338 + else 4339 + sta->supp_rates[band] = sdata->u.sta.supp_rates_bits[band]; 4343 4340 4344 4341 rate_control_rate_init(sta, local); 4345 4342
+15 -14
net/mac80211/rx.c
··· 67 67 return 1; 68 68 if (unlikely(skb->len < 16 + present_fcs_len + radiotap_len)) 69 69 return 1; 70 - if (((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 71 - cpu_to_le16(IEEE80211_FTYPE_CTL)) && 72 - ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) != 73 - cpu_to_le16(IEEE80211_STYPE_PSPOLL)) && 74 - ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) != 75 - cpu_to_le16(IEEE80211_STYPE_BACK_REQ))) 70 + if (ieee80211_is_ctl(hdr->frame_control) && 71 + !ieee80211_is_pspoll(hdr->frame_control) && 72 + !ieee80211_is_back_req(hdr->frame_control)) 76 73 return 1; 77 74 return 0; 78 75 } ··· 1823 1826 if (!bssid) 1824 1827 return 0; 1825 1828 if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT && 1826 - (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) 1829 + (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) { 1830 + if (!rx->sta) 1831 + rx->sta = ieee80211_ibss_add_sta(sdata->dev, 1832 + rx->skb, bssid, hdr->addr2, 1833 + BIT(rx->status->rate_idx)); 1827 1834 return 1; 1835 + } 1828 1836 else if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { 1829 1837 if (!(rx->flags & IEEE80211_RX_IN_SCAN)) 1830 1838 return 0; ··· 1842 1840 rx->flags &= ~IEEE80211_RX_RA_MATCH; 1843 1841 } else if (!rx->sta) 1844 1842 rx->sta = ieee80211_ibss_add_sta(sdata->dev, rx->skb, 1845 - bssid, hdr->addr2); 1843 + bssid, hdr->addr2, 1844 + BIT(rx->status->rate_idx)); 1846 1845 break; 1847 1846 case IEEE80211_IF_TYPE_MESH_POINT: 1848 1847 if (!multicast && ··· 2121 2118 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 2122 2119 struct sta_info *sta; 2123 2120 struct tid_ampdu_rx *tid_agg_rx; 2124 - u16 fc, sc; 2121 + u16 sc; 2125 2122 u16 mpdu_seq_num; 2126 2123 u8 ret = 0, *qc; 2127 2124 int tid; ··· 2130 2127 if (!sta) 2131 2128 return ret; 2132 2129 2133 - fc = le16_to_cpu(hdr->frame_control); 2134 - 2135 2130 /* filter the QoS data rx stream according to 2136 2131 * STA/TID and check if this STA/TID is on aggregation */ 2137 - if (!WLAN_FC_IS_QOS_DATA(fc)) 2132 + if (!ieee80211_is_data_qos(hdr->frame_control)) 2138 2133 goto end_reorder; 2139 2134 2140 - qc = skb->data + ieee80211_get_hdrlen(fc) - QOS_CONTROL_LEN; 2135 + qc = ieee80211_get_qos_ctl(hdr); 2141 2136 tid = qc[0] & QOS_CONTROL_TID_MASK; 2142 2137 2143 2138 if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_OPERATIONAL) ··· 2144 2143 tid_agg_rx = sta->ampdu_mlme.tid_rx[tid]; 2145 2144 2146 2145 /* null data frames are excluded */ 2147 - if (unlikely(fc & IEEE80211_STYPE_NULLFUNC)) 2146 + if (unlikely(ieee80211_is_nullfunc(hdr->frame_control))) 2148 2147 goto end_reorder; 2149 2148 2150 2149 /* new un-ordered ampdu frame - process it */
+43 -42
net/mac80211/tkip.c
··· 64 64 return tkip_sbox[val & 0xff] ^ swab16(tkip_sbox[val >> 8]); 65 65 } 66 66 67 + static u8 *write_tkip_iv(u8 *pos, u16 iv16) 68 + { 69 + *pos++ = iv16 >> 8; 70 + *pos++ = ((iv16 >> 8) | 0x20) & 0x7f; 71 + *pos++ = iv16 & 0xFF; 72 + return pos; 73 + } 74 + 67 75 /* 68 76 * P1K := Phase1(TA, TK, TSC) 69 77 * TA = transmitter address (48 bits) ··· 79 71 * TSC = TKIP sequence counter (48 bits, only 32 msb bits used) 80 72 * P1K: 80 bits 81 73 */ 82 - static void tkip_mixing_phase1(struct ieee80211_key *key, const u8 *ta, 83 - struct tkip_ctx *ctx, u32 tsc_IV32) 74 + static void tkip_mixing_phase1(const u8 *tk, struct tkip_ctx *ctx, 75 + const u8 *ta, u32 tsc_IV32) 84 76 { 85 77 int i, j; 86 - const u8 *tk = &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY]; 87 78 u16 *p1k = ctx->p1k; 88 79 89 80 p1k[0] = tsc_IV32 & 0xFFFF; ··· 102 95 ctx->initialized = 1; 103 96 } 104 97 105 - static void tkip_mixing_phase2(struct ieee80211_key *key, struct tkip_ctx *ctx, 98 + static void tkip_mixing_phase2(const u8 *tk, struct tkip_ctx *ctx, 106 99 u16 tsc_IV16, u8 *rc4key) 107 100 { 108 101 u16 ppk[6]; 109 102 const u16 *p1k = ctx->p1k; 110 - const u8 *tk = &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY]; 111 103 int i; 112 104 113 105 ppk[0] = p1k[0]; ··· 129 123 ppk[4] += ror16(ppk[3], 1); 130 124 ppk[5] += ror16(ppk[4], 1); 131 125 132 - rc4key[0] = tsc_IV16 >> 8; 133 - rc4key[1] = ((tsc_IV16 >> 8) | 0x20) & 0x7f; 134 - rc4key[2] = tsc_IV16 & 0xFF; 135 - rc4key[3] = ((ppk[5] ^ get_unaligned_le16(tk)) >> 1) & 0xFF; 126 + rc4key = write_tkip_iv(rc4key, tsc_IV16); 127 + *rc4key++ = ((ppk[5] ^ get_unaligned_le16(tk)) >> 1) & 0xFF; 136 128 137 - rc4key += 4; 138 129 for (i = 0; i < 6; i++) 139 130 put_unaligned_le16(ppk[i], rc4key + 2 * i); 140 131 } ··· 139 136 /* Add TKIP IV and Ext. IV at @pos. @iv0, @iv1, and @iv2 are the first octets 140 137 * of the IV. Returns pointer to the octet following IVs (i.e., beginning of 141 138 * the packet payload). */ 142 - u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key, 143 - u8 iv0, u8 iv1, u8 iv2) 139 + u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key, u16 iv16) 144 140 { 145 - *pos++ = iv0; 146 - *pos++ = iv1; 147 - *pos++ = iv2; 141 + pos = write_tkip_iv(pos, iv16); 148 142 *pos++ = (key->conf.keyidx << 6) | (1 << 5) /* Ext IV */; 149 143 put_unaligned_le32(key->u.tkip.tx.iv32, pos); 150 144 return pos + 4; 151 - } 152 - 153 - static void ieee80211_tkip_gen_rc4key(struct ieee80211_key *key, u8 *ta, 154 - u8 *rc4key) 155 - { 156 - /* Calculate per-packet key */ 157 - if (key->u.tkip.tx.iv16 == 0 || !key->u.tkip.tx.initialized) 158 - tkip_mixing_phase1(key, ta, &key->u.tkip.tx, key->u.tkip.tx.iv32); 159 - 160 - tkip_mixing_phase2(key, &key->u.tkip.tx, key->u.tkip.tx.iv16, rc4key); 161 145 } 162 146 163 147 void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf, ··· 153 163 { 154 164 struct ieee80211_key *key = (struct ieee80211_key *) 155 165 container_of(keyconf, struct ieee80211_key, conf); 156 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 157 - u8 *data = (u8 *) hdr; 158 - u16 fc = le16_to_cpu(hdr->frame_control); 159 - int hdr_len = ieee80211_get_hdrlen(fc); 160 - u8 *ta = hdr->addr2; 166 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 167 + u8 *data; 168 + const u8 *tk; 169 + struct tkip_ctx *ctx; 161 170 u16 iv16; 162 171 u32 iv32; 163 172 164 - iv16 = data[hdr_len + 2] | (data[hdr_len] << 8); 165 - iv32 = get_unaligned_le32(data + hdr_len + 4); 173 + data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control); 174 + iv16 = data[2] | (data[0] << 8); 175 + iv32 = get_unaligned_le32(&data[4]); 176 + 177 + tk = &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY]; 178 + ctx = &key->u.tkip.tx; 166 179 167 180 #ifdef CONFIG_TKIP_DEBUG 168 181 printk(KERN_DEBUG "TKIP encrypt: iv16 = 0x%04x, iv32 = 0x%08x\n", 169 182 iv16, iv32); 170 183 171 - if (iv32 != key->u.tkip.tx.iv32) { 184 + if (iv32 != ctx->iv32) { 172 185 printk(KERN_DEBUG "skb: iv32 = 0x%08x key: iv32 = 0x%08x\n", 173 - iv32, key->u.tkip.tx.iv32); 186 + iv32, ctx->iv32); 174 187 printk(KERN_DEBUG "Wrap around of iv16 in the middle of a " 175 188 "fragmented packet\n"); 176 189 } ··· 182 189 /* Update the p1k only when the iv16 in the packet wraps around, this 183 190 * might occur after the wrap around of iv16 in the key in case of 184 191 * fragmented packets. */ 185 - if (iv16 == 0 || !key->u.tkip.tx.initialized) 186 - tkip_mixing_phase1(key, ta, &key->u.tkip.tx, iv32); 192 + if (iv16 == 0 || !ctx->initialized) 193 + tkip_mixing_phase1(tk, ctx, hdr->addr2, iv32); 187 194 188 195 if (type == IEEE80211_TKIP_P1_KEY) { 189 - memcpy(outkey, key->u.tkip.tx.p1k, sizeof(u16) * 5); 196 + memcpy(outkey, ctx->p1k, sizeof(u16) * 5); 190 197 return; 191 198 } 192 199 193 - tkip_mixing_phase2(key, &key->u.tkip.tx, iv16, outkey); 200 + tkip_mixing_phase2(tk, ctx, iv16, outkey); 194 201 } 195 202 EXPORT_SYMBOL(ieee80211_get_tkip_key); 196 203 ··· 204 211 u8 *pos, size_t payload_len, u8 *ta) 205 212 { 206 213 u8 rc4key[16]; 214 + struct tkip_ctx *ctx = &key->u.tkip.tx; 215 + const u8 *tk = &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY]; 207 216 208 - ieee80211_tkip_gen_rc4key(key, ta, rc4key); 209 - pos = ieee80211_tkip_add_iv(pos, key, rc4key[0], rc4key[1], rc4key[2]); 217 + /* Calculate per-packet key */ 218 + if (ctx->iv16 == 0 || !ctx->initialized) 219 + tkip_mixing_phase1(tk, ctx, ta, ctx->iv32); 220 + 221 + tkip_mixing_phase2(tk, ctx, ctx->iv16, rc4key); 222 + 223 + pos = ieee80211_tkip_add_iv(pos, key, key->u.tkip.tx.iv16); 210 224 ieee80211_wep_encrypt_data(tfm, rc4key, 16, pos, payload_len); 211 225 } 212 226 ··· 231 231 u32 iv16; 232 232 u8 rc4key[16], keyid, *pos = payload; 233 233 int res; 234 + const u8 *tk = &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY]; 234 235 235 236 if (payload_len < 12) 236 237 return -1; ··· 282 281 if (!key->u.tkip.rx[queue].initialized || 283 282 key->u.tkip.rx[queue].iv32 != iv32) { 284 283 /* IV16 wrapped around - perform TKIP phase 1 */ 285 - tkip_mixing_phase1(key, ta, &key->u.tkip.rx[queue], iv32); 284 + tkip_mixing_phase1(tk, &key->u.tkip.rx[queue], ta, iv32); 286 285 #ifdef CONFIG_TKIP_DEBUG 287 286 { 288 287 int i; ··· 315 314 } 316 315 } 317 316 318 - tkip_mixing_phase2(key, &key->u.tkip.rx[queue], iv16, rc4key); 317 + tkip_mixing_phase2(tk, &key->u.tkip.rx[queue], iv16, rc4key); 319 318 #ifdef CONFIG_TKIP_DEBUG 320 319 { 321 320 int i;
+2 -2
net/mac80211/tkip.h
··· 13 13 #include <linux/crypto.h> 14 14 #include "key.h" 15 15 16 - u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key, 17 - u8 iv0, u8 iv1, u8 iv2); 16 + u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key, u16 iv16); 17 + 18 18 void ieee80211_tkip_encrypt_data(struct crypto_blkcipher *tfm, 19 19 struct ieee80211_key *key, 20 20 u8 *pos, size_t payload_len, u8 *ta);
+4 -4
net/mac80211/tx.c
··· 660 660 661 661 /* 662 662 * Warn when submitting a fragmented A-MPDU frame and drop it. 663 - * This is an error and needs to be fixed elsewhere, but when 664 - * done needs to take care of monitor interfaces (injection) 665 - * etc. 663 + * This scenario is handled in __ieee80211_tx_prepare but extra 664 + * caution taken here as fragmented ampdu may cause Tx stop. 666 665 */ 667 666 if (WARN_ON(tx->flags & IEEE80211_TX_CTL_AMPDU || 668 667 skb_get_queue_mapping(tx->skb) >= ··· 980 981 if (tx->flags & IEEE80211_TX_FRAGMENTED) { 981 982 if ((tx->flags & IEEE80211_TX_UNICAST) && 982 983 skb->len + FCS_LEN > local->fragmentation_threshold && 983 - !local->ops->set_frag_threshold) 984 + !local->ops->set_frag_threshold && 985 + !(info->flags & IEEE80211_TX_CTL_AMPDU)) 984 986 tx->flags |= IEEE80211_TX_FRAGMENTED; 985 987 else 986 988 tx->flags &= ~IEEE80211_TX_FRAGMENTED;
+55 -26
net/mac80211/util.c
··· 45 45 u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len, 46 46 enum ieee80211_if_types type) 47 47 { 48 - u16 fc; 48 + __le16 fc = hdr->frame_control; 49 49 50 50 /* drop ACK/CTS frames and incorrect hdr len (ctrl) */ 51 51 if (len < 16) 52 52 return NULL; 53 53 54 - fc = le16_to_cpu(hdr->frame_control); 55 - 56 - switch (fc & IEEE80211_FCTL_FTYPE) { 57 - case IEEE80211_FTYPE_DATA: 54 + if (ieee80211_is_data(fc)) { 58 55 if (len < 24) /* drop incorrect hdr len (data) */ 59 56 return NULL; 60 - switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) { 61 - case IEEE80211_FCTL_TODS: 62 - return hdr->addr1; 63 - case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS): 57 + 58 + if (ieee80211_has_a4(fc)) 64 59 return NULL; 65 - case IEEE80211_FCTL_FROMDS: 60 + if (ieee80211_has_tods(fc)) 61 + return hdr->addr1; 62 + if (ieee80211_has_fromds(fc)) 66 63 return hdr->addr2; 67 - case 0: 68 - return hdr->addr3; 69 - } 70 - break; 71 - case IEEE80211_FTYPE_MGMT: 64 + 65 + return hdr->addr3; 66 + } 67 + 68 + if (ieee80211_is_mgmt(fc)) { 72 69 if (len < 24) /* drop incorrect hdr len (mgmt) */ 73 70 return NULL; 74 71 return hdr->addr3; 75 - case IEEE80211_FTYPE_CTL: 76 - if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL) 72 + } 73 + 74 + if (ieee80211_is_ctl(fc)) { 75 + if(ieee80211_is_pspoll(fc)) 77 76 return hdr->addr1; 78 - else if ((fc & IEEE80211_FCTL_STYPE) == 79 - IEEE80211_STYPE_BACK_REQ) { 77 + 78 + if (ieee80211_is_back_req(fc)) { 80 79 switch (type) { 81 80 case IEEE80211_IF_TYPE_STA: 82 81 return hdr->addr2; ··· 83 84 case IEEE80211_IF_TYPE_VLAN: 84 85 return hdr->addr1; 85 86 default: 86 - return NULL; 87 + break; /* fall through to the return */ 87 88 } 88 89 } 89 - else 90 - return NULL; 91 90 } 92 91 93 92 return NULL; ··· 130 133 } 131 134 EXPORT_SYMBOL(ieee80211_get_hdrlen); 132 135 133 - int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) 136 + unsigned int ieee80211_hdrlen(__le16 fc) 134 137 { 135 - const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *) skb->data; 136 - int hdrlen; 138 + unsigned int hdrlen = 24; 139 + 140 + if (ieee80211_is_data(fc)) { 141 + if (ieee80211_has_a4(fc)) 142 + hdrlen = 30; 143 + if (ieee80211_is_data_qos(fc)) 144 + hdrlen += IEEE80211_QOS_CTL_LEN; 145 + goto out; 146 + } 147 + 148 + if (ieee80211_is_ctl(fc)) { 149 + /* 150 + * ACK and CTS are 10 bytes, all others 16. To see how 151 + * to get this condition consider 152 + * subtype mask: 0b0000000011110000 (0x00F0) 153 + * ACK subtype: 0b0000000011010000 (0x00D0) 154 + * CTS subtype: 0b0000000011000000 (0x00C0) 155 + * bits that matter: ^^^ (0x00E0) 156 + * value of those: 0b0000000011000000 (0x00C0) 157 + */ 158 + if ((fc & cpu_to_le16(0x00E0)) == cpu_to_le16(0x00C0)) 159 + hdrlen = 10; 160 + else 161 + hdrlen = 16; 162 + } 163 + out: 164 + return hdrlen; 165 + } 166 + EXPORT_SYMBOL(ieee80211_hdrlen); 167 + 168 + unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) 169 + { 170 + const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *)skb->data; 171 + unsigned int hdrlen; 137 172 138 173 if (unlikely(skb->len < 10)) 139 174 return 0; 140 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)); 175 + hdrlen = ieee80211_hdrlen(hdr->frame_control); 141 176 if (unlikely(hdrlen > skb->len)) 142 177 return 0; 143 178 return hdrlen;
+5 -13
net/mac80211/wme.c
··· 105 105 { 106 106 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr); 107 107 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 108 - unsigned short fc = le16_to_cpu(hdr->frame_control); 109 - int qos; 110 108 111 - /* see if frame is data or non data frame */ 112 - if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) { 109 + if (!ieee80211_is_data(hdr->frame_control)) { 113 110 /* management frames go on AC_VO queue, but are sent 114 111 * without QoS control fields */ 115 112 return 0; ··· 116 119 /* use AC from radiotap */ 117 120 } 118 121 119 - /* is this a QoS frame? */ 120 - qos = fc & IEEE80211_STYPE_QOS_DATA; 121 - 122 - if (!qos) { 122 + if (!ieee80211_is_data_qos(hdr->frame_control)) { 123 123 skb->priority = 0; /* required for correct WPA/11i MIC */ 124 124 return ieee802_1d_to_ac[skb->priority]; 125 125 } ··· 145 151 struct ieee80211_sched_data *q = qdisc_priv(qd); 146 152 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 147 153 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 148 - unsigned short fc = le16_to_cpu(hdr->frame_control); 149 154 struct Qdisc *qdisc; 150 155 struct sta_info *sta; 151 156 int err, queue; ··· 178 185 179 186 /* now we know the 1d priority, fill in the QoS header if there is one 180 187 */ 181 - if (WLAN_FC_IS_QOS_DATA(fc)) { 182 - u8 *p = skb->data + ieee80211_get_hdrlen(fc) - 2; 188 + if (ieee80211_is_data_qos(hdr->frame_control)) { 189 + u8 *p = ieee80211_get_qos_ctl(hdr); 183 190 u8 ack_policy = 0; 184 191 tid = skb->priority & QOS_CONTROL_TAG1D_MASK; 185 192 if (local->wifi_wme_noack_test) 186 193 ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK << 187 194 QOS_CONTROL_ACK_POLICY_SHIFT; 188 195 /* qos header is 2 bytes, second reserved */ 189 - *p = ack_policy | tid; 190 - p++; 196 + *p++ = ack_policy | tid; 191 197 *p = 0; 192 198 193 199 rcu_read_lock();
+16 -53
net/mac80211/wpa.c
··· 24 24 { 25 25 struct ieee80211_hdr *hdr; 26 26 size_t hdrlen; 27 - u16 fc; 28 - int a4_included; 29 - u8 *pos; 27 + __le16 fc; 30 28 31 - hdr = (struct ieee80211_hdr *) skb->data; 32 - fc = le16_to_cpu(hdr->frame_control); 29 + hdr = (struct ieee80211_hdr *)skb->data; 30 + fc = hdr->frame_control; 33 31 34 - hdrlen = 24; 35 - if ((fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) == 36 - (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 37 - hdrlen += ETH_ALEN; 38 - *sa = hdr->addr4; 39 - *da = hdr->addr3; 40 - } else if (fc & IEEE80211_FCTL_FROMDS) { 41 - *sa = hdr->addr3; 42 - *da = hdr->addr1; 43 - } else if (fc & IEEE80211_FCTL_TODS) { 44 - *sa = hdr->addr2; 45 - *da = hdr->addr3; 46 - } else { 47 - *sa = hdr->addr2; 48 - *da = hdr->addr1; 49 - } 32 + hdrlen = ieee80211_hdrlen(fc); 50 33 51 - if (fc & 0x80) 52 - hdrlen += 2; 34 + *sa = ieee80211_get_SA(hdr); 35 + *da = ieee80211_get_DA(hdr); 53 36 54 37 *data = skb->data + hdrlen; 55 38 *data_len = skb->len - hdrlen; 56 39 57 - a4_included = (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == 58 - (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS); 59 - if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && 60 - fc & IEEE80211_STYPE_QOS_DATA) { 61 - pos = (u8 *) &hdr->addr4; 62 - if (a4_included) 63 - pos += 6; 64 - *qos_tid = pos[0] & 0x0f; 65 - *qos_tid |= 0x80; /* qos_included flag */ 66 - } else 40 + if (ieee80211_is_data_qos(fc)) 41 + *qos_tid = (*ieee80211_get_qos_ctl(hdr) & 0x0f) | 0x80; 42 + else 67 43 *qos_tid = 0; 68 44 69 45 return skb->len < hdrlen ? -1 : 0; ··· 162 186 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 163 187 struct ieee80211_key *key = tx->key; 164 188 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 165 - int hdrlen, len, tail; 166 - u16 fc; 189 + unsigned int hdrlen; 190 + int len, tail; 167 191 u8 *pos; 168 192 169 193 info->control.icv_len = TKIP_ICV_LEN; ··· 176 200 return 0; 177 201 } 178 202 179 - fc = le16_to_cpu(hdr->frame_control); 180 - hdrlen = ieee80211_get_hdrlen(fc); 203 + hdrlen = ieee80211_hdrlen(hdr->frame_control); 181 204 len = skb->len - hdrlen; 182 205 183 206 if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) ··· 198 223 key->u.tkip.tx.iv32++; 199 224 200 225 if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { 201 - hdr = (struct ieee80211_hdr *)skb->data; 202 - 203 226 /* hwaccel - with preallocated room for IV */ 204 - ieee80211_tkip_add_iv(pos, key, 205 - (u8) (key->u.tkip.tx.iv16 >> 8), 206 - (u8) (((key->u.tkip.tx.iv16 >> 8) | 0x20) & 207 - 0x7f), 208 - (u8) key->u.tkip.tx.iv16); 227 + ieee80211_tkip_add_iv(pos, key, key->u.tkip.tx.iv16); 209 228 210 229 info->control.hw_key = &tx->key->conf; 211 230 return 0; ··· 241 272 ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx) 242 273 { 243 274 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; 244 - u16 fc; 245 275 int hdrlen, res, hwaccel = 0, wpa_test = 0; 246 276 struct ieee80211_key *key = rx->key; 247 277 struct sk_buff *skb = rx->skb; 248 278 DECLARE_MAC_BUF(mac); 249 279 250 - fc = le16_to_cpu(hdr->frame_control); 251 - hdrlen = ieee80211_get_hdrlen(fc); 280 + hdrlen = ieee80211_hdrlen(hdr->frame_control); 252 281 253 282 if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) 254 283 return RX_CONTINUE; ··· 394 427 struct ieee80211_key *key = tx->key; 395 428 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 396 429 int hdrlen, len, tail; 397 - u16 fc; 398 430 u8 *pos, *pn, *b_0, *aad, *scratch; 399 431 int i; 400 432 ··· 412 446 b_0 = scratch + 3 * AES_BLOCK_LEN; 413 447 aad = scratch + 4 * AES_BLOCK_LEN; 414 448 415 - fc = le16_to_cpu(hdr->frame_control); 416 - hdrlen = ieee80211_get_hdrlen(fc); 449 + hdrlen = ieee80211_hdrlen(hdr->frame_control); 417 450 len = skb->len - hdrlen; 418 451 419 452 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) ··· 481 516 ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) 482 517 { 483 518 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; 484 - u16 fc; 485 519 int hdrlen; 486 520 struct ieee80211_key *key = rx->key; 487 521 struct sk_buff *skb = rx->skb; ··· 488 524 int data_len; 489 525 DECLARE_MAC_BUF(mac); 490 526 491 - fc = le16_to_cpu(hdr->frame_control); 492 - hdrlen = ieee80211_get_hdrlen(fc); 527 + hdrlen = ieee80211_hdrlen(hdr->frame_control); 493 528 494 529 if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) 495 530 return RX_CONTINUE;
+18
net/wireless/reg.c
··· 80 80 IEEE80211_CHAN_RADAR), 81 81 }; 82 82 83 + static const struct ieee80211_channel_range ieee80211_EU_channels[] = { 84 + /* IEEE 802.11b/g, channels 1..13 */ 85 + RANGE_PWR(2412, 2472, 20, 6, 0), 86 + /* IEEE 802.11a, channel 36*/ 87 + RANGE_PWR(5180, 5180, 23, 6, IEEE80211_CHAN_PASSIVE_SCAN), 88 + /* IEEE 802.11a, channel 40*/ 89 + RANGE_PWR(5200, 5200, 23, 6, IEEE80211_CHAN_PASSIVE_SCAN), 90 + /* IEEE 802.11a, channel 44*/ 91 + RANGE_PWR(5220, 5220, 23, 6, IEEE80211_CHAN_PASSIVE_SCAN), 92 + /* IEEE 802.11a, channels 48..64 */ 93 + RANGE_PWR(5240, 5320, 23, 6, IEEE80211_CHAN_NO_IBSS | 94 + IEEE80211_CHAN_RADAR), 95 + /* IEEE 802.11a, channels 100..140 */ 96 + RANGE_PWR(5500, 5700, 30, 6, IEEE80211_CHAN_NO_IBSS | 97 + IEEE80211_CHAN_RADAR), 98 + }; 99 + 83 100 #define REGDOM(_code) \ 84 101 { \ 85 102 .code = __stringify(_code), \ ··· 107 90 static const struct ieee80211_regdomain ieee80211_regdoms[] = { 108 91 REGDOM(US), 109 92 REGDOM(JP), 93 + REGDOM(EU), 110 94 }; 111 95 112 96