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>
50 #include <asm/div64.h>
52 #define DRV_NAME "iwl3945"
63 #define DRV_DESCRIPTION \
64 "Intel(R) PRO/Wireless 3945ABG/BG Network Connection driver for Linux"
66 #ifdef CONFIG_IWLEGACY_DEBUG
77 #define DRV_VERSION IWLWIFI_VERSION VD "s"
78 #define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation"
110 switch (il3945_mod_params.
antenna) {
126 IL_ERR(
"Bad antenna selector value (0x%x)\n",
133 il3945_set_ccmp_dynamic_key_info(
struct il_priv *il,
159 il->
stations[sta_id].sta.key.key_offset =
165 "no space for a new key");
167 il->
stations[sta_id].sta.key.key_flags = key_flags;
171 D_INFO(
"hwcrypto: modify ucode station key info\n");
175 spin_unlock_irqrestore(&il->
sta_lock, flags);
181 il3945_set_tkip_dynamic_key_info(
struct il_priv *il,
188 il3945_set_wep_dynamic_key_info(
struct il_priv *il,
195 il3945_clear_sta_key_info(
struct il_priv *il,
u8 sta_id)
208 spin_unlock_irqrestore(&il->
sta_lock, flags);
210 D_INFO(
"hwcrypto: clear ucode station key info\n");
222 switch (keyconf->
cipher) {
224 ret = il3945_set_ccmp_dynamic_key_info(il, keyconf, sta_id);
227 ret = il3945_set_tkip_dynamic_key_info(il, keyconf, sta_id);
231 ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id);
234 IL_ERR(
"Unknown alg: %s alg=%x\n", __func__, keyconf->
cipher);
238 D_WEP(
"Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n",
245 il3945_remove_static_key(
struct il_priv *il)
264 il3945_clear_free_frames(
struct il_priv *il)
278 IL_WARN(
"%d frames still in use. Did we lose one?\n",
285 il3945_get_free_frame(
struct il_priv *il)
292 IL_ERR(
"Could not allocate frame!\n");
308 memset(frame, 0,
sizeof(*frame));
329 il3945_send_beacon_cmd(
struct il_priv *il)
332 unsigned int frame_size;
336 frame = il3945_get_free_frame(il);
339 IL_ERR(
"Could not obtain free frame buffer for beacon "
350 il3945_free_frame(il, frame);
356 il3945_unset_hw_params(
struct il_priv *il)
358 if (il->_3945.shared_virt)
361 il->_3945.shared_virt, il->_3945.shared_phys);
367 struct sk_buff *skb_frag,
int sta_id)
374 switch (keyinfo->cipher) {
377 memcpy(tx_cmd->
key, keyinfo->key, keyinfo->keylen);
378 D_TX(
"tx_cmd with AES hwcrypto\n");
393 memcpy(&tx_cmd->
key[3], keyinfo->key, keyinfo->keylen);
395 D_TX(
"Configuring packet for WEP encryption " "with key %d\n",
396 info->
control.hw_key->hw_key_idx);
400 IL_ERR(
"Unknown encode cipher %x\n", keyinfo->cipher);
420 if (ieee80211_is_mgmt(
fc))
422 if (ieee80211_is_probe_resp(
fc) &&
431 if (ieee80211_has_morefrags(
fc))
434 if (ieee80211_is_data_qos(
fc)) {
435 u8 *qc = ieee80211_get_qos_ctl(hdr);
445 if (ieee80211_is_mgmt(
fc)) {
446 if (ieee80211_is_assoc_req(
fc) || ieee80211_is_reassoc_req(
fc))
463 il3945_tx_skb(
struct il_priv *il,
476 int txq_id = skb_get_queue_mapping(skb);
483 u8 wait_write_ptr = 0;
487 if (il_is_rfkill(il)) {
488 D_DROP(
"Dropping - RF KILL\n");
492 if ((ieee80211_get_tx_rate(il->
hw, info)->hw_value & 0xFF) ==
494 IL_ERR(
"ERROR: No TX rate available.\n");
498 unicast = !is_multicast_ether_addr(hdr->
addr1);
503 #ifdef CONFIG_IWLEGACY_DEBUG
504 if (ieee80211_is_auth(fc))
505 D_TX(
"Sending AUTH frame\n");
506 else if (ieee80211_is_assoc_req(fc))
507 D_TX(
"Sending ASSOC frame\n");
508 else if (ieee80211_is_reassoc_req(fc))
509 D_TX(
"Sending REASSOC frame\n");
512 spin_unlock_irqrestore(&il->
lock, flags);
517 sta_id = il_sta_id_or_broadcast(il, sta);
519 D_DROP(
"Dropping - INVALID STATION: %pM\n", hdr->
addr1);
523 D_RATE(
"station Id %d\n", sta_id);
525 if (ieee80211_is_data_qos(fc)) {
526 u8 *qc = ieee80211_get_qos_ctl(hdr);
533 txq = &il->
txq[txq_id];
541 idx = il_get_cmd_idx(q, q->
write_ptr, 0);
550 memset(tx_cmd, 0,
sizeof(*tx_cmd));
559 out_cmd->
hdr.sequence =
567 il3945_build_tx_cmd_hwcrypto(il, info, out_cmd, skb, sta_id);
570 il3945_build_tx_cmd_basic(il, out_cmd, info, hdr, sta_id);
591 il_print_hex_dump(il,
IL_DL_TX, tx_cmd,
sizeof(*tx_cmd));
607 len = (len + 3) & ~3;
620 il->
ops->txq_attach_buf_to_tfd(il, txq, txcmd_phys, len, 1, 0);
627 pci_map_single(il->
pci_dev, skb->
data + hdr_len, len,
629 il->
ops->txq_attach_buf_to_tfd(il, txq, phys_addr, len, 0,
636 spin_unlock_irqrestore(&il->
lock, flags);
639 if (wait_write_ptr) {
643 spin_unlock_irqrestore(&il->
lock, flags);
646 il_stop_queue(il, txq);
652 spin_unlock_irqrestore(&il->
lock, flags);
658 il3945_get_measurement(
struct il_priv *il,
665 .data = (
void *)&spectrum,
670 int spectrum_resp_status;
673 if (il_is_associated(il))
680 memset(&spectrum, 0,
sizeof(spectrum));
686 cmd.
len =
sizeof(spectrum);
689 if (il_is_associated(il))
690 spectrum.start_time =
694 spectrum.start_time = 0;
697 spectrum.channels[0].channel = params->
channel;
698 spectrum.channels[0].type =
type;
710 IL_ERR(
"Bad return from N_RX_ON_ASSOC command\n");
715 switch (spectrum_resp_status) {
718 D_INFO(
"Replaced existing measurement: %d\n",
745 D_INFO(
"Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n",
749 D_INFO(
"Initialization Alive received.\n");
754 D_INFO(
"Runtime Alive received.\n");
766 IL_WARN(
"uCode did not respond OK.\n");
772 #ifdef CONFIG_IWLEGACY_DEBUG
776 D_RX(
"Received C_ADD_STA: 0x%02X\n", pkt->
u.
status);
784 #ifdef CONFIG_IWLEGACY_DEBUG
787 D_RX(
"beacon status %x retries %d iss %d " "tsf %d %d rate %d\n",
807 IL_WARN(
"Card state received: HW:%s SW:%s\n",
813 if (flags & HW_CARD_DISABLED)
838 il3945_setup_handlers(
struct il_priv *il)
949 il3945_rx_queue_restock(
struct il_priv *il)
958 write = rxq->
write & ~0x7;
967 il3945_dma_addr2rbd_ptr(il, rxb->
page_dma);
972 spin_unlock_irqrestore(&rxq->
lock, flags);
984 spin_unlock_irqrestore(&rxq->
lock, flags);
1004 unsigned long flags;
1010 if (list_empty(&rxq->
rx_used)) {
1011 spin_unlock_irqrestore(&rxq->
lock, flags);
1014 spin_unlock_irqrestore(&rxq->
lock, flags);
1026 D_INFO(
"Failed to allocate SKB buffer.\n");
1029 IL_ERR(
"Failed to allocate SKB buffer with %0x."
1030 "Only %u free buffers remaining.\n",
1039 if (list_empty(&rxq->
rx_used)) {
1040 spin_unlock_irqrestore(&rxq->
lock, flags);
1047 spin_unlock_irqrestore(&rxq->
lock, flags);
1052 pci_map_page(il->
pci_dev, page, 0,
1062 spin_unlock_irqrestore(&rxq->
lock, flags);
1069 unsigned long flags;
1072 INIT_LIST_HEAD(&rxq->
rx_free);
1073 INIT_LIST_HEAD(&rxq->
rx_used);
1079 pci_unmap_page(il->
pci_dev, rxq->
pool[i].page_dma,
1082 __il_free_pages(il, rxq->
pool[i].page);
1093 spin_unlock_irqrestore(&rxq->
lock, flags);
1100 unsigned long flags;
1105 il3945_rx_queue_restock(il);
1106 spin_unlock_irqrestore(&il->
lock, flags);
1110 il3945_rx_replenish_now(
struct il_priv *il)
1114 il3945_rx_queue_restock(il);
1128 pci_unmap_page(il->
pci_dev, rxq->
pool[i].page_dma,
1131 __il_free_pages(il, rxq->
pool[i].page);
1145 static u8 ratio2dB[100] = {
1147 0, 0, 6, 10, 12, 14, 16, 17, 18, 19,
1148 20, 21, 22, 22, 23, 23, 24, 25, 26, 26,
1149 26, 26, 26, 27, 27, 28, 28, 28, 29, 29,
1150 29, 30, 30, 30, 31, 31, 31, 31, 32, 32,
1151 32, 32, 32, 33, 33, 33, 33, 33, 34, 34,
1152 34, 34, 34, 34, 35, 35, 35, 35, 35, 35,
1153 36, 36, 36, 36, 36, 36, 36, 37, 37, 37,
1154 37, 37, 37, 37, 37, 38, 38, 38, 38, 38,
1155 38, 38, 38, 38, 38, 39, 39, 39, 39, 39,
1156 39, 39, 39, 39, 39, 40, 40, 40, 40, 40
1166 if (sig_ratio >= 1000)
1171 if (sig_ratio >= 100)
1172 return 20 + (
int)ratio2dB[sig_ratio / 10];
1179 return (
int)ratio2dB[sig_ratio];
1190 il3945_rx_handle(
struct il_priv *il)
1197 unsigned long flags;
1200 int total_empty = 0;
1209 if (total_empty < 0)
1216 D_RX(
"r = %d, i = %d\n", r, i);
1251 D_RX(
"r = %d, i = %d, %s, 0x%02x\n", r, i,
1257 D_RX(
"r %d i %d No handler needed for %s, 0x%02x\n", r,
1292 spin_unlock_irqrestore(&rxq->
lock, flags);
1301 il3945_rx_replenish_now(il);
1310 il3945_rx_replenish_now(il);
1312 il3945_rx_queue_restock(il);
1317 il3945_synchronize_irq(
struct il_priv *il)
1325 il3945_desc_lookup(
int i)
1333 return "BAD_CHECKSUM";
1335 return "NMI_INTERRUPT";
1339 return "FATAL_ERROR";
1345 #define ERROR_START_OFFSET (1 * sizeof(u32))
1346 #define ERROR_ELEM_SIZE (7 * sizeof(u32))
1353 u32 blink1, blink2, ilink1, ilink2;
1357 if (!il3945_hw_valid_rtc_data_addr(base)) {
1358 IL_ERR(
"Not valid error log pointer 0x%08X\n", base);
1365 IL_ERR(
"Start IWL Error Log Dump:\n");
1366 IL_ERR(
"Status: 0x%08lX, count: %d\n", il->
status, count);
1369 IL_ERR(
"Desc Time asrtPC blink2 "
1370 "ilink1 nmiPC Line\n");
1382 IL_ERR(
"%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n",
1383 il3945_desc_lookup(desc), desc, time, blink1, blink2,
1384 ilink1, ilink2, data1);
1389 il3945_irq_tasklet(
struct il_priv *il)
1391 u32 inta, handled = 0;
1393 unsigned long flags;
1394 #ifdef CONFIG_IWLEGACY_DEBUG
1412 #ifdef CONFIG_IWLEGACY_DEBUG
1413 if (il_get_debug_level(il) &
IL_DL_ISR) {
1416 D_ISR(
"inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta,
1417 inta_mask, inta_fh);
1421 spin_unlock_irqrestore(&il->
lock, flags);
1434 IL_ERR(
"Hardware error detected. Restarting.\n");
1437 il_disable_interrupts(il);
1446 #ifdef CONFIG_IWLEGACY_DEBUG
1447 if (il_get_debug_level(il) & (IL_DL_ISR)) {
1450 D_ISR(
"Scheduler finished to transmit "
1451 "the frame/frames.\n");
1457 D_ISR(
"Alive interrupt\n");
1467 IL_ERR(
"Microcode SW error detected. " "Restarting 0x%X.\n",
1476 D_ISR(
"Wakeup interrupt\n");
1493 il3945_rx_handle(il);
1499 D_ISR(
"Tx interrupt\n");
1507 if (inta & ~handled) {
1508 IL_ERR(
"Unhandled INTA bits 0x%08x\n", inta & ~handled);
1513 IL_WARN(
"Disabled INTA bits 0x%08x were pending\n",
1515 IL_WARN(
" with inta_fh = 0x%08x\n", inta_fh);
1521 il_enable_interrupts(il);
1523 #ifdef CONFIG_IWLEGACY_DEBUG
1524 if (il_get_debug_level(il) & (IL_DL_ISR)) {
1528 D_ISR(
"End inta 0x%08x, enabled 0x%08x, fh 0x%08x, "
1529 "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags);
1543 u16 passive_dwell = 0;
1544 u16 active_dwell = 0;
1547 sband = il_get_hw_mode(il, band);
1554 if (passive_dwell <= active_dwell)
1555 passive_dwell = active_dwell + 1;
1557 for (i = 0, added = 0; i < il->
scan_request->n_channels; i++) {
1560 if (chan->
band != band)
1566 if (!il_is_channel_valid(ch_info)) {
1567 D_SCAN(
"Channel %d is INVALID for this band.\n",
1577 if (!is_active || il_is_channel_passive(ch_info) ||
1597 if ((scan_ch->
type & 1) && n_probes)
1602 scan_ch->
tpc.dsp_atten = 110;
1607 scan_ch->
tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3;
1609 scan_ch->
tpc.tx_gain = ((1 << 5) | (5 << 3));
1617 (scan_ch->
type & 1) ?
"ACTIVE" :
"PASSIVE",
1618 (scan_ch->
type & 1) ? active_dwell : passive_dwell);
1624 D_SCAN(
"total channels to scan %d\n", added);
1656 il3945_dealloc_ucode_pci(
struct il_priv *il)
1678 D_INFO(
"ucode inst image size is %u\n", len);
1683 for (; len > 0; len -=
sizeof(
u32), image++) {
1689 IL_ERR(
"uCode INST section is invalid at "
1690 "offset 0x%x, is 0x%x, s/b 0x%x\n",
1700 D_INFO(
"ucode image in INSTRUCTION memory is good\n");
1718 D_INFO(
"ucode inst image size is %u\n", len);
1720 for (i = 0; i < len; i += 100, image += 100 /
sizeof(
u32)) {
1728 IL_ERR(
"uCode INST section is invalid at "
1729 "offset 0x%x, is 0x%x, s/b 0x%x\n", i, val,
1747 il3945_verify_ucode(
struct il_priv *il)
1756 rc = il3945_verify_inst_sparse(il, image, len);
1758 D_INFO(
"Bootstrap uCode is good in inst SRAM\n");
1765 rc = il3945_verify_inst_sparse(il, image, len);
1767 D_INFO(
"Initialize uCode is good in inst SRAM\n");
1774 rc = il3945_verify_inst_sparse(il, image, len);
1776 D_INFO(
"Runtime uCode is good in inst SRAM\n");
1780 IL_ERR(
"NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
1787 rc = il3945_verify_inst_full(il, image, len);
1793 il3945_nic_start(
struct il_priv *il)
1799 #define IL3945_UCODE_GET(item) \
1800 static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\
1802 return le32_to_cpu(ucode->v1.item); \
1806 il3945_ucode_get_header_size(
u32 api_ver)
1814 return (
u8 *) ucode->
v1.data;
1829 il3945_read_ucode(
struct il_priv *il)
1835 const char *name_pre = il->
cfg->fw_name_pre;
1836 const unsigned int api_max = il->
cfg->ucode_api_max;
1837 const unsigned int api_min = il->
cfg->ucode_api_min;
1845 for (idx = api_max; idx >= api_min; idx--) {
1846 sprintf(buf,
"%s%u%s", name_pre, idx,
".ucode");
1849 IL_ERR(
"%s firmware file req failed: %d\n", buf, ret);
1856 IL_ERR(
"Loaded firmware %s, "
1857 "which is deprecated. "
1858 " Please use API v%u instead.\n", buf,
1860 D_INFO(
"Got firmware '%s' file "
1861 "(%zd bytes) from disk\n", buf, ucode_raw->
size);
1870 if (ucode_raw->
size < il3945_ucode_get_header_size(1)) {
1871 IL_ERR(
"File size way too small!\n");
1881 inst_size = il3945_ucode_get_inst_size(ucode);
1882 data_size = il3945_ucode_get_data_size(ucode);
1883 init_size = il3945_ucode_get_init_size(ucode);
1884 init_data_size = il3945_ucode_get_init_data_size(ucode);
1885 boot_size = il3945_ucode_get_boot_size(ucode);
1886 src = il3945_ucode_get_data(ucode);
1892 if (api_ver < api_min || api_ver > api_max) {
1893 IL_ERR(
"Driver unable to support your firmware API. "
1894 "Driver supports v%u, firmware is v%u.\n", api_max,
1900 if (api_ver != api_max)
1901 IL_ERR(
"Firmware has old API version. Expected %u, "
1902 "got %u. New firmware can be obtained "
1903 "from http://www.intellinuxwireless.org.\n", api_max,
1906 IL_INFO(
"loaded firmware version %u.%u.%u.%u\n",
1910 snprintf(il->
hw->wiphy->fw_version,
sizeof(il->
hw->wiphy->fw_version),
1916 D_INFO(
"f/w package hdr runtime inst size = %u\n", inst_size);
1917 D_INFO(
"f/w package hdr runtime data size = %u\n", data_size);
1918 D_INFO(
"f/w package hdr init inst size = %u\n", init_size);
1919 D_INFO(
"f/w package hdr init data size = %u\n", init_data_size);
1920 D_INFO(
"f/w package hdr boot inst size = %u\n", boot_size);
1923 if (ucode_raw->
size !=
1924 il3945_ucode_get_header_size(api_ver) + inst_size + data_size +
1925 init_size + init_data_size + boot_size) {
1927 D_INFO(
"uCode file size %zd does not match expected size\n",
1935 D_INFO(
"uCode instr len %d too large to fit in\n", inst_size);
1941 D_INFO(
"uCode data len %d too large to fit in\n", data_size);
1946 D_INFO(
"uCode init instr len %d too large to fit in\n",
1952 D_INFO(
"uCode init data len %d too large to fit in\n",
1958 D_INFO(
"uCode boot instr len %d too large to fit in\n",
1983 if (init_size && init_data_size) {
2007 D_INFO(
"Copying (but not loading) uCode instr len %zd\n", len);
2011 D_INFO(
"uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n",
2017 D_INFO(
"Copying (but not loading) uCode data len %zd\n", len);
2025 D_INFO(
"Copying (but not loading) init instr len %zd\n", len);
2031 if (init_data_size) {
2033 D_INFO(
"Copying (but not loading) init data len %zd\n", len);
2040 D_INFO(
"Copying (but not loading) boot instr len %zd\n", len);
2048 IL_ERR(
"failed to allocate pci memory\n");
2050 il3945_dealloc_ucode_pci(il);
2069 il3945_set_ucode_ptrs(
struct il_priv *il)
2088 D_INFO(
"Runtime uCode pointers are set.\n");
2101 il3945_init_alive_start(
struct il_priv *il)
2107 D_INFO(
"Initialize Alive failed.\n");
2114 if (il3945_verify_ucode(il)) {
2117 D_INFO(
"Bad \"initialize\" uCode load.\n");
2124 D_INFO(
"Initialization Alive received.\n");
2125 if (il3945_set_ucode_ptrs(il)) {
2128 D_INFO(
"Couldn't set up uCode pointers.\n");
2143 il3945_alive_start(
struct il_priv *il)
2145 int thermal_spin = 0;
2148 D_INFO(
"Runtime Alive received.\n");
2153 D_INFO(
"Alive failed.\n");
2160 if (il3945_verify_ucode(il)) {
2163 D_INFO(
"Bad runtime uCode load.\n");
2168 D_INFO(
"RFKILL status: 0x%x\n", rfkill);
2180 D_INFO(
"Thermal calibration took %dus\n",
2191 if (il_is_rfkill(il))
2200 if (il_is_associated(il)) {
2221 D_INFO(
"ALIVE processing complete.\n");
2230 static void il3945_cancel_deferred_work(
struct il_priv *il);
2233 __il3945_down(
struct il_priv *il)
2235 unsigned long flags;
2251 il_clear_driver_stations(il);
2266 il_disable_interrupts(il);
2267 spin_unlock_irqrestore(&il->
lock, flags);
2268 il3945_synchronize_irq(il);
2275 if (!il_is_init(il)) {
2318 il3945_clear_free_frames(il);
2322 il3945_down(
struct il_priv *il)
2328 il3945_cancel_deferred_work(il);
2331 #define MAX_HW_RESTARTS 5
2334 il3945_alloc_bcast_station(
struct il_priv *il)
2336 unsigned long flags;
2342 IL_ERR(
"Unable to prepare broadcast station\n");
2343 spin_unlock_irqrestore(&il->
sta_lock, flags);
2350 spin_unlock_irqrestore(&il->
sta_lock, flags);
2356 __il3945_up(
struct il_priv *il)
2360 rc = il3945_alloc_bcast_station(il);
2365 IL_WARN(
"Exit pending; will not bring the NIC up\n");
2370 IL_ERR(
"ucode not available for device bring up\n");
2379 IL_WARN(
"Radio disabled by HW RF Kill switch\n");
2383 _il_wr(il,
CSR_INT, 0xFFFFFFFF);
2387 IL_ERR(
"Unable to int nic\n");
2396 _il_wr(il,
CSR_INT, 0xFFFFFFFF);
2397 il_enable_interrupts(il);
2418 rc = il->
ops->load_ucode(il);
2421 IL_ERR(
"Unable to set up bootstrap uCode: %d\n", rc);
2426 il3945_nic_start(il);
2439 IL_ERR(
"Unable to initialize device after %d attempts.\n", i);
2459 il3945_init_alive_start(il);
2474 il3945_alive_start(il);
2494 if (new_rfkill != old_rfkill) {
2502 D_RF_KILL(
"RF_KILL bit toggled to %s.\n",
2503 new_rfkill ?
"disable radio" :
"enable radio");
2524 bool is_active =
false;
2535 D_SCAN(
"Fail to allocate scan memory\n");
2545 if (il_is_associated(il)) {
2549 u32 scan_suspend_time = 100;
2551 D_INFO(
"Scanning while associated...\n");
2553 interval = vif->
bss_conf.beacon_int;
2566 extra = (suspend_time /
interval) << 24;
2568 0xFF0FFFFF & (extra | ((suspend_time %
interval) * 1024));
2571 D_SCAN(
"suspend_time 0x%X beacon interval %d\n",
2572 scan_suspend_time, interval);
2577 D_SCAN(
"Kicking off active scan\n");
2593 D_SCAN(
"Kicking off passive scan.\n");
2614 IL_WARN(
"Invalid scan band\n");
2637 il3945_get_channels_for_scan(il, band, is_active, n_probes,
2638 (
void *)&scan->
data[len], vif);
2719 D_ASSOC(
"Associated as %d to: %pM\n", il->
vif->bss_conf.aid,
2727 conf = &il->
hw->conf;
2734 IL_WARN(
"C_RXON_TIMING failed - " "Attempting to continue.\n");
2740 D_ASSOC(
"assoc id %d beacon interval %d\n", il->
vif->bss_conf.aid,
2741 il->
vif->bss_conf.beacon_int);
2743 if (il->
vif->bss_conf.use_short_preamble)
2749 if (il->
vif->bss_conf.use_short_slot)
2757 switch (il->
vif->type) {
2762 il3945_send_beacon_cmd(il);
2765 IL_ERR(
"%s Should not be called in %d mode\n", __func__,
2777 #define UCODE_READY_TIMEOUT (2 * HZ)
2793 ret = il3945_read_ucode(il);
2795 IL_ERR(
"Could not read microcode: %d\n", ret);
2797 goto out_release_irq;
2801 ret = __il3945_up(il);
2806 goto out_release_irq;
2808 D_INFO(
"Start UP work.\n");
2817 IL_ERR(
"Wait for START_ALIVE timeout after %dms.\n",
2820 goto out_release_irq;
2872 D_TX(
"dev->xmit(%d bytes) at rate 0x%02x\n", skb->
len,
2873 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->
bitrate);
2875 if (il3945_tx_skb(il, control->
sta, skb))
2891 if (!(il_is_associated(il))) {
2900 IL_WARN(
"C_RXON_TIMING failed - "
2901 "Attempting to continue.\n");
2905 if (vif->
bss_conf.use_short_preamble)
2920 il3945_send_beacon_cmd(il);
2950 static_key = !il_is_associated(il);
2953 sta_id = il_sta_id_or_broadcast(il, sta);
2966 ret = il3945_set_static_key(il, key);
2968 ret = il3945_set_dynamic_key(il, key, sta_id);
2973 ret = il3945_remove_static_key(il);
2975 ret = il3945_clear_sta_key_info(il, sta_id);
3004 IL_ERR(
"Unable to add station %pM (%d)\n", sta->
addr, ret);
3010 sta_priv->
common.sta_id = sta_id;
3013 D_INFO(
"Initializing rate scaling for station %pM\n", sta->
addr);
3021 il3945_configure_filter(
struct ieee80211_hw *hw,
unsigned int changed_flags,
3022 unsigned int *total_flags,
u64 multicast)
3025 __le32 filter_or = 0, filter_nand = 0;
3027 #define CHK(test, flag) do { \
3028 if (*total_flags & (test)) \
3029 filter_or |= (flag); \
3031 filter_nand |= (flag); \
3034 D_MAC80211(
"Enter: changed: 0x%x, total: 0x%x\n", changed_flags,
3045 il->
staging.filter_flags &= ~filter_nand;
3046 il->
staging.filter_flags |= filter_or;
3073 #ifdef CONFIG_IWLEGACY_DEBUG
3091 return sprintf(buf,
"0x%08X\n", il_get_debug_level(il));
3096 const char *buf,
size_t count)
3104 IL_INFO(
"%s is not in hex or decimal form.\n", buf);
3106 il->debug_level =
val;
3112 il3945_store_debug_level);
3122 if (!il_is_alive(il))
3139 const char *buf,
size_t count)
3142 char *
p = (
char *)buf;
3147 IL_INFO(
": %s is not in decimal form.\n", buf);
3155 il3945_store_tx_power);
3167 const char *buf,
size_t count)
3176 IL_WARN(
"Could not cancel scan.\n");
3178 D_INFO(
"Committing rxon.flags = 0x%04X\n", flags);
3189 il3945_store_flags);
3202 const char *buf,
size_t count)
3211 IL_WARN(
"Could not cancel scan.\n");
3213 D_INFO(
"Committing rxon.filter_flags = " "0x%04X\n",
3225 il3945_store_filter_flags);
3233 u32 size =
sizeof(measure_report), len = 0, ofs = 0;
3234 u8 *data = (
u8 *) &measure_report;
3235 unsigned long flags;
3239 spin_unlock_irqrestore(&il->
lock, flags);
3244 spin_unlock_irqrestore(&il->
lock, flags);
3254 size -=
min(size, 16
U);
3262 const char *buf,
size_t count)
3276 strncpy(buffer, buf,
min(
sizeof(buffer), count));
3282 while (*p && *p !=
' ')
3288 D_INFO(
"Invoking measurement of type %d on " "channel %d (for '%s')\n",
3290 il3945_get_measurement(il, ¶ms, type);
3296 il3945_store_measurement);
3300 const char *buf,
size_t count)
3320 il3945_store_retry_rate);
3336 if (!il_is_alive(il))
3344 const char *buf,
size_t count)
3352 if (
sscanf(buf,
"%1i", &ant) != 1) {
3353 D_INFO(
"not in hex or decimal form.\n");
3357 if (ant >= 0 && ant <= 2) {
3358 D_INFO(
"Setting antenna select to %d.\n", ant);
3361 D_INFO(
"Bad antenna select value %d.\n", ant);
3367 il3945_store_antenna);
3373 if (!il_is_alive(il))
3382 const char *buf,
size_t count)
3385 char *p = (
char *)buf;
3402 il3945_setup_deferred_work(
struct il_priv *il)
3423 (
void (*)(
unsigned long))il3945_irq_tasklet,
3428 il3945_cancel_deferred_work(
struct il_priv *il)
3438 static struct attribute *il3945_sysfs_entries[] = {
3439 &dev_attr_antenna.attr,
3440 &dev_attr_channels.attr,
3441 &dev_attr_dump_errors.attr,
3442 &dev_attr_flags.attr,
3443 &dev_attr_filter_flags.attr,
3444 &dev_attr_measurement.attr,
3445 &dev_attr_retry_rate.attr,
3446 &dev_attr_status.attr,
3447 &dev_attr_temperature.attr,
3448 &dev_attr_tx_power.attr,
3449 #ifdef CONFIG_IWLEGACY_DEBUG
3450 &dev_attr_debug_level.attr,
3457 .attrs = il3945_sysfs_entries,
3461 .tx = il3945_mac_tx,
3462 .start = il3945_mac_start,
3463 .stop = il3945_mac_stop,
3468 .configure_filter = il3945_configure_filter,
3469 .set_key = il3945_mac_set_key,
3474 .sta_add = il3945_mac_sta_add,
3480 il3945_init_drv(
struct il_priv *il)
3506 IL_WARN(
"Unsupported EEPROM version: 0x%04X\n",
3513 IL_ERR(
"initializing regulatory failed: %d\n", ret);
3520 goto err_free_channel_map;
3525 IL_ERR(
"initializing geos failed: %d\n", ret);
3526 goto err_free_channel_map;
3532 err_free_channel_map:
3538 #define IL3945_MAX_PROBE_REQUEST 200
3541 il3945_setup_mac(
struct il_priv *il)
3553 hw->
wiphy->interface_modes =
3579 IL_ERR(
"Failed to register hw (error %d)\n", ret);
3595 unsigned long flags;
3608 SET_IEEE80211_DEV(hw, &pdev->
dev);
3617 D_INFO(
"Disabling hw_scan\n");
3621 D_INFO(
"*** LOAD DRIVER ***\n");
3624 #ifdef CONFIG_IWLEGACY_DEBUGFS
3639 goto out_ieee80211_free_hw;
3646 err = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(32));
3648 IL_WARN(
"No suitable DMA available.\n");
3649 goto out_pci_disable_device;
3652 pci_set_drvdata(pdev, il);
3655 goto out_pci_disable_device;
3663 goto out_pci_release_regions;
3666 D_INFO(
"pci_resource_len = 0x%08llx\n",
3672 pci_write_config_byte(pdev, 0x41, 0x00);
3694 IL_ERR(
"Unable to init EEPROM\n");
3707 IL_ERR(
"failed to set hw settings\n");
3708 goto out_eeprom_free;
3715 err = il3945_init_drv(il);
3717 IL_ERR(
"initializing driver failed\n");
3718 goto out_unset_hw_params;
3721 IL_INFO(
"Detected Intel Wireless WiFi Link %s\n", il->
cfg->name);
3728 il_disable_interrupts(il);
3729 spin_unlock_irqrestore(&il->
lock, flags);
3736 goto out_disable_msi;
3741 IL_ERR(
"failed to create sysfs device attributes\n");
3742 goto out_release_irq;
3746 il3945_setup_deferred_work(il);
3747 il3945_setup_handlers(il);
3754 il_enable_interrupts(il);
3756 err = il3945_setup_mac(il);
3758 goto out_remove_sysfs;
3762 IL_ERR(
"failed to create debugfs files. Ignoring error: %d\n",
3780 out_unset_hw_params:
3781 il3945_unset_hw_params(il);
3786 out_pci_release_regions:
3788 out_pci_disable_device:
3789 pci_set_drvdata(pdev,
NULL);
3791 out_ieee80211_free_hw:
3798 il3945_pci_remove(
struct pci_dev *pdev)
3800 struct il_priv *il = pci_get_drvdata(pdev);
3801 unsigned long flags;
3806 D_INFO(
"*** UNLOAD DRIVER ***\n");
3834 il_disable_interrupts(il);
3835 spin_unlock_irqrestore(&il->
lock, flags);
3837 il3945_synchronize_irq(il);
3843 il3945_dealloc_ucode_pci(il);
3846 il3945_rx_queue_free(il, &il->
rxq);
3849 il3945_unset_hw_params(il);
3866 pci_set_drvdata(pdev,
NULL);
3886 .probe = il3945_pci_probe,
3901 pr_err(
"Unable to register rate control algorithm: %d\n", ret);
3905 ret = pci_register_driver(&il3945_driver);
3907 pr_err(
"Unable to initialize PCI module\n");
3908 goto error_register;
3930 MODULE_PARM_DESC(swcrypto,
"using software crypto (default 1 [software])");
3933 MODULE_PARM_DESC(disable_hw_scan,
"disable hardware scanning (default 1)");
3934 #ifdef CONFIG_IWLEGACY_DEBUG