Lines Matching +full:aspm +full:- +full:no +full:- +full:l0s
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
19 #include <linux/dma-mapping.h>
39 return -ETIMEDOUT; in _il_poll_bit()
48 spin_lock_irqsave(&p->reg_lock, reg_flags); in il_set_bit()
50 spin_unlock_irqrestore(&p->reg_lock, reg_flags); in il_set_bit()
59 spin_lock_irqsave(&p->reg_lock, reg_flags); in il_clear_bit()
61 spin_unlock_irqrestore(&p->reg_lock, reg_flags); in il_clear_bit()
79 * to/from host DRAM when sleeping/waking for power-saving. in _il_grab_nic_access()
120 return -ETIMEDOUT; in il_poll_bit()
130 spin_lock_irqsave(&il->reg_lock, reg_flags); in il_rd_prph()
134 spin_unlock_irqrestore(&il->reg_lock, reg_flags); in il_rd_prph()
144 spin_lock_irqsave(&il->reg_lock, reg_flags); in il_wr_prph()
149 spin_unlock_irqrestore(&il->reg_lock, reg_flags); in il_wr_prph()
159 spin_lock_irqsave(&il->reg_lock, reg_flags); in il_read_targ_mem()
166 spin_unlock_irqrestore(&il->reg_lock, reg_flags); in il_read_targ_mem()
176 spin_lock_irqsave(&il->reg_lock, reg_flags); in il_write_targ_mem()
182 spin_unlock_irqrestore(&il->reg_lock, reg_flags); in il_write_targ_mem()
244 if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { in il_generic_cmd_callback()
246 il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); in il_generic_cmd_callback()
250 switch (cmd->hdr.cmd) { in il_generic_cmd_callback()
254 il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); in il_generic_cmd_callback()
257 D_HC("back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), in il_generic_cmd_callback()
258 pkt->hdr.flags); in il_generic_cmd_callback()
268 BUG_ON(!(cmd->flags & CMD_ASYNC)); in il_send_cmd_async()
271 BUG_ON(cmd->flags & CMD_WANT_SKB); in il_send_cmd_async()
274 if (!cmd->callback) in il_send_cmd_async()
275 cmd->callback = il_generic_cmd_callback; in il_send_cmd_async()
277 if (test_bit(S_EXIT_PENDING, &il->status)) in il_send_cmd_async()
278 return -EBUSY; in il_send_cmd_async()
283 il_get_cmd_string(cmd->id), ret); in il_send_cmd_async()
295 lockdep_assert_held(&il->mutex); in il_send_cmd_sync()
297 BUG_ON(cmd->flags & CMD_ASYNC); in il_send_cmd_sync()
300 BUG_ON(cmd->callback); in il_send_cmd_sync()
303 il_get_cmd_string(cmd->id)); in il_send_cmd_sync()
305 set_bit(S_HCMD_ACTIVE, &il->status); in il_send_cmd_sync()
307 il_get_cmd_string(cmd->id)); in il_send_cmd_sync()
313 il_get_cmd_string(cmd->id), ret); in il_send_cmd_sync()
317 ret = wait_event_timeout(il->wait_command_queue, in il_send_cmd_sync()
318 !test_bit(S_HCMD_ACTIVE, &il->status), in il_send_cmd_sync()
321 if (test_bit(S_HCMD_ACTIVE, &il->status)) { in il_send_cmd_sync()
323 il_get_cmd_string(cmd->id), in il_send_cmd_sync()
326 clear_bit(S_HCMD_ACTIVE, &il->status); in il_send_cmd_sync()
328 il_get_cmd_string(cmd->id)); in il_send_cmd_sync()
329 ret = -ETIMEDOUT; in il_send_cmd_sync()
334 if (test_bit(S_RFKILL, &il->status)) { in il_send_cmd_sync()
336 il_get_cmd_string(cmd->id)); in il_send_cmd_sync()
337 ret = -ECANCELED; in il_send_cmd_sync()
340 if (test_bit(S_FW_ERROR, &il->status)) { in il_send_cmd_sync()
342 il_get_cmd_string(cmd->id)); in il_send_cmd_sync()
343 ret = -EIO; in il_send_cmd_sync()
346 if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { in il_send_cmd_sync()
348 il_get_cmd_string(cmd->id)); in il_send_cmd_sync()
349 ret = -EIO; in il_send_cmd_sync()
357 if (cmd->flags & CMD_WANT_SKB) { in il_send_cmd_sync()
362 * address (cmd->meta.source). in il_send_cmd_sync()
364 il->txq[il->cmd_queue].meta[cmd_idx].flags &= ~CMD_WANT_SKB; in il_send_cmd_sync()
367 if (cmd->reply_page) { in il_send_cmd_sync()
368 il_free_pages(il, cmd->reply_page); in il_send_cmd_sync()
369 cmd->reply_page = 0; in il_send_cmd_sync()
379 if (cmd->flags & CMD_ASYNC) in il_send_cmd()
439 {.throughput = 1 * 1024 - 1, .blink_time = 260},
440 {.throughput = 5 * 1024 - 1, .blink_time = 220},
441 {.throughput = 10 * 1024 - 1, .blink_time = 190},
442 {.throughput = 20 * 1024 - 1, .blink_time = 170},
443 {.throughput = 50 * 1024 - 1, .blink_time = 150},
444 {.throughput = 70 * 1024 - 1, .blink_time = 130},
445 {.throughput = 100 * 1024 - 1, .blink_time = 110},
446 {.throughput = 200 * 1024 - 1, .blink_time = 80},
447 {.throughput = 300 * 1024 - 1, .blink_time = 50},
456 * The calculation is: (100-averageDeviation)/100 * blinkTime
458 * compensation = (100 - averageDeviation) * 64 / 100
466 "use pre-defined blinking time\n"); in il_blink_compensation()
483 if (!test_bit(S_READY, &il->status)) in il_led_cmd()
484 return -EBUSY; in il_led_cmd()
486 if (il->blink_on == on && il->blink_off == off) in il_led_cmd()
495 il->cfg->led_compensation); in il_led_cmd()
498 il->cfg->led_compensation); in il_led_cmd()
501 il->cfg->led_compensation); in il_led_cmd()
503 ret = il->ops->send_led_cmd(il, &led_cmd); in il_led_cmd()
505 il->blink_on = on; in il_led_cmd()
506 il->blink_off = off; in il_led_cmd()
540 mode = il->cfg->led_mode; in il_leds_init()
542 il->led.name = in il_leds_init()
543 kasprintf(GFP_KERNEL, "%s-led", wiphy_name(il->hw->wiphy)); in il_leds_init()
544 il->led.brightness_set = il_led_brightness_set; in il_leds_init()
545 il->led.blink_set = il_led_blink_set; in il_leds_init()
546 il->led.max_brightness = 1; in il_leds_init()
553 il->led.default_trigger = in il_leds_init()
554 ieee80211_create_tpt_led_trigger(il->hw, in il_leds_init()
560 il->led.default_trigger = ieee80211_get_radio_led_name(il->hw); in il_leds_init()
564 ret = led_classdev_register(&il->pci_dev->dev, &il->led); in il_leds_init()
566 kfree(il->led.name); in il_leds_init()
570 il->led_registered = true; in il_leds_init()
577 if (!il->led_registered) in il_leds_exit()
580 led_classdev_unregister(&il->led); in il_leds_exit()
581 kfree(il->led.name); in il_leds_exit()
591 * For example, il_priv->eeprom.band_3_channels[4] from the band_3
597 * information into il->channel_info_24/52 and il->channel_map_24/52
611 * channel. There is no corresponding channel information for that
622 static const u8 il_eeprom_band_2[] = { /* 4915-5080MHz */
626 static const u8 il_eeprom_band_3[] = { /* 5170-5320MHz */
630 static const u8 il_eeprom_band_4[] = { /* 5500-5700MHz */
634 static const u8 il_eeprom_band_5[] = { /* 5725-5825MHz */
665 ret = -ENOENT; in il_eeprom_verify_signature()
674 BUG_ON(offset >= il->cfg->eeprom_size); in il_eeprom_query_addr()
675 return &il->eeprom[offset]; in il_eeprom_query_addr()
682 if (!il->eeprom) in il_eeprom_query16()
684 return (u16) il->eeprom[offset] | ((u16) il->eeprom[offset + 1] << 8); in il_eeprom_query16()
689 * il_eeprom_init - read EEPROM contents
691 * Load the EEPROM contents from adapter into il->eeprom
693 * NOTE: This routine uses the non-debug IO access functions.
705 sz = il->cfg->eeprom_size; in il_eeprom_init()
707 il->eeprom = kzalloc(sz, GFP_KERNEL); in il_eeprom_init()
708 if (!il->eeprom) in il_eeprom_init()
709 return -ENOMEM; in il_eeprom_init()
711 e = (__le16 *) il->eeprom; in il_eeprom_init()
713 il->ops->apm_init(il); in il_eeprom_init()
718 ret = -ENOENT; in il_eeprom_init()
723 ret = il->ops->eeprom_acquire_semaphore(il); in il_eeprom_init()
726 ret = -ENOENT; in il_eeprom_init()
755 il->ops->eeprom_release_semaphore(il); in il_eeprom_init()
769 kfree(il->eeprom); in il_eeprom_free()
770 il->eeprom = NULL; in il_eeprom_free()
780 u32 offset = il->cfg->regulatory_bands[eep_band - 1]; in il_init_band_reference()
837 #define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \
840 * il_mod_ht40_chan_info - Copy ht40 channel info into driver's il.
855 return -1; in il_mod_ht40_chan_info()
858 " Ad-Hoc %ssupported\n", ch_info->channel, in il_mod_ht40_chan_info()
862 CHECK_AND_PRINT(DFS), eeprom_ch->flags, in il_mod_ht40_chan_info()
863 eeprom_ch->max_power_avg, in il_mod_ht40_chan_info()
864 ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) && in il_mod_ht40_chan_info()
865 !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? "" : "not "); in il_mod_ht40_chan_info()
867 ch_info->ht40_eeprom = *eeprom_ch; in il_mod_ht40_chan_info()
868 ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg; in il_mod_ht40_chan_info()
869 ch_info->ht40_flags = eeprom_ch->flags; in il_mod_ht40_chan_info()
870 if (eeprom_ch->flags & EEPROM_CHANNEL_VALID) in il_mod_ht40_chan_info()
871 ch_info->ht40_extension_channel &= in il_mod_ht40_chan_info()
881 * il_init_channel_map - Set up driver's info for all possible channels
892 if (il->channel_count) { in il_init_channel_map()
899 il->channel_count = in il_init_channel_map()
904 D_EEPROM("Parsing data for %d channels.\n", il->channel_count); in il_init_channel_map()
906 il->channel_info = in il_init_channel_map()
907 kcalloc(il->channel_count, sizeof(struct il_channel_info), in il_init_channel_map()
909 if (!il->channel_info) { in il_init_channel_map()
911 il->channel_count = 0; in il_init_channel_map()
912 return -ENOMEM; in il_init_channel_map()
915 ch_info = il->channel_info; in il_init_channel_map()
927 ch_info->channel = eeprom_ch_idx[ch]; in il_init_channel_map()
928 ch_info->band = in il_init_channel_map()
934 ch_info->eeprom = eeprom_ch_info[ch]; in il_init_channel_map()
936 /* Copy the run-time flags so they are there even on in il_init_channel_map()
938 ch_info->flags = eeprom_ch_info[ch].flags; in il_init_channel_map()
941 ch_info->ht40_extension_channel = in il_init_channel_map()
945 D_EEPROM("Ch. %d Flags %x [%sGHz] - " in il_init_channel_map()
946 "No traffic\n", ch_info->channel, in il_init_channel_map()
947 ch_info->flags, in il_init_channel_map()
954 /* Initialize regulatory-based run-time data */ in il_init_channel_map()
955 ch_info->max_power_avg = ch_info->curr_txpow = in il_init_channel_map()
957 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; in il_init_channel_map()
958 ch_info->min_power = 0; in il_init_channel_map()
961 " Ad-Hoc %ssupported\n", ch_info->channel, in il_init_channel_map()
982 if (il->cfg->regulatory_bands[5] == EEPROM_REGULATORY_BAND_NO_HT40 && in il_init_channel_map()
983 il->cfg->regulatory_bands[6] == EEPROM_REGULATORY_BAND_NO_HT40) in il_init_channel_map()
1017 * il_free_channel_map - undo allocations in il_init_channel_map
1022 kfree(il->channel_info); in il_free_channel_map()
1023 il->channel_count = 0; in il_free_channel_map()
1028 * il_get_channel_info - Find driver's ilate channel info
1040 for (i = 14; i < il->channel_count; i++) { in il_get_channel_info()
1041 if (il->channel_info[i].channel == channel) in il_get_channel_info()
1042 return &il->channel_info[i]; in il_get_channel_info()
1047 return &il->channel_info[channel - 1]; in il_get_channel_info()
1086 if (il->power_data.pci_pm) in il_build_powertable_cmd()
1087 cmd->flags |= IL_POWER_PCI_PM_MSK; in il_build_powertable_cmd()
1089 /* if no Power Save, we are done */ in il_build_powertable_cmd()
1090 if (il->power_data.ps_disabled) in il_build_powertable_cmd()
1093 cmd->flags = IL_POWER_DRIVER_ALLOW_SLEEP_MSK; in il_build_powertable_cmd()
1094 cmd->keep_alive_seconds = 0; in il_build_powertable_cmd()
1095 cmd->debug_flags = 0; in il_build_powertable_cmd()
1096 cmd->rx_data_timeout = cpu_to_le32(25 * 1024); in il_build_powertable_cmd()
1097 cmd->tx_data_timeout = cpu_to_le32(25 * 1024); in il_build_powertable_cmd()
1098 cmd->keep_alive_beacons = 0; in il_build_powertable_cmd()
1100 dtim_period = il->vif ? il->vif->bss_conf.dtim_period : 0; in il_build_powertable_cmd()
1103 memcpy(cmd->sleep_interval, interval[0], sizeof(interval[0])); in il_build_powertable_cmd()
1106 memcpy(cmd->sleep_interval, interval[1], sizeof(interval[1])); in il_build_powertable_cmd()
1109 memcpy(cmd->sleep_interval, interval[2], sizeof(interval[2])); in il_build_powertable_cmd()
1121 __le32 tmp = cmd->sleep_interval[IL_POWER_VEC_SIZE - 1]; in il_build_powertable_cmd()
1128 cmd->flags |= IL_POWER_SLEEP_OVER_DTIM_MSK; in il_build_powertable_cmd()
1131 cmd->flags &= ~IL_POWER_SLEEP_OVER_DTIM_MSK; in il_build_powertable_cmd()
1135 if (le32_to_cpu(cmd->sleep_interval[i]) > max_sleep) in il_build_powertable_cmd()
1136 cmd->sleep_interval[i] = cpu_to_le32(max_sleep); in il_build_powertable_cmd()
1143 D_POWER("Flags value = 0x%08X\n", cmd->flags); in il_set_power()
1144 D_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); in il_set_power()
1145 D_POWER("Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); in il_set_power()
1147 le32_to_cpu(cmd->sleep_interval[0]), in il_set_power()
1148 le32_to_cpu(cmd->sleep_interval[1]), in il_set_power()
1149 le32_to_cpu(cmd->sleep_interval[2]), in il_set_power()
1150 le32_to_cpu(cmd->sleep_interval[3]), in il_set_power()
1151 le32_to_cpu(cmd->sleep_interval[4])); in il_set_power()
1163 lockdep_assert_held(&il->mutex); in il_power_set_mode()
1166 update_chains = il->chain_noise_data.state == IL_CHAIN_NOISE_DONE || in il_power_set_mode()
1167 il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; in il_power_set_mode()
1169 if (!memcmp(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) in il_power_set_mode()
1173 return -EIO; in il_power_set_mode()
1176 memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); in il_power_set_mode()
1177 if (test_bit(S_SCANNING, &il->status) && !force) { in il_power_set_mode()
1182 if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) in il_power_set_mode()
1183 set_bit(S_POWER_PMI, &il->status); in il_power_set_mode()
1187 if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) in il_power_set_mode()
1188 clear_bit(S_POWER_PMI, &il->status); in il_power_set_mode()
1190 if (il->ops->update_chain_flags && update_chains) in il_power_set_mode()
1191 il->ops->update_chain_flags(il); in il_power_set_mode()
1192 else if (il->ops->update_chain_flags) in il_power_set_mode()
1195 il->chain_noise_data.state); in il_power_set_mode()
1197 memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); in il_power_set_mode()
1221 pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl); in il_power_initialize()
1222 il->power_data.pci_pm = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S); in il_power_initialize()
1224 il->power_data.debug_sleep_level_override = -1; in il_power_initialize()
1226 memset(&il->power_data.sleep_cmd, 0, sizeof(il->power_data.sleep_cmd)); in il_power_initialize()
1260 if (!test_bit(S_READY, &il->status) || in il_send_scan_abort()
1261 !test_bit(S_GEO_CONFIGURED, &il->status) || in il_send_scan_abort()
1262 !test_bit(S_SCAN_HW, &il->status) || in il_send_scan_abort()
1263 test_bit(S_FW_ERROR, &il->status) || in il_send_scan_abort()
1264 test_bit(S_EXIT_PENDING, &il->status)) in il_send_scan_abort()
1265 return -EIO; in il_send_scan_abort()
1272 if (pkt->u.status != CAN_ABORT_STATUS) { in il_send_scan_abort()
1279 D_SCAN("SCAN_ABORT ret %d.\n", pkt->u.status); in il_send_scan_abort()
1280 ret = -EIO; in il_send_scan_abort()
1295 if (il->scan_request) { in il_complete_scan()
1297 ieee80211_scan_completed(il->hw, &info); in il_complete_scan()
1300 il->scan_vif = NULL; in il_complete_scan()
1301 il->scan_request = NULL; in il_complete_scan()
1307 lockdep_assert_held(&il->mutex); in il_force_scan_end()
1309 if (!test_bit(S_SCANNING, &il->status)) { in il_force_scan_end()
1315 clear_bit(S_SCANNING, &il->status); in il_force_scan_end()
1316 clear_bit(S_SCAN_HW, &il->status); in il_force_scan_end()
1317 clear_bit(S_SCAN_ABORTING, &il->status); in il_force_scan_end()
1326 lockdep_assert_held(&il->mutex); in il_do_scan_abort()
1328 if (!test_bit(S_SCANNING, &il->status)) { in il_do_scan_abort()
1333 if (test_and_set_bit(S_SCAN_ABORTING, &il->status)) { in il_do_scan_abort()
1347 * il_scan_cancel - Cancel any currently executing HW scan
1353 queue_work(il->workqueue, &il->abort_scan); in il_scan_cancel()
1359 * il_scan_cancel_timeout - Cancel any currently executing HW scan
1368 lockdep_assert_held(&il->mutex); in il_scan_cancel_timeout()
1375 if (!test_bit(S_SCAN_HW, &il->status)) in il_scan_cancel_timeout()
1380 return test_bit(S_SCAN_HW, &il->status); in il_scan_cancel_timeout()
1391 (struct il_scanreq_notification *)pkt->u.raw; in il_hdl_scan()
1393 D_SCAN("Scan request status = 0x%x\n", notif->status); in il_hdl_scan()
1403 (struct il_scanstart_notification *)pkt->u.raw; in il_hdl_scan_start()
1404 il->scan_start_tsf = le32_to_cpu(notif->tsf_low); in il_hdl_scan_start()
1406 "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", notif->channel, in il_hdl_scan_start()
1407 notif->band ? "bg" : "a", le32_to_cpu(notif->tsf_high), in il_hdl_scan_start()
1408 le32_to_cpu(notif->tsf_low), notif->status, notif->beacon_timer); in il_hdl_scan_start()
1418 (struct il_scanresults_notification *)pkt->u.raw; in il_hdl_scan_results()
1420 D_SCAN("Scan ch.res: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d " in il_hdl_scan_results()
1421 "elapsed=%lu usec\n", notif->channel, notif->band ? "bg" : "a", in il_hdl_scan_results()
1422 le32_to_cpu(notif->tsf_high), le32_to_cpu(notif->tsf_low), in il_hdl_scan_results()
1423 le32_to_cpu(notif->stats[0]), in il_hdl_scan_results()
1424 le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); in il_hdl_scan_results()
1434 struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; in il_hdl_scan_complete()
1436 D_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", in il_hdl_scan_complete()
1437 scan_notif->scanned_channels, scan_notif->tsf_low, in il_hdl_scan_complete()
1438 scan_notif->tsf_high, scan_notif->status); in il_hdl_scan_complete()
1440 /* The HW is no longer scanning */ in il_hdl_scan_complete()
1441 clear_bit(S_SCAN_HW, &il->status); in il_hdl_scan_complete()
1444 (il->scan_band == NL80211_BAND_2GHZ) ? "2.4" : "5.2", in il_hdl_scan_complete()
1445 jiffies_to_msecs(jiffies - il->scan_start)); in il_hdl_scan_complete()
1447 queue_work(il->workqueue, &il->scan_completed); in il_hdl_scan_complete()
1454 il->handlers[C_SCAN] = il_hdl_scan; in il_setup_rx_scan_handlers()
1455 il->handlers[N_SCAN_START] = il_hdl_scan_start; in il_setup_rx_scan_handlers()
1456 il->handlers[N_SCAN_RESULTS] = il_hdl_scan_results; in il_setup_rx_scan_handlers()
1457 il->handlers[N_SCAN_COMPLETE] = il_hdl_scan_complete; in il_setup_rx_scan_handlers()
1492 value = il->vif ? il->vif->bss_conf.beacon_int : 0; in il_get_passive_dwell_time()
1495 value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; in il_get_passive_dwell_time()
1506 u8 ant_idx = fls(il->hw_params.valid_tx_ant) - 1; in il_init_scan_params()
1507 if (!il->scan_tx_ant[NL80211_BAND_5GHZ]) in il_init_scan_params()
1508 il->scan_tx_ant[NL80211_BAND_5GHZ] = ant_idx; in il_init_scan_params()
1509 if (!il->scan_tx_ant[NL80211_BAND_2GHZ]) in il_init_scan_params()
1510 il->scan_tx_ant[NL80211_BAND_2GHZ] = ant_idx; in il_init_scan_params()
1519 lockdep_assert_held(&il->mutex); in il_scan_initiate()
1521 cancel_delayed_work(&il->scan_check); in il_scan_initiate()
1525 return -EIO; in il_scan_initiate()
1528 if (test_bit(S_SCAN_HW, &il->status)) { in il_scan_initiate()
1530 return -EBUSY; in il_scan_initiate()
1533 if (test_bit(S_SCAN_ABORTING, &il->status)) { in il_scan_initiate()
1535 return -EBUSY; in il_scan_initiate()
1540 set_bit(S_SCANNING, &il->status); in il_scan_initiate()
1541 il->scan_start = jiffies; in il_scan_initiate()
1543 ret = il->ops->request_scan(il, vif); in il_scan_initiate()
1545 clear_bit(S_SCANNING, &il->status); in il_scan_initiate()
1549 queue_delayed_work(il->workqueue, &il->scan_check, in il_scan_initiate()
1559 struct cfg80211_scan_request *req = &hw_req->req; in il_mac_hw_scan()
1560 struct il_priv *il = hw->priv; in il_mac_hw_scan()
1563 if (req->n_channels == 0) { in il_mac_hw_scan()
1564 IL_ERR("Can not scan on no channels.\n"); in il_mac_hw_scan()
1565 return -EINVAL; in il_mac_hw_scan()
1568 mutex_lock(&il->mutex); in il_mac_hw_scan()
1571 if (test_bit(S_SCANNING, &il->status)) { in il_mac_hw_scan()
1573 ret = -EAGAIN; in il_mac_hw_scan()
1578 il->scan_request = req; in il_mac_hw_scan()
1579 il->scan_vif = vif; in il_mac_hw_scan()
1580 il->scan_band = req->channels[0]->band; in il_mac_hw_scan()
1586 mutex_unlock(&il->mutex); in il_mac_hw_scan()
1603 mutex_lock(&il->mutex); in il_bg_scan_check()
1605 mutex_unlock(&il->mutex); in il_bg_scan_check()
1609 * il_fill_probe_req - fill in all required fields and IE for probe request
1620 left -= 24; in il_fill_probe_req()
1624 frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); in il_fill_probe_req()
1625 eth_broadcast_addr(frame->da); in il_fill_probe_req()
1626 memcpy(frame->sa, ta, ETH_ALEN); in il_fill_probe_req()
1627 eth_broadcast_addr(frame->bssid); in il_fill_probe_req()
1628 frame->seq_ctrl = 0; in il_fill_probe_req()
1633 pos = &frame->u.probe_req.variable[0]; in il_fill_probe_req()
1636 left -= 2; in il_fill_probe_req()
1665 mutex_lock(&il->mutex); in il_bg_abort_scan()
1667 mutex_unlock(&il->mutex); in il_bg_abort_scan()
1678 cancel_delayed_work(&il->scan_check); in il_bg_scan_completed()
1680 mutex_lock(&il->mutex); in il_bg_scan_completed()
1682 aborted = test_and_clear_bit(S_SCAN_ABORTING, &il->status); in il_bg_scan_completed()
1686 if (!test_and_clear_bit(S_SCANNING, &il->status)) { in il_bg_scan_completed()
1702 il_power_set_mode(il, &il->power_data.sleep_cmd_next, false); in il_bg_scan_completed()
1703 il_set_tx_power(il, il->tx_power_next, false); in il_bg_scan_completed()
1705 il->ops->post_scan(il); in il_bg_scan_completed()
1708 mutex_unlock(&il->mutex); in il_bg_scan_completed()
1714 INIT_WORK(&il->scan_completed, il_bg_scan_completed); in il_setup_scan_deferred_work()
1715 INIT_WORK(&il->abort_scan, il_bg_abort_scan); in il_setup_scan_deferred_work()
1716 INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); in il_setup_scan_deferred_work()
1723 cancel_work_sync(&il->abort_scan); in il_cancel_scan_deferred_work()
1724 cancel_work_sync(&il->scan_completed); in il_cancel_scan_deferred_work()
1726 if (cancel_delayed_work_sync(&il->scan_check)) { in il_cancel_scan_deferred_work()
1727 mutex_lock(&il->mutex); in il_cancel_scan_deferred_work()
1729 mutex_unlock(&il->mutex); in il_cancel_scan_deferred_work()
1734 /* il->sta_lock must be held */
1739 if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) in il_sta_ucode_activate()
1741 sta_id, il->stations[sta_id].sta.sta.addr); in il_sta_ucode_activate()
1743 if (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { in il_sta_ucode_activate()
1746 il->stations[sta_id].sta.sta.addr); in il_sta_ucode_activate()
1748 il->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; in il_sta_ucode_activate()
1750 il->stations[sta_id].sta.sta.addr); in il_sta_ucode_activate()
1758 u8 sta_id = addsta->sta.sta_id; in il_process_add_sta_resp()
1760 int ret = -EIO; in il_process_add_sta_resp()
1762 if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { in il_process_add_sta_resp()
1763 IL_ERR("Bad return from C_ADD_STA (0x%08X)\n", pkt->hdr.flags); in il_process_add_sta_resp()
1769 spin_lock_irqsave(&il->sta_lock, flags); in il_process_add_sta_resp()
1771 switch (pkt->u.add_sta.status) { in il_process_add_sta_resp()
1778 IL_ERR("Adding station %d failed, no room in table.\n", sta_id); in il_process_add_sta_resp()
1781 IL_ERR("Adding station %d failed, no block ack resource.\n", in il_process_add_sta_resp()
1785 IL_ERR("Attempting to modify non-existing station %d\n", in il_process_add_sta_resp()
1789 D_ASSOC("Received C_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); in il_process_add_sta_resp()
1794 il->stations[sta_id].sta.mode == in il_process_add_sta_resp()
1796 il->stations[sta_id].sta.sta.addr); in il_process_add_sta_resp()
1807 il->stations[sta_id].sta.mode == in il_process_add_sta_resp()
1808 STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", addsta->sta.addr); in il_process_add_sta_resp()
1809 spin_unlock_irqrestore(&il->sta_lock, flags); in il_process_add_sta_resp()
1818 struct il_addsta_cmd *addsta = (struct il_addsta_cmd *)cmd->cmd.payload; in il_add_sta_callback()
1835 u8 sta_id __maybe_unused = sta->sta.sta_id; in il_send_add_sta()
1837 D_INFO("Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->sta.addr, in il_send_add_sta()
1847 cmd.len = il->ops->build_addsta_hcmd(sta, data); in il_send_add_sta()
1866 struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->deflink.ht_cap; in il_set_ht_add_station()
1869 if (!sta || !sta_ht_inf->ht_supported) in il_set_ht_add_station()
1873 (sta->deflink.smps_mode == IEEE80211_SMPS_STATIC) ? "static" : in il_set_ht_add_station()
1874 (sta->deflink.smps_mode == IEEE80211_SMPS_DYNAMIC) ? "dynamic" : in il_set_ht_add_station()
1877 sta_flags = il->stations[idx].sta.station_flags; in il_set_ht_add_station()
1881 switch (sta->deflink.smps_mode) { in il_set_ht_add_station()
1891 IL_WARN("Invalid MIMO PS mode %d\n", sta->deflink.smps_mode); in il_set_ht_add_station()
1896 cpu_to_le32((u32) sta_ht_inf-> in il_set_ht_add_station()
1900 cpu_to_le32((u32) sta_ht_inf-> in il_set_ht_add_station()
1903 if (il_is_ht40_tx_allowed(il, &sta->deflink.ht_cap)) in il_set_ht_add_station()
1908 il->stations[idx].sta.station_flags = sta_flags; in il_set_ht_add_station()
1914 * il_prep_station - Prepare station information for addition
1930 sta_id = il->hw_params.bcast_id; in il_prep_station()
1932 for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) { in il_prep_station()
1933 if (ether_addr_equal(il->stations[i].sta.sta.addr, in il_prep_station()
1939 if (!il->stations[i].used && in il_prep_station()
1956 if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { in il_prep_station()
1961 if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && in il_prep_station()
1962 (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && in il_prep_station()
1963 ether_addr_equal(il->stations[sta_id].sta.sta.addr, addr)) { in il_prep_station()
1969 station = &il->stations[sta_id]; in il_prep_station()
1970 station->used = IL_STA_DRIVER_ACTIVE; in il_prep_station()
1972 il->num_stations++; in il_prep_station()
1975 memset(&station->sta, 0, sizeof(struct il_addsta_cmd)); in il_prep_station()
1976 memcpy(station->sta.sta.addr, addr, ETH_ALEN); in il_prep_station()
1977 station->sta.mode = 0; in il_prep_station()
1978 station->sta.sta.sta_id = sta_id; in il_prep_station()
1979 station->sta.station_flags = 0; in il_prep_station()
1989 rate = (il->band == NL80211_BAND_5GHZ) ? RATE_6M_PLCP : RATE_1M_PLCP; in il_prep_station()
1991 station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); in il_prep_station()
2001 * il_add_station_common -
2013 spin_lock_irqsave(&il->sta_lock, flags_spin); in il_add_station_common()
2017 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_add_station_common()
2018 return -EINVAL; in il_add_station_common()
2026 if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { in il_add_station_common()
2028 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_add_station_common()
2029 return -EEXIST; in il_add_station_common()
2032 if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && in il_add_station_common()
2033 (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { in il_add_station_common()
2036 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_add_station_common()
2037 return -EEXIST; in il_add_station_common()
2040 il->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; in il_add_station_common()
2041 memcpy(&sta_cmd, &il->stations[sta_id].sta, in il_add_station_common()
2043 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_add_station_common()
2048 spin_lock_irqsave(&il->sta_lock, flags_spin); in il_add_station_common()
2050 il->stations[sta_id].sta.sta.addr); in il_add_station_common()
2051 il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; in il_add_station_common()
2052 il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; in il_add_station_common()
2053 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_add_station_common()
2061 * il_sta_ucode_deactivate - deactivate ucode status for a station
2063 * il->sta_lock must be held
2069 if ((il->stations[sta_id]. in il_sta_ucode_deactivate()
2074 il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; in il_sta_ucode_deactivate()
2076 memset(&il->stations[sta_id], 0, sizeof(struct il_station_entry)); in il_sta_ucode_deactivate()
2109 if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { in il_send_remove_station()
2110 IL_ERR("Bad return from C_REM_STA (0x%08X)\n", pkt->hdr.flags); in il_send_remove_station()
2111 ret = -EIO; in il_send_remove_station()
2115 switch (pkt->u.rem_sta.status) { in il_send_remove_station()
2118 spin_lock_irqsave(&il->sta_lock, flags_spin); in il_send_remove_station()
2120 spin_unlock_irqrestore(&il->sta_lock, in il_send_remove_station()
2126 ret = -EIO; in il_send_remove_station()
2137 * il_remove_station - Remove driver's knowledge of station.
2158 return -EINVAL; in il_remove_station()
2160 spin_lock_irqsave(&il->sta_lock, flags); in il_remove_station()
2162 if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { in il_remove_station()
2167 if (!(il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { in il_remove_station()
2172 if (il->stations[sta_id].used & IL_STA_LOCAL) { in il_remove_station()
2173 kfree(il->stations[sta_id].lq); in il_remove_station()
2174 il->stations[sta_id].lq = NULL; in il_remove_station()
2177 il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; in il_remove_station()
2179 il->num_stations--; in il_remove_station()
2181 BUG_ON(il->num_stations < 0); in il_remove_station()
2183 spin_unlock_irqrestore(&il->sta_lock, flags); in il_remove_station()
2187 spin_unlock_irqrestore(&il->sta_lock, flags); in il_remove_station()
2188 return -EINVAL; in il_remove_station()
2193 * il_clear_ucode_stations - clear ucode station table bits
2209 spin_lock_irqsave(&il->sta_lock, flags_spin); in il_clear_ucode_stations()
2210 for (i = 0; i < il->hw_params.max_stations; i++) { in il_clear_ucode_stations()
2211 if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { in il_clear_ucode_stations()
2213 il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; in il_clear_ucode_stations()
2217 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_clear_ucode_stations()
2220 D_INFO("No active stations found to be cleared\n"); in il_clear_ucode_stations()
2225 * il_restore_stations() - Restore driver known stations to device
2249 spin_lock_irqsave(&il->sta_lock, flags_spin); in il_restore_stations()
2250 for (i = 0; i < il->hw_params.max_stations; i++) { in il_restore_stations()
2251 if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && in il_restore_stations()
2252 !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { in il_restore_stations()
2254 il->stations[i].sta.sta.addr); in il_restore_stations()
2255 il->stations[i].sta.mode = 0; in il_restore_stations()
2256 il->stations[i].used |= IL_STA_UCODE_INPROGRESS; in il_restore_stations()
2261 for (i = 0; i < il->hw_params.max_stations; i++) { in il_restore_stations()
2262 if ((il->stations[i].used & IL_STA_UCODE_INPROGRESS)) { in il_restore_stations()
2263 memcpy(&sta_cmd, &il->stations[i].sta, in il_restore_stations()
2266 if (il->stations[i].lq) { in il_restore_stations()
2267 memcpy(&lq, il->stations[i].lq, in il_restore_stations()
2271 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_restore_stations()
2274 spin_lock_irqsave(&il->sta_lock, flags_spin); in il_restore_stations()
2276 il->stations[i].sta.sta.addr); in il_restore_stations()
2277 il->stations[i].used &= ~IL_STA_DRIVER_ACTIVE; in il_restore_stations()
2278 il->stations[i].used &= in il_restore_stations()
2280 spin_unlock_irqrestore(&il->sta_lock, in il_restore_stations()
2289 spin_lock_irqsave(&il->sta_lock, flags_spin); in il_restore_stations()
2290 il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; in il_restore_stations()
2294 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_restore_stations()
2297 " .... no stations to be restored.\n"); in il_restore_stations()
2308 for (i = 0; i < il->sta_key_max_num; i++) in il_get_free_ucode_key_idx()
2309 if (!test_and_set_bit(i, &il->ucode_key_table)) in il_get_free_ucode_key_idx()
2322 spin_lock_irqsave(&il->sta_lock, flags); in il_dealloc_bcast_stations()
2323 for (i = 0; i < il->hw_params.max_stations; i++) { in il_dealloc_bcast_stations()
2324 if (!(il->stations[i].used & IL_STA_BCAST)) in il_dealloc_bcast_stations()
2327 il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; in il_dealloc_bcast_stations()
2328 il->num_stations--; in il_dealloc_bcast_stations()
2329 BUG_ON(il->num_stations < 0); in il_dealloc_bcast_stations()
2330 kfree(il->stations[i].lq); in il_dealloc_bcast_stations()
2331 il->stations[i].lq = NULL; in il_dealloc_bcast_stations()
2333 spin_unlock_irqrestore(&il->sta_lock, flags); in il_dealloc_bcast_stations()
2342 D_RATE("lq station id 0x%x\n", lq->sta_id); in il_dump_lq_cmd()
2343 D_RATE("lq ant 0x%X 0x%X\n", lq->general_params.single_stream_ant_msk, in il_dump_lq_cmd()
2344 lq->general_params.dual_stream_ant_msk); in il_dump_lq_cmd()
2347 D_RATE("lq idx %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); in il_dump_lq_cmd()
2357 * il_is_lq_table_valid() - Test one aspect of LQ cmd for validity
2372 if (il->ht.enabled) in il_is_lq_table_valid()
2375 D_INFO("Channel %u is not an HT channel\n", il->active.channel); in il_is_lq_table_valid()
2377 if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { in il_is_lq_table_valid()
2386 * il_send_lq_cmd() - Send link quality command
2409 if (WARN_ON(lq->sta_id == IL_INVALID_STATION)) in il_send_lq_cmd()
2410 return -EINVAL; in il_send_lq_cmd()
2412 spin_lock_irqsave(&il->sta_lock, flags_spin); in il_send_lq_cmd()
2413 if (!(il->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { in il_send_lq_cmd()
2414 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_send_lq_cmd()
2415 return -EINVAL; in il_send_lq_cmd()
2417 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_send_lq_cmd()
2425 ret = -EINVAL; in il_send_lq_cmd()
2433 lq->sta_id); in il_send_lq_cmd()
2434 spin_lock_irqsave(&il->sta_lock, flags_spin); in il_send_lq_cmd()
2435 il->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; in il_send_lq_cmd()
2436 spin_unlock_irqrestore(&il->sta_lock, flags_spin); in il_send_lq_cmd()
2446 struct il_priv *il = hw->priv; in il_mac_sta_remove()
2447 struct il_station_priv_common *sta_common = (void *)sta->drv_priv; in il_mac_sta_remove()
2450 mutex_lock(&il->mutex); in il_mac_sta_remove()
2451 D_MAC80211("enter station %pM\n", sta->addr); in il_mac_sta_remove()
2453 ret = il_remove_station(il, sta_common->sta_id, sta->addr); in il_mac_sta_remove()
2455 IL_ERR("Error removing station %pM\n", sta->addr); in il_mac_sta_remove()
2458 mutex_unlock(&il->mutex); in il_mac_sta_remove()
2464 /************************** RX-FUNCTIONS ****************************/
2478 * to -- the driver can read up to (but not including) this position and get
2482 * The WRITE idx maps to the last position the driver has read from -- the
2485 * The queue is empty (no good data) if WRITE = READ - 1, and is full if
2489 * IDX position, and WRITE to the last (READ - 1 wrapped)
2497 * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When
2498 * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled
2499 * to replenish the iwl->rxq->rx_free.
2501 * iwl->rxq is replenished and the READ IDX is updated (updating the
2504 * detached from the iwl->rxq. The driver 'processed' idx is updated.
2505 * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free
2506 * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ
2507 * IDX is not incremented and iwl->status(RX_STALLED) is set. If there
2521 * -- enable interrupts --
2522 * ISR - il_rx() Detach il_rx_bufs from pool up to the
2532 * il_rx_queue_space - Return number of free slots available in queue.
2537 int s = q->read - q->write; in il_rx_queue_space()
2541 s -= 2; in il_rx_queue_space()
2549 * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue
2555 u32 rx_wrt_ptr_reg = il->hw_params.rx_wrt_ptr_reg; in il_rx_queue_update_write_ptr()
2558 spin_lock_irqsave(&q->lock, flags); in il_rx_queue_update_write_ptr()
2560 if (q->need_update == 0) in il_rx_queue_update_write_ptr()
2563 /* If power-saving is in use, make sure device is awake */ in il_rx_queue_update_write_ptr()
2564 if (test_bit(S_POWER_PMI, &il->status)) { in il_rx_queue_update_write_ptr()
2575 q->write_actual = (q->write & ~0x7); in il_rx_queue_update_write_ptr()
2576 il_wr(il, rx_wrt_ptr_reg, q->write_actual); in il_rx_queue_update_write_ptr()
2581 q->write_actual = (q->write & ~0x7); in il_rx_queue_update_write_ptr()
2582 il_wr(il, rx_wrt_ptr_reg, q->write_actual); in il_rx_queue_update_write_ptr()
2585 q->need_update = 0; in il_rx_queue_update_write_ptr()
2588 spin_unlock_irqrestore(&q->lock, flags); in il_rx_queue_update_write_ptr()
2595 struct il_rx_queue *rxq = &il->rxq; in il_rx_queue_alloc()
2596 struct device *dev = &il->pci_dev->dev; in il_rx_queue_alloc()
2599 spin_lock_init(&rxq->lock); in il_rx_queue_alloc()
2600 INIT_LIST_HEAD(&rxq->rx_free); in il_rx_queue_alloc()
2601 INIT_LIST_HEAD(&rxq->rx_used); in il_rx_queue_alloc()
2604 rxq->bd = dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->bd_dma, in il_rx_queue_alloc()
2606 if (!rxq->bd) in il_rx_queue_alloc()
2609 rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct il_rb_status), in il_rx_queue_alloc()
2610 &rxq->rb_stts_dma, GFP_KERNEL); in il_rx_queue_alloc()
2611 if (!rxq->rb_stts) in il_rx_queue_alloc()
2616 list_add_tail(&rxq->pool[i].list, &rxq->rx_used); in il_rx_queue_alloc()
2620 rxq->read = rxq->write = 0; in il_rx_queue_alloc()
2621 rxq->write_actual = 0; in il_rx_queue_alloc()
2622 rxq->free_count = 0; in il_rx_queue_alloc()
2623 rxq->need_update = 0; in il_rx_queue_alloc()
2627 dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, in il_rx_queue_alloc()
2628 rxq->bd_dma); in il_rx_queue_alloc()
2630 return -ENOMEM; in il_rx_queue_alloc()
2638 struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); in il_hdl_spectrum_measurement()
2640 if (!report->state) { in il_hdl_spectrum_measurement()
2645 memcpy(&il->measure_report, report, sizeof(*report)); in il_hdl_spectrum_measurement()
2646 il->measurement_status |= MEASUREMENT_READY; in il_hdl_spectrum_measurement()
2651 * returns non-zero if packet should be dropped
2657 u16 fc = le16_to_cpu(hdr->frame_control); in il_set_decrypted_flag()
2663 if (il->active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) in il_set_decrypted_flag()
2685 return -1; in il_set_decrypted_flag()
2692 stats->flag |= RX_FLAG_DECRYPTED; in il_set_decrypted_flag()
2704 * il_txq_update_write_ptr - Send new write idx to hardware
2710 int txq_id = txq->q.id; in il_txq_update_write_ptr()
2712 if (txq->need_update == 0) in il_txq_update_write_ptr()
2716 if (test_bit(S_POWER_PMI, &il->status)) { in il_txq_update_write_ptr()
2730 il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); in il_txq_update_write_ptr()
2733 * else not in power-save mode, in il_txq_update_write_ptr()
2738 _il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); in il_txq_update_write_ptr()
2739 txq->need_update = 0; in il_txq_update_write_ptr()
2744 * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's
2749 struct il_tx_queue *txq = &il->txq[txq_id]; in il_tx_queue_unmap()
2750 struct il_queue *q = &txq->q; in il_tx_queue_unmap()
2752 if (q->n_bd == 0) in il_tx_queue_unmap()
2755 while (q->write_ptr != q->read_ptr) { in il_tx_queue_unmap()
2756 il->ops->txq_free_tfd(il, txq); in il_tx_queue_unmap()
2757 q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); in il_tx_queue_unmap()
2763 * il_tx_queue_free - Deallocate DMA queue.
2768 * 0-fill, but do not free "txq" descriptor structure.
2773 struct il_tx_queue *txq = &il->txq[txq_id]; in il_tx_queue_free()
2774 struct device *dev = &il->pci_dev->dev; in il_tx_queue_free()
2779 /* De-alloc array of command/tx buffers */ in il_tx_queue_free()
2780 if (txq->cmd) { in il_tx_queue_free()
2782 kfree(txq->cmd[i]); in il_tx_queue_free()
2785 /* De-alloc circular buffer of TFDs */ in il_tx_queue_free()
2786 if (txq->q.n_bd) in il_tx_queue_free()
2787 dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, in il_tx_queue_free()
2788 txq->tfds, txq->q.dma_addr); in il_tx_queue_free()
2790 /* De-alloc array of per-TFD driver data */ in il_tx_queue_free()
2791 kfree(txq->skbs); in il_tx_queue_free()
2792 txq->skbs = NULL; in il_tx_queue_free()
2795 kfree(txq->cmd); in il_tx_queue_free()
2796 kfree(txq->meta); in il_tx_queue_free()
2797 txq->cmd = NULL; in il_tx_queue_free()
2798 txq->meta = NULL; in il_tx_queue_free()
2800 /* 0-fill queue descriptor structure */ in il_tx_queue_free()
2806 * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue
2811 struct il_tx_queue *txq = &il->txq[il->cmd_queue]; in il_cmd_queue_unmap()
2812 struct il_queue *q = &txq->q; in il_cmd_queue_unmap()
2815 if (q->n_bd == 0) in il_cmd_queue_unmap()
2818 while (q->read_ptr != q->write_ptr) { in il_cmd_queue_unmap()
2819 i = il_get_cmd_idx(q, q->read_ptr, 0); in il_cmd_queue_unmap()
2821 if (txq->meta[i].flags & CMD_MAPPED) { in il_cmd_queue_unmap()
2822 dma_unmap_single(&il->pci_dev->dev, in il_cmd_queue_unmap()
2823 dma_unmap_addr(&txq->meta[i], mapping), in il_cmd_queue_unmap()
2824 dma_unmap_len(&txq->meta[i], len), in il_cmd_queue_unmap()
2826 txq->meta[i].flags = 0; in il_cmd_queue_unmap()
2829 q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); in il_cmd_queue_unmap()
2832 i = q->n_win; in il_cmd_queue_unmap()
2833 if (txq->meta[i].flags & CMD_MAPPED) { in il_cmd_queue_unmap()
2834 dma_unmap_single(&il->pci_dev->dev, in il_cmd_queue_unmap()
2835 dma_unmap_addr(&txq->meta[i], mapping), in il_cmd_queue_unmap()
2836 dma_unmap_len(&txq->meta[i], len), in il_cmd_queue_unmap()
2838 txq->meta[i].flags = 0; in il_cmd_queue_unmap()
2844 * il_cmd_queue_free - Deallocate DMA queue.
2848 * 0-fill, but do not free "txq" descriptor structure.
2853 struct il_tx_queue *txq = &il->txq[il->cmd_queue]; in il_cmd_queue_free()
2854 struct device *dev = &il->pci_dev->dev; in il_cmd_queue_free()
2859 /* De-alloc array of command/tx buffers */ in il_cmd_queue_free()
2860 if (txq->cmd) { in il_cmd_queue_free()
2862 kfree(txq->cmd[i]); in il_cmd_queue_free()
2865 /* De-alloc circular buffer of TFDs */ in il_cmd_queue_free()
2866 if (txq->q.n_bd) in il_cmd_queue_free()
2867 dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, in il_cmd_queue_free()
2868 txq->tfds, txq->q.dma_addr); in il_cmd_queue_free()
2871 kfree(txq->cmd); in il_cmd_queue_free()
2872 kfree(txq->meta); in il_cmd_queue_free()
2873 txq->cmd = NULL; in il_cmd_queue_free()
2874 txq->meta = NULL; in il_cmd_queue_free()
2876 /* 0-fill queue descriptor structure */ in il_cmd_queue_free()
2881 /*************** DMA-QUEUE-GENERAL-FUNCTIONS *****
2907 int s = q->read_ptr - q->write_ptr; in il_queue_space()
2909 if (q->read_ptr > q->write_ptr) in il_queue_space()
2910 s -= q->n_bd; in il_queue_space()
2913 s += q->n_win; in il_queue_space()
2915 s -= 2; in il_queue_space()
2924 * il_queue_init - Initialize queue's high/low-water and read/write idxes
2930 * TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise in il_queue_init()
2933 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); in il_queue_init()
2934 /* FIXME: remove q->n_bd */ in il_queue_init()
2935 q->n_bd = TFD_QUEUE_SIZE_MAX; in il_queue_init()
2937 q->n_win = slots; in il_queue_init()
2938 q->id = id; in il_queue_init()
2940 /* slots_must be power-of-two size, otherwise in il_queue_init()
2944 q->low_mark = q->n_win / 4; in il_queue_init()
2945 if (q->low_mark < 4) in il_queue_init()
2946 q->low_mark = 4; in il_queue_init()
2948 q->high_mark = q->n_win / 8; in il_queue_init()
2949 if (q->high_mark < 2) in il_queue_init()
2950 q->high_mark = 2; in il_queue_init()
2952 q->write_ptr = q->read_ptr = 0; in il_queue_init()
2958 * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue
2963 struct device *dev = &il->pci_dev->dev; in il_tx_queue_alloc()
2964 size_t tfd_sz = il->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; in il_tx_queue_alloc()
2968 if (id != il->cmd_queue) { in il_tx_queue_alloc()
2969 txq->skbs = kcalloc(TFD_QUEUE_SIZE_MAX, in il_tx_queue_alloc()
2972 if (!txq->skbs) { in il_tx_queue_alloc()
2977 txq->skbs = NULL; in il_tx_queue_alloc()
2981 txq->tfds = in il_tx_queue_alloc()
2982 dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); in il_tx_queue_alloc()
2983 if (!txq->tfds) in il_tx_queue_alloc()
2986 txq->q.id = id; in il_tx_queue_alloc()
2991 kfree(txq->skbs); in il_tx_queue_alloc()
2992 txq->skbs = NULL; in il_tx_queue_alloc()
2994 return -ENOMEM; in il_tx_queue_alloc()
2998 * il_tx_queue_init - Allocate and initialize one tx/cmd queue
3005 struct il_tx_queue *txq = &il->txq[txq_id]; in il_tx_queue_init()
3012 * For normal Tx queues (all other queues), no super-size command in il_tx_queue_init()
3015 if (txq_id == il->cmd_queue) { in il_tx_queue_init()
3023 txq->meta = in il_tx_queue_init()
3025 txq->cmd = in il_tx_queue_init()
3028 if (!txq->meta || !txq->cmd) in il_tx_queue_init()
3037 txq->cmd[i] = kmalloc(len, GFP_KERNEL); in il_tx_queue_init()
3038 if (!txq->cmd[i]) in il_tx_queue_init()
3047 txq->need_update = 0; in il_tx_queue_init()
3050 * For the default queues 0-3, set up the swq_id in il_tx_queue_init()
3051 * already -- all others need to get one later in il_tx_queue_init()
3057 /* Initialize queue's high/low-water marks, and head/tail idxes */ in il_tx_queue_init()
3058 il_queue_init(il, &txq->q, slots, txq_id); in il_tx_queue_init()
3061 il->ops->txq_init(il, txq); in il_tx_queue_init()
3066 kfree(txq->cmd[i]); in il_tx_queue_init()
3068 kfree(txq->meta); in il_tx_queue_init()
3069 txq->meta = NULL; in il_tx_queue_init()
3070 kfree(txq->cmd); in il_tx_queue_init()
3071 txq->cmd = NULL; in il_tx_queue_init()
3073 return -ENOMEM; in il_tx_queue_init()
3081 struct il_tx_queue *txq = &il->txq[txq_id]; in il_tx_queue_reset()
3083 if (txq_id == il->cmd_queue) { in il_tx_queue_reset()
3091 memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); in il_tx_queue_reset()
3092 txq->need_update = 0; in il_tx_queue_reset()
3094 /* Initialize queue's high/low-water marks, and head/tail idxes */ in il_tx_queue_reset()
3095 il_queue_init(il, &txq->q, slots, txq_id); in il_tx_queue_reset()
3098 il->ops->txq_init(il, txq); in il_tx_queue_reset()
3105 * il_enqueue_hcmd - enqueue a uCode command
3116 struct il_tx_queue *txq = &il->txq[il->cmd_queue]; in il_enqueue_hcmd()
3117 struct il_queue *q = &txq->q; in il_enqueue_hcmd()
3126 cmd->len = il->ops->get_hcmd_size(cmd->id, cmd->len); in il_enqueue_hcmd()
3127 fix_size = (u16) (cmd->len + sizeof(out_cmd->hdr)); in il_enqueue_hcmd()
3135 !(cmd->flags & CMD_SIZE_HUGE)); in il_enqueue_hcmd()
3139 IL_WARN("Not sending command - %s KILL\n", in il_enqueue_hcmd()
3141 return -EIO; in il_enqueue_hcmd()
3144 spin_lock_irqsave(&il->hcmd_lock, flags); in il_enqueue_hcmd()
3146 if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { in il_enqueue_hcmd()
3147 spin_unlock_irqrestore(&il->hcmd_lock, flags); in il_enqueue_hcmd()
3150 queue_work(il->workqueue, &il->restart); in il_enqueue_hcmd()
3151 return -ENOSPC; in il_enqueue_hcmd()
3154 idx = il_get_cmd_idx(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); in il_enqueue_hcmd()
3155 out_cmd = txq->cmd[idx]; in il_enqueue_hcmd()
3156 out_meta = &txq->meta[idx]; in il_enqueue_hcmd()
3160 * we're using a larger payload buffer to avoid "field- in il_enqueue_hcmd()
3161 * spanning write" warnings at run-time for huge commands. in il_enqueue_hcmd()
3163 if (cmd->flags & CMD_SIZE_HUGE) in il_enqueue_hcmd()
3164 out_payload = ((struct il_device_cmd_huge *)out_cmd)->cmd.payload; in il_enqueue_hcmd()
3166 out_payload = out_cmd->cmd.payload; in il_enqueue_hcmd()
3168 if (WARN_ON(out_meta->flags & CMD_MAPPED)) { in il_enqueue_hcmd()
3169 spin_unlock_irqrestore(&il->hcmd_lock, flags); in il_enqueue_hcmd()
3170 return -ENOSPC; in il_enqueue_hcmd()
3173 memset(out_meta, 0, sizeof(*out_meta)); /* re-initialize to NULL */ in il_enqueue_hcmd()
3174 out_meta->flags = cmd->flags | CMD_MAPPED; in il_enqueue_hcmd()
3175 if (cmd->flags & CMD_WANT_SKB) in il_enqueue_hcmd()
3176 out_meta->source = cmd; in il_enqueue_hcmd()
3177 if (cmd->flags & CMD_ASYNC) in il_enqueue_hcmd()
3178 out_meta->callback = cmd->callback; in il_enqueue_hcmd()
3180 out_cmd->hdr.cmd = cmd->id; in il_enqueue_hcmd()
3181 memcpy(out_payload, cmd->data, cmd->len); in il_enqueue_hcmd()
3186 out_cmd->hdr.flags = 0; in il_enqueue_hcmd()
3187 out_cmd->hdr.sequence = in il_enqueue_hcmd()
3188 cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | IDX_TO_SEQ(q->write_ptr)); in il_enqueue_hcmd()
3189 if (cmd->flags & CMD_SIZE_HUGE) in il_enqueue_hcmd()
3190 out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; in il_enqueue_hcmd()
3193 switch (out_cmd->hdr.cmd) { in il_enqueue_hcmd()
3198 il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, in il_enqueue_hcmd()
3199 le16_to_cpu(out_cmd->hdr.sequence), fix_size, in il_enqueue_hcmd()
3200 q->write_ptr, idx, il->cmd_queue); in il_enqueue_hcmd()
3205 il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, in il_enqueue_hcmd()
3206 le16_to_cpu(out_cmd->hdr.sequence), fix_size, q->write_ptr, in il_enqueue_hcmd()
3207 idx, il->cmd_queue); in il_enqueue_hcmd()
3211 phys_addr = dma_map_single(&il->pci_dev->dev, &out_cmd->hdr, fix_size, in il_enqueue_hcmd()
3213 if (unlikely(dma_mapping_error(&il->pci_dev->dev, phys_addr))) { in il_enqueue_hcmd()
3214 idx = -ENOMEM; in il_enqueue_hcmd()
3220 txq->need_update = 1; in il_enqueue_hcmd()
3222 if (il->ops->txq_update_byte_cnt_tbl) in il_enqueue_hcmd()
3224 il->ops->txq_update_byte_cnt_tbl(il, txq, 0); in il_enqueue_hcmd()
3226 il->ops->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 1, in il_enqueue_hcmd()
3227 U32_PAD(cmd->len)); in il_enqueue_hcmd()
3230 q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); in il_enqueue_hcmd()
3234 spin_unlock_irqrestore(&il->hcmd_lock, flags); in il_enqueue_hcmd()
3239 * il_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd
3248 struct il_tx_queue *txq = &il->txq[txq_id]; in il_hcmd_queue_reclaim()
3249 struct il_queue *q = &txq->q; in il_hcmd_queue_reclaim()
3252 if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { in il_hcmd_queue_reclaim()
3254 "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, in il_hcmd_queue_reclaim()
3255 q->write_ptr, q->read_ptr); in il_hcmd_queue_reclaim()
3259 for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; in il_hcmd_queue_reclaim()
3260 q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { in il_hcmd_queue_reclaim()
3264 q->write_ptr, q->read_ptr); in il_hcmd_queue_reclaim()
3265 queue_work(il->workqueue, &il->restart); in il_hcmd_queue_reclaim()
3272 * il_tx_cmd_complete - Pull unused buffers off the queue and reclaim them
3283 u16 sequence = le16_to_cpu(pkt->hdr.sequence); in il_tx_cmd_complete()
3287 bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); in il_tx_cmd_complete()
3290 struct il_tx_queue *txq = &il->txq[il->cmd_queue]; in il_tx_cmd_complete()
3297 (txq_id != il->cmd_queue, in il_tx_cmd_complete()
3299 txq_id, il->cmd_queue, sequence, il->txq[il->cmd_queue].q.read_ptr, in il_tx_cmd_complete()
3300 il->txq[il->cmd_queue].q.write_ptr)) { in il_tx_cmd_complete()
3305 cmd_idx = il_get_cmd_idx(&txq->q, idx, huge); in il_tx_cmd_complete()
3306 cmd = txq->cmd[cmd_idx]; in il_tx_cmd_complete()
3307 meta = &txq->meta[cmd_idx]; in il_tx_cmd_complete()
3309 txq->time_stamp = jiffies; in il_tx_cmd_complete()
3311 dma_unmap_single(&il->pci_dev->dev, dma_unmap_addr(meta, mapping), in il_tx_cmd_complete()
3315 if (meta->flags & CMD_WANT_SKB) { in il_tx_cmd_complete()
3316 meta->source->reply_page = (unsigned long)rxb_addr(rxb); in il_tx_cmd_complete()
3317 rxb->page = NULL; in il_tx_cmd_complete()
3318 } else if (meta->callback) in il_tx_cmd_complete()
3319 meta->callback(il, cmd, pkt); in il_tx_cmd_complete()
3321 spin_lock_irqsave(&il->hcmd_lock, flags); in il_tx_cmd_complete()
3325 if (!(meta->flags & CMD_ASYNC)) { in il_tx_cmd_complete()
3326 clear_bit(S_HCMD_ACTIVE, &il->status); in il_tx_cmd_complete()
3328 il_get_cmd_string(cmd->hdr.cmd)); in il_tx_cmd_complete()
3329 wake_up(&il->wait_command_queue); in il_tx_cmd_complete()
3333 meta->flags = 0; in il_tx_cmd_complete()
3335 spin_unlock_irqrestore(&il->hcmd_lock, flags); in il_tx_cmd_complete()
3339 MODULE_DESCRIPTION("iwl-legacy: common functions for 3945 and 4965");
3352 * co-exist problem. The possible behaviors are:
3362 MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist");
3378 u8 rx_chains_num = il->hw_params.rx_chains_num; in il_init_ht_hw_capab()
3379 u8 tx_chains_num = il->hw_params.tx_chains_num; in il_init_ht_hw_capab()
3381 ht_info->cap = 0; in il_init_ht_hw_capab()
3382 memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); in il_init_ht_hw_capab()
3384 ht_info->ht_supported = true; in il_init_ht_hw_capab()
3386 ht_info->cap |= IEEE80211_HT_CAP_SGI_20; in il_init_ht_hw_capab()
3388 if (il->hw_params.ht40_channel & BIT(band)) { in il_init_ht_hw_capab()
3389 ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; in il_init_ht_hw_capab()
3390 ht_info->cap |= IEEE80211_HT_CAP_SGI_40; in il_init_ht_hw_capab()
3391 ht_info->mcs.rx_mask[4] = 0x01; in il_init_ht_hw_capab()
3395 if (il->cfg->mod_params->amsdu_size_8K) in il_init_ht_hw_capab()
3396 ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; in il_init_ht_hw_capab()
3398 ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; in il_init_ht_hw_capab()
3399 ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; in il_init_ht_hw_capab()
3401 ht_info->mcs.rx_mask[0] = 0xFF; in il_init_ht_hw_capab()
3403 ht_info->mcs.rx_mask[1] = 0xFF; in il_init_ht_hw_capab()
3405 ht_info->mcs.rx_mask[2] = 0xFF; in il_init_ht_hw_capab()
3410 ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate); in il_init_ht_hw_capab()
3413 ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in il_init_ht_hw_capab()
3415 ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; in il_init_ht_hw_capab()
3416 ht_info->mcs.tx_params |= in il_init_ht_hw_capab()
3417 ((tx_chains_num - in il_init_ht_hw_capab()
3423 * il_init_geos - Initialize mac80211's geo/channel info based from eeprom
3436 if (il->bands[NL80211_BAND_2GHZ].n_bitrates || in il_init_geos()
3437 il->bands[NL80211_BAND_5GHZ].n_bitrates) { in il_init_geos()
3439 set_bit(S_GEO_CONFIGURED, &il->status); in il_init_geos()
3444 kcalloc(il->channel_count, sizeof(struct ieee80211_channel), in il_init_geos()
3447 return -ENOMEM; in il_init_geos()
3454 return -ENOMEM; in il_init_geos()
3458 sband = &il->bands[NL80211_BAND_5GHZ]; in il_init_geos()
3459 sband->channels = &channels[ARRAY_SIZE(il_eeprom_band_1)]; in il_init_geos()
3461 sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; in il_init_geos()
3462 sband->n_bitrates = RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; in il_init_geos()
3464 if (il->cfg->sku & IL_SKU_N) in il_init_geos()
3465 il_init_ht_hw_capab(il, &sband->ht_cap, NL80211_BAND_5GHZ); in il_init_geos()
3467 sband = &il->bands[NL80211_BAND_2GHZ]; in il_init_geos()
3468 sband->channels = channels; in il_init_geos()
3470 sband->bitrates = rates; in il_init_geos()
3471 sband->n_bitrates = RATE_COUNT_LEGACY; in il_init_geos()
3473 if (il->cfg->sku & IL_SKU_N) in il_init_geos()
3474 il_init_ht_hw_capab(il, &sband->ht_cap, NL80211_BAND_2GHZ); in il_init_geos()
3476 il->ieee_channels = channels; in il_init_geos()
3477 il->ieee_rates = rates; in il_init_geos()
3479 for (i = 0; i < il->channel_count; i++) { in il_init_geos()
3480 ch = &il->channel_info[i]; in il_init_geos()
3485 sband = &il->bands[ch->band]; in il_init_geos()
3487 geo_ch = &sband->channels[sband->n_channels++]; in il_init_geos()
3489 geo_ch->center_freq = in il_init_geos()
3490 ieee80211_channel_to_frequency(ch->channel, ch->band); in il_init_geos()
3491 geo_ch->max_power = ch->max_power_avg; in il_init_geos()
3492 geo_ch->max_antenna_gain = 0xff; in il_init_geos()
3493 geo_ch->hw_value = ch->channel; in il_init_geos()
3496 if (!(ch->flags & EEPROM_CHANNEL_IBSS)) in il_init_geos()
3497 geo_ch->flags |= IEEE80211_CHAN_NO_IR; in il_init_geos()
3499 if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) in il_init_geos()
3500 geo_ch->flags |= IEEE80211_CHAN_NO_IR; in il_init_geos()
3502 if (ch->flags & EEPROM_CHANNEL_RADAR) in il_init_geos()
3503 geo_ch->flags |= IEEE80211_CHAN_RADAR; in il_init_geos()
3505 geo_ch->flags |= ch->ht40_extension_channel; in il_init_geos()
3507 if (ch->max_power_avg > max_tx_power) in il_init_geos()
3508 max_tx_power = ch->max_power_avg; in il_init_geos()
3510 geo_ch->flags |= IEEE80211_CHAN_DISABLED; in il_init_geos()
3513 D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", ch->channel, in il_init_geos()
3514 geo_ch->center_freq, in il_init_geos()
3516 geo_ch-> in il_init_geos()
3518 geo_ch->flags); in il_init_geos()
3521 il->tx_power_device_lmt = max_tx_power; in il_init_geos()
3522 il->tx_power_user_lmt = max_tx_power; in il_init_geos()
3523 il->tx_power_next = max_tx_power; in il_init_geos()
3525 if (il->bands[NL80211_BAND_5GHZ].n_channels == 0 && in il_init_geos()
3526 (il->cfg->sku & IL_SKU_A)) { in il_init_geos()
3529 il->pci_dev->device, il->pci_dev->subsystem_device); in il_init_geos()
3530 il->cfg->sku &= ~IL_SKU_A; in il_init_geos()
3534 il->bands[NL80211_BAND_2GHZ].n_channels, in il_init_geos()
3535 il->bands[NL80211_BAND_5GHZ].n_channels); in il_init_geos()
3537 set_bit(S_GEO_CONFIGURED, &il->status); in il_init_geos()
3544 * il_free_geos - undo allocations in il_init_geos
3549 kfree(il->ieee_channels); in il_free_geos()
3550 kfree(il->ieee_rates); in il_free_geos()
3551 clear_bit(S_GEO_CONFIGURED, &il->status); in il_free_geos()
3566 return !(ch_info-> in il_is_channel_extension()
3569 return !(ch_info-> in il_is_channel_extension()
3578 if (!il->ht.enabled || !il->ht.is_40mhz) in il_is_ht40_tx_allowed()
3585 if (ht_cap && !ht_cap->ht_supported) in il_is_ht40_tx_allowed()
3589 if (il->disable_ht40) in il_is_ht40_tx_allowed()
3593 return il_is_channel_extension(il, il->band, in il_is_ht40_tx_allowed()
3594 le16_to_cpu(il->staging.channel), in il_is_ht40_tx_allowed()
3595 il->ht.extension_chan_offset); in il_is_ht40_tx_allowed()
3640 struct ieee80211_vif *vif = il->vif; in il_send_rxon_timing()
3642 conf = &il->hw->conf; in il_send_rxon_timing()
3644 lockdep_assert_held(&il->mutex); in il_send_rxon_timing()
3646 memset(&il->timing, 0, sizeof(struct il_rxon_time_cmd)); in il_send_rxon_timing()
3648 il->timing.timestamp = cpu_to_le64(il->timestamp); in il_send_rxon_timing()
3649 il->timing.listen_interval = cpu_to_le16(conf->listen_interval); in il_send_rxon_timing()
3651 beacon_int = vif ? vif->bss_conf.beacon_int : 0; in il_send_rxon_timing()
3657 il->timing.atim_win = 0; in il_send_rxon_timing()
3661 il->hw_params.max_beacon_itrvl * in il_send_rxon_timing()
3663 il->timing.beacon_interval = cpu_to_le16(beacon_int); in il_send_rxon_timing()
3665 tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ in il_send_rxon_timing()
3668 il->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); in il_send_rxon_timing()
3670 il->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ? : 1) : 1; in il_send_rxon_timing()
3673 le16_to_cpu(il->timing.beacon_interval), in il_send_rxon_timing()
3674 le32_to_cpu(il->timing.beacon_init_val), in il_send_rxon_timing()
3675 le16_to_cpu(il->timing.atim_win)); in il_send_rxon_timing()
3677 return il_send_cmd_pdu(il, C_RXON_TIMING, sizeof(il->timing), in il_send_rxon_timing()
3678 &il->timing); in il_send_rxon_timing()
3685 struct il_rxon_cmd *rxon = &il->staging; in il_set_rxon_hwcrypto()
3688 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; in il_set_rxon_hwcrypto()
3690 rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; in il_set_rxon_hwcrypto()
3699 struct il_rxon_cmd *rxon = &il->staging; in il_check_rxon_cmd()
3702 if (rxon->flags & RXON_FLG_BAND_24G_MSK) { in il_check_rxon_cmd()
3703 if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { in il_check_rxon_cmd()
3707 if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { in il_check_rxon_cmd()
3712 if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { in il_check_rxon_cmd()
3716 if (rxon->flags & RXON_FLG_CCK_MSK) { in il_check_rxon_cmd()
3721 if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { in il_check_rxon_cmd()
3727 if ((rxon->ofdm_basic_rates & RATE_6M_MASK) == 0 && in il_check_rxon_cmd()
3728 (rxon->cck_basic_rates & RATE_1M_MASK) == 0) { in il_check_rxon_cmd()
3733 if (le16_to_cpu(rxon->assoc_id) > 2007) { in il_check_rxon_cmd()
3738 if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) == in il_check_rxon_cmd()
3744 if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) == in il_check_rxon_cmd()
3750 if ((rxon-> in il_check_rxon_cmd()
3753 IL_WARN("TGg but no auto-detect\n"); in il_check_rxon_cmd()
3758 IL_WARN("Tuning to channel %d\n", le16_to_cpu(rxon->channel)); in il_check_rxon_cmd()
3762 return -EINVAL; in il_check_rxon_cmd()
3769 * il_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
3779 const struct il_rxon_cmd *staging = &il->staging; in il_full_rxon_required()
3780 const struct il_rxon_cmd *active = &il->active; in il_full_rxon_required()
3784 D_INFO("need full RXON - " #cond "\n"); \ in il_full_rxon_required()
3790 D_INFO("need full RXON - " \ in il_full_rxon_required()
3791 #c1 " != " #c2 " - %d != %d\n", \ in il_full_rxon_required()
3798 CHK(!ether_addr_equal_64bits(staging->bssid_addr, active->bssid_addr)); in il_full_rxon_required()
3799 CHK(!ether_addr_equal_64bits(staging->node_addr, active->node_addr)); in il_full_rxon_required()
3800 CHK(!ether_addr_equal_64bits(staging->wlap_bssid_addr, in il_full_rxon_required()
3801 active->wlap_bssid_addr)); in il_full_rxon_required()
3802 CHK_NEQ(staging->dev_type, active->dev_type); in il_full_rxon_required()
3803 CHK_NEQ(staging->channel, active->channel); in il_full_rxon_required()
3804 CHK_NEQ(staging->air_propagation, active->air_propagation); in il_full_rxon_required()
3805 CHK_NEQ(staging->ofdm_ht_single_stream_basic_rates, in il_full_rxon_required()
3806 active->ofdm_ht_single_stream_basic_rates); in il_full_rxon_required()
3807 CHK_NEQ(staging->ofdm_ht_dual_stream_basic_rates, in il_full_rxon_required()
3808 active->ofdm_ht_dual_stream_basic_rates); in il_full_rxon_required()
3809 CHK_NEQ(staging->assoc_id, active->assoc_id); in il_full_rxon_required()
3812 * be updated with the RXON_ASSOC command -- however only some in il_full_rxon_required()
3816 CHK_NEQ(staging->flags & RXON_FLG_BAND_24G_MSK, in il_full_rxon_required()
3817 active->flags & RXON_FLG_BAND_24G_MSK); in il_full_rxon_required()
3820 CHK_NEQ(staging->filter_flags & RXON_FILTER_ASSOC_MSK, in il_full_rxon_required()
3821 active->filter_flags & RXON_FILTER_ASSOC_MSK); in il_full_rxon_required()
3834 * Assign the lowest rate -- should really get this from in il_get_lowest_plcp()
3837 if (il->staging.flags & RXON_FLG_BAND_24G_MSK) in il_get_lowest_plcp()
3847 struct il_rxon_cmd *rxon = &il->staging; in _il_set_rxon_ht()
3849 if (!il->ht.enabled) { in _il_set_rxon_ht()
3850 rxon->flags &= in _il_set_rxon_ht()
3857 rxon->flags |= in _il_set_rxon_ht()
3858 cpu_to_le32(il->ht.protection << RXON_FLG_HT_OPERATING_MODE_POS); in _il_set_rxon_ht()
3863 rxon->flags &= in _il_set_rxon_ht()
3867 if (il->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { in _il_set_rxon_ht()
3868 rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; in _il_set_rxon_ht()
3870 switch (il->ht.extension_chan_offset) { in _il_set_rxon_ht()
3872 rxon->flags &= in _il_set_rxon_ht()
3876 rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; in _il_set_rxon_ht()
3881 switch (il->ht.extension_chan_offset) { in _il_set_rxon_ht()
3883 rxon->flags &= in _il_set_rxon_ht()
3885 rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; in _il_set_rxon_ht()
3888 rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; in _il_set_rxon_ht()
3889 rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; in _il_set_rxon_ht()
3899 rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; in _il_set_rxon_ht()
3902 if (il->ops->set_rxon_chain) in _il_set_rxon_ht()
3903 il->ops->set_rxon_chain(il); in _il_set_rxon_ht()
3906 "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), in _il_set_rxon_ht()
3907 il->ht.protection, il->ht.extension_chan_offset); in _il_set_rxon_ht()
3928 max = il->channel_count; in il_get_single_channel_number()
3935 channel = il->channel_info[i].channel; in il_get_single_channel_number()
3936 if (channel == le16_to_cpu(il->staging.channel)) in il_get_single_channel_number()
3949 * il_set_rxon_channel - Set the band and channel values in staging RXON
3953 * in the staging RXON flag structure based on the ch->band
3958 enum nl80211_band band = ch->band; in il_set_rxon_channel()
3959 u16 channel = ch->hw_value; in il_set_rxon_channel()
3961 if (le16_to_cpu(il->staging.channel) == channel && il->band == band) in il_set_rxon_channel()
3964 il->staging.channel = cpu_to_le16(channel); in il_set_rxon_channel()
3966 il->staging.flags &= ~RXON_FLG_BAND_24G_MSK; in il_set_rxon_channel()
3968 il->staging.flags |= RXON_FLG_BAND_24G_MSK; in il_set_rxon_channel()
3970 il->band = band; in il_set_rxon_channel()
3983 il->staging.flags &= in il_set_flags_for_band()
3986 il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; in il_set_flags_for_band()
3989 if (vif && vif->bss_conf.use_short_slot) in il_set_flags_for_band()
3990 il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; in il_set_flags_for_band()
3992 il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; in il_set_flags_for_band()
3994 il->staging.flags |= RXON_FLG_BAND_24G_MSK; in il_set_flags_for_band()
3995 il->staging.flags |= RXON_FLG_AUTO_DETECT_MSK; in il_set_flags_for_band()
3996 il->staging.flags &= ~RXON_FLG_CCK_MSK; in il_set_flags_for_band()
4009 memset(&il->staging, 0, sizeof(il->staging)); in il_connection_init_rx_config()
4011 switch (il->iw_mode) { in il_connection_init_rx_config()
4013 il->staging.dev_type = RXON_DEV_TYPE_ESS; in il_connection_init_rx_config()
4016 il->staging.dev_type = RXON_DEV_TYPE_ESS; in il_connection_init_rx_config()
4017 il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; in il_connection_init_rx_config()
4020 il->staging.dev_type = RXON_DEV_TYPE_IBSS; in il_connection_init_rx_config()
4021 il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; in il_connection_init_rx_config()
4022 il->staging.filter_flags = in il_connection_init_rx_config()
4026 IL_ERR("Unsupported interface type %d\n", il->vif->type); in il_connection_init_rx_config()
4033 if (!hw_to_local(il->hw)->short_preamble) in il_connection_init_rx_config()
4034 il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; in il_connection_init_rx_config()
4036 il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; in il_connection_init_rx_config()
4040 il_get_channel_info(il, il->band, le16_to_cpu(il->active.channel)); in il_connection_init_rx_config()
4043 ch_info = &il->channel_info[0]; in il_connection_init_rx_config()
4045 il->staging.channel = cpu_to_le16(ch_info->channel); in il_connection_init_rx_config()
4046 il->band = ch_info->band; in il_connection_init_rx_config()
4048 il_set_flags_for_band(il, il->band, il->vif); in il_connection_init_rx_config()
4050 il->staging.ofdm_basic_rates = in il_connection_init_rx_config()
4052 il->staging.cck_basic_rates = in il_connection_init_rx_config()
4056 il->staging.flags &= in il_connection_init_rx_config()
4058 if (il->vif) in il_connection_init_rx_config()
4059 memcpy(il->staging.node_addr, il->vif->addr, ETH_ALEN); in il_connection_init_rx_config()
4061 il->staging.ofdm_ht_single_stream_basic_rates = 0xff; in il_connection_init_rx_config()
4062 il->staging.ofdm_ht_dual_stream_basic_rates = 0xff; in il_connection_init_rx_config()
4073 hw = il_get_hw_mode(il, il->band); in il_set_rate()
4079 il->active_rate = 0; in il_set_rate()
4081 for (i = 0; i < hw->n_bitrates; i++) { in il_set_rate()
4082 rate = &(hw->bitrates[i]); in il_set_rate()
4083 if (rate->hw_value < RATE_COUNT_LEGACY) in il_set_rate()
4084 il->active_rate |= (1 << rate->hw_value); in il_set_rate()
4087 D_RATE("Set active_rate = %0x\n", il->active_rate); in il_set_rate()
4089 il->staging.cck_basic_rates = in il_set_rate()
4092 il->staging.ofdm_basic_rates = in il_set_rate()
4100 if (test_bit(S_EXIT_PENDING, &il->status)) in il_chswitch_done()
4103 if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) in il_chswitch_done()
4104 ieee80211_chswitch_done(il->vif, is_success); in il_chswitch_done()
4112 struct il_csa_notification *csa = &(pkt->u.csa_notif); in il_hdl_csa()
4113 struct il_rxon_cmd *rxon = (void *)&il->active; in il_hdl_csa()
4115 if (!test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) in il_hdl_csa()
4118 if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { in il_hdl_csa()
4119 rxon->channel = csa->channel; in il_hdl_csa()
4120 il->staging.channel = csa->channel; in il_hdl_csa()
4121 D_11H("CSA notif: channel %d\n", le16_to_cpu(csa->channel)); in il_hdl_csa()
4125 le16_to_cpu(csa->channel)); in il_hdl_csa()
4135 struct il_rxon_cmd *rxon = &il->staging; in il_print_rx_config_cmd()
4139 D_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); in il_print_rx_config_cmd()
4140 D_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); in il_print_rx_config_cmd()
4141 D_RADIO("u32 filter_flags: 0x%08x\n", le32_to_cpu(rxon->filter_flags)); in il_print_rx_config_cmd()
4142 D_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type); in il_print_rx_config_cmd()
4143 D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", rxon->ofdm_basic_rates); in il_print_rx_config_cmd()
4144 D_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); in il_print_rx_config_cmd()
4145 D_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr); in il_print_rx_config_cmd()
4146 D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); in il_print_rx_config_cmd()
4147 D_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); in il_print_rx_config_cmd()
4152 * il_irq_handle_error - called for HW or SW error interrupt from card
4157 /* Set the FW error flag -- cleared on il_down */ in il_irq_handle_error()
4158 set_bit(S_FW_ERROR, &il->status); in il_irq_handle_error()
4161 clear_bit(S_HCMD_ACTIVE, &il->status); in il_irq_handle_error()
4163 IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version); in il_irq_handle_error()
4165 il->ops->dump_nic_error_log(il); in il_irq_handle_error()
4166 if (il->ops->dump_fh) in il_irq_handle_error()
4167 il->ops->dump_fh(il, NULL, false); in il_irq_handle_error()
4173 wake_up(&il->wait_command_queue); in il_irq_handle_error()
4177 clear_bit(S_READY, &il->status); in il_irq_handle_error()
4179 if (!test_bit(S_EXIT_PENDING, &il->status)) { in il_irq_handle_error()
4183 if (il->cfg->mod_params->restart_fw) in il_irq_handle_error()
4184 queue_work(il->workqueue, &il->restart); in il_irq_handle_error()
4211 lockdep_assert_held(&il->reg_lock); in _il_apm_stop()
4225 * D0A* (powered-up Active) --> D0U* (Uninitialized) state. in _il_apm_stop()
4236 spin_lock_irqsave(&il->reg_lock, flags); in il_apm_stop()
4238 spin_unlock_irqrestore(&il->reg_lock, flags); in il_apm_stop()
4260 /* Disable L0S exit timer (platform NMI Work/Around) */ in il_apm_init()
4265 * Disable L0s without affecting L1; in il_apm_init()
4266 * don't wait for ICH L0s (ICH bug W/A) in il_apm_init()
4276 * wake device's PCI Express link L1a -> L0s in il_apm_init()
4277 * NOTE: This is no-op for 3945 (non-existent bit) in il_apm_init()
4283 * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition. in il_apm_init()
4284 * Check if BIOS (or OS) enabled L1-ASPM on this device. in il_apm_init()
4285 * If so (likely), disable L0S, so device moves directly L0->L1; in il_apm_init()
4287 * If not (unlikely), enable L0S, so there is at least some in il_apm_init()
4290 if (il->cfg->set_l0s) { in il_apm_init()
4291 ret = pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl); in il_apm_init()
4293 /* L1-ASPM enabled; disable(!) L0S */ in il_apm_init()
4296 D_POWER("L1 Enabled; Disabling L0S\n"); in il_apm_init()
4298 /* L1-ASPM disabled; enable(!) L0S */ in il_apm_init()
4301 D_POWER("L1 Disabled; Enabling L0S\n"); in il_apm_init()
4305 /* Configure analog phase-lock-loop before activating to D0A */ in il_apm_init()
4306 if (il->cfg->pll_cfg_val) in il_apm_init()
4308 il->cfg->pll_cfg_val); in il_apm_init()
4312 * D0U* --> D0A* (powered-up active) state. in il_apm_init()
4318 * device-internal resources is supported, e.g. il_wr_prph() in il_apm_init()
4338 if (il->cfg->use_bsm) in il_apm_init()
4345 /* Disable L1-Active */ in il_apm_init()
4361 lockdep_assert_held(&il->mutex); in il_set_tx_power()
4363 if (il->tx_power_user_lmt == tx_power && !force) in il_set_tx_power()
4366 if (!il->ops->send_tx_power) in il_set_tx_power()
4367 return -EOPNOTSUPP; in il_set_tx_power()
4372 return -EINVAL; in il_set_tx_power()
4375 if (tx_power > il->tx_power_device_lmt) { in il_set_tx_power()
4377 tx_power, il->tx_power_device_lmt); in il_set_tx_power()
4378 return -EINVAL; in il_set_tx_power()
4382 return -EIO; in il_set_tx_power()
4386 il->tx_power_next = tx_power; in il_set_tx_power()
4389 defer = test_bit(S_SCANNING, &il->status) || in il_set_tx_power()
4390 memcmp(&il->active, &il->staging, sizeof(il->staging)); in il_set_tx_power()
4396 prev_tx_power = il->tx_power_user_lmt; in il_set_tx_power()
4397 il->tx_power_user_lmt = tx_power; in il_set_tx_power()
4399 ret = il->ops->send_tx_power(il); in il_set_tx_power()
4403 il->tx_power_user_lmt = prev_tx_power; in il_set_tx_power()
4404 il->tx_power_next = prev_tx_power; in il_set_tx_power()
4454 struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); in il_hdl_pm_sleep()
4456 sleep->pm_sleep_mode, sleep->pm_wakeup_src); in il_hdl_pm_sleep()
4465 u32 len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; in il_hdl_pm_debug_stats()
4467 il_get_cmd_string(pkt->hdr.cmd)); in il_hdl_pm_debug_stats()
4468 il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); in il_hdl_pm_debug_stats()
4479 le32_to_cpu(pkt->u.err_resp.error_type), in il_hdl_error()
4480 il_get_cmd_string(pkt->u.err_resp.cmd_id), in il_hdl_error()
4481 pkt->u.err_resp.cmd_id, in il_hdl_error()
4482 le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), in il_hdl_error()
4483 le32_to_cpu(pkt->u.err_resp.error_info)); in il_hdl_error()
4490 memset(&il->isr_stats, 0, sizeof(il->isr_stats)); in il_clear_isr_stats()
4498 struct il_priv *il = hw->priv; in il_mac_conf_tx()
4505 D_MAC80211("leave - RF not ready\n"); in il_mac_conf_tx()
4506 return -EIO; in il_mac_conf_tx()
4510 D_MAC80211("leave - queue >= AC_NUM %d\n", queue); in il_mac_conf_tx()
4514 q = AC_NUM - 1 - queue; in il_mac_conf_tx()
4516 spin_lock_irqsave(&il->lock, flags); in il_mac_conf_tx()
4518 il->qos_data.def_qos_parm.ac[q].cw_min = in il_mac_conf_tx()
4519 cpu_to_le16(params->cw_min); in il_mac_conf_tx()
4520 il->qos_data.def_qos_parm.ac[q].cw_max = in il_mac_conf_tx()
4521 cpu_to_le16(params->cw_max); in il_mac_conf_tx()
4522 il->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; in il_mac_conf_tx()
4523 il->qos_data.def_qos_parm.ac[q].edca_txop = in il_mac_conf_tx()
4524 cpu_to_le16((params->txop * 32)); in il_mac_conf_tx()
4526 il->qos_data.def_qos_parm.ac[q].reserved1 = 0; in il_mac_conf_tx()
4528 spin_unlock_irqrestore(&il->lock, flags); in il_mac_conf_tx()
4538 struct il_priv *il = hw->priv; in il_mac_tx_last_beacon()
4543 ret = (il->ibss_manager == IL_IBSS_MANAGER); in il_mac_tx_last_beacon()
4555 if (il->ops->set_rxon_chain) in il_set_mode()
4556 il->ops->set_rxon_chain(il); in il_set_mode()
4564 struct il_priv *il = hw->priv; in il_mac_add_interface()
4568 mutex_lock(&il->mutex); in il_mac_add_interface()
4569 D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); in il_mac_add_interface()
4573 err = -EINVAL; in il_mac_add_interface()
4581 reset = (il->vif == vif); in il_mac_add_interface()
4582 if (il->vif && !reset) { in il_mac_add_interface()
4583 err = -EOPNOTSUPP; in il_mac_add_interface()
4587 il->vif = vif; in il_mac_add_interface()
4588 il->iw_mode = vif->type; in il_mac_add_interface()
4592 IL_WARN("Fail to set mode %d\n", vif->type); in il_mac_add_interface()
4594 il->vif = NULL; in il_mac_add_interface()
4595 il->iw_mode = NL80211_IFTYPE_STATION; in il_mac_add_interface()
4601 mutex_unlock(&il->mutex); in il_mac_add_interface()
4610 lockdep_assert_held(&il->mutex); in il_teardown_interface()
4612 if (il->scan_vif == vif) { in il_teardown_interface()
4623 struct il_priv *il = hw->priv; in il_mac_remove_interface()
4625 mutex_lock(&il->mutex); in il_mac_remove_interface()
4626 D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); in il_mac_remove_interface()
4628 WARN_ON(il->vif != vif); in il_mac_remove_interface()
4629 il->vif = NULL; in il_mac_remove_interface()
4630 il->iw_mode = NL80211_IFTYPE_UNSPECIFIED; in il_mac_remove_interface()
4632 eth_zero_addr(il->bssid); in il_mac_remove_interface()
4635 mutex_unlock(&il->mutex); in il_mac_remove_interface()
4642 if (!il->txq) in il_alloc_txq_mem()
4643 il->txq = in il_alloc_txq_mem()
4644 kcalloc(il->cfg->num_of_queues, in il_alloc_txq_mem()
4647 if (!il->txq) { in il_alloc_txq_mem()
4649 return -ENOMEM; in il_alloc_txq_mem()
4658 kfree(il->txq); in il_free_txq_mem()
4659 il->txq = NULL; in il_free_txq_mem()
4668 if (test_bit(S_EXIT_PENDING, &il->status)) in il_force_reset()
4669 return -EINVAL; in il_force_reset()
4671 force_reset = &il->force_reset; in il_force_reset()
4672 force_reset->reset_request_count++; in il_force_reset()
4674 if (force_reset->last_force_reset_jiffies && in il_force_reset()
4675 time_after(force_reset->last_force_reset_jiffies + in il_force_reset()
4676 force_reset->reset_duration, jiffies)) { in il_force_reset()
4678 force_reset->reset_reject_count++; in il_force_reset()
4679 return -EAGAIN; in il_force_reset()
4682 force_reset->reset_success_count++; in il_force_reset()
4683 force_reset->last_force_reset_jiffies = jiffies; in il_force_reset()
4694 if (!external && !il->cfg->mod_params->restart_fw) { in il_force_reset()
4702 /* Set the FW error flag -- cleared on il_down */ in il_force_reset()
4703 set_bit(S_FW_ERROR, &il->status); in il_force_reset()
4704 wake_up(&il->wait_command_queue); in il_force_reset()
4709 clear_bit(S_READY, &il->status); in il_force_reset()
4710 queue_work(il->workqueue, &il->restart); in il_force_reset()
4720 struct il_priv *il = hw->priv; in il_mac_change_interface()
4723 mutex_lock(&il->mutex); in il_mac_change_interface()
4725 vif->type, vif->addr, newtype, newp2p); in il_mac_change_interface()
4728 err = -EOPNOTSUPP; in il_mac_change_interface()
4732 if (!il->vif || !il_is_ready_rf(il)) { in il_mac_change_interface()
4737 err = -EBUSY; in il_mac_change_interface()
4742 vif->type = newtype; in il_mac_change_interface()
4743 vif->p2p = false; in il_mac_change_interface()
4744 il->iw_mode = newtype; in il_mac_change_interface()
4750 mutex_unlock(&il->mutex); in il_mac_change_interface()
4759 struct il_priv *il = hw->priv; in il_mac_flush()
4763 mutex_lock(&il->mutex); in il_mac_flush()
4766 if (il->txq == NULL) in il_mac_flush()
4769 for (i = 0; i < il->hw_params.max_txq_num; i++) { in il_mac_flush()
4772 if (i == il->cmd_queue) in il_mac_flush()
4775 q = &il->txq[i].q; in il_mac_flush()
4776 if (q->read_ptr == q->write_ptr) in il_mac_flush()
4780 IL_ERR("Failed to flush queue %d\n", q->id); in il_mac_flush()
4788 mutex_unlock(&il->mutex); in il_mac_flush()
4799 struct il_tx_queue *txq = &il->txq[cnt]; in il_check_stuck_queue()
4800 struct il_queue *q = &txq->q; in il_check_stuck_queue()
4805 if (q->read_ptr == q->write_ptr) { in il_check_stuck_queue()
4806 txq->time_stamp = now; in il_check_stuck_queue()
4811 txq->time_stamp + in il_check_stuck_queue()
4812 msecs_to_jiffies(il->cfg->wd_timeout); in il_check_stuck_queue()
4815 IL_ERR("Queue %d stuck for %u ms.\n", q->id, in il_check_stuck_queue()
4816 jiffies_to_msecs(now - txq->time_stamp)); in il_check_stuck_queue()
4818 return (ret == -EAGAIN) ? 0 : 1; in il_check_stuck_queue()
4841 if (test_bit(S_EXIT_PENDING, &il->status)) in il_bg_watchdog()
4844 timeout = il->cfg->wd_timeout; in il_bg_watchdog()
4849 if (il_check_stuck_queue(il, il->cmd_queue)) in il_bg_watchdog()
4853 for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { in il_bg_watchdog()
4855 if (cnt == il->cmd_queue) in il_bg_watchdog()
4861 mod_timer(&il->watchdog, in il_bg_watchdog()
4869 unsigned int timeout = il->cfg->wd_timeout; in il_setup_watchdog()
4872 mod_timer(&il->watchdog, in il_setup_watchdog()
4875 del_timer(&il->watchdog); in il_setup_watchdog()
4881 * time in usec will be changed into a 32-bit value in extended:internal format
4898 il->hw_params. in il_usecs_to_beacons()
4899 beacon_time_tsf_bits) >> il-> in il_usecs_to_beacons()
4903 il->hw_params. in il_usecs_to_beacons()
4906 return (quot << il->hw_params.beacon_time_tsf_bits) + rem; in il_usecs_to_beacons()
4918 il->hw_params. in il_add_beacon_time()
4921 il->hw_params. in il_add_beacon_time()
4925 il->hw_params. in il_add_beacon_time()
4928 il->hw_params. in il_add_beacon_time()
4932 res += base_low - addon_low; in il_add_beacon_time()
4934 res += interval + base_low - addon_low; in il_add_beacon_time()
4935 res += (1 << il->hw_params.beacon_time_tsf_bits); in il_add_beacon_time()
4937 res += (1 << il->hw_params.beacon_time_tsf_bits); in il_add_beacon_time()
4953 * first but since il_mac_stop() has no knowledge of who the caller is, in il_pci_suspend()
4983 set_bit(S_RFKILL, &il->status); in il_pci_resume()
4985 clear_bit(S_RFKILL, &il->status); in il_pci_resume()
4987 wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); in il_pci_resume()
5000 if (test_bit(S_EXIT_PENDING, &il->status)) in il_update_qos()
5003 il->qos_data.def_qos_parm.qos_flags = 0; in il_update_qos()
5005 if (il->qos_data.qos_active) in il_update_qos()
5006 il->qos_data.def_qos_parm.qos_flags |= in il_update_qos()
5009 if (il->ht.enabled) in il_update_qos()
5010 il->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; in il_update_qos()
5013 il->qos_data.qos_active, il->qos_data.def_qos_parm.qos_flags); in il_update_qos()
5016 &il->qos_data.def_qos_parm, NULL); in il_update_qos()
5020 * il_mac_config - mac80211 config callback
5025 struct il_priv *il = hw->priv; in il_mac_config()
5027 struct ieee80211_conf *conf = &hw->conf; in il_mac_config()
5028 struct ieee80211_channel *channel = conf->chandef.chan; in il_mac_config()
5029 struct il_ht_config *ht_conf = &il->current_ht_config; in il_mac_config()
5036 mutex_lock(&il->mutex); in il_mac_config()
5037 D_MAC80211("enter: channel %d changed 0x%X\n", channel->hw_value, in il_mac_config()
5040 if (unlikely(test_bit(S_SCANNING, &il->status))) { in il_mac_config()
5047 /* mac80211 uses static for non-HT which is what we want */ in il_mac_config()
5048 il->current_ht_config.smps = conf->smps_mode; in il_mac_config()
5057 if (il->ops->set_rxon_chain) in il_mac_config()
5058 il->ops->set_rxon_chain(il); in il_mac_config()
5069 ch = channel->hw_value; in il_mac_config()
5070 ch_info = il_get_channel_info(il, channel->band, ch); in il_mac_config()
5072 D_MAC80211("leave - invalid channel\n"); in il_mac_config()
5073 ret = -EINVAL; in il_mac_config()
5077 if (il->iw_mode == NL80211_IFTYPE_ADHOC && in il_mac_config()
5079 D_MAC80211("leave - not IBSS channel\n"); in il_mac_config()
5080 ret = -EINVAL; in il_mac_config()
5084 spin_lock_irqsave(&il->lock, flags); in il_mac_config()
5087 if (il->ht.enabled != conf_is_ht(conf)) { in il_mac_config()
5088 il->ht.enabled = conf_is_ht(conf); in il_mac_config()
5091 if (il->ht.enabled) { in il_mac_config()
5093 il->ht.extension_chan_offset = in il_mac_config()
5095 il->ht.is_40mhz = true; in il_mac_config()
5097 il->ht.extension_chan_offset = in il_mac_config()
5099 il->ht.is_40mhz = true; in il_mac_config()
5101 il->ht.extension_chan_offset = in il_mac_config()
5103 il->ht.is_40mhz = false; in il_mac_config()
5106 il->ht.is_40mhz = false; in il_mac_config()
5109 * Default to no protection. Protection mode will in il_mac_config()
5112 il->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE; in il_mac_config()
5117 if ((le16_to_cpu(il->staging.channel) != ch)) in il_mac_config()
5118 il->staging.flags = 0; in il_mac_config()
5123 il_set_flags_for_band(il, channel->band, il->vif); in il_mac_config()
5125 spin_unlock_irqrestore(&il->lock, flags); in il_mac_config()
5127 if (il->ops->update_bcast_stations) in il_mac_config()
5128 ret = il->ops->update_bcast_stations(il); in il_mac_config()
5138 il->power_data.ps_disabled = !(conf->flags & IEEE80211_CONF_PS); in il_mac_config()
5139 if (!il->power_data.ps_disabled) in il_mac_config()
5147 D_MAC80211("TX Power old=%d new=%d\n", il->tx_power_user_lmt, in il_mac_config()
5148 conf->power_level); in il_mac_config()
5150 il_set_tx_power(il, conf->power_level, false); in il_mac_config()
5154 D_MAC80211("leave - not ready\n"); in il_mac_config()
5161 if (memcmp(&il->active, &il->staging, sizeof(il->staging))) in il_mac_config()
5164 D_INFO("Not re-sending same RXON configuration.\n"); in il_mac_config()
5170 mutex_unlock(&il->mutex); in il_mac_config()
5179 struct il_priv *il = hw->priv; in il_mac_reset_tsf()
5182 mutex_lock(&il->mutex); in il_mac_reset_tsf()
5183 D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); in il_mac_reset_tsf()
5185 spin_lock_irqsave(&il->lock, flags); in il_mac_reset_tsf()
5187 memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); in il_mac_reset_tsf()
5190 dev_consume_skb_irq(il->beacon_skb); in il_mac_reset_tsf()
5191 il->beacon_skb = NULL; in il_mac_reset_tsf()
5192 il->timestamp = 0; in il_mac_reset_tsf()
5194 spin_unlock_irqrestore(&il->lock, flags); in il_mac_reset_tsf()
5198 D_MAC80211("leave - not ready\n"); in il_mac_reset_tsf()
5199 mutex_unlock(&il->mutex); in il_mac_reset_tsf()
5204 il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; in il_mac_reset_tsf()
5210 mutex_unlock(&il->mutex); in il_mac_reset_tsf()
5217 struct il_ht_config *ht_conf = &il->current_ht_config; in il_ht_conf()
5219 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; in il_ht_conf()
5223 if (!il->ht.enabled) in il_ht_conf()
5226 il->ht.protection = in il_ht_conf()
5227 bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; in il_ht_conf()
5228 il->ht.non_gf_sta_present = in il_ht_conf()
5229 !!(bss_conf-> in il_ht_conf()
5232 ht_conf->single_chain_sufficient = false; in il_ht_conf()
5234 switch (vif->type) { in il_ht_conf()
5237 sta = ieee80211_find_sta(vif, bss_conf->bssid); in il_ht_conf()
5239 struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in il_ht_conf()
5243 (ht_cap->mcs. in il_ht_conf()
5248 if (ht_cap->mcs.rx_mask[1] == 0 && in il_ht_conf()
5249 ht_cap->mcs.rx_mask[2] == 0) in il_ht_conf()
5250 ht_conf->single_chain_sufficient = true; in il_ht_conf()
5252 ht_conf->single_chain_sufficient = true; in il_ht_conf()
5260 ht_conf->single_chain_sufficient = true; in il_ht_conf()
5265 ht_conf->single_chain_sufficient = true; in il_ht_conf()
5278 * inform the ucode that there is no longer an in il_set_no_assoc()
5279 * association and that no more packets should be in il_set_no_assoc()
5282 il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; in il_set_no_assoc()
5283 il->staging.assoc_id = 0; in il_set_no_assoc()
5290 struct il_priv *il = hw->priv; in il_beacon_update()
5300 lockdep_assert_held(&il->mutex); in il_beacon_update()
5302 if (!il->beacon_enabled) { in il_beacon_update()
5303 IL_ERR("update beacon with no beaconing enabled\n"); in il_beacon_update()
5308 spin_lock_irqsave(&il->lock, flags); in il_beacon_update()
5309 dev_consume_skb_irq(il->beacon_skb); in il_beacon_update()
5310 il->beacon_skb = skb; in il_beacon_update()
5312 timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; in il_beacon_update()
5313 il->timestamp = le64_to_cpu(timestamp); in il_beacon_update()
5316 spin_unlock_irqrestore(&il->lock, flags); in il_beacon_update()
5319 D_MAC80211("leave - RF not ready\n"); in il_beacon_update()
5323 il->ops->post_associate(il); in il_beacon_update()
5330 struct il_priv *il = hw->priv; in il_mac_bss_info_changed()
5333 mutex_lock(&il->mutex); in il_mac_bss_info_changed()
5337 D_MAC80211("leave - not alive\n"); in il_mac_bss_info_changed()
5338 mutex_unlock(&il->mutex); in il_mac_bss_info_changed()
5345 spin_lock_irqsave(&il->lock, flags); in il_mac_bss_info_changed()
5346 il->qos_data.qos_active = bss_conf->qos; in il_mac_bss_info_changed()
5348 spin_unlock_irqrestore(&il->lock, flags); in il_mac_bss_info_changed()
5353 if (vif->bss_conf.enable_beacon) in il_mac_bss_info_changed()
5354 il->beacon_enabled = true; in il_mac_bss_info_changed()
5356 il->beacon_enabled = false; in il_mac_bss_info_changed()
5360 D_MAC80211("BSSID %pM\n", bss_conf->bssid); in il_mac_bss_info_changed()
5364 * there is traffic on that channel. If no frame will be in il_mac_bss_info_changed()
5370 if (is_zero_ether_addr(bss_conf->bssid)) in il_mac_bss_info_changed()
5379 D_MAC80211("leave - scan abort failed\n"); in il_mac_bss_info_changed()
5380 mutex_unlock(&il->mutex); in il_mac_bss_info_changed()
5385 memcpy(il->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); in il_mac_bss_info_changed()
5388 memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); in il_mac_bss_info_changed()
5396 if (vif->type == NL80211_IFTYPE_ADHOC && (changes & BSS_CHANGED_BEACON)) in il_mac_bss_info_changed()
5400 D_MAC80211("ERP_PREAMBLE %d\n", bss_conf->use_short_preamble); in il_mac_bss_info_changed()
5401 if (bss_conf->use_short_preamble) in il_mac_bss_info_changed()
5402 il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; in il_mac_bss_info_changed()
5404 il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; in il_mac_bss_info_changed()
5408 D_MAC80211("ERP_CTS %d\n", bss_conf->use_cts_prot); in il_mac_bss_info_changed()
5409 if (bss_conf->use_cts_prot && il->band != NL80211_BAND_5GHZ) in il_mac_bss_info_changed()
5410 il->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; in il_mac_bss_info_changed()
5412 il->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; in il_mac_bss_info_changed()
5413 if (bss_conf->use_cts_prot) in il_mac_bss_info_changed()
5414 il->staging.flags |= RXON_FLG_SELF_CTS_EN; in il_mac_bss_info_changed()
5416 il->staging.flags &= ~RXON_FLG_SELF_CTS_EN; in il_mac_bss_info_changed()
5425 if (A-band) in il_mac_bss_info_changed()
5426 il->staging.ofdm_basic_rates = in il_mac_bss_info_changed()
5427 bss_conf->basic_rates; in il_mac_bss_info_changed()
5429 il->staging.ofdm_basic_rates = in il_mac_bss_info_changed()
5430 bss_conf->basic_rates >> 4; in il_mac_bss_info_changed()
5431 il->staging.cck_basic_rates = in il_mac_bss_info_changed()
5432 bss_conf->basic_rates & 0xF; in il_mac_bss_info_changed()
5439 if (il->ops->set_rxon_chain) in il_mac_bss_info_changed()
5440 il->ops->set_rxon_chain(il); in il_mac_bss_info_changed()
5444 D_MAC80211("ASSOC %d\n", vif->cfg.assoc); in il_mac_bss_info_changed()
5445 if (vif->cfg.assoc) { in il_mac_bss_info_changed()
5446 il->timestamp = bss_conf->sync_tsf; in il_mac_bss_info_changed()
5449 il->ops->post_associate(il); in il_mac_bss_info_changed()
5454 if (changes && il_is_associated(il) && vif->cfg.aid) { in il_mac_bss_info_changed()
5459 memcpy((void *)&il->active, &il->staging, in il_mac_bss_info_changed()
5465 if (vif->bss_conf.enable_beacon) { in il_mac_bss_info_changed()
5466 memcpy(il->staging.bssid_addr, bss_conf->bssid, in il_mac_bss_info_changed()
5468 memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); in il_mac_bss_info_changed()
5469 il->ops->config_ap(il); in il_mac_bss_info_changed()
5475 ret = il->ops->manage_ibss_station(il, vif, in il_mac_bss_info_changed()
5476 vif->cfg.ibss_joined); in il_mac_bss_info_changed()
5479 vif->cfg.ibss_joined ? "add" : "remove", in il_mac_bss_info_changed()
5480 bss_conf->bssid); in il_mac_bss_info_changed()
5484 mutex_unlock(&il->mutex); in il_mac_bss_info_changed()
5498 spin_lock_irqsave(&il->lock, flags); in il_isr()
5501 * back-to-back ISRs and sporadic interrupts from our NIC. in il_isr()
5502 * If we have something to service, the tasklet will re-enable ints. in il_isr()
5503 * If we *don't* have something, we'll re-enable before leaving here. */ in il_isr()
5531 /* il_irq_tasklet() will service interrupts and re-enable them */ in il_isr()
5533 tasklet_schedule(&il->irq_tasklet); in il_isr()
5536 spin_unlock_irqrestore(&il->lock, flags); in il_isr()
5540 /* re-enable interrupts here since we don't have anything to service. */ in il_isr()
5541 /* only Re-enable if disabled by irq */ in il_isr()
5542 if (test_bit(S_INT_ENABLED, &il->status)) in il_isr()
5544 spin_unlock_irqrestore(&il->lock, flags); in il_isr()
5557 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { in il_tx_cmd_protection()
5574 } else if (info->control.rates[0]. in il_tx_cmd_protection()