30 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
32 #include <linux/kernel.h>
33 #include <linux/module.h>
35 #include <linux/pci.h>
37 #include <linux/slab.h>
40 #include <linux/sched.h>
42 #include <linux/netdevice.h>
45 #include <linux/if_arp.h>
49 #include <asm/div64.h>
51 #define DRV_NAME "iwl4965"
65 #define DRV_DESCRIPTION "Intel(R) Wireless WiFi 4965 driver for Linux"
67 #ifdef CONFIG_IWLEGACY_DEBUG
73 #define DRV_VERSION IWLWIFI_VERSION VD
85 IL_ERR(
"Tx flush command to flush out all frames\n");
116 __il_free_pages(il, rxq->
pool[i].page);
130 spin_unlock_irqrestore(&rxq->
lock, flags);
140 if (il->
cfg->mod_params->amsdu_size_8K)
178 il4965_set_pwr_vmain(
struct il_priv *il)
206 spin_unlock_irqrestore(&il->
lock, flags);
208 il4965_set_pwr_vmain(il);
215 IL_ERR(
"Unable to initialize Rx queue\n");
230 spin_unlock_irqrestore(&il->
lock, flags);
286 il4965_dma_addr2rbd_ptr(il, rxb->
page_dma);
291 spin_unlock_irqrestore(&rxq->
lock, flags);
302 spin_unlock_irqrestore(&rxq->
lock, flags);
327 if (list_empty(&rxq->
rx_used)) {
328 spin_unlock_irqrestore(&rxq->
lock, flags);
331 spin_unlock_irqrestore(&rxq->
lock, flags);
343 D_INFO(
"alloc_pages failed, " "order: %d\n",
348 IL_ERR(
"Failed to alloc_pages with %s. "
349 "Only %u free buffers remaining.\n",
361 if (list_empty(&rxq->
rx_used)) {
362 spin_unlock_irqrestore(&rxq->
lock, flags);
370 spin_unlock_irqrestore(&rxq->
lock, flags);
376 pci_map_page(il->
pci_dev, page, 0,
390 spin_unlock_irqrestore(&rxq->
lock, flags);
403 spin_unlock_irqrestore(&il->
lock, flags);
428 __il_free_pages(il, rxq->
pool[i].page);
452 IL_ERR(
"Can't stop Rx DMA.\n");
465 idx = (rate_n_flags & 0xff);
472 if (
il_rates[idx].plcp == (rate_n_flags & 0xFF))
473 return idx - band_offset;
501 for (i = 0; i < 3; i++)
502 if (valid_antennae & (1 << i))
505 D_STATS(
"Rssi In A %d B %d C %d Max %d AGC dB %d\n",
515 il4965_translate_rx_status(
struct il_priv *il,
u32 decrypt_in)
520 RX_RES_STATUS_STATION_FOUND)
522 (RX_RES_STATUS_STATION_FOUND |
533 if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==
542 switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) {
569 D_RX(
"decrypt_in:0x%x decrypt_out = 0x%x\n", decrypt_in, decrypt_out);
584 D_DROP(
"Dropping packet while interface is not open.\n");
589 if (!il->
cfg->mod_params->sw_crypto &&
593 skb = dev_alloc_skb(128);
595 IL_ERR(
"dev_alloc_skb failed\n");
603 memcpy(IEEE80211_SKB_RXCB(skb), stats,
sizeof(*stats));
646 if (!il->_4965.last_phy_res_valid) {
647 IL_ERR(
"MPDU frame without cached PHY data\n");
650 phy_res = &il->_4965.last_phy_res;
654 rx_pkt_status = *(
__le32 *) (pkt->
u.
raw +
sizeof(*amsdu) + len);
656 il4965_translate_rx_status(il,
le32_to_cpu(rx_pkt_status));
660 D_DROP(
"dsp size out of range [0,20]: %d/n",
694 rx_status.
signal = il4965_calc_rssi(il, phy_res);
697 (
unsigned long long)rx_status.
mactime);
728 il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, rxb,
738 il->_4965.last_phy_res_valid =
true;
751 u16 passive_dwell = 0;
752 u16 active_dwell = 0;
756 sband = il_get_hw_mode(il, band);
763 if (passive_dwell <= active_dwell)
764 passive_dwell = active_dwell + 1;
766 for (i = 0, added = 0; i < il->
scan_request->n_channels; i++) {
769 if (chan->
band != band)
776 if (!il_is_channel_valid(ch_info)) {
777 D_SCAN(
"Channel %d is INVALID for this band.\n",
782 if (!is_active || il_is_channel_passive(ch_info) ||
802 scan_ch->
tx_gain = ((1 << 5) | (3 << 3)) | 3;
804 scan_ch->
tx_gain = ((1 << 5) | (5 << 3));
806 D_SCAN(
"Scanning ch=%d prob=0x%X [%s %d]\n", channel,
811 type & SCAN_CHANNEL_TYPE_ACTIVE) ? active_dwell :
818 D_SCAN(
"total channels to scan %d\n", added);
829 ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0;
830 if (valid &
BIT(ind)) {
853 bool is_active =
false;
866 D_SCAN(
"fail to allocate memory for scan\n");
876 if (il_is_any_associated(il)) {
880 u32 scan_suspend_time = 100;
882 D_INFO(
"Scanning while associated...\n");
883 interval = vif->
bss_conf.beacon_int;
890 extra = (suspend_time /
interval) << 22;
892 (extra | ((suspend_time %
interval) * 1024));
894 D_SCAN(
"suspend_time 0x%X beacon interval %d\n",
895 scan_suspend_time, interval);
900 D_SCAN(
"Kicking off active scan\n");
916 D_SCAN(
"Start passive scan.\n");
939 IL_WARN(
"Invalid scan band\n");
965 if (il->
cfg->scan_rx_antennas[band])
966 rx_ant = il->
cfg->scan_rx_antennas[band];
968 il4965_toggle_tx_ant(il, &il->
scan_tx_ant[band], scan_tx_antennas);
978 active_chains = rx_ant;
980 D_SCAN(
"chain_noise_data.active_chains: %u\n",
983 rx_ant = il4965_first_antenna(active_chains);
1004 il4965_get_channels_for_scan(il, vif, band, is_active, n_probes,
1005 (
void *)&scan->
data[cmd_len]);
1030 struct il_vif_priv *vif_priv = (
void *)vif->drv_priv;
1044 if (il->
stations[sta_id].tid[tid].tfds_in_queue >= freed)
1045 il->
stations[sta_id].tid[tid].tfds_in_queue -= freed;
1047 D_TX(
"free more than tfds_in_queue (%u:%d)\n",
1048 il->
stations[sta_id].tid[tid].tfds_in_queue, freed);
1049 il->
stations[sta_id].tid[tid].tfds_in_queue = 0;
1053 #define IL_TX_QUEUE_MSK 0xfffff
1056 il4965_is_single_rx_stream(
struct il_priv *il)
1062 #define IL_NUM_RX_CHAINS_MULTIPLE 3
1063 #define IL_NUM_RX_CHAINS_SINGLE 2
1064 #define IL_NUM_IDLE_CHAINS_DUAL 2
1065 #define IL_NUM_IDLE_CHAINS_SINGLE 1
1078 il4965_get_active_rx_chain_count(
struct il_priv *il)
1081 if (il4965_is_single_rx_stream(il))
1092 il4965_get_idle_rx_chain_count(
struct il_priv *il,
int active_cnt)
1109 il4965_count_chain_bitmap(
u32 chain_bitmap)
1112 res = (chain_bitmap &
BIT(0)) >> 0;
1113 res += (chain_bitmap &
BIT(1)) >> 1;
1114 res += (chain_bitmap &
BIT(2)) >> 2;
1115 res += (chain_bitmap &
BIT(3)) >> 3;
1128 bool is_single = il4965_is_single_rx_stream(il);
1130 u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt;
1141 active_chains = il->
hw_params.valid_rx_ant;
1146 active_rx_cnt = il4965_get_active_rx_chain_count(il);
1147 idle_rx_cnt = il4965_get_idle_rx_chain_count(il, active_rx_cnt);
1152 valid_rx_cnt = il4965_count_chain_bitmap(active_chains);
1153 if (valid_rx_cnt < active_rx_cnt)
1154 active_rx_cnt = valid_rx_cnt;
1156 if (valid_rx_cnt < idle_rx_cnt)
1157 idle_rx_cnt = valid_rx_cnt;
1169 D_ASSOC(
"rx_chain=0x%X active=%d idle=%d\n", il->
staging.rx_chain,
1170 active_rx_cnt, idle_rx_cnt);
1172 WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 ||
1173 active_rx_cnt < idle_rx_cnt);
1177 il4965_get_fh_string(
int cmd)
1198 #ifdef CONFIG_IWLEGACY_DEBUG
1202 static const u32 fh_tbl[] = {
1213 #ifdef CONFIG_IWLEGACY_DEBUG
1220 scnprintf(*buf + pos, bufsz - pos,
"FH register values:\n");
1225 il4965_get_fh_string(fh_tbl[i]),
1226 il_rd(il, fh_tbl[i]));
1231 IL_ERR(
"FH register values:\n");
1233 IL_ERR(
" %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]),
1234 il_rd(il, fh_tbl[i]));
1248 D_CALIB(
"missed bcn cnsq %d totl %d rcd %d expctd %d\n",
1262 il4965_rx_calc_noise(
struct il_priv *il)
1265 int num_active_rx = 0;
1266 int total_silence = 0;
1267 int bcn_silence_a, bcn_silence_b, bcn_silence_c;
1270 rx_info = &(il->_4965.stats.rx.general);
1278 if (bcn_silence_a) {
1279 total_silence += bcn_silence_a;
1282 if (bcn_silence_b) {
1283 total_silence += bcn_silence_b;
1286 if (bcn_silence_c) {
1287 total_silence += bcn_silence_c;
1293 last_rx_noise = (total_silence / num_active_rx) - 107;
1297 D_CALIB(
"inband silence a %u, b %u, c %u, dBm %d\n", bcn_silence_a,
1298 bcn_silence_b, bcn_silence_c, last_rx_noise);
1301 #ifdef CONFIG_IWLEGACY_DEBUGFS
1308 il4965_accumulative_stats(
struct il_priv *il,
__le32 * stats)
1317 prev_stats = (
__le32 *) &il->_4965.stats;
1318 accum_stats = (
u32 *) &il->_4965.accum_stats;
1320 general = &il->_4965.stats.general.common;
1321 accum_general = &il->_4965.accum_stats.general.common;
1322 tx = &il->_4965.stats.tx;
1323 accum_tx = &il->_4965.accum_stats.tx;
1324 delta = (
u32 *) &il->_4965.delta_stats;
1325 max_delta = (
u32 *) &il->_4965.max_delta;
1329 sizeof(
__le32), stats++, prev_stats++, delta++, max_delta++,
1334 *accum_stats += *
delta;
1335 if (*delta > *max_delta)
1336 *max_delta = *
delta;
1349 const int recalib_seconds = 60;
1353 D_RX(
"Statistics notification received (%d vs %d).\n",
1359 pkt->
u.
stats.general.common.temperature) ||
1362 #ifdef CONFIG_IWLEGACY_DEBUGFS
1363 il4965_accumulative_stats(il, (
__le32 *) &pkt->
u.
stats);
1367 memcpy(&il->_4965.stats, &pkt->
u.
stats,
sizeof(il->_4965.stats));
1380 il4965_rx_calc_noise(il);
1394 #ifdef CONFIG_IWLEGACY_DEBUGFS
1395 memset(&il->_4965.accum_stats, 0,
1397 memset(&il->_4965.delta_stats, 0,
1401 D_RX(
"Statistics have been cleared\n");
1433 static const u8 tid_to_ac[] = {
1445 il4965_get_ac_from_tid(
u16 tid)
1448 return tid_to_ac[tid];
1455 il4965_get_fifo_from_tid(
u16 tid)
1457 const u8 ac_to_fifo[] = {
1465 return ac_to_fifo[tid_to_ac[tid]];
1475 il4965_tx_cmd_build_basic(
struct il_priv *il,
struct sk_buff *skb,
1486 if (ieee80211_is_mgmt(fc))
1488 if (ieee80211_is_probe_resp(fc) &&
1496 if (ieee80211_is_back_req(fc))
1500 if (ieee80211_has_morefrags(fc))
1503 if (ieee80211_is_data_qos(fc)) {
1504 u8 *qc = ieee80211_get_qos_ctl(hdr);
1514 if (ieee80211_is_mgmt(fc)) {
1515 if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc))
1529 il4965_tx_cmd_build_rate(
struct il_priv *il,
1535 const u8 rts_retry_limit = 60;
1538 u8 data_retry_limit;
1542 if (ieee80211_is_probe_resp(fc))
1543 data_retry_limit = 3;
1552 if (ieee80211_is_data(fc)) {
1564 rate_idx = info->
control.rates[0].idx;
1567 rate_idx = rate_lowest_index(&il->
bands[info->
band], sta);
1572 rate_plcp =
il_rates[rate_idx].plcp;
1595 switch (keyconf->
cipher) {
1601 D_TX(
"tx_cmd with AES hwcrypto\n");
1607 D_TX(
"tx_cmd with tkip hwcrypto\n");
1620 D_TX(
"Configuring packet for WEP encryption " "with key %d\n",
1650 u16 len, firstlen, secondlen;
1655 u8 wait_write_ptr = 0;
1658 unsigned long flags;
1659 bool is_agg =
false;
1662 if (il_is_rfkill(il)) {
1663 D_DROP(
"Dropping - RF KILL\n");
1669 #ifdef CONFIG_IWLEGACY_DEBUG
1670 if (ieee80211_is_auth(fc))
1671 D_TX(
"Sending AUTH frame\n");
1672 else if (ieee80211_is_assoc_req(fc))
1673 D_TX(
"Sending ASSOC frame\n");
1674 else if (ieee80211_is_reassoc_req(fc))
1675 D_TX(
"Sending REASSOC frame\n");
1681 if (!ieee80211_is_data(fc))
1685 sta_id = il_sta_id_or_broadcast(il, sta);
1688 D_DROP(
"Dropping - INVALID STATION: %pM\n", hdr->
addr1);
1693 D_TX(
"station Id %d\n", sta_id);
1696 sta_priv = (
void *)sta->drv_priv;
1698 if (sta_priv && sta_priv->
asleep &&
1716 txq_id = skb_get_queue_mapping(skb);
1721 if (ieee80211_is_data_qos(fc)) {
1722 qc = ieee80211_get_qos_ctl(hdr);
1742 txq = &il->
txq[txq_id];
1750 if (ieee80211_is_data_qos(fc)) {
1752 if (!ieee80211_has_morefrags(fc))
1763 tx_cmd = &out_cmd->
cmd.
tx;
1774 out_cmd->
hdr.sequence =
1786 il4965_tx_cmd_build_hwcrypto(il, info, tx_cmd, skb, sta_id);
1789 il4965_tx_cmd_build_basic(il, skb, tx_cmd, info, hdr, sta_id);
1791 il4965_tx_cmd_build_rate(il, tx_cmd, info, sta, fc);
1803 len =
sizeof(
struct il_tx_cmd) + sizeof(struct il_cmd_header) + hdr_len;
1804 firstlen = (len + 3) & ~3;
1807 if (firstlen != len)
1813 pci_map_single(il->
pci_dev, &out_cmd->
hdr, firstlen,
1819 il->
ops->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0);
1831 if (secondlen > 0) {
1833 pci_map_single(il->
pci_dev, skb->
data + hdr_len, secondlen,
1835 il->
ops->txq_attach_buf_to_tfd(il, txq, phys_addr, secondlen,
1840 txcmd_phys +
sizeof(
struct il_cmd_header) +
1841 offsetof(struct il_tx_cmd, scratch);
1844 pci_dma_sync_single_for_cpu(il->
pci_dev, txcmd_phys, firstlen,
1847 tx_cmd->
dram_msb_ptr = il_get_dma_hi_addr(scratch_phys);
1851 il_print_hex_dump(il,
IL_DL_TX, (
u8 *) tx_cmd,
sizeof(*tx_cmd));
1852 il_print_hex_dump(il,
IL_DL_TX, (
u8 *) tx_cmd->
hdr, hdr_len);
1858 pci_dma_sync_single_for_device(il->
pci_dev, txcmd_phys, firstlen,
1864 spin_unlock_irqrestore(&il->
lock, flags);
1880 if (sta_priv && sta_priv->
client && !is_agg)
1884 if (wait_write_ptr) {
1888 spin_unlock_irqrestore(&il->
lock, flags);
1890 il_stop_queue(il, txq);
1897 spin_unlock_irqrestore(&il->
lock, flags);
1919 memset(ptr, 0,
sizeof(*ptr));
1934 for (txq_id = 0; txq_id < il->
hw_params.max_txq_num; txq_id++)
1940 il4965_free_dma_ptr(il, &il->
kw);
1959 unsigned long flags;
1968 IL_ERR(
"Scheduler BC Table allocation failed\n");
1974 IL_ERR(
"Keep Warm allocation failed\n");
1991 spin_unlock_irqrestore(&il->
lock, flags);
1994 for (txq_id = 0; txq_id < il->
hw_params.max_txq_num; txq_id++) {
1997 IL_ERR(
"Tx %d queue init failed\n", txq_id);
2006 il4965_free_dma_ptr(il, &il->
kw);
2017 unsigned long flags;
2026 spin_unlock_irqrestore(&il->
lock, flags);
2029 for (txq_id = 0; txq_id < il->
hw_params.max_txq_num; txq_id++)
2042 for (txq_id = 0; txq_id < il->
hw_params.max_txq_num; txq_id++)
2060 for (ch = 0; ch < il->
hw_params.dma_chnl_num; ch++) {
2068 IL_ERR(
"Timeout stopping DMA channel %d [0x%08x]",
2080 il4965_txq_ctx_activate_free(
struct il_priv *il)
2084 for (txq_id = 0; txq_id < il->
hw_params.max_txq_num; txq_id++)
2094 il4965_tx_queue_stop_scheduler(
struct il_priv *il,
u16 txq_id)
2107 il4965_tx_queue_set_q2ratid(
struct il_priv *il,
u16 ra_tid,
u16 txq_id)
2121 tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF);
2123 tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000);
2137 il4965_txq_agg_enable(
struct il_priv *il,
int txq_id,
int tx_fifo,
int sta_id,
2138 int tid,
u16 ssn_idx)
2140 unsigned long flags;
2146 il->
cfg->num_of_ampdu_queues <= txq_id)) {
2147 IL_WARN(
"queue number out of range: %d, must be %d to %d\n",
2150 il->
cfg->num_of_ampdu_queues - 1);
2164 il4965_tx_queue_stop_scheduler(il, txq_id);
2167 il4965_tx_queue_set_q2ratid(il, ra_tid, txq_id);
2174 il->
txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
2175 il->
txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
2197 spin_unlock_irqrestore(&il->
lock, flags);
2210 unsigned long flags;
2214 tx_fifo = il4965_get_fifo_from_tid(tid);
2218 D_HT(
"%s on ra = %pM tid = %d\n", __func__, sta->
addr, tid);
2220 sta_id = il_sta_id(sta);
2222 IL_ERR(
"Start AGG on invalid station\n");
2229 IL_ERR(
"Start AGG when state is not IL_AGG_OFF !\n");
2233 txq_id = il4965_txq_ctx_activate_free(il);
2235 IL_ERR(
"No free aggregation queue available\n");
2240 tid_data = &il->
stations[sta_id].tid[tid];
2242 tid_data->
agg.txq_id = txq_id;
2243 il_set_swq_id(&il->
txq[txq_id], il4965_get_ac_from_tid(tid), txq_id);
2244 spin_unlock_irqrestore(&il->
sta_lock, flags);
2246 ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, sta_id, tid, *ssn);
2251 tid_data = &il->
stations[sta_id].tid[tid];
2253 D_HT(
"HW queue is empty\n");
2257 D_HT(
"HW queue is NOT empty: %d packets in HW queue\n",
2261 spin_unlock_irqrestore(&il->
sta_lock, flags);
2270 il4965_txq_agg_disable(
struct il_priv *il,
u16 txq_id,
u16 ssn_idx,
u8 tx_fifo)
2274 il->
cfg->num_of_ampdu_queues <= txq_id)) {
2275 IL_WARN(
"queue number out of range: %d, must be %d to %d\n",
2278 il->
cfg->num_of_ampdu_queues - 1);
2282 il4965_tx_queue_stop_scheduler(il, txq_id);
2286 il->
txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
2287 il->
txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
2292 il_txq_ctx_deactivate(il, txq_id);
2302 int tx_fifo_id, txq_id, sta_id,
ssn;
2304 int write_ptr, read_ptr;
2305 unsigned long flags;
2308 tx_fifo_id = il4965_get_fifo_from_tid(tid);
2312 sta_id = il_sta_id(sta);
2315 IL_ERR(
"Invalid station for AGG tid %d\n", tid);
2321 tid_data = &il->
stations[sta_id].tid[tid];
2323 txq_id = tid_data->
agg.txq_id;
2325 switch (il->
stations[sta_id].tid[tid].agg.state) {
2333 D_HT(
"AGG stop before setup done\n");
2338 IL_WARN(
"Stopping AGG while state not ON or starting\n");
2341 write_ptr = il->
txq[txq_id].q.write_ptr;
2342 read_ptr = il->
txq[txq_id].q.read_ptr;
2345 if (write_ptr != read_ptr) {
2346 D_HT(
"Stopping a non empty AGG HW QUEUE\n");
2347 il->
stations[sta_id].tid[tid].agg.state =
2349 spin_unlock_irqrestore(&il->
sta_lock, flags);
2353 D_HT(
"HW queue is empty\n");
2359 spin_lock(&il->
lock);
2368 il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo_id);
2369 spin_unlock_irqrestore(&il->
lock, flags);
2385 switch (il->
stations[sta_id].tid[tid].agg.state) {
2389 if (txq_id == tid_data->
agg.txq_id &&
2392 int tx_fifo = il4965_get_fifo_from_tid(tid);
2393 D_HT(
"HW queue empty: continue DELBA flow\n");
2394 il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo);
2402 D_HT(
"HW queue empty: continue ADDBA flow\n");
2421 sta_priv = (
void *)sta->drv_priv;
2431 il4965_tx_status(
struct il_priv *il,
struct sk_buff *skb,
bool is_agg)
2436 il4965_non_agg_tx_status(il, hdr->
addr1);
2450 if (idx >= q->
n_bd || il_queue_used(q, idx) == 0) {
2451 IL_ERR(
"Read idx for DMA queue txq id (%d), idx %d, "
2452 "is out of range [0-%d] %d %d.\n", txq_id, idx, q->
n_bd,
2457 for (idx = il_queue_inc_wrap(idx, q->
n_bd); q->
read_ptr != idx;
2460 skb = txq->
skbs[txq->
q.read_ptr];
2472 il->
ops->txq_free_tfd(il, txq);
2484 il4965_tx_status_reply_compressed_ba(
struct il_priv *il,
struct il_ht_agg *agg,
2496 IL_ERR(
"Received BA when not expected\n");
2519 sent_bitmap = bitmap & agg->
bitmap;
2524 while (sent_bitmap) {
2525 ack = sent_bitmap & 1ULL;
2527 D_TX_REPLY(
"%s ON i=%d idx=%d raw=%d\n", ack ?
"ACK" :
"NACK",
2533 D_TX_REPLY(
"Bitmap %llx\n", (
unsigned long long)bitmap);
2535 info = IEEE80211_SKB_CB(il->
txq[scd_flow].skbs[agg->
start_idx]);
2539 info->
status.ampdu_ack_len = successes;
2559 unsigned long flags;
2564 if (is_broadcast_ether_addr(addr))
2568 for (i = start; i < il->
hw_params.max_stations; i++)
2570 ether_addr_equal(il->
stations[i].sta.sta.addr, addr)) {
2585 ((il->
stations[ret].used & IL_STA_UCODE_ACTIVE) &&
2587 IL_ERR(
"Requested station info for sta %d before ready.\n",
2591 spin_unlock_irqrestore(&il->
sta_lock, flags);
2601 u8 *
da = ieee80211_get_DA(hdr);
2603 return il4965_find_station(il, da);
2614 il4965_tx_status_to_mac80211(
u32 status)
2645 D_TX_REPLY(
"got tx response w/o block-ack\n");
2658 D_TX_REPLY(
"FrameCnt = %d, StartIdx=%d idx=%d\n",
2661 info = IEEE80211_SKB_CB(il->
txq[txq_id].skbs[idx]);
2664 info->
flags |= il4965_tx_status_to_mac80211(status);
2667 D_TX_REPLY(
"1 Frame 0x%x failure :%d\n", status & 0xff,
2669 D_TX_REPLY(
"Rate Info rate_n_flags=%x\n", rate_n_flags);
2691 D_TX_REPLY(
"FrameCnt = %d, txq_id=%d idx=%d\n",
2694 skb = il->
txq[txq_id].skbs[
idx];
2701 IL_ERR(
"BUG_ON idx doesn't match seq control"
2702 " idx=%d, seq_idx=%d, seq=%d\n", idx,
2707 D_TX_REPLY(
"AGG Frame i=%d idx %d seq=%d\n", i, idx,
2712 sh = (start -
idx) + 0xff;
2713 bitmap = bitmap << sh;
2716 }
else if (sh < -64)
2717 sh = 0xff - (start -
idx);
2721 bitmap = bitmap << sh;
2724 bitmap |= 1ULL << sh;
2725 D_TX_REPLY(
"start=%d bitmap=0x%llx\n", start,
2726 (
unsigned long long)bitmap);
2731 D_TX_REPLY(
"Frames %d start_idx=%d bitmap=0x%llx\n",
2733 (
unsigned long long)agg->
bitmap);
2761 unsigned long flags;
2763 if (idx >= txq->
q.n_bd || il_queue_used(&txq->
q, idx) == 0) {
2764 IL_ERR(
"Read idx for DMA queue txq_id (%d) idx %d "
2765 "is out of range [0-%d] %d %d\n", txq_id, idx,
2766 txq->
q.n_bd, txq->
q.write_ptr, txq->
q.read_ptr);
2772 skb = txq->
skbs[txq->
q.read_ptr];
2773 info = IEEE80211_SKB_CB(skb);
2778 qc = ieee80211_get_qos_ctl(hdr);
2782 sta_id = il4965_get_ra_sta_id(il, hdr);
2784 IL_ERR(
"Station not known\n");
2790 const u32 scd_ssn = il4965_get_scd_ssn(tx_resp);
2794 agg = &il->
stations[sta_id].tid[tid].agg;
2796 il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx);
2800 !il4965_is_tx_success(status))
2803 if (txq->
q.read_ptr != (scd_ssn & 0xff)) {
2804 idx = il_queue_dec_wrap(scd_ssn & 0xff, txq->
q.n_bd);
2805 D_TX_REPLY(
"Retry scheduler reclaim scd_ssn "
2806 "%d idx %d\n", scd_ssn, idx);
2815 il_wake_queue(il, txq);
2819 info->
flags |= il4965_tx_status_to_mac80211(status);
2825 "rate_n_flags 0x%x retries %d\n", txq_id,
2826 il4965_get_tx_fail_reason(status), status,
2838 il_wake_queue(il, txq);
2845 spin_unlock_irqrestore(&il->
sta_lock, flags);
2888 unsigned long flags;
2897 if (scd_flow >= il->
hw_params.max_txq_num) {
2898 IL_ERR(
"BUG_ON scd_flow is bigger than number of queues\n");
2902 txq = &il->
txq[scd_flow];
2903 sta_id = ba_resp->
sta_id;
2905 agg = &il->
stations[sta_id].tid[tid].agg;
2913 D_TX_REPLY(
"BA scd_flow %d does not match txq_id %d\n",
2919 idx = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->
q.n_bd);
2923 D_TX_REPLY(
"N_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n",
2926 D_TX_REPLY(
"TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = "
2927 "%d, scd_ssn = %d\n", ba_resp->
tid, ba_resp->
seq_ctl,
2931 (
unsigned long long)agg->
bitmap);
2934 il4965_tx_status_reply_compressed_ba(il, agg, ba_resp);
2939 if (txq->
q.read_ptr != (ba_resp_scd_ssn & 0xff)) {
2947 il_wake_queue(il, txq);
2952 spin_unlock_irqrestore(&il->
sta_lock, flags);
2955 #ifdef CONFIG_IWLEGACY_DEBUG
2957 il4965_get_tx_fail_reason(
u32 status)
2959 #define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x
2960 #define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x
2965 TX_STATUS_POSTPONE(
DELAY);
2966 TX_STATUS_POSTPONE(FEW_BYTES);
2967 TX_STATUS_POSTPONE(QUIET_PERIOD);
2968 TX_STATUS_POSTPONE(CALC_TTAK);
2969 TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY);
2970 TX_STATUS_FAIL(SHORT_LIMIT);
2971 TX_STATUS_FAIL(LONG_LIMIT);
2972 TX_STATUS_FAIL(FIFO_UNDERRUN);
2973 TX_STATUS_FAIL(DRAIN_FLOW);
2974 TX_STATUS_FAIL(RFKILL_FLUSH);
2975 TX_STATUS_FAIL(LIFE_EXPIRE);
2976 TX_STATUS_FAIL(DEST_PS);
2978 TX_STATUS_FAIL(BT_RETRY);
2979 TX_STATUS_FAIL(STA_INVALID);
2980 TX_STATUS_FAIL(FRAG_DROPPED);
2981 TX_STATUS_FAIL(TID_DISABLE);
2982 TX_STATUS_FAIL(FIFO_FLUSHED);
2983 TX_STATUS_FAIL(INSUFFICIENT_CF_POLL);
2984 TX_STATUS_FAIL(PASSIVE_NO_RX);
2985 TX_STATUS_FAIL(NO_BEACON_ON_RADAR);
2990 #undef TX_STATUS_FAIL
2991 #undef TX_STATUS_POSTPONE
2996 il4965_sta_alloc_lq(
struct il_priv *il,
u8 sta_id)
3005 IL_ERR(
"Unable to allocate memory for LQ cmd.\n");
3023 link_cmd->
rs_table[i].rate_n_flags = rate_n_flags;
3026 il4965_first_antenna(il->
hw_params.valid_tx_ant);
3033 }
else if (il4965_num_of_ant(il->
hw_params.valid_tx_ant) == 2) {
3058 unsigned long flags;
3065 IL_ERR(
"Unable to add station %pM\n", addr);
3074 spin_unlock_irqrestore(&il->
sta_lock, flags);
3077 link_cmd = il4965_sta_alloc_lq(il, sta_id);
3079 IL_ERR(
"Unable to initialize rate scaling for station %pM.\n",
3086 IL_ERR(
"Link quality command failed (%d)\n", ret);
3090 spin_unlock_irqrestore(&il->
sta_lock, flags);
3096 il4965_static_wepkey_cmd(
struct il_priv *il,
bool send_if_empty)
3108 bool not_empty =
false;
3118 wep_cmd->
key[
i].key_idx =
i;
3120 wep_cmd->
key[
i].key_offset =
i;
3126 memcpy(&wep_cmd->
key[i].key[3], il->_4965.wep_keys[i].key, key_size);
3135 if (not_empty || send_if_empty)
3146 return il4965_static_wepkey_cmd(il,
false);
3154 int idx = keyconf->
keyidx;
3158 D_WEP(
"Removing default WEP key: idx=%d\n", idx);
3161 if (il_is_rfkill(il)) {
3162 D_WEP(
"Not sending C_WEPKEY command due to RFKILL.\n");
3166 ret = il4965_static_wepkey_cmd(il, 1);
3167 D_WEP(
"Remove default WEP key: idx=%d ret=%d\n", idx, ret);
3177 int len = keyconf->
keylen;
3178 int idx = keyconf->
keyidx;
3183 D_WEP(
"Bad WEP key length %d\n", keyconf->
keylen);
3191 il->_4965.wep_keys[
idx].key_size = len;
3192 memcpy(&il->_4965.wep_keys[idx].key, &keyconf->
key, len);
3194 ret = il4965_static_wepkey_cmd(il,
false);
3196 D_WEP(
"Set default WEP key: len=%d idx=%d ret=%d\n", len, idx, ret);
3201 il4965_set_wep_dynamic_key_info(
struct il_priv *il,
3204 unsigned long flags;
3235 il->
stations[sta_id].sta.key.key_offset =
3241 "no space for a new key");
3243 il->
stations[sta_id].sta.key.key_flags = key_flags;
3249 spin_unlock_irqrestore(&il->
sta_lock, flags);
3255 il4965_set_ccmp_dynamic_key_info(
struct il_priv *il,
3258 unsigned long flags;
3283 il->
stations[sta_id].sta.key.key_offset =
3289 "no space for a new key");
3291 il->
stations[sta_id].sta.key.key_flags = key_flags;
3297 spin_unlock_irqrestore(&il->
sta_lock, flags);
3303 il4965_set_tkip_dynamic_key_info(
struct il_priv *il,
3306 unsigned long flags;
3323 il->
stations[sta_id].keyinfo.keylen = 16;
3327 il->
stations[sta_id].sta.key.key_offset =
3333 "no space for a new key");
3335 il->
stations[sta_id].sta.key.key_flags = key_flags;
3342 spin_unlock_irqrestore(&il->
sta_lock, flags);
3352 unsigned long flags;
3361 sta_id = il_sta_id_or_broadcast(il, sta);
3367 il->
stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (
u8) iv32;
3369 for (i = 0; i < 5; i++)
3370 il->
stations[sta_id].sta.key.tkip_rx_ttak[i] =
3378 spin_unlock_irqrestore(&il->
sta_lock, flags);
3385 unsigned long flags;
3392 il->_4965.key_mapping_keys--;
3398 D_WEP(
"Remove dynamic key: idx=%d sta=%d\n", keyconf->
keyidx, sta_id);
3400 if (keyconf->
keyidx != keyidx) {
3406 spin_unlock_irqrestore(&il->
sta_lock, flags);
3413 spin_unlock_irqrestore(&il->
sta_lock, flags);
3419 IL_ERR(
"idx %d not used in uCode key table.\n",
3420 il->
stations[sta_id].sta.key.key_offset);
3423 il->
stations[sta_id].sta.key.key_flags =
3429 if (il_is_rfkill(il)) {
3431 (
"Not sending C_ADD_STA command because RFKILL enabled.\n");
3432 spin_unlock_irqrestore(&il->
sta_lock, flags);
3437 spin_unlock_irqrestore(&il->
sta_lock, flags);
3450 il->_4965.key_mapping_keys++;
3453 switch (keyconf->
cipher) {
3456 il4965_set_ccmp_dynamic_key_info(il, keyconf, sta_id);
3460 il4965_set_tkip_dynamic_key_info(il, keyconf, sta_id);
3464 ret = il4965_set_wep_dynamic_key_info(il, keyconf, sta_id);
3467 IL_ERR(
"Unknown alg: %s cipher = %x\n", __func__,
3472 D_WEP(
"Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n",
3489 unsigned long flags;
3495 IL_ERR(
"Unable to prepare broadcast station\n");
3496 spin_unlock_irqrestore(&il->
sta_lock, flags);
3503 spin_unlock_irqrestore(&il->
sta_lock, flags);
3505 link_cmd = il4965_sta_alloc_lq(il, sta_id);
3508 (
"Unable to initialize rate scaling for bcast station.\n");
3514 spin_unlock_irqrestore(&il->
sta_lock, flags);
3526 il4965_update_bcast_station(
struct il_priv *il)
3528 unsigned long flags;
3532 link_cmd = il4965_sta_alloc_lq(il, sta_id);
3534 IL_ERR(
"Unable to initialize rate scaling for bcast sta.\n");
3542 D_INFO(
"Bcast sta rate scaling has not been initialized.\n");
3544 spin_unlock_irqrestore(&il->
sta_lock, flags);
3552 return il4965_update_bcast_station(il);
3561 unsigned long flags;
3573 spin_unlock_irqrestore(&il->
sta_lock, flags);
3582 unsigned long flags;
3588 sta_id = il_sta_id(sta);
3593 il->
stations[sta_id].sta.station_flags_msk = 0;
3595 il->
stations[sta_id].sta.add_immediate_ba_tid = (
u8) tid;
3600 spin_unlock_irqrestore(&il->
sta_lock, flags);
3608 unsigned long flags;
3614 sta_id = il_sta_id(sta);
3616 IL_ERR(
"Invalid station for AGG tid %d\n", tid);
3621 il->
stations[sta_id].sta.station_flags_msk = 0;
3623 il->
stations[sta_id].sta.remove_immediate_ba_tid = (
u8) tid;
3627 spin_unlock_irqrestore(&il->
sta_lock, flags);
3635 unsigned long flags;
3640 il->
stations[sta_id].sta.sta.modify_mask =
3645 spin_unlock_irqrestore(&il->
sta_lock, flags);
3652 if (il->
ops->set_rxon_chain) {
3653 il->
ops->set_rxon_chain(il);
3660 il4965_clear_free_frames(
struct il_priv *il)
3674 IL_WARN(
"%d frames still in use. Did we lose one?\n",
3681 il4965_get_free_frame(
struct il_priv *il)
3688 IL_ERR(
"Could not allocate frame!\n");
3704 memset(frame, 0,
sizeof(*frame));
3727 il4965_set_beacon_tim(
struct il_priv *il,
3738 tim_idx = mgmt->
u.beacon.variable - beacon;
3741 while ((tim_idx < (frame_size - 2)) &&
3743 tim_idx += beacon[tim_idx + 1] + 2;
3746 if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] ==
WLAN_EID_TIM)) {
3748 tx_beacon_cmd->
tim_size = beacon[tim_idx + 1];
3750 IL_WARN(
"Unable to find TIM Element in beacon\n");
3768 IL_ERR(
"Trying to build beacon without beaconing enabled\n");
3773 tx_beacon_cmd = &frame->
u.
beacon;
3774 memset(tx_beacon_cmd, 0,
sizeof(*tx_beacon_cmd));
3778 il4965_fill_beacon_frame(il, tx_beacon_cmd->
frame,
3779 sizeof(frame->
u) -
sizeof(*tx_beacon_cmd));
3787 tx_beacon_cmd->
tx.sta_id = il->
hw_params.bcast_id;
3789 tx_beacon_cmd->
tx.tx_flags =
3794 il4965_set_beacon_tim(il, tx_beacon_cmd, (
u8 *) tx_beacon_cmd->
frame,
3803 tx_beacon_cmd->
tx.rate_n_flags =
cpu_to_le32(rate | rate_flags);
3805 return sizeof(*tx_beacon_cmd) + frame_size;
3812 unsigned int frame_size;
3815 frame = il4965_get_free_frame(il);
3817 IL_ERR(
"Could not obtain free frame buffer for beacon "
3822 frame_size = il4965_hw_get_beacon_cmd(il, frame);
3824 IL_ERR(
"Error configuring the beacon command\n");
3825 il4965_free_frame(il, frame);
3831 il4965_free_frame(il, frame);
3837 il4965_tfd_tb_get_addr(
struct il_tfd *tfd,
u8 idx)
3851 il4965_tfd_tb_get_len(
struct il_tfd *tfd,
u8 idx)
3866 hi_n_len |= ((addr >> 16) >> 16) & 0xF;
3874 il4965_tfd_get_num_tbs(
struct il_tfd *tfd)
3893 int idx = txq->
q.read_ptr;
3897 tfd = &tfd_tmp[idx];
3900 num_tbs = il4965_tfd_get_num_tbs(tfd);
3916 pci_unmap_single(
dev, il4965_tfd_tb_get_addr(tfd, i),
3917 il4965_tfd_tb_get_len(tfd, i),
3937 struct il_tfd *tfd, *tfd_tmp;
3945 memset(tfd, 0,
sizeof(*tfd));
3947 num_tbs = il4965_tfd_get_num_tbs(tfd);
3951 IL_ERR(
"Error can not send more than %d chunks\n",
3958 IL_ERR(
"Unaligned address = %llx\n", (
unsigned long long)addr);
3960 il4965_tfd_set_tb(tfd, num_tbs, addr, len);
3975 int txq_id = txq->
q.id;
3997 D_INFO(
"Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n",
4001 D_INFO(
"Initialization Alive received.\n");
4006 D_INFO(
"Runtime Alive received.\n");
4017 IL_WARN(
"uCode did not respond OK.\n");
4031 il4965_bg_stats_periodic(
unsigned long data)
4039 if (!il_is_ready_rf(il))
4051 #ifdef CONFIG_IWLEGACY_DEBUG
4054 D_RX(
"beacon status %x retries %d iss %d tsf:0x%.8x%.8x rate %d\n",
4064 il4965_perform_ct_kill_task(
struct il_priv *il)
4066 unsigned long flags;
4079 _il_release_nic_access(il);
4080 spin_unlock_irqrestore(&il->
reg_lock, flags);
4090 unsigned long status = il->
status;
4092 D_RF_KILL(
"Card state received: HW:%s SW:%s CT:%s\n",
4113 il4965_perform_ct_kill_task(il);
4115 if (flags & HW_CARD_DISABLED)
4141 il4965_setup_handlers(
struct il_priv *il)
4190 unsigned long flags;
4202 D_RX(
"r = %d, i = %d\n", r, i);
4206 if (total_empty < 0)
4248 D_RX(
"r = %d, i = %d, %s, 0x%02x\n", r, i,
4254 D_RX(
"r %d i %d No handler needed for %s, 0x%02x\n", r,
4289 spin_unlock_irqrestore(&rxq->
lock, flags);
4314 il4965_synchronize_irq(
struct il_priv *il)
4322 il4965_irq_tasklet(
struct il_priv *il)
4324 u32 inta, handled = 0;
4326 unsigned long flags;
4328 #ifdef CONFIG_IWLEGACY_DEBUG
4346 #ifdef CONFIG_IWLEGACY_DEBUG
4347 if (il_get_debug_level(il) &
IL_DL_ISR) {
4350 D_ISR(
"inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta,
4351 inta_mask, inta_fh);
4355 spin_unlock_irqrestore(&il->
lock, flags);
4368 IL_ERR(
"Hardware error detected. Restarting.\n");
4371 il_disable_interrupts(il);
4380 #ifdef CONFIG_IWLEGACY_DEBUG
4381 if (il_get_debug_level(il) & (IL_DL_ISR)) {
4384 D_ISR(
"Scheduler finished to transmit "
4385 "the frame/frames.\n");
4391 D_ISR(
"Alive interrupt\n");
4406 IL_WARN(
"RF_KILL bit toggled to %s.\n",
4407 hw_rf_kill ?
"disable radio" :
"enable radio");
4429 IL_ERR(
"Microcode CT kill error detected.\n");
4436 IL_ERR(
"Microcode SW error detected. " " Restarting 0x%X.\n",
4449 D_ISR(
"Wakeup interrupt\n");
4451 for (i = 0; i < il->
hw_params.max_txq_num; i++)
4468 D_ISR(
"uCode load interrupt\n");
4476 if (inta & ~handled) {
4477 IL_ERR(
"Unhandled INTA bits 0x%08x\n", inta & ~handled);
4482 IL_WARN(
"Disabled INTA bits 0x%08x were pending\n",
4484 IL_WARN(
" with FH49_INT = 0x%08x\n", inta_fh);
4490 il_enable_interrupts(il);
4492 else if (handled & CSR_INT_BIT_RF_KILL)
4493 il_enable_rfkill_int(il);
4495 #ifdef CONFIG_IWLEGACY_DEBUG
4496 if (il_get_debug_level(il) & (IL_DL_ISR)) {
4500 D_ISR(
"End inta 0x%08x, enabled 0x%08x, fh 0x%08x, "
4501 "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags);
4512 #ifdef CONFIG_IWLEGACY_DEBUG
4530 return sprintf(buf,
"0x%08X\n", il_get_debug_level(il));
4535 const char *buf,
size_t count)
4543 IL_ERR(
"%s is not in hex or decimal form.\n", buf);
4545 il->debug_level =
val;
4551 il4965_store_debug_level);
4561 if (!il_is_alive(il))
4574 if (!il_is_ready_rf(il))
4582 const char *buf,
size_t count)
4590 IL_INFO(
"%s is not in decimal form.\n", buf);
4594 IL_ERR(
"failed setting tx power (0x%d).\n", ret);
4602 il4965_store_tx_power);
4604 static struct attribute *il_sysfs_entries[] = {
4605 &dev_attr_temperature.attr,
4606 &dev_attr_tx_power.attr,
4607 #ifdef CONFIG_IWLEGACY_DEBUG
4608 &dev_attr_debug_level.attr,
4615 .attrs = il_sysfs_entries,
4625 il4965_dealloc_ucode_pci(
struct il_priv *il)
4636 il4965_nic_start(
struct il_priv *il)
4642 static void il4965_ucode_callback(
const struct firmware *ucode_raw,
4644 static int il4965_mac_setup_register(
struct il_priv *il,
u32 max_probe_length);
4647 il4965_request_firmware(
struct il_priv *il,
bool first)
4649 const char *name_pre = il->
cfg->fw_name_pre;
4660 if (il->
fw_idx < il->
cfg->ucode_api_min) {
4661 IL_ERR(
"no suitable firmware found!\n");
4671 il4965_ucode_callback);
4680 il4965_load_firmware(
struct il_priv *il,
const struct firmware *ucode_raw,
4697 IL_ERR(
"File size too small!\n");
4705 src = ucode->
v1.data;
4710 if (ucode_raw->
size !=
4714 IL_ERR(
"uCode file size %d does not match expected size\n",
4715 (
int)ucode_raw->
size);
4740 il4965_ucode_callback(
const struct firmware *ucode_raw,
void *
context)
4746 const unsigned int api_max = il->
cfg->ucode_api_max;
4747 const unsigned int api_min = il->
cfg->ucode_api_min;
4750 u32 max_probe_length = 200;
4751 u32 standard_phy_calibration_size =
4754 memset(&pieces, 0,
sizeof(pieces));
4757 if (il->
fw_idx <= il->
cfg->ucode_api_max)
4758 IL_ERR(
"request for firmware file '%s' failed.\n",
4767 if (ucode_raw->
size < 4) {
4768 IL_ERR(
"File size way too small!\n");
4775 err = il4965_load_firmware(il, ucode_raw, &pieces);
4787 if (api_ver < api_min || api_ver > api_max) {
4788 IL_ERR(
"Driver unable to support your firmware API. "
4789 "Driver supports v%u, firmware is v%u.\n", api_max,
4794 if (api_ver != api_max)
4795 IL_ERR(
"Firmware has old API version. Expected v%u, "
4796 "got v%u. New firmware can be obtained "
4797 "from http://www.intellinuxwireless.org.\n", api_max,
4800 IL_INFO(
"loaded firmware version %u.%u.%u.%u\n",
4804 snprintf(il->
hw->wiphy->fw_version,
sizeof(il->
hw->wiphy->fw_version),
4816 D_INFO(
"f/w package hdr runtime inst size = %Zd\n", pieces.
inst_size);
4817 D_INFO(
"f/w package hdr runtime data size = %Zd\n", pieces.
data_size);
4824 IL_ERR(
"uCode instr len %Zd too large to fit in\n",
4830 IL_ERR(
"uCode data len %Zd too large to fit in\n",
4836 IL_ERR(
"uCode init instr len %Zd too large to fit in\n",
4842 IL_ERR(
"uCode init data len %Zd too large to fit in\n",
4848 IL_ERR(
"uCode boot instr len %Zd too large to fit in\n",
4899 D_INFO(
"Copying (but not loading) uCode instr len %Zd\n",
4903 D_INFO(
"uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n",
4910 D_INFO(
"Copying (but not loading) uCode data len %Zd\n",
4917 D_INFO(
"Copying (but not loading) init instr len %Zd\n",
4924 D_INFO(
"Copying (but not loading) init data len %Zd\n",
4931 D_INFO(
"Copying (but not loading) boot instr len %Zd\n",
4939 il->_4965.phy_calib_chain_noise_reset_cmd =
4940 standard_phy_calibration_size;
4941 il->_4965.phy_calib_chain_noise_gain_cmd =
4942 standard_phy_calibration_size + 1;
4949 err = il4965_mac_setup_register(il, max_probe_length);
4955 IL_ERR(
"failed to create debugfs files. Ignoring error: %d\n",
4960 IL_ERR(
"failed to create sysfs device attributes\n");
4966 complete(&il->_4965.firmware_loading_complete);
4971 if (il4965_request_firmware(il,
false))
4977 IL_ERR(
"failed to allocate pci memory\n");
4978 il4965_dealloc_ucode_pci(il);
4980 complete(&il->_4965.firmware_loading_complete);
4985 static const char *
const desc_lookup_text[] = {
4990 "NMI_INTERRUPT_WDG",
4994 "HW_ERROR_TUNE_LOCK",
4995 "HW_ERROR_TEMPERATURE",
4996 "ILLEGAL_CHAN_FREQ",
4999 "NMI_INTERRUPT_HOST",
5000 "NMI_INTERRUPT_ACTION_PT",
5001 "NMI_INTERRUPT_UNKNOWN",
5002 "UCODE_VERSION_MISMATCH",
5003 "HW_ERROR_ABS_LOCK",
5004 "HW_ERROR_CAL_LOCK_FAIL",
5005 "NMI_INTERRUPT_INST_ACTION_PT",
5006 "NMI_INTERRUPT_DATA_ACTION_PT",
5008 "NMI_INTERRUPT_TRM",
5009 "NMI_INTERRUPT_BREAK_POINT",
5019 } advanced_lookup[] = {
5021 "NMI_INTERRUPT_WDG", 0x34}, {
5022 "SYSASSERT", 0x35}, {
5023 "UCODE_VERSION_MISMATCH", 0x37}, {
5024 "BAD_COMMAND", 0x38}, {
5025 "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C}, {
5026 "FATAL_ERROR", 0x3D}, {
5027 "NMI_TRM_HW_ERR", 0x46}, {
5028 "NMI_INTERRUPT_TRM", 0x4C}, {
5029 "NMI_INTERRUPT_BREAK_POINT", 0x54}, {
5030 "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C}, {
5031 "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64}, {
5032 "NMI_INTERRUPT_HOST", 0x66}, {
5033 "NMI_INTERRUPT_ACTION_PT", 0x7C}, {
5034 "NMI_INTERRUPT_UNKNOWN", 0x84}, {
5035 "NMI_INTERRUPT_INST_ACTION_PT", 0x86}, {
5036 "ADVANCED_SYSASSERT", 0},};
5039 il4965_desc_lookup(
u32 num)
5045 return desc_lookup_text[num];
5048 for (i = 0; i <
max; i++) {
5049 if (advanced_lookup[i].num == num)
5052 return advanced_lookup[
i].name;
5055 #define ERROR_START_OFFSET (1 * sizeof(u32))
5056 #define ERROR_ELEM_SIZE (7 * sizeof(u32))
5063 u32 blink1, blink2, ilink1, ilink2;
5071 if (!il->
ops->is_valid_rtc_data_addr(base)) {
5072 IL_ERR(
"Not valid error log pointer 0x%08X for %s uCode\n",
5080 IL_ERR(
"Start IWL Error Log Dump:\n");
5081 IL_ERR(
"Status: 0x%08lX, count: %d\n", il->
status, count);
5098 "data1 data2 line\n");
5099 IL_ERR(
"%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n",
5100 il4965_desc_lookup(desc), desc, time, data1, data2, line);
5101 IL_ERR(
"pc blink1 blink2 ilink1 ilink2 hcmd\n");
5102 IL_ERR(
"0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", pc, blink1,
5103 blink2, ilink1, ilink2, hcmd);
5107 il4965_rf_kill_ct_config(
struct il_priv *il)
5110 unsigned long flags;
5116 spin_unlock_irqrestore(&il->
lock, flags);
5118 cmd.critical_temperature_R =
5123 IL_ERR(
"C_CT_KILL_CONFIG failed\n");
5125 D_INFO(
"C_CT_KILL_CONFIG " "succeeded, "
5126 "critical temperature is %d\n",
5130 static const s8 default_queue_to_tx_fifo[] = {
5140 #define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo))))
5143 il4965_alive_notify(
struct il_priv *il)
5146 unsigned long flags;
5184 for (i = 0; i < il->
hw_params.max_txq_num; i++) {
5218 for (i = 0; i < 4; i++)
5226 for (i = 0; i <
ARRAY_SIZE(default_queue_to_tx_fifo); i++) {
5227 int ac = default_queue_to_tx_fifo[
i];
5229 il_txq_ctx_activate(il, i);
5237 spin_unlock_irqrestore(&il->
lock, flags);
5248 il4965_alive_start(
struct il_priv *il)
5252 D_INFO(
"Runtime Alive received.\n");
5257 D_INFO(
"Alive failed.\n");
5267 D_INFO(
"Bad runtime uCode load.\n");
5271 ret = il4965_alive_notify(il);
5273 IL_WARN(
"Could not complete ALIVE transition [ntf]: %d\n", ret);
5283 if (il_is_rfkill(il))
5290 if (il_is_associated(il)) {
5300 if (il->
ops->set_rxon_chain)
5301 il->
ops->set_rxon_chain(il);
5315 il4965_rf_kill_ct_config(il);
5317 D_INFO(
"ALIVE processing complete.\n");
5321 D_INFO(
"Updated power mode\n");
5329 static void il4965_cancel_deferred_work(
struct il_priv *il);
5332 __il4965_down(
struct il_priv *il)
5334 unsigned long flags;
5358 memset(il->_4965.wep_keys, 0,
sizeof(il->_4965.wep_keys));
5359 il->_4965.key_mapping_keys = 0;
5363 il_clear_driver_stations(il);
5378 il_disable_interrupts(il);
5379 spin_unlock_irqrestore(&il->
lock, flags);
5380 il4965_synchronize_irq(il);
5387 if (!il_is_init(il)) {
5431 il4965_clear_free_frames(il);
5435 il4965_down(
struct il_priv *il)
5441 il4965_cancel_deferred_work(il);
5446 il4965_set_hw_ready(
struct il_priv *il)
5465 il4965_prepare_card_hw(
struct il_priv *il)
5471 il4965_set_hw_ready(il);
5485 il4965_set_hw_ready(il);
5488 #define MAX_HW_RESTARTS 5
5491 __il4965_up(
struct il_priv *il)
5497 IL_WARN(
"Exit pending; will not bring the NIC up\n");
5502 IL_ERR(
"ucode not available for device bringup\n");
5512 il4965_prepare_card_hw(il);
5514 IL_ERR(
"HW not ready\n");
5519 if (_il_rd(il,
CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
5525 il_enable_rfkill_int(il);
5526 IL_WARN(
"Radio disabled by HW RF Kill switch\n");
5530 _il_wr(il,
CSR_INT, 0xFFFFFFFF);
5537 IL_ERR(
"Unable to init nic\n");
5546 _il_wr(il,
CSR_INT, 0xFFFFFFFF);
5547 il_enable_interrupts(il);
5564 ret = il->
ops->load_ucode(il);
5567 IL_ERR(
"Unable to set up bootstrap uCode: %d\n", ret);
5572 il4965_nic_start(il);
5585 IL_ERR(
"Unable to initialize device after %d attempts.\n", i);
5596 il4965_bg_init_alive_start(
struct work_struct *data)
5605 il->
ops->init_alive_start(il);
5620 il4965_alive_start(il);
5662 il4965_cancel_deferred_work(il);
5697 #define UCODE_READY_TIMEOUT (4 * HZ)
5704 il4965_mac_setup_register(
struct il_priv *il,
u32 max_probe_length)
5725 hw->
wiphy->interface_modes =
5740 hw->
wiphy->max_scan_ie_len = max_probe_length - 24 - 2;
5758 IL_ERR(
"Failed to register hw (error %d)\n", ret);
5776 ret = __il4965_up(il);
5782 if (il_is_rfkill(il))
5785 D_INFO(
"Start UP work done.\n");
5794 IL_ERR(
"START_ALIVE timeout after %dms.\n",
5826 _il_wr(il,
CSR_INT, 0xFFFFFFFF);
5827 il_enable_rfkill_int(il);
5841 D_TX(
"dev->xmit(%d bytes) at rate 0x%02x\n", skb->
len,
5842 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->
bitrate);
5872 bool is_default_wep_key =
false;
5876 if (il->
cfg->mod_params->sw_crypto) {
5891 sta_id = il_sta_id_or_broadcast(il, sta);
5907 is_default_wep_key = !il->_4965.key_mapping_keys;
5909 is_default_wep_key =
5915 if (is_default_wep_key)
5923 if (is_default_wep_key)
5949 D_HT(
"A-MPDU action on addr %pM tid %d\n", sta->
addr, tid);
5996 D_INFO(
"received request to add station %pM\n", sta->
addr);
5998 D_INFO(
"proceeding to add station %pM\n", sta->
addr);
6006 IL_ERR(
"Unable to add station %pM (%d)\n", sta->
addr, ret);
6012 sta_priv->
common.sta_id = sta_id;
6015 D_INFO(
"Initializing rate scaling for station %pM\n", sta->
addr);
6037 if (il_is_rfkill(il))
6045 if (!il_is_associated(il))
6048 if (!il->
ops->set_channel_switch)
6056 if (!il_is_channel_valid(ch_info)) {
6061 spin_lock_irq(&il->
lock);
6066 il->
ht.enabled = conf_is_ht(conf);
6067 if (il->
ht.enabled) {
6068 if (conf_is_ht40_minus(conf)) {
6069 il->
ht.extension_chan_offset =
6071 il->
ht.is_40mhz =
true;
6072 }
else if (conf_is_ht40_plus(conf)) {
6073 il->
ht.extension_chan_offset =
6075 il->
ht.is_40mhz =
true;
6077 il->
ht.extension_chan_offset =
6079 il->
ht.is_40mhz =
false;
6082 il->
ht.is_40mhz =
false;
6091 spin_unlock_irq(&il->
lock);
6100 if (il->
ops->set_channel_switch(il, ch_switch)) {
6113 unsigned int *total_flags,
u64 multicast)
6116 __le32 filter_or = 0, filter_nand = 0;
6118 #define CHK(test, flag) do { \
6119 if (*total_flags & (test)) \
6120 filter_or |= (flag); \
6122 filter_nand |= (flag); \
6125 D_MAC80211(
"Enter: changed: 0x%x, total: 0x%x\n", changed_flags,
6137 il->
staging.filter_flags &= ~filter_nand;
6138 il->
staging.filter_flags |= filter_or;
6183 il->
ops->send_tx_power(il);
6193 il4965_setup_deferred_work(
struct il_priv *il)
6218 (
void (*)(
unsigned long))il4965_irq_tasklet,
6223 il4965_cancel_deferred_work(
struct il_priv *il)
6268 int tx_fifo_id,
int scd_retry)
6270 int txq_id = txq->
q.id;
6285 D_INFO(
"%s %s Queue %d on AC %d\n", active ?
"Activate" :
"Deactivate",
6286 scd_retry ?
"BA" :
"AC", txq_id, tx_fifo_id);
6312 il4965_init_drv(
struct il_priv *il)
6335 if (il->
ops->set_rxon_chain)
6336 il->
ops->set_rxon_chain(il);
6342 IL_ERR(
"initializing regulatory failed: %d\n", ret);
6348 IL_ERR(
"initializing geos failed: %d\n", ret);
6349 goto err_free_channel_map;
6355 err_free_channel_map:
6362 il4965_uninit_drv(
struct il_priv *il)
6370 il4965_hw_detect(
struct il_priv *il)
6382 .auto_corr_min_ofdm = 85,
6383 .auto_corr_min_ofdm_mrc = 170,
6384 .auto_corr_min_ofdm_x1 = 105,
6385 .auto_corr_min_ofdm_mrc_x1 = 220,
6387 .auto_corr_max_ofdm = 120,
6388 .auto_corr_max_ofdm_mrc = 210,
6389 .auto_corr_max_ofdm_x1 = 140,
6390 .auto_corr_max_ofdm_mrc_x1 = 270,
6392 .auto_corr_min_cck = 125,
6393 .auto_corr_max_cck = 200,
6394 .auto_corr_min_cck_mrc = 200,
6395 .auto_corr_max_cck_mrc = 400,
6400 .barker_corr_th_min = 190,
6401 .barker_corr_th_min_mrc = 390,
6406 il4965_set_hw_params(
struct il_priv *il)
6411 if (il->
cfg->mod_params->amsdu_size_8K)
6418 if (il->
cfg->mod_params->disable_11n)
6423 il->
cfg->num_of_queues =
6424 il->
cfg->mod_params->num_of_queues;
6429 il->
cfg->num_of_queues *
6441 il->
hw_params.tx_chains_num = il4965_num_of_ant(il->
cfg->valid_tx_ant);
6442 il->
hw_params.rx_chains_num = il4965_num_of_ant(il->
cfg->valid_rx_ant);
6449 il->
hw_params.sens = &il4965_sensitivity;
6460 unsigned long flags;
6474 SET_IEEE80211_DEV(hw, &pdev->
dev);
6476 D_INFO(
"*** LOAD DRIVER ***\n");
6479 #ifdef CONFIG_IWLEGACY_DEBUGFS
6494 goto out_ieee80211_free_hw;
6501 err = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(36));
6509 IL_WARN(
"No suitable DMA available.\n");
6510 goto out_pci_disable_device;
6516 goto out_pci_disable_device;
6518 pci_set_drvdata(pdev, il);
6526 goto out_pci_release_regions;
6529 D_INFO(
"pci_resource_len = 0x%08llx\n",
6546 il4965_hw_detect(il);
6553 il4965_prepare_card_hw(il);
6555 IL_WARN(
"Failed, HW not ready\n");
6565 IL_ERR(
"Unable to init EEPROM\n");
6570 goto out_free_eeprom;
6573 goto out_free_eeprom;
6579 il->
hw->wiphy->n_addresses = 1;
6584 il4965_set_hw_params(il);
6590 err = il4965_init_drv(il);
6592 goto out_free_eeprom;
6599 il_disable_interrupts(il);
6600 spin_unlock_irqrestore(&il->
lock, flags);
6607 goto out_disable_msi;
6610 il4965_setup_deferred_work(il);
6611 il4965_setup_handlers(il);
6620 pci_cmd &= ~PCI_COMMAND_INTX_DISABLE;
6624 il_enable_rfkill_int(il);
6627 if (_il_rd(il,
CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
6637 init_completion(&il->_4965.firmware_loading_complete);
6639 err = il4965_request_firmware(il,
true);
6641 goto out_destroy_workqueue;
6645 out_destroy_workqueue:
6651 il4965_uninit_drv(il);
6656 out_pci_release_regions:
6657 pci_set_drvdata(pdev,
NULL);
6659 out_pci_disable_device:
6661 out_ieee80211_free_hw:
6668 il4965_pci_remove(
struct pci_dev *pdev)
6670 struct il_priv *il = pci_get_drvdata(pdev);
6671 unsigned long flags;
6678 D_INFO(
"*** UNLOAD DRIVER ***\n");
6711 il_disable_interrupts(il);
6712 spin_unlock_irqrestore(&il->
lock, flags);
6714 il4965_synchronize_irq(il);
6716 il4965_dealloc_ucode_pci(il);
6738 pci_set_drvdata(pdev,
NULL);
6740 il4965_uninit_drv(il);
6773 .id_table = il4965_hw_card_ids,
6774 .probe = il4965_pci_probe,
6789 pr_err(
"Unable to register rate control algorithm: %d\n", ret);
6793 ret = pci_register_driver(&il4965_driver);
6795 pr_err(
"Unable to initialize PCI module\n");
6796 goto error_register;
6816 #ifdef CONFIG_IWLEGACY_DEBUG
6822 MODULE_PARM_DESC(swcrypto,
"using crypto in software (default 0 [hardware])");