29 #include <linux/kernel.h>
30 #include <linux/module.h>
32 #include <linux/sched.h>
33 #include <linux/slab.h>
34 #include <linux/types.h>
37 #include <linux/pci.h>
52 if ((_il_rd(il, addr) & mask) == (bits & mask))
56 }
while (t < timeout);
65 unsigned long reg_flags;
69 spin_unlock_irqrestore(&p->
reg_lock, reg_flags);
76 unsigned long reg_flags;
79 _il_clear_bit(p, r, m);
80 spin_unlock_irqrestore(&p->
reg_lock, reg_flags);
116 WARN_ONCE(1,
"Timeout waiting for ucode processor access "
117 "(CSR_GP_CNTRL 0x%08x)\n", val);
133 if ((il_rd(il, addr) & mask) == mask)
137 }
while (t < timeout);
146 unsigned long reg_flags;
151 val = _il_rd_prph(il, reg);
152 _il_release_nic_access(il);
153 spin_unlock_irqrestore(&il->
reg_lock, reg_flags);
161 unsigned long reg_flags;
165 _il_wr_prph(il, addr, val);
166 _il_release_nic_access(il);
168 spin_unlock_irqrestore(&il->
reg_lock, reg_flags);
175 unsigned long reg_flags;
184 _il_release_nic_access(il);
185 spin_unlock_irqrestore(&il->
reg_lock, reg_flags);
193 unsigned long reg_flags;
199 _il_release_nic_access(il);
201 spin_unlock_irqrestore(&il->
reg_lock, reg_flags);
257 #define HOST_COMPLETE_TIMEOUT (HZ / 2)
264 IL_ERR(
"Bad return from %s (0x%08X)\n",
268 #ifdef CONFIG_IWLEGACY_DEBUG
269 switch (cmd->
hdr.cmd) {
294 cmd->
callback = il_generic_cmd_callback;
301 IL_ERR(
"Error sending %s: enqueue_hcmd failed: %d\n",
321 D_INFO(
"Attempting to send sync command %s\n",
325 D_INFO(
"Setting HCMD_ACTIVE for command %s\n",
331 IL_ERR(
"Error sending %s: enqueue_hcmd failed: %d\n",
341 IL_ERR(
"Error sending %s: time out after %dms.\n",
346 D_INFO(
"Clearing HCMD_ACTIVE for command %s\n",
354 IL_ERR(
"Command %s aborted: RF KILL Switch\n",
360 IL_ERR(
"Command %s failed: FW Error\n",
366 IL_ERR(
"Error: Response NULL in '%s'\n",
399 return il_send_cmd_async(il, cmd);
433 return il_send_cmd_async(il, &cmd);
441 "0=system default, " "1=On(RF On)/Off(RF Off), 2=blinking");
457 {.throughput = 0, .blink_time = 334},
458 {.throughput = 1 * 1024 - 1, .blink_time = 260},
459 {.throughput = 5 * 1024 - 1, .blink_time = 220},
460 {.throughput = 10 * 1024 - 1, .blink_time = 190},
461 {.throughput = 20 * 1024 - 1, .blink_time = 170},
462 {.throughput = 50 * 1024 - 1, .blink_time = 150},
463 {.throughput = 70 * 1024 - 1, .blink_time = 130},
464 {.throughput = 100 * 1024 - 1, .blink_time = 110},
465 {.throughput = 200 * 1024 - 1, .blink_time = 80},
466 {.throughput = 300 * 1024 - 1, .blink_time = 50},
484 IL_ERR(
"undefined blink compensation: "
485 "use pre-defined blinking time\n");
489 return (
u8) ((time * compensation) >> 6);
513 D_LED(
"Led blink time compensation=%u\n",
514 il->
cfg->led_compensation);
516 il_blink_compensation(il, on,
517 il->
cfg->led_compensation);
519 il_blink_compensation(il, off,
520 il->
cfg->led_compensation);
522 ret = il->
ops->send_led_cmd(il, &led_cmd);
535 unsigned long on = 0;
544 il_led_blink_set(
struct led_classdev *led_cdev,
unsigned long *delay_on,
545 unsigned long *delay_off)
559 mode = il->
cfg->led_mode;
563 il->
led.brightness_set = il_led_brightness_set;
564 il->
led.blink_set = il_led_blink_set;
565 il->
led.max_brightness = 1;
572 il->
led.default_trigger =
573 ieee80211_create_tpt_led_trigger(il->
hw,
579 il->
led.default_trigger = ieee80211_get_radio_led_name(il->
hw);
637 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
641 static const u8 il_eeprom_band_2[] = {
642 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16
645 static const u8 il_eeprom_band_3[] = {
646 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
649 static const u8 il_eeprom_band_4[] = {
650 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
653 static const u8 il_eeprom_band_5[] = {
654 145, 149, 153, 157, 161, 165
657 static const u8 il_eeprom_band_6[] = {
661 static const u8 il_eeprom_band_7[] = {
662 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157
672 il_eeprom_verify_signature(
struct il_priv *il)
677 D_EEPROM(
"EEPROM signature=0x%08x\n", gp);
683 IL_ERR(
"bad EEPROM signature," "EEPROM_GP=0x%08x\n", gp);
724 sz = il->
cfg->eeprom_size;
733 il->
ops->apm_init(il);
735 ret = il_eeprom_verify_signature(il);
737 IL_ERR(
"EEPROM not found, EEPROM_GP=0x%08x\n", gp);
743 ret = il->
ops->eeprom_acquire_semaphore(il);
745 IL_ERR(
"Failed to acquire EEPROM semaphore.\n");
751 for (addr = 0; addr < sz; addr +=
sizeof(
u16)) {
763 IL_ERR(
"Time out reading EEPROM[%d]\n", addr);
770 D_EEPROM(
"NVM Type: %s, version: 0x%x\n",
"EEPROM",
775 il->
ops->eeprom_release_semaphore(il);
796 il_init_band_reference(
const struct il_priv *il,
int eep_band,
797 int *eeprom_ch_count,
799 const u8 **eeprom_ch_idx)
805 *eeprom_ch_count =
ARRAY_SIZE(il_eeprom_band_1);
812 *eeprom_ch_count =
ARRAY_SIZE(il_eeprom_band_2);
816 *eeprom_ch_idx = il_eeprom_band_2;
819 *eeprom_ch_count =
ARRAY_SIZE(il_eeprom_band_3);
823 *eeprom_ch_idx = il_eeprom_band_3;
826 *eeprom_ch_count =
ARRAY_SIZE(il_eeprom_band_4);
830 *eeprom_ch_idx = il_eeprom_band_4;
833 *eeprom_ch_count =
ARRAY_SIZE(il_eeprom_band_5);
837 *eeprom_ch_idx = il_eeprom_band_5;
840 *eeprom_ch_count =
ARRAY_SIZE(il_eeprom_band_6);
844 *eeprom_ch_idx = il_eeprom_band_6;
847 *eeprom_ch_count =
ARRAY_SIZE(il_eeprom_band_7);
851 *eeprom_ch_idx = il_eeprom_band_7;
858 #define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \
868 u8 clear_ht40_extension_channel)
875 if (!il_is_channel_valid(ch_info))
878 D_EEPROM(
"HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):"
879 " Ad-Hoc %ssupported\n", ch_info->
channel,
880 il_is_channel_a_band(ch_info) ?
"5.2" :
"2.4",
893 ~clear_ht40_extension_channel;
898 #define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \
907 int eeprom_ch_count = 0;
908 const u8 *eeprom_ch_idx =
NULL;
914 D_EEPROM(
"Channel map already initialized.\n");
918 D_EEPROM(
"Initializing regulatory info from EEPROM\n");
931 IL_ERR(
"Could not allocate channel_info\n");
941 for (band = 1; band <= 5; band++) {
943 il_init_band_reference(il, band, &eeprom_ch_count,
944 &eeprom_ch_info, &eeprom_ch_idx);
947 for (ch = 0; ch < eeprom_ch_count; ch++) {
948 ch_info->
channel = eeprom_ch_idx[ch];
955 ch_info->
eeprom = eeprom_ch_info[ch];
965 if (!(il_is_channel_valid(ch_info))) {
966 D_EEPROM(
"Ch. %d Flags %x [%sGHz] - "
967 "No traffic\n", ch_info->
channel,
969 il_is_channel_a_band(ch_info) ?
"5.2" :
981 D_EEPROM(
"Ch. %d [%sGHz] " "%s%s%s%s%s%s(0x%02x %ddBm):"
982 " Ad-Hoc %ssupported\n", ch_info->
channel,
983 il_is_channel_a_band(ch_info) ?
"5.2" :
"2.4",
990 eeprom_ch_info[ch].
flags,
992 ((eeprom_ch_info[ch].
994 !(eeprom_ch_info[ch].
1008 for (band = 6; band <= 7; band++) {
1011 il_init_band_reference(il, band, &eeprom_ch_count,
1012 &eeprom_ch_info, &eeprom_ch_idx);
1019 for (ch = 0; ch < eeprom_ch_count; ch++) {
1021 il_mod_ht40_chan_info(il, ieeeband, eeprom_ch_idx[ch],
1022 &eeprom_ch_info[ch],
1026 il_mod_ht40_chan_info(il, ieeeband,
1027 eeprom_ch_idx[ch] + 4,
1028 &eeprom_ch_info[ch],
1067 if (channel >= 1 && channel <= 14)
1099 memset(cmd, 0,
sizeof(*cmd));
1104 D_POWER(
"Sleep command for CAM\n");
1110 D_POWER(
"Sending power/sleep command\n");
1114 D_POWER(
"Sleep interval vector = { %d , %d , %d , %d , %d }\n",
1140 if (!il_is_ready_rf(il))
1146 D_INFO(
"Defer power set mode while scanning\n");
1153 ret = il_set_power(il, cmd);
1158 if (il->
ops->update_chain_flags && update_chains)
1159 il->
ops->update_chain_flags(il);
1160 else if (il->
ops->update_chain_flags)
1161 D_POWER(
"Cannot update the power, chain noise "
1162 "calibration running: %d\n",
1167 IL_ERR(
"set power fail, ret = %d", ret);
1177 il_power_sleep_cam_cmd(il, &cmd);
1186 u16 lctl = il_pcie_link_ctl(il);
1190 il->
power_data.debug_sleep_level_override = -1;
1199 #define IL_ACTIVE_DWELL_TIME_24 (30)
1200 #define IL_ACTIVE_DWELL_TIME_52 (20)
1202 #define IL_ACTIVE_DWELL_FACTOR_24GHZ (3)
1203 #define IL_ACTIVE_DWELL_FACTOR_52GHZ (2)
1208 #define IL_PASSIVE_DWELL_TIME_24 (20)
1209 #define IL_PASSIVE_DWELL_TIME_52 (10)
1210 #define IL_PASSIVE_DWELL_BASE (100)
1211 #define IL_CHANNEL_TUNE_TIME 5
1214 il_send_scan_abort(
struct il_priv *il)
1258 D_SCAN(
"Complete scan in mac80211\n");
1272 D_SCAN(
"Forcing scan end while not scanning\n");
1276 D_SCAN(
"Forcing scan end\n");
1280 il_complete_scan(il,
true);
1284 il_do_scan_abort(
struct il_priv *il)
1291 D_SCAN(
"Not performing scan to abort\n");
1296 D_SCAN(
"Scan abort in progress\n");
1300 ret = il_send_scan_abort(il);
1302 D_SCAN(
"Send scan abort failed %d\n", ret);
1305 D_SCAN(
"Successfully send scan abort\n");
1314 D_SCAN(
"Queuing abort scan\n");
1332 D_SCAN(
"Scan cancel timeout\n");
1334 il_do_scan_abort(il);
1350 #ifdef CONFIG_IWLEGACY_DEBUG
1367 D_SCAN(
"Scan start: " "%d [802.11%s] "
1368 "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", notif->
channel,
1377 #ifdef CONFIG_IWLEGACY_DEBUG
1382 D_SCAN(
"Scan ch.res: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d "
1383 "elapsed=%lu usec\n", notif->
channel, notif->
band ?
"bg" :
"a",
1395 #ifdef CONFIG_IWLEGACY_DEBUG
1400 D_SCAN(
"Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n",
1407 D_SCAN(
"Scan on %sGHz took %dms\n",
1450 if (il_is_any_associated(il)) {
1456 value = il->
vif ? il->
vif->bss_conf.beacon_int : 0;
1460 passive =
min(value, passive);
1487 if (!il_is_ready_rf(il)) {
1488 IL_WARN(
"Request scan called when driver not ready.\n");
1493 D_SCAN(
"Multiple concurrent scan requests in parallel.\n");
1498 D_SCAN(
"Scan request while abort pending.\n");
1502 D_SCAN(
"Starting scan...\n");
1507 ret = il->
ops->request_scan(il, vif);
1527 IL_ERR(
"Can not scan on no channels.\n");
1535 D_SCAN(
"Scan already in progress.\n");
1545 ret = il_scan_initiate(il, vif);
1561 D_SCAN(
"Scan check work\n");
1589 eth_broadcast_addr(frame->
da);
1591 eth_broadcast_addr(frame->
bssid);
1597 pos = &frame->
u.probe_req.variable[0];
1611 if (ies && ie_len) {
1612 memcpy(pos, ies, ie_len);
1625 D_SCAN(
"Abort scan work\n");
1640 D_SCAN(
"Completed scan.\n");
1648 D_SCAN(
"Aborted scan completed.\n");
1651 D_SCAN(
"Scan already completed.\n");
1655 il_complete_scan(il, aborted);
1659 if (!il_is_ready_rf(il))
1669 il->
ops->post_scan(il);
1700 il_sta_ucode_activate(
struct il_priv *il,
u8 sta_id)
1704 IL_ERR(
"ACTIVATE a non DRIVER active station id %u addr %pM\n",
1705 sta_id, il->
stations[sta_id].sta.sta.addr);
1708 D_ASSOC(
"STA id %u addr %pM already present"
1709 " in uCode (according to driver)\n", sta_id,
1710 il->
stations[sta_id].sta.sta.addr);
1713 D_ASSOC(
"Added STA id %u addr %pM to uCode\n", sta_id,
1714 il->
stations[sta_id].sta.sta.addr);
1722 u8 sta_id = addsta->
sta.sta_id;
1723 unsigned long flags;
1727 IL_ERR(
"Bad return from C_ADD_STA (0x%08X)\n", pkt->
hdr.flags);
1731 D_INFO(
"Processing response for adding station %u\n", sta_id);
1737 D_INFO(
"C_ADD_STA PASSED\n");
1738 il_sta_ucode_activate(il, sta_id);
1742 IL_ERR(
"Adding station %d failed, no room in table.\n", sta_id);
1745 IL_ERR(
"Adding station %d failed, no block ack resource.\n",
1749 IL_ERR(
"Attempting to modify non-existing station %d\n",
1757 D_INFO(
"%s station id %u addr %pM\n",
1760 il->
stations[sta_id].sta.sta.addr);
1770 D_INFO(
"%s station according to cmd buffer %pM\n",
1773 spin_unlock_irqrestore(&il->
sta_lock, flags);
1784 il_process_add_sta_resp(il, addsta, pkt,
false);
1793 u8 data[
sizeof(*sta)];
1801 D_INFO(
"Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->
sta.addr,
1804 if (flags & CMD_ASYNC)
1805 cmd.
callback = il_add_sta_callback;
1811 cmd.
len = il->
ops->build_addsta_hcmd(sta, data);
1814 if (ret || (flags & CMD_ASYNC))
1819 ret = il_process_add_sta_resp(il, sta, pkt,
true);
1838 D_ASSOC(
"spatial multiplexing power save mode: %s\n",
1847 switch (mimo_ps_mode) {
1857 IL_WARN(
"Invalid MIMO PS mode %d\n", mimo_ps_mode);
1895 else if (is_broadcast_ether_addr(addr))
1899 if (ether_addr_equal(il->
stations[i].sta.sta.addr,
1923 D_INFO(
"STA %d already in process of being added.\n", sta_id);
1927 if ((il->
stations[sta_id].used & IL_STA_DRIVER_ACTIVE) &&
1929 ether_addr_equal(il->
stations[sta_id].sta.sta.addr, addr)) {
1930 D_ASSOC(
"STA %d (%pM) already added, not adding again.\n",
1937 D_ASSOC(
"Add STA to driver ID %d: %pM\n", sta_id, addr);
1943 station->
sta.mode = 0;
1944 station->
sta.sta.sta_id = sta_id;
1945 station->
sta.station_flags = 0;
1952 il_set_ht_add_station(il, sta_id, sta);
1964 #define STA_WAIT_TIMEOUT (HZ/2)
1973 unsigned long flags_spin;
1982 IL_ERR(
"Unable to prepare station %pM for addition\n", addr);
1983 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
1993 D_INFO(
"STA %d already in process of being added.\n", sta_id);
1994 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
1998 if ((il->
stations[sta_id].used & IL_STA_DRIVER_ACTIVE) &&
2000 D_ASSOC(
"STA %d (%pM) already added, not adding again.\n",
2002 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
2009 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
2015 IL_ERR(
"Adding station %pM failed.\n",
2016 il->
stations[sta_id].sta.sta.addr);
2017 il->
stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE;
2018 il->
stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS;
2019 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
2032 il_sta_ucode_deactivate(
struct il_priv *il,
u8 sta_id)
2038 IL_ERR(
"removed non active STA %u\n", sta_id);
2043 D_ASSOC(
"Removed STA %u\n", sta_id);
2047 il_send_remove_station(
struct il_priv *il,
const u8 *
addr,
int sta_id,
2053 unsigned long flags_spin;
2060 .data = &rm_sta_cmd,
2063 memset(&rm_sta_cmd, 0,
sizeof(rm_sta_cmd));
2064 rm_sta_cmd.num_sta = 1;
2076 IL_ERR(
"Bad return from C_REM_STA (0x%08X)\n", pkt->
hdr.flags);
2085 il_sta_ucode_deactivate(il, sta_id);
2086 spin_unlock_irqrestore(&il->
sta_lock,
2089 D_ASSOC(
"C_REM_STA PASSED\n");
2093 IL_ERR(
"C_REM_STA failed\n");
2108 unsigned long flags;
2110 if (!il_is_ready(il)) {
2111 D_INFO(
"Unable to remove station %pM, device not ready.\n",
2121 D_ASSOC(
"Removing STA from driver:%d %pM\n", sta_id, addr);
2128 if (!(il->
stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) {
2129 D_INFO(
"Removing %pM but non DRIVER active\n", addr);
2134 D_INFO(
"Removing %pM but non UCODE active\n", addr);
2143 il->
stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE;
2149 spin_unlock_irqrestore(&il->
sta_lock, flags);
2151 return il_send_remove_station(il, addr, sta_id,
false);
2153 spin_unlock_irqrestore(&il->
sta_lock, flags);
2170 unsigned long flags_spin;
2171 bool cleared =
false;
2173 D_INFO(
"Clearing ucode stations in driver\n");
2176 for (i = 0; i < il->
hw_params.max_stations; i++) {
2178 D_INFO(
"Clearing ucode active for station %d\n", i);
2179 il->
stations[
i].used &= ~IL_STA_UCODE_ACTIVE;
2183 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
2186 D_INFO(
"No active stations found to be cleared\n");
2203 unsigned long flags_spin;
2209 if (!il_is_ready(il)) {
2210 D_INFO(
"Not ready yet, not restoring any stations.\n");
2214 D_ASSOC(
"Restoring all known stations ... start.\n");
2216 for (i = 0; i < il->
hw_params.max_stations; i++) {
2217 if ((il->
stations[i].used & IL_STA_DRIVER_ACTIVE) &&
2219 D_ASSOC(
"Restoring sta %pM\n",
2227 for (i = 0; i < il->
hw_params.max_stations; i++) {
2237 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
2241 IL_ERR(
"Adding station %pM failed.\n",
2243 il->
stations[
i].used &= ~IL_STA_DRIVER_ACTIVE;
2245 ~IL_STA_UCODE_INPROGRESS;
2246 spin_unlock_irqrestore(&il->
sta_lock,
2256 il->
stations[
i].used &= ~IL_STA_UCODE_INPROGRESS;
2260 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
2262 D_INFO(
"Restoring all known stations"
2263 " .... no stations to be restored.\n");
2265 D_INFO(
"Restoring all known stations" " .... complete.\n");
2285 unsigned long flags;
2289 for (i = 0; i < il->
hw_params.max_stations; i++) {
2299 spin_unlock_irqrestore(&il->
sta_lock, flags);
2303 #ifdef CONFIG_IWLEGACY_DEBUG
2341 D_INFO(
"Channel %u is not an HT channel\n", il->
active.channel);
2344 D_INFO(
"idx %d of LQ expects HT channel\n", i);
2366 unsigned long flags_spin;
2380 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
2383 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
2385 il_dump_lq_cmd(il, lq);
2388 if (il_is_lq_table_valid(il, lq))
2397 D_INFO(
"init LQ command complete,"
2398 " clearing sta addition status for sta %d\n",
2402 spin_unlock_irqrestore(&il->
sta_lock, flags_spin);
2421 IL_ERR(
"Error removing station %pM\n", sta->
addr);
2520 unsigned long flags;
2534 D_INFO(
"Rx queue requesting wakeup," " GP1 = 0x%x\n",
2554 spin_unlock_irqrestore(&q->
lock, flags);
2566 INIT_LIST_HEAD(&rxq->
rx_free);
2567 INIT_LIST_HEAD(&rxq->
rx_used);
2608 if (!report->
state) {
2609 D_11H(
"Spectrum Measure Notification: Start\n");
2637 D_RX(
"decrypt_res:0x%x\n", decrypt_res);
2647 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
2651 D_RX(
"Packet destroyed\n");
2655 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
2657 D_RX(
"hw decrypt successfully!!!\n");
2676 int txq_id = txq->
q.id;
2689 D_INFO(
"Tx queue %d requesting wakeup," " GP1 = 0x%x\n",
2722 il->
ops->txq_free_tfd(il, txq);
2752 txq->
tfds, txq->
q.dma_addr);
2765 memset(txq, 0,
sizeof(*txq));
2783 i = il_get_cmd_idx(q, q->
read_ptr, 0);
2790 txq->
meta[
i].flags = 0;
2802 txq->
meta[
i].flags = 0;
2831 txq->
tfds, txq->
q.dma_addr);
2840 memset(txq, 0,
sizeof(*txq));
2935 IL_ERR(
"Fail to alloc skbs\n");
2946 IL_ERR(
"Fail to alloc TFDs\n");
2967 int slots, actual_slots;
2980 actual_slots = slots + 1;
2983 actual_slots =
slots;
2992 goto out_free_arrays;
2995 for (i = 0; i < actual_slots; i++) {
3006 ret = il_tx_queue_alloc(il, txq, txq_id);
3018 il_set_swq_id(txq, txq_id, txq_id);
3021 il_queue_init(il, &txq->
q, slots, txq_id);
3024 il->
ops->txq_init(il, txq);
3028 for (i = 0; i < actual_slots; i++)
3041 int slots, actual_slots;
3056 il_queue_init(il, &txq->
q, slots, txq_id);
3059 il->
ops->txq_init(il, txq);
3082 unsigned long flags;
3087 cmd->
len = il->
ops->get_hcmd_size(cmd->
id, cmd->
len);
3088 fix_size = (
u16) (cmd->
len +
sizeof(out_cmd->
hdr));
3099 if (il_is_rfkill(il) || il_is_ctkill(il)) {
3100 IL_WARN(
"Not sending command - %s KILL\n",
3101 il_is_rfkill(il) ?
"RF" :
"CT");
3108 spin_unlock_irqrestore(&il->
hcmd_lock, flags);
3110 IL_ERR(
"Restarting adapter due to command queue full\n");
3120 spin_unlock_irqrestore(&il->
hcmd_lock, flags);
3124 memset(out_meta, 0,
sizeof(*out_meta));
3131 out_cmd->
hdr.cmd = cmd->
id;
3137 out_cmd->
hdr.flags = 0;
3138 out_cmd->
hdr.sequence =
3146 #ifdef CONFIG_IWLEGACY_DEBUG
3147 switch (out_cmd->
hdr.cmd) {
3150 D_HC_DUMP(
"Sending command %s (#%x), seq: 0x%04X, "
3151 "%d bytes at %d[%d]:%d\n",
3157 D_HC(
"Sending command %s (#%x), seq: 0x%04X, "
3158 "%d bytes at %d[%d]:%d\n",
3166 if (il->
ops->txq_update_byte_cnt_tbl)
3168 il->
ops->txq_update_byte_cnt_tbl(il, txq, 0);
3171 pci_map_single(il->
pci_dev, &out_cmd->
hdr, fix_size,
3176 il->
ops->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 1,
3183 spin_unlock_irqrestore(&il->
hcmd_lock, flags);
3195 il_hcmd_queue_reclaim(
struct il_priv *il,
int txq_id,
int idx,
int cmd_idx)
3201 if (idx >= q->
n_bd || il_queue_used(q, idx) == 0) {
3202 IL_ERR(
"Read idx for DMA queue txq id (%d), idx %d, "
3203 "is out of range [0-%d] %d %d.\n", txq_id, idx, q->
n_bd,
3208 for (idx = il_queue_inc_wrap(idx, q->
n_bd); q->
read_ptr != idx;
3212 IL_ERR(
"HCMD skipped: idx (%d) %d %d\n", idx,
3240 unsigned long flags;
3247 "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n",
3254 cmd_idx = il_get_cmd_idx(&txq->
q, idx, huge);
3272 il_hcmd_queue_reclaim(il, txq_id, idx, cmd_idx);
3276 D_INFO(
"Clearing HCMD_ACTIVE for command %s\n",
3284 spin_unlock_irqrestore(&il->
hcmd_lock, flags);
3309 static bool bt_coex_active =
true;
3319 #define MAX_BIT_RATE_40_MHZ 150
3320 #define MAX_BIT_RATE_20_MHZ 72
3322 il_init_ht_hw_capab(
const struct il_priv *il,
3326 u16 max_bit_rate = 0;
3340 ht_info->
mcs.rx_mask[4] = 0x01;
3344 if (il->
cfg->mod_params->amsdu_size_8K)
3350 ht_info->
mcs.rx_mask[0] = 0xFF;
3351 if (rx_chains_num >= 2)
3352 ht_info->
mcs.rx_mask[1] = 0xFF;
3353 if (rx_chains_num >= 3)
3354 ht_info->
mcs.rx_mask[2] = 0xFF;
3357 max_bit_rate *= rx_chains_num;
3363 if (tx_chains_num != rx_chains_num) {
3365 ht_info->
mcs.tx_params |=
3383 s8 max_tx_power = 0;
3387 D_INFO(
"Geography modes already initialized.\n");
3431 if (!il_is_channel_valid(ch))
3444 if (il_is_channel_valid(ch)) {
3462 D_INFO(
"Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", ch->
channel,
3464 il_is_channel_a_band(ch) ?
"5.2" :
"2.4",
3476 IL_INFO(
"Incorrectly detected BG card as ABG. "
3477 "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n",
3482 IL_INFO(
"Tunable channels: %d 802.11bg, %d 802.11a channels\n",
3511 if (!il_is_channel_valid(ch_info))
3527 if (!il->
ht.enabled || !il->
ht.is_40mhz)
3537 #ifdef CONFIG_IWLEGACY_DEBUGFS
3538 if (il->disable_ht40)
3542 return il_is_channel_extension(il, il->
band,
3544 il->
ht.extension_chan_offset);
3549 il_adjust_beacon_interval(
u16 beacon_val,
u16 max_beacon_val)
3573 beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val;
3574 new_val = beacon_val / beacon_factor;
3577 new_val = max_beacon_val;
3586 s32 interval_tm, rem;
3591 conf = &il->
hw->conf;
3600 beacon_int = vif ? vif->
bss_conf.beacon_int : 0;
3609 il_adjust_beacon_interval(beacon_int,
3616 rem =
do_div(tsf, interval_tm);
3619 il->
timing.dtim_period = vif ? (vif->
bss_conf.dtim_period ? : 1) : 1;
3621 D_ASSOC(
"beacon interval %d beacon timer %d beacon tim %d\n",
3653 IL_WARN(
"check 2.4G: wrong narrow\n");
3657 IL_WARN(
"check 2.4G: wrong radar\n");
3662 IL_WARN(
"check 5.2G: not short slot!\n");
3666 IL_WARN(
"check 5.2G: CCK!\n");
3671 IL_WARN(
"mac/bssid mcast!\n");
3678 IL_WARN(
"neither 1 nor 6 are basic\n");
3689 IL_WARN(
"CCK and short slot\n");
3695 IL_WARN(
"CCK and auto detect");
3702 IL_WARN(
"TGg but no auto-detect\n");
3710 IL_ERR(
"Invalid RXON\n");
3733 D_INFO("need full RXON - " #cond "\n"); \
3737 #define CHK_NEQ(c1, c2) \
3738 if ((c1) != (c2)) { \
3739 D_INFO("need full RXON - " \
3740 #c1 " != " #c2 " - %d != %d\n", \
3746 CHK(!il_is_associated(il));
3798 if (!il->
ht.enabled) {
3819 switch (il->
ht.extension_chan_offset) {
3830 switch (il->
ht.extension_chan_offset) {
3843 IL_ERR(
"invalid extension channel offset\n");
3851 if (il->
ops->set_rxon_chain)
3852 il->
ops->set_rxon_chain(il);
3854 D_ASSOC(
"rxon flags 0x%X operation mode :0x%X "
3856 il->
ht.protection, il->
ht.extension_chan_offset);
3862 _il_set_rxon_ht(il, ht_conf);
3883 for (i = min; i <
max; i++) {
3889 if (il_is_channel_valid(ch_info))
3921 D_INFO(
"Staging channel set to %d [%d]\n", channel, band);
3938 if (vif && vif->
bss_conf.use_short_slot)
3971 IL_ERR(
"Unsupported interface type %d\n", il->
vif->type);
3978 if (!hw_to_local(il->
hw)->short_preamble)
3995 il->
staging.ofdm_basic_rates =
4006 il->
staging.ofdm_ht_single_stream_basic_rates = 0xff;
4007 il->
staging.ofdm_ht_dual_stream_basic_rates = 0xff;
4018 hw = il_get_hw_mode(il, il->
band);
4020 IL_ERR(
"Failed to set rate: unable to get hw mode\n");
4037 il->
staging.ofdm_basic_rates =
4069 IL_ERR(
"CSA notif (fail) : channel %d\n",
4076 #ifdef CONFIG_IWLEGACY_DEBUG
4078 il_print_rx_config_cmd(
struct il_priv *il)
4083 il_print_hex_dump(il,
IL_DL_RADIO, (
u8 *) rxon,
sizeof(*rxon));
4108 IL_ERR(
"Loaded firmware version: %s\n", il->
hw->wiphy->fw_version);
4110 il->
ops->dump_nic_error_log(il);
4111 if (il->
ops->dump_fh)
4112 il->
ops->dump_fh(il,
NULL,
false);
4113 #ifdef CONFIG_IWLEGACY_DEBUG
4115 il_print_rx_config_cmd(il);
4126 "Restarting adapter due to uCode error.\n");
4128 if (il->
cfg->mod_params->restart_fw)
4135 _il_apm_stop_master(
struct il_priv *il)
4146 IL_WARN(
"Master Disable Timed Out, 100 usec\n");
4158 D_INFO(
"Stop card, put in low power state\n");
4161 _il_apm_stop_master(il);
4179 unsigned long flags;
4183 spin_unlock_irqrestore(&il->
reg_lock, flags);
4198 D_INFO(
"Init card's basic functions\n");
4235 if (il->
cfg->set_l0s) {
4236 lctl = il_pcie_link_ctl(il);
4238 PCI_CFG_LINK_CTRL_VAL_L1_EN) {
4242 D_POWER(
"L1 Enabled; Disabling L0S\n");
4247 D_POWER(
"L1 Disabled; Enabling L0S\n");
4252 if (il->
cfg->pll_cfg_val)
4254 il->
cfg->pll_cfg_val);
4272 D_INFO(
"Failed to init the card\n");
4284 if (il->
cfg->use_bsm)
4312 if (!il->
ops->send_tx_power)
4317 IL_WARN(
"Requested user TXPOWER %d below 1 mW.\n", tx_power);
4322 IL_WARN(
"Requested user TXPOWER %d above upper limit %d.\n",
4327 if (!il_is_ready_rf(il))
4337 if (defer && !force) {
4338 D_INFO(
"Deferring tx power set\n");
4345 ret = il->
ops->send_tx_power(il);
4366 if (!bt_coex_active)
4375 IL_ERR(
"failed to send BT Coex Config\n");
4398 #ifdef CONFIG_IWLEGACY_DEBUG
4401 D_RX(
"sleep mode: %d, src: %d\n",
4412 D_RADIO(
"Dumping %d bytes of unhandled notification for %s:\n", len,
4423 IL_ERR(
"Error Reply type 0x%08X cmd %s (0x%02X) "
4424 "seq 0x%04X ser 0x%08X\n",
4444 unsigned long flags;
4449 if (!il_is_ready_rf(il)) {
4455 D_MAC80211(
"leave - queue >= AC_NUM %d\n", queue);
4463 il->
qos_data.def_qos_parm.ac[
q].cw_min =
4465 il->
qos_data.def_qos_parm.ac[
q].cw_max =
4468 il->
qos_data.def_qos_parm.ac[
q].edca_txop =
4471 il->
qos_data.def_qos_parm.ac[
q].reserved1 = 0;
4473 spin_unlock_irqrestore(&il->
lock, flags);
4496 il_set_mode(
struct il_priv *il)
4500 if (il->
ops->set_rxon_chain)
4501 il->
ops->set_rxon_chain(il);
4503 return il_commit_rxon(il);
4516 if (!il_is_ready_rf(il)) {
4517 IL_WARN(
"Try to add interface when device not ready\n");
4526 reset = (il->
vif ==
vif);
4527 if (il->
vif && !reset) {
4535 err = il_set_mode(il);
4579 il_teardown_interface(il, vif,
false);
4595 IL_ERR(
"Not enough memory for txq\n");
4624 D_INFO(
"force reset rejected\n");
4641 if (!external && !il->
cfg->mod_params->restart_fw) {
4642 D_INFO(
"Cancel firmware reload based on "
4643 "module parameter setting\n");
4647 IL_ERR(
"On demand firmware reload\n");
4670 D_MAC80211(
"enter: type %d, addr %pM newtype %d newp2p %d\n",
4671 vif->
type, vif->
addr, newtype, newp2p);
4678 if (!il->
vif || !il_is_ready_rf(il)) {
4688 il_teardown_interface(il, vif,
true);
4689 vif->
type = newtype;
4691 err = il_set_mode(il);
4715 il_check_stuck_queue(
struct il_priv *il,
int cnt)
4733 IL_ERR(
"Queue %d stuck for %u ms.\n", q->
id,
4736 return (ret == -
EAGAIN) ? 0 : 1;
4746 #define IL_WD_TICK(timeout) ((timeout) / 4)
4757 unsigned long timeout;
4762 timeout = il->
cfg->wd_timeout;
4767 if (il_check_stuck_queue(il, il->
cmd_queue))
4771 for (cnt = 0; cnt < il->
hw_params.max_txq_num; cnt++) {
4775 if (il_check_stuck_queue(il, cnt))
4787 unsigned int timeout = il->
cfg->wd_timeout;
4810 if (!interval || !usec)
4815 interval) & (il_beacon_time_mask_high(il,
4817 beacon_time_tsf_bits) >> il->
4820 (usec %
interval) & il_beacon_time_mask_low(il,
4822 beacon_time_tsf_bits);
4824 return (quot << il->
hw_params.beacon_time_tsf_bits) + rem;
4835 u32 base_low = base & il_beacon_time_mask_low(il,
4837 beacon_time_tsf_bits);
4838 u32 addon_low = addon & il_beacon_time_mask_low(il,
4840 beacon_time_tsf_bits);
4842 u32 res = (base & il_beacon_time_mask_high(il,
4844 beacon_time_tsf_bits)) +
4845 (addon & il_beacon_time_mask_high(il,
4847 beacon_time_tsf_bits));
4849 if (base_low > addon_low)
4850 res += base_low - addon_low;
4851 else if (base_low < addon_low) {
4852 res += interval + base_low - addon_low;
4853 res += (1 << il->
hw_params.beacon_time_tsf_bits);
4855 res += (1 << il->
hw_params.beacon_time_tsf_bits);
4867 struct il_priv *il = pci_get_drvdata(pdev);
4885 struct il_priv *il = pci_get_drvdata(pdev);
4886 bool hw_rfkill =
false;
4894 il_enable_interrupts(il);
4915 il_update_qos(
struct il_priv *il)
4920 il->
qos_data.def_qos_parm.qos_flags = 0;
4923 il->
qos_data.def_qos_parm.qos_flags |=
4929 D_QOS(
"send QoS cmd with Qos active=%d FLAGS=0x%X\n",
4947 unsigned long flags = 0;
4950 int scan_active = 0;
4951 bool ht_changed =
false;
4974 if (il->
ops->set_rxon_chain)
4975 il->
ops->set_rxon_chain(il);
4988 if (!il_is_channel_valid(ch_info)) {
4995 !il_is_channel_ibss(ch_info)) {
5004 if (il->
ht.enabled != conf_is_ht(conf)) {
5005 il->
ht.enabled = conf_is_ht(conf);
5008 if (il->
ht.enabled) {
5009 if (conf_is_ht40_minus(conf)) {
5010 il->
ht.extension_chan_offset =
5012 il->
ht.is_40mhz =
true;
5013 }
else if (conf_is_ht40_plus(conf)) {
5014 il->
ht.extension_chan_offset =
5016 il->
ht.is_40mhz =
true;
5018 il->
ht.extension_chan_offset =
5020 il->
ht.is_40mhz =
false;
5023 il->
ht.is_40mhz =
false;
5042 spin_unlock_irqrestore(&il->
lock, flags);
5044 if (il->
ops->update_bcast_stations)
5045 ret = il->
ops->update_bcast_stations(il);
5067 if (!il_is_ready(il)) {
5078 D_INFO(
"Not re-sending same RXON configuration.\n");
5094 unsigned long flags;
5109 spin_unlock_irqrestore(&il->
lock, flags);
5112 if (!il_is_ready_rf(il)) {
5138 if (!il->
ht.enabled)
5143 il->
ht.non_gf_sta_present =
5149 switch (vif->
type) {
5163 if (ht_cap->
mcs.rx_mask[1] == 0 &&
5164 ht_cap->
mcs.rx_mask[2] == 0)
5166 if (maxstreams <= 1)
5206 unsigned long flags;
5208 struct sk_buff *
skb = ieee80211_beacon_get(hw, vif);
5218 IL_ERR(
"update beacon with no beaconing enabled\n");
5234 spin_unlock_irqrestore(&il->
lock, flags);
5236 if (!il_is_ready_rf(il)) {
5241 il->
ops->post_associate(il);
5252 D_MAC80211(
"enter: changes 0x%x\n", changes);
5254 if (!il_is_alive(il)) {
5261 unsigned long flags;
5266 spin_unlock_irqrestore(&il->
lock, flags);
5304 il_beacon_update(hw, vif);
5344 il_ht_conf(il, vif);
5346 if (il->
ops->set_rxon_chain)
5347 il->
ops->set_rxon_chain(il);
5352 if (bss_conf->
assoc) {
5355 if (!il_is_rfkill(il))
5356 il->
ops->post_associate(il);
5358 il_set_no_assoc(il, vif);
5361 if (changes && il_is_associated(il) && bss_conf->
aid) {
5362 D_MAC80211(
"Changes (%#x) while associated\n", changes);
5363 ret = il_send_rxon_assoc(il);
5371 if (changes & BSS_CHANGED_BEACON_ENABLED) {
5376 il->
ops->config_ap(il);
5378 il_set_no_assoc(il, vif);
5382 ret = il->
ops->manage_ibss_station(il, vif,
5385 IL_ERR(
"failed to %s IBSS station %pM\n",
5401 unsigned long flags;
5421 if (!inta && !inta_fh) {
5422 D_ISR(
"Ignore interrupt, inta == 0, inta_fh == 0\n");
5426 if (inta == 0xFFFFFFFF || (inta & 0xFFFFFFF0) == 0xa5a5a5a0) {
5429 IL_WARN(
"HARDWARE GONE?? INTA == 0x%08x\n", inta);
5433 D_ISR(
"ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask,
5439 if (
likely(inta || inta_fh))
5443 spin_unlock_irqrestore(&il->
lock, flags);
5450 il_enable_interrupts(il);
5451 spin_unlock_irqrestore(&il->
lock, flags);
5469 if (!ieee80211_is_mgmt(fc))
5481 }
else if (info->
control.rates[0].