.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /****************************************************************************** |
---|
2 | 3 | * |
---|
3 | 4 | * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. |
---|
4 | 5 | * |
---|
5 | 6 | * Portions of this file are derived from the ipw3945 project, as well |
---|
6 | 7 | * as portions of the ieee80211 subsystem header files. |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify it |
---|
9 | | - * under the terms of version 2 of the GNU General Public License as |
---|
10 | | - * published by the Free Software Foundation. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
---|
13 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
14 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
15 | | - * more details. |
---|
16 | | - * |
---|
17 | | - * You should have received a copy of the GNU General Public License along with |
---|
18 | | - * this program; if not, write to the Free Software Foundation, Inc., |
---|
19 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
---|
20 | | - * |
---|
21 | | - * The full GNU General Public License is included in this distribution in the |
---|
22 | | - * file called LICENSE. |
---|
23 | 8 | * |
---|
24 | 9 | * Contact Information: |
---|
25 | 10 | * Intel Linux Wireless <ilw@linux.intel.com> |
---|
.. | .. |
---|
33 | 18 | #include <linux/module.h> |
---|
34 | 19 | #include <linux/init.h> |
---|
35 | 20 | #include <linux/pci.h> |
---|
36 | | -#include <linux/pci-aspm.h> |
---|
37 | 21 | #include <linux/slab.h> |
---|
38 | 22 | #include <linux/dma-mapping.h> |
---|
39 | 23 | #include <linux/delay.h> |
---|
.. | .. |
---|
43 | 27 | #include <linux/firmware.h> |
---|
44 | 28 | #include <linux/etherdevice.h> |
---|
45 | 29 | #include <linux/if_arp.h> |
---|
| 30 | +#include <linux/units.h> |
---|
46 | 31 | |
---|
47 | 32 | #include <net/mac80211.h> |
---|
48 | 33 | |
---|
.. | .. |
---|
241 | 226 | return 0; |
---|
242 | 227 | } |
---|
243 | 228 | |
---|
244 | | -/** |
---|
| 229 | +/* |
---|
245 | 230 | * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr |
---|
246 | 231 | */ |
---|
247 | 232 | static inline __le32 |
---|
.. | .. |
---|
250 | 235 | return cpu_to_le32((u32) (dma_addr >> 8)); |
---|
251 | 236 | } |
---|
252 | 237 | |
---|
253 | | -/** |
---|
| 238 | +/* |
---|
254 | 239 | * il4965_rx_queue_restock - refill RX queue from pre-allocated pool |
---|
255 | 240 | * |
---|
256 | 241 | * If there are slots in the RX queue that need to be restocked, |
---|
.. | .. |
---|
303 | 288 | } |
---|
304 | 289 | } |
---|
305 | 290 | |
---|
306 | | -/** |
---|
| 291 | +/* |
---|
307 | 292 | * il4965_rx_replenish - Move all used packet from rx_used to rx_free |
---|
308 | 293 | * |
---|
309 | 294 | * When moving to rx_free an SKB is allocated for the slot. |
---|
.. | .. |
---|
559 | 544 | decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK; |
---|
560 | 545 | break; |
---|
561 | 546 | } |
---|
562 | | - /* fall through if TTAK OK */ |
---|
| 547 | + fallthrough; /* if TTAK OK */ |
---|
563 | 548 | default: |
---|
564 | 549 | if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK)) |
---|
565 | 550 | decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC; |
---|
.. | .. |
---|
1142 | 1127 | return res; |
---|
1143 | 1128 | } |
---|
1144 | 1129 | |
---|
1145 | | -/** |
---|
| 1130 | +/* |
---|
1146 | 1131 | * il4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image |
---|
1147 | 1132 | * |
---|
1148 | 1133 | * Selects how many and which Rx receivers/antennas/chains to use. |
---|
.. | .. |
---|
1430 | 1415 | /* |
---|
1431 | 1416 | * mac80211 queues, ACs, hardware queues, FIFOs. |
---|
1432 | 1417 | * |
---|
1433 | | - * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues |
---|
| 1418 | + * Cf. https://wireless.wiki.kernel.org/en/developers/Documentation/mac80211/queues |
---|
1434 | 1419 | * |
---|
1435 | 1420 | * Mac80211 uses the following numbers, which we get as from it |
---|
1436 | 1421 | * by way of skb_get_queue_mapping(skb): |
---|
.. | .. |
---|
1632 | 1617 | |
---|
1633 | 1618 | case WLAN_CIPHER_SUITE_WEP104: |
---|
1634 | 1619 | tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; |
---|
1635 | | - /* fall through */ |
---|
| 1620 | + fallthrough; |
---|
1636 | 1621 | case WLAN_CIPHER_SUITE_WEP40: |
---|
1637 | 1622 | tx_cmd->sec_ctl |= |
---|
1638 | 1623 | (TX_CMD_SEC_WEP | (keyconf->keyidx & TX_CMD_SEC_MSK) << |
---|
.. | .. |
---|
1948 | 1933 | memset(ptr, 0, sizeof(*ptr)); |
---|
1949 | 1934 | } |
---|
1950 | 1935 | |
---|
1951 | | -/** |
---|
| 1936 | +/* |
---|
1952 | 1937 | * il4965_hw_txq_ctx_free - Free TXQ Context |
---|
1953 | 1938 | * |
---|
1954 | 1939 | * Destroy all TX DMA queues and structures |
---|
.. | .. |
---|
1974 | 1959 | il_free_txq_mem(il); |
---|
1975 | 1960 | } |
---|
1976 | 1961 | |
---|
1977 | | -/** |
---|
| 1962 | +/* |
---|
1978 | 1963 | * il4965_txq_ctx_alloc - allocate TX queue context |
---|
1979 | 1964 | * Allocate all Tx DMA structures and initialize them |
---|
1980 | | - * |
---|
1981 | | - * @param il |
---|
1982 | | - * @return error code |
---|
1983 | 1965 | */ |
---|
1984 | 1966 | int |
---|
1985 | 1967 | il4965_txq_ctx_alloc(struct il_priv *il) |
---|
.. | .. |
---|
2075 | 2057 | il_tx_queue_unmap(il, txq_id); |
---|
2076 | 2058 | } |
---|
2077 | 2059 | |
---|
2078 | | -/** |
---|
| 2060 | +/* |
---|
2079 | 2061 | * il4965_txq_ctx_stop - Stop all Tx DMA channels |
---|
2080 | 2062 | */ |
---|
2081 | 2063 | void |
---|
.. | .. |
---|
2116 | 2098 | return -1; |
---|
2117 | 2099 | } |
---|
2118 | 2100 | |
---|
2119 | | -/** |
---|
| 2101 | +/* |
---|
2120 | 2102 | * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration |
---|
2121 | 2103 | */ |
---|
2122 | 2104 | static void |
---|
.. | .. |
---|
2129 | 2111 | (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); |
---|
2130 | 2112 | } |
---|
2131 | 2113 | |
---|
2132 | | -/** |
---|
| 2114 | +/* |
---|
2133 | 2115 | * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue |
---|
2134 | 2116 | */ |
---|
2135 | 2117 | static int |
---|
.. | .. |
---|
2156 | 2138 | return 0; |
---|
2157 | 2139 | } |
---|
2158 | 2140 | |
---|
2159 | | -/** |
---|
| 2141 | +/* |
---|
2160 | 2142 | * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue |
---|
2161 | 2143 | * |
---|
2162 | 2144 | * NOTE: txq_id must be greater than IL49_FIRST_AMPDU_QUEUE, |
---|
.. | .. |
---|
2281 | 2263 | if (tid_data->tfds_in_queue == 0) { |
---|
2282 | 2264 | D_HT("HW queue is empty\n"); |
---|
2283 | 2265 | tid_data->agg.state = IL_AGG_ON; |
---|
2284 | | - ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); |
---|
| 2266 | + ret = IEEE80211_AMPDU_TX_START_IMMEDIATE; |
---|
2285 | 2267 | } else { |
---|
2286 | 2268 | D_HT("HW queue is NOT empty: %d packets in HW queue\n", |
---|
2287 | 2269 | tid_data->tfds_in_queue); |
---|
.. | .. |
---|
2291 | 2273 | return ret; |
---|
2292 | 2274 | } |
---|
2293 | 2275 | |
---|
2294 | | -/** |
---|
| 2276 | +/* |
---|
2295 | 2277 | * txq_id must be greater than IL49_FIRST_AMPDU_QUEUE |
---|
2296 | 2278 | * il->lock must be held by the caller |
---|
2297 | 2279 | */ |
---|
.. | .. |
---|
2503 | 2485 | return nfreed; |
---|
2504 | 2486 | } |
---|
2505 | 2487 | |
---|
2506 | | -/** |
---|
| 2488 | +/* |
---|
2507 | 2489 | * il4965_tx_status_reply_compressed_ba - Update tx status from block-ack |
---|
2508 | 2490 | * |
---|
2509 | 2491 | * Go through block-ack's bitmap of ACK'd frames, update driver's record of |
---|
.. | .. |
---|
2656 | 2638 | } |
---|
2657 | 2639 | } |
---|
2658 | 2640 | |
---|
2659 | | -/** |
---|
| 2641 | +/* |
---|
2660 | 2642 | * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue |
---|
2661 | 2643 | */ |
---|
2662 | 2644 | static int |
---|
.. | .. |
---|
2768 | 2750 | return 0; |
---|
2769 | 2751 | } |
---|
2770 | 2752 | |
---|
2771 | | -/** |
---|
| 2753 | +/* |
---|
2772 | 2754 | * il4965_hdl_tx - Handle standard (non-aggregation) Tx response |
---|
2773 | 2755 | */ |
---|
2774 | 2756 | static void |
---|
.. | .. |
---|
2784 | 2766 | struct ieee80211_tx_info *info; |
---|
2785 | 2767 | struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; |
---|
2786 | 2768 | u32 status = le32_to_cpu(tx_resp->u.status); |
---|
2787 | | - int uninitialized_var(tid); |
---|
| 2769 | + int tid; |
---|
2788 | 2770 | int sta_id; |
---|
2789 | 2771 | int freed; |
---|
2790 | 2772 | u8 *qc = NULL; |
---|
.. | .. |
---|
2888 | 2870 | spin_unlock_irqrestore(&il->sta_lock, flags); |
---|
2889 | 2871 | } |
---|
2890 | 2872 | |
---|
2891 | | -/** |
---|
| 2873 | +/* |
---|
2892 | 2874 | * translate ucode response to mac80211 tx status control values |
---|
2893 | 2875 | */ |
---|
2894 | 2876 | void |
---|
.. | .. |
---|
2912 | 2894 | r->idx = il4965_hwrate_to_mac80211_idx(rate_n_flags, info->band); |
---|
2913 | 2895 | } |
---|
2914 | 2896 | |
---|
2915 | | -/** |
---|
| 2897 | +/* |
---|
2916 | 2898 | * il4965_hdl_compressed_ba - Handler for N_COMPRESSED_BA |
---|
2917 | 2899 | * |
---|
2918 | 2900 | * Handles block-acknowledge notification from device, which reports success |
---|
.. | .. |
---|
3347 | 3329 | struct ieee80211_key_conf *keyconf, u8 sta_id) |
---|
3348 | 3330 | { |
---|
3349 | 3331 | unsigned long flags; |
---|
3350 | | - int ret = 0; |
---|
3351 | 3332 | __le16 key_flags = 0; |
---|
3352 | 3333 | |
---|
3353 | 3334 | key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK); |
---|
.. | .. |
---|
3384 | 3365 | |
---|
3385 | 3366 | spin_unlock_irqrestore(&il->sta_lock, flags); |
---|
3386 | 3367 | |
---|
3387 | | - return ret; |
---|
| 3368 | + return 0; |
---|
3388 | 3369 | } |
---|
3389 | 3370 | |
---|
3390 | 3371 | void |
---|
.. | .. |
---|
3518 | 3499 | return ret; |
---|
3519 | 3500 | } |
---|
3520 | 3501 | |
---|
3521 | | -/** |
---|
| 3502 | +/* |
---|
3522 | 3503 | * il4965_alloc_bcast_station - add broadcast station into driver's station table. |
---|
3523 | 3504 | * |
---|
3524 | 3505 | * This adds the broadcast station into the driver's station table |
---|
.. | .. |
---|
3559 | 3540 | return 0; |
---|
3560 | 3541 | } |
---|
3561 | 3542 | |
---|
3562 | | -/** |
---|
| 3543 | +/* |
---|
3563 | 3544 | * il4965_update_bcast_station - update broadcast station's LQ command |
---|
3564 | 3545 | * |
---|
3565 | 3546 | * Only used by iwl4965. Placed here to have all bcast station management |
---|
.. | .. |
---|
3595 | 3576 | return il4965_update_bcast_station(il); |
---|
3596 | 3577 | } |
---|
3597 | 3578 | |
---|
3598 | | -/** |
---|
| 3579 | +/* |
---|
3599 | 3580 | * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table |
---|
3600 | 3581 | */ |
---|
3601 | 3582 | int |
---|
.. | .. |
---|
3919 | 3900 | return tfd->num_tbs & 0x1f; |
---|
3920 | 3901 | } |
---|
3921 | 3902 | |
---|
3922 | | -/** |
---|
| 3903 | +/* |
---|
3923 | 3904 | * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] |
---|
3924 | | - * @il - driver ilate data |
---|
3925 | | - * @txq - tx queue |
---|
3926 | 3905 | * |
---|
3927 | 3906 | * Does NOT advance any TFD circular buffer read/write idxes |
---|
3928 | 3907 | * Does NOT free the TFD itself (which is within circular buffer) |
---|
.. | .. |
---|
4060 | 4039 | IL_WARN("uCode did not respond OK.\n"); |
---|
4061 | 4040 | } |
---|
4062 | 4041 | |
---|
4063 | | -/** |
---|
| 4042 | +/* |
---|
4064 | 4043 | * il4965_bg_stats_periodic - Timer callback to queue stats |
---|
4065 | 4044 | * |
---|
4066 | 4045 | * This callback is provided in order to send a stats request. |
---|
.. | .. |
---|
4171 | 4150 | wake_up(&il->wait_command_queue); |
---|
4172 | 4151 | } |
---|
4173 | 4152 | |
---|
4174 | | -/** |
---|
| 4153 | +/* |
---|
4175 | 4154 | * il4965_setup_handlers - Initialize Rx handler callbacks |
---|
4176 | 4155 | * |
---|
4177 | 4156 | * Setup the RX handlers for each of the reply types sent from the uCode |
---|
.. | .. |
---|
4215 | 4194 | il->handlers[C_TX] = il4965_hdl_tx; |
---|
4216 | 4195 | } |
---|
4217 | 4196 | |
---|
4218 | | -/** |
---|
| 4197 | +/* |
---|
4219 | 4198 | * il4965_rx_handle - Main entry function for receiving responses from uCode |
---|
4220 | 4199 | * |
---|
4221 | 4200 | * Uses the il->handlers callback function array to invoke |
---|
.. | .. |
---|
4360 | 4339 | } |
---|
4361 | 4340 | |
---|
4362 | 4341 | static void |
---|
4363 | | -il4965_irq_tasklet(unsigned long data) |
---|
| 4342 | +il4965_irq_tasklet(struct tasklet_struct *t) |
---|
4364 | 4343 | { |
---|
4365 | | - struct il_priv *il = (struct il_priv *)data; |
---|
| 4344 | + struct il_priv *il = from_tasklet(il, t, irq_tasklet); |
---|
4366 | 4345 | u32 inta, handled = 0; |
---|
4367 | 4346 | u32 inta_fh; |
---|
4368 | 4347 | unsigned long flags; |
---|
.. | .. |
---|
4772 | 4751 | return 0; |
---|
4773 | 4752 | } |
---|
4774 | 4753 | |
---|
4775 | | -/** |
---|
| 4754 | +/* |
---|
4776 | 4755 | * il4965_ucode_callback - callback when firmware was loaded |
---|
4777 | 4756 | * |
---|
4778 | 4757 | * If loaded successfully, copies the firmware into buffers |
---|
.. | .. |
---|
4989 | 4968 | if (err) |
---|
4990 | 4969 | goto out_unbind; |
---|
4991 | 4970 | |
---|
4992 | | - err = il_dbgfs_register(il, DRV_NAME); |
---|
4993 | | - if (err) |
---|
4994 | | - IL_ERR("failed to create debugfs files. Ignoring error: %d\n", |
---|
4995 | | - err); |
---|
| 4971 | + il_dbgfs_register(il, DRV_NAME); |
---|
4996 | 4972 | |
---|
4997 | 4973 | err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group); |
---|
4998 | 4974 | if (err) { |
---|
.. | .. |
---|
5278 | 5254 | return 0; |
---|
5279 | 5255 | } |
---|
5280 | 5256 | |
---|
5281 | | -/** |
---|
| 5257 | +/* |
---|
5282 | 5258 | * il4965_alive_start - called after N_ALIVE notification received |
---|
5283 | 5259 | * from protocol/runtime uCode (initialization uCode's |
---|
5284 | 5260 | * Alive gets handled by il_init_alive_start()). |
---|
.. | .. |
---|
6236 | 6212 | mutex_unlock(&il->mutex); |
---|
6237 | 6213 | } |
---|
6238 | 6214 | |
---|
6239 | | -static void |
---|
| 6215 | +static int |
---|
6240 | 6216 | il4965_setup_deferred_work(struct il_priv *il) |
---|
6241 | 6217 | { |
---|
6242 | 6218 | il->workqueue = create_singlethread_workqueue(DRV_NAME); |
---|
| 6219 | + if (!il->workqueue) |
---|
| 6220 | + return -ENOMEM; |
---|
6243 | 6221 | |
---|
6244 | 6222 | init_waitqueue_head(&il->wait_command_queue); |
---|
6245 | 6223 | |
---|
.. | .. |
---|
6257 | 6235 | |
---|
6258 | 6236 | timer_setup(&il->watchdog, il_bg_watchdog, 0); |
---|
6259 | 6237 | |
---|
6260 | | - tasklet_init(&il->irq_tasklet, |
---|
6261 | | - il4965_irq_tasklet, |
---|
6262 | | - (unsigned long)il); |
---|
| 6238 | + tasklet_setup(&il->irq_tasklet, il4965_irq_tasklet); |
---|
| 6239 | + |
---|
| 6240 | + return 0; |
---|
6263 | 6241 | } |
---|
6264 | 6242 | |
---|
6265 | 6243 | static void |
---|
.. | .. |
---|
6488 | 6466 | il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; |
---|
6489 | 6467 | |
---|
6490 | 6468 | il->hw_params.ct_kill_threshold = |
---|
6491 | | - CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); |
---|
| 6469 | + celsius_to_kelvin(CT_KILL_THRESHOLD_LEGACY); |
---|
6492 | 6470 | |
---|
6493 | 6471 | il->hw_params.sens = &il4965_sensitivity; |
---|
6494 | 6472 | il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; |
---|
.. | .. |
---|
6649 | 6627 | goto out_disable_msi; |
---|
6650 | 6628 | } |
---|
6651 | 6629 | |
---|
6652 | | - il4965_setup_deferred_work(il); |
---|
| 6630 | + err = il4965_setup_deferred_work(il); |
---|
| 6631 | + if (err) |
---|
| 6632 | + goto out_free_irq; |
---|
| 6633 | + |
---|
6653 | 6634 | il4965_setup_handlers(il); |
---|
6654 | 6635 | |
---|
6655 | 6636 | /********************************************* |
---|
.. | .. |
---|
6687 | 6668 | out_destroy_workqueue: |
---|
6688 | 6669 | destroy_workqueue(il->workqueue); |
---|
6689 | 6670 | il->workqueue = NULL; |
---|
| 6671 | +out_free_irq: |
---|
6690 | 6672 | free_irq(il->pci_dev->irq, il); |
---|
6691 | 6673 | out_disable_msi: |
---|
6692 | 6674 | pci_disable_msi(il->pci_dev); |
---|