hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/wireless/intel/iwlegacy/4965-mac.c
....@@ -1,25 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /******************************************************************************
23 *
34 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
45 *
56 * Portions of this file are derived from the ipw3945 project, as well
67 * 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.
238 *
249 * Contact Information:
2510 * Intel Linux Wireless <ilw@linux.intel.com>
....@@ -33,7 +18,6 @@
3318 #include <linux/module.h>
3419 #include <linux/init.h>
3520 #include <linux/pci.h>
36
-#include <linux/pci-aspm.h>
3721 #include <linux/slab.h>
3822 #include <linux/dma-mapping.h>
3923 #include <linux/delay.h>
....@@ -43,6 +27,7 @@
4327 #include <linux/firmware.h>
4428 #include <linux/etherdevice.h>
4529 #include <linux/if_arp.h>
30
+#include <linux/units.h>
4631
4732 #include <net/mac80211.h>
4833
....@@ -241,7 +226,7 @@
241226 return 0;
242227 }
243228
244
-/**
229
+/*
245230 * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr
246231 */
247232 static inline __le32
....@@ -250,7 +235,7 @@
250235 return cpu_to_le32((u32) (dma_addr >> 8));
251236 }
252237
253
-/**
238
+/*
254239 * il4965_rx_queue_restock - refill RX queue from pre-allocated pool
255240 *
256241 * If there are slots in the RX queue that need to be restocked,
....@@ -303,7 +288,7 @@
303288 }
304289 }
305290
306
-/**
291
+/*
307292 * il4965_rx_replenish - Move all used packet from rx_used to rx_free
308293 *
309294 * When moving to rx_free an SKB is allocated for the slot.
....@@ -559,7 +544,7 @@
559544 decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK;
560545 break;
561546 }
562
- /* fall through if TTAK OK */
547
+ fallthrough; /* if TTAK OK */
563548 default:
564549 if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK))
565550 decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;
....@@ -1142,7 +1127,7 @@
11421127 return res;
11431128 }
11441129
1145
-/**
1130
+/*
11461131 * il4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image
11471132 *
11481133 * Selects how many and which Rx receivers/antennas/chains to use.
....@@ -1430,7 +1415,7 @@
14301415 /*
14311416 * mac80211 queues, ACs, hardware queues, FIFOs.
14321417 *
1433
- * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues
1418
+ * Cf. https://wireless.wiki.kernel.org/en/developers/Documentation/mac80211/queues
14341419 *
14351420 * Mac80211 uses the following numbers, which we get as from it
14361421 * by way of skb_get_queue_mapping(skb):
....@@ -1632,7 +1617,7 @@
16321617
16331618 case WLAN_CIPHER_SUITE_WEP104:
16341619 tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
1635
- /* fall through */
1620
+ fallthrough;
16361621 case WLAN_CIPHER_SUITE_WEP40:
16371622 tx_cmd->sec_ctl |=
16381623 (TX_CMD_SEC_WEP | (keyconf->keyidx & TX_CMD_SEC_MSK) <<
....@@ -1948,7 +1933,7 @@
19481933 memset(ptr, 0, sizeof(*ptr));
19491934 }
19501935
1951
-/**
1936
+/*
19521937 * il4965_hw_txq_ctx_free - Free TXQ Context
19531938 *
19541939 * Destroy all TX DMA queues and structures
....@@ -1974,12 +1959,9 @@
19741959 il_free_txq_mem(il);
19751960 }
19761961
1977
-/**
1962
+/*
19781963 * il4965_txq_ctx_alloc - allocate TX queue context
19791964 * Allocate all Tx DMA structures and initialize them
1980
- *
1981
- * @param il
1982
- * @return error code
19831965 */
19841966 int
19851967 il4965_txq_ctx_alloc(struct il_priv *il)
....@@ -2075,7 +2057,7 @@
20752057 il_tx_queue_unmap(il, txq_id);
20762058 }
20772059
2078
-/**
2060
+/*
20792061 * il4965_txq_ctx_stop - Stop all Tx DMA channels
20802062 */
20812063 void
....@@ -2116,7 +2098,7 @@
21162098 return -1;
21172099 }
21182100
2119
-/**
2101
+/*
21202102 * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration
21212103 */
21222104 static void
....@@ -2129,7 +2111,7 @@
21292111 (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN));
21302112 }
21312113
2132
-/**
2114
+/*
21332115 * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue
21342116 */
21352117 static int
....@@ -2156,7 +2138,7 @@
21562138 return 0;
21572139 }
21582140
2159
-/**
2141
+/*
21602142 * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue
21612143 *
21622144 * NOTE: txq_id must be greater than IL49_FIRST_AMPDU_QUEUE,
....@@ -2281,7 +2263,7 @@
22812263 if (tid_data->tfds_in_queue == 0) {
22822264 D_HT("HW queue is empty\n");
22832265 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;
22852267 } else {
22862268 D_HT("HW queue is NOT empty: %d packets in HW queue\n",
22872269 tid_data->tfds_in_queue);
....@@ -2291,7 +2273,7 @@
22912273 return ret;
22922274 }
22932275
2294
-/**
2276
+/*
22952277 * txq_id must be greater than IL49_FIRST_AMPDU_QUEUE
22962278 * il->lock must be held by the caller
22972279 */
....@@ -2503,7 +2485,7 @@
25032485 return nfreed;
25042486 }
25052487
2506
-/**
2488
+/*
25072489 * il4965_tx_status_reply_compressed_ba - Update tx status from block-ack
25082490 *
25092491 * Go through block-ack's bitmap of ACK'd frames, update driver's record of
....@@ -2656,7 +2638,7 @@
26562638 }
26572639 }
26582640
2659
-/**
2641
+/*
26602642 * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue
26612643 */
26622644 static int
....@@ -2768,7 +2750,7 @@
27682750 return 0;
27692751 }
27702752
2771
-/**
2753
+/*
27722754 * il4965_hdl_tx - Handle standard (non-aggregation) Tx response
27732755 */
27742756 static void
....@@ -2784,7 +2766,7 @@
27842766 struct ieee80211_tx_info *info;
27852767 struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
27862768 u32 status = le32_to_cpu(tx_resp->u.status);
2787
- int uninitialized_var(tid);
2769
+ int tid;
27882770 int sta_id;
27892771 int freed;
27902772 u8 *qc = NULL;
....@@ -2888,7 +2870,7 @@
28882870 spin_unlock_irqrestore(&il->sta_lock, flags);
28892871 }
28902872
2891
-/**
2873
+/*
28922874 * translate ucode response to mac80211 tx status control values
28932875 */
28942876 void
....@@ -2912,7 +2894,7 @@
29122894 r->idx = il4965_hwrate_to_mac80211_idx(rate_n_flags, info->band);
29132895 }
29142896
2915
-/**
2897
+/*
29162898 * il4965_hdl_compressed_ba - Handler for N_COMPRESSED_BA
29172899 *
29182900 * Handles block-acknowledge notification from device, which reports success
....@@ -3347,7 +3329,6 @@
33473329 struct ieee80211_key_conf *keyconf, u8 sta_id)
33483330 {
33493331 unsigned long flags;
3350
- int ret = 0;
33513332 __le16 key_flags = 0;
33523333
33533334 key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
....@@ -3384,7 +3365,7 @@
33843365
33853366 spin_unlock_irqrestore(&il->sta_lock, flags);
33863367
3387
- return ret;
3368
+ return 0;
33883369 }
33893370
33903371 void
....@@ -3518,7 +3499,7 @@
35183499 return ret;
35193500 }
35203501
3521
-/**
3502
+/*
35223503 * il4965_alloc_bcast_station - add broadcast station into driver's station table.
35233504 *
35243505 * This adds the broadcast station into the driver's station table
....@@ -3559,7 +3540,7 @@
35593540 return 0;
35603541 }
35613542
3562
-/**
3543
+/*
35633544 * il4965_update_bcast_station - update broadcast station's LQ command
35643545 *
35653546 * Only used by iwl4965. Placed here to have all bcast station management
....@@ -3595,7 +3576,7 @@
35953576 return il4965_update_bcast_station(il);
35963577 }
35973578
3598
-/**
3579
+/*
35993580 * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table
36003581 */
36013582 int
....@@ -3919,10 +3900,8 @@
39193900 return tfd->num_tbs & 0x1f;
39203901 }
39213902
3922
-/**
3903
+/*
39233904 * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr]
3924
- * @il - driver ilate data
3925
- * @txq - tx queue
39263905 *
39273906 * Does NOT advance any TFD circular buffer read/write idxes
39283907 * Does NOT free the TFD itself (which is within circular buffer)
....@@ -4060,7 +4039,7 @@
40604039 IL_WARN("uCode did not respond OK.\n");
40614040 }
40624041
4063
-/**
4042
+/*
40644043 * il4965_bg_stats_periodic - Timer callback to queue stats
40654044 *
40664045 * This callback is provided in order to send a stats request.
....@@ -4171,7 +4150,7 @@
41714150 wake_up(&il->wait_command_queue);
41724151 }
41734152
4174
-/**
4153
+/*
41754154 * il4965_setup_handlers - Initialize Rx handler callbacks
41764155 *
41774156 * Setup the RX handlers for each of the reply types sent from the uCode
....@@ -4215,7 +4194,7 @@
42154194 il->handlers[C_TX] = il4965_hdl_tx;
42164195 }
42174196
4218
-/**
4197
+/*
42194198 * il4965_rx_handle - Main entry function for receiving responses from uCode
42204199 *
42214200 * Uses the il->handlers callback function array to invoke
....@@ -4360,9 +4339,9 @@
43604339 }
43614340
43624341 static void
4363
-il4965_irq_tasklet(unsigned long data)
4342
+il4965_irq_tasklet(struct tasklet_struct *t)
43644343 {
4365
- struct il_priv *il = (struct il_priv *)data;
4344
+ struct il_priv *il = from_tasklet(il, t, irq_tasklet);
43664345 u32 inta, handled = 0;
43674346 u32 inta_fh;
43684347 unsigned long flags;
....@@ -4772,7 +4751,7 @@
47724751 return 0;
47734752 }
47744753
4775
-/**
4754
+/*
47764755 * il4965_ucode_callback - callback when firmware was loaded
47774756 *
47784757 * If loaded successfully, copies the firmware into buffers
....@@ -4989,10 +4968,7 @@
49894968 if (err)
49904969 goto out_unbind;
49914970
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);
49964972
49974973 err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group);
49984974 if (err) {
....@@ -5278,7 +5254,7 @@
52785254 return 0;
52795255 }
52805256
5281
-/**
5257
+/*
52825258 * il4965_alive_start - called after N_ALIVE notification received
52835259 * from protocol/runtime uCode (initialization uCode's
52845260 * Alive gets handled by il_init_alive_start()).
....@@ -6236,10 +6212,12 @@
62366212 mutex_unlock(&il->mutex);
62376213 }
62386214
6239
-static void
6215
+static int
62406216 il4965_setup_deferred_work(struct il_priv *il)
62416217 {
62426218 il->workqueue = create_singlethread_workqueue(DRV_NAME);
6219
+ if (!il->workqueue)
6220
+ return -ENOMEM;
62436221
62446222 init_waitqueue_head(&il->wait_command_queue);
62456223
....@@ -6257,9 +6235,9 @@
62576235
62586236 timer_setup(&il->watchdog, il_bg_watchdog, 0);
62596237
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;
62636241 }
62646242
62656243 static void
....@@ -6488,7 +6466,7 @@
64886466 il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant;
64896467
64906468 il->hw_params.ct_kill_threshold =
6491
- CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY);
6469
+ celsius_to_kelvin(CT_KILL_THRESHOLD_LEGACY);
64926470
64936471 il->hw_params.sens = &il4965_sensitivity;
64946472 il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS;
....@@ -6649,7 +6627,10 @@
66496627 goto out_disable_msi;
66506628 }
66516629
6652
- il4965_setup_deferred_work(il);
6630
+ err = il4965_setup_deferred_work(il);
6631
+ if (err)
6632
+ goto out_free_irq;
6633
+
66536634 il4965_setup_handlers(il);
66546635
66556636 /*********************************************
....@@ -6687,6 +6668,7 @@
66876668 out_destroy_workqueue:
66886669 destroy_workqueue(il->workqueue);
66896670 il->workqueue = NULL;
6671
+out_free_irq:
66906672 free_irq(il->pci_dev->irq, il);
66916673 out_disable_msi:
66926674 pci_disable_msi(il->pci_dev);