Lines Matching +full:queue +full:- +full:pkt +full:- +full:rx
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
11 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
22 #include <linux/dma-mapping.h>
71 if (!test_bit(S_EXIT_PENDING, &il->status)) in il4965_check_abort_status()
72 queue_work(il->workqueue, &il->tx_flush); in il4965_check_abort_status()
89 spin_lock_irqsave(&rxq->lock, flags); in il4965_rx_queue_reset()
90 INIT_LIST_HEAD(&rxq->rx_free); in il4965_rx_queue_reset()
91 INIT_LIST_HEAD(&rxq->rx_used); in il4965_rx_queue_reset()
92 /* Fill the rx_used queue with _all_ of the Rx buffers */ in il4965_rx_queue_reset()
96 if (rxq->pool[i].page != NULL) { in il4965_rx_queue_reset()
97 dma_unmap_page(&il->pci_dev->dev, in il4965_rx_queue_reset()
98 rxq->pool[i].page_dma, in il4965_rx_queue_reset()
99 PAGE_SIZE << il->hw_params.rx_page_order, in il4965_rx_queue_reset()
101 __il_free_pages(il, rxq->pool[i].page); in il4965_rx_queue_reset()
102 rxq->pool[i].page = NULL; in il4965_rx_queue_reset()
104 list_add_tail(&rxq->pool[i].list, &rxq->rx_used); in il4965_rx_queue_reset()
108 rxq->queue[i] = NULL; in il4965_rx_queue_reset()
111 * not restocked the Rx queue with fresh buffers */ in il4965_rx_queue_reset()
112 rxq->read = rxq->write = 0; in il4965_rx_queue_reset()
113 rxq->write_actual = 0; in il4965_rx_queue_reset()
114 rxq->free_count = 0; in il4965_rx_queue_reset()
115 spin_unlock_irqrestore(&rxq->lock, flags); in il4965_rx_queue_reset()
125 if (il->cfg->mod_params->amsdu_size_8K) in il4965_rx_init()
130 /* Stop Rx DMA */ in il4965_rx_init()
133 /* Reset driver's Rx queue write idx */ in il4965_rx_init()
137 il_wr(il, FH49_RSCSR_CHNL0_RBDCB_BASE_REG, (u32) (rxq->bd_dma >> 8)); in il4965_rx_init()
139 /* Tell device where in DRAM to update its Rx status */ in il4965_rx_init()
140 il_wr(il, FH49_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); in il4965_rx_init()
142 /* Enable Rx DMA in il4965_rx_init()
143 * Direct rx interrupts to hosts in il4965_rx_init()
144 * Rx buffer size 4 or 8k in il4965_rx_init()
169 if (pci_pme_capable(il->pci_dev, PCI_D3cold)) in il4965_set_pwr_vmain()
184 struct il_rx_queue *rxq = &il->rxq; in il4965_hw_nic_init()
187 spin_lock_irqsave(&il->lock, flags); in il4965_hw_nic_init()
191 spin_unlock_irqrestore(&il->lock, flags); in il4965_hw_nic_init()
196 /* Allocate the RX queue, or reset if it is already allocated */ in il4965_hw_nic_init()
197 if (!rxq->bd) { in il4965_hw_nic_init()
200 IL_ERR("Unable to initialize Rx queue\n"); in il4965_hw_nic_init()
201 return -ENOMEM; in il4965_hw_nic_init()
210 spin_lock_irqsave(&il->lock, flags); in il4965_hw_nic_init()
212 rxq->need_update = 1; in il4965_hw_nic_init()
215 spin_unlock_irqrestore(&il->lock, flags); in il4965_hw_nic_init()
218 if (!il->txq) { in il4965_hw_nic_init()
225 set_bit(S_INIT, &il->status); in il4965_hw_nic_init()
231 * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr
240 * il4965_rx_queue_restock - refill RX queue from pre-allocated pool
242 * If there are slots in the RX queue that need to be restocked,
243 * and we have free pre-allocated buffers, fill the ranks as much
253 struct il_rx_queue *rxq = &il->rxq; in il4965_rx_queue_restock()
258 spin_lock_irqsave(&rxq->lock, flags); in il4965_rx_queue_restock()
259 while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { in il4965_rx_queue_restock()
261 rxb = rxq->queue[rxq->write]; in il4965_rx_queue_restock()
262 BUG_ON(rxb && rxb->page); in il4965_rx_queue_restock()
264 /* Get next free Rx buffer, remove from free list */ in il4965_rx_queue_restock()
265 element = rxq->rx_free.next; in il4965_rx_queue_restock()
269 /* Point to Rx buffer via next RBD in circular buffer */ in il4965_rx_queue_restock()
270 rxq->bd[rxq->write] = in il4965_rx_queue_restock()
271 il4965_dma_addr2rbd_ptr(il, rxb->page_dma); in il4965_rx_queue_restock()
272 rxq->queue[rxq->write] = rxb; in il4965_rx_queue_restock()
273 rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; in il4965_rx_queue_restock()
274 rxq->free_count--; in il4965_rx_queue_restock()
276 spin_unlock_irqrestore(&rxq->lock, flags); in il4965_rx_queue_restock()
277 /* If the pre-allocated buffer pool is dropping low, schedule to in il4965_rx_queue_restock()
279 if (rxq->free_count <= RX_LOW_WATERMARK) in il4965_rx_queue_restock()
280 queue_work(il->workqueue, &il->rx_replenish); in il4965_rx_queue_restock()
284 if (rxq->write_actual != (rxq->write & ~0x7)) { in il4965_rx_queue_restock()
285 spin_lock_irqsave(&rxq->lock, flags); in il4965_rx_queue_restock()
286 rxq->need_update = 1; in il4965_rx_queue_restock()
287 spin_unlock_irqrestore(&rxq->lock, flags); in il4965_rx_queue_restock()
293 * il4965_rx_replenish - Move all used packet from rx_used to rx_free
297 * Also restock the Rx queue via il_rx_queue_restock.
303 struct il_rx_queue *rxq = &il->rxq; in il4965_rx_allocate()
312 spin_lock_irqsave(&rxq->lock, flags); in il4965_rx_allocate()
313 if (list_empty(&rxq->rx_used)) { in il4965_rx_allocate()
314 spin_unlock_irqrestore(&rxq->lock, flags); in il4965_rx_allocate()
317 spin_unlock_irqrestore(&rxq->lock, flags); in il4965_rx_allocate()
319 if (rxq->free_count > RX_LOW_WATERMARK) in il4965_rx_allocate()
322 if (il->hw_params.rx_page_order > 0) in il4965_rx_allocate()
326 page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); in il4965_rx_allocate()
330 il->hw_params.rx_page_order); in il4965_rx_allocate()
332 if (rxq->free_count <= RX_LOW_WATERMARK && in il4965_rx_allocate()
338 rxq->free_count); in il4965_rx_allocate()
339 /* We don't reschedule replenish work here -- we will in il4965_rx_allocate()
346 page_dma = dma_map_page(&il->pci_dev->dev, page, 0, in il4965_rx_allocate()
347 PAGE_SIZE << il->hw_params.rx_page_order, in il4965_rx_allocate()
349 if (unlikely(dma_mapping_error(&il->pci_dev->dev, page_dma))) { in il4965_rx_allocate()
350 __free_pages(page, il->hw_params.rx_page_order); in il4965_rx_allocate()
354 spin_lock_irqsave(&rxq->lock, flags); in il4965_rx_allocate()
356 if (list_empty(&rxq->rx_used)) { in il4965_rx_allocate()
357 spin_unlock_irqrestore(&rxq->lock, flags); in il4965_rx_allocate()
358 dma_unmap_page(&il->pci_dev->dev, page_dma, in il4965_rx_allocate()
359 PAGE_SIZE << il->hw_params.rx_page_order, in il4965_rx_allocate()
361 __free_pages(page, il->hw_params.rx_page_order); in il4965_rx_allocate()
365 element = rxq->rx_used.next; in il4965_rx_allocate()
369 BUG_ON(rxb->page); in il4965_rx_allocate()
371 rxb->page = page; in il4965_rx_allocate()
372 rxb->page_dma = page_dma; in il4965_rx_allocate()
373 list_add_tail(&rxb->list, &rxq->rx_free); in il4965_rx_allocate()
374 rxq->free_count++; in il4965_rx_allocate()
375 il->alloc_rxb_page++; in il4965_rx_allocate()
377 spin_unlock_irqrestore(&rxq->lock, flags); in il4965_rx_allocate()
388 spin_lock_irqsave(&il->lock, flags); in il4965_rx_replenish()
390 spin_unlock_irqrestore(&il->lock, flags); in il4965_rx_replenish()
411 if (rxq->pool[i].page != NULL) { in il4965_rx_queue_free()
412 dma_unmap_page(&il->pci_dev->dev, in il4965_rx_queue_free()
413 rxq->pool[i].page_dma, in il4965_rx_queue_free()
414 PAGE_SIZE << il->hw_params.rx_page_order, in il4965_rx_queue_free()
416 __il_free_pages(il, rxq->pool[i].page); in il4965_rx_queue_free()
417 rxq->pool[i].page = NULL; in il4965_rx_queue_free()
421 dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, in il4965_rx_queue_free()
422 rxq->bd_dma); in il4965_rx_queue_free()
423 dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), in il4965_rx_queue_free()
424 rxq->rb_stts, rxq->rb_stts_dma); in il4965_rx_queue_free()
425 rxq->bd = NULL; in il4965_rx_queue_free()
426 rxq->rb_stts = NULL; in il4965_rx_queue_free()
440 IL_ERR("Can't stop Rx DMA.\n"); in il4965_rxq_stop()
461 return idx - band_offset; in il4965_hwrate_to_mac80211_idx()
464 return -1; in il4965_hwrate_to_mac80211_idx()
473 (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; in il4965_calc_rssi()
475 (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) >> in il4965_calc_rssi()
479 (le16_to_cpu(rx_resp->phy_flags) & IL49_RX_PHY_FLAGS_ANTENNAE_MASK) in il4965_calc_rssi()
491 max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); in il4965_calc_rssi()
494 ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], in il4965_calc_rssi()
497 /* dBm = max_rssi dB - agc dB - constant. in il4965_calc_rssi()
499 return max_rssi - agc - IL4965_RSSI_OFFSET; in il4965_calc_rssi()
570 __le16 fc = hdr->frame_control; in il4965_pass_packet_to_mac80211()
573 if (unlikely(!il->is_open)) { in il4965_pass_packet_to_mac80211()
578 if (unlikely(test_bit(IL_STOP_REASON_PASSIVE, &il->stop_reason))) { in il4965_pass_packet_to_mac80211()
580 D_INFO("Woke queues - frame received on passive channel\n"); in il4965_pass_packet_to_mac80211()
584 if (!il->cfg->mod_params->sw_crypto && in il4965_pass_packet_to_mac80211()
597 skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), in il4965_pass_packet_to_mac80211()
598 len, PAGE_SIZE << il->hw_params.rx_page_order); in il4965_pass_packet_to_mac80211()
599 il->alloc_rxb_page--; in il4965_pass_packet_to_mac80211()
600 rxb->page = NULL; in il4965_pass_packet_to_mac80211()
606 ieee80211_rx(il->hw, skb); in il4965_pass_packet_to_mac80211()
610 * N_RX_MPDU (HT high-throughput N frames). */
616 struct il_rx_pkt *pkt = rxb_addr(rxb); in il4965_hdl_rx() local
628 * command and cached in il->last_phy_res in il4965_hdl_rx()
633 if (pkt->hdr.cmd == N_RX) { in il4965_hdl_rx()
634 phy_res = (struct il_rx_phy_res *)pkt->u.raw; in il4965_hdl_rx()
636 (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) + in il4965_hdl_rx()
637 phy_res->cfg_phy_cnt); in il4965_hdl_rx()
639 len = le16_to_cpu(phy_res->byte_count); in il4965_hdl_rx()
641 *(__le32 *) (pkt->u.raw + sizeof(*phy_res) + in il4965_hdl_rx()
642 phy_res->cfg_phy_cnt + len); in il4965_hdl_rx()
645 if (!il->_4965.last_phy_res_valid) { in il4965_hdl_rx()
649 phy_res = &il->_4965.last_phy_res; in il4965_hdl_rx()
650 amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; in il4965_hdl_rx()
651 header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); in il4965_hdl_rx()
652 len = le16_to_cpu(amsdu->byte_count); in il4965_hdl_rx()
653 rx_pkt_status = *(__le32 *) (pkt->u.raw + sizeof(*amsdu) + len); in il4965_hdl_rx()
658 if ((unlikely(phy_res->cfg_phy_cnt > 20))) { in il4965_hdl_rx()
660 phy_res->cfg_phy_cnt); in il4965_hdl_rx()
671 rate_n_flags = le32_to_cpu(phy_res->rate_n_flags); in il4965_hdl_rx()
674 rx_status.mactime = le64_to_cpu(phy_res->timestamp); in il4965_hdl_rx()
676 (phy_res-> in il4965_hdl_rx()
680 ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), in il4965_hdl_rx()
690 il->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); in il4965_hdl_rx()
705 * same frame was received on all three RX chains. in il4965_hdl_rx()
708 * new 802.11n radiotap field "RX chains" that is defined in il4965_hdl_rx()
712 (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) >> in il4965_hdl_rx()
716 if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) in il4965_hdl_rx()
729 if (phy_res->phy_flags & RX_RES_PHY_FLAGS_AGG_MSK) { in il4965_hdl_rx()
730 /* We know which subframes of an A-MPDU belong in il4965_hdl_rx()
736 rx_status.ampdu_reference = il->_4965.ampdu_ref; in il4965_hdl_rx()
743 /* Cache phy data (Rx signal strength, etc) for HT frame (N_RX_PHY).
748 struct il_rx_pkt *pkt = rxb_addr(rxb); in il4965_hdl_rx_phy() local
749 il->_4965.last_phy_res_valid = true; in il4965_hdl_rx_phy()
750 il->_4965.ampdu_ref++; in il4965_hdl_rx_phy()
751 memcpy(&il->_4965.last_phy_res, pkt->u.raw, in il4965_hdl_rx_phy()
778 for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { in il4965_get_channels_for_scan()
779 chan = il->scan_request->channels[i]; in il4965_get_channels_for_scan()
781 if (chan->band != band) in il4965_get_channels_for_scan()
784 channel = chan->hw_value; in il4965_get_channels_for_scan()
785 scan_ch->channel = cpu_to_le16(channel); in il4965_get_channels_for_scan()
795 (chan->flags & IEEE80211_CHAN_NO_IR)) in il4965_get_channels_for_scan()
796 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; in il4965_get_channels_for_scan()
798 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; in il4965_get_channels_for_scan()
801 scan_ch->type |= IL_SCAN_PROBE_MASK(n_probes); in il4965_get_channels_for_scan()
803 scan_ch->active_dwell = cpu_to_le16(active_dwell); in il4965_get_channels_for_scan()
804 scan_ch->passive_dwell = cpu_to_le16(passive_dwell); in il4965_get_channels_for_scan()
807 scan_ch->dsp_atten = 110; in il4965_get_channels_for_scan()
811 * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3; in il4965_get_channels_for_scan()
814 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3; in il4965_get_channels_for_scan()
816 scan_ch->tx_gain = ((1 << 5) | (5 << 3)); in il4965_get_channels_for_scan()
819 le32_to_cpu(scan_ch->type), in il4965_get_channels_for_scan()
820 (scan_ch-> in il4965_get_channels_for_scan()
822 (scan_ch-> in il4965_get_channels_for_scan()
840 for (i = 0; i < RATE_ANT_NUM - 1; i++) { in il4965_toggle_tx_ant()
863 u8 rx_ant = il->hw_params.valid_rx_ant; in il4965_request_scan()
868 u8 scan_tx_antennas = il->hw_params.valid_tx_ant; in il4965_request_scan()
871 lockdep_assert_held(&il->mutex); in il4965_request_scan()
873 if (!il->scan_cmd) { in il4965_request_scan()
874 il->scan_cmd = in il4965_request_scan()
877 if (!il->scan_cmd) { in il4965_request_scan()
879 return -ENOMEM; in il4965_request_scan()
882 scan = il->scan_cmd; in il4965_request_scan()
885 scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; in il4965_request_scan()
886 scan->quiet_time = IL_ACTIVE_QUIET_TIME; in il4965_request_scan()
895 interval = vif->bss_conf.beacon_int; in il4965_request_scan()
897 scan->suspend_time = 0; in il4965_request_scan()
898 scan->max_out_time = cpu_to_le32(200 * 1024); in il4965_request_scan()
905 scan->suspend_time = cpu_to_le32(scan_suspend_time); in il4965_request_scan()
910 if (il->scan_request->n_ssids) { in il4965_request_scan()
913 for (i = 0; i < il->scan_request->n_ssids; i++) { in il4965_request_scan()
915 if (!il->scan_request->ssids[i].ssid_len) in il4965_request_scan()
917 scan->direct_scan[p].id = WLAN_EID_SSID; in il4965_request_scan()
918 scan->direct_scan[p].len = in il4965_request_scan()
919 il->scan_request->ssids[i].ssid_len; in il4965_request_scan()
920 memcpy(scan->direct_scan[p].ssid, in il4965_request_scan()
921 il->scan_request->ssids[i].ssid, in il4965_request_scan()
922 il->scan_request->ssids[i].ssid_len); in il4965_request_scan()
930 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; in il4965_request_scan()
931 scan->tx_cmd.sta_id = il->hw_params.bcast_id; in il4965_request_scan()
932 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; in il4965_request_scan()
934 switch (il->scan_band) { in il4965_request_scan()
936 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; in il4965_request_scan()
938 le32_to_cpu(il->active.flags & RXON_FLG_CHANNEL_MODE_MSK) >> in il4965_request_scan()
952 return -EIO; in il4965_request_scan()
967 * sending out probes -- setting this to a huge value will in il4965_request_scan()
972 scan->good_CRC_th = in il4965_request_scan()
975 band = il->scan_band; in il4965_request_scan()
977 if (il->cfg->scan_rx_antennas[band]) in il4965_request_scan()
978 rx_ant = il->cfg->scan_rx_antennas[band]; in il4965_request_scan()
980 il4965_toggle_tx_ant(il, &il->scan_tx_ant[band], scan_tx_antennas); in il4965_request_scan()
981 rate_flags |= BIT(il->scan_tx_ant[band]) << RATE_MCS_ANT_POS; in il4965_request_scan()
982 scan->tx_cmd.rate_n_flags = cpu_to_le32(rate | rate_flags); in il4965_request_scan()
985 if (test_bit(S_POWER_PMI, &il->status)) { in il4965_request_scan()
988 rx_ant & ((u8) (il->chain_noise_data.active_chains)); in il4965_request_scan()
993 il->chain_noise_data.active_chains); in il4965_request_scan()
999 rx_chain |= il->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; in il4965_request_scan()
1003 scan->rx_chain = cpu_to_le16(rx_chain); in il4965_request_scan()
1006 il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, in il4965_request_scan()
1007 vif->addr, il->scan_request->ie, in il4965_request_scan()
1008 il->scan_request->ie_len, in il4965_request_scan()
1009 IL_MAX_SCAN_SIZE - sizeof(*scan)); in il4965_request_scan()
1010 scan->tx_cmd.len = cpu_to_le16(cmd_len); in il4965_request_scan()
1012 scan->filter_flags |= in il4965_request_scan()
1015 scan->channel_count = in il4965_request_scan()
1017 (void *)&scan->data[cmd_len]); in il4965_request_scan()
1018 if (scan->channel_count == 0) { in il4965_request_scan()
1019 D_SCAN("channel count %d\n", scan->channel_count); in il4965_request_scan()
1020 return -EIO; in il4965_request_scan()
1024 le16_to_cpu(scan->tx_cmd.len) + in il4965_request_scan()
1025 scan->channel_count * sizeof(struct il_scan_channel); in il4965_request_scan()
1027 scan->len = cpu_to_le16(cmd.len); in il4965_request_scan()
1029 set_bit(S_SCAN_HW, &il->status); in il4965_request_scan()
1033 clear_bit(S_SCAN_HW, &il->status); in il4965_request_scan()
1042 struct il_vif_priv *vif_priv = (void *)vif->drv_priv; in il4965_manage_ibss_station()
1045 return il4965_add_bssid_station(il, vif->bss_conf.bssid, in il4965_manage_ibss_station()
1046 &vif_priv->ibss_bssid_sta_id); in il4965_manage_ibss_station()
1047 return il_remove_station(il, vif_priv->ibss_bssid_sta_id, in il4965_manage_ibss_station()
1048 vif->bss_conf.bssid); in il4965_manage_ibss_station()
1054 lockdep_assert_held(&il->sta_lock); in il4965_free_tfds_in_queue()
1056 if (il->stations[sta_id].tid[tid].tfds_in_queue >= freed) in il4965_free_tfds_in_queue()
1057 il->stations[sta_id].tid[tid].tfds_in_queue -= freed; in il4965_free_tfds_in_queue()
1060 il->stations[sta_id].tid[tid].tfds_in_queue, freed); in il4965_free_tfds_in_queue()
1061 il->stations[sta_id].tid[tid].tfds_in_queue = 0; in il4965_free_tfds_in_queue()
1070 return il->current_ht_config.smps == IEEE80211_SMPS_STATIC || in il4965_is_single_rx_stream()
1071 il->current_ht_config.single_chain_sufficient; in il4965_is_single_rx_stream()
1092 /* # of Rx chains to use when expecting MIMO. */ in il4965_get_active_rx_chain_count()
1101 * multiplexing power save, use the active count for rx chain count.
1106 /* # Rx chains when idling, depending on SMPS mode */ in il4965_get_idle_rx_chain_count()
1107 switch (il->current_ht_config.smps) { in il4965_get_idle_rx_chain_count()
1114 WARN(1, "invalid SMPS mode %d", il->current_ht_config.smps); in il4965_get_idle_rx_chain_count()
1132 * il4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image
1134 * Selects how many and which Rx receivers/antennas/chains to use.
1141 bool is_cam = !test_bit(S_POWER_PMI, &il->status); in il4965_set_rxon_chain()
1150 if (il->chain_noise_data.active_chains) in il4965_set_rxon_chain()
1151 active_chains = il->chain_noise_data.active_chains; in il4965_set_rxon_chain()
1153 active_chains = il->hw_params.valid_rx_ant; in il4965_set_rxon_chain()
1161 /* correct rx chain count according hw settings in il4965_set_rxon_chain()
1174 il->staging.rx_chain = cpu_to_le16(rx_chain); in il4965_set_rxon_chain()
1177 il->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; in il4965_set_rxon_chain()
1179 il->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; in il4965_set_rxon_chain()
1181 D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", il->staging.rx_chain, in il4965_set_rxon_chain()
1230 return -ENOMEM; in il4965_dump_fh()
1232 scnprintf(*buf + pos, bufsz - pos, "FH register values:\n"); in il4965_dump_fh()
1235 scnprintf(*buf + pos, bufsz - pos, in il4965_dump_fh()
1254 struct il_rx_pkt *pkt = rxb_addr(rxb); in il4965_hdl_missed_beacon() local
1257 missed_beacon = &pkt->u.missed_beacon; in il4965_hdl_missed_beacon()
1258 if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > in il4965_hdl_missed_beacon()
1259 il->missed_beacon_threshold) { in il4965_hdl_missed_beacon()
1261 le32_to_cpu(missed_beacon->consecutive_missed_beacons), in il4965_hdl_missed_beacon()
1262 le32_to_cpu(missed_beacon->total_missed_becons), in il4965_hdl_missed_beacon()
1263 le32_to_cpu(missed_beacon->num_recvd_beacons), in il4965_hdl_missed_beacon()
1264 le32_to_cpu(missed_beacon->num_expected_beacons)); in il4965_hdl_missed_beacon()
1265 if (!test_bit(S_SCANNING, &il->status)) in il4965_hdl_missed_beacon()
1282 rx_info = &(il->_4965.stats.rx.general); in il4965_rx_calc_noise()
1284 le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; in il4965_rx_calc_noise()
1286 le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; in il4965_rx_calc_noise()
1288 le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; in il4965_rx_calc_noise()
1305 last_rx_noise = (total_silence / num_active_rx) - 107; in il4965_rx_calc_noise()
1317 * the case of counters roll-over.
1328 prev_stats = (__le32 *) &il->_4965.stats; in il4965_accumulative_stats()
1329 accum_stats = (u32 *) &il->_4965.accum_stats; in il4965_accumulative_stats()
1331 general = &il->_4965.stats.general.common; in il4965_accumulative_stats()
1332 accum_general = &il->_4965.accum_stats.general.common; in il4965_accumulative_stats()
1333 delta = (u32 *) &il->_4965.delta_stats; in il4965_accumulative_stats()
1334 max_delta = (u32 *) &il->_4965.max_delta; in il4965_accumulative_stats()
1342 (le32_to_cpu(*stats) - le32_to_cpu(*prev_stats)); in il4965_accumulative_stats()
1349 /* reset accumulative stats for "no-counter" type stats */ in il4965_accumulative_stats()
1350 accum_general->temperature = general->temperature; in il4965_accumulative_stats()
1351 accum_general->ttl_timestamp = general->ttl_timestamp; in il4965_accumulative_stats()
1360 struct il_rx_pkt *pkt = rxb_addr(rxb); in il4965_hdl_stats() local
1364 le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); in il4965_hdl_stats()
1367 ((il->_4965.stats.general.common.temperature != in il4965_hdl_stats()
1368 pkt->u.stats.general.common.temperature) || in il4965_hdl_stats()
1369 ((il->_4965.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK) != in il4965_hdl_stats()
1370 (pkt->u.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK))); in il4965_hdl_stats()
1372 il4965_accumulative_stats(il, (__le32 *) &pkt->u.stats); in il4965_hdl_stats()
1376 memcpy(&il->_4965.stats, &pkt->u.stats, sizeof(il->_4965.stats)); in il4965_hdl_stats()
1378 set_bit(S_STATS, &il->status); in il4965_hdl_stats()
1384 mod_timer(&il->stats_periodic, in il4965_hdl_stats()
1387 if (unlikely(!test_bit(S_SCANNING, &il->status)) && in il4965_hdl_stats()
1388 (pkt->hdr.cmd == N_STATS)) { in il4965_hdl_stats()
1390 queue_work(il->workqueue, &il->run_time_calib_work); in il4965_hdl_stats()
1400 struct il_rx_pkt *pkt = rxb_addr(rxb); in il4965_hdl_c_stats() local
1402 if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATS_CLEAR_MSK) { in il4965_hdl_c_stats()
1404 memset(&il->_4965.accum_stats, 0, in il4965_hdl_c_stats()
1406 memset(&il->_4965.delta_stats, 0, in il4965_hdl_c_stats()
1408 memset(&il->_4965.max_delta, 0, sizeof(struct il_notif_stats)); in il4965_hdl_c_stats()
1430 * Regular (not A-MPDU) frames are put into hardware queues corresponding
1431 * to the FIFOs, see comments in iwl-prph.h. Aggregated frames get their
1432 * own queue per aggregation session (RA/TID combination), such queues are
1433 * set up to map into FIFOs too, for which we need an AC->FIFO mapping. In
1434 * order to map frames to the right queue, we also need an AC->hw queue
1438 * 4965.c), the AC->hw queue mapping is the identity
1459 /* no support for TIDs 8-15 yet */ in il4965_get_ac_from_tid()
1460 return -EINVAL; in il4965_get_ac_from_tid()
1476 /* no support for TIDs 8-15 yet */ in il4965_get_fifo_from_tid()
1477 return -EINVAL; in il4965_get_fifo_from_tid()
1489 __le16 fc = hdr->frame_control; in il4965_tx_cmd_build_basic()
1490 __le32 tx_flags = tx_cmd->tx_flags; in il4965_tx_cmd_build_basic()
1492 tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; in il4965_tx_cmd_build_basic()
1493 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { in il4965_tx_cmd_build_basic()
1498 !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) in il4965_tx_cmd_build_basic()
1508 tx_cmd->sta_id = std_id; in il4965_tx_cmd_build_basic()
1514 tx_cmd->tid_tspec = qc[0] & 0xf; in il4965_tx_cmd_build_basic()
1525 tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); in il4965_tx_cmd_build_basic()
1527 tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); in il4965_tx_cmd_build_basic()
1529 tx_cmd->timeout.pm_frame_timeout = 0; in il4965_tx_cmd_build_basic()
1532 tx_cmd->driver_txop = 0; in il4965_tx_cmd_build_basic()
1533 tx_cmd->tx_flags = tx_flags; in il4965_tx_cmd_build_basic()
1534 tx_cmd->next_frame_len = 0; in il4965_tx_cmd_build_basic()
1555 tx_cmd->data_retry_limit = data_retry_limit; in il4965_tx_cmd_build_rate()
1557 tx_cmd->rts_retry_limit = min(data_retry_limit, rts_retry_limit); in il4965_tx_cmd_build_rate()
1562 tx_cmd->initial_rate_idx = 0; in il4965_tx_cmd_build_rate()
1563 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; in il4965_tx_cmd_build_rate()
1573 rate_idx = info->control.rates[0].idx; in il4965_tx_cmd_build_rate()
1574 if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || rate_idx < 0 in il4965_tx_cmd_build_rate()
1576 rate_idx = rate_lowest_index(&il->bands[info->band], sta); in il4965_tx_cmd_build_rate()
1578 if (info->band == NL80211_BAND_5GHZ) in il4965_tx_cmd_build_rate()
1580 /* Get PLCP rate for tx_cmd->rate_n_flags */ in il4965_tx_cmd_build_rate()
1590 il4965_toggle_tx_ant(il, &il->mgmt_tx_ant, il->hw_params.valid_tx_ant); in il4965_tx_cmd_build_rate()
1591 rate_flags |= BIT(il->mgmt_tx_ant) << RATE_MCS_ANT_POS; in il4965_tx_cmd_build_rate()
1594 tx_cmd->rate_n_flags = cpu_to_le32(rate_plcp | rate_flags); in il4965_tx_cmd_build_rate()
1602 struct ieee80211_key_conf *keyconf = info->control.hw_key; in il4965_tx_cmd_build_hwcrypto()
1604 switch (keyconf->cipher) { in il4965_tx_cmd_build_hwcrypto()
1606 tx_cmd->sec_ctl = TX_CMD_SEC_CCM; in il4965_tx_cmd_build_hwcrypto()
1607 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); in il4965_tx_cmd_build_hwcrypto()
1608 if (info->flags & IEEE80211_TX_CTL_AMPDU) in il4965_tx_cmd_build_hwcrypto()
1609 tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; in il4965_tx_cmd_build_hwcrypto()
1614 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; in il4965_tx_cmd_build_hwcrypto()
1615 ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); in il4965_tx_cmd_build_hwcrypto()
1620 tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; in il4965_tx_cmd_build_hwcrypto()
1623 tx_cmd->sec_ctl |= in il4965_tx_cmd_build_hwcrypto()
1624 (TX_CMD_SEC_WEP | (keyconf->keyidx & TX_CMD_SEC_MSK) << in il4965_tx_cmd_build_hwcrypto()
1627 memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); in il4965_tx_cmd_build_hwcrypto()
1630 keyconf->keyidx); in il4965_tx_cmd_build_hwcrypto()
1634 IL_ERR("Unknown encode cipher %x\n", keyconf->cipher); in il4965_tx_cmd_build_hwcrypto()
1647 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in il4965_tx_skb()
1670 spin_lock_irqsave(&il->lock, flags); in il4965_tx_skb()
1672 D_DROP("Dropping - RF KILL\n"); in il4965_tx_skb()
1676 fc = hdr->frame_control; in il4965_tx_skb()
1691 sta_id = il->hw_params.bcast_id; in il4965_tx_skb()
1697 D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); in il4965_tx_skb()
1705 sta_priv = (void *)sta->drv_priv; in il4965_tx_skb()
1707 if (sta_priv && sta_priv->asleep && in il4965_tx_skb()
1708 (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) { in il4965_tx_skb()
1712 * next frame is processed -- and the next frame to in il4965_tx_skb()
1722 WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM); in il4965_tx_skb()
1724 /* Access category (AC) is also the queue number */ in il4965_tx_skb()
1727 /* irqs already disabled/saved above when locking il->lock */ in il4965_tx_skb()
1728 spin_lock(&il->sta_lock); in il4965_tx_skb()
1734 spin_unlock(&il->sta_lock); in il4965_tx_skb()
1737 seq_number = il->stations[sta_id].tid[tid].seq_number; in il4965_tx_skb()
1739 hdr->seq_ctrl = in il4965_tx_skb()
1740 hdr->seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG); in il4965_tx_skb()
1741 hdr->seq_ctrl |= cpu_to_le16(seq_number); in il4965_tx_skb()
1744 if (info->flags & IEEE80211_TX_CTL_AMPDU && in il4965_tx_skb()
1745 il->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { in il4965_tx_skb()
1746 txq_id = il->stations[sta_id].tid[tid].agg.txq_id; in il4965_tx_skb()
1751 txq = &il->txq[txq_id]; in il4965_tx_skb()
1752 q = &txq->q; in il4965_tx_skb()
1754 if (unlikely(il_queue_space(q) < q->high_mark)) { in il4965_tx_skb()
1755 spin_unlock(&il->sta_lock); in il4965_tx_skb()
1760 il->stations[sta_id].tid[tid].tfds_in_queue++; in il4965_tx_skb()
1762 il->stations[sta_id].tid[tid].seq_number = seq_number; in il4965_tx_skb()
1765 spin_unlock(&il->sta_lock); in il4965_tx_skb()
1767 txq->skbs[q->write_ptr] = skb; in il4965_tx_skb()
1769 /* Set up first empty entry in queue's array of Tx/cmd buffers */ in il4965_tx_skb()
1770 out_cmd = txq->cmd[q->write_ptr]; in il4965_tx_skb()
1771 out_meta = &txq->meta[q->write_ptr]; in il4965_tx_skb()
1772 tx_cmd = container_of(&out_cmd->cmd.tx, struct il_tx_cmd, __hdr); in il4965_tx_skb()
1773 memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); in il4965_tx_skb()
1777 * Set up the Tx-command (not MAC!) header. in il4965_tx_skb()
1778 * Store the chosen Tx queue and TFD idx within the sequence field; in il4965_tx_skb()
1780 * locate the frame within the tx queue and do post-tx processing. in il4965_tx_skb()
1782 out_cmd->hdr.cmd = C_TX; in il4965_tx_skb()
1783 out_cmd->hdr.sequence = in il4965_tx_skb()
1785 (QUEUE_TO_SEQ(txq_id) | IDX_TO_SEQ(q->write_ptr))); in il4965_tx_skb()
1788 memcpy(tx_cmd->hdr, hdr, hdr_len); in il4965_tx_skb()
1791 tx_cmd->len = cpu_to_le16((u16) skb->len); in il4965_tx_skb()
1793 if (info->control.hw_key) in il4965_tx_skb()
1802 * Use the first empty entry in this queue's command buffer array in il4965_tx_skb()
1813 /* Tell NIC about any 2-byte padding after MAC header */ in il4965_tx_skb()
1815 tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK; in il4965_tx_skb()
1819 txcmd_phys = dma_map_single(&il->pci_dev->dev, &out_cmd->hdr, firstlen, in il4965_tx_skb()
1821 if (unlikely(dma_mapping_error(&il->pci_dev->dev, txcmd_phys))) in il4965_tx_skb()
1826 secondlen = skb->len - hdr_len; in il4965_tx_skb()
1828 phys_addr = dma_map_single(&il->pci_dev->dev, skb->data + hdr_len, in il4965_tx_skb()
1830 if (unlikely(dma_mapping_error(&il->pci_dev->dev, phys_addr))) in il4965_tx_skb()
1836 il->ops->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0); in il4965_tx_skb()
1840 il->ops->txq_attach_buf_to_tfd(il, txq, phys_addr, secondlen, in il4965_tx_skb()
1843 if (!ieee80211_has_morefrags(hdr->frame_control)) { in il4965_tx_skb()
1844 txq->need_update = 1; in il4965_tx_skb()
1847 txq->need_update = 0; in il4965_tx_skb()
1855 dma_sync_single_for_cpu(&il->pci_dev->dev, txcmd_phys, firstlen, in il4965_tx_skb()
1857 tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); in il4965_tx_skb()
1858 tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); in il4965_tx_skb()
1860 il_update_stats(il, true, fc, skb->len); in il4965_tx_skb()
1862 D_TX("sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); in il4965_tx_skb()
1863 D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); in il4965_tx_skb()
1865 il_print_hex_dump(il, IL_DL_TX, (u8 *) tx_cmd->hdr, hdr_len); in il4965_tx_skb()
1867 /* Set up entry for this TFD in Tx byte-count array */ in il4965_tx_skb()
1868 if (info->flags & IEEE80211_TX_CTL_AMPDU) in il4965_tx_skb()
1869 il->ops->txq_update_byte_cnt_tbl(il, txq, le16_to_cpu(tx_cmd->len)); in il4965_tx_skb()
1871 dma_sync_single_for_device(&il->pci_dev->dev, txcmd_phys, firstlen, in il4965_tx_skb()
1875 q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); in il4965_tx_skb()
1877 spin_unlock_irqrestore(&il->lock, flags); in il4965_tx_skb()
1893 if (sta_priv && sta_priv->client && !is_agg) in il4965_tx_skb()
1894 atomic_inc(&sta_priv->pending_frames); in il4965_tx_skb()
1896 if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { in il4965_tx_skb()
1898 spin_lock_irqsave(&il->lock, flags); in il4965_tx_skb()
1899 txq->need_update = 1; in il4965_tx_skb()
1901 spin_unlock_irqrestore(&il->lock, flags); in il4965_tx_skb()
1910 spin_unlock_irqrestore(&il->lock, flags); in il4965_tx_skb()
1911 return -1; in il4965_tx_skb()
1917 ptr->addr = dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, in il4965_alloc_dma_ptr()
1919 if (!ptr->addr) in il4965_alloc_dma_ptr()
1920 return -ENOMEM; in il4965_alloc_dma_ptr()
1921 ptr->size = size; in il4965_alloc_dma_ptr()
1928 if (unlikely(!ptr->addr)) in il4965_free_dma_ptr()
1931 dma_free_coherent(&il->pci_dev->dev, ptr->size, ptr->addr, ptr->dma); in il4965_free_dma_ptr()
1936 * il4965_hw_txq_ctx_free - Free TXQ Context
1946 if (il->txq) { in il4965_hw_txq_ctx_free()
1947 for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) in il4965_hw_txq_ctx_free()
1948 if (txq_id == il->cmd_queue) in il4965_hw_txq_ctx_free()
1953 il4965_free_dma_ptr(il, &il->kw); in il4965_hw_txq_ctx_free()
1955 il4965_free_dma_ptr(il, &il->scd_bc_tbls); in il4965_hw_txq_ctx_free()
1957 /* free tx queue structure */ in il4965_hw_txq_ctx_free()
1962 * il4965_txq_ctx_alloc - allocate TX queue context
1971 /* Free all tx/cmd queues and keep-warm buffer */ in il4965_txq_ctx_alloc()
1975 il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, in il4965_txq_ctx_alloc()
1976 il->hw_params.scd_bc_tbls_size); in il4965_txq_ctx_alloc()
1981 /* Alloc keep-warm buffer */ in il4965_txq_ctx_alloc()
1982 ret = il4965_alloc_dma_ptr(il, &il->kw, IL_KW_SIZE); in il4965_txq_ctx_alloc()
1988 /* allocate tx queue structure */ in il4965_txq_ctx_alloc()
1993 spin_lock_irqsave(&il->lock, flags); in il4965_txq_ctx_alloc()
1999 il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4); in il4965_txq_ctx_alloc()
2001 spin_unlock_irqrestore(&il->lock, flags); in il4965_txq_ctx_alloc()
2003 /* Alloc and init all Tx queues, including the command queue (#4/#9) */ in il4965_txq_ctx_alloc()
2004 for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { in il4965_txq_ctx_alloc()
2007 IL_ERR("Tx %d queue init failed\n", txq_id); in il4965_txq_ctx_alloc()
2016 il4965_free_dma_ptr(il, &il->kw); in il4965_txq_ctx_alloc()
2018 il4965_free_dma_ptr(il, &il->scd_bc_tbls); in il4965_txq_ctx_alloc()
2029 spin_lock_irqsave(&il->lock, flags); in il4965_txq_ctx_reset()
2034 il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4); in il4965_txq_ctx_reset()
2036 spin_unlock_irqrestore(&il->lock, flags); in il4965_txq_ctx_reset()
2038 /* Alloc and init all Tx queues, including the command queue (#4) */ in il4965_txq_ctx_reset()
2039 for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) in il4965_txq_ctx_reset()
2048 if (!il->txq) in il4965_txq_ctx_unmap()
2052 for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) in il4965_txq_ctx_unmap()
2053 if (txq_id == il->cmd_queue) in il4965_txq_ctx_unmap()
2060 * il4965_txq_ctx_stop - Stop all Tx DMA channels
2070 for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { in il4965_txq_ctx_stop()
2084 * Find first available (lowest unused) Tx Queue, mark it "active".
2085 * Called only when finding queue for aggregation.
2087 * be in use as EDCA AC (0-3), Command (4), reserved (5, 6)
2094 for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) in il4965_txq_ctx_activate_free()
2095 if (!test_and_set_bit(txq_id, &il->txq_ctx_active_msk)) in il4965_txq_ctx_activate_free()
2097 return -1; in il4965_txq_ctx_activate_free()
2101 * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration
2106 /* Simply stop the queue, but don't change any configuration; in il4965_tx_queue_stop_scheduler()
2107 * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ in il4965_tx_queue_stop_scheduler()
2114 * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue
2126 il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); in il4965_tx_queue_set_q2ratid()
2141 * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue
2156 il->cfg->num_of_ampdu_queues <= txq_id)) { in il4965_txq_agg_enable()
2157 IL_WARN("queue number out of range: %d, must be %d to %d\n", in il4965_txq_agg_enable()
2160 il->cfg->num_of_ampdu_queues - 1); in il4965_txq_agg_enable()
2161 return -EINVAL; in il4965_txq_agg_enable()
2171 spin_lock_irqsave(&il->lock, flags); in il4965_txq_agg_enable()
2173 /* Stop this Tx queue before configuring it */ in il4965_txq_agg_enable()
2176 /* Map receiver-address / traffic-ID to this queue */ in il4965_txq_agg_enable()
2179 /* Set this queue as a chain-building queue */ in il4965_txq_agg_enable()
2184 il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); in il4965_txq_agg_enable()
2185 il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); in il4965_txq_agg_enable()
2188 /* Set up Tx win size and frame limit for this queue */ in il4965_txq_agg_enable()
2190 il->scd_base_addr + in il4965_txq_agg_enable()
2196 il->scd_base_addr + in il4965_txq_agg_enable()
2204 /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ in il4965_txq_agg_enable()
2205 il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 1); in il4965_txq_agg_enable()
2207 spin_unlock_irqrestore(&il->lock, flags); in il4965_txq_agg_enable()
2228 D_HT("%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); in il4965_tx_agg_start()
2233 return -ENXIO; in il4965_tx_agg_start()
2236 return -EINVAL; in il4965_tx_agg_start()
2238 if (il->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { in il4965_tx_agg_start()
2240 return -ENXIO; in il4965_tx_agg_start()
2244 if (txq_id == -1) { in il4965_tx_agg_start()
2245 IL_ERR("No free aggregation queue available\n"); in il4965_tx_agg_start()
2246 return -ENXIO; in il4965_tx_agg_start()
2249 spin_lock_irqsave(&il->sta_lock, flags); in il4965_tx_agg_start()
2250 tid_data = &il->stations[sta_id].tid[tid]; in il4965_tx_agg_start()
2251 *ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); in il4965_tx_agg_start()
2252 tid_data->agg.txq_id = txq_id; in il4965_tx_agg_start()
2253 il_set_swq_id(&il->txq[txq_id], il4965_get_ac_from_tid(tid), txq_id); in il4965_tx_agg_start()
2254 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_tx_agg_start()
2260 spin_lock_irqsave(&il->sta_lock, flags); in il4965_tx_agg_start()
2261 tid_data = &il->stations[sta_id].tid[tid]; in il4965_tx_agg_start()
2262 if (tid_data->tfds_in_queue == 0) { in il4965_tx_agg_start()
2263 D_HT("HW queue is empty\n"); in il4965_tx_agg_start()
2264 tid_data->agg.state = IL_AGG_ON; in il4965_tx_agg_start()
2267 D_HT("HW queue is NOT empty: %d packets in HW queue\n", in il4965_tx_agg_start()
2268 tid_data->tfds_in_queue); in il4965_tx_agg_start()
2269 tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; in il4965_tx_agg_start()
2271 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_tx_agg_start()
2277 * il->lock must be held by the caller
2284 il->cfg->num_of_ampdu_queues <= txq_id)) { in il4965_txq_agg_disable()
2285 IL_WARN("queue number out of range: %d, must be %d to %d\n", in il4965_txq_agg_disable()
2288 il->cfg->num_of_ampdu_queues - 1); in il4965_txq_agg_disable()
2289 return -EINVAL; in il4965_txq_agg_disable()
2296 il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); in il4965_txq_agg_disable()
2297 il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); in il4965_txq_agg_disable()
2303 il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); in il4965_txq_agg_disable()
2326 return -ENXIO; in il4965_tx_agg_stop()
2329 spin_lock_irqsave(&il->sta_lock, flags); in il4965_tx_agg_stop()
2331 tid_data = &il->stations[sta_id].tid[tid]; in il4965_tx_agg_stop()
2332 ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; in il4965_tx_agg_stop()
2333 txq_id = tid_data->agg.txq_id; in il4965_tx_agg_stop()
2335 switch (il->stations[sta_id].tid[tid].agg.state) { in il4965_tx_agg_stop()
2340 * queue we selected previously, i.e. before the in il4965_tx_agg_stop()
2351 write_ptr = il->txq[txq_id].q.write_ptr; in il4965_tx_agg_stop()
2352 read_ptr = il->txq[txq_id].q.read_ptr; in il4965_tx_agg_stop()
2354 /* The queue is not empty */ in il4965_tx_agg_stop()
2356 D_HT("Stopping a non empty AGG HW QUEUE\n"); in il4965_tx_agg_stop()
2357 il->stations[sta_id].tid[tid].agg.state = in il4965_tx_agg_stop()
2359 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_tx_agg_stop()
2363 D_HT("HW queue is empty\n"); in il4965_tx_agg_stop()
2365 il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; in il4965_tx_agg_stop()
2368 spin_unlock(&il->sta_lock); in il4965_tx_agg_stop()
2369 spin_lock(&il->lock); in il4965_tx_agg_stop()
2372 * the only reason this call can fail is queue number out of range, in il4965_tx_agg_stop()
2375 * to deactivate the uCode queue, just return "success" to allow in il4965_tx_agg_stop()
2379 spin_unlock_irqrestore(&il->lock, flags); in il4965_tx_agg_stop()
2381 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in il4965_tx_agg_stop()
2389 struct il_queue *q = &il->txq[txq_id].q; in il4965_txq_check_empty()
2390 u8 *addr = il->stations[sta_id].sta.sta.addr; in il4965_txq_check_empty()
2391 struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid]; in il4965_txq_check_empty()
2393 lockdep_assert_held(&il->sta_lock); in il4965_txq_check_empty()
2395 switch (il->stations[sta_id].tid[tid].agg.state) { in il4965_txq_check_empty()
2398 /* aggregated HW queue */ in il4965_txq_check_empty()
2399 if (txq_id == tid_data->agg.txq_id && in il4965_txq_check_empty()
2400 q->read_ptr == q->write_ptr) { in il4965_txq_check_empty()
2401 u16 ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); in il4965_txq_check_empty()
2403 D_HT("HW queue empty: continue DELBA flow\n"); in il4965_txq_check_empty()
2405 tid_data->agg.state = IL_AGG_OFF; in il4965_txq_check_empty()
2406 ieee80211_stop_tx_ba_cb_irqsafe(il->vif, addr, tid); in il4965_txq_check_empty()
2410 /* We are reclaiming the last packet of the queue */ in il4965_txq_check_empty()
2411 if (tid_data->tfds_in_queue == 0) { in il4965_txq_check_empty()
2412 D_HT("HW queue empty: continue ADDBA flow\n"); in il4965_txq_check_empty()
2413 tid_data->agg.state = IL_AGG_ON; in il4965_txq_check_empty()
2414 ieee80211_start_tx_ba_cb_irqsafe(il->vif, addr, tid); in il4965_txq_check_empty()
2429 sta = ieee80211_find_sta(il->vif, addr1); in il4965_non_agg_tx_status()
2431 sta_priv = (void *)sta->drv_priv; in il4965_non_agg_tx_status()
2433 if (sta_priv->client && in il4965_non_agg_tx_status()
2434 atomic_dec_return(&sta_priv->pending_frames) == 0) in il4965_non_agg_tx_status()
2435 ieee80211_sta_block_awake(il->hw, sta, false); in il4965_non_agg_tx_status()
2443 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in il4965_tx_status()
2446 il4965_non_agg_tx_status(il, hdr->addr1); in il4965_tx_status()
2448 ieee80211_tx_status_irqsafe(il->hw, skb); in il4965_tx_status()
2454 struct il_tx_queue *txq = &il->txq[txq_id]; in il4965_tx_queue_reclaim()
2455 struct il_queue *q = &txq->q; in il4965_tx_queue_reclaim()
2460 if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { in il4965_tx_queue_reclaim()
2461 IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " in il4965_tx_queue_reclaim()
2462 "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, in il4965_tx_queue_reclaim()
2463 q->write_ptr, q->read_ptr); in il4965_tx_queue_reclaim()
2467 for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; in il4965_tx_queue_reclaim()
2468 q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { in il4965_tx_queue_reclaim()
2470 skb = txq->skbs[txq->q.read_ptr]; in il4965_tx_queue_reclaim()
2475 hdr = (struct ieee80211_hdr *) skb->data; in il4965_tx_queue_reclaim()
2476 if (ieee80211_is_data_qos(hdr->frame_control)) in il4965_tx_queue_reclaim()
2481 txq->skbs[txq->q.read_ptr] = NULL; in il4965_tx_queue_reclaim()
2482 il->ops->txq_free_tfd(il, txq); in il4965_tx_queue_reclaim()
2488 * il4965_tx_status_reply_compressed_ba - Update tx status from block-ack
2490 * Go through block-ack's bitmap of ACK'd frames, update driver's record of
2498 u16 seq_ctl = le16_to_cpu(ba_resp->seq_ctl); in il4965_tx_status_reply_compressed_ba()
2499 u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); in il4965_tx_status_reply_compressed_ba()
2504 if (unlikely(!agg->wait_for_ba)) { in il4965_tx_status_reply_compressed_ba()
2505 if (unlikely(ba_resp->bitmap)) in il4965_tx_status_reply_compressed_ba()
2507 return -EINVAL; in il4965_tx_status_reply_compressed_ba()
2510 /* Mark that the expected block-ack response arrived */ in il4965_tx_status_reply_compressed_ba()
2511 agg->wait_for_ba = 0; in il4965_tx_status_reply_compressed_ba()
2512 D_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); in il4965_tx_status_reply_compressed_ba()
2514 /* Calculate shift to align block-ack bits with our Tx win bits */ in il4965_tx_status_reply_compressed_ba()
2515 sh = agg->start_idx - SEQ_TO_IDX(seq_ctl >> 4); in il4965_tx_status_reply_compressed_ba()
2519 if (agg->frame_count > (64 - sh)) { in il4965_tx_status_reply_compressed_ba()
2521 return -1; in il4965_tx_status_reply_compressed_ba()
2524 /* don't use 64-bit values for now */ in il4965_tx_status_reply_compressed_ba()
2525 bitmap = le64_to_cpu(ba_resp->bitmap) >> sh; in il4965_tx_status_reply_compressed_ba()
2528 * transmitted bitmap and block-ack bitmap */ in il4965_tx_status_reply_compressed_ba()
2529 sent_bitmap = bitmap & agg->bitmap; in il4965_tx_status_reply_compressed_ba()
2538 i, (agg->start_idx + i) & 0xff, agg->start_idx + i); in il4965_tx_status_reply_compressed_ba()
2545 info = IEEE80211_SKB_CB(il->txq[scd_flow].skbs[agg->start_idx]); in il4965_tx_status_reply_compressed_ba()
2546 memset(&info->status, 0, sizeof(info->status)); in il4965_tx_status_reply_compressed_ba()
2547 info->flags |= IEEE80211_TX_STAT_ACK; in il4965_tx_status_reply_compressed_ba()
2548 info->flags |= IEEE80211_TX_STAT_AMPDU; in il4965_tx_status_reply_compressed_ba()
2549 info->status.ampdu_ack_len = successes; in il4965_tx_status_reply_compressed_ba()
2550 info->status.ampdu_len = agg->frame_count; in il4965_tx_status_reply_compressed_ba()
2551 il4965_hwrate_to_tx_control(il, agg->rate_n_flags, info); in il4965_tx_status_reply_compressed_ba()
2571 if (il->iw_mode == NL80211_IFTYPE_ADHOC) in il4965_find_station()
2575 return il->hw_params.bcast_id; in il4965_find_station()
2577 spin_lock_irqsave(&il->sta_lock, flags); in il4965_find_station()
2578 for (i = start; i < il->hw_params.max_stations; i++) in il4965_find_station()
2579 if (il->stations[i].used && in il4965_find_station()
2580 ether_addr_equal(il->stations[i].sta.sta.addr, addr)) { in il4965_find_station()
2585 D_ASSOC("can not find STA %pM total %d\n", addr, il->num_stations); in il4965_find_station()
2594 (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || in il4965_find_station()
2595 (il->stations[ret].used & IL_STA_UCODE_INPROGRESS))) { in il4965_find_station()
2600 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_find_station()
2607 if (il->iw_mode == NL80211_IFTYPE_STATION) in il4965_get_ra_sta_id()
2619 return le32_to_cpup(&tx_resp->u.status + in il4965_get_scd_ssn()
2620 tx_resp->frame_count) & IEEE80211_MAX_SN; in il4965_get_scd_ssn()
2640 * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue
2648 struct agg_tx_status *frame_status = tx_resp->u.agg_status; in il4965_tx_status_reply_tx()
2651 u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); in il4965_tx_status_reply_tx()
2654 if (agg->wait_for_ba) in il4965_tx_status_reply_tx()
2655 D_TX_REPLY("got tx response w/o block-ack\n"); in il4965_tx_status_reply_tx()
2657 agg->frame_count = tx_resp->frame_count; in il4965_tx_status_reply_tx()
2658 agg->start_idx = start_idx; in il4965_tx_status_reply_tx()
2659 agg->rate_n_flags = rate_n_flags; in il4965_tx_status_reply_tx()
2660 agg->bitmap = 0; in il4965_tx_status_reply_tx()
2663 if (agg->frame_count == 1) { in il4965_tx_status_reply_tx()
2664 /* Only one frame was attempted; no block-ack will arrive */ in il4965_tx_status_reply_tx()
2669 agg->frame_count, agg->start_idx, idx); in il4965_tx_status_reply_tx()
2671 info = IEEE80211_SKB_CB(il->txq[txq_id].skbs[idx]); in il4965_tx_status_reply_tx()
2672 info->status.rates[0].count = tx_resp->failure_frame + 1; in il4965_tx_status_reply_tx()
2673 info->flags &= ~IEEE80211_TX_CTL_AMPDU; in il4965_tx_status_reply_tx()
2674 info->flags |= il4965_tx_status_to_mac80211(status); in il4965_tx_status_reply_tx()
2678 tx_resp->failure_frame); in il4965_tx_status_reply_tx()
2681 agg->wait_for_ba = 0; in il4965_tx_status_reply_tx()
2683 /* Two or more frames were attempted; expect block-ack */ in il4965_tx_status_reply_tx()
2685 int start = agg->start_idx; in il4965_tx_status_reply_tx()
2688 /* Construct bit-map of pending frames within Tx win */ in il4965_tx_status_reply_tx()
2689 for (i = 0; i < agg->frame_count; i++) { in il4965_tx_status_reply_tx()
2702 agg->frame_count, txq_id, idx); in il4965_tx_status_reply_tx()
2704 skb = il->txq[txq_id].skbs[idx]; in il4965_tx_status_reply_tx()
2706 return -1; in il4965_tx_status_reply_tx()
2707 hdr = (struct ieee80211_hdr *) skb->data; in il4965_tx_status_reply_tx()
2709 sc = le16_to_cpu(hdr->seq_ctrl); in il4965_tx_status_reply_tx()
2713 IEEE80211_SEQ_TO_SN(sc), hdr->seq_ctrl); in il4965_tx_status_reply_tx()
2714 return -1; in il4965_tx_status_reply_tx()
2720 sh = idx - start; in il4965_tx_status_reply_tx()
2722 sh = (start - idx) + 0xff; in il4965_tx_status_reply_tx()
2726 } else if (sh < -64) in il4965_tx_status_reply_tx()
2727 sh = 0xff - (start - idx); in il4965_tx_status_reply_tx()
2729 sh = start - idx; in il4965_tx_status_reply_tx()
2739 agg->bitmap = bitmap; in il4965_tx_status_reply_tx()
2740 agg->start_idx = start; in il4965_tx_status_reply_tx()
2742 agg->frame_count, agg->start_idx, in il4965_tx_status_reply_tx()
2743 (unsigned long long)agg->bitmap); in il4965_tx_status_reply_tx()
2746 agg->wait_for_ba = 1; in il4965_tx_status_reply_tx()
2752 * il4965_hdl_tx - Handle standard (non-aggregation) Tx response
2757 struct il_rx_pkt *pkt = rxb_addr(rxb); in il4965_hdl_tx() local
2758 u16 sequence = le16_to_cpu(pkt->hdr.sequence); in il4965_hdl_tx()
2761 struct il_tx_queue *txq = &il->txq[txq_id]; in il4965_hdl_tx()
2765 struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; in il4965_hdl_tx()
2766 u32 status = le32_to_cpu(tx_resp->u.status); in il4965_hdl_tx()
2773 if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { in il4965_hdl_tx()
2774 IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " in il4965_hdl_tx()
2775 "is out of range [0-%d] %d %d\n", txq_id, idx, in il4965_hdl_tx()
2776 txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); in il4965_hdl_tx()
2780 txq->time_stamp = jiffies; in il4965_hdl_tx()
2782 skb = txq->skbs[txq->q.read_ptr]; in il4965_hdl_tx()
2784 memset(&info->status, 0, sizeof(info->status)); in il4965_hdl_tx()
2786 hdr = (struct ieee80211_hdr *) skb->data; in il4965_hdl_tx()
2787 if (ieee80211_is_data_qos(hdr->frame_control)) { in il4965_hdl_tx()
2793 if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { in il4965_hdl_tx()
2806 il->iw_mode == NL80211_IFTYPE_STATION) { in il4965_hdl_tx()
2808 D_INFO("Stopped queues - RX waiting on passive channel\n"); in il4965_hdl_tx()
2811 spin_lock_irqsave(&il->sta_lock, flags); in il4965_hdl_tx()
2812 if (txq->sched_retry) { in il4965_hdl_tx()
2819 agg = &il->stations[sta_id].tid[tid].agg; in il4965_hdl_tx()
2824 if (tx_resp->frame_count == 1 && in il4965_hdl_tx()
2826 info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; in il4965_hdl_tx()
2828 if (txq->q.read_ptr != (scd_ssn & 0xff)) { in il4965_hdl_tx()
2829 idx = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); in il4965_hdl_tx()
2835 if (il->mac80211_registered && in il4965_hdl_tx()
2836 il_queue_space(&txq->q) > txq->q.low_mark && in il4965_hdl_tx()
2837 agg->state != IL_EMPTYING_HW_QUEUE_DELBA) in il4965_hdl_tx()
2841 info->status.rates[0].count = tx_resp->failure_frame + 1; in il4965_hdl_tx()
2842 info->flags |= il4965_tx_status_to_mac80211(status); in il4965_hdl_tx()
2844 le32_to_cpu(tx_resp->rate_n_flags), in il4965_hdl_tx()
2850 le32_to_cpu(tx_resp->rate_n_flags), in il4965_hdl_tx()
2851 tx_resp->failure_frame); in il4965_hdl_tx()
2859 if (il->mac80211_registered && in il4965_hdl_tx()
2860 il_queue_space(&txq->q) > txq->q.low_mark) in il4965_hdl_tx()
2867 il4965_check_abort_status(il, tx_resp->frame_count, status); in il4965_hdl_tx()
2869 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_hdl_tx()
2879 struct ieee80211_tx_rate *r = &info->status.rates[0]; in il4965_hwrate_to_tx_control()
2881 info->status.antenna = in il4965_hwrate_to_tx_control()
2884 r->flags |= IEEE80211_TX_RC_MCS; in il4965_hwrate_to_tx_control()
2886 r->flags |= IEEE80211_TX_RC_GREEN_FIELD; in il4965_hwrate_to_tx_control()
2888 r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; in il4965_hwrate_to_tx_control()
2890 r->flags |= IEEE80211_TX_RC_DUP_DATA; in il4965_hwrate_to_tx_control()
2892 r->flags |= IEEE80211_TX_RC_SHORT_GI; in il4965_hwrate_to_tx_control()
2893 r->idx = il4965_hwrate_to_mac80211_idx(rate_n_flags, info->band); in il4965_hwrate_to_tx_control()
2897 * il4965_hdl_compressed_ba - Handler for N_COMPRESSED_BA
2899 * Handles block-acknowledge notification from device, which reports success
2905 struct il_rx_pkt *pkt = rxb_addr(rxb); in il4965_hdl_compressed_ba() local
2906 struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; in il4965_hdl_compressed_ba()
2914 /* "flow" corresponds to Tx queue */ in il4965_hdl_compressed_ba()
2915 u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); in il4965_hdl_compressed_ba()
2917 /* "ssn" is start of block-ack Tx win, corresponds to idx in il4965_hdl_compressed_ba()
2918 * (in Tx queue's circular buffer) of first TFD/frame in win */ in il4965_hdl_compressed_ba()
2919 u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); in il4965_hdl_compressed_ba()
2921 if (scd_flow >= il->hw_params.max_txq_num) { in il4965_hdl_compressed_ba()
2926 txq = &il->txq[scd_flow]; in il4965_hdl_compressed_ba()
2927 sta_id = ba_resp->sta_id; in il4965_hdl_compressed_ba()
2928 tid = ba_resp->tid; in il4965_hdl_compressed_ba()
2929 agg = &il->stations[sta_id].tid[tid].agg; in il4965_hdl_compressed_ba()
2930 if (unlikely(agg->txq_id != scd_flow)) { in il4965_hdl_compressed_ba()
2938 scd_flow, agg->txq_id); in il4965_hdl_compressed_ba()
2942 /* Find idx just before block-ack win */ in il4965_hdl_compressed_ba()
2943 idx = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); in il4965_hdl_compressed_ba()
2945 spin_lock_irqsave(&il->sta_lock, flags); in il4965_hdl_compressed_ba()
2948 agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, in il4965_hdl_compressed_ba()
2949 ba_resp->sta_id); in il4965_hdl_compressed_ba()
2951 "%d, scd_ssn = %d\n", ba_resp->tid, ba_resp->seq_ctl, in il4965_hdl_compressed_ba()
2952 (unsigned long long)le64_to_cpu(ba_resp->bitmap), in il4965_hdl_compressed_ba()
2953 ba_resp->scd_flow, ba_resp->scd_ssn); in il4965_hdl_compressed_ba()
2954 D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", agg->start_idx, in il4965_hdl_compressed_ba()
2955 (unsigned long long)agg->bitmap); in il4965_hdl_compressed_ba()
2961 * block-ack win (we assume that they've been successfully in il4965_hdl_compressed_ba()
2963 if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { in il4965_hdl_compressed_ba()
2964 /* calculate mac80211 ampdu sw queue to wake */ in il4965_hdl_compressed_ba()
2968 if (il_queue_space(&txq->q) > txq->q.low_mark && in il4965_hdl_compressed_ba()
2969 il->mac80211_registered && in il4965_hdl_compressed_ba()
2970 agg->state != IL_EMPTYING_HW_QUEUE_DELBA) in il4965_hdl_compressed_ba()
2976 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_hdl_compressed_ba()
3034 if (il->band == NL80211_BAND_5GHZ) in il4965_sta_alloc_lq()
3043 il4965_first_antenna(il->hw_params. in il4965_sta_alloc_lq()
3047 link_cmd->rs_table[i].rate_n_flags = rate_n_flags; in il4965_sta_alloc_lq()
3049 link_cmd->general_params.single_stream_ant_msk = in il4965_sta_alloc_lq()
3050 il4965_first_antenna(il->hw_params.valid_tx_ant); in il4965_sta_alloc_lq()
3052 link_cmd->general_params.dual_stream_ant_msk = in il4965_sta_alloc_lq()
3053 il->hw_params.valid_tx_ant & ~il4965_first_antenna(il->hw_params. in il4965_sta_alloc_lq()
3055 if (!link_cmd->general_params.dual_stream_ant_msk) { in il4965_sta_alloc_lq()
3056 link_cmd->general_params.dual_stream_ant_msk = ANT_AB; in il4965_sta_alloc_lq()
3057 } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { in il4965_sta_alloc_lq()
3058 link_cmd->general_params.dual_stream_ant_msk = in il4965_sta_alloc_lq()
3059 il->hw_params.valid_tx_ant; in il4965_sta_alloc_lq()
3062 link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; in il4965_sta_alloc_lq()
3063 link_cmd->agg_params.agg_time_limit = in il4965_sta_alloc_lq()
3066 link_cmd->sta_id = sta_id; in il4965_sta_alloc_lq()
3072 * il4965_add_bssid_station - Add the special IBSS BSSID station
3096 spin_lock_irqsave(&il->sta_lock, flags); in il4965_add_bssid_station()
3097 il->stations[sta_id].used |= IL_STA_LOCAL; in il4965_add_bssid_station()
3098 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_add_bssid_station()
3105 return -ENOMEM; in il4965_add_bssid_station()
3112 spin_lock_irqsave(&il->sta_lock, flags); in il4965_add_bssid_station()
3113 il->stations[sta_id].lq = link_cmd; in il4965_add_bssid_station()
3114 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_add_bssid_station()
3140 u8 key_size = il->_4965.wep_keys[i].key_size; in il4965_static_wepkey_cmd()
3142 wep_cmd->key[i].key_idx = i; in il4965_static_wepkey_cmd()
3144 wep_cmd->key[i].key_offset = i; in il4965_static_wepkey_cmd()
3147 wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; in il4965_static_wepkey_cmd()
3149 wep_cmd->key[i].key_size = key_size; in il4965_static_wepkey_cmd()
3150 memcpy(&wep_cmd->key[i].key[3], il->_4965.wep_keys[i].key, key_size); in il4965_static_wepkey_cmd()
3153 wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; in il4965_static_wepkey_cmd()
3154 wep_cmd->num_keys = WEP_KEYS_MAX; in il4965_static_wepkey_cmd()
3168 lockdep_assert_held(&il->mutex); in il4965_restore_default_wep_keys()
3178 int idx = keyconf->keyidx; in il4965_remove_default_wep_key()
3180 lockdep_assert_held(&il->mutex); in il4965_remove_default_wep_key()
3184 memset(&il->_4965.wep_keys[idx], 0, sizeof(struct il_wep_key)); in il4965_remove_default_wep_key()
3201 int len = keyconf->keylen; in il4965_set_default_wep_key()
3202 int idx = keyconf->keyidx; in il4965_set_default_wep_key()
3204 lockdep_assert_held(&il->mutex); in il4965_set_default_wep_key()
3207 D_WEP("Bad WEP key length %d\n", keyconf->keylen); in il4965_set_default_wep_key()
3208 return -EINVAL; in il4965_set_default_wep_key()
3211 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; in il4965_set_default_wep_key()
3212 keyconf->hw_key_idx = HW_KEY_DEFAULT; in il4965_set_default_wep_key()
3213 il->stations[IL_AP_ID].keyinfo.cipher = keyconf->cipher; in il4965_set_default_wep_key()
3215 il->_4965.wep_keys[idx].key_size = len; in il4965_set_default_wep_key()
3216 memcpy(&il->_4965.wep_keys[idx].key, &keyconf->key, len); in il4965_set_default_wep_key()
3232 lockdep_assert_held(&il->mutex); in il4965_set_wep_dynamic_key_info()
3234 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; in il4965_set_wep_dynamic_key_info()
3237 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); in il4965_set_wep_dynamic_key_info()
3240 if (keyconf->keylen == WEP_KEY_LEN_128) in il4965_set_wep_dynamic_key_info()
3243 if (sta_id == il->hw_params.bcast_id) in il4965_set_wep_dynamic_key_info()
3246 spin_lock_irqsave(&il->sta_lock, flags); in il4965_set_wep_dynamic_key_info()
3248 il->stations[sta_id].keyinfo.cipher = keyconf->cipher; in il4965_set_wep_dynamic_key_info()
3249 il->stations[sta_id].keyinfo.keylen = keyconf->keylen; in il4965_set_wep_dynamic_key_info()
3250 il->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; in il4965_set_wep_dynamic_key_info()
3252 memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); in il4965_set_wep_dynamic_key_info()
3254 memcpy(&il->stations[sta_id].sta.key.key[3], keyconf->key, in il4965_set_wep_dynamic_key_info()
3255 keyconf->keylen); in il4965_set_wep_dynamic_key_info()
3257 if ((il->stations[sta_id].sta.key. in il4965_set_wep_dynamic_key_info()
3259 il->stations[sta_id].sta.key.key_offset = in il4965_set_wep_dynamic_key_info()
3264 WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, in il4965_set_wep_dynamic_key_info()
3267 il->stations[sta_id].sta.key.key_flags = key_flags; in il4965_set_wep_dynamic_key_info()
3268 il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; in il4965_set_wep_dynamic_key_info()
3269 il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; in il4965_set_wep_dynamic_key_info()
3271 memcpy(&sta_cmd, &il->stations[sta_id].sta, in il4965_set_wep_dynamic_key_info()
3273 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_set_wep_dynamic_key_info()
3286 lockdep_assert_held(&il->mutex); in il4965_set_ccmp_dynamic_key_info()
3289 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); in il4965_set_ccmp_dynamic_key_info()
3292 if (sta_id == il->hw_params.bcast_id) in il4965_set_ccmp_dynamic_key_info()
3295 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; in il4965_set_ccmp_dynamic_key_info()
3297 spin_lock_irqsave(&il->sta_lock, flags); in il4965_set_ccmp_dynamic_key_info()
3298 il->stations[sta_id].keyinfo.cipher = keyconf->cipher; in il4965_set_ccmp_dynamic_key_info()
3299 il->stations[sta_id].keyinfo.keylen = keyconf->keylen; in il4965_set_ccmp_dynamic_key_info()
3301 memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); in il4965_set_ccmp_dynamic_key_info()
3303 memcpy(il->stations[sta_id].sta.key.key, keyconf->key, keyconf->keylen); in il4965_set_ccmp_dynamic_key_info()
3305 if ((il->stations[sta_id].sta.key. in il4965_set_ccmp_dynamic_key_info()
3307 il->stations[sta_id].sta.key.key_offset = in il4965_set_ccmp_dynamic_key_info()
3312 WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, in il4965_set_ccmp_dynamic_key_info()
3315 il->stations[sta_id].sta.key.key_flags = key_flags; in il4965_set_ccmp_dynamic_key_info()
3316 il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; in il4965_set_ccmp_dynamic_key_info()
3317 il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; in il4965_set_ccmp_dynamic_key_info()
3319 memcpy(&sta_cmd, &il->stations[sta_id].sta, in il4965_set_ccmp_dynamic_key_info()
3321 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_set_ccmp_dynamic_key_info()
3334 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); in il4965_set_tkip_dynamic_key_info()
3337 if (sta_id == il->hw_params.bcast_id) in il4965_set_tkip_dynamic_key_info()
3340 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; in il4965_set_tkip_dynamic_key_info()
3341 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; in il4965_set_tkip_dynamic_key_info()
3343 spin_lock_irqsave(&il->sta_lock, flags); in il4965_set_tkip_dynamic_key_info()
3345 il->stations[sta_id].keyinfo.cipher = keyconf->cipher; in il4965_set_tkip_dynamic_key_info()
3346 il->stations[sta_id].keyinfo.keylen = 16; in il4965_set_tkip_dynamic_key_info()
3348 if ((il->stations[sta_id].sta.key. in il4965_set_tkip_dynamic_key_info()
3350 il->stations[sta_id].sta.key.key_offset = in il4965_set_tkip_dynamic_key_info()
3355 WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, in il4965_set_tkip_dynamic_key_info()
3358 il->stations[sta_id].sta.key.key_flags = key_flags; in il4965_set_tkip_dynamic_key_info()
3361 memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, 16); in il4965_set_tkip_dynamic_key_info()
3363 memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16); in il4965_set_tkip_dynamic_key_info()
3365 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_set_tkip_dynamic_key_info()
3388 spin_lock_irqsave(&il->sta_lock, flags); in il4965_update_tkip_key()
3390 il->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; in il4965_update_tkip_key()
3393 il->stations[sta_id].sta.key.tkip_rx_ttak[i] = in il4965_update_tkip_key()
3396 il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; in il4965_update_tkip_key()
3397 il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; in il4965_update_tkip_key()
3399 il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); in il4965_update_tkip_key()
3401 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_update_tkip_key()
3413 lockdep_assert_held(&il->mutex); in il4965_remove_dynamic_key()
3415 il->_4965.key_mapping_keys--; in il4965_remove_dynamic_key()
3417 spin_lock_irqsave(&il->sta_lock, flags); in il4965_remove_dynamic_key()
3418 key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); in il4965_remove_dynamic_key()
3421 D_WEP("Remove dynamic key: idx=%d sta=%d\n", keyconf->keyidx, sta_id); in il4965_remove_dynamic_key()
3423 if (keyconf->keyidx != keyidx) { in il4965_remove_dynamic_key()
3429 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_remove_dynamic_key()
3433 if (il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_INVALID) { in il4965_remove_dynamic_key()
3434 IL_WARN("Removing wrong key %d 0x%x\n", keyconf->keyidx, in il4965_remove_dynamic_key()
3436 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_remove_dynamic_key()
3441 (il->stations[sta_id].sta.key.key_offset, &il->ucode_key_table)) in il4965_remove_dynamic_key()
3443 il->stations[sta_id].sta.key.key_offset); in il4965_remove_dynamic_key()
3444 memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); in il4965_remove_dynamic_key()
3445 memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo)); in il4965_remove_dynamic_key()
3446 il->stations[sta_id].sta.key.key_flags = in il4965_remove_dynamic_key()
3448 il->stations[sta_id].sta.key.key_offset = keyconf->hw_key_idx; in il4965_remove_dynamic_key()
3449 il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; in il4965_remove_dynamic_key()
3450 il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; in il4965_remove_dynamic_key()
3455 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_remove_dynamic_key()
3458 memcpy(&sta_cmd, &il->stations[sta_id].sta, in il4965_remove_dynamic_key()
3460 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_remove_dynamic_key()
3471 lockdep_assert_held(&il->mutex); in il4965_set_dynamic_key()
3473 il->_4965.key_mapping_keys++; in il4965_set_dynamic_key()
3474 keyconf->hw_key_idx = HW_KEY_DYNAMIC; in il4965_set_dynamic_key()
3476 switch (keyconf->cipher) { in il4965_set_dynamic_key()
3491 keyconf->cipher); in il4965_set_dynamic_key()
3492 ret = -EINVAL; in il4965_set_dynamic_key()
3496 keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); in il4965_set_dynamic_key()
3502 * il4965_alloc_bcast_station - add broadcast station into driver's station table.
3515 spin_lock_irqsave(&il->sta_lock, flags); in il4965_alloc_bcast_station()
3519 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_alloc_bcast_station()
3521 return -EINVAL; in il4965_alloc_bcast_station()
3524 il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; in il4965_alloc_bcast_station()
3525 il->stations[sta_id].used |= IL_STA_BCAST; in il4965_alloc_bcast_station()
3526 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_alloc_bcast_station()
3532 return -ENOMEM; in il4965_alloc_bcast_station()
3535 spin_lock_irqsave(&il->sta_lock, flags); in il4965_alloc_bcast_station()
3536 il->stations[sta_id].lq = link_cmd; in il4965_alloc_bcast_station()
3537 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_alloc_bcast_station()
3543 * il4965_update_bcast_station - update broadcast station's LQ command
3553 u8 sta_id = il->hw_params.bcast_id; in il4965_update_bcast_station()
3558 return -ENOMEM; in il4965_update_bcast_station()
3561 spin_lock_irqsave(&il->sta_lock, flags); in il4965_update_bcast_station()
3562 if (il->stations[sta_id].lq) in il4965_update_bcast_station()
3563 kfree(il->stations[sta_id].lq); in il4965_update_bcast_station()
3566 il->stations[sta_id].lq = link_cmd; in il4965_update_bcast_station()
3567 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_update_bcast_station()
3579 * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table
3587 lockdep_assert_held(&il->mutex); in il4965_sta_tx_modify_enable_tid()
3590 spin_lock_irqsave(&il->sta_lock, flags); in il4965_sta_tx_modify_enable_tid()
3591 il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; in il4965_sta_tx_modify_enable_tid()
3592 il->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); in il4965_sta_tx_modify_enable_tid()
3593 il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; in il4965_sta_tx_modify_enable_tid()
3594 memcpy(&sta_cmd, &il->stations[sta_id].sta, in il4965_sta_tx_modify_enable_tid()
3596 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_sta_tx_modify_enable_tid()
3609 lockdep_assert_held(&il->mutex); in il4965_sta_rx_agg_start()
3613 return -ENXIO; in il4965_sta_rx_agg_start()
3615 spin_lock_irqsave(&il->sta_lock, flags); in il4965_sta_rx_agg_start()
3616 il->stations[sta_id].sta.station_flags_msk = 0; in il4965_sta_rx_agg_start()
3617 il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; in il4965_sta_rx_agg_start()
3618 il->stations[sta_id].sta.add_immediate_ba_tid = (u8) tid; in il4965_sta_rx_agg_start()
3619 il->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); in il4965_sta_rx_agg_start()
3620 il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; in il4965_sta_rx_agg_start()
3621 memcpy(&sta_cmd, &il->stations[sta_id].sta, in il4965_sta_rx_agg_start()
3623 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_sta_rx_agg_start()
3635 lockdep_assert_held(&il->mutex); in il4965_sta_rx_agg_stop()
3640 return -ENXIO; in il4965_sta_rx_agg_stop()
3643 spin_lock_irqsave(&il->sta_lock, flags); in il4965_sta_rx_agg_stop()
3644 il->stations[sta_id].sta.station_flags_msk = 0; in il4965_sta_rx_agg_stop()
3645 il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; in il4965_sta_rx_agg_stop()
3646 il->stations[sta_id].sta.remove_immediate_ba_tid = (u8) tid; in il4965_sta_rx_agg_stop()
3647 il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; in il4965_sta_rx_agg_stop()
3648 memcpy(&sta_cmd, &il->stations[sta_id].sta, in il4965_sta_rx_agg_stop()
3650 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_sta_rx_agg_stop()
3660 spin_lock_irqsave(&il->sta_lock, flags); in il4965_sta_modify_sleep_tx_count()
3661 il->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; in il4965_sta_modify_sleep_tx_count()
3662 il->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; in il4965_sta_modify_sleep_tx_count()
3663 il->stations[sta_id].sta.sta.modify_mask = in il4965_sta_modify_sleep_tx_count()
3665 il->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); in il4965_sta_modify_sleep_tx_count()
3666 il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; in il4965_sta_modify_sleep_tx_count()
3667 il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); in il4965_sta_modify_sleep_tx_count()
3668 spin_unlock_irqrestore(&il->sta_lock, flags); in il4965_sta_modify_sleep_tx_count()
3675 if (il->ops->set_rxon_chain) { in il4965_update_chain_flags()
3676 il->ops->set_rxon_chain(il); in il4965_update_chain_flags()
3677 if (il->active.rx_chain != il->staging.rx_chain) in il4965_update_chain_flags()
3687 D_INFO("%d frames on pre-allocated heap on clear.\n", il->frames_count); in il4965_clear_free_frames()
3689 while (!list_empty(&il->free_frames)) { in il4965_clear_free_frames()
3690 element = il->free_frames.next; in il4965_clear_free_frames()
3693 il->frames_count--; in il4965_clear_free_frames()
3696 if (il->frames_count) { in il4965_clear_free_frames()
3698 il->frames_count); in il4965_clear_free_frames()
3699 il->frames_count = 0; in il4965_clear_free_frames()
3708 if (list_empty(&il->free_frames)) { in il4965_get_free_frame()
3715 il->frames_count++; in il4965_get_free_frame()
3719 element = il->free_frames.next; in il4965_get_free_frame()
3728 list_add(&frame->list, &il->free_frames); in il4965_free_frame()
3735 lockdep_assert_held(&il->mutex); in il4965_fill_beacon_frame()
3737 if (!il->beacon_skb) in il4965_fill_beacon_frame()
3740 if (il->beacon_skb->len > left) in il4965_fill_beacon_frame()
3743 memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); in il4965_fill_beacon_frame()
3745 return il->beacon_skb->len; in il4965_fill_beacon_frame()
3759 * variable-length part of the beacon. in il4965_set_beacon_tim()
3761 tim_idx = mgmt->u.beacon.variable - beacon; in il4965_set_beacon_tim()
3763 /* Parse variable-length elements of beacon to find WLAN_EID_TIM */ in il4965_set_beacon_tim()
3764 while ((tim_idx < (frame_size - 2)) && in il4965_set_beacon_tim()
3769 if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) { in il4965_set_beacon_tim()
3770 tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); in il4965_set_beacon_tim()
3771 tx_beacon_cmd->tim_size = beacon[tim_idx + 1]; in il4965_set_beacon_tim()
3788 lockdep_assert_held(&il->mutex); in il4965_hw_get_beacon_cmd()
3790 if (!il->beacon_enabled) { in il4965_hw_get_beacon_cmd()
3796 tx_beacon_cmd = &frame->u.beacon; in il4965_hw_get_beacon_cmd()
3801 il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, in il4965_hw_get_beacon_cmd()
3802 sizeof(frame->u) - sizeof(*tx_beacon_cmd)); in il4965_hw_get_beacon_cmd()
3809 tx_beacon_cmd->tx.len = cpu_to_le16((u16) frame_size); in il4965_hw_get_beacon_cmd()
3810 tx_beacon_cmd->tx.sta_id = il->hw_params.bcast_id; in il4965_hw_get_beacon_cmd()
3811 tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; in il4965_hw_get_beacon_cmd()
3812 tx_beacon_cmd->tx.tx_flags = in il4965_hw_get_beacon_cmd()
3817 il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *) tx_beacon_cmd->frame, in il4965_hw_get_beacon_cmd()
3822 il4965_toggle_tx_ant(il, &il->mgmt_tx_ant, il->hw_params.valid_tx_ant); in il4965_hw_get_beacon_cmd()
3823 rate_flags = BIT(il->mgmt_tx_ant) << RATE_MCS_ANT_POS; in il4965_hw_get_beacon_cmd()
3826 tx_beacon_cmd->tx.rate_n_flags = cpu_to_le32(rate | rate_flags); in il4965_hw_get_beacon_cmd()
3842 return -ENOMEM; in il4965_send_beacon_cmd()
3849 return -EINVAL; in il4965_send_beacon_cmd()
3852 rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, &frame->u.cmd[0]); in il4965_send_beacon_cmd()
3862 struct il_tfd_tb *tb = &tfd->tbs[idx]; in il4965_tfd_tb_get_addr()
3864 dma_addr_t addr = get_unaligned_le32(&tb->lo); in il4965_tfd_tb_get_addr()
3867 ((dma_addr_t) (le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << in il4965_tfd_tb_get_addr()
3876 struct il_tfd_tb *tb = &tfd->tbs[idx]; in il4965_tfd_tb_get_len()
3878 return le16_to_cpu(tb->hi_n_len) >> 4; in il4965_tfd_tb_get_len()
3884 struct il_tfd_tb *tb = &tfd->tbs[idx]; in il4965_tfd_set_tb()
3887 put_unaligned_le32(addr, &tb->lo); in il4965_tfd_set_tb()
3891 tb->hi_n_len = cpu_to_le16(hi_n_len); in il4965_tfd_set_tb()
3893 tfd->num_tbs = idx + 1; in il4965_tfd_set_tb()
3899 return tfd->num_tbs & 0x1f; in il4965_tfd_get_num_tbs()
3903 * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr]
3911 struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; in il4965_hw_txq_free_tfd()
3913 struct pci_dev *dev = il->pci_dev; in il4965_hw_txq_free_tfd()
3914 int idx = txq->q.read_ptr; in il4965_hw_txq_free_tfd()
3931 dma_unmap_single(&dev->dev, in il4965_hw_txq_free_tfd()
3932 dma_unmap_addr(&txq->meta[idx], mapping), in il4965_hw_txq_free_tfd()
3933 dma_unmap_len(&txq->meta[idx], len), in il4965_hw_txq_free_tfd()
3938 dma_unmap_single(&dev->dev, il4965_tfd_tb_get_addr(tfd, i), in il4965_hw_txq_free_tfd()
3942 if (txq->skbs) { in il4965_hw_txq_free_tfd()
3943 struct sk_buff *skb = txq->skbs[txq->q.read_ptr]; in il4965_hw_txq_free_tfd()
3945 /* can be called from irqs-disabled context */ in il4965_hw_txq_free_tfd()
3948 txq->skbs[txq->q.read_ptr] = NULL; in il4965_hw_txq_free_tfd()
3961 q = &txq->q; in il4965_hw_txq_attach_buf_to_tfd()
3962 tfd_tmp = (struct il_tfd *)txq->tfds; in il4965_hw_txq_attach_buf_to_tfd()
3963 tfd = &tfd_tmp[q->write_ptr]; in il4965_hw_txq_attach_buf_to_tfd()
3974 return -EINVAL; in il4965_hw_txq_attach_buf_to_tfd()
3988 * given Tx queue, and enable the DMA channel used for that queue.
3996 int txq_id = txq->q.id; in il4965_hw_tx_queue_init()
3998 /* Circular buffer (TFD queue in DRAM) physical base address */ in il4965_hw_tx_queue_init()
3999 il_wr(il, FH49_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); in il4965_hw_tx_queue_init()
4006 * Generic RX handler implementations
4012 struct il_rx_pkt *pkt = rxb_addr(rxb); in il4965_hdl_alive() local
4016 palive = &pkt->u.alive_frame; in il4965_hdl_alive()
4019 palive->is_valid, palive->ver_type, palive->ver_subtype); in il4965_hdl_alive()
4021 if (palive->ver_subtype == INITIALIZE_SUBTYPE) { in il4965_hdl_alive()
4023 memcpy(&il->card_alive_init, &pkt->u.raw, in il4965_hdl_alive()
4025 pwork = &il->init_alive_start; in il4965_hdl_alive()
4028 memcpy(&il->card_alive, &pkt->u.alive_frame, in il4965_hdl_alive()
4030 pwork = &il->alive_start; in il4965_hdl_alive()
4035 if (palive->is_valid == UCODE_VALID_OK) in il4965_hdl_alive()
4036 queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); in il4965_hdl_alive()
4042 * il4965_bg_stats_periodic - Timer callback to queue stats
4056 if (test_bit(S_EXIT_PENDING, &il->status)) in il4965_bg_stats_periodic()
4059 /* dont send host command if rf-kill is on */ in il4965_bg_stats_periodic()
4069 struct il_rx_pkt *pkt = rxb_addr(rxb); in il4965_hdl_beacon() local
4071 (struct il4965_beacon_notif *)pkt->u.raw; in il4965_hdl_beacon()
4073 u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); in il4965_hdl_beacon()
4076 le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, in il4965_hdl_beacon()
4077 beacon->beacon_notify_hdr.failure_frame, in il4965_hdl_beacon()
4078 le32_to_cpu(beacon->ibss_mgr_status), in il4965_hdl_beacon()
4079 le32_to_cpu(beacon->high_tsf), le32_to_cpu(beacon->low_tsf), rate); in il4965_hdl_beacon()
4081 il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); in il4965_hdl_beacon()
4091 if (il->mac80211_registered) in il4965_perform_ct_kill_task()
4092 ieee80211_stop_queues(il->hw); in il4965_perform_ct_kill_task()
4098 spin_lock_irqsave(&il->reg_lock, flags); in il4965_perform_ct_kill_task()
4101 spin_unlock_irqrestore(&il->reg_lock, flags); in il4965_perform_ct_kill_task()
4109 struct il_rx_pkt *pkt = rxb_addr(rxb); in il4965_hdl_card_state() local
4110 u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); in il4965_hdl_card_state()
4111 unsigned long status = il->status; in il4965_hdl_card_state()
4137 set_bit(S_RFKILL, &il->status); in il4965_hdl_card_state()
4139 clear_bit(S_RFKILL, &il->status); in il4965_hdl_card_state()
4145 test_bit(S_RFKILL, &il->status))) in il4965_hdl_card_state()
4146 wiphy_rfkill_set_hw_state(il->hw->wiphy, in il4965_hdl_card_state()
4147 test_bit(S_RFKILL, &il->status)); in il4965_hdl_card_state()
4149 wake_up(&il->wait_command_queue); in il4965_hdl_card_state()
4153 * il4965_setup_handlers - Initialize Rx handler callbacks
4155 * Setup the RX handlers for each of the reply types sent from the uCode
4164 il->handlers[N_ALIVE] = il4965_hdl_alive; in il4965_setup_handlers()
4165 il->handlers[N_ERROR] = il_hdl_error; in il4965_setup_handlers()
4166 il->handlers[N_CHANNEL_SWITCH] = il_hdl_csa; in il4965_setup_handlers()
4167 il->handlers[N_SPECTRUM_MEASUREMENT] = il_hdl_spectrum_measurement; in il4965_setup_handlers()
4168 il->handlers[N_PM_SLEEP] = il_hdl_pm_sleep; in il4965_setup_handlers()
4169 il->handlers[N_PM_DEBUG_STATS] = il_hdl_pm_debug_stats; in il4965_setup_handlers()
4170 il->handlers[N_BEACON] = il4965_hdl_beacon; in il4965_setup_handlers()
4177 il->handlers[C_STATS] = il4965_hdl_c_stats; in il4965_setup_handlers()
4178 il->handlers[N_STATS] = il4965_hdl_stats; in il4965_setup_handlers()
4183 il->handlers[N_CARD_STATE] = il4965_hdl_card_state; in il4965_setup_handlers()
4185 il->handlers[N_MISSED_BEACONS] = il4965_hdl_missed_beacon; in il4965_setup_handlers()
4186 /* Rx handlers */ in il4965_setup_handlers()
4187 il->handlers[N_RX_PHY] = il4965_hdl_rx_phy; in il4965_setup_handlers()
4188 il->handlers[N_RX_MPDU] = il4965_hdl_rx; in il4965_setup_handlers()
4189 il->handlers[N_RX] = il4965_hdl_rx; in il4965_setup_handlers()
4191 il->handlers[N_COMPRESSED_BA] = il4965_hdl_compressed_ba; in il4965_setup_handlers()
4193 il->handlers[C_TX] = il4965_hdl_tx; in il4965_setup_handlers()
4197 * il4965_rx_handle - Main entry function for receiving responses from uCode
4199 * Uses the il->handlers callback function array to invoke
4201 * frame-received notifications, and other notifications.
4207 struct il_rx_pkt *pkt; in il4965_rx_handle() local
4208 struct il_rx_queue *rxq = &il->rxq; in il4965_rx_handle()
4216 /* uCode's read idx (stored in shared DRAM) indicates the last Rx in il4965_rx_handle()
4218 r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; in il4965_rx_handle()
4219 i = rxq->read; in il4965_rx_handle()
4221 /* Rx interrupt, but nothing sent from uCode */ in il4965_rx_handle()
4225 /* calculate total frames need to be restock after handling RX */ in il4965_rx_handle()
4226 total_empty = r - rxq->write_actual; in il4965_rx_handle()
4234 rxb = rxq->queue[i]; in il4965_rx_handle()
4236 /* If an RXB doesn't have a Rx queue slot associated with it, in il4965_rx_handle()
4237 * then a bug has been introduced in the queue refilling in il4965_rx_handle()
4238 * routines -- catch it here */ in il4965_rx_handle()
4241 rxq->queue[i] = NULL; in il4965_rx_handle()
4243 dma_unmap_page(&il->pci_dev->dev, rxb->page_dma, in il4965_rx_handle()
4244 PAGE_SIZE << il->hw_params.rx_page_order, in il4965_rx_handle()
4246 pkt = rxb_addr(rxb); in il4965_rx_handle()
4247 reclaim = il_need_reclaim(il, pkt); in il4965_rx_handle()
4252 if (il->handlers[pkt->hdr.cmd]) { in il4965_rx_handle()
4254 il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); in il4965_rx_handle()
4255 il->isr_stats.handlers[pkt->hdr.cmd]++; in il4965_rx_handle()
4256 il->handlers[pkt->hdr.cmd] (il, rxb); in il4965_rx_handle()
4260 i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); in il4965_rx_handle()
4264 * XXX: After here, we should always check rxb->page in il4965_rx_handle()
4266 * memory (pkt). Because some handler might have in il4965_rx_handle()
4273 * as we reclaim the driver command queue */ in il4965_rx_handle()
4274 if (rxb->page) in il4965_rx_handle()
4281 * SKBs that fail to Rx correctly, add them back into the in il4965_rx_handle()
4283 spin_lock_irqsave(&rxq->lock, flags); in il4965_rx_handle()
4284 if (rxb->page != NULL) { in il4965_rx_handle()
4285 rxb->page_dma = in il4965_rx_handle()
4286 dma_map_page(&il->pci_dev->dev, rxb->page, 0, in il4965_rx_handle()
4287 PAGE_SIZE << il->hw_params.rx_page_order, in il4965_rx_handle()
4290 if (unlikely(dma_mapping_error(&il->pci_dev->dev, in il4965_rx_handle()
4291 rxb->page_dma))) { in il4965_rx_handle()
4292 __il_free_pages(il, rxb->page); in il4965_rx_handle()
4293 rxb->page = NULL; in il4965_rx_handle()
4294 list_add_tail(&rxb->list, &rxq->rx_used); in il4965_rx_handle()
4296 list_add_tail(&rxb->list, &rxq->rx_free); in il4965_rx_handle()
4297 rxq->free_count++; in il4965_rx_handle()
4300 list_add_tail(&rxb->list, &rxq->rx_used); in il4965_rx_handle()
4302 spin_unlock_irqrestore(&rxq->lock, flags); in il4965_rx_handle()
4306 * restock the Rx queue so ucode wont assert. */ in il4965_rx_handle()
4310 rxq->read = i; in il4965_rx_handle()
4318 rxq->read = i; in il4965_rx_handle()
4330 synchronize_irq(il->pci_dev->irq); in il4965_synchronize_irq()
4331 tasklet_kill(&il->irq_tasklet); in il4965_synchronize_irq()
4346 spin_lock_irqsave(&il->lock, flags); in il4965_irq_tasklet()
4354 /* Ack/clear/reset pending flow-handler (DMA) interrupts. in il4965_irq_tasklet()
4369 spin_unlock_irqrestore(&il->lock, flags); in il4965_irq_tasklet()
4387 il->isr_stats.hw++; in il4965_irq_tasklet()
4400 il->isr_stats.sch++; in il4965_irq_tasklet()
4403 /* Alive notification via Rx interrupt will do the real work */ in il4965_irq_tasklet()
4406 il->isr_stats.alive++; in il4965_irq_tasklet()
4423 il->isr_stats.rfkill++; in il4965_irq_tasklet()
4431 set_bit(S_RFKILL, &il->status); in il4965_irq_tasklet()
4433 clear_bit(S_RFKILL, &il->status); in il4965_irq_tasklet()
4436 wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); in il4965_irq_tasklet()
4444 il->isr_stats.ctkill++; in il4965_irq_tasklet()
4452 il->isr_stats.sw++; in il4965_irq_tasklet()
4458 * uCode wakes up after power-down sleep. in il4965_irq_tasklet()
4460 * and about any Rx buffers made available while asleep. in il4965_irq_tasklet()
4464 il_rx_queue_update_write_ptr(il, &il->rxq); in il4965_irq_tasklet()
4465 for (i = 0; i < il->hw_params.max_txq_num; i++) in il4965_irq_tasklet()
4466 il_txq_update_write_ptr(il, &il->txq[i]); in il4965_irq_tasklet()
4467 il->isr_stats.wakeup++; in il4965_irq_tasklet()
4472 * Rx "responses" (frame-received notification), and other in il4965_irq_tasklet()
4476 il->isr_stats.rx++; in il4965_irq_tasklet()
4483 il->isr_stats.tx++; in il4965_irq_tasklet()
4486 il->ucode_write_complete = 1; in il4965_irq_tasklet()
4487 wake_up(&il->wait_command_queue); in il4965_irq_tasklet()
4492 il->isr_stats.unhandled++; in il4965_irq_tasklet()
4495 if (inta & ~(il->inta_mask)) { in il4965_irq_tasklet()
4497 inta & ~il->inta_mask); in il4965_irq_tasklet()
4501 /* Re-enable all interrupts */ in il4965_irq_tasklet()
4502 /* only Re-enable if disabled by irq */ in il4965_irq_tasklet()
4503 if (test_bit(S_INT_ENABLED, &il->status)) in il4965_irq_tasklet()
4505 /* Re-enable RF_KILL if it occurred */ in il4965_irq_tasklet()
4559 il->debug_level = val; in il4965_store_debug_level()
4576 return -EAGAIN; in il4965_show_temperature()
4578 return sprintf(buf, "%d\n", il->temperature); in il4965_show_temperature()
4591 return sprintf(buf, "%d\n", il->tx_power_user_lmt); in il4965_show_tx_power()
4641 il_free_fw_desc(il->pci_dev, &il->ucode_code); in il4965_dealloc_ucode_pci()
4642 il_free_fw_desc(il->pci_dev, &il->ucode_data); in il4965_dealloc_ucode_pci()
4643 il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); in il4965_dealloc_ucode_pci()
4644 il_free_fw_desc(il->pci_dev, &il->ucode_init); in il4965_dealloc_ucode_pci()
4645 il_free_fw_desc(il->pci_dev, &il->ucode_init_data); in il4965_dealloc_ucode_pci()
4646 il_free_fw_desc(il->pci_dev, &il->ucode_boot); in il4965_dealloc_ucode_pci()
4663 const char *name_pre = il->cfg->fw_name_pre; in il4965_request_firmware()
4667 il->fw_idx = il->cfg->ucode_api_max; in il4965_request_firmware()
4668 sprintf(tag, "%d", il->fw_idx); in il4965_request_firmware()
4670 il->fw_idx--; in il4965_request_firmware()
4671 sprintf(tag, "%d", il->fw_idx); in il4965_request_firmware()
4674 if (il->fw_idx < il->cfg->ucode_api_min) { in il4965_request_firmware()
4676 return -ENOENT; in il4965_request_firmware()
4679 sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); in il4965_request_firmware()
4681 D_INFO("attempting to load firmware '%s'\n", il->firmware_name); in il4965_request_firmware()
4683 return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, in il4965_request_firmware()
4684 &il->pci_dev->dev, GFP_KERNEL, il, in il4965_request_firmware()
4697 struct il_ucode_header *ucode = (void *)ucode_raw->data; in il4965_load_firmware()
4701 il->ucode_ver = le32_to_cpu(ucode->ver); in il4965_load_firmware()
4702 api_ver = IL_UCODE_API(il->ucode_ver); in il4965_load_firmware()
4710 if (ucode_raw->size < hdr_size) { in il4965_load_firmware()
4712 return -EINVAL; in il4965_load_firmware()
4714 pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); in il4965_load_firmware()
4715 pieces->data_size = le32_to_cpu(ucode->v1.data_size); in il4965_load_firmware()
4716 pieces->init_size = le32_to_cpu(ucode->v1.init_size); in il4965_load_firmware()
4717 pieces->init_data_size = le32_to_cpu(ucode->v1.init_data_size); in il4965_load_firmware()
4718 pieces->boot_size = le32_to_cpu(ucode->v1.boot_size); in il4965_load_firmware()
4719 src = ucode->v1.data; in il4965_load_firmware()
4724 if (ucode_raw->size != in il4965_load_firmware()
4725 hdr_size + pieces->inst_size + pieces->data_size + in il4965_load_firmware()
4726 pieces->init_size + pieces->init_data_size + pieces->boot_size) { in il4965_load_firmware()
4729 (int)ucode_raw->size); in il4965_load_firmware()
4730 return -EINVAL; in il4965_load_firmware()
4733 pieces->inst = src; in il4965_load_firmware()
4734 src += pieces->inst_size; in il4965_load_firmware()
4735 pieces->data = src; in il4965_load_firmware()
4736 src += pieces->data_size; in il4965_load_firmware()
4737 pieces->init = src; in il4965_load_firmware()
4738 src += pieces->init_size; in il4965_load_firmware()
4739 pieces->init_data = src; in il4965_load_firmware()
4740 src += pieces->init_data_size; in il4965_load_firmware()
4741 pieces->boot = src; in il4965_load_firmware()
4742 src += pieces->boot_size; in il4965_load_firmware()
4748 * il4965_ucode_callback - callback when firmware was loaded
4759 const unsigned int api_max = il->cfg->ucode_api_max; in il4965_ucode_callback()
4760 const unsigned int api_min = il->cfg->ucode_api_min; in il4965_ucode_callback()
4770 if (il->fw_idx <= il->cfg->ucode_api_max) in il4965_ucode_callback()
4772 il->firmware_name); in il4965_ucode_callback()
4776 D_INFO("Loaded firmware file '%s' (%zd bytes).\n", il->firmware_name, in il4965_ucode_callback()
4777 ucode_raw->size); in il4965_ucode_callback()
4780 if (ucode_raw->size < 4) { in il4965_ucode_callback()
4791 api_ver = IL_UCODE_API(il->ucode_ver); in il4965_ucode_callback()
4812 IL_UCODE_MAJOR(il->ucode_ver), IL_UCODE_MINOR(il->ucode_ver), in il4965_ucode_callback()
4813 IL_UCODE_API(il->ucode_ver), IL_UCODE_SERIAL(il->ucode_ver)); in il4965_ucode_callback()
4815 snprintf(il->hw->wiphy->fw_version, sizeof(il->hw->wiphy->fw_version), in il4965_ucode_callback()
4816 "%u.%u.%u.%u", IL_UCODE_MAJOR(il->ucode_ver), in il4965_ucode_callback()
4817 IL_UCODE_MINOR(il->ucode_ver), IL_UCODE_API(il->ucode_ver), in il4965_ucode_callback()
4818 IL_UCODE_SERIAL(il->ucode_ver)); in il4965_ucode_callback()
4822 * we will try to load a version with a smaller API -- maybe the in il4965_ucode_callback()
4826 D_INFO("f/w package hdr ucode version raw = 0x%x\n", il->ucode_ver); in il4965_ucode_callback()
4834 if (pieces.inst_size > il->hw_params.max_inst_size) { in il4965_ucode_callback()
4840 if (pieces.data_size > il->hw_params.max_data_size) { in il4965_ucode_callback()
4846 if (pieces.init_size > il->hw_params.max_inst_size) { in il4965_ucode_callback()
4852 if (pieces.init_data_size > il->hw_params.max_data_size) { in il4965_ucode_callback()
4858 if (pieces.boot_size > il->hw_params.max_bsm_size) { in il4965_ucode_callback()
4864 /* Allocate ucode buffers for card's bus-master loading ... */ in il4965_ucode_callback()
4868 * 2) backup cache for save/restore during power-downs */ in il4965_ucode_callback()
4869 il->ucode_code.len = pieces.inst_size; in il4965_ucode_callback()
4870 il_alloc_fw_desc(il->pci_dev, &il->ucode_code); in il4965_ucode_callback()
4872 il->ucode_data.len = pieces.data_size; in il4965_ucode_callback()
4873 il_alloc_fw_desc(il->pci_dev, &il->ucode_data); in il4965_ucode_callback()
4875 il->ucode_data_backup.len = pieces.data_size; in il4965_ucode_callback()
4876 il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); in il4965_ucode_callback()
4878 if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || in il4965_ucode_callback()
4879 !il->ucode_data_backup.v_addr) in il4965_ucode_callback()
4884 il->ucode_init.len = pieces.init_size; in il4965_ucode_callback()
4885 il_alloc_fw_desc(il->pci_dev, &il->ucode_init); in il4965_ucode_callback()
4887 il->ucode_init_data.len = pieces.init_data_size; in il4965_ucode_callback()
4888 il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); in il4965_ucode_callback()
4890 if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) in il4965_ucode_callback()
4896 il->ucode_boot.len = pieces.boot_size; in il4965_ucode_callback()
4897 il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); in il4965_ucode_callback()
4899 if (!il->ucode_boot.v_addr) in il4965_ucode_callback()
4905 il->sta_key_max_num = STA_KEY_MAX_NUM; in il4965_ucode_callback()
4907 /* Copy images into buffers for card's bus-master reads ... */ in il4965_ucode_callback()
4912 memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); in il4965_ucode_callback()
4915 il->ucode_code.v_addr, (u32) il->ucode_code.p_addr); in il4965_ucode_callback()
4923 memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); in il4965_ucode_callback()
4924 memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); in il4965_ucode_callback()
4930 memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); in il4965_ucode_callback()
4937 memcpy(il->ucode_init_data.v_addr, pieces.init_data, in il4965_ucode_callback()
4944 memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); in il4965_ucode_callback()
4950 il->_4965.phy_calib_chain_noise_reset_cmd = in il4965_ucode_callback()
4952 il->_4965.phy_calib_chain_noise_gain_cmd = in il4965_ucode_callback()
4966 err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group); in il4965_ucode_callback()
4974 complete(&il->_4965.firmware_loading_complete); in il4965_ucode_callback()
4988 complete(&il->_4965.firmware_loading_complete); in il4965_ucode_callback()
4989 device_release_driver(&il->pci_dev->dev); in il4965_ucode_callback()
5055 max = ARRAY_SIZE(advanced_lookup) - 1; in il4965_desc_lookup()
5074 if (il->ucode_type == UCODE_INIT) in il4965_dump_nic_error_log()
5075 base = le32_to_cpu(il->card_alive_init.error_event_table_ptr); in il4965_dump_nic_error_log()
5077 base = le32_to_cpu(il->card_alive.error_event_table_ptr); in il4965_dump_nic_error_log()
5079 if (!il->ops->is_valid_rtc_data_addr(base)) { in il4965_dump_nic_error_log()
5081 base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); in il4965_dump_nic_error_log()
5089 IL_ERR("Status: 0x%08lX, count: %d\n", il->status, count); in il4965_dump_nic_error_log()
5093 il->isr_stats.err_code = desc; in il4965_dump_nic_error_log()
5107 IL_ERR("%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", in il4965_dump_nic_error_log()
5121 spin_lock_irqsave(&il->lock, flags); in il4965_rf_kill_ct_config()
5124 spin_unlock_irqrestore(&il->lock, flags); in il4965_rf_kill_ct_config()
5127 cpu_to_le32(il->hw_params.ct_kill_threshold); in il4965_rf_kill_ct_config()
5135 il->hw_params.ct_kill_threshold); in il4965_rf_kill_ct_config()
5148 #define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo))))
5158 spin_lock_irqsave(&il->lock, flags); in il4965_alive_notify()
5161 il->scd_base_addr = il_rd_prph(il, IL49_SCD_SRAM_BASE_ADDR); in il4965_alive_notify()
5162 a = il->scd_base_addr + IL49_SCD_CONTEXT_DATA_OFFSET; in il4965_alive_notify()
5163 for (; a < il->scd_base_addr + IL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) in il4965_alive_notify()
5165 for (; a < il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) in il4965_alive_notify()
5169 il->scd_base_addr + in il4965_alive_notify()
5170 IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); in il4965_alive_notify()
5175 il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, il->scd_bc_tbls.dma >> 10); in il4965_alive_notify()
5191 /* Initialize each Tx queue (including the command queue) */ in il4965_alive_notify()
5192 for (i = 0; i < il->hw_params.max_txq_num; i++) { in il4965_alive_notify()
5198 /* Max Tx Window size for Scheduler-ACK mode */ in il4965_alive_notify()
5200 il->scd_base_addr + in il4965_alive_notify()
5208 il->scd_base_addr + in il4965_alive_notify()
5217 (1 << il->hw_params.max_txq_num) - 1); in il4965_alive_notify()
5224 /* make sure all queue are not stopped */ in il4965_alive_notify()
5225 memset(&il->queue_stopped[0], 0, sizeof(il->queue_stopped)); in il4965_alive_notify()
5227 atomic_set(&il->queue_stop_count[i], 0); in il4965_alive_notify()
5229 /* reset to 0 to enable all the queue first */ in il4965_alive_notify()
5230 il->txq_ctx_active_msk = 0; in il4965_alive_notify()
5231 /* Map each Tx/cmd queue to its corresponding fifo */ in il4965_alive_notify()
5242 il4965_tx_queue_set_status(il, &il->txq[i], ac, 0); in il4965_alive_notify()
5245 spin_unlock_irqrestore(&il->lock, flags); in il4965_alive_notify()
5251 * il4965_alive_start - called after N_ALIVE notification received
5262 if (il->card_alive.is_valid != UCODE_VALID_OK) { in il4965_alive_start()
5286 set_bit(S_ALIVE, &il->status); in il4965_alive_start()
5294 ieee80211_wake_queues(il->hw); in il4965_alive_start()
5296 il->active_rate = RATES_MASK; in il4965_alive_start()
5303 (struct il_rxon_cmd *)&il->active; in il4965_alive_start()
5305 il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; in il4965_alive_start()
5306 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; in il4965_alive_start()
5311 if (il->ops->set_rxon_chain) in il4965_alive_start()
5312 il->ops->set_rxon_chain(il); in il4965_alive_start()
5320 set_bit(S_READY, &il->status); in il4965_alive_start()
5329 wake_up(&il->wait_command_queue); in il4965_alive_start()
5334 queue_work(il->workqueue, &il->restart); in il4965_alive_start()
5349 exit_pending = test_and_set_bit(S_EXIT_PENDING, &il->status); in __il4965_down()
5353 del_timer_sync(&il->watchdog); in __il4965_down()
5358 spin_lock_irq(&il->sta_lock); in __il4965_down()
5366 memset(il->_4965.wep_keys, 0, sizeof(il->_4965.wep_keys)); in __il4965_down()
5367 il->_4965.key_mapping_keys = 0; in __il4965_down()
5368 spin_unlock_irq(&il->sta_lock); in __il4965_down()
5374 wake_up_all(&il->wait_command_queue); in __il4965_down()
5379 clear_bit(S_EXIT_PENDING, &il->status); in __il4965_down()
5381 /* stop and reset the on-board processor */ in __il4965_down()
5385 spin_lock_irqsave(&il->lock, flags); in __il4965_down()
5387 spin_unlock_irqrestore(&il->lock, flags); in __il4965_down()
5390 if (il->mac80211_registered) in __il4965_down()
5391 ieee80211_stop_queues(il->hw); in __il4965_down()
5396 il->status = in __il4965_down()
5397 test_bit(S_RFKILL, &il->status) << S_RFKILL | in __il4965_down()
5398 test_bit(S_GEO_CONFIGURED, &il->status) << S_GEO_CONFIGURED | in __il4965_down()
5399 test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; in __il4965_down()
5405 il->status &= in __il4965_down()
5406 test_bit(S_RFKILL, &il->status) << S_RFKILL | in __il4965_down()
5407 test_bit(S_GEO_CONFIGURED, &il->status) << S_GEO_CONFIGURED | in __il4965_down()
5408 test_bit(S_FW_ERROR, &il->status) << S_FW_ERROR | in __il4965_down()
5409 test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; in __il4965_down()
5412 * We disabled and synchronized interrupt, and priv->mutex is taken, so in __il4965_down()
5416 spin_lock_irq(&il->reg_lock); in __il4965_down()
5421 /* Power-down device's busmaster DMA clocks */ in __il4965_down()
5429 spin_unlock_irq(&il->reg_lock); in __il4965_down()
5433 memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); in __il4965_down()
5435 dev_kfree_skb(il->beacon_skb); in __il4965_down()
5436 il->beacon_skb = NULL; in __il4965_down()
5445 mutex_lock(&il->mutex); in il4965_down()
5447 mutex_unlock(&il->mutex); in il4965_down()
5467 il->hw_ready = true; in il4965_set_hw_ready()
5469 D_INFO("hardware %s ready\n", (il->hw_ready) ? "" : "not"); in il4965_set_hw_ready()
5477 il->hw_ready = false; in il4965_prepare_card_hw()
5480 if (il->hw_ready) in il4965_prepare_card_hw()
5492 if (ret != -ETIMEDOUT) in il4965_prepare_card_hw()
5504 if (test_bit(S_EXIT_PENDING, &il->status)) { in __il4965_up()
5506 return -EIO; in __il4965_up()
5509 if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { in __il4965_up()
5511 return -EIO; in __il4965_up()
5521 if (!il->hw_ready) { in __il4965_up()
5524 return -EIO; in __il4965_up()
5529 clear_bit(S_RFKILL, &il->status); in __il4965_up()
5531 set_bit(S_RFKILL, &il->status); in __il4965_up()
5532 wiphy_rfkill_set_hw_state(il->hw->wiphy, true); in __il4965_up()
5543 il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; in __il4965_up()
5565 * This will be used to initialize the on-board processor's in __il4965_up()
5567 memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, in __il4965_up()
5568 il->ucode_data.len); in __il4965_up()
5575 ret = il->ops->load_ucode(il); in __il4965_up()
5590 set_bit(S_EXIT_PENDING, &il->status); in __il4965_up()
5592 clear_bit(S_EXIT_PENDING, &il->status); in __il4965_up()
5597 return -EIO; in __il4965_up()
5612 mutex_lock(&il->mutex); in il4965_bg_init_alive_start()
5613 if (test_bit(S_EXIT_PENDING, &il->status)) in il4965_bg_init_alive_start()
5616 il->ops->init_alive_start(il); in il4965_bg_init_alive_start()
5618 mutex_unlock(&il->mutex); in il4965_bg_init_alive_start()
5627 mutex_lock(&il->mutex); in il4965_bg_alive_start()
5628 if (test_bit(S_EXIT_PENDING, &il->status)) in il4965_bg_alive_start()
5633 mutex_unlock(&il->mutex); in il4965_bg_alive_start()
5642 mutex_lock(&il->mutex); in il4965_bg_run_time_calib_work()
5644 if (test_bit(S_EXIT_PENDING, &il->status) || in il4965_bg_run_time_calib_work()
5645 test_bit(S_SCANNING, &il->status)) { in il4965_bg_run_time_calib_work()
5646 mutex_unlock(&il->mutex); in il4965_bg_run_time_calib_work()
5650 if (il->start_calib) { in il4965_bg_run_time_calib_work()
5651 il4965_chain_noise_calibration(il, (void *)&il->_4965.stats); in il4965_bg_run_time_calib_work()
5652 il4965_sensitivity_calibration(il, (void *)&il->_4965.stats); in il4965_bg_run_time_calib_work()
5655 mutex_unlock(&il->mutex); in il4965_bg_run_time_calib_work()
5663 if (test_bit(S_EXIT_PENDING, &il->status)) in il4965_bg_restart()
5666 if (test_and_clear_bit(S_FW_ERROR, &il->status)) { in il4965_bg_restart()
5667 mutex_lock(&il->mutex); in il4965_bg_restart()
5668 il->is_open = 0; in il4965_bg_restart()
5672 mutex_unlock(&il->mutex); in il4965_bg_restart()
5674 ieee80211_restart_hw(il->hw); in il4965_bg_restart()
5678 mutex_lock(&il->mutex); in il4965_bg_restart()
5679 if (test_bit(S_EXIT_PENDING, &il->status)) { in il4965_bg_restart()
5680 mutex_unlock(&il->mutex); in il4965_bg_restart()
5685 mutex_unlock(&il->mutex); in il4965_bg_restart()
5694 if (test_bit(S_EXIT_PENDING, &il->status)) in il4965_bg_rx_replenish()
5697 mutex_lock(&il->mutex); in il4965_bg_rx_replenish()
5699 mutex_unlock(&il->mutex); in il4965_bg_rx_replenish()
5718 struct ieee80211_hw *hw = il->hw; in il4965_mac_setup_register()
5720 hw->rate_control_algorithm = "iwl-4965-rs"; in il4965_mac_setup_register()
5730 if (il->cfg->sku & IL_SKU_N) in il4965_mac_setup_register()
5731 hw->wiphy->features |= NL80211_FEATURE_DYNAMIC_SMPS | in il4965_mac_setup_register()
5734 hw->sta_data_size = sizeof(struct il_station_priv); in il4965_mac_setup_register()
5735 hw->vif_data_size = sizeof(struct il_vif_priv); in il4965_mac_setup_register()
5737 hw->wiphy->interface_modes = in il4965_mac_setup_register()
5740 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; in il4965_mac_setup_register()
5741 hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | in il4965_mac_setup_register()
5746 * RX performance significantly. in il4965_mac_setup_register()
5748 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; in il4965_mac_setup_register()
5750 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; in il4965_mac_setup_register()
5751 /* we create the 802.11 header and a zero-length SSID element */ in il4965_mac_setup_register()
5752 hw->wiphy->max_scan_ie_len = max_probe_length - 24 - 2; in il4965_mac_setup_register()
5755 hw->queues = 4; in il4965_mac_setup_register()
5757 hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL; in il4965_mac_setup_register()
5759 if (il->bands[NL80211_BAND_2GHZ].n_channels) in il4965_mac_setup_register()
5760 il->hw->wiphy->bands[NL80211_BAND_2GHZ] = in il4965_mac_setup_register()
5761 &il->bands[NL80211_BAND_2GHZ]; in il4965_mac_setup_register()
5762 if (il->bands[NL80211_BAND_5GHZ].n_channels) in il4965_mac_setup_register()
5763 il->hw->wiphy->bands[NL80211_BAND_5GHZ] = in il4965_mac_setup_register()
5764 &il->bands[NL80211_BAND_5GHZ]; in il4965_mac_setup_register()
5768 wiphy_ext_feature_set(il->hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); in il4965_mac_setup_register()
5770 ret = ieee80211_register_hw(il->hw); in il4965_mac_setup_register()
5775 il->mac80211_registered = 1; in il4965_mac_setup_register()
5783 struct il_priv *il = hw->priv; in il4965_mac_start()
5789 mutex_lock(&il->mutex); in il4965_mac_start()
5791 mutex_unlock(&il->mutex); in il4965_mac_start()
5803 ret = wait_event_timeout(il->wait_command_queue, in il4965_mac_start()
5804 test_bit(S_READY, &il->status), in il4965_mac_start()
5807 if (!test_bit(S_READY, &il->status)) { in il4965_mac_start()
5810 return -ETIMEDOUT; in il4965_mac_start()
5817 il->is_open = 1; in il4965_mac_start()
5825 struct il_priv *il = hw->priv; in il4965_mac_stop()
5829 if (!il->is_open) in il4965_mac_stop()
5832 il->is_open = 0; in il4965_mac_stop()
5836 flush_workqueue(il->workqueue); in il4965_mac_stop()
5851 struct il_priv *il = hw->priv; in il4965_mac_tx()
5855 D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, in il4965_mac_tx()
5856 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); in il4965_mac_tx()
5858 if (il4965_tx_skb(il, control->sta, skb)) in il4965_mac_tx()
5869 struct il_priv *il = hw->priv; in il4965_mac_update_tkip_key()
5883 struct il_priv *il = hw->priv; in il4965_mac_set_key()
5890 if (il->cfg->mod_params->sw_crypto) { in il4965_mac_set_key()
5891 D_MAC80211("leave - hwcrypto disabled\n"); in il4965_mac_set_key()
5892 return -EOPNOTSUPP; in il4965_mac_set_key()
5899 if (vif->type == NL80211_IFTYPE_ADHOC && in il4965_mac_set_key()
5900 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in il4965_mac_set_key()
5901 D_MAC80211("leave - ad-hoc group key\n"); in il4965_mac_set_key()
5902 return -EOPNOTSUPP; in il4965_mac_set_key()
5907 return -EINVAL; in il4965_mac_set_key()
5909 mutex_lock(&il->mutex); in il4965_mac_set_key()
5918 if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || in il4965_mac_set_key()
5919 key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { in il4965_mac_set_key()
5921 is_default_wep_key = !il->_4965.key_mapping_keys; in il4965_mac_set_key()
5924 (key->hw_key_idx == HW_KEY_DEFAULT); in il4965_mac_set_key()
5945 ret = -EINVAL; in il4965_mac_set_key()
5948 mutex_unlock(&il->mutex); in il4965_mac_set_key()
5958 struct il_priv *il = hw->priv; in il4965_mac_ampdu_action()
5959 int ret = -EINVAL; in il4965_mac_ampdu_action()
5960 struct ieee80211_sta *sta = params->sta; in il4965_mac_ampdu_action()
5961 enum ieee80211_ampdu_mlme_action action = params->action; in il4965_mac_ampdu_action()
5962 u16 tid = params->tid; in il4965_mac_ampdu_action()
5963 u16 *ssn = ¶ms->ssn; in il4965_mac_ampdu_action()
5965 D_HT("A-MPDU action on addr %pM tid %d\n", sta->addr, tid); in il4965_mac_ampdu_action()
5967 if (!(il->cfg->sku & IL_SKU_N)) in il4965_mac_ampdu_action()
5968 return -EACCES; in il4965_mac_ampdu_action()
5970 mutex_lock(&il->mutex); in il4965_mac_ampdu_action()
5974 D_HT("start Rx\n"); in il4965_mac_ampdu_action()
5978 D_HT("stop Rx\n"); in il4965_mac_ampdu_action()
5980 if (test_bit(S_EXIT_PENDING, &il->status)) in il4965_mac_ampdu_action()
5992 if (test_bit(S_EXIT_PENDING, &il->status)) in il4965_mac_ampdu_action()
5999 mutex_unlock(&il->mutex); in il4965_mac_ampdu_action()
6008 struct il_priv *il = hw->priv; in il4965_mac_sta_add()
6009 struct il_station_priv *sta_priv = (void *)sta->drv_priv; in il4965_mac_sta_add()
6010 bool is_ap = vif->type == NL80211_IFTYPE_STATION; in il4965_mac_sta_add()
6014 D_INFO("received request to add station %pM\n", sta->addr); in il4965_mac_sta_add()
6015 mutex_lock(&il->mutex); in il4965_mac_sta_add()
6016 D_INFO("proceeding to add station %pM\n", sta->addr); in il4965_mac_sta_add()
6017 sta_priv->common.sta_id = IL_INVALID_STATION; in il4965_mac_sta_add()
6019 atomic_set(&sta_priv->pending_frames, 0); in il4965_mac_sta_add()
6022 il_add_station_common(il, sta->addr, is_ap, sta, &sta_id); in il4965_mac_sta_add()
6024 IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret); in il4965_mac_sta_add()
6026 mutex_unlock(&il->mutex); in il4965_mac_sta_add()
6030 sta_priv->common.sta_id = sta_id; in il4965_mac_sta_add()
6033 D_INFO("Initializing rate scaling for station %pM\n", sta->addr); in il4965_mac_sta_add()
6035 mutex_unlock(&il->mutex); in il4965_mac_sta_add()
6044 struct il_priv *il = hw->priv; in il4965_mac_channel_switch()
6046 struct ieee80211_conf *conf = &hw->conf; in il4965_mac_channel_switch()
6047 struct ieee80211_channel *channel = ch_switch->chandef.chan; in il4965_mac_channel_switch()
6048 struct il_ht_config *ht_conf = &il->current_ht_config; in il4965_mac_channel_switch()
6053 mutex_lock(&il->mutex); in il4965_mac_channel_switch()
6058 if (test_bit(S_EXIT_PENDING, &il->status) || in il4965_mac_channel_switch()
6059 test_bit(S_SCANNING, &il->status) || in il4965_mac_channel_switch()
6060 test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) in il4965_mac_channel_switch()
6066 if (!il->ops->set_channel_switch) in il4965_mac_channel_switch()
6069 ch = channel->hw_value; in il4965_mac_channel_switch()
6070 if (le16_to_cpu(il->active.channel) == ch) in il4965_mac_channel_switch()
6073 ch_info = il_get_channel_info(il, channel->band, ch); in il4965_mac_channel_switch()
6079 spin_lock_irq(&il->lock); in il4965_mac_channel_switch()
6081 il->current_ht_config.smps = conf->smps_mode; in il4965_mac_channel_switch()
6084 switch (cfg80211_get_chandef_type(&ch_switch->chandef)) { in il4965_mac_channel_switch()
6087 il->ht.is_40mhz = false; in il4965_mac_channel_switch()
6088 il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE; in il4965_mac_channel_switch()
6091 il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW; in il4965_mac_channel_switch()
6092 il->ht.is_40mhz = true; in il4965_mac_channel_switch()
6095 il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE; in il4965_mac_channel_switch()
6096 il->ht.is_40mhz = true; in il4965_mac_channel_switch()
6100 if ((le16_to_cpu(il->staging.channel) != ch)) in il4965_mac_channel_switch()
6101 il->staging.flags = 0; in il4965_mac_channel_switch()
6105 il_set_flags_for_band(il, channel->band, il->vif); in il4965_mac_channel_switch()
6107 spin_unlock_irq(&il->lock); in il4965_mac_channel_switch()
6114 set_bit(S_CHANNEL_SWITCH_PENDING, &il->status); in il4965_mac_channel_switch()
6115 il->switch_channel = cpu_to_le16(ch); in il4965_mac_channel_switch()
6116 if (il->ops->set_channel_switch(il, ch_switch)) { in il4965_mac_channel_switch()
6117 clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status); in il4965_mac_channel_switch()
6118 il->switch_channel = 0; in il4965_mac_channel_switch()
6119 ieee80211_chswitch_done(il->vif, false, 0); in il4965_mac_channel_switch()
6123 mutex_unlock(&il->mutex); in il4965_mac_channel_switch()
6131 struct il_priv *il = hw->priv; in il4965_configure_filter()
6151 mutex_lock(&il->mutex); in il4965_configure_filter()
6153 il->staging.filter_flags &= ~filter_nand; in il4965_configure_filter()
6154 il->staging.filter_flags |= filter_or; in il4965_configure_filter()
6161 mutex_unlock(&il->mutex); in il4965_configure_filter()
6186 mutex_lock(&il->mutex); in il4965_bg_txpower_work()
6192 if (test_bit(S_EXIT_PENDING, &il->status) || in il4965_bg_txpower_work()
6193 test_bit(S_SCANNING, &il->status)) in il4965_bg_txpower_work()
6197 * TX power since frames can be sent on non-radar channels while in il4965_bg_txpower_work()
6199 il->ops->send_tx_power(il); in il4965_bg_txpower_work()
6203 il->last_temperature = il->temperature; in il4965_bg_txpower_work()
6205 mutex_unlock(&il->mutex); in il4965_bg_txpower_work()
6211 il->workqueue = create_singlethread_workqueue(DRV_NAME); in il4965_setup_deferred_work()
6212 if (!il->workqueue) in il4965_setup_deferred_work()
6213 return -ENOMEM; in il4965_setup_deferred_work()
6215 init_waitqueue_head(&il->wait_command_queue); in il4965_setup_deferred_work()
6217 INIT_WORK(&il->restart, il4965_bg_restart); in il4965_setup_deferred_work()
6218 INIT_WORK(&il->rx_replenish, il4965_bg_rx_replenish); in il4965_setup_deferred_work()
6219 INIT_WORK(&il->run_time_calib_work, il4965_bg_run_time_calib_work); in il4965_setup_deferred_work()
6220 INIT_DELAYED_WORK(&il->init_alive_start, il4965_bg_init_alive_start); in il4965_setup_deferred_work()
6221 INIT_DELAYED_WORK(&il->alive_start, il4965_bg_alive_start); in il4965_setup_deferred_work()
6225 INIT_WORK(&il->txpower_work, il4965_bg_txpower_work); in il4965_setup_deferred_work()
6227 timer_setup(&il->stats_periodic, il4965_bg_stats_periodic, 0); in il4965_setup_deferred_work()
6229 timer_setup(&il->watchdog, il_bg_watchdog, 0); in il4965_setup_deferred_work()
6231 tasklet_setup(&il->irq_tasklet, il4965_irq_tasklet); in il4965_setup_deferred_work()
6239 cancel_work_sync(&il->txpower_work); in il4965_cancel_deferred_work()
6240 cancel_delayed_work_sync(&il->init_alive_start); in il4965_cancel_deferred_work()
6241 cancel_delayed_work(&il->alive_start); in il4965_cancel_deferred_work()
6242 cancel_work_sync(&il->run_time_calib_work); in il4965_cancel_deferred_work()
6246 del_timer_sync(&il->stats_periodic); in il4965_cancel_deferred_work()
6271 * Acquire il->lock before calling this function !
6284 int txq_id = txq->q.id; in il4965_tx_queue_set_status()
6286 /* Find out whether to activate Tx queue */ in il4965_tx_queue_set_status()
6287 int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; in il4965_tx_queue_set_status()
6297 txq->sched_retry = scd_retry; in il4965_tx_queue_set_status()
6299 D_INFO("%s %s Queue %d on AC %d\n", active ? "Activate" : "Deactivate", in il4965_tx_queue_set_status()
6336 spin_lock_init(&il->sta_lock); in il4965_init_drv()
6337 spin_lock_init(&il->hcmd_lock); in il4965_init_drv()
6339 INIT_LIST_HEAD(&il->free_frames); in il4965_init_drv()
6341 mutex_init(&il->mutex); in il4965_init_drv()
6343 il->ieee_channels = NULL; in il4965_init_drv()
6344 il->ieee_rates = NULL; in il4965_init_drv()
6345 il->band = NL80211_BAND_2GHZ; in il4965_init_drv()
6347 il->iw_mode = NL80211_IFTYPE_STATION; in il4965_init_drv()
6348 il->current_ht_config.smps = IEEE80211_SMPS_STATIC; in il4965_init_drv()
6349 il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; in il4965_init_drv()
6352 il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; in il4965_init_drv()
6355 if (il->ops->set_rxon_chain) in il4965_init_drv()
6356 il->ops->set_rxon_chain(il); in il4965_init_drv()
6371 il4965_init_hw_rates(il, il->ieee_rates); in il4965_init_drv()
6386 kfree(il->scan_cmd); in il4965_uninit_drv()
6392 il->hw_rev = _il_rd(il, CSR_HW_REV); in il4965_hw_detect()
6393 il->hw_wa_rev = _il_rd(il, CSR_HW_REV_WA_REG); in il4965_hw_detect()
6394 il->rev_id = il->pci_dev->revision; in il4965_hw_detect()
6395 D_INFO("HW Revision ID = 0x%X\n", il->rev_id); in il4965_hw_detect()
6428 il->hw_params.bcast_id = IL4965_BROADCAST_ID; in il4965_set_hw_params()
6429 il->hw_params.max_rxq_size = RX_QUEUE_SIZE; in il4965_set_hw_params()
6430 il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; in il4965_set_hw_params()
6431 if (il->cfg->mod_params->amsdu_size_8K) in il4965_set_hw_params()
6432 il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); in il4965_set_hw_params()
6434 il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); in il4965_set_hw_params()
6436 il->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; in il4965_set_hw_params()
6438 if (il->cfg->mod_params->disable_11n) in il4965_set_hw_params()
6439 il->cfg->sku &= ~IL_SKU_N; in il4965_set_hw_params()
6441 if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && in il4965_set_hw_params()
6442 il->cfg->mod_params->num_of_queues <= IL49_NUM_QUEUES) in il4965_set_hw_params()
6443 il->cfg->num_of_queues = in il4965_set_hw_params()
6444 il->cfg->mod_params->num_of_queues; in il4965_set_hw_params()
6446 il->hw_params.max_txq_num = il->cfg->num_of_queues; in il4965_set_hw_params()
6447 il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; in il4965_set_hw_params()
6448 il->hw_params.scd_bc_tbls_size = in il4965_set_hw_params()
6449 il->cfg->num_of_queues * in il4965_set_hw_params()
6452 il->hw_params.tfd_size = sizeof(struct il_tfd); in il4965_set_hw_params()
6453 il->hw_params.max_stations = IL4965_STATION_COUNT; in il4965_set_hw_params()
6454 il->hw_params.max_data_size = IL49_RTC_DATA_SIZE; in il4965_set_hw_params()
6455 il->hw_params.max_inst_size = IL49_RTC_INST_SIZE; in il4965_set_hw_params()
6456 il->hw_params.max_bsm_size = BSM_SRAM_SIZE; in il4965_set_hw_params()
6457 il->hw_params.ht40_channel = BIT(NL80211_BAND_5GHZ); in il4965_set_hw_params()
6459 il->hw_params.rx_wrt_ptr_reg = FH49_RSCSR_CHNL0_WPTR; in il4965_set_hw_params()
6461 il->hw_params.tx_chains_num = il4965_num_of_ant(il->cfg->valid_tx_ant); in il4965_set_hw_params()
6462 il->hw_params.rx_chains_num = il4965_num_of_ant(il->cfg->valid_rx_ant); in il4965_set_hw_params()
6463 il->hw_params.valid_tx_ant = il->cfg->valid_tx_ant; in il4965_set_hw_params()
6464 il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; in il4965_set_hw_params()
6466 il->hw_params.ct_kill_threshold = in il4965_set_hw_params()
6469 il->hw_params.sens = &il4965_sensitivity; in il4965_set_hw_params()
6470 il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; in il4965_set_hw_params()
6479 struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); in il4965_pci_probe()
6489 err = -ENOMEM; in il4965_pci_probe()
6492 il = hw->priv; in il4965_pci_probe()
6493 il->hw = hw; in il4965_pci_probe()
6494 SET_IEEE80211_DEV(hw, &pdev->dev); in il4965_pci_probe()
6497 il->cfg = cfg; in il4965_pci_probe()
6498 il->ops = &il4965_ops; in il4965_pci_probe()
6500 il->debugfs_ops = &il4965_debugfs_ops; in il4965_pci_probe()
6502 il->pci_dev = pdev; in il4965_pci_probe()
6503 il->inta_mask = CSR_INI_SET_MASK; in il4965_pci_probe()
6513 err = -ENODEV; in il4965_pci_probe()
6519 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(36)); in il4965_pci_probe()
6521 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in il4965_pci_probe()
6538 il->hw_base = pci_ioremap_bar(pdev, 0); in il4965_pci_probe()
6539 if (!il->hw_base) { in il4965_pci_probe()
6540 err = -ENODEV; in il4965_pci_probe()
6546 D_INFO("pci_resource_base = %p\n", il->hw_base); in il4965_pci_probe()
6551 spin_lock_init(&il->reg_lock); in il4965_pci_probe()
6552 spin_lock_init(&il->lock); in il4965_pci_probe()
6555 * stop and reset the on-board processor just in case it is in a in il4965_pci_probe()
6562 IL_INFO("Detected %s, REV=0x%X\n", il->cfg->name, il->hw_rev); in il4965_pci_probe()
6569 if (!il->hw_ready) { in il4965_pci_probe()
6571 err = -EIO; in il4965_pci_probe()
6589 il4965_eeprom_get_mac(il, il->addresses[0].addr); in il4965_pci_probe()
6590 D_INFO("MAC address: %pM\n", il->addresses[0].addr); in il4965_pci_probe()
6591 il->hw->wiphy->addresses = il->addresses; in il4965_pci_probe()
6592 il->hw->wiphy->n_addresses = 1; in il4965_pci_probe()
6611 spin_lock_irqsave(&il->lock, flags); in il4965_pci_probe()
6613 spin_unlock_irqrestore(&il->lock, flags); in il4965_pci_probe()
6615 pci_enable_msi(il->pci_dev); in il4965_pci_probe()
6617 err = request_irq(il->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, il); in il4965_pci_probe()
6619 IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); in il4965_pci_probe()
6634 pci_read_config_word(il->pci_dev, PCI_COMMAND, &pci_cmd); in il4965_pci_probe()
6637 pci_write_config_word(il->pci_dev, PCI_COMMAND, pci_cmd); in il4965_pci_probe()
6644 clear_bit(S_RFKILL, &il->status); in il4965_pci_probe()
6646 set_bit(S_RFKILL, &il->status); in il4965_pci_probe()
6648 wiphy_rfkill_set_hw_state(il->hw->wiphy, in il4965_pci_probe()
6649 test_bit(S_RFKILL, &il->status)); in il4965_pci_probe()
6653 init_completion(&il->_4965.firmware_loading_complete); in il4965_pci_probe()
6662 destroy_workqueue(il->workqueue); in il4965_pci_probe()
6663 il->workqueue = NULL; in il4965_pci_probe()
6665 free_irq(il->pci_dev->irq, il); in il4965_pci_probe()
6667 pci_disable_msi(il->pci_dev); in il4965_pci_probe()
6672 iounmap(il->hw_base); in il4965_pci_probe()
6678 ieee80211_free_hw(il->hw); in il4965_pci_probe()
6692 wait_for_completion(&il->_4965.firmware_loading_complete); in il4965_pci_remove()
6697 sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); in il4965_pci_remove()
6703 set_bit(S_EXIT_PENDING, &il->status); in il4965_pci_remove()
6707 if (il->mac80211_registered) { in il4965_pci_remove()
6708 ieee80211_unregister_hw(il->hw); in il4965_pci_remove()
6709 il->mac80211_registered = 0; in il4965_pci_remove()
6726 spin_lock_irqsave(&il->lock, flags); in il4965_pci_remove()
6728 spin_unlock_irqrestore(&il->lock, flags); in il4965_pci_remove()
6734 if (il->rxq.bd) in il4965_pci_remove()
6735 il4965_rx_queue_free(il, &il->rxq); in il4965_pci_remove()
6743 * il->workqueue... so we can't take down the workqueue in il4965_pci_remove()
6745 destroy_workqueue(il->workqueue); in il4965_pci_remove()
6746 il->workqueue = NULL; in il4965_pci_remove()
6748 free_irq(il->pci_dev->irq, il); in il4965_pci_remove()
6749 pci_disable_msi(il->pci_dev); in il4965_pci_remove()
6750 iounmap(il->hw_base); in il4965_pci_remove()
6756 dev_kfree_skb(il->beacon_skb); in il4965_pci_remove()
6758 ieee80211_free_hw(il->hw); in il4965_pci_remove()
6763 * must be called under il->lock and mac access