diff options
author | David S. Miller <davem@davemloft.net> | 2008-05-15 03:52:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-05-15 03:52:37 -0400 |
commit | f42a44494bcdf03fc851c03d438464d59c0ceaf5 (patch) | |
tree | 986ea7b54e9fc79a64863fd7e92eabd99ffd37a3 /drivers/net/wireless/iwlwifi/iwl4965-base.c | |
parent | 63fe46da9c380b3f2bbdf3765044649517cc717c (diff) | |
parent | ef85ad541f9a6ccd3f89ec73f92b2d6f45a9d3e8 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl4965-base.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl4965-base.c | 1135 |
1 files changed, 275 insertions, 860 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 4406fc72d881..55ca752ae9e6 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c | |||
@@ -54,7 +54,7 @@ | |||
54 | #include "iwl-calib.h" | 54 | #include "iwl-calib.h" |
55 | 55 | ||
56 | static int iwl4965_tx_queue_update_write_ptr(struct iwl_priv *priv, | 56 | static int iwl4965_tx_queue_update_write_ptr(struct iwl_priv *priv, |
57 | struct iwl4965_tx_queue *txq); | 57 | struct iwl_tx_queue *txq); |
58 | 58 | ||
59 | /****************************************************************************** | 59 | /****************************************************************************** |
60 | * | 60 | * |
@@ -145,6 +145,7 @@ static const char *iwl4965_escape_essid(const char *essid, u8 essid_len) | |||
145 | return escaped; | 145 | return escaped; |
146 | } | 146 | } |
147 | 147 | ||
148 | |||
148 | /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** | 149 | /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** |
149 | * DMA services | 150 | * DMA services |
150 | * | 151 | * |
@@ -206,173 +207,6 @@ static inline u8 get_cmd_index(struct iwl4965_queue *q, u32 index, int is_huge) | |||
206 | return index & (q->n_window - 1); | 207 | return index & (q->n_window - 1); |
207 | } | 208 | } |
208 | 209 | ||
209 | /** | ||
210 | * iwl4965_queue_init - Initialize queue's high/low-water and read/write indexes | ||
211 | */ | ||
212 | static int iwl4965_queue_init(struct iwl_priv *priv, struct iwl4965_queue *q, | ||
213 | int count, int slots_num, u32 id) | ||
214 | { | ||
215 | q->n_bd = count; | ||
216 | q->n_window = slots_num; | ||
217 | q->id = id; | ||
218 | |||
219 | /* count must be power-of-two size, otherwise iwl_queue_inc_wrap | ||
220 | * and iwl_queue_dec_wrap are broken. */ | ||
221 | BUG_ON(!is_power_of_2(count)); | ||
222 | |||
223 | /* slots_num must be power-of-two size, otherwise | ||
224 | * get_cmd_index is broken. */ | ||
225 | BUG_ON(!is_power_of_2(slots_num)); | ||
226 | |||
227 | q->low_mark = q->n_window / 4; | ||
228 | if (q->low_mark < 4) | ||
229 | q->low_mark = 4; | ||
230 | |||
231 | q->high_mark = q->n_window / 8; | ||
232 | if (q->high_mark < 2) | ||
233 | q->high_mark = 2; | ||
234 | |||
235 | q->write_ptr = q->read_ptr = 0; | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * iwl4965_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue | ||
242 | */ | ||
243 | static int iwl4965_tx_queue_alloc(struct iwl_priv *priv, | ||
244 | struct iwl4965_tx_queue *txq, u32 id) | ||
245 | { | ||
246 | struct pci_dev *dev = priv->pci_dev; | ||
247 | |||
248 | /* Driver private data, only for Tx (not command) queues, | ||
249 | * not shared with device. */ | ||
250 | if (id != IWL_CMD_QUEUE_NUM) { | ||
251 | txq->txb = kmalloc(sizeof(txq->txb[0]) * | ||
252 | TFD_QUEUE_SIZE_MAX, GFP_KERNEL); | ||
253 | if (!txq->txb) { | ||
254 | IWL_ERROR("kmalloc for auxiliary BD " | ||
255 | "structures failed\n"); | ||
256 | goto error; | ||
257 | } | ||
258 | } else | ||
259 | txq->txb = NULL; | ||
260 | |||
261 | /* Circular buffer of transmit frame descriptors (TFDs), | ||
262 | * shared with device */ | ||
263 | txq->bd = pci_alloc_consistent(dev, | ||
264 | sizeof(txq->bd[0]) * TFD_QUEUE_SIZE_MAX, | ||
265 | &txq->q.dma_addr); | ||
266 | |||
267 | if (!txq->bd) { | ||
268 | IWL_ERROR("pci_alloc_consistent(%zd) failed\n", | ||
269 | sizeof(txq->bd[0]) * TFD_QUEUE_SIZE_MAX); | ||
270 | goto error; | ||
271 | } | ||
272 | txq->q.id = id; | ||
273 | |||
274 | return 0; | ||
275 | |||
276 | error: | ||
277 | if (txq->txb) { | ||
278 | kfree(txq->txb); | ||
279 | txq->txb = NULL; | ||
280 | } | ||
281 | |||
282 | return -ENOMEM; | ||
283 | } | ||
284 | |||
285 | /** | ||
286 | * iwl4965_tx_queue_init - Allocate and initialize one tx/cmd queue | ||
287 | */ | ||
288 | int iwl4965_tx_queue_init(struct iwl_priv *priv, | ||
289 | struct iwl4965_tx_queue *txq, int slots_num, u32 txq_id) | ||
290 | { | ||
291 | struct pci_dev *dev = priv->pci_dev; | ||
292 | int len; | ||
293 | int rc = 0; | ||
294 | |||
295 | /* | ||
296 | * Alloc buffer array for commands (Tx or other types of commands). | ||
297 | * For the command queue (#4), allocate command space + one big | ||
298 | * command for scan, since scan command is very huge; the system will | ||
299 | * not have two scans at the same time, so only one is needed. | ||
300 | * For normal Tx queues (all other queues), no super-size command | ||
301 | * space is needed. | ||
302 | */ | ||
303 | len = sizeof(struct iwl_cmd) * slots_num; | ||
304 | if (txq_id == IWL_CMD_QUEUE_NUM) | ||
305 | len += IWL_MAX_SCAN_SIZE; | ||
306 | txq->cmd = pci_alloc_consistent(dev, len, &txq->dma_addr_cmd); | ||
307 | if (!txq->cmd) | ||
308 | return -ENOMEM; | ||
309 | |||
310 | /* Alloc driver data array and TFD circular buffer */ | ||
311 | rc = iwl4965_tx_queue_alloc(priv, txq, txq_id); | ||
312 | if (rc) { | ||
313 | pci_free_consistent(dev, len, txq->cmd, txq->dma_addr_cmd); | ||
314 | |||
315 | return -ENOMEM; | ||
316 | } | ||
317 | txq->need_update = 0; | ||
318 | |||
319 | /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise | ||
320 | * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */ | ||
321 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); | ||
322 | |||
323 | /* Initialize queue's high/low-water marks, and head/tail indexes */ | ||
324 | iwl4965_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); | ||
325 | |||
326 | /* Tell device where to find queue */ | ||
327 | iwl4965_hw_tx_queue_init(priv, txq); | ||
328 | |||
329 | return 0; | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * iwl4965_tx_queue_free - Deallocate DMA queue. | ||
334 | * @txq: Transmit queue to deallocate. | ||
335 | * | ||
336 | * Empty queue by removing and destroying all BD's. | ||
337 | * Free all buffers. | ||
338 | * 0-fill, but do not free "txq" descriptor structure. | ||
339 | */ | ||
340 | void iwl4965_tx_queue_free(struct iwl_priv *priv, struct iwl4965_tx_queue *txq) | ||
341 | { | ||
342 | struct iwl4965_queue *q = &txq->q; | ||
343 | struct pci_dev *dev = priv->pci_dev; | ||
344 | int len; | ||
345 | |||
346 | if (q->n_bd == 0) | ||
347 | return; | ||
348 | |||
349 | /* first, empty all BD's */ | ||
350 | for (; q->write_ptr != q->read_ptr; | ||
351 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) | ||
352 | iwl4965_hw_txq_free_tfd(priv, txq); | ||
353 | |||
354 | len = sizeof(struct iwl_cmd) * q->n_window; | ||
355 | if (q->id == IWL_CMD_QUEUE_NUM) | ||
356 | len += IWL_MAX_SCAN_SIZE; | ||
357 | |||
358 | /* De-alloc array of command/tx buffers */ | ||
359 | pci_free_consistent(dev, len, txq->cmd, txq->dma_addr_cmd); | ||
360 | |||
361 | /* De-alloc circular buffer of TFDs */ | ||
362 | if (txq->q.n_bd) | ||
363 | pci_free_consistent(dev, sizeof(struct iwl4965_tfd_frame) * | ||
364 | txq->q.n_bd, txq->bd, txq->q.dma_addr); | ||
365 | |||
366 | /* De-alloc array of per-TFD driver data */ | ||
367 | if (txq->txb) { | ||
368 | kfree(txq->txb); | ||
369 | txq->txb = NULL; | ||
370 | } | ||
371 | |||
372 | /* 0-fill queue descriptor structure */ | ||
373 | memset(txq, 0, sizeof(*txq)); | ||
374 | } | ||
375 | |||
376 | const u8 iwl4965_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | 210 | const u8 iwl4965_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
377 | 211 | ||
378 | /*************** STATION TABLE MANAGEMENT **** | 212 | /*************** STATION TABLE MANAGEMENT **** |
@@ -433,7 +267,7 @@ u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr, | |||
433 | { | 267 | { |
434 | int i; | 268 | int i; |
435 | int index = IWL_INVALID_STATION; | 269 | int index = IWL_INVALID_STATION; |
436 | struct iwl4965_station_entry *station; | 270 | struct iwl_station_entry *station; |
437 | unsigned long flags_spin; | 271 | unsigned long flags_spin; |
438 | DECLARE_MAC_BUF(mac); | 272 | DECLARE_MAC_BUF(mac); |
439 | 273 | ||
@@ -476,7 +310,7 @@ u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr, | |||
476 | priv->num_stations++; | 310 | priv->num_stations++; |
477 | 311 | ||
478 | /* Set up the REPLY_ADD_STA command to send to device */ | 312 | /* Set up the REPLY_ADD_STA command to send to device */ |
479 | memset(&station->sta, 0, sizeof(struct iwl4965_addsta_cmd)); | 313 | memset(&station->sta, 0, sizeof(struct iwl_addsta_cmd)); |
480 | memcpy(station->sta.sta.addr, addr, ETH_ALEN); | 314 | memcpy(station->sta.sta.addr, addr, ETH_ALEN); |
481 | station->sta.mode = 0; | 315 | station->sta.mode = 0; |
482 | station->sta.sta.sta_id = index; | 316 | station->sta.sta.sta_id = index; |
@@ -493,7 +327,7 @@ u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr, | |||
493 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | 327 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); |
494 | 328 | ||
495 | /* Add station to device's station table */ | 329 | /* Add station to device's station table */ |
496 | iwl4965_send_add_station(priv, &station->sta, flags); | 330 | iwl_send_add_sta(priv, &station->sta, flags); |
497 | return index; | 331 | return index; |
498 | 332 | ||
499 | } | 333 | } |
@@ -513,9 +347,9 @@ u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr, | |||
513 | */ | 347 | */ |
514 | int iwl4965_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) | 348 | int iwl4965_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) |
515 | { | 349 | { |
516 | struct iwl4965_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; | 350 | struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; |
517 | struct iwl4965_queue *q = &txq->q; | 351 | struct iwl4965_queue *q = &txq->q; |
518 | struct iwl4965_tfd_frame *tfd; | 352 | struct iwl_tfd_frame *tfd; |
519 | u32 *control_flags; | 353 | u32 *control_flags; |
520 | struct iwl_cmd *out_cmd; | 354 | struct iwl_cmd *out_cmd; |
521 | u32 idx; | 355 | u32 idx; |
@@ -902,8 +736,8 @@ static int iwl4965_send_bt_config(struct iwl_priv *priv) | |||
902 | 736 | ||
903 | static int iwl4965_send_scan_abort(struct iwl_priv *priv) | 737 | static int iwl4965_send_scan_abort(struct iwl_priv *priv) |
904 | { | 738 | { |
905 | int rc = 0; | 739 | int ret = 0; |
906 | struct iwl4965_rx_packet *res; | 740 | struct iwl_rx_packet *res; |
907 | struct iwl_host_cmd cmd = { | 741 | struct iwl_host_cmd cmd = { |
908 | .id = REPLY_SCAN_ABORT_CMD, | 742 | .id = REPLY_SCAN_ABORT_CMD, |
909 | .meta.flags = CMD_WANT_SKB, | 743 | .meta.flags = CMD_WANT_SKB, |
@@ -917,13 +751,13 @@ static int iwl4965_send_scan_abort(struct iwl_priv *priv) | |||
917 | return 0; | 751 | return 0; |
918 | } | 752 | } |
919 | 753 | ||
920 | rc = iwl_send_cmd_sync(priv, &cmd); | 754 | ret = iwl_send_cmd_sync(priv, &cmd); |
921 | if (rc) { | 755 | if (ret) { |
922 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); | 756 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); |
923 | return rc; | 757 | return ret; |
924 | } | 758 | } |
925 | 759 | ||
926 | res = (struct iwl4965_rx_packet *)cmd.meta.u.skb->data; | 760 | res = (struct iwl_rx_packet *)cmd.meta.u.skb->data; |
927 | if (res->u.status != CAN_ABORT_STATUS) { | 761 | if (res->u.status != CAN_ABORT_STATUS) { |
928 | /* The scan abort will return 1 for success or | 762 | /* The scan abort will return 1 for success or |
929 | * 2 for "failure". A failure condition can be | 763 | * 2 for "failure". A failure condition can be |
@@ -938,7 +772,7 @@ static int iwl4965_send_scan_abort(struct iwl_priv *priv) | |||
938 | 772 | ||
939 | dev_kfree_skb_any(cmd.meta.u.skb); | 773 | dev_kfree_skb_any(cmd.meta.u.skb); |
940 | 774 | ||
941 | return rc; | 775 | return ret; |
942 | } | 776 | } |
943 | 777 | ||
944 | /* | 778 | /* |
@@ -963,51 +797,6 @@ static int iwl4965_send_card_state(struct iwl_priv *priv, u32 flags, u8 meta_fla | |||
963 | return iwl_send_cmd(priv, &cmd); | 797 | return iwl_send_cmd(priv, &cmd); |
964 | } | 798 | } |
965 | 799 | ||
966 | int iwl4965_send_add_station(struct iwl_priv *priv, | ||
967 | struct iwl4965_addsta_cmd *sta, u8 flags) | ||
968 | { | ||
969 | struct iwl4965_rx_packet *res = NULL; | ||
970 | int rc = 0; | ||
971 | struct iwl_host_cmd cmd = { | ||
972 | .id = REPLY_ADD_STA, | ||
973 | .len = sizeof(struct iwl4965_addsta_cmd), | ||
974 | .meta.flags = flags, | ||
975 | .data = sta, | ||
976 | }; | ||
977 | |||
978 | if (!(flags & CMD_ASYNC)) | ||
979 | cmd.meta.flags |= CMD_WANT_SKB; | ||
980 | |||
981 | rc = iwl_send_cmd(priv, &cmd); | ||
982 | |||
983 | if (rc || (flags & CMD_ASYNC)) | ||
984 | return rc; | ||
985 | |||
986 | res = (struct iwl4965_rx_packet *)cmd.meta.u.skb->data; | ||
987 | if (res->hdr.flags & IWL_CMD_FAILED_MSK) { | ||
988 | IWL_ERROR("Bad return from REPLY_ADD_STA (0x%08X)\n", | ||
989 | res->hdr.flags); | ||
990 | rc = -EIO; | ||
991 | } | ||
992 | |||
993 | if (rc == 0) { | ||
994 | switch (res->u.add_sta.status) { | ||
995 | case ADD_STA_SUCCESS_MSK: | ||
996 | IWL_DEBUG_INFO("REPLY_ADD_STA PASSED\n"); | ||
997 | break; | ||
998 | default: | ||
999 | rc = -EIO; | ||
1000 | IWL_WARNING("REPLY_ADD_STA failed\n"); | ||
1001 | break; | ||
1002 | } | ||
1003 | } | ||
1004 | |||
1005 | priv->alloc_rxb_skb--; | ||
1006 | dev_kfree_skb_any(cmd.meta.u.skb); | ||
1007 | |||
1008 | return rc; | ||
1009 | } | ||
1010 | |||
1011 | static void iwl4965_clear_free_frames(struct iwl_priv *priv) | 800 | static void iwl4965_clear_free_frames(struct iwl_priv *priv) |
1012 | { | 801 | { |
1013 | struct list_head *element; | 802 | struct list_head *element; |
@@ -1783,7 +1572,7 @@ static void iwl4965_build_tx_cmd_hwcrypto(struct iwl_priv *priv, | |||
1783 | struct sk_buff *skb_frag, | 1572 | struct sk_buff *skb_frag, |
1784 | int sta_id) | 1573 | int sta_id) |
1785 | { | 1574 | { |
1786 | struct iwl4965_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; | 1575 | struct iwl_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; |
1787 | struct iwl_wep_key *wepkey; | 1576 | struct iwl_wep_key *wepkey; |
1788 | int keyidx = 0; | 1577 | int keyidx = 0; |
1789 | 1578 | ||
@@ -1959,7 +1748,7 @@ static int iwl4965_get_sta_id(struct iwl_priv *priv, | |||
1959 | IWL_DEBUG_DROP("Station %s not in station map. " | 1748 | IWL_DEBUG_DROP("Station %s not in station map. " |
1960 | "Defaulting to broadcast...\n", | 1749 | "Defaulting to broadcast...\n", |
1961 | print_mac(mac, hdr->addr1)); | 1750 | print_mac(mac, hdr->addr1)); |
1962 | iwl_print_hex_dump(IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); | 1751 | iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); |
1963 | return priv->hw_params.bcast_sta_id; | 1752 | return priv->hw_params.bcast_sta_id; |
1964 | 1753 | ||
1965 | default: | 1754 | default: |
@@ -1975,10 +1764,10 @@ static int iwl4965_tx_skb(struct iwl_priv *priv, | |||
1975 | struct sk_buff *skb, struct ieee80211_tx_control *ctl) | 1764 | struct sk_buff *skb, struct ieee80211_tx_control *ctl) |
1976 | { | 1765 | { |
1977 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 1766 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
1978 | struct iwl4965_tfd_frame *tfd; | 1767 | struct iwl_tfd_frame *tfd; |
1979 | u32 *control_flags; | 1768 | u32 *control_flags; |
1980 | int txq_id = ctl->queue; | 1769 | int txq_id = ctl->queue; |
1981 | struct iwl4965_tx_queue *txq = NULL; | 1770 | struct iwl_tx_queue *txq = NULL; |
1982 | struct iwl4965_queue *q = NULL; | 1771 | struct iwl4965_queue *q = NULL; |
1983 | dma_addr_t phys_addr; | 1772 | dma_addr_t phys_addr; |
1984 | dma_addr_t txcmd_phys; | 1773 | dma_addr_t txcmd_phys; |
@@ -2175,10 +1964,10 @@ static int iwl4965_tx_skb(struct iwl_priv *priv, | |||
2175 | txq->need_update = 0; | 1964 | txq->need_update = 0; |
2176 | } | 1965 | } |
2177 | 1966 | ||
2178 | iwl_print_hex_dump(IWL_DL_TX, out_cmd->cmd.payload, | 1967 | iwl_print_hex_dump(priv, IWL_DL_TX, out_cmd->cmd.payload, |
2179 | sizeof(out_cmd->cmd.tx)); | 1968 | sizeof(out_cmd->cmd.tx)); |
2180 | 1969 | ||
2181 | iwl_print_hex_dump(IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr, | 1970 | iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr, |
2182 | ieee80211_get_hdrlen(fc)); | 1971 | ieee80211_get_hdrlen(fc)); |
2183 | 1972 | ||
2184 | /* Set up entry for this TFD in Tx byte-count array */ | 1973 | /* Set up entry for this TFD in Tx byte-count array */ |
@@ -2441,7 +2230,7 @@ static int iwl4965_get_measurement(struct iwl_priv *priv, | |||
2441 | u8 type) | 2230 | u8 type) |
2442 | { | 2231 | { |
2443 | struct iwl4965_spectrum_cmd spectrum; | 2232 | struct iwl4965_spectrum_cmd spectrum; |
2444 | struct iwl4965_rx_packet *res; | 2233 | struct iwl_rx_packet *res; |
2445 | struct iwl_host_cmd cmd = { | 2234 | struct iwl_host_cmd cmd = { |
2446 | .id = REPLY_SPECTRUM_MEASUREMENT_CMD, | 2235 | .id = REPLY_SPECTRUM_MEASUREMENT_CMD, |
2447 | .data = (void *)&spectrum, | 2236 | .data = (void *)&spectrum, |
@@ -2486,7 +2275,7 @@ static int iwl4965_get_measurement(struct iwl_priv *priv, | |||
2486 | if (rc) | 2275 | if (rc) |
2487 | return rc; | 2276 | return rc; |
2488 | 2277 | ||
2489 | res = (struct iwl4965_rx_packet *)cmd.meta.u.skb->data; | 2278 | res = (struct iwl_rx_packet *)cmd.meta.u.skb->data; |
2490 | if (res->hdr.flags & IWL_CMD_FAILED_MSK) { | 2279 | if (res->hdr.flags & IWL_CMD_FAILED_MSK) { |
2491 | IWL_ERROR("Bad return from REPLY_RX_ON_ASSOC command\n"); | 2280 | IWL_ERROR("Bad return from REPLY_RX_ON_ASSOC command\n"); |
2492 | rc = -EIO; | 2281 | rc = -EIO; |
@@ -2542,7 +2331,7 @@ static void iwl4965_txstatus_to_ieee(struct iwl_priv *priv, | |||
2542 | */ | 2331 | */ |
2543 | int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | 2332 | int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) |
2544 | { | 2333 | { |
2545 | struct iwl4965_tx_queue *txq = &priv->txq[txq_id]; | 2334 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; |
2546 | struct iwl4965_queue *q = &txq->q; | 2335 | struct iwl4965_queue *q = &txq->q; |
2547 | int nfreed = 0; | 2336 | int nfreed = 0; |
2548 | 2337 | ||
@@ -2559,7 +2348,7 @@ int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | |||
2559 | if (txq_id != IWL_CMD_QUEUE_NUM) { | 2348 | if (txq_id != IWL_CMD_QUEUE_NUM) { |
2560 | iwl4965_txstatus_to_ieee(priv, | 2349 | iwl4965_txstatus_to_ieee(priv, |
2561 | &(txq->txb[txq->q.read_ptr])); | 2350 | &(txq->txb[txq->q.read_ptr])); |
2562 | iwl4965_hw_txq_free_tfd(priv, txq); | 2351 | iwl_hw_txq_free_tfd(priv, txq); |
2563 | } else if (nfreed > 1) { | 2352 | } else if (nfreed > 1) { |
2564 | IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index, | 2353 | IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index, |
2565 | q->write_ptr, q->read_ptr); | 2354 | q->write_ptr, q->read_ptr); |
@@ -2568,12 +2357,6 @@ int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | |||
2568 | nfreed++; | 2357 | nfreed++; |
2569 | } | 2358 | } |
2570 | 2359 | ||
2571 | /* if (iwl4965_queue_space(q) > q->low_mark && (txq_id >= 0) && | ||
2572 | (txq_id != IWL_CMD_QUEUE_NUM) && | ||
2573 | priv->mac80211_registered) | ||
2574 | ieee80211_wake_queue(priv->hw, txq_id); */ | ||
2575 | |||
2576 | |||
2577 | return nfreed; | 2360 | return nfreed; |
2578 | } | 2361 | } |
2579 | 2362 | ||
@@ -2623,7 +2406,7 @@ static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp) | |||
2623 | * iwl4965_tx_status_reply_tx - Handle Tx rspnse for frames in aggregation queue | 2406 | * iwl4965_tx_status_reply_tx - Handle Tx rspnse for frames in aggregation queue |
2624 | */ | 2407 | */ |
2625 | static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, | 2408 | static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, |
2626 | struct iwl4965_ht_agg *agg, | 2409 | struct iwl_ht_agg *agg, |
2627 | struct iwl4965_tx_resp_agg *tx_resp, | 2410 | struct iwl4965_tx_resp_agg *tx_resp, |
2628 | u16 start_idx) | 2411 | u16 start_idx) |
2629 | { | 2412 | { |
@@ -2742,13 +2525,13 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, | |||
2742 | * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response | 2525 | * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response |
2743 | */ | 2526 | */ |
2744 | static void iwl4965_rx_reply_tx(struct iwl_priv *priv, | 2527 | static void iwl4965_rx_reply_tx(struct iwl_priv *priv, |
2745 | struct iwl4965_rx_mem_buffer *rxb) | 2528 | struct iwl_rx_mem_buffer *rxb) |
2746 | { | 2529 | { |
2747 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2530 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2748 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | 2531 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); |
2749 | int txq_id = SEQ_TO_QUEUE(sequence); | 2532 | int txq_id = SEQ_TO_QUEUE(sequence); |
2750 | int index = SEQ_TO_INDEX(sequence); | 2533 | int index = SEQ_TO_INDEX(sequence); |
2751 | struct iwl4965_tx_queue *txq = &priv->txq[txq_id]; | 2534 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; |
2752 | struct ieee80211_tx_status *tx_status; | 2535 | struct ieee80211_tx_status *tx_status; |
2753 | struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; | 2536 | struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; |
2754 | u32 status = le32_to_cpu(tx_resp->status); | 2537 | u32 status = le32_to_cpu(tx_resp->status); |
@@ -2781,7 +2564,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv, | |||
2781 | 2564 | ||
2782 | if (txq->sched_retry) { | 2565 | if (txq->sched_retry) { |
2783 | const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp); | 2566 | const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp); |
2784 | struct iwl4965_ht_agg *agg = NULL; | 2567 | struct iwl_ht_agg *agg = NULL; |
2785 | 2568 | ||
2786 | if (!qc) | 2569 | if (!qc) |
2787 | return; | 2570 | return; |
@@ -2797,7 +2580,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv, | |||
2797 | } | 2580 | } |
2798 | 2581 | ||
2799 | if (txq->q.read_ptr != (scd_ssn & 0xff)) { | 2582 | if (txq->q.read_ptr != (scd_ssn & 0xff)) { |
2800 | int freed; | 2583 | int freed, ampdu_q; |
2801 | index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); | 2584 | index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); |
2802 | IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " | 2585 | IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " |
2803 | "%d index %d\n", scd_ssn , index); | 2586 | "%d index %d\n", scd_ssn , index); |
@@ -2806,9 +2589,15 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv, | |||
2806 | 2589 | ||
2807 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && | 2590 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && |
2808 | txq_id >= 0 && priv->mac80211_registered && | 2591 | txq_id >= 0 && priv->mac80211_registered && |
2809 | agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) | 2592 | agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) { |
2810 | ieee80211_wake_queue(priv->hw, txq_id); | 2593 | /* calculate mac80211 ampdu sw queue to wake */ |
2811 | 2594 | ampdu_q = txq_id - IWL_BACK_QUEUE_FIRST_ID + | |
2595 | priv->hw->queues; | ||
2596 | if (agg->state == IWL_AGG_OFF) | ||
2597 | ieee80211_wake_queue(priv->hw, txq_id); | ||
2598 | else | ||
2599 | ieee80211_wake_queue(priv->hw, ampdu_q); | ||
2600 | } | ||
2812 | iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id); | 2601 | iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id); |
2813 | } | 2602 | } |
2814 | } else { | 2603 | } else { |
@@ -2827,20 +2616,17 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv, | |||
2827 | tx_resp->failure_frame); | 2616 | tx_resp->failure_frame); |
2828 | 2617 | ||
2829 | IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); | 2618 | IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); |
2619 | #ifdef CONFIG_IWL4965_HT | ||
2830 | if (index != -1) { | 2620 | if (index != -1) { |
2831 | int freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); | 2621 | int freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); |
2832 | #ifdef CONFIG_IWL4965_HT | ||
2833 | if (tid != MAX_TID_COUNT) | 2622 | if (tid != MAX_TID_COUNT) |
2834 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; | 2623 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; |
2835 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && | 2624 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && |
2836 | (txq_id >= 0) && | 2625 | (txq_id >= 0) && priv->mac80211_registered) |
2837 | priv->mac80211_registered) | ||
2838 | ieee80211_wake_queue(priv->hw, txq_id); | 2626 | ieee80211_wake_queue(priv->hw, txq_id); |
2839 | if (tid != MAX_TID_COUNT) | 2627 | if (tid != MAX_TID_COUNT) |
2840 | iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id); | 2628 | iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id); |
2841 | #endif | ||
2842 | } | 2629 | } |
2843 | #ifdef CONFIG_IWL4965_HT | ||
2844 | } | 2630 | } |
2845 | #endif /* CONFIG_IWL4965_HT */ | 2631 | #endif /* CONFIG_IWL4965_HT */ |
2846 | 2632 | ||
@@ -2850,9 +2636,9 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv, | |||
2850 | 2636 | ||
2851 | 2637 | ||
2852 | static void iwl4965_rx_reply_alive(struct iwl_priv *priv, | 2638 | static void iwl4965_rx_reply_alive(struct iwl_priv *priv, |
2853 | struct iwl4965_rx_mem_buffer *rxb) | 2639 | struct iwl_rx_mem_buffer *rxb) |
2854 | { | 2640 | { |
2855 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2641 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2856 | struct iwl4965_alive_resp *palive; | 2642 | struct iwl4965_alive_resp *palive; |
2857 | struct delayed_work *pwork; | 2643 | struct delayed_work *pwork; |
2858 | 2644 | ||
@@ -2886,18 +2672,18 @@ static void iwl4965_rx_reply_alive(struct iwl_priv *priv, | |||
2886 | } | 2672 | } |
2887 | 2673 | ||
2888 | static void iwl4965_rx_reply_add_sta(struct iwl_priv *priv, | 2674 | static void iwl4965_rx_reply_add_sta(struct iwl_priv *priv, |
2889 | struct iwl4965_rx_mem_buffer *rxb) | 2675 | struct iwl_rx_mem_buffer *rxb) |
2890 | { | 2676 | { |
2891 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2677 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2892 | 2678 | ||
2893 | IWL_DEBUG_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); | 2679 | IWL_DEBUG_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); |
2894 | return; | 2680 | return; |
2895 | } | 2681 | } |
2896 | 2682 | ||
2897 | static void iwl4965_rx_reply_error(struct iwl_priv *priv, | 2683 | static void iwl4965_rx_reply_error(struct iwl_priv *priv, |
2898 | struct iwl4965_rx_mem_buffer *rxb) | 2684 | struct iwl_rx_mem_buffer *rxb) |
2899 | { | 2685 | { |
2900 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2686 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2901 | 2687 | ||
2902 | IWL_ERROR("Error Reply type 0x%08X cmd %s (0x%02X) " | 2688 | IWL_ERROR("Error Reply type 0x%08X cmd %s (0x%02X) " |
2903 | "seq 0x%04X ser 0x%08X\n", | 2689 | "seq 0x%04X ser 0x%08X\n", |
@@ -2910,9 +2696,9 @@ static void iwl4965_rx_reply_error(struct iwl_priv *priv, | |||
2910 | 2696 | ||
2911 | #define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x | 2697 | #define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x |
2912 | 2698 | ||
2913 | static void iwl4965_rx_csa(struct iwl_priv *priv, struct iwl4965_rx_mem_buffer *rxb) | 2699 | static void iwl4965_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) |
2914 | { | 2700 | { |
2915 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2701 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2916 | struct iwl4965_rxon_cmd *rxon = (void *)&priv->active_rxon; | 2702 | struct iwl4965_rxon_cmd *rxon = (void *)&priv->active_rxon; |
2917 | struct iwl4965_csa_notification *csa = &(pkt->u.csa_notif); | 2703 | struct iwl4965_csa_notification *csa = &(pkt->u.csa_notif); |
2918 | IWL_DEBUG_11H("CSA notif: channel %d, status %d\n", | 2704 | IWL_DEBUG_11H("CSA notif: channel %d, status %d\n", |
@@ -2922,15 +2708,15 @@ static void iwl4965_rx_csa(struct iwl_priv *priv, struct iwl4965_rx_mem_buffer * | |||
2922 | } | 2708 | } |
2923 | 2709 | ||
2924 | static void iwl4965_rx_spectrum_measure_notif(struct iwl_priv *priv, | 2710 | static void iwl4965_rx_spectrum_measure_notif(struct iwl_priv *priv, |
2925 | struct iwl4965_rx_mem_buffer *rxb) | 2711 | struct iwl_rx_mem_buffer *rxb) |
2926 | { | 2712 | { |
2927 | #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT | 2713 | #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT |
2928 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2714 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2929 | struct iwl4965_spectrum_notification *report = &(pkt->u.spectrum_notif); | 2715 | struct iwl4965_spectrum_notification *report = &(pkt->u.spectrum_notif); |
2930 | 2716 | ||
2931 | if (!report->state) { | 2717 | if (!report->state) { |
2932 | IWL_DEBUG(IWL_DL_11H | IWL_DL_INFO, | 2718 | IWL_DEBUG(IWL_DL_11H, |
2933 | "Spectrum Measure Notification: Start\n"); | 2719 | "Spectrum Measure Notification: Start\n"); |
2934 | return; | 2720 | return; |
2935 | } | 2721 | } |
2936 | 2722 | ||
@@ -2940,10 +2726,10 @@ static void iwl4965_rx_spectrum_measure_notif(struct iwl_priv *priv, | |||
2940 | } | 2726 | } |
2941 | 2727 | ||
2942 | static void iwl4965_rx_pm_sleep_notif(struct iwl_priv *priv, | 2728 | static void iwl4965_rx_pm_sleep_notif(struct iwl_priv *priv, |
2943 | struct iwl4965_rx_mem_buffer *rxb) | 2729 | struct iwl_rx_mem_buffer *rxb) |
2944 | { | 2730 | { |
2945 | #ifdef CONFIG_IWLWIFI_DEBUG | 2731 | #ifdef CONFIG_IWLWIFI_DEBUG |
2946 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2732 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2947 | struct iwl4965_sleep_notification *sleep = &(pkt->u.sleep_notif); | 2733 | struct iwl4965_sleep_notification *sleep = &(pkt->u.sleep_notif); |
2948 | IWL_DEBUG_RX("sleep mode: %d, src: %d\n", | 2734 | IWL_DEBUG_RX("sleep mode: %d, src: %d\n", |
2949 | sleep->pm_sleep_mode, sleep->pm_wakeup_src); | 2735 | sleep->pm_sleep_mode, sleep->pm_wakeup_src); |
@@ -2951,13 +2737,13 @@ static void iwl4965_rx_pm_sleep_notif(struct iwl_priv *priv, | |||
2951 | } | 2737 | } |
2952 | 2738 | ||
2953 | static void iwl4965_rx_pm_debug_statistics_notif(struct iwl_priv *priv, | 2739 | static void iwl4965_rx_pm_debug_statistics_notif(struct iwl_priv *priv, |
2954 | struct iwl4965_rx_mem_buffer *rxb) | 2740 | struct iwl_rx_mem_buffer *rxb) |
2955 | { | 2741 | { |
2956 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2742 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2957 | IWL_DEBUG_RADIO("Dumping %d bytes of unhandled " | 2743 | IWL_DEBUG_RADIO("Dumping %d bytes of unhandled " |
2958 | "notification for %s:\n", | 2744 | "notification for %s:\n", |
2959 | le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd)); | 2745 | le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd)); |
2960 | iwl_print_hex_dump(IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len)); | 2746 | iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len)); |
2961 | } | 2747 | } |
2962 | 2748 | ||
2963 | static void iwl4965_bg_beacon_update(struct work_struct *work) | 2749 | static void iwl4965_bg_beacon_update(struct work_struct *work) |
@@ -2986,10 +2772,10 @@ static void iwl4965_bg_beacon_update(struct work_struct *work) | |||
2986 | } | 2772 | } |
2987 | 2773 | ||
2988 | static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, | 2774 | static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, |
2989 | struct iwl4965_rx_mem_buffer *rxb) | 2775 | struct iwl_rx_mem_buffer *rxb) |
2990 | { | 2776 | { |
2991 | #ifdef CONFIG_IWLWIFI_DEBUG | 2777 | #ifdef CONFIG_IWLWIFI_DEBUG |
2992 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2778 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2993 | struct iwl4965_beacon_notif *beacon = &(pkt->u.beacon_status); | 2779 | struct iwl4965_beacon_notif *beacon = &(pkt->u.beacon_status); |
2994 | u8 rate = iwl4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); | 2780 | u8 rate = iwl4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); |
2995 | 2781 | ||
@@ -3009,10 +2795,10 @@ static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, | |||
3009 | 2795 | ||
3010 | /* Service response to REPLY_SCAN_CMD (0x80) */ | 2796 | /* Service response to REPLY_SCAN_CMD (0x80) */ |
3011 | static void iwl4965_rx_reply_scan(struct iwl_priv *priv, | 2797 | static void iwl4965_rx_reply_scan(struct iwl_priv *priv, |
3012 | struct iwl4965_rx_mem_buffer *rxb) | 2798 | struct iwl_rx_mem_buffer *rxb) |
3013 | { | 2799 | { |
3014 | #ifdef CONFIG_IWLWIFI_DEBUG | 2800 | #ifdef CONFIG_IWLWIFI_DEBUG |
3015 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2801 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
3016 | struct iwl4965_scanreq_notification *notif = | 2802 | struct iwl4965_scanreq_notification *notif = |
3017 | (struct iwl4965_scanreq_notification *)pkt->u.raw; | 2803 | (struct iwl4965_scanreq_notification *)pkt->u.raw; |
3018 | 2804 | ||
@@ -3022,9 +2808,9 @@ static void iwl4965_rx_reply_scan(struct iwl_priv *priv, | |||
3022 | 2808 | ||
3023 | /* Service SCAN_START_NOTIFICATION (0x82) */ | 2809 | /* Service SCAN_START_NOTIFICATION (0x82) */ |
3024 | static void iwl4965_rx_scan_start_notif(struct iwl_priv *priv, | 2810 | static void iwl4965_rx_scan_start_notif(struct iwl_priv *priv, |
3025 | struct iwl4965_rx_mem_buffer *rxb) | 2811 | struct iwl_rx_mem_buffer *rxb) |
3026 | { | 2812 | { |
3027 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2813 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
3028 | struct iwl4965_scanstart_notification *notif = | 2814 | struct iwl4965_scanstart_notification *notif = |
3029 | (struct iwl4965_scanstart_notification *)pkt->u.raw; | 2815 | (struct iwl4965_scanstart_notification *)pkt->u.raw; |
3030 | priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); | 2816 | priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); |
@@ -3039,9 +2825,9 @@ static void iwl4965_rx_scan_start_notif(struct iwl_priv *priv, | |||
3039 | 2825 | ||
3040 | /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ | 2826 | /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ |
3041 | static void iwl4965_rx_scan_results_notif(struct iwl_priv *priv, | 2827 | static void iwl4965_rx_scan_results_notif(struct iwl_priv *priv, |
3042 | struct iwl4965_rx_mem_buffer *rxb) | 2828 | struct iwl_rx_mem_buffer *rxb) |
3043 | { | 2829 | { |
3044 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2830 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
3045 | struct iwl4965_scanresults_notification *notif = | 2831 | struct iwl4965_scanresults_notification *notif = |
3046 | (struct iwl4965_scanresults_notification *)pkt->u.raw; | 2832 | (struct iwl4965_scanresults_notification *)pkt->u.raw; |
3047 | 2833 | ||
@@ -3064,9 +2850,9 @@ static void iwl4965_rx_scan_results_notif(struct iwl_priv *priv, | |||
3064 | 2850 | ||
3065 | /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ | 2851 | /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ |
3066 | static void iwl4965_rx_scan_complete_notif(struct iwl_priv *priv, | 2852 | static void iwl4965_rx_scan_complete_notif(struct iwl_priv *priv, |
3067 | struct iwl4965_rx_mem_buffer *rxb) | 2853 | struct iwl_rx_mem_buffer *rxb) |
3068 | { | 2854 | { |
3069 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2855 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
3070 | struct iwl4965_scancomplete_notification *scan_notif = (void *)pkt->u.raw; | 2856 | struct iwl4965_scancomplete_notification *scan_notif = (void *)pkt->u.raw; |
3071 | 2857 | ||
3072 | IWL_DEBUG_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", | 2858 | IWL_DEBUG_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", |
@@ -3122,9 +2908,9 @@ reschedule: | |||
3122 | /* Handle notification from uCode that card's power state is changing | 2908 | /* Handle notification from uCode that card's power state is changing |
3123 | * due to software, hardware, or critical temperature RFKILL */ | 2909 | * due to software, hardware, or critical temperature RFKILL */ |
3124 | static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, | 2910 | static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, |
3125 | struct iwl4965_rx_mem_buffer *rxb) | 2911 | struct iwl_rx_mem_buffer *rxb) |
3126 | { | 2912 | { |
3127 | struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; | 2913 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
3128 | u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); | 2914 | u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); |
3129 | unsigned long status = priv->status; | 2915 | unsigned long status = priv->status; |
3130 | 2916 | ||
@@ -3242,9 +3028,9 @@ static void iwl4965_setup_rx_handlers(struct iwl_priv *priv) | |||
3242 | * if the callback returns 1 | 3028 | * if the callback returns 1 |
3243 | */ | 3029 | */ |
3244 | static void iwl4965_tx_cmd_complete(struct iwl_priv *priv, | 3030 | static void iwl4965_tx_cmd_complete(struct iwl_priv *priv, |
3245 | struct iwl4965_rx_mem_buffer *rxb) | 3031 | struct iwl_rx_mem_buffer *rxb) |
3246 | { | 3032 | { |
3247 | struct iwl4965_rx_packet *pkt = (struct iwl4965_rx_packet *)rxb->skb->data; | 3033 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
3248 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | 3034 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); |
3249 | int txq_id = SEQ_TO_QUEUE(sequence); | 3035 | int txq_id = SEQ_TO_QUEUE(sequence); |
3250 | int index = SEQ_TO_INDEX(sequence); | 3036 | int index = SEQ_TO_INDEX(sequence); |
@@ -3279,438 +3065,28 @@ static void iwl4965_tx_cmd_complete(struct iwl_priv *priv, | |||
3279 | } | 3065 | } |
3280 | } | 3066 | } |
3281 | 3067 | ||
3282 | /************************** RX-FUNCTIONS ****************************/ | ||
3283 | /* | ||
3284 | * Rx theory of operation | ||
3285 | * | ||
3286 | * Driver allocates a circular buffer of Receive Buffer Descriptors (RBDs), | ||
3287 | * each of which point to Receive Buffers to be filled by 4965. These get | ||
3288 | * used not only for Rx frames, but for any command response or notification | ||
3289 | * from the 4965. The driver and 4965 manage the Rx buffers by means | ||
3290 | * of indexes into the circular buffer. | ||
3291 | * | ||
3292 | * Rx Queue Indexes | ||
3293 | * The host/firmware share two index registers for managing the Rx buffers. | ||
3294 | * | ||
3295 | * The READ index maps to the first position that the firmware may be writing | ||
3296 | * to -- the driver can read up to (but not including) this position and get | ||
3297 | * good data. | ||
3298 | * The READ index is managed by the firmware once the card is enabled. | ||
3299 | * | ||
3300 | * The WRITE index maps to the last position the driver has read from -- the | ||
3301 | * position preceding WRITE is the last slot the firmware can place a packet. | ||
3302 | * | ||
3303 | * The queue is empty (no good data) if WRITE = READ - 1, and is full if | ||
3304 | * WRITE = READ. | ||
3305 | * | ||
3306 | * During initialization, the host sets up the READ queue position to the first | ||
3307 | * INDEX position, and WRITE to the last (READ - 1 wrapped) | ||
3308 | * | ||
3309 | * When the firmware places a packet in a buffer, it will advance the READ index | ||
3310 | * and fire the RX interrupt. The driver can then query the READ index and | ||
3311 | * process as many packets as possible, moving the WRITE index forward as it | ||
3312 | * resets the Rx queue buffers with new memory. | ||
3313 | * | ||
3314 | * The management in the driver is as follows: | ||
3315 | * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When | ||
3316 | * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled | ||
3317 | * to replenish the iwl->rxq->rx_free. | ||
3318 | * + In iwl4965_rx_replenish (scheduled) if 'processed' != 'read' then the | ||
3319 | * iwl->rxq is replenished and the READ INDEX is updated (updating the | ||
3320 | * 'processed' and 'read' driver indexes as well) | ||
3321 | * + A received packet is processed and handed to the kernel network stack, | ||
3322 | * detached from the iwl->rxq. The driver 'processed' index is updated. | ||
3323 | * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free | ||
3324 | * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ | ||
3325 | * INDEX is not incremented and iwl->status(RX_STALLED) is set. If there | ||
3326 | * were enough free buffers and RX_STALLED is set it is cleared. | ||
3327 | * | ||
3328 | * | ||
3329 | * Driver sequence: | ||
3330 | * | ||
3331 | * iwl4965_rx_queue_alloc() Allocates rx_free | ||
3332 | * iwl4965_rx_replenish() Replenishes rx_free list from rx_used, and calls | ||
3333 | * iwl4965_rx_queue_restock | ||
3334 | * iwl4965_rx_queue_restock() Moves available buffers from rx_free into Rx | ||
3335 | * queue, updates firmware pointers, and updates | ||
3336 | * the WRITE index. If insufficient rx_free buffers | ||
3337 | * are available, schedules iwl4965_rx_replenish | ||
3338 | * | ||
3339 | * -- enable interrupts -- | ||
3340 | * ISR - iwl4965_rx() Detach iwl4965_rx_mem_buffers from pool up to the | ||
3341 | * READ INDEX, detaching the SKB from the pool. | ||
3342 | * Moves the packet buffer from queue to rx_used. | ||
3343 | * Calls iwl4965_rx_queue_restock to refill any empty | ||
3344 | * slots. | ||
3345 | * ... | ||
3346 | * | ||
3347 | */ | ||
3348 | |||
3349 | /** | ||
3350 | * iwl4965_rx_queue_space - Return number of free slots available in queue. | ||
3351 | */ | ||
3352 | static int iwl4965_rx_queue_space(const struct iwl4965_rx_queue *q) | ||
3353 | { | ||
3354 | int s = q->read - q->write; | ||
3355 | if (s <= 0) | ||
3356 | s += RX_QUEUE_SIZE; | ||
3357 | /* keep some buffer to not confuse full and empty queue */ | ||
3358 | s -= 2; | ||
3359 | if (s < 0) | ||
3360 | s = 0; | ||
3361 | return s; | ||
3362 | } | ||
3363 | |||
3364 | /** | ||
3365 | * iwl4965_rx_queue_update_write_ptr - Update the write pointer for the RX queue | ||
3366 | */ | ||
3367 | int iwl4965_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl4965_rx_queue *q) | ||
3368 | { | ||
3369 | u32 reg = 0; | ||
3370 | int rc = 0; | ||
3371 | unsigned long flags; | ||
3372 | |||
3373 | spin_lock_irqsave(&q->lock, flags); | ||
3374 | |||
3375 | if (q->need_update == 0) | ||
3376 | goto exit_unlock; | ||
3377 | |||
3378 | /* If power-saving is in use, make sure device is awake */ | ||
3379 | if (test_bit(STATUS_POWER_PMI, &priv->status)) { | ||
3380 | reg = iwl_read32(priv, CSR_UCODE_DRV_GP1); | ||
3381 | |||
3382 | if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { | ||
3383 | iwl_set_bit(priv, CSR_GP_CNTRL, | ||
3384 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); | ||
3385 | goto exit_unlock; | ||
3386 | } | ||
3387 | |||
3388 | rc = iwl_grab_nic_access(priv); | ||
3389 | if (rc) | ||
3390 | goto exit_unlock; | ||
3391 | |||
3392 | /* Device expects a multiple of 8 */ | ||
3393 | iwl_write_direct32(priv, FH_RSCSR_CHNL0_WPTR, | ||
3394 | q->write & ~0x7); | ||
3395 | iwl_release_nic_access(priv); | ||
3396 | |||
3397 | /* Else device is assumed to be awake */ | ||
3398 | } else | ||
3399 | /* Device expects a multiple of 8 */ | ||
3400 | iwl_write32(priv, FH_RSCSR_CHNL0_WPTR, q->write & ~0x7); | ||
3401 | |||
3402 | |||
3403 | q->need_update = 0; | ||
3404 | |||
3405 | exit_unlock: | ||
3406 | spin_unlock_irqrestore(&q->lock, flags); | ||
3407 | return rc; | ||
3408 | } | ||
3409 | |||
3410 | /** | ||
3411 | * iwl4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr | ||
3412 | */ | ||
3413 | static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl_priv *priv, | ||
3414 | dma_addr_t dma_addr) | ||
3415 | { | ||
3416 | return cpu_to_le32((u32)(dma_addr >> 8)); | ||
3417 | } | ||
3418 | |||
3419 | |||
3420 | /** | ||
3421 | * iwl4965_rx_queue_restock - refill RX queue from pre-allocated pool | ||
3422 | * | ||
3423 | * If there are slots in the RX queue that need to be restocked, | ||
3424 | * and we have free pre-allocated buffers, fill the ranks as much | ||
3425 | * as we can, pulling from rx_free. | ||
3426 | * | ||
3427 | * This moves the 'write' index forward to catch up with 'processed', and | ||
3428 | * also updates the memory address in the firmware to reference the new | ||
3429 | * target buffer. | ||
3430 | */ | ||
3431 | static int iwl4965_rx_queue_restock(struct iwl_priv *priv) | ||
3432 | { | ||
3433 | struct iwl4965_rx_queue *rxq = &priv->rxq; | ||
3434 | struct list_head *element; | ||
3435 | struct iwl4965_rx_mem_buffer *rxb; | ||
3436 | unsigned long flags; | ||
3437 | int write, rc; | ||
3438 | |||
3439 | spin_lock_irqsave(&rxq->lock, flags); | ||
3440 | write = rxq->write & ~0x7; | ||
3441 | while ((iwl4965_rx_queue_space(rxq) > 0) && (rxq->free_count)) { | ||
3442 | /* Get next free Rx buffer, remove from free list */ | ||
3443 | element = rxq->rx_free.next; | ||
3444 | rxb = list_entry(element, struct iwl4965_rx_mem_buffer, list); | ||
3445 | list_del(element); | ||
3446 | |||
3447 | /* Point to Rx buffer via next RBD in circular buffer */ | ||
3448 | rxq->bd[rxq->write] = iwl4965_dma_addr2rbd_ptr(priv, rxb->dma_addr); | ||
3449 | rxq->queue[rxq->write] = rxb; | ||
3450 | rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; | ||
3451 | rxq->free_count--; | ||
3452 | } | ||
3453 | spin_unlock_irqrestore(&rxq->lock, flags); | ||
3454 | /* If the pre-allocated buffer pool is dropping low, schedule to | ||
3455 | * refill it */ | ||
3456 | if (rxq->free_count <= RX_LOW_WATERMARK) | ||
3457 | queue_work(priv->workqueue, &priv->rx_replenish); | ||
3458 | |||
3459 | |||
3460 | /* If we've added more space for the firmware to place data, tell it. | ||
3461 | * Increment device's write pointer in multiples of 8. */ | ||
3462 | if ((write != (rxq->write & ~0x7)) | ||
3463 | || (abs(rxq->write - rxq->read) > 7)) { | ||
3464 | spin_lock_irqsave(&rxq->lock, flags); | ||
3465 | rxq->need_update = 1; | ||
3466 | spin_unlock_irqrestore(&rxq->lock, flags); | ||
3467 | rc = iwl4965_rx_queue_update_write_ptr(priv, rxq); | ||
3468 | if (rc) | ||
3469 | return rc; | ||
3470 | } | ||
3471 | |||
3472 | return 0; | ||
3473 | } | ||
3474 | |||
3475 | /** | ||
3476 | * iwl4965_rx_replenish - Move all used packet from rx_used to rx_free | ||
3477 | * | ||
3478 | * When moving to rx_free an SKB is allocated for the slot. | ||
3479 | * | ||
3480 | * Also restock the Rx queue via iwl4965_rx_queue_restock. | ||
3481 | * This is called as a scheduled work item (except for during initialization) | ||
3482 | */ | ||
3483 | static void iwl4965_rx_allocate(struct iwl_priv *priv) | ||
3484 | { | ||
3485 | struct iwl4965_rx_queue *rxq = &priv->rxq; | ||
3486 | struct list_head *element; | ||
3487 | struct iwl4965_rx_mem_buffer *rxb; | ||
3488 | unsigned long flags; | ||
3489 | spin_lock_irqsave(&rxq->lock, flags); | ||
3490 | while (!list_empty(&rxq->rx_used)) { | ||
3491 | element = rxq->rx_used.next; | ||
3492 | rxb = list_entry(element, struct iwl4965_rx_mem_buffer, list); | ||
3493 | |||
3494 | /* Alloc a new receive buffer */ | ||
3495 | rxb->skb = | ||
3496 | alloc_skb(priv->hw_params.rx_buf_size, | ||
3497 | __GFP_NOWARN | GFP_ATOMIC); | ||
3498 | if (!rxb->skb) { | ||
3499 | if (net_ratelimit()) | ||
3500 | printk(KERN_CRIT DRV_NAME | ||
3501 | ": Can not allocate SKB buffers\n"); | ||
3502 | /* We don't reschedule replenish work here -- we will | ||
3503 | * call the restock method and if it still needs | ||
3504 | * more buffers it will schedule replenish */ | ||
3505 | break; | ||
3506 | } | ||
3507 | priv->alloc_rxb_skb++; | ||
3508 | list_del(element); | ||
3509 | |||
3510 | /* Get physical address of RB/SKB */ | ||
3511 | rxb->dma_addr = | ||
3512 | pci_map_single(priv->pci_dev, rxb->skb->data, | ||
3513 | priv->hw_params.rx_buf_size, PCI_DMA_FROMDEVICE); | ||
3514 | list_add_tail(&rxb->list, &rxq->rx_free); | ||
3515 | rxq->free_count++; | ||
3516 | } | ||
3517 | spin_unlock_irqrestore(&rxq->lock, flags); | ||
3518 | } | ||
3519 | |||
3520 | /* | 3068 | /* |
3521 | * this should be called while priv->lock is locked | 3069 | * this should be called while priv->lock is locked |
3522 | */ | 3070 | */ |
3523 | static void __iwl4965_rx_replenish(void *data) | 3071 | static void __iwl_rx_replenish(struct iwl_priv *priv) |
3524 | { | ||
3525 | struct iwl_priv *priv = data; | ||
3526 | |||
3527 | iwl4965_rx_allocate(priv); | ||
3528 | iwl4965_rx_queue_restock(priv); | ||
3529 | } | ||
3530 | |||
3531 | |||
3532 | void iwl4965_rx_replenish(void *data) | ||
3533 | { | ||
3534 | struct iwl_priv *priv = data; | ||
3535 | unsigned long flags; | ||
3536 | |||
3537 | iwl4965_rx_allocate(priv); | ||
3538 | |||
3539 | spin_lock_irqsave(&priv->lock, flags); | ||
3540 | iwl4965_rx_queue_restock(priv); | ||
3541 | spin_unlock_irqrestore(&priv->lock, flags); | ||
3542 | } | ||
3543 | |||
3544 | /* Assumes that the skb field of the buffers in 'pool' is kept accurate. | ||
3545 | * If an SKB has been detached, the POOL needs to have its SKB set to NULL | ||
3546 | * This free routine walks the list of POOL entries and if SKB is set to | ||
3547 | * non NULL it is unmapped and freed | ||
3548 | */ | ||
3549 | static void iwl4965_rx_queue_free(struct iwl_priv *priv, struct iwl4965_rx_queue *rxq) | ||
3550 | { | ||
3551 | int i; | ||
3552 | for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { | ||
3553 | if (rxq->pool[i].skb != NULL) { | ||
3554 | pci_unmap_single(priv->pci_dev, | ||
3555 | rxq->pool[i].dma_addr, | ||
3556 | priv->hw_params.rx_buf_size, | ||
3557 | PCI_DMA_FROMDEVICE); | ||
3558 | dev_kfree_skb(rxq->pool[i].skb); | ||
3559 | } | ||
3560 | } | ||
3561 | |||
3562 | pci_free_consistent(priv->pci_dev, 4 * RX_QUEUE_SIZE, rxq->bd, | ||
3563 | rxq->dma_addr); | ||
3564 | rxq->bd = NULL; | ||
3565 | } | ||
3566 | |||
3567 | int iwl4965_rx_queue_alloc(struct iwl_priv *priv) | ||
3568 | { | 3072 | { |
3569 | struct iwl4965_rx_queue *rxq = &priv->rxq; | 3073 | iwl_rx_allocate(priv); |
3570 | struct pci_dev *dev = priv->pci_dev; | 3074 | iwl_rx_queue_restock(priv); |
3571 | int i; | ||
3572 | |||
3573 | spin_lock_init(&rxq->lock); | ||
3574 | INIT_LIST_HEAD(&rxq->rx_free); | ||
3575 | INIT_LIST_HEAD(&rxq->rx_used); | ||
3576 | |||
3577 | /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */ | ||
3578 | rxq->bd = pci_alloc_consistent(dev, 4 * RX_QUEUE_SIZE, &rxq->dma_addr); | ||
3579 | if (!rxq->bd) | ||
3580 | return -ENOMEM; | ||
3581 | |||
3582 | /* Fill the rx_used queue with _all_ of the Rx buffers */ | ||
3583 | for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) | ||
3584 | list_add_tail(&rxq->pool[i].list, &rxq->rx_used); | ||
3585 | |||
3586 | /* Set us so that we have processed and used all buffers, but have | ||
3587 | * not restocked the Rx queue with fresh buffers */ | ||
3588 | rxq->read = rxq->write = 0; | ||
3589 | rxq->free_count = 0; | ||
3590 | rxq->need_update = 0; | ||
3591 | return 0; | ||
3592 | } | 3075 | } |
3593 | 3076 | ||
3594 | void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl4965_rx_queue *rxq) | ||
3595 | { | ||
3596 | unsigned long flags; | ||
3597 | int i; | ||
3598 | spin_lock_irqsave(&rxq->lock, flags); | ||
3599 | INIT_LIST_HEAD(&rxq->rx_free); | ||
3600 | INIT_LIST_HEAD(&rxq->rx_used); | ||
3601 | /* Fill the rx_used queue with _all_ of the Rx buffers */ | ||
3602 | for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { | ||
3603 | /* In the reset function, these buffers may have been allocated | ||
3604 | * to an SKB, so we need to unmap and free potential storage */ | ||
3605 | if (rxq->pool[i].skb != NULL) { | ||
3606 | pci_unmap_single(priv->pci_dev, | ||
3607 | rxq->pool[i].dma_addr, | ||
3608 | priv->hw_params.rx_buf_size, | ||
3609 | PCI_DMA_FROMDEVICE); | ||
3610 | priv->alloc_rxb_skb--; | ||
3611 | dev_kfree_skb(rxq->pool[i].skb); | ||
3612 | rxq->pool[i].skb = NULL; | ||
3613 | } | ||
3614 | list_add_tail(&rxq->pool[i].list, &rxq->rx_used); | ||
3615 | } | ||
3616 | |||
3617 | /* Set us so that we have processed and used all buffers, but have | ||
3618 | * not restocked the Rx queue with fresh buffers */ | ||
3619 | rxq->read = rxq->write = 0; | ||
3620 | rxq->free_count = 0; | ||
3621 | spin_unlock_irqrestore(&rxq->lock, flags); | ||
3622 | } | ||
3623 | |||
3624 | /* Convert linear signal-to-noise ratio into dB */ | ||
3625 | static u8 ratio2dB[100] = { | ||
3626 | /* 0 1 2 3 4 5 6 7 8 9 */ | ||
3627 | 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ | ||
3628 | 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ | ||
3629 | 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ | ||
3630 | 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ | ||
3631 | 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ | ||
3632 | 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ | ||
3633 | 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ | ||
3634 | 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ | ||
3635 | 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ | ||
3636 | 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ | ||
3637 | }; | ||
3638 | |||
3639 | /* Calculates a relative dB value from a ratio of linear | ||
3640 | * (i.e. not dB) signal levels. | ||
3641 | * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ | ||
3642 | int iwl4965_calc_db_from_ratio(int sig_ratio) | ||
3643 | { | ||
3644 | /* 1000:1 or higher just report as 60 dB */ | ||
3645 | if (sig_ratio >= 1000) | ||
3646 | return 60; | ||
3647 | |||
3648 | /* 100:1 or higher, divide by 10 and use table, | ||
3649 | * add 20 dB to make up for divide by 10 */ | ||
3650 | if (sig_ratio >= 100) | ||
3651 | return (20 + (int)ratio2dB[sig_ratio/10]); | ||
3652 | |||
3653 | /* We shouldn't see this */ | ||
3654 | if (sig_ratio < 1) | ||
3655 | return 0; | ||
3656 | |||
3657 | /* Use table for ratios 1:1 - 99:1 */ | ||
3658 | return (int)ratio2dB[sig_ratio]; | ||
3659 | } | ||
3660 | |||
3661 | #define PERFECT_RSSI (-20) /* dBm */ | ||
3662 | #define WORST_RSSI (-95) /* dBm */ | ||
3663 | #define RSSI_RANGE (PERFECT_RSSI - WORST_RSSI) | ||
3664 | |||
3665 | /* Calculate an indication of rx signal quality (a percentage, not dBm!). | ||
3666 | * See http://www.ces.clemson.edu/linux/signal_quality.shtml for info | ||
3667 | * about formulas used below. */ | ||
3668 | int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm) | ||
3669 | { | ||
3670 | int sig_qual; | ||
3671 | int degradation = PERFECT_RSSI - rssi_dbm; | ||
3672 | |||
3673 | /* If we get a noise measurement, use signal-to-noise ratio (SNR) | ||
3674 | * as indicator; formula is (signal dbm - noise dbm). | ||
3675 | * SNR at or above 40 is a great signal (100%). | ||
3676 | * Below that, scale to fit SNR of 0 - 40 dB within 0 - 100% indicator. | ||
3677 | * Weakest usable signal is usually 10 - 15 dB SNR. */ | ||
3678 | if (noise_dbm) { | ||
3679 | if (rssi_dbm - noise_dbm >= 40) | ||
3680 | return 100; | ||
3681 | else if (rssi_dbm < noise_dbm) | ||
3682 | return 0; | ||
3683 | sig_qual = ((rssi_dbm - noise_dbm) * 5) / 2; | ||
3684 | |||
3685 | /* Else use just the signal level. | ||
3686 | * This formula is a least squares fit of data points collected and | ||
3687 | * compared with a reference system that had a percentage (%) display | ||
3688 | * for signal quality. */ | ||
3689 | } else | ||
3690 | sig_qual = (100 * (RSSI_RANGE * RSSI_RANGE) - degradation * | ||
3691 | (15 * RSSI_RANGE + 62 * degradation)) / | ||
3692 | (RSSI_RANGE * RSSI_RANGE); | ||
3693 | |||
3694 | if (sig_qual > 100) | ||
3695 | sig_qual = 100; | ||
3696 | else if (sig_qual < 1) | ||
3697 | sig_qual = 0; | ||
3698 | |||
3699 | return sig_qual; | ||
3700 | } | ||
3701 | 3077 | ||
3702 | /** | 3078 | /** |
3703 | * iwl4965_rx_handle - Main entry function for receiving responses from uCode | 3079 | * iwl_rx_handle - Main entry function for receiving responses from uCode |
3704 | * | 3080 | * |
3705 | * Uses the priv->rx_handlers callback function array to invoke | 3081 | * Uses the priv->rx_handlers callback function array to invoke |
3706 | * the appropriate handlers, including command responses, | 3082 | * the appropriate handlers, including command responses, |
3707 | * frame-received notifications, and other notifications. | 3083 | * frame-received notifications, and other notifications. |
3708 | */ | 3084 | */ |
3709 | static void iwl4965_rx_handle(struct iwl_priv *priv) | 3085 | void iwl_rx_handle(struct iwl_priv *priv) |
3710 | { | 3086 | { |
3711 | struct iwl4965_rx_mem_buffer *rxb; | 3087 | struct iwl_rx_mem_buffer *rxb; |
3712 | struct iwl4965_rx_packet *pkt; | 3088 | struct iwl_rx_packet *pkt; |
3713 | struct iwl4965_rx_queue *rxq = &priv->rxq; | 3089 | struct iwl_rx_queue *rxq = &priv->rxq; |
3714 | u32 r, i; | 3090 | u32 r, i; |
3715 | int reclaim; | 3091 | int reclaim; |
3716 | unsigned long flags; | 3092 | unsigned long flags; |
@@ -3719,14 +3095,14 @@ static void iwl4965_rx_handle(struct iwl_priv *priv) | |||
3719 | 3095 | ||
3720 | /* uCode's read index (stored in shared DRAM) indicates the last Rx | 3096 | /* uCode's read index (stored in shared DRAM) indicates the last Rx |
3721 | * buffer that the driver may process (last buffer filled by ucode). */ | 3097 | * buffer that the driver may process (last buffer filled by ucode). */ |
3722 | r = iwl4965_hw_get_rx_read(priv); | 3098 | r = priv->cfg->ops->lib->shared_mem_rx_idx(priv); |
3723 | i = rxq->read; | 3099 | i = rxq->read; |
3724 | 3100 | ||
3725 | /* Rx interrupt, but nothing sent from uCode */ | 3101 | /* Rx interrupt, but nothing sent from uCode */ |
3726 | if (i == r) | 3102 | if (i == r) |
3727 | IWL_DEBUG(IWL_DL_RX | IWL_DL_ISR, "r = %d, i = %d\n", r, i); | 3103 | IWL_DEBUG(IWL_DL_RX, "r = %d, i = %d\n", r, i); |
3728 | 3104 | ||
3729 | if (iwl4965_rx_queue_space(rxq) > (RX_QUEUE_SIZE / 2)) | 3105 | if (iwl_rx_queue_space(rxq) > (RX_QUEUE_SIZE / 2)) |
3730 | fill_rx = 1; | 3106 | fill_rx = 1; |
3731 | 3107 | ||
3732 | while (i != r) { | 3108 | while (i != r) { |
@@ -3742,7 +3118,7 @@ static void iwl4965_rx_handle(struct iwl_priv *priv) | |||
3742 | pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->dma_addr, | 3118 | pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->dma_addr, |
3743 | priv->hw_params.rx_buf_size, | 3119 | priv->hw_params.rx_buf_size, |
3744 | PCI_DMA_FROMDEVICE); | 3120 | PCI_DMA_FROMDEVICE); |
3745 | pkt = (struct iwl4965_rx_packet *)rxb->skb->data; | 3121 | pkt = (struct iwl_rx_packet *)rxb->skb->data; |
3746 | 3122 | ||
3747 | /* Reclaim a command buffer only if this packet is a response | 3123 | /* Reclaim a command buffer only if this packet is a response |
3748 | * to a (driver-originated) command. | 3124 | * to a (driver-originated) command. |
@@ -3761,13 +3137,12 @@ static void iwl4965_rx_handle(struct iwl_priv *priv) | |||
3761 | * handle those that need handling via function in | 3137 | * handle those that need handling via function in |
3762 | * rx_handlers table. See iwl4965_setup_rx_handlers() */ | 3138 | * rx_handlers table. See iwl4965_setup_rx_handlers() */ |
3763 | if (priv->rx_handlers[pkt->hdr.cmd]) { | 3139 | if (priv->rx_handlers[pkt->hdr.cmd]) { |
3764 | IWL_DEBUG(IWL_DL_HOST_COMMAND | IWL_DL_RX | IWL_DL_ISR, | 3140 | IWL_DEBUG(IWL_DL_RX, "r = %d, i = %d, %s, 0x%02x\n", r, |
3765 | "r = %d, i = %d, %s, 0x%02x\n", r, i, | 3141 | i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); |
3766 | get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); | ||
3767 | priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); | 3142 | priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); |
3768 | } else { | 3143 | } else { |
3769 | /* No handling needed */ | 3144 | /* No handling needed */ |
3770 | IWL_DEBUG(IWL_DL_HOST_COMMAND | IWL_DL_RX | IWL_DL_ISR, | 3145 | IWL_DEBUG(IWL_DL_RX, |
3771 | "r %d i %d No handler needed for %s, 0x%02x\n", | 3146 | "r %d i %d No handler needed for %s, 0x%02x\n", |
3772 | r, i, get_cmd_string(pkt->hdr.cmd), | 3147 | r, i, get_cmd_string(pkt->hdr.cmd), |
3773 | pkt->hdr.cmd); | 3148 | pkt->hdr.cmd); |
@@ -3805,7 +3180,7 @@ static void iwl4965_rx_handle(struct iwl_priv *priv) | |||
3805 | count++; | 3180 | count++; |
3806 | if (count >= 8) { | 3181 | if (count >= 8) { |
3807 | priv->rxq.read = i; | 3182 | priv->rxq.read = i; |
3808 | __iwl4965_rx_replenish(priv); | 3183 | __iwl_rx_replenish(priv); |
3809 | count = 0; | 3184 | count = 0; |
3810 | } | 3185 | } |
3811 | } | 3186 | } |
@@ -3813,14 +3188,91 @@ static void iwl4965_rx_handle(struct iwl_priv *priv) | |||
3813 | 3188 | ||
3814 | /* Backtrack one entry */ | 3189 | /* Backtrack one entry */ |
3815 | priv->rxq.read = i; | 3190 | priv->rxq.read = i; |
3816 | iwl4965_rx_queue_restock(priv); | 3191 | iwl_rx_queue_restock(priv); |
3192 | } | ||
3193 | /* Convert linear signal-to-noise ratio into dB */ | ||
3194 | static u8 ratio2dB[100] = { | ||
3195 | /* 0 1 2 3 4 5 6 7 8 9 */ | ||
3196 | 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ | ||
3197 | 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ | ||
3198 | 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ | ||
3199 | 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ | ||
3200 | 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ | ||
3201 | 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ | ||
3202 | 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ | ||
3203 | 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ | ||
3204 | 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ | ||
3205 | 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ | ||
3206 | }; | ||
3207 | |||
3208 | /* Calculates a relative dB value from a ratio of linear | ||
3209 | * (i.e. not dB) signal levels. | ||
3210 | * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ | ||
3211 | int iwl4965_calc_db_from_ratio(int sig_ratio) | ||
3212 | { | ||
3213 | /* 1000:1 or higher just report as 60 dB */ | ||
3214 | if (sig_ratio >= 1000) | ||
3215 | return 60; | ||
3216 | |||
3217 | /* 100:1 or higher, divide by 10 and use table, | ||
3218 | * add 20 dB to make up for divide by 10 */ | ||
3219 | if (sig_ratio >= 100) | ||
3220 | return (20 + (int)ratio2dB[sig_ratio/10]); | ||
3221 | |||
3222 | /* We shouldn't see this */ | ||
3223 | if (sig_ratio < 1) | ||
3224 | return 0; | ||
3225 | |||
3226 | /* Use table for ratios 1:1 - 99:1 */ | ||
3227 | return (int)ratio2dB[sig_ratio]; | ||
3228 | } | ||
3229 | |||
3230 | #define PERFECT_RSSI (-20) /* dBm */ | ||
3231 | #define WORST_RSSI (-95) /* dBm */ | ||
3232 | #define RSSI_RANGE (PERFECT_RSSI - WORST_RSSI) | ||
3233 | |||
3234 | /* Calculate an indication of rx signal quality (a percentage, not dBm!). | ||
3235 | * See http://www.ces.clemson.edu/linux/signal_quality.shtml for info | ||
3236 | * about formulas used below. */ | ||
3237 | int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm) | ||
3238 | { | ||
3239 | int sig_qual; | ||
3240 | int degradation = PERFECT_RSSI - rssi_dbm; | ||
3241 | |||
3242 | /* If we get a noise measurement, use signal-to-noise ratio (SNR) | ||
3243 | * as indicator; formula is (signal dbm - noise dbm). | ||
3244 | * SNR at or above 40 is a great signal (100%). | ||
3245 | * Below that, scale to fit SNR of 0 - 40 dB within 0 - 100% indicator. | ||
3246 | * Weakest usable signal is usually 10 - 15 dB SNR. */ | ||
3247 | if (noise_dbm) { | ||
3248 | if (rssi_dbm - noise_dbm >= 40) | ||
3249 | return 100; | ||
3250 | else if (rssi_dbm < noise_dbm) | ||
3251 | return 0; | ||
3252 | sig_qual = ((rssi_dbm - noise_dbm) * 5) / 2; | ||
3253 | |||
3254 | /* Else use just the signal level. | ||
3255 | * This formula is a least squares fit of data points collected and | ||
3256 | * compared with a reference system that had a percentage (%) display | ||
3257 | * for signal quality. */ | ||
3258 | } else | ||
3259 | sig_qual = (100 * (RSSI_RANGE * RSSI_RANGE) - degradation * | ||
3260 | (15 * RSSI_RANGE + 62 * degradation)) / | ||
3261 | (RSSI_RANGE * RSSI_RANGE); | ||
3262 | |||
3263 | if (sig_qual > 100) | ||
3264 | sig_qual = 100; | ||
3265 | else if (sig_qual < 1) | ||
3266 | sig_qual = 0; | ||
3267 | |||
3268 | return sig_qual; | ||
3817 | } | 3269 | } |
3818 | 3270 | ||
3819 | /** | 3271 | /** |
3820 | * iwl4965_tx_queue_update_write_ptr - Send new write index to hardware | 3272 | * iwl4965_tx_queue_update_write_ptr - Send new write index to hardware |
3821 | */ | 3273 | */ |
3822 | static int iwl4965_tx_queue_update_write_ptr(struct iwl_priv *priv, | 3274 | static int iwl4965_tx_queue_update_write_ptr(struct iwl_priv *priv, |
3823 | struct iwl4965_tx_queue *txq) | 3275 | struct iwl_tx_queue *txq) |
3824 | { | 3276 | { |
3825 | u32 reg = 0; | 3277 | u32 reg = 0; |
3826 | int rc = 0; | 3278 | int rc = 0; |
@@ -3863,12 +3315,13 @@ static int iwl4965_tx_queue_update_write_ptr(struct iwl_priv *priv, | |||
3863 | } | 3315 | } |
3864 | 3316 | ||
3865 | #ifdef CONFIG_IWLWIFI_DEBUG | 3317 | #ifdef CONFIG_IWLWIFI_DEBUG |
3866 | static void iwl4965_print_rx_config_cmd(struct iwl4965_rxon_cmd *rxon) | 3318 | static void iwl4965_print_rx_config_cmd(struct iwl_priv *priv) |
3867 | { | 3319 | { |
3320 | struct iwl4965_rxon_cmd *rxon = &priv->staging_rxon; | ||
3868 | DECLARE_MAC_BUF(mac); | 3321 | DECLARE_MAC_BUF(mac); |
3869 | 3322 | ||
3870 | IWL_DEBUG_RADIO("RX CONFIG:\n"); | 3323 | IWL_DEBUG_RADIO("RX CONFIG:\n"); |
3871 | iwl_print_hex_dump(IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); | 3324 | iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); |
3872 | IWL_DEBUG_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); | 3325 | IWL_DEBUG_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); |
3873 | IWL_DEBUG_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); | 3326 | IWL_DEBUG_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); |
3874 | IWL_DEBUG_RADIO("u32 filter_flags: 0x%08x\n", | 3327 | IWL_DEBUG_RADIO("u32 filter_flags: 0x%08x\n", |
@@ -4094,10 +3547,10 @@ static void iwl4965_irq_handle_error(struct iwl_priv *priv) | |||
4094 | clear_bit(STATUS_HCMD_ACTIVE, &priv->status); | 3547 | clear_bit(STATUS_HCMD_ACTIVE, &priv->status); |
4095 | 3548 | ||
4096 | #ifdef CONFIG_IWLWIFI_DEBUG | 3549 | #ifdef CONFIG_IWLWIFI_DEBUG |
4097 | if (iwl_debug_level & IWL_DL_FW_ERRORS) { | 3550 | if (priv->debug_level & IWL_DL_FW_ERRORS) { |
4098 | iwl4965_dump_nic_error_log(priv); | 3551 | iwl4965_dump_nic_error_log(priv); |
4099 | iwl4965_dump_nic_event_log(priv); | 3552 | iwl4965_dump_nic_event_log(priv); |
4100 | iwl4965_print_rx_config_cmd(&priv->staging_rxon); | 3553 | iwl4965_print_rx_config_cmd(priv); |
4101 | } | 3554 | } |
4102 | #endif | 3555 | #endif |
4103 | 3556 | ||
@@ -4108,7 +3561,7 @@ static void iwl4965_irq_handle_error(struct iwl_priv *priv) | |||
4108 | clear_bit(STATUS_READY, &priv->status); | 3561 | clear_bit(STATUS_READY, &priv->status); |
4109 | 3562 | ||
4110 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) { | 3563 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) { |
4111 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_FW_ERRORS, | 3564 | IWL_DEBUG(IWL_DL_FW_ERRORS, |
4112 | "Restarting adapter due to uCode error.\n"); | 3565 | "Restarting adapter due to uCode error.\n"); |
4113 | 3566 | ||
4114 | if (iwl_is_associated(priv)) { | 3567 | if (iwl_is_associated(priv)) { |
@@ -4116,7 +3569,8 @@ static void iwl4965_irq_handle_error(struct iwl_priv *priv) | |||
4116 | sizeof(priv->recovery_rxon)); | 3569 | sizeof(priv->recovery_rxon)); |
4117 | priv->error_recovering = 1; | 3570 | priv->error_recovering = 1; |
4118 | } | 3571 | } |
4119 | queue_work(priv->workqueue, &priv->restart); | 3572 | if (priv->cfg->mod_params->restart_fw) |
3573 | queue_work(priv->workqueue, &priv->restart); | ||
4120 | } | 3574 | } |
4121 | } | 3575 | } |
4122 | 3576 | ||
@@ -4161,7 +3615,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) | |||
4161 | iwl_write32(priv, CSR_FH_INT_STATUS, inta_fh); | 3615 | iwl_write32(priv, CSR_FH_INT_STATUS, inta_fh); |
4162 | 3616 | ||
4163 | #ifdef CONFIG_IWLWIFI_DEBUG | 3617 | #ifdef CONFIG_IWLWIFI_DEBUG |
4164 | if (iwl_debug_level & IWL_DL_ISR) { | 3618 | if (priv->debug_level & IWL_DL_ISR) { |
4165 | /* just for debug */ | 3619 | /* just for debug */ |
4166 | inta_mask = iwl_read32(priv, CSR_INT_MASK); | 3620 | inta_mask = iwl_read32(priv, CSR_INT_MASK); |
4167 | IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", | 3621 | IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", |
@@ -4195,7 +3649,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) | |||
4195 | } | 3649 | } |
4196 | 3650 | ||
4197 | #ifdef CONFIG_IWLWIFI_DEBUG | 3651 | #ifdef CONFIG_IWLWIFI_DEBUG |
4198 | if (iwl_debug_level & (IWL_DL_ISR)) { | 3652 | if (priv->debug_level & (IWL_DL_ISR)) { |
4199 | /* NIC fires this, but we don't use it, redundant with WAKEUP */ | 3653 | /* NIC fires this, but we don't use it, redundant with WAKEUP */ |
4200 | if (inta & CSR_INT_BIT_SCD) | 3654 | if (inta & CSR_INT_BIT_SCD) |
4201 | IWL_DEBUG_ISR("Scheduler finished to transmit " | 3655 | IWL_DEBUG_ISR("Scheduler finished to transmit " |
@@ -4216,8 +3670,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) | |||
4216 | CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) | 3670 | CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) |
4217 | hw_rf_kill = 1; | 3671 | hw_rf_kill = 1; |
4218 | 3672 | ||
4219 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_RF_KILL | IWL_DL_ISR, | 3673 | IWL_DEBUG(IWL_DL_RF_KILL, "RF_KILL bit toggled to %s.\n", |
4220 | "RF_KILL bit toggled to %s.\n", | ||
4221 | hw_rf_kill ? "disable radio":"enable radio"); | 3674 | hw_rf_kill ? "disable radio":"enable radio"); |
4222 | 3675 | ||
4223 | /* Queue restart only if RF_KILL switch was set to "kill" | 3676 | /* Queue restart only if RF_KILL switch was set to "kill" |
@@ -4249,7 +3702,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) | |||
4249 | /* uCode wakes up after power-down sleep */ | 3702 | /* uCode wakes up after power-down sleep */ |
4250 | if (inta & CSR_INT_BIT_WAKEUP) { | 3703 | if (inta & CSR_INT_BIT_WAKEUP) { |
4251 | IWL_DEBUG_ISR("Wakeup interrupt\n"); | 3704 | IWL_DEBUG_ISR("Wakeup interrupt\n"); |
4252 | iwl4965_rx_queue_update_write_ptr(priv, &priv->rxq); | 3705 | iwl_rx_queue_update_write_ptr(priv, &priv->rxq); |
4253 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[0]); | 3706 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[0]); |
4254 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[1]); | 3707 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[1]); |
4255 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[2]); | 3708 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[2]); |
@@ -4264,7 +3717,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) | |||
4264 | * Rx "responses" (frame-received notification), and other | 3717 | * Rx "responses" (frame-received notification), and other |
4265 | * notifications from uCode come through here*/ | 3718 | * notifications from uCode come through here*/ |
4266 | if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { | 3719 | if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { |
4267 | iwl4965_rx_handle(priv); | 3720 | iwl_rx_handle(priv); |
4268 | handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); | 3721 | handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); |
4269 | } | 3722 | } |
4270 | 3723 | ||
@@ -4288,7 +3741,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) | |||
4288 | iwl4965_enable_interrupts(priv); | 3741 | iwl4965_enable_interrupts(priv); |
4289 | 3742 | ||
4290 | #ifdef CONFIG_IWLWIFI_DEBUG | 3743 | #ifdef CONFIG_IWLWIFI_DEBUG |
4291 | if (iwl_debug_level & (IWL_DL_ISR)) { | 3744 | if (priv->debug_level & (IWL_DL_ISR)) { |
4292 | inta = iwl_read32(priv, CSR_INT); | 3745 | inta = iwl_read32(priv, CSR_INT); |
4293 | inta_mask = iwl_read32(priv, CSR_INT_MASK); | 3746 | inta_mask = iwl_read32(priv, CSR_INT_MASK); |
4294 | inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); | 3747 | inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); |
@@ -4708,105 +4161,6 @@ static int iwl4965_read_ucode(struct iwl_priv *priv) | |||
4708 | return ret; | 4161 | return ret; |
4709 | } | 4162 | } |
4710 | 4163 | ||
4711 | |||
4712 | /** | ||
4713 | * iwl4965_set_ucode_ptrs - Set uCode address location | ||
4714 | * | ||
4715 | * Tell initialization uCode where to find runtime uCode. | ||
4716 | * | ||
4717 | * BSM registers initially contain pointers to initialization uCode. | ||
4718 | * We need to replace them to load runtime uCode inst and data, | ||
4719 | * and to save runtime data when powering down. | ||
4720 | */ | ||
4721 | static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv) | ||
4722 | { | ||
4723 | dma_addr_t pinst; | ||
4724 | dma_addr_t pdata; | ||
4725 | int rc = 0; | ||
4726 | unsigned long flags; | ||
4727 | |||
4728 | /* bits 35:4 for 4965 */ | ||
4729 | pinst = priv->ucode_code.p_addr >> 4; | ||
4730 | pdata = priv->ucode_data_backup.p_addr >> 4; | ||
4731 | |||
4732 | spin_lock_irqsave(&priv->lock, flags); | ||
4733 | rc = iwl_grab_nic_access(priv); | ||
4734 | if (rc) { | ||
4735 | spin_unlock_irqrestore(&priv->lock, flags); | ||
4736 | return rc; | ||
4737 | } | ||
4738 | |||
4739 | /* Tell bootstrap uCode where to find image to load */ | ||
4740 | iwl_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); | ||
4741 | iwl_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); | ||
4742 | iwl_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, | ||
4743 | priv->ucode_data.len); | ||
4744 | |||
4745 | /* Inst bytecount must be last to set up, bit 31 signals uCode | ||
4746 | * that all new ptr/size info is in place */ | ||
4747 | iwl_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, | ||
4748 | priv->ucode_code.len | BSM_DRAM_INST_LOAD); | ||
4749 | |||
4750 | iwl_release_nic_access(priv); | ||
4751 | |||
4752 | spin_unlock_irqrestore(&priv->lock, flags); | ||
4753 | |||
4754 | IWL_DEBUG_INFO("Runtime uCode pointers are set.\n"); | ||
4755 | |||
4756 | return rc; | ||
4757 | } | ||
4758 | |||
4759 | /** | ||
4760 | * iwl4965_init_alive_start - Called after REPLY_ALIVE notification received | ||
4761 | * | ||
4762 | * Called after REPLY_ALIVE notification received from "initialize" uCode. | ||
4763 | * | ||
4764 | * The 4965 "initialize" ALIVE reply contains calibration data for: | ||
4765 | * Voltage, temperature, and MIMO tx gain correction, now stored in priv | ||
4766 | * (3945 does not contain this data). | ||
4767 | * | ||
4768 | * Tell "initialize" uCode to go ahead and load the runtime uCode. | ||
4769 | */ | ||
4770 | static void iwl4965_init_alive_start(struct iwl_priv *priv) | ||
4771 | { | ||
4772 | /* Check alive response for "valid" sign from uCode */ | ||
4773 | if (priv->card_alive_init.is_valid != UCODE_VALID_OK) { | ||
4774 | /* We had an error bringing up the hardware, so take it | ||
4775 | * all the way back down so we can try again */ | ||
4776 | IWL_DEBUG_INFO("Initialize Alive failed.\n"); | ||
4777 | goto restart; | ||
4778 | } | ||
4779 | |||
4780 | /* Bootstrap uCode has loaded initialize uCode ... verify inst image. | ||
4781 | * This is a paranoid check, because we would not have gotten the | ||
4782 | * "initialize" alive if code weren't properly loaded. */ | ||
4783 | if (iwl_verify_ucode(priv)) { | ||
4784 | /* Runtime instruction load was bad; | ||
4785 | * take it all the way back down so we can try again */ | ||
4786 | IWL_DEBUG_INFO("Bad \"initialize\" uCode load.\n"); | ||
4787 | goto restart; | ||
4788 | } | ||
4789 | |||
4790 | /* Calculate temperature */ | ||
4791 | priv->temperature = iwl4965_get_temperature(priv); | ||
4792 | |||
4793 | /* Send pointers to protocol/runtime uCode image ... init code will | ||
4794 | * load and launch runtime uCode, which will send us another "Alive" | ||
4795 | * notification. */ | ||
4796 | IWL_DEBUG_INFO("Initialization Alive received.\n"); | ||
4797 | if (iwl4965_set_ucode_ptrs(priv)) { | ||
4798 | /* Runtime instruction load won't happen; | ||
4799 | * take it all the way back down so we can try again */ | ||
4800 | IWL_DEBUG_INFO("Couldn't set up uCode pointers.\n"); | ||
4801 | goto restart; | ||
4802 | } | ||
4803 | return; | ||
4804 | |||
4805 | restart: | ||
4806 | queue_work(priv->workqueue, &priv->restart); | ||
4807 | } | ||
4808 | |||
4809 | |||
4810 | /** | 4164 | /** |
4811 | * iwl4965_alive_start - called after REPLY_ALIVE notification received | 4165 | * iwl4965_alive_start - called after REPLY_ALIVE notification received |
4812 | * from protocol/runtime uCode (initialization uCode's | 4166 | * from protocol/runtime uCode (initialization uCode's |
@@ -5056,7 +4410,7 @@ static int __iwl4965_up(struct iwl_priv *priv) | |||
5056 | return ret; | 4410 | return ret; |
5057 | } | 4411 | } |
5058 | 4412 | ||
5059 | ret = priv->cfg->ops->lib->hw_nic_init(priv); | 4413 | ret = iwl_hw_nic_init(priv); |
5060 | if (ret) { | 4414 | if (ret) { |
5061 | IWL_ERROR("Unable to init nic\n"); | 4415 | IWL_ERROR("Unable to init nic\n"); |
5062 | return ret; | 4416 | return ret; |
@@ -5132,7 +4486,7 @@ static void iwl4965_bg_init_alive_start(struct work_struct *data) | |||
5132 | return; | 4486 | return; |
5133 | 4487 | ||
5134 | mutex_lock(&priv->mutex); | 4488 | mutex_lock(&priv->mutex); |
5135 | iwl4965_init_alive_start(priv); | 4489 | priv->cfg->ops->lib->init_alive_start(priv); |
5136 | mutex_unlock(&priv->mutex); | 4490 | mutex_unlock(&priv->mutex); |
5137 | } | 4491 | } |
5138 | 4492 | ||
@@ -5161,7 +4515,7 @@ static void iwl4965_bg_rf_kill(struct work_struct *work) | |||
5161 | mutex_lock(&priv->mutex); | 4515 | mutex_lock(&priv->mutex); |
5162 | 4516 | ||
5163 | if (!iwl_is_rfkill(priv)) { | 4517 | if (!iwl_is_rfkill(priv)) { |
5164 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_RF_KILL, | 4518 | IWL_DEBUG(IWL_DL_RF_KILL, |
5165 | "HW and/or SW RF Kill no longer active, restarting " | 4519 | "HW and/or SW RF Kill no longer active, restarting " |
5166 | "device\n"); | 4520 | "device\n"); |
5167 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) | 4521 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) |
@@ -5184,6 +4538,24 @@ static void iwl4965_bg_rf_kill(struct work_struct *work) | |||
5184 | mutex_unlock(&priv->mutex); | 4538 | mutex_unlock(&priv->mutex); |
5185 | } | 4539 | } |
5186 | 4540 | ||
4541 | static void iwl4965_bg_set_monitor(struct work_struct *work) | ||
4542 | { | ||
4543 | struct iwl_priv *priv = container_of(work, | ||
4544 | struct iwl_priv, set_monitor); | ||
4545 | |||
4546 | IWL_DEBUG(IWL_DL_STATE, "setting monitor mode\n"); | ||
4547 | |||
4548 | mutex_lock(&priv->mutex); | ||
4549 | |||
4550 | if (!iwl_is_ready(priv)) | ||
4551 | IWL_DEBUG(IWL_DL_STATE, "leave - not ready\n"); | ||
4552 | else | ||
4553 | if (iwl4965_set_mode(priv, IEEE80211_IF_TYPE_MNTR) != 0) | ||
4554 | IWL_ERROR("iwl4965_set_mode() failed\n"); | ||
4555 | |||
4556 | mutex_unlock(&priv->mutex); | ||
4557 | } | ||
4558 | |||
5187 | #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) | 4559 | #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) |
5188 | 4560 | ||
5189 | static void iwl4965_bg_scan_check(struct work_struct *data) | 4561 | static void iwl4965_bg_scan_check(struct work_struct *data) |
@@ -5197,9 +4569,9 @@ static void iwl4965_bg_scan_check(struct work_struct *data) | |||
5197 | mutex_lock(&priv->mutex); | 4569 | mutex_lock(&priv->mutex); |
5198 | if (test_bit(STATUS_SCANNING, &priv->status) || | 4570 | if (test_bit(STATUS_SCANNING, &priv->status) || |
5199 | test_bit(STATUS_SCAN_ABORTING, &priv->status)) { | 4571 | test_bit(STATUS_SCAN_ABORTING, &priv->status)) { |
5200 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, | 4572 | IWL_DEBUG(IWL_DL_SCAN, "Scan completion watchdog resetting " |
5201 | "Scan completion watchdog resetting adapter (%dms)\n", | 4573 | "adapter (%dms)\n", |
5202 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); | 4574 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); |
5203 | 4575 | ||
5204 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) | 4576 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) |
5205 | iwl4965_send_scan_abort(priv); | 4577 | iwl4965_send_scan_abort(priv); |
@@ -5453,7 +4825,7 @@ static void iwl4965_bg_rx_replenish(struct work_struct *data) | |||
5453 | return; | 4825 | return; |
5454 | 4826 | ||
5455 | mutex_lock(&priv->mutex); | 4827 | mutex_lock(&priv->mutex); |
5456 | iwl4965_rx_replenish(priv); | 4828 | iwl_rx_replenish(priv); |
5457 | mutex_unlock(&priv->mutex); | 4829 | mutex_unlock(&priv->mutex); |
5458 | } | 4830 | } |
5459 | 4831 | ||
@@ -5501,7 +4873,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv) | |||
5501 | 4873 | ||
5502 | #ifdef CONFIG_IWL4965_HT | 4874 | #ifdef CONFIG_IWL4965_HT |
5503 | if (priv->current_ht_config.is_ht) | 4875 | if (priv->current_ht_config.is_ht) |
5504 | iwl4965_set_rxon_ht(priv, &priv->current_ht_config); | 4876 | iwl_set_rxon_ht(priv, &priv->current_ht_config); |
5505 | #endif /* CONFIG_IWL4965_HT*/ | 4877 | #endif /* CONFIG_IWL4965_HT*/ |
5506 | iwl_set_rxon_chain(priv); | 4878 | iwl_set_rxon_chain(priv); |
5507 | priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); | 4879 | priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); |
@@ -5600,7 +4972,7 @@ static void iwl4965_bg_scan_completed(struct work_struct *work) | |||
5600 | struct iwl_priv *priv = | 4972 | struct iwl_priv *priv = |
5601 | container_of(work, struct iwl_priv, scan_completed); | 4973 | container_of(work, struct iwl_priv, scan_completed); |
5602 | 4974 | ||
5603 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, "SCAN complete scan\n"); | 4975 | IWL_DEBUG(IWL_DL_SCAN, "SCAN complete scan\n"); |
5604 | 4976 | ||
5605 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | 4977 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
5606 | return; | 4978 | return; |
@@ -6073,7 +5445,22 @@ static void iwl4965_configure_filter(struct ieee80211_hw *hw, | |||
6073 | * XXX: dummy | 5445 | * XXX: dummy |
6074 | * see also iwl4965_connection_init_rx_config | 5446 | * see also iwl4965_connection_init_rx_config |
6075 | */ | 5447 | */ |
6076 | *total_flags = 0; | 5448 | struct iwl_priv *priv = hw->priv; |
5449 | int new_flags = 0; | ||
5450 | if (changed_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) { | ||
5451 | if (*total_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) { | ||
5452 | IWL_DEBUG_MAC80211("Enter: type %d (0x%x, 0x%x)\n", | ||
5453 | IEEE80211_IF_TYPE_MNTR, | ||
5454 | changed_flags, *total_flags); | ||
5455 | /* queue work 'cuz mac80211 is holding a lock which | ||
5456 | * prevents us from issuing (synchronous) f/w cmds */ | ||
5457 | queue_work(priv->workqueue, &priv->set_monitor); | ||
5458 | new_flags &= FIF_PROMISC_IN_BSS | | ||
5459 | FIF_OTHER_BSS | | ||
5460 | FIF_ALLMULTI; | ||
5461 | } | ||
5462 | } | ||
5463 | *total_flags = new_flags; | ||
6077 | } | 5464 | } |
6078 | 5465 | ||
6079 | static void iwl4965_mac_remove_interface(struct ieee80211_hw *hw, | 5466 | static void iwl4965_mac_remove_interface(struct ieee80211_hw *hw, |
@@ -6261,7 +5648,7 @@ static void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw, | |||
6261 | priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; | 5648 | priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; |
6262 | priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; | 5649 | priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; |
6263 | 5650 | ||
6264 | iwl4965_send_add_station(priv, &priv->stations[sta_id].sta, CMD_ASYNC); | 5651 | iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); |
6265 | 5652 | ||
6266 | spin_unlock_irqrestore(&priv->sta_lock, flags); | 5653 | spin_unlock_irqrestore(&priv->sta_lock, flags); |
6267 | 5654 | ||
@@ -6395,7 +5782,7 @@ static int iwl4965_mac_get_tx_stats(struct ieee80211_hw *hw, | |||
6395 | { | 5782 | { |
6396 | struct iwl_priv *priv = hw->priv; | 5783 | struct iwl_priv *priv = hw->priv; |
6397 | int i, avail; | 5784 | int i, avail; |
6398 | struct iwl4965_tx_queue *txq; | 5785 | struct iwl_tx_queue *txq; |
6399 | struct iwl4965_queue *q; | 5786 | struct iwl4965_queue *q; |
6400 | unsigned long flags; | 5787 | unsigned long flags; |
6401 | 5788 | ||
@@ -6428,6 +5815,9 @@ static int iwl4965_mac_get_tx_stats(struct ieee80211_hw *hw, | |||
6428 | static int iwl4965_mac_get_stats(struct ieee80211_hw *hw, | 5815 | static int iwl4965_mac_get_stats(struct ieee80211_hw *hw, |
6429 | struct ieee80211_low_level_stats *stats) | 5816 | struct ieee80211_low_level_stats *stats) |
6430 | { | 5817 | { |
5818 | struct iwl_priv *priv = hw->priv; | ||
5819 | |||
5820 | priv = hw->priv; | ||
6431 | IWL_DEBUG_MAC80211("enter\n"); | 5821 | IWL_DEBUG_MAC80211("enter\n"); |
6432 | IWL_DEBUG_MAC80211("leave\n"); | 5822 | IWL_DEBUG_MAC80211("leave\n"); |
6433 | 5823 | ||
@@ -6436,6 +5826,9 @@ static int iwl4965_mac_get_stats(struct ieee80211_hw *hw, | |||
6436 | 5826 | ||
6437 | static u64 iwl4965_mac_get_tsf(struct ieee80211_hw *hw) | 5827 | static u64 iwl4965_mac_get_tsf(struct ieee80211_hw *hw) |
6438 | { | 5828 | { |
5829 | struct iwl_priv *priv; | ||
5830 | |||
5831 | priv = hw->priv; | ||
6439 | IWL_DEBUG_MAC80211("enter\n"); | 5832 | IWL_DEBUG_MAC80211("enter\n"); |
6440 | IWL_DEBUG_MAC80211("leave\n"); | 5833 | IWL_DEBUG_MAC80211("leave\n"); |
6441 | 5834 | ||
@@ -6569,13 +5962,18 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk | |||
6569 | * See the level definitions in iwl for details. | 5962 | * See the level definitions in iwl for details. |
6570 | */ | 5963 | */ |
6571 | 5964 | ||
6572 | static ssize_t show_debug_level(struct device_driver *d, char *buf) | 5965 | static ssize_t show_debug_level(struct device *d, |
5966 | struct device_attribute *attr, char *buf) | ||
6573 | { | 5967 | { |
6574 | return sprintf(buf, "0x%08X\n", iwl_debug_level); | 5968 | struct iwl_priv *priv = d->driver_data; |
5969 | |||
5970 | return sprintf(buf, "0x%08X\n", priv->debug_level); | ||
6575 | } | 5971 | } |
6576 | static ssize_t store_debug_level(struct device_driver *d, | 5972 | static ssize_t store_debug_level(struct device *d, |
5973 | struct device_attribute *attr, | ||
6577 | const char *buf, size_t count) | 5974 | const char *buf, size_t count) |
6578 | { | 5975 | { |
5976 | struct iwl_priv *priv = d->driver_data; | ||
6579 | char *p = (char *)buf; | 5977 | char *p = (char *)buf; |
6580 | u32 val; | 5978 | u32 val; |
6581 | 5979 | ||
@@ -6584,17 +5982,37 @@ static ssize_t store_debug_level(struct device_driver *d, | |||
6584 | printk(KERN_INFO DRV_NAME | 5982 | printk(KERN_INFO DRV_NAME |
6585 | ": %s is not in hex or decimal form.\n", buf); | 5983 | ": %s is not in hex or decimal form.\n", buf); |
6586 | else | 5984 | else |
6587 | iwl_debug_level = val; | 5985 | priv->debug_level = val; |
6588 | 5986 | ||
6589 | return strnlen(buf, count); | 5987 | return strnlen(buf, count); |
6590 | } | 5988 | } |
6591 | 5989 | ||
6592 | static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, | 5990 | static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, |
6593 | show_debug_level, store_debug_level); | 5991 | show_debug_level, store_debug_level); |
5992 | |||
6594 | 5993 | ||
6595 | #endif /* CONFIG_IWLWIFI_DEBUG */ | 5994 | #endif /* CONFIG_IWLWIFI_DEBUG */ |
6596 | 5995 | ||
6597 | 5996 | ||
5997 | static ssize_t show_version(struct device *d, | ||
5998 | struct device_attribute *attr, char *buf) | ||
5999 | { | ||
6000 | struct iwl_priv *priv = d->driver_data; | ||
6001 | struct iwl4965_alive_resp *palive = &priv->card_alive; | ||
6002 | |||
6003 | if (palive->is_valid) | ||
6004 | return sprintf(buf, "fw version: 0x%01X.0x%01X.0x%01X.0x%01X\n" | ||
6005 | "fw type: 0x%01X 0x%01X\n", | ||
6006 | palive->ucode_major, palive->ucode_minor, | ||
6007 | palive->sw_rev[0], palive->sw_rev[1], | ||
6008 | palive->ver_type, palive->ver_subtype); | ||
6009 | |||
6010 | else | ||
6011 | return sprintf(buf, "fw not loaded\n"); | ||
6012 | } | ||
6013 | |||
6014 | static DEVICE_ATTR(version, S_IWUSR | S_IRUGO, show_version, NULL); | ||
6015 | |||
6598 | static ssize_t show_temperature(struct device *d, | 6016 | static ssize_t show_temperature(struct device *d, |
6599 | struct device_attribute *attr, char *buf) | 6017 | struct device_attribute *attr, char *buf) |
6600 | { | 6018 | { |
@@ -6998,6 +6416,7 @@ static void iwl4965_setup_deferred_work(struct iwl_priv *priv) | |||
6998 | INIT_WORK(&priv->abort_scan, iwl4965_bg_abort_scan); | 6416 | INIT_WORK(&priv->abort_scan, iwl4965_bg_abort_scan); |
6999 | INIT_WORK(&priv->rf_kill, iwl4965_bg_rf_kill); | 6417 | INIT_WORK(&priv->rf_kill, iwl4965_bg_rf_kill); |
7000 | INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); | 6418 | INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); |
6419 | INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor); | ||
7001 | INIT_DELAYED_WORK(&priv->post_associate, iwl4965_bg_post_associate); | 6420 | INIT_DELAYED_WORK(&priv->post_associate, iwl4965_bg_post_associate); |
7002 | INIT_DELAYED_WORK(&priv->init_alive_start, iwl4965_bg_init_alive_start); | 6421 | INIT_DELAYED_WORK(&priv->init_alive_start, iwl4965_bg_init_alive_start); |
7003 | INIT_DELAYED_WORK(&priv->alive_start, iwl4965_bg_alive_start); | 6422 | INIT_DELAYED_WORK(&priv->alive_start, iwl4965_bg_alive_start); |
@@ -7036,6 +6455,10 @@ static struct attribute *iwl4965_sysfs_entries[] = { | |||
7036 | &dev_attr_status.attr, | 6455 | &dev_attr_status.attr, |
7037 | &dev_attr_temperature.attr, | 6456 | &dev_attr_temperature.attr, |
7038 | &dev_attr_tx_power.attr, | 6457 | &dev_attr_tx_power.attr, |
6458 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
6459 | &dev_attr_debug_level.attr, | ||
6460 | #endif | ||
6461 | &dev_attr_version.attr, | ||
7039 | 6462 | ||
7040 | NULL | 6463 | NULL |
7041 | }; | 6464 | }; |
@@ -7085,7 +6508,9 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7085 | /* Disabling hardware scan means that mac80211 will perform scans | 6508 | /* Disabling hardware scan means that mac80211 will perform scans |
7086 | * "the hard way", rather than using device's scan. */ | 6509 | * "the hard way", rather than using device's scan. */ |
7087 | if (cfg->mod_params->disable_hw_scan) { | 6510 | if (cfg->mod_params->disable_hw_scan) { |
7088 | IWL_DEBUG_INFO("Disabling hw_scan\n"); | 6511 | if (cfg->mod_params->debug & IWL_DL_INFO) |
6512 | dev_printk(KERN_DEBUG, &(pdev->dev), | ||
6513 | "Disabling hw_scan\n"); | ||
7089 | iwl4965_hw_ops.hw_scan = NULL; | 6514 | iwl4965_hw_ops.hw_scan = NULL; |
7090 | } | 6515 | } |
7091 | 6516 | ||
@@ -7104,7 +6529,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7104 | priv->pci_dev = pdev; | 6529 | priv->pci_dev = pdev; |
7105 | 6530 | ||
7106 | #ifdef CONFIG_IWLWIFI_DEBUG | 6531 | #ifdef CONFIG_IWLWIFI_DEBUG |
7107 | iwl_debug_level = priv->cfg->mod_params->debug; | 6532 | priv->debug_level = priv->cfg->mod_params->debug; |
7108 | atomic_set(&priv->restrict_refcnt, 0); | 6533 | atomic_set(&priv->restrict_refcnt, 0); |
7109 | #endif | 6534 | #endif |
7110 | 6535 | ||
@@ -7310,8 +6735,8 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) | |||
7310 | iwl4965_dealloc_ucode_pci(priv); | 6735 | iwl4965_dealloc_ucode_pci(priv); |
7311 | 6736 | ||
7312 | if (priv->rxq.bd) | 6737 | if (priv->rxq.bd) |
7313 | iwl4965_rx_queue_free(priv, &priv->rxq); | 6738 | iwl_rx_queue_free(priv, &priv->rxq); |
7314 | iwl4965_hw_txq_ctx_free(priv); | 6739 | iwl_hw_txq_ctx_free(priv); |
7315 | 6740 | ||
7316 | iwlcore_clear_stations_table(priv); | 6741 | iwlcore_clear_stations_table(priv); |
7317 | iwl_eeprom_free(priv); | 6742 | iwl_eeprom_free(priv); |
@@ -7420,18 +6845,11 @@ static int __init iwl4965_init(void) | |||
7420 | IWL_ERROR("Unable to initialize PCI module\n"); | 6845 | IWL_ERROR("Unable to initialize PCI module\n"); |
7421 | goto error_register; | 6846 | goto error_register; |
7422 | } | 6847 | } |
7423 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
7424 | ret = driver_create_file(&iwl_driver.driver, &driver_attr_debug_level); | ||
7425 | if (ret) { | ||
7426 | IWL_ERROR("Unable to create driver sysfs file\n"); | ||
7427 | goto error_debug; | ||
7428 | } | ||
7429 | #endif | ||
7430 | 6848 | ||
7431 | return ret; | 6849 | return ret; |
7432 | 6850 | ||
6851 | |||
7433 | #ifdef CONFIG_IWLWIFI_DEBUG | 6852 | #ifdef CONFIG_IWLWIFI_DEBUG |
7434 | error_debug: | ||
7435 | pci_unregister_driver(&iwl_driver); | 6853 | pci_unregister_driver(&iwl_driver); |
7436 | #endif | 6854 | #endif |
7437 | error_register: | 6855 | error_register: |
@@ -7441,9 +6859,6 @@ error_register: | |||
7441 | 6859 | ||
7442 | static void __exit iwl4965_exit(void) | 6860 | static void __exit iwl4965_exit(void) |
7443 | { | 6861 | { |
7444 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
7445 | driver_remove_file(&iwl_driver.driver, &driver_attr_debug_level); | ||
7446 | #endif | ||
7447 | pci_unregister_driver(&iwl_driver); | 6862 | pci_unregister_driver(&iwl_driver); |
7448 | iwl4965_rate_control_unregister(); | 6863 | iwl4965_rate_control_unregister(); |
7449 | } | 6864 | } |