diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl4965-base.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl4965-base.c | 1670 |
1 files changed, 143 insertions, 1527 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 55ca752ae9e6..c71daec8c746 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c | |||
@@ -53,8 +53,6 @@ | |||
53 | #include "iwl-sta.h" | 53 | #include "iwl-sta.h" |
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, | ||
57 | struct iwl_tx_queue *txq); | ||
58 | 56 | ||
59 | /****************************************************************************** | 57 | /****************************************************************************** |
60 | * | 58 | * |
@@ -89,22 +87,6 @@ MODULE_VERSION(DRV_VERSION); | |||
89 | MODULE_AUTHOR(DRV_COPYRIGHT); | 87 | MODULE_AUTHOR(DRV_COPYRIGHT); |
90 | MODULE_LICENSE("GPL"); | 88 | MODULE_LICENSE("GPL"); |
91 | 89 | ||
92 | __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr) | ||
93 | { | ||
94 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
95 | int hdr_len = ieee80211_get_hdrlen(fc); | ||
96 | |||
97 | if ((fc & 0x00cc) == (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) | ||
98 | return (__le16 *) ((u8 *) hdr + hdr_len - QOS_CONTROL_LEN); | ||
99 | return NULL; | ||
100 | } | ||
101 | |||
102 | static const struct ieee80211_supported_band *iwl_get_hw_mode( | ||
103 | struct iwl_priv *priv, enum ieee80211_band band) | ||
104 | { | ||
105 | return priv->hw->wiphy->bands[band]; | ||
106 | } | ||
107 | |||
108 | static int iwl4965_is_empty_essid(const char *essid, int essid_len) | 90 | static int iwl4965_is_empty_essid(const char *essid, int essid_len) |
109 | { | 91 | { |
110 | /* Single white space is for Linksys APs */ | 92 | /* Single white space is for Linksys APs */ |
@@ -145,70 +127,6 @@ static const char *iwl4965_escape_essid(const char *essid, u8 essid_len) | |||
145 | return escaped; | 127 | return escaped; |
146 | } | 128 | } |
147 | 129 | ||
148 | |||
149 | /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** | ||
150 | * DMA services | ||
151 | * | ||
152 | * Theory of operation | ||
153 | * | ||
154 | * A Tx or Rx queue resides in host DRAM, and is comprised of a circular buffer | ||
155 | * of buffer descriptors, each of which points to one or more data buffers for | ||
156 | * the device to read from or fill. Driver and device exchange status of each | ||
157 | * queue via "read" and "write" pointers. Driver keeps minimum of 2 empty | ||
158 | * entries in each circular buffer, to protect against confusing empty and full | ||
159 | * queue states. | ||
160 | * | ||
161 | * The device reads or writes the data in the queues via the device's several | ||
162 | * DMA/FIFO channels. Each queue is mapped to a single DMA channel. | ||
163 | * | ||
164 | * For Tx queue, there are low mark and high mark limits. If, after queuing | ||
165 | * the packet for Tx, free space become < low mark, Tx queue stopped. When | ||
166 | * reclaiming packets (on 'tx done IRQ), if free space become > high mark, | ||
167 | * Tx queue resumed. | ||
168 | * | ||
169 | * The 4965 operates with up to 17 queues: One receive queue, one transmit | ||
170 | * queue (#4) for sending commands to the device firmware, and 15 other | ||
171 | * Tx queues that may be mapped to prioritized Tx DMA/FIFO channels. | ||
172 | * | ||
173 | * See more detailed info in iwl-4965-hw.h. | ||
174 | ***************************************************/ | ||
175 | |||
176 | int iwl4965_queue_space(const struct iwl4965_queue *q) | ||
177 | { | ||
178 | int s = q->read_ptr - q->write_ptr; | ||
179 | |||
180 | if (q->read_ptr > q->write_ptr) | ||
181 | s -= q->n_bd; | ||
182 | |||
183 | if (s <= 0) | ||
184 | s += q->n_window; | ||
185 | /* keep some reserve to not confuse empty and full situations */ | ||
186 | s -= 2; | ||
187 | if (s < 0) | ||
188 | s = 0; | ||
189 | return s; | ||
190 | } | ||
191 | |||
192 | |||
193 | static inline int x2_queue_used(const struct iwl4965_queue *q, int i) | ||
194 | { | ||
195 | return q->write_ptr > q->read_ptr ? | ||
196 | (i >= q->read_ptr && i < q->write_ptr) : | ||
197 | !(i < q->read_ptr && i >= q->write_ptr); | ||
198 | } | ||
199 | |||
200 | static inline u8 get_cmd_index(struct iwl4965_queue *q, u32 index, int is_huge) | ||
201 | { | ||
202 | /* This is for scan command, the big buffer at end of command array */ | ||
203 | if (is_huge) | ||
204 | return q->n_window; /* must be power of 2 */ | ||
205 | |||
206 | /* Otherwise, use normal size buffers */ | ||
207 | return index & (q->n_window - 1); | ||
208 | } | ||
209 | |||
210 | const u8 iwl4965_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | ||
211 | |||
212 | /*************** STATION TABLE MANAGEMENT **** | 130 | /*************** STATION TABLE MANAGEMENT **** |
213 | * mac80211 should be examined to determine if sta_info is duplicating | 131 | * mac80211 should be examined to determine if sta_info is duplicating |
214 | * the functionality provided here | 132 | * the functionality provided here |
@@ -216,213 +134,11 @@ const u8 iwl4965_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF | |||
216 | 134 | ||
217 | /**************************************************************/ | 135 | /**************************************************************/ |
218 | 136 | ||
219 | #if 0 /* temporary disable till we add real remove station */ | ||
220 | /** | ||
221 | * iwl4965_remove_station - Remove driver's knowledge of station. | ||
222 | * | ||
223 | * NOTE: This does not remove station from device's station table. | ||
224 | */ | ||
225 | static u8 iwl4965_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap) | ||
226 | { | ||
227 | int index = IWL_INVALID_STATION; | ||
228 | int i; | ||
229 | unsigned long flags; | ||
230 | |||
231 | spin_lock_irqsave(&priv->sta_lock, flags); | ||
232 | 137 | ||
233 | if (is_ap) | ||
234 | index = IWL_AP_ID; | ||
235 | else if (is_broadcast_ether_addr(addr)) | ||
236 | index = priv->hw_params.bcast_sta_id; | ||
237 | else | ||
238 | for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) | ||
239 | if (priv->stations[i].used && | ||
240 | !compare_ether_addr(priv->stations[i].sta.sta.addr, | ||
241 | addr)) { | ||
242 | index = i; | ||
243 | break; | ||
244 | } | ||
245 | |||
246 | if (unlikely(index == IWL_INVALID_STATION)) | ||
247 | goto out; | ||
248 | |||
249 | if (priv->stations[index].used) { | ||
250 | priv->stations[index].used = 0; | ||
251 | priv->num_stations--; | ||
252 | } | ||
253 | |||
254 | BUG_ON(priv->num_stations < 0); | ||
255 | |||
256 | out: | ||
257 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
258 | return 0; | ||
259 | } | ||
260 | #endif | ||
261 | |||
262 | /** | ||
263 | * iwl4965_add_station_flags - Add station to tables in driver and device | ||
264 | */ | ||
265 | u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr, | ||
266 | int is_ap, u8 flags, void *ht_data) | ||
267 | { | ||
268 | int i; | ||
269 | int index = IWL_INVALID_STATION; | ||
270 | struct iwl_station_entry *station; | ||
271 | unsigned long flags_spin; | ||
272 | DECLARE_MAC_BUF(mac); | ||
273 | |||
274 | spin_lock_irqsave(&priv->sta_lock, flags_spin); | ||
275 | if (is_ap) | ||
276 | index = IWL_AP_ID; | ||
277 | else if (is_broadcast_ether_addr(addr)) | ||
278 | index = priv->hw_params.bcast_sta_id; | ||
279 | else | ||
280 | for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) { | ||
281 | if (!compare_ether_addr(priv->stations[i].sta.sta.addr, | ||
282 | addr)) { | ||
283 | index = i; | ||
284 | break; | ||
285 | } | ||
286 | |||
287 | if (!priv->stations[i].used && | ||
288 | index == IWL_INVALID_STATION) | ||
289 | index = i; | ||
290 | } | ||
291 | |||
292 | |||
293 | /* These two conditions have the same outcome, but keep them separate | ||
294 | since they have different meanings */ | ||
295 | if (unlikely(index == IWL_INVALID_STATION)) { | ||
296 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
297 | return index; | ||
298 | } | ||
299 | |||
300 | if (priv->stations[index].used && | ||
301 | !compare_ether_addr(priv->stations[index].sta.sta.addr, addr)) { | ||
302 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
303 | return index; | ||
304 | } | ||
305 | |||
306 | |||
307 | IWL_DEBUG_ASSOC("Add STA ID %d: %s\n", index, print_mac(mac, addr)); | ||
308 | station = &priv->stations[index]; | ||
309 | station->used = 1; | ||
310 | priv->num_stations++; | ||
311 | |||
312 | /* Set up the REPLY_ADD_STA command to send to device */ | ||
313 | memset(&station->sta, 0, sizeof(struct iwl_addsta_cmd)); | ||
314 | memcpy(station->sta.sta.addr, addr, ETH_ALEN); | ||
315 | station->sta.mode = 0; | ||
316 | station->sta.sta.sta_id = index; | ||
317 | station->sta.station_flags = 0; | ||
318 | |||
319 | #ifdef CONFIG_IWL4965_HT | ||
320 | /* BCAST station and IBSS stations do not work in HT mode */ | ||
321 | if (index != priv->hw_params.bcast_sta_id && | ||
322 | priv->iw_mode != IEEE80211_IF_TYPE_IBSS) | ||
323 | iwl4965_set_ht_add_station(priv, index, | ||
324 | (struct ieee80211_ht_info *) ht_data); | ||
325 | #endif /*CONFIG_IWL4965_HT*/ | ||
326 | |||
327 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
328 | |||
329 | /* Add station to device's station table */ | ||
330 | iwl_send_add_sta(priv, &station->sta, flags); | ||
331 | return index; | ||
332 | |||
333 | } | ||
334 | |||
335 | |||
336 | |||
337 | /*************** HOST COMMAND QUEUE FUNCTIONS *****/ | ||
338 | |||
339 | /** | ||
340 | * iwl4965_enqueue_hcmd - enqueue a uCode command | ||
341 | * @priv: device private data point | ||
342 | * @cmd: a point to the ucode command structure | ||
343 | * | ||
344 | * The function returns < 0 values to indicate the operation is | ||
345 | * failed. On success, it turns the index (> 0) of command in the | ||
346 | * command queue. | ||
347 | */ | ||
348 | int iwl4965_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) | ||
349 | { | ||
350 | struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; | ||
351 | struct iwl4965_queue *q = &txq->q; | ||
352 | struct iwl_tfd_frame *tfd; | ||
353 | u32 *control_flags; | ||
354 | struct iwl_cmd *out_cmd; | ||
355 | u32 idx; | ||
356 | u16 fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); | ||
357 | dma_addr_t phys_addr; | ||
358 | int ret; | ||
359 | unsigned long flags; | ||
360 | |||
361 | /* If any of the command structures end up being larger than | ||
362 | * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then | ||
363 | * we will need to increase the size of the TFD entries */ | ||
364 | BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && | ||
365 | !(cmd->meta.flags & CMD_SIZE_HUGE)); | ||
366 | |||
367 | if (iwl_is_rfkill(priv)) { | ||
368 | IWL_DEBUG_INFO("Not sending command - RF KILL"); | ||
369 | return -EIO; | ||
370 | } | ||
371 | |||
372 | if (iwl4965_queue_space(q) < ((cmd->meta.flags & CMD_ASYNC) ? 2 : 1)) { | ||
373 | IWL_ERROR("No space for Tx\n"); | ||
374 | return -ENOSPC; | ||
375 | } | ||
376 | |||
377 | spin_lock_irqsave(&priv->hcmd_lock, flags); | ||
378 | |||
379 | tfd = &txq->bd[q->write_ptr]; | ||
380 | memset(tfd, 0, sizeof(*tfd)); | ||
381 | |||
382 | control_flags = (u32 *) tfd; | ||
383 | |||
384 | idx = get_cmd_index(q, q->write_ptr, cmd->meta.flags & CMD_SIZE_HUGE); | ||
385 | out_cmd = &txq->cmd[idx]; | ||
386 | |||
387 | out_cmd->hdr.cmd = cmd->id; | ||
388 | memcpy(&out_cmd->meta, &cmd->meta, sizeof(cmd->meta)); | ||
389 | memcpy(&out_cmd->cmd.payload, cmd->data, cmd->len); | ||
390 | |||
391 | /* At this point, the out_cmd now has all of the incoming cmd | ||
392 | * information */ | ||
393 | |||
394 | out_cmd->hdr.flags = 0; | ||
395 | out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(IWL_CMD_QUEUE_NUM) | | ||
396 | INDEX_TO_SEQ(q->write_ptr)); | ||
397 | if (out_cmd->meta.flags & CMD_SIZE_HUGE) | ||
398 | out_cmd->hdr.sequence |= cpu_to_le16(SEQ_HUGE_FRAME); | ||
399 | |||
400 | phys_addr = txq->dma_addr_cmd + sizeof(txq->cmd[0]) * idx + | ||
401 | offsetof(struct iwl_cmd, hdr); | ||
402 | iwl4965_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, fix_size); | ||
403 | |||
404 | IWL_DEBUG_HC("Sending command %s (#%x), seq: 0x%04X, " | ||
405 | "%d bytes at %d[%d]:%d\n", | ||
406 | get_cmd_string(out_cmd->hdr.cmd), | ||
407 | out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), | ||
408 | fix_size, q->write_ptr, idx, IWL_CMD_QUEUE_NUM); | ||
409 | |||
410 | txq->need_update = 1; | ||
411 | |||
412 | /* Set up entry in queue's byte count circular buffer */ | ||
413 | priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, 0); | ||
414 | |||
415 | /* Increment and update queue's write index */ | ||
416 | q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); | ||
417 | ret = iwl4965_tx_queue_update_write_ptr(priv, txq); | ||
418 | |||
419 | spin_unlock_irqrestore(&priv->hcmd_lock, flags); | ||
420 | return ret ? ret : idx; | ||
421 | } | ||
422 | 138 | ||
423 | static void iwl4965_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) | 139 | static void iwl4965_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) |
424 | { | 140 | { |
425 | struct iwl4965_rxon_cmd *rxon = &priv->staging_rxon; | 141 | struct iwl_rxon_cmd *rxon = &priv->staging_rxon; |
426 | 142 | ||
427 | if (hw_decrypt) | 143 | if (hw_decrypt) |
428 | rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; | 144 | rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; |
@@ -432,45 +148,13 @@ static void iwl4965_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) | |||
432 | } | 148 | } |
433 | 149 | ||
434 | /** | 150 | /** |
435 | * iwl4965_rxon_add_station - add station into station table. | ||
436 | * | ||
437 | * there is only one AP station with id= IWL_AP_ID | ||
438 | * NOTE: mutex must be held before calling this fnction | ||
439 | */ | ||
440 | static int iwl4965_rxon_add_station(struct iwl_priv *priv, | ||
441 | const u8 *addr, int is_ap) | ||
442 | { | ||
443 | u8 sta_id; | ||
444 | |||
445 | /* Add station to device's station table */ | ||
446 | #ifdef CONFIG_IWL4965_HT | ||
447 | struct ieee80211_conf *conf = &priv->hw->conf; | ||
448 | struct ieee80211_ht_info *cur_ht_config = &conf->ht_conf; | ||
449 | |||
450 | if ((is_ap) && | ||
451 | (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) && | ||
452 | (priv->iw_mode == IEEE80211_IF_TYPE_STA)) | ||
453 | sta_id = iwl4965_add_station_flags(priv, addr, is_ap, | ||
454 | 0, cur_ht_config); | ||
455 | else | ||
456 | #endif /* CONFIG_IWL4965_HT */ | ||
457 | sta_id = iwl4965_add_station_flags(priv, addr, is_ap, | ||
458 | 0, NULL); | ||
459 | |||
460 | /* Set up default rate scaling table in device's station table */ | ||
461 | iwl4965_add_station(priv, addr, is_ap); | ||
462 | |||
463 | return sta_id; | ||
464 | } | ||
465 | |||
466 | /** | ||
467 | * iwl4965_check_rxon_cmd - validate RXON structure is valid | 151 | * iwl4965_check_rxon_cmd - validate RXON structure is valid |
468 | * | 152 | * |
469 | * NOTE: This is really only useful during development and can eventually | 153 | * NOTE: This is really only useful during development and can eventually |
470 | * be #ifdef'd out once the driver is stable and folks aren't actively | 154 | * be #ifdef'd out once the driver is stable and folks aren't actively |
471 | * making changes | 155 | * making changes |
472 | */ | 156 | */ |
473 | static int iwl4965_check_rxon_cmd(struct iwl4965_rxon_cmd *rxon) | 157 | static int iwl4965_check_rxon_cmd(struct iwl_rxon_cmd *rxon) |
474 | { | 158 | { |
475 | int error = 0; | 159 | int error = 0; |
476 | int counter = 1; | 160 | int counter = 1; |
@@ -595,7 +279,7 @@ static int iwl4965_full_rxon_required(struct iwl_priv *priv) | |||
595 | static int iwl4965_commit_rxon(struct iwl_priv *priv) | 279 | static int iwl4965_commit_rxon(struct iwl_priv *priv) |
596 | { | 280 | { |
597 | /* cast away the const for active_rxon in this function */ | 281 | /* cast away the const for active_rxon in this function */ |
598 | struct iwl4965_rxon_cmd *active_rxon = (void *)&priv->active_rxon; | 282 | struct iwl_rxon_cmd *active_rxon = (void *)&priv->active_rxon; |
599 | DECLARE_MAC_BUF(mac); | 283 | DECLARE_MAC_BUF(mac); |
600 | int rc = 0; | 284 | int rc = 0; |
601 | 285 | ||
@@ -640,7 +324,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv) | |||
640 | active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 324 | active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
641 | 325 | ||
642 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON, | 326 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON, |
643 | sizeof(struct iwl4965_rxon_cmd), | 327 | sizeof(struct iwl_rxon_cmd), |
644 | &priv->active_rxon); | 328 | &priv->active_rxon); |
645 | 329 | ||
646 | /* If the mask clearing failed then we set | 330 | /* If the mask clearing failed then we set |
@@ -665,12 +349,13 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv) | |||
665 | iwl4965_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto); | 349 | iwl4965_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto); |
666 | /* Apply the new configuration */ | 350 | /* Apply the new configuration */ |
667 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON, | 351 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON, |
668 | sizeof(struct iwl4965_rxon_cmd), &priv->staging_rxon); | 352 | sizeof(struct iwl_rxon_cmd), &priv->staging_rxon); |
669 | if (rc) { | 353 | if (rc) { |
670 | IWL_ERROR("Error setting new configuration (%d).\n", rc); | 354 | IWL_ERROR("Error setting new configuration (%d).\n", rc); |
671 | return rc; | 355 | return rc; |
672 | } | 356 | } |
673 | 357 | ||
358 | iwl_remove_station(priv, iwl_bcast_addr, 0); | ||
674 | iwlcore_clear_stations_table(priv); | 359 | iwlcore_clear_stations_table(priv); |
675 | 360 | ||
676 | if (!priv->error_recovering) | 361 | if (!priv->error_recovering) |
@@ -689,7 +374,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv) | |||
689 | } | 374 | } |
690 | 375 | ||
691 | /* Add the broadcast address so we can send broadcast frames */ | 376 | /* Add the broadcast address so we can send broadcast frames */ |
692 | if (iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0) == | 377 | if (iwl_rxon_add_station(priv, iwl_bcast_addr, 0) == |
693 | IWL_INVALID_STATION) { | 378 | IWL_INVALID_STATION) { |
694 | IWL_ERROR("Error adding BROADCAST address for transmit.\n"); | 379 | IWL_ERROR("Error adding BROADCAST address for transmit.\n"); |
695 | return -EIO; | 380 | return -EIO; |
@@ -699,7 +384,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv) | |||
699 | * add the IWL_AP_ID to the station rate table */ | 384 | * add the IWL_AP_ID to the station rate table */ |
700 | if (iwl_is_associated(priv) && | 385 | if (iwl_is_associated(priv) && |
701 | (priv->iw_mode == IEEE80211_IF_TYPE_STA)) { | 386 | (priv->iw_mode == IEEE80211_IF_TYPE_STA)) { |
702 | if (iwl4965_rxon_add_station(priv, priv->active_rxon.bssid_addr, 1) | 387 | if (iwl_rxon_add_station(priv, priv->active_rxon.bssid_addr, 1) |
703 | == IWL_INVALID_STATION) { | 388 | == IWL_INVALID_STATION) { |
704 | IWL_ERROR("Error adding AP address for transmit.\n"); | 389 | IWL_ERROR("Error adding AP address for transmit.\n"); |
705 | return -EIO; | 390 | return -EIO; |
@@ -797,7 +482,7 @@ static int iwl4965_send_card_state(struct iwl_priv *priv, u32 flags, u8 meta_fla | |||
797 | return iwl_send_cmd(priv, &cmd); | 482 | return iwl_send_cmd(priv, &cmd); |
798 | } | 483 | } |
799 | 484 | ||
800 | static void iwl4965_clear_free_frames(struct iwl_priv *priv) | 485 | static void iwl_clear_free_frames(struct iwl_priv *priv) |
801 | { | 486 | { |
802 | struct list_head *element; | 487 | struct list_head *element; |
803 | 488 | ||
@@ -807,7 +492,7 @@ static void iwl4965_clear_free_frames(struct iwl_priv *priv) | |||
807 | while (!list_empty(&priv->free_frames)) { | 492 | while (!list_empty(&priv->free_frames)) { |
808 | element = priv->free_frames.next; | 493 | element = priv->free_frames.next; |
809 | list_del(element); | 494 | list_del(element); |
810 | kfree(list_entry(element, struct iwl4965_frame, list)); | 495 | kfree(list_entry(element, struct iwl_frame, list)); |
811 | priv->frames_count--; | 496 | priv->frames_count--; |
812 | } | 497 | } |
813 | 498 | ||
@@ -818,9 +503,9 @@ static void iwl4965_clear_free_frames(struct iwl_priv *priv) | |||
818 | } | 503 | } |
819 | } | 504 | } |
820 | 505 | ||
821 | static struct iwl4965_frame *iwl4965_get_free_frame(struct iwl_priv *priv) | 506 | static struct iwl_frame *iwl_get_free_frame(struct iwl_priv *priv) |
822 | { | 507 | { |
823 | struct iwl4965_frame *frame; | 508 | struct iwl_frame *frame; |
824 | struct list_head *element; | 509 | struct list_head *element; |
825 | if (list_empty(&priv->free_frames)) { | 510 | if (list_empty(&priv->free_frames)) { |
826 | frame = kzalloc(sizeof(*frame), GFP_KERNEL); | 511 | frame = kzalloc(sizeof(*frame), GFP_KERNEL); |
@@ -835,10 +520,10 @@ static struct iwl4965_frame *iwl4965_get_free_frame(struct iwl_priv *priv) | |||
835 | 520 | ||
836 | element = priv->free_frames.next; | 521 | element = priv->free_frames.next; |
837 | list_del(element); | 522 | list_del(element); |
838 | return list_entry(element, struct iwl4965_frame, list); | 523 | return list_entry(element, struct iwl_frame, list); |
839 | } | 524 | } |
840 | 525 | ||
841 | static void iwl4965_free_frame(struct iwl_priv *priv, struct iwl4965_frame *frame) | 526 | static void iwl_free_frame(struct iwl_priv *priv, struct iwl_frame *frame) |
842 | { | 527 | { |
843 | memset(frame, 0, sizeof(*frame)); | 528 | memset(frame, 0, sizeof(*frame)); |
844 | list_add(&frame->list, &priv->free_frames); | 529 | list_add(&frame->list, &priv->free_frames); |
@@ -875,9 +560,9 @@ static u8 iwl4965_rate_get_lowest_plcp(struct iwl_priv *priv) | |||
875 | 560 | ||
876 | /* Find lowest valid rate */ | 561 | /* Find lowest valid rate */ |
877 | for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID; | 562 | for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID; |
878 | i = iwl4965_rates[i].next_ieee) { | 563 | i = iwl_rates[i].next_ieee) { |
879 | if (rate_mask & (1 << i)) | 564 | if (rate_mask & (1 << i)) |
880 | return iwl4965_rates[i].plcp; | 565 | return iwl_rates[i].plcp; |
881 | } | 566 | } |
882 | 567 | ||
883 | /* No valid rate was found. Assign the lowest one */ | 568 | /* No valid rate was found. Assign the lowest one */ |
@@ -889,12 +574,12 @@ static u8 iwl4965_rate_get_lowest_plcp(struct iwl_priv *priv) | |||
889 | 574 | ||
890 | static int iwl4965_send_beacon_cmd(struct iwl_priv *priv) | 575 | static int iwl4965_send_beacon_cmd(struct iwl_priv *priv) |
891 | { | 576 | { |
892 | struct iwl4965_frame *frame; | 577 | struct iwl_frame *frame; |
893 | unsigned int frame_size; | 578 | unsigned int frame_size; |
894 | int rc; | 579 | int rc; |
895 | u8 rate; | 580 | u8 rate; |
896 | 581 | ||
897 | frame = iwl4965_get_free_frame(priv); | 582 | frame = iwl_get_free_frame(priv); |
898 | 583 | ||
899 | if (!frame) { | 584 | if (!frame) { |
900 | IWL_ERROR("Could not obtain free frame buffer for beacon " | 585 | IWL_ERROR("Could not obtain free frame buffer for beacon " |
@@ -909,7 +594,7 @@ static int iwl4965_send_beacon_cmd(struct iwl_priv *priv) | |||
909 | rc = iwl_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, | 594 | rc = iwl_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, |
910 | &frame->u.cmd[0]); | 595 | &frame->u.cmd[0]); |
911 | 596 | ||
912 | iwl4965_free_frame(priv, frame); | 597 | iwl_free_frame(priv, frame); |
913 | 598 | ||
914 | return rc; | 599 | return rc; |
915 | } | 600 | } |
@@ -936,7 +621,7 @@ static u16 iwl4965_supported_rate_to_ie(u8 *ie, u16 supported_rate, | |||
936 | for (bit = 1, i = 0; i < IWL_RATE_COUNT; i++, bit <<= 1) { | 621 | for (bit = 1, i = 0; i < IWL_RATE_COUNT; i++, bit <<= 1) { |
937 | if (bit & supported_rate) { | 622 | if (bit & supported_rate) { |
938 | ret_rates |= bit; | 623 | ret_rates |= bit; |
939 | rates[*cnt] = iwl4965_rates[i].ieee | | 624 | rates[*cnt] = iwl_rates[i].ieee | |
940 | ((bit & basic_rate) ? 0x80 : 0x00); | 625 | ((bit & basic_rate) ? 0x80 : 0x00); |
941 | (*cnt)++; | 626 | (*cnt)++; |
942 | (*left)--; | 627 | (*left)--; |
@@ -967,9 +652,9 @@ static void iwl4965_ht_conf(struct iwl_priv *priv, | |||
967 | priv->ps_mode = (u8)((ht_conf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2); | 652 | priv->ps_mode = (u8)((ht_conf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2); |
968 | 653 | ||
969 | if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20) | 654 | if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20) |
970 | iwl_conf->sgf |= 0x1; | 655 | iwl_conf->sgf |= HT_SHORT_GI_20MHZ; |
971 | if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40) | 656 | if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40) |
972 | iwl_conf->sgf |= 0x2; | 657 | iwl_conf->sgf |= HT_SHORT_GI_40MHZ; |
973 | 658 | ||
974 | iwl_conf->is_green_field = !!(ht_conf->cap & IEEE80211_HT_CAP_GRN_FLD); | 659 | iwl_conf->is_green_field = !!(ht_conf->cap & IEEE80211_HT_CAP_GRN_FLD); |
975 | iwl_conf->max_amsdu_size = | 660 | iwl_conf->max_amsdu_size = |
@@ -1056,9 +741,9 @@ static u16 iwl4965_fill_probe_req(struct iwl_priv *priv, | |||
1056 | len += 24; | 741 | len += 24; |
1057 | 742 | ||
1058 | frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); | 743 | frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); |
1059 | memcpy(frame->da, iwl4965_broadcast_addr, ETH_ALEN); | 744 | memcpy(frame->da, iwl_bcast_addr, ETH_ALEN); |
1060 | memcpy(frame->sa, priv->mac_addr, ETH_ALEN); | 745 | memcpy(frame->sa, priv->mac_addr, ETH_ALEN); |
1061 | memcpy(frame->bssid, iwl4965_broadcast_addr, ETH_ALEN); | 746 | memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN); |
1062 | frame->seq_ctrl = 0; | 747 | frame->seq_ctrl = 0; |
1063 | 748 | ||
1064 | /* fill in our indirect SSID IE */ | 749 | /* fill in our indirect SSID IE */ |
@@ -1224,33 +909,7 @@ int iwl4965_is_network_packet(struct iwl_priv *priv, struct ieee80211_hdr *heade | |||
1224 | return 1; | 909 | return 1; |
1225 | } | 910 | } |
1226 | 911 | ||
1227 | #define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x | ||
1228 | |||
1229 | static const char *iwl4965_get_tx_fail_reason(u32 status) | ||
1230 | { | ||
1231 | switch (status & TX_STATUS_MSK) { | ||
1232 | case TX_STATUS_SUCCESS: | ||
1233 | return "SUCCESS"; | ||
1234 | TX_STATUS_ENTRY(SHORT_LIMIT); | ||
1235 | TX_STATUS_ENTRY(LONG_LIMIT); | ||
1236 | TX_STATUS_ENTRY(FIFO_UNDERRUN); | ||
1237 | TX_STATUS_ENTRY(MGMNT_ABORT); | ||
1238 | TX_STATUS_ENTRY(NEXT_FRAG); | ||
1239 | TX_STATUS_ENTRY(LIFE_EXPIRE); | ||
1240 | TX_STATUS_ENTRY(DEST_PS); | ||
1241 | TX_STATUS_ENTRY(ABORTED); | ||
1242 | TX_STATUS_ENTRY(BT_RETRY); | ||
1243 | TX_STATUS_ENTRY(STA_INVALID); | ||
1244 | TX_STATUS_ENTRY(FRAG_DROPPED); | ||
1245 | TX_STATUS_ENTRY(TID_DISABLE); | ||
1246 | TX_STATUS_ENTRY(FRAME_FLUSHED); | ||
1247 | TX_STATUS_ENTRY(INSUFFICIENT_CF_POLL); | ||
1248 | TX_STATUS_ENTRY(TX_LOCKED); | ||
1249 | TX_STATUS_ENTRY(NO_BEACON_ON_RADAR); | ||
1250 | } | ||
1251 | 912 | ||
1252 | return "UNKNOWN"; | ||
1253 | } | ||
1254 | 913 | ||
1255 | /** | 914 | /** |
1256 | * iwl4965_scan_cancel - Cancel any currently executing HW scan | 915 | * iwl4965_scan_cancel - Cancel any currently executing HW scan |
@@ -1425,8 +1084,8 @@ static int iwl4965_scan_initiate(struct iwl_priv *priv) | |||
1425 | } | 1084 | } |
1426 | 1085 | ||
1427 | 1086 | ||
1428 | static void iwl4965_set_flags_for_phymode(struct iwl_priv *priv, | 1087 | static void iwl_set_flags_for_band(struct iwl_priv *priv, |
1429 | enum ieee80211_band band) | 1088 | enum ieee80211_band band) |
1430 | { | 1089 | { |
1431 | if (band == IEEE80211_BAND_5GHZ) { | 1090 | if (band == IEEE80211_BAND_5GHZ) { |
1432 | priv->staging_rxon.flags &= | 1091 | priv->staging_rxon.flags &= |
@@ -1511,7 +1170,7 @@ static void iwl4965_connection_init_rx_config(struct iwl_priv *priv) | |||
1511 | priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); | 1170 | priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); |
1512 | priv->band = ch_info->band; | 1171 | priv->band = ch_info->band; |
1513 | 1172 | ||
1514 | iwl4965_set_flags_for_phymode(priv, priv->band); | 1173 | iwl_set_flags_for_band(priv, priv->band); |
1515 | 1174 | ||
1516 | priv->staging_rxon.ofdm_basic_rates = | 1175 | priv->staging_rxon.ofdm_basic_rates = |
1517 | (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; | 1176 | (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; |
@@ -1566,441 +1225,6 @@ static int iwl4965_set_mode(struct iwl_priv *priv, int mode) | |||
1566 | return 0; | 1225 | return 0; |
1567 | } | 1226 | } |
1568 | 1227 | ||
1569 | static void iwl4965_build_tx_cmd_hwcrypto(struct iwl_priv *priv, | ||
1570 | struct ieee80211_tx_control *ctl, | ||
1571 | struct iwl_cmd *cmd, | ||
1572 | struct sk_buff *skb_frag, | ||
1573 | int sta_id) | ||
1574 | { | ||
1575 | struct iwl_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; | ||
1576 | struct iwl_wep_key *wepkey; | ||
1577 | int keyidx = 0; | ||
1578 | |||
1579 | BUG_ON(ctl->hw_key->hw_key_idx > 3); | ||
1580 | |||
1581 | switch (keyinfo->alg) { | ||
1582 | case ALG_CCMP: | ||
1583 | cmd->cmd.tx.sec_ctl = TX_CMD_SEC_CCM; | ||
1584 | memcpy(cmd->cmd.tx.key, keyinfo->key, keyinfo->keylen); | ||
1585 | if (ctl->flags & IEEE80211_TXCTL_AMPDU) | ||
1586 | cmd->cmd.tx.tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; | ||
1587 | IWL_DEBUG_TX("tx_cmd with aes hwcrypto\n"); | ||
1588 | break; | ||
1589 | |||
1590 | case ALG_TKIP: | ||
1591 | cmd->cmd.tx.sec_ctl = TX_CMD_SEC_TKIP; | ||
1592 | ieee80211_get_tkip_key(keyinfo->conf, skb_frag, | ||
1593 | IEEE80211_TKIP_P2_KEY, cmd->cmd.tx.key); | ||
1594 | IWL_DEBUG_TX("tx_cmd with tkip hwcrypto\n"); | ||
1595 | break; | ||
1596 | |||
1597 | case ALG_WEP: | ||
1598 | wepkey = &priv->wep_keys[ctl->hw_key->hw_key_idx]; | ||
1599 | cmd->cmd.tx.sec_ctl = 0; | ||
1600 | if (priv->default_wep_key) { | ||
1601 | /* the WEP key was sent as static */ | ||
1602 | keyidx = ctl->hw_key->hw_key_idx; | ||
1603 | memcpy(&cmd->cmd.tx.key[3], wepkey->key, | ||
1604 | wepkey->key_size); | ||
1605 | if (wepkey->key_size == WEP_KEY_LEN_128) | ||
1606 | cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128; | ||
1607 | } else { | ||
1608 | /* the WEP key was sent as dynamic */ | ||
1609 | keyidx = keyinfo->keyidx; | ||
1610 | memcpy(&cmd->cmd.tx.key[3], keyinfo->key, | ||
1611 | keyinfo->keylen); | ||
1612 | if (keyinfo->keylen == WEP_KEY_LEN_128) | ||
1613 | cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128; | ||
1614 | } | ||
1615 | |||
1616 | cmd->cmd.tx.sec_ctl |= (TX_CMD_SEC_WEP | | ||
1617 | (keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT); | ||
1618 | |||
1619 | IWL_DEBUG_TX("Configuring packet for WEP encryption " | ||
1620 | "with key %d\n", keyidx); | ||
1621 | break; | ||
1622 | |||
1623 | default: | ||
1624 | printk(KERN_ERR "Unknown encode alg %d\n", keyinfo->alg); | ||
1625 | break; | ||
1626 | } | ||
1627 | } | ||
1628 | |||
1629 | /* | ||
1630 | * handle build REPLY_TX command notification. | ||
1631 | */ | ||
1632 | static void iwl4965_build_tx_cmd_basic(struct iwl_priv *priv, | ||
1633 | struct iwl_cmd *cmd, | ||
1634 | struct ieee80211_tx_control *ctrl, | ||
1635 | struct ieee80211_hdr *hdr, | ||
1636 | int is_unicast, u8 std_id) | ||
1637 | { | ||
1638 | __le16 *qc; | ||
1639 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
1640 | __le32 tx_flags = cmd->cmd.tx.tx_flags; | ||
1641 | |||
1642 | cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; | ||
1643 | if (!(ctrl->flags & IEEE80211_TXCTL_NO_ACK)) { | ||
1644 | tx_flags |= TX_CMD_FLG_ACK_MSK; | ||
1645 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) | ||
1646 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | ||
1647 | if (ieee80211_is_probe_response(fc) && | ||
1648 | !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) | ||
1649 | tx_flags |= TX_CMD_FLG_TSF_MSK; | ||
1650 | } else { | ||
1651 | tx_flags &= (~TX_CMD_FLG_ACK_MSK); | ||
1652 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | ||
1653 | } | ||
1654 | |||
1655 | if (ieee80211_is_back_request(fc)) | ||
1656 | tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; | ||
1657 | |||
1658 | |||
1659 | cmd->cmd.tx.sta_id = std_id; | ||
1660 | if (ieee80211_get_morefrag(hdr)) | ||
1661 | tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; | ||
1662 | |||
1663 | qc = ieee80211_get_qos_ctrl(hdr); | ||
1664 | if (qc) { | ||
1665 | cmd->cmd.tx.tid_tspec = (u8) (le16_to_cpu(*qc) & 0xf); | ||
1666 | tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; | ||
1667 | } else | ||
1668 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | ||
1669 | |||
1670 | if (ctrl->flags & IEEE80211_TXCTL_USE_RTS_CTS) { | ||
1671 | tx_flags |= TX_CMD_FLG_RTS_MSK; | ||
1672 | tx_flags &= ~TX_CMD_FLG_CTS_MSK; | ||
1673 | } else if (ctrl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) { | ||
1674 | tx_flags &= ~TX_CMD_FLG_RTS_MSK; | ||
1675 | tx_flags |= TX_CMD_FLG_CTS_MSK; | ||
1676 | } | ||
1677 | |||
1678 | if ((tx_flags & TX_CMD_FLG_RTS_MSK) || (tx_flags & TX_CMD_FLG_CTS_MSK)) | ||
1679 | tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; | ||
1680 | |||
1681 | tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); | ||
1682 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { | ||
1683 | if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ || | ||
1684 | (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ) | ||
1685 | cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3); | ||
1686 | else | ||
1687 | cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2); | ||
1688 | } else { | ||
1689 | cmd->cmd.tx.timeout.pm_frame_timeout = 0; | ||
1690 | } | ||
1691 | |||
1692 | cmd->cmd.tx.driver_txop = 0; | ||
1693 | cmd->cmd.tx.tx_flags = tx_flags; | ||
1694 | cmd->cmd.tx.next_frame_len = 0; | ||
1695 | } | ||
1696 | static void iwl_update_tx_stats(struct iwl_priv *priv, u16 fc, u16 len) | ||
1697 | { | ||
1698 | /* 0 - mgmt, 1 - cnt, 2 - data */ | ||
1699 | int idx = (fc & IEEE80211_FCTL_FTYPE) >> 2; | ||
1700 | priv->tx_stats[idx].cnt++; | ||
1701 | priv->tx_stats[idx].bytes += len; | ||
1702 | } | ||
1703 | /** | ||
1704 | * iwl4965_get_sta_id - Find station's index within station table | ||
1705 | * | ||
1706 | * If new IBSS station, create new entry in station table | ||
1707 | */ | ||
1708 | static int iwl4965_get_sta_id(struct iwl_priv *priv, | ||
1709 | struct ieee80211_hdr *hdr) | ||
1710 | { | ||
1711 | int sta_id; | ||
1712 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
1713 | DECLARE_MAC_BUF(mac); | ||
1714 | |||
1715 | /* If this frame is broadcast or management, use broadcast station id */ | ||
1716 | if (((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) || | ||
1717 | is_multicast_ether_addr(hdr->addr1)) | ||
1718 | return priv->hw_params.bcast_sta_id; | ||
1719 | |||
1720 | switch (priv->iw_mode) { | ||
1721 | |||
1722 | /* If we are a client station in a BSS network, use the special | ||
1723 | * AP station entry (that's the only station we communicate with) */ | ||
1724 | case IEEE80211_IF_TYPE_STA: | ||
1725 | return IWL_AP_ID; | ||
1726 | |||
1727 | /* If we are an AP, then find the station, or use BCAST */ | ||
1728 | case IEEE80211_IF_TYPE_AP: | ||
1729 | sta_id = iwl_find_station(priv, hdr->addr1); | ||
1730 | if (sta_id != IWL_INVALID_STATION) | ||
1731 | return sta_id; | ||
1732 | return priv->hw_params.bcast_sta_id; | ||
1733 | |||
1734 | /* If this frame is going out to an IBSS network, find the station, | ||
1735 | * or create a new station table entry */ | ||
1736 | case IEEE80211_IF_TYPE_IBSS: | ||
1737 | sta_id = iwl_find_station(priv, hdr->addr1); | ||
1738 | if (sta_id != IWL_INVALID_STATION) | ||
1739 | return sta_id; | ||
1740 | |||
1741 | /* Create new station table entry */ | ||
1742 | sta_id = iwl4965_add_station_flags(priv, hdr->addr1, | ||
1743 | 0, CMD_ASYNC, NULL); | ||
1744 | |||
1745 | if (sta_id != IWL_INVALID_STATION) | ||
1746 | return sta_id; | ||
1747 | |||
1748 | IWL_DEBUG_DROP("Station %s not in station map. " | ||
1749 | "Defaulting to broadcast...\n", | ||
1750 | print_mac(mac, hdr->addr1)); | ||
1751 | iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); | ||
1752 | return priv->hw_params.bcast_sta_id; | ||
1753 | |||
1754 | default: | ||
1755 | IWL_WARNING("Unknown mode of operation: %d", priv->iw_mode); | ||
1756 | return priv->hw_params.bcast_sta_id; | ||
1757 | } | ||
1758 | } | ||
1759 | |||
1760 | /* | ||
1761 | * start REPLY_TX command process | ||
1762 | */ | ||
1763 | static int iwl4965_tx_skb(struct iwl_priv *priv, | ||
1764 | struct sk_buff *skb, struct ieee80211_tx_control *ctl) | ||
1765 | { | ||
1766 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
1767 | struct iwl_tfd_frame *tfd; | ||
1768 | u32 *control_flags; | ||
1769 | int txq_id = ctl->queue; | ||
1770 | struct iwl_tx_queue *txq = NULL; | ||
1771 | struct iwl4965_queue *q = NULL; | ||
1772 | dma_addr_t phys_addr; | ||
1773 | dma_addr_t txcmd_phys; | ||
1774 | dma_addr_t scratch_phys; | ||
1775 | struct iwl_cmd *out_cmd = NULL; | ||
1776 | u16 len, idx, len_org; | ||
1777 | u8 id, hdr_len, unicast; | ||
1778 | u8 sta_id; | ||
1779 | u16 seq_number = 0; | ||
1780 | u16 fc; | ||
1781 | __le16 *qc; | ||
1782 | u8 wait_write_ptr = 0; | ||
1783 | unsigned long flags; | ||
1784 | int rc; | ||
1785 | |||
1786 | spin_lock_irqsave(&priv->lock, flags); | ||
1787 | if (iwl_is_rfkill(priv)) { | ||
1788 | IWL_DEBUG_DROP("Dropping - RF KILL\n"); | ||
1789 | goto drop_unlock; | ||
1790 | } | ||
1791 | |||
1792 | if (!priv->vif) { | ||
1793 | IWL_DEBUG_DROP("Dropping - !priv->vif\n"); | ||
1794 | goto drop_unlock; | ||
1795 | } | ||
1796 | |||
1797 | if ((ctl->tx_rate->hw_value & 0xFF) == IWL_INVALID_RATE) { | ||
1798 | IWL_ERROR("ERROR: No TX rate available.\n"); | ||
1799 | goto drop_unlock; | ||
1800 | } | ||
1801 | |||
1802 | unicast = !is_multicast_ether_addr(hdr->addr1); | ||
1803 | id = 0; | ||
1804 | |||
1805 | fc = le16_to_cpu(hdr->frame_control); | ||
1806 | |||
1807 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
1808 | if (ieee80211_is_auth(fc)) | ||
1809 | IWL_DEBUG_TX("Sending AUTH frame\n"); | ||
1810 | else if (ieee80211_is_assoc_request(fc)) | ||
1811 | IWL_DEBUG_TX("Sending ASSOC frame\n"); | ||
1812 | else if (ieee80211_is_reassoc_request(fc)) | ||
1813 | IWL_DEBUG_TX("Sending REASSOC frame\n"); | ||
1814 | #endif | ||
1815 | |||
1816 | /* drop all data frame if we are not associated */ | ||
1817 | if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && | ||
1818 | (!iwl_is_associated(priv) || | ||
1819 | ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id) || | ||
1820 | !priv->assoc_station_added)) { | ||
1821 | IWL_DEBUG_DROP("Dropping - !iwl_is_associated\n"); | ||
1822 | goto drop_unlock; | ||
1823 | } | ||
1824 | |||
1825 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1826 | |||
1827 | hdr_len = ieee80211_get_hdrlen(fc); | ||
1828 | |||
1829 | /* Find (or create) index into station table for destination station */ | ||
1830 | sta_id = iwl4965_get_sta_id(priv, hdr); | ||
1831 | if (sta_id == IWL_INVALID_STATION) { | ||
1832 | DECLARE_MAC_BUF(mac); | ||
1833 | |||
1834 | IWL_DEBUG_DROP("Dropping - INVALID STATION: %s\n", | ||
1835 | print_mac(mac, hdr->addr1)); | ||
1836 | goto drop; | ||
1837 | } | ||
1838 | |||
1839 | IWL_DEBUG_TX("station Id %d\n", sta_id); | ||
1840 | |||
1841 | qc = ieee80211_get_qos_ctrl(hdr); | ||
1842 | if (qc) { | ||
1843 | u8 tid = (u8)(le16_to_cpu(*qc) & 0xf); | ||
1844 | seq_number = priv->stations[sta_id].tid[tid].seq_number & | ||
1845 | IEEE80211_SCTL_SEQ; | ||
1846 | hdr->seq_ctrl = cpu_to_le16(seq_number) | | ||
1847 | (hdr->seq_ctrl & | ||
1848 | __constant_cpu_to_le16(IEEE80211_SCTL_FRAG)); | ||
1849 | seq_number += 0x10; | ||
1850 | #ifdef CONFIG_IWL4965_HT | ||
1851 | /* aggregation is on for this <sta,tid> */ | ||
1852 | if (ctl->flags & IEEE80211_TXCTL_AMPDU) | ||
1853 | txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; | ||
1854 | priv->stations[sta_id].tid[tid].tfds_in_queue++; | ||
1855 | #endif /* CONFIG_IWL4965_HT */ | ||
1856 | } | ||
1857 | |||
1858 | /* Descriptor for chosen Tx queue */ | ||
1859 | txq = &priv->txq[txq_id]; | ||
1860 | q = &txq->q; | ||
1861 | |||
1862 | spin_lock_irqsave(&priv->lock, flags); | ||
1863 | |||
1864 | /* Set up first empty TFD within this queue's circular TFD buffer */ | ||
1865 | tfd = &txq->bd[q->write_ptr]; | ||
1866 | memset(tfd, 0, sizeof(*tfd)); | ||
1867 | control_flags = (u32 *) tfd; | ||
1868 | idx = get_cmd_index(q, q->write_ptr, 0); | ||
1869 | |||
1870 | /* Set up driver data for this TFD */ | ||
1871 | memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl4965_tx_info)); | ||
1872 | txq->txb[q->write_ptr].skb[0] = skb; | ||
1873 | memcpy(&(txq->txb[q->write_ptr].status.control), | ||
1874 | ctl, sizeof(struct ieee80211_tx_control)); | ||
1875 | |||
1876 | /* Set up first empty entry in queue's array of Tx/cmd buffers */ | ||
1877 | out_cmd = &txq->cmd[idx]; | ||
1878 | memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); | ||
1879 | memset(&out_cmd->cmd.tx, 0, sizeof(out_cmd->cmd.tx)); | ||
1880 | |||
1881 | /* | ||
1882 | * Set up the Tx-command (not MAC!) header. | ||
1883 | * Store the chosen Tx queue and TFD index within the sequence field; | ||
1884 | * after Tx, uCode's Tx response will return this value so driver can | ||
1885 | * locate the frame within the tx queue and do post-tx processing. | ||
1886 | */ | ||
1887 | out_cmd->hdr.cmd = REPLY_TX; | ||
1888 | out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | | ||
1889 | INDEX_TO_SEQ(q->write_ptr))); | ||
1890 | |||
1891 | /* Copy MAC header from skb into command buffer */ | ||
1892 | memcpy(out_cmd->cmd.tx.hdr, hdr, hdr_len); | ||
1893 | |||
1894 | /* | ||
1895 | * Use the first empty entry in this queue's command buffer array | ||
1896 | * to contain the Tx command and MAC header concatenated together | ||
1897 | * (payload data will be in another buffer). | ||
1898 | * Size of this varies, due to varying MAC header length. | ||
1899 | * If end is not dword aligned, we'll have 2 extra bytes at the end | ||
1900 | * of the MAC header (device reads on dword boundaries). | ||
1901 | * We'll tell device about this padding later. | ||
1902 | */ | ||
1903 | len = priv->hw_params.tx_cmd_len + | ||
1904 | sizeof(struct iwl_cmd_header) + hdr_len; | ||
1905 | |||
1906 | len_org = len; | ||
1907 | len = (len + 3) & ~3; | ||
1908 | |||
1909 | if (len_org != len) | ||
1910 | len_org = 1; | ||
1911 | else | ||
1912 | len_org = 0; | ||
1913 | |||
1914 | /* Physical address of this Tx command's header (not MAC header!), | ||
1915 | * within command buffer array. */ | ||
1916 | txcmd_phys = txq->dma_addr_cmd + sizeof(struct iwl_cmd) * idx + | ||
1917 | offsetof(struct iwl_cmd, hdr); | ||
1918 | |||
1919 | /* Add buffer containing Tx command and MAC(!) header to TFD's | ||
1920 | * first entry */ | ||
1921 | iwl4965_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len); | ||
1922 | |||
1923 | if (!(ctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) | ||
1924 | iwl4965_build_tx_cmd_hwcrypto(priv, ctl, out_cmd, skb, sta_id); | ||
1925 | |||
1926 | /* Set up TFD's 2nd entry to point directly to remainder of skb, | ||
1927 | * if any (802.11 null frames have no payload). */ | ||
1928 | len = skb->len - hdr_len; | ||
1929 | if (len) { | ||
1930 | phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len, | ||
1931 | len, PCI_DMA_TODEVICE); | ||
1932 | iwl4965_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, len); | ||
1933 | } | ||
1934 | |||
1935 | /* Tell 4965 about any 2-byte padding after MAC header */ | ||
1936 | if (len_org) | ||
1937 | out_cmd->cmd.tx.tx_flags |= TX_CMD_FLG_MH_PAD_MSK; | ||
1938 | |||
1939 | /* Total # bytes to be transmitted */ | ||
1940 | len = (u16)skb->len; | ||
1941 | out_cmd->cmd.tx.len = cpu_to_le16(len); | ||
1942 | |||
1943 | /* TODO need this for burst mode later on */ | ||
1944 | iwl4965_build_tx_cmd_basic(priv, out_cmd, ctl, hdr, unicast, sta_id); | ||
1945 | |||
1946 | /* set is_hcca to 0; it probably will never be implemented */ | ||
1947 | iwl4965_hw_build_tx_cmd_rate(priv, out_cmd, ctl, hdr, sta_id, 0); | ||
1948 | |||
1949 | iwl_update_tx_stats(priv, fc, len); | ||
1950 | |||
1951 | scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) + | ||
1952 | offsetof(struct iwl4965_tx_cmd, scratch); | ||
1953 | out_cmd->cmd.tx.dram_lsb_ptr = cpu_to_le32(scratch_phys); | ||
1954 | out_cmd->cmd.tx.dram_msb_ptr = iwl_get_dma_hi_address(scratch_phys); | ||
1955 | |||
1956 | if (!ieee80211_get_morefrag(hdr)) { | ||
1957 | txq->need_update = 1; | ||
1958 | if (qc) { | ||
1959 | u8 tid = (u8)(le16_to_cpu(*qc) & 0xf); | ||
1960 | priv->stations[sta_id].tid[tid].seq_number = seq_number; | ||
1961 | } | ||
1962 | } else { | ||
1963 | wait_write_ptr = 1; | ||
1964 | txq->need_update = 0; | ||
1965 | } | ||
1966 | |||
1967 | iwl_print_hex_dump(priv, IWL_DL_TX, out_cmd->cmd.payload, | ||
1968 | sizeof(out_cmd->cmd.tx)); | ||
1969 | |||
1970 | iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr, | ||
1971 | ieee80211_get_hdrlen(fc)); | ||
1972 | |||
1973 | /* Set up entry for this TFD in Tx byte-count array */ | ||
1974 | priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, len); | ||
1975 | |||
1976 | /* Tell device the write index *just past* this latest filled TFD */ | ||
1977 | q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); | ||
1978 | rc = iwl4965_tx_queue_update_write_ptr(priv, txq); | ||
1979 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1980 | |||
1981 | if (rc) | ||
1982 | return rc; | ||
1983 | |||
1984 | if ((iwl4965_queue_space(q) < q->high_mark) | ||
1985 | && priv->mac80211_registered) { | ||
1986 | if (wait_write_ptr) { | ||
1987 | spin_lock_irqsave(&priv->lock, flags); | ||
1988 | txq->need_update = 1; | ||
1989 | iwl4965_tx_queue_update_write_ptr(priv, txq); | ||
1990 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1991 | } | ||
1992 | |||
1993 | ieee80211_stop_queue(priv->hw, ctl->queue); | ||
1994 | } | ||
1995 | |||
1996 | return 0; | ||
1997 | |||
1998 | drop_unlock: | ||
1999 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2000 | drop: | ||
2001 | return -1; | ||
2002 | } | ||
2003 | |||
2004 | static void iwl4965_set_rate(struct iwl_priv *priv) | 1228 | static void iwl4965_set_rate(struct iwl_priv *priv) |
2005 | { | 1229 | { |
2006 | const struct ieee80211_supported_band *hw = NULL; | 1230 | const struct ieee80211_supported_band *hw = NULL; |
@@ -2305,341 +1529,16 @@ static int iwl4965_get_measurement(struct iwl_priv *priv, | |||
2305 | } | 1529 | } |
2306 | #endif | 1530 | #endif |
2307 | 1531 | ||
2308 | static void iwl4965_txstatus_to_ieee(struct iwl_priv *priv, | ||
2309 | struct iwl4965_tx_info *tx_sta) | ||
2310 | { | ||
2311 | |||
2312 | tx_sta->status.ack_signal = 0; | ||
2313 | tx_sta->status.excessive_retries = 0; | ||
2314 | |||
2315 | if (in_interrupt()) | ||
2316 | ieee80211_tx_status_irqsafe(priv->hw, | ||
2317 | tx_sta->skb[0], &(tx_sta->status)); | ||
2318 | else | ||
2319 | ieee80211_tx_status(priv->hw, | ||
2320 | tx_sta->skb[0], &(tx_sta->status)); | ||
2321 | |||
2322 | tx_sta->skb[0] = NULL; | ||
2323 | } | ||
2324 | |||
2325 | /** | ||
2326 | * iwl4965_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd | ||
2327 | * | ||
2328 | * When FW advances 'R' index, all entries between old and new 'R' index | ||
2329 | * need to be reclaimed. As result, some free space forms. If there is | ||
2330 | * enough free space (> low mark), wake the stack that feeds us. | ||
2331 | */ | ||
2332 | int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | ||
2333 | { | ||
2334 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; | ||
2335 | struct iwl4965_queue *q = &txq->q; | ||
2336 | int nfreed = 0; | ||
2337 | |||
2338 | if ((index >= q->n_bd) || (x2_queue_used(q, index) == 0)) { | ||
2339 | IWL_ERROR("Read index for DMA queue txq id (%d), index %d, " | ||
2340 | "is out of range [0-%d] %d %d.\n", txq_id, | ||
2341 | index, q->n_bd, q->write_ptr, q->read_ptr); | ||
2342 | return 0; | ||
2343 | } | ||
2344 | |||
2345 | for (index = iwl_queue_inc_wrap(index, q->n_bd); | ||
2346 | q->read_ptr != index; | ||
2347 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { | ||
2348 | if (txq_id != IWL_CMD_QUEUE_NUM) { | ||
2349 | iwl4965_txstatus_to_ieee(priv, | ||
2350 | &(txq->txb[txq->q.read_ptr])); | ||
2351 | iwl_hw_txq_free_tfd(priv, txq); | ||
2352 | } else if (nfreed > 1) { | ||
2353 | IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index, | ||
2354 | q->write_ptr, q->read_ptr); | ||
2355 | queue_work(priv->workqueue, &priv->restart); | ||
2356 | } | ||
2357 | nfreed++; | ||
2358 | } | ||
2359 | |||
2360 | return nfreed; | ||
2361 | } | ||
2362 | |||
2363 | static int iwl4965_is_tx_success(u32 status) | ||
2364 | { | ||
2365 | status &= TX_STATUS_MSK; | ||
2366 | return (status == TX_STATUS_SUCCESS) | ||
2367 | || (status == TX_STATUS_DIRECT_DONE); | ||
2368 | } | ||
2369 | |||
2370 | /****************************************************************************** | 1532 | /****************************************************************************** |
2371 | * | 1533 | * |
2372 | * Generic RX handler implementations | 1534 | * Generic RX handler implementations |
2373 | * | 1535 | * |
2374 | ******************************************************************************/ | 1536 | ******************************************************************************/ |
2375 | #ifdef CONFIG_IWL4965_HT | 1537 | static void iwl_rx_reply_alive(struct iwl_priv *priv, |
2376 | |||
2377 | static inline int iwl4965_get_ra_sta_id(struct iwl_priv *priv, | ||
2378 | struct ieee80211_hdr *hdr) | ||
2379 | { | ||
2380 | if (priv->iw_mode == IEEE80211_IF_TYPE_STA) | ||
2381 | return IWL_AP_ID; | ||
2382 | else { | ||
2383 | u8 *da = ieee80211_get_DA(hdr); | ||
2384 | return iwl_find_station(priv, da); | ||
2385 | } | ||
2386 | } | ||
2387 | |||
2388 | static struct ieee80211_hdr *iwl4965_tx_queue_get_hdr( | ||
2389 | struct iwl_priv *priv, int txq_id, int idx) | ||
2390 | { | ||
2391 | if (priv->txq[txq_id].txb[idx].skb[0]) | ||
2392 | return (struct ieee80211_hdr *)priv->txq[txq_id]. | ||
2393 | txb[idx].skb[0]->data; | ||
2394 | return NULL; | ||
2395 | } | ||
2396 | |||
2397 | static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp) | ||
2398 | { | ||
2399 | __le32 *scd_ssn = (__le32 *)((u32 *)&tx_resp->status + | ||
2400 | tx_resp->frame_count); | ||
2401 | return le32_to_cpu(*scd_ssn) & MAX_SN; | ||
2402 | |||
2403 | } | ||
2404 | |||
2405 | /** | ||
2406 | * iwl4965_tx_status_reply_tx - Handle Tx rspnse for frames in aggregation queue | ||
2407 | */ | ||
2408 | static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, | ||
2409 | struct iwl_ht_agg *agg, | ||
2410 | struct iwl4965_tx_resp_agg *tx_resp, | ||
2411 | u16 start_idx) | ||
2412 | { | ||
2413 | u16 status; | ||
2414 | struct agg_tx_status *frame_status = &tx_resp->status; | ||
2415 | struct ieee80211_tx_status *tx_status = NULL; | ||
2416 | struct ieee80211_hdr *hdr = NULL; | ||
2417 | int i, sh; | ||
2418 | int txq_id, idx; | ||
2419 | u16 seq; | ||
2420 | |||
2421 | if (agg->wait_for_ba) | ||
2422 | IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n"); | ||
2423 | |||
2424 | agg->frame_count = tx_resp->frame_count; | ||
2425 | agg->start_idx = start_idx; | ||
2426 | agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); | ||
2427 | agg->bitmap = 0; | ||
2428 | |||
2429 | /* # frames attempted by Tx command */ | ||
2430 | if (agg->frame_count == 1) { | ||
2431 | /* Only one frame was attempted; no block-ack will arrive */ | ||
2432 | status = le16_to_cpu(frame_status[0].status); | ||
2433 | seq = le16_to_cpu(frame_status[0].sequence); | ||
2434 | idx = SEQ_TO_INDEX(seq); | ||
2435 | txq_id = SEQ_TO_QUEUE(seq); | ||
2436 | |||
2437 | /* FIXME: code repetition */ | ||
2438 | IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", | ||
2439 | agg->frame_count, agg->start_idx, idx); | ||
2440 | |||
2441 | tx_status = &(priv->txq[txq_id].txb[idx].status); | ||
2442 | tx_status->retry_count = tx_resp->failure_frame; | ||
2443 | tx_status->control.flags &= ~IEEE80211_TXCTL_AMPDU; | ||
2444 | tx_status->flags = iwl4965_is_tx_success(status)? | ||
2445 | IEEE80211_TX_STATUS_ACK : 0; | ||
2446 | iwl4965_hwrate_to_tx_control(priv, | ||
2447 | le32_to_cpu(tx_resp->rate_n_flags), | ||
2448 | &tx_status->control); | ||
2449 | /* FIXME: code repetition end */ | ||
2450 | |||
2451 | IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", | ||
2452 | status & 0xff, tx_resp->failure_frame); | ||
2453 | IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", | ||
2454 | iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags)); | ||
2455 | |||
2456 | agg->wait_for_ba = 0; | ||
2457 | } else { | ||
2458 | /* Two or more frames were attempted; expect block-ack */ | ||
2459 | u64 bitmap = 0; | ||
2460 | int start = agg->start_idx; | ||
2461 | |||
2462 | /* Construct bit-map of pending frames within Tx window */ | ||
2463 | for (i = 0; i < agg->frame_count; i++) { | ||
2464 | u16 sc; | ||
2465 | status = le16_to_cpu(frame_status[i].status); | ||
2466 | seq = le16_to_cpu(frame_status[i].sequence); | ||
2467 | idx = SEQ_TO_INDEX(seq); | ||
2468 | txq_id = SEQ_TO_QUEUE(seq); | ||
2469 | |||
2470 | if (status & (AGG_TX_STATE_FEW_BYTES_MSK | | ||
2471 | AGG_TX_STATE_ABORT_MSK)) | ||
2472 | continue; | ||
2473 | |||
2474 | IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", | ||
2475 | agg->frame_count, txq_id, idx); | ||
2476 | |||
2477 | hdr = iwl4965_tx_queue_get_hdr(priv, txq_id, idx); | ||
2478 | |||
2479 | sc = le16_to_cpu(hdr->seq_ctrl); | ||
2480 | if (idx != (SEQ_TO_SN(sc) & 0xff)) { | ||
2481 | IWL_ERROR("BUG_ON idx doesn't match seq control" | ||
2482 | " idx=%d, seq_idx=%d, seq=%d\n", | ||
2483 | idx, SEQ_TO_SN(sc), | ||
2484 | hdr->seq_ctrl); | ||
2485 | return -1; | ||
2486 | } | ||
2487 | |||
2488 | IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", | ||
2489 | i, idx, SEQ_TO_SN(sc)); | ||
2490 | |||
2491 | sh = idx - start; | ||
2492 | if (sh > 64) { | ||
2493 | sh = (start - idx) + 0xff; | ||
2494 | bitmap = bitmap << sh; | ||
2495 | sh = 0; | ||
2496 | start = idx; | ||
2497 | } else if (sh < -64) | ||
2498 | sh = 0xff - (start - idx); | ||
2499 | else if (sh < 0) { | ||
2500 | sh = start - idx; | ||
2501 | start = idx; | ||
2502 | bitmap = bitmap << sh; | ||
2503 | sh = 0; | ||
2504 | } | ||
2505 | bitmap |= (1 << sh); | ||
2506 | IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%x\n", | ||
2507 | start, (u32)(bitmap & 0xFFFFFFFF)); | ||
2508 | } | ||
2509 | |||
2510 | agg->bitmap = bitmap; | ||
2511 | agg->start_idx = start; | ||
2512 | agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); | ||
2513 | IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", | ||
2514 | agg->frame_count, agg->start_idx, | ||
2515 | (unsigned long long)agg->bitmap); | ||
2516 | |||
2517 | if (bitmap) | ||
2518 | agg->wait_for_ba = 1; | ||
2519 | } | ||
2520 | return 0; | ||
2521 | } | ||
2522 | #endif | ||
2523 | |||
2524 | /** | ||
2525 | * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response | ||
2526 | */ | ||
2527 | static void iwl4965_rx_reply_tx(struct iwl_priv *priv, | ||
2528 | struct iwl_rx_mem_buffer *rxb) | 1538 | struct iwl_rx_mem_buffer *rxb) |
2529 | { | 1539 | { |
2530 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | 1540 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2531 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | 1541 | struct iwl_alive_resp *palive; |
2532 | int txq_id = SEQ_TO_QUEUE(sequence); | ||
2533 | int index = SEQ_TO_INDEX(sequence); | ||
2534 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; | ||
2535 | struct ieee80211_tx_status *tx_status; | ||
2536 | struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; | ||
2537 | u32 status = le32_to_cpu(tx_resp->status); | ||
2538 | #ifdef CONFIG_IWL4965_HT | ||
2539 | int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION; | ||
2540 | struct ieee80211_hdr *hdr; | ||
2541 | __le16 *qc; | ||
2542 | #endif | ||
2543 | |||
2544 | if ((index >= txq->q.n_bd) || (x2_queue_used(&txq->q, index) == 0)) { | ||
2545 | IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " | ||
2546 | "is out of range [0-%d] %d %d\n", txq_id, | ||
2547 | index, txq->q.n_bd, txq->q.write_ptr, | ||
2548 | txq->q.read_ptr); | ||
2549 | return; | ||
2550 | } | ||
2551 | |||
2552 | #ifdef CONFIG_IWL4965_HT | ||
2553 | hdr = iwl4965_tx_queue_get_hdr(priv, txq_id, index); | ||
2554 | qc = ieee80211_get_qos_ctrl(hdr); | ||
2555 | |||
2556 | if (qc) | ||
2557 | tid = le16_to_cpu(*qc) & 0xf; | ||
2558 | |||
2559 | sta_id = iwl4965_get_ra_sta_id(priv, hdr); | ||
2560 | if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) { | ||
2561 | IWL_ERROR("Station not known\n"); | ||
2562 | return; | ||
2563 | } | ||
2564 | |||
2565 | if (txq->sched_retry) { | ||
2566 | const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp); | ||
2567 | struct iwl_ht_agg *agg = NULL; | ||
2568 | |||
2569 | if (!qc) | ||
2570 | return; | ||
2571 | |||
2572 | agg = &priv->stations[sta_id].tid[tid].agg; | ||
2573 | |||
2574 | iwl4965_tx_status_reply_tx(priv, agg, | ||
2575 | (struct iwl4965_tx_resp_agg *)tx_resp, index); | ||
2576 | |||
2577 | if ((tx_resp->frame_count == 1) && | ||
2578 | !iwl4965_is_tx_success(status)) { | ||
2579 | /* TODO: send BAR */ | ||
2580 | } | ||
2581 | |||
2582 | if (txq->q.read_ptr != (scd_ssn & 0xff)) { | ||
2583 | int freed, ampdu_q; | ||
2584 | index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); | ||
2585 | IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " | ||
2586 | "%d index %d\n", scd_ssn , index); | ||
2587 | freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); | ||
2588 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; | ||
2589 | |||
2590 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && | ||
2591 | txq_id >= 0 && priv->mac80211_registered && | ||
2592 | agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) { | ||
2593 | /* calculate mac80211 ampdu sw queue to wake */ | ||
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 | } | ||
2601 | iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id); | ||
2602 | } | ||
2603 | } else { | ||
2604 | #endif /* CONFIG_IWL4965_HT */ | ||
2605 | tx_status = &(txq->txb[txq->q.read_ptr].status); | ||
2606 | |||
2607 | tx_status->retry_count = tx_resp->failure_frame; | ||
2608 | tx_status->flags = | ||
2609 | iwl4965_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0; | ||
2610 | iwl4965_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), | ||
2611 | &tx_status->control); | ||
2612 | |||
2613 | IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " | ||
2614 | "retries %d\n", txq_id, iwl4965_get_tx_fail_reason(status), | ||
2615 | status, le32_to_cpu(tx_resp->rate_n_flags), | ||
2616 | tx_resp->failure_frame); | ||
2617 | |||
2618 | IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); | ||
2619 | #ifdef CONFIG_IWL4965_HT | ||
2620 | if (index != -1) { | ||
2621 | int freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); | ||
2622 | if (tid != MAX_TID_COUNT) | ||
2623 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; | ||
2624 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && | ||
2625 | (txq_id >= 0) && priv->mac80211_registered) | ||
2626 | ieee80211_wake_queue(priv->hw, txq_id); | ||
2627 | if (tid != MAX_TID_COUNT) | ||
2628 | iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id); | ||
2629 | } | ||
2630 | } | ||
2631 | #endif /* CONFIG_IWL4965_HT */ | ||
2632 | |||
2633 | if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) | ||
2634 | IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n"); | ||
2635 | } | ||
2636 | |||
2637 | |||
2638 | static void iwl4965_rx_reply_alive(struct iwl_priv *priv, | ||
2639 | struct iwl_rx_mem_buffer *rxb) | ||
2640 | { | ||
2641 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
2642 | struct iwl4965_alive_resp *palive; | ||
2643 | struct delayed_work *pwork; | 1542 | struct delayed_work *pwork; |
2644 | 1543 | ||
2645 | palive = &pkt->u.alive_frame; | 1544 | palive = &pkt->u.alive_frame; |
@@ -2653,12 +1552,12 @@ static void iwl4965_rx_reply_alive(struct iwl_priv *priv, | |||
2653 | IWL_DEBUG_INFO("Initialization Alive received.\n"); | 1552 | IWL_DEBUG_INFO("Initialization Alive received.\n"); |
2654 | memcpy(&priv->card_alive_init, | 1553 | memcpy(&priv->card_alive_init, |
2655 | &pkt->u.alive_frame, | 1554 | &pkt->u.alive_frame, |
2656 | sizeof(struct iwl4965_init_alive_resp)); | 1555 | sizeof(struct iwl_init_alive_resp)); |
2657 | pwork = &priv->init_alive_start; | 1556 | pwork = &priv->init_alive_start; |
2658 | } else { | 1557 | } else { |
2659 | IWL_DEBUG_INFO("Runtime Alive received.\n"); | 1558 | IWL_DEBUG_INFO("Runtime Alive received.\n"); |
2660 | memcpy(&priv->card_alive, &pkt->u.alive_frame, | 1559 | memcpy(&priv->card_alive, &pkt->u.alive_frame, |
2661 | sizeof(struct iwl4965_alive_resp)); | 1560 | sizeof(struct iwl_alive_resp)); |
2662 | pwork = &priv->alive_start; | 1561 | pwork = &priv->alive_start; |
2663 | } | 1562 | } |
2664 | 1563 | ||
@@ -2671,15 +1570,6 @@ static void iwl4965_rx_reply_alive(struct iwl_priv *priv, | |||
2671 | IWL_WARNING("uCode did not respond OK.\n"); | 1570 | IWL_WARNING("uCode did not respond OK.\n"); |
2672 | } | 1571 | } |
2673 | 1572 | ||
2674 | static void iwl4965_rx_reply_add_sta(struct iwl_priv *priv, | ||
2675 | struct iwl_rx_mem_buffer *rxb) | ||
2676 | { | ||
2677 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
2678 | |||
2679 | IWL_DEBUG_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); | ||
2680 | return; | ||
2681 | } | ||
2682 | |||
2683 | static void iwl4965_rx_reply_error(struct iwl_priv *priv, | 1573 | static void iwl4965_rx_reply_error(struct iwl_priv *priv, |
2684 | struct iwl_rx_mem_buffer *rxb) | 1574 | struct iwl_rx_mem_buffer *rxb) |
2685 | { | 1575 | { |
@@ -2699,7 +1589,7 @@ static void iwl4965_rx_reply_error(struct iwl_priv *priv, | |||
2699 | static void iwl4965_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) | 1589 | static void iwl4965_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) |
2700 | { | 1590 | { |
2701 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | 1591 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2702 | struct iwl4965_rxon_cmd *rxon = (void *)&priv->active_rxon; | 1592 | struct iwl_rxon_cmd *rxon = (void *)&priv->active_rxon; |
2703 | struct iwl4965_csa_notification *csa = &(pkt->u.csa_notif); | 1593 | struct iwl4965_csa_notification *csa = &(pkt->u.csa_notif); |
2704 | IWL_DEBUG_11H("CSA notif: channel %d, status %d\n", | 1594 | IWL_DEBUG_11H("CSA notif: channel %d, status %d\n", |
2705 | le16_to_cpu(csa->channel), le32_to_cpu(csa->status)); | 1595 | le16_to_cpu(csa->channel), le32_to_cpu(csa->status)); |
@@ -2753,7 +1643,7 @@ static void iwl4965_bg_beacon_update(struct work_struct *work) | |||
2753 | struct sk_buff *beacon; | 1643 | struct sk_buff *beacon; |
2754 | 1644 | ||
2755 | /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ | 1645 | /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ |
2756 | beacon = ieee80211_beacon_get(priv->hw, priv->vif, NULL); | 1646 | beacon = ieee80211_beacon_get(priv->hw, priv->vif); |
2757 | 1647 | ||
2758 | if (!beacon) { | 1648 | if (!beacon) { |
2759 | IWL_ERROR("update beacon failed\n"); | 1649 | IWL_ERROR("update beacon failed\n"); |
@@ -2976,6 +1866,17 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, | |||
2976 | wake_up_interruptible(&priv->wait_command_queue); | 1866 | wake_up_interruptible(&priv->wait_command_queue); |
2977 | } | 1867 | } |
2978 | 1868 | ||
1869 | /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). | ||
1870 | * This will be used later in iwl4965_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ | ||
1871 | static void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv, | ||
1872 | struct iwl_rx_mem_buffer *rxb) | ||
1873 | { | ||
1874 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
1875 | priv->last_phy_res[0] = 1; | ||
1876 | memcpy(&priv->last_phy_res[1], &(pkt->u.raw[0]), | ||
1877 | sizeof(struct iwl4965_rx_phy_res)); | ||
1878 | } | ||
1879 | |||
2979 | /** | 1880 | /** |
2980 | * iwl4965_setup_rx_handlers - Initialize Rx handler callbacks | 1881 | * iwl4965_setup_rx_handlers - Initialize Rx handler callbacks |
2981 | * | 1882 | * |
@@ -2987,8 +1888,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, | |||
2987 | */ | 1888 | */ |
2988 | static void iwl4965_setup_rx_handlers(struct iwl_priv *priv) | 1889 | static void iwl4965_setup_rx_handlers(struct iwl_priv *priv) |
2989 | { | 1890 | { |
2990 | priv->rx_handlers[REPLY_ALIVE] = iwl4965_rx_reply_alive; | 1891 | priv->rx_handlers[REPLY_ALIVE] = iwl_rx_reply_alive; |
2991 | priv->rx_handlers[REPLY_ADD_STA] = iwl4965_rx_reply_add_sta; | ||
2992 | priv->rx_handlers[REPLY_ERROR] = iwl4965_rx_reply_error; | 1892 | priv->rx_handlers[REPLY_ERROR] = iwl4965_rx_reply_error; |
2993 | priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl4965_rx_csa; | 1893 | priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl4965_rx_csa; |
2994 | priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = | 1894 | priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = |
@@ -3005,66 +1905,25 @@ static void iwl4965_setup_rx_handlers(struct iwl_priv *priv) | |||
3005 | */ | 1905 | */ |
3006 | priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_hw_rx_statistics; | 1906 | priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_hw_rx_statistics; |
3007 | priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_hw_rx_statistics; | 1907 | priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_hw_rx_statistics; |
3008 | 1908 | /* scan handlers */ | |
3009 | priv->rx_handlers[REPLY_SCAN_CMD] = iwl4965_rx_reply_scan; | 1909 | priv->rx_handlers[REPLY_SCAN_CMD] = iwl4965_rx_reply_scan; |
3010 | priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl4965_rx_scan_start_notif; | 1910 | priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl4965_rx_scan_start_notif; |
3011 | priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = | 1911 | priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = |
3012 | iwl4965_rx_scan_results_notif; | 1912 | iwl4965_rx_scan_results_notif; |
3013 | priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = | 1913 | priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = |
3014 | iwl4965_rx_scan_complete_notif; | 1914 | iwl4965_rx_scan_complete_notif; |
1915 | /* status change handler */ | ||
3015 | priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif; | 1916 | priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif; |
3016 | priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx; | ||
3017 | 1917 | ||
1918 | priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] = | ||
1919 | iwl_rx_missed_beacon_notif; | ||
1920 | /* Rx handlers */ | ||
1921 | priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl4965_rx_reply_rx_phy; | ||
1922 | priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwl4965_rx_reply_rx; | ||
3018 | /* Set up hardware specific Rx handlers */ | 1923 | /* Set up hardware specific Rx handlers */ |
3019 | priv->cfg->ops->lib->rx_handler_setup(priv); | 1924 | priv->cfg->ops->lib->rx_handler_setup(priv); |
3020 | } | 1925 | } |
3021 | 1926 | ||
3022 | /** | ||
3023 | * iwl4965_tx_cmd_complete - Pull unused buffers off the queue and reclaim them | ||
3024 | * @rxb: Rx buffer to reclaim | ||
3025 | * | ||
3026 | * If an Rx buffer has an async callback associated with it the callback | ||
3027 | * will be executed. The attached skb (if present) will only be freed | ||
3028 | * if the callback returns 1 | ||
3029 | */ | ||
3030 | static void iwl4965_tx_cmd_complete(struct iwl_priv *priv, | ||
3031 | struct iwl_rx_mem_buffer *rxb) | ||
3032 | { | ||
3033 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
3034 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | ||
3035 | int txq_id = SEQ_TO_QUEUE(sequence); | ||
3036 | int index = SEQ_TO_INDEX(sequence); | ||
3037 | int huge = sequence & SEQ_HUGE_FRAME; | ||
3038 | int cmd_index; | ||
3039 | struct iwl_cmd *cmd; | ||
3040 | |||
3041 | /* If a Tx command is being handled and it isn't in the actual | ||
3042 | * command queue then there a command routing bug has been introduced | ||
3043 | * in the queue management code. */ | ||
3044 | if (txq_id != IWL_CMD_QUEUE_NUM) | ||
3045 | IWL_ERROR("Error wrong command queue %d command id 0x%X\n", | ||
3046 | txq_id, pkt->hdr.cmd); | ||
3047 | BUG_ON(txq_id != IWL_CMD_QUEUE_NUM); | ||
3048 | |||
3049 | cmd_index = get_cmd_index(&priv->txq[IWL_CMD_QUEUE_NUM].q, index, huge); | ||
3050 | cmd = &priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_index]; | ||
3051 | |||
3052 | /* Input error checking is done when commands are added to queue. */ | ||
3053 | if (cmd->meta.flags & CMD_WANT_SKB) { | ||
3054 | cmd->meta.source->u.skb = rxb->skb; | ||
3055 | rxb->skb = NULL; | ||
3056 | } else if (cmd->meta.u.callback && | ||
3057 | !cmd->meta.u.callback(priv, cmd, rxb->skb)) | ||
3058 | rxb->skb = NULL; | ||
3059 | |||
3060 | iwl4965_tx_queue_reclaim(priv, txq_id, index); | ||
3061 | |||
3062 | if (!(cmd->meta.flags & CMD_ASYNC)) { | ||
3063 | clear_bit(STATUS_HCMD_ACTIVE, &priv->status); | ||
3064 | wake_up_interruptible(&priv->wait_command_queue); | ||
3065 | } | ||
3066 | } | ||
3067 | |||
3068 | /* | 1927 | /* |
3069 | * this should be called while priv->lock is locked | 1928 | * this should be called while priv->lock is locked |
3070 | */ | 1929 | */ |
@@ -3153,7 +2012,7 @@ void iwl_rx_handle(struct iwl_priv *priv) | |||
3153 | * fire off the (possibly) blocking iwl_send_cmd() | 2012 | * fire off the (possibly) blocking iwl_send_cmd() |
3154 | * as we reclaim the driver command queue */ | 2013 | * as we reclaim the driver command queue */ |
3155 | if (rxb && rxb->skb) | 2014 | if (rxb && rxb->skb) |
3156 | iwl4965_tx_cmd_complete(priv, rxb); | 2015 | iwl_tx_cmd_complete(priv, rxb); |
3157 | else | 2016 | else |
3158 | IWL_WARNING("Claim null rxb?\n"); | 2017 | IWL_WARNING("Claim null rxb?\n"); |
3159 | } | 2018 | } |
@@ -3268,56 +2127,10 @@ int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm) | |||
3268 | return sig_qual; | 2127 | return sig_qual; |
3269 | } | 2128 | } |
3270 | 2129 | ||
3271 | /** | ||
3272 | * iwl4965_tx_queue_update_write_ptr - Send new write index to hardware | ||
3273 | */ | ||
3274 | static int iwl4965_tx_queue_update_write_ptr(struct iwl_priv *priv, | ||
3275 | struct iwl_tx_queue *txq) | ||
3276 | { | ||
3277 | u32 reg = 0; | ||
3278 | int rc = 0; | ||
3279 | int txq_id = txq->q.id; | ||
3280 | |||
3281 | if (txq->need_update == 0) | ||
3282 | return rc; | ||
3283 | |||
3284 | /* if we're trying to save power */ | ||
3285 | if (test_bit(STATUS_POWER_PMI, &priv->status)) { | ||
3286 | /* wake up nic if it's powered down ... | ||
3287 | * uCode will wake up, and interrupt us again, so next | ||
3288 | * time we'll skip this part. */ | ||
3289 | reg = iwl_read32(priv, CSR_UCODE_DRV_GP1); | ||
3290 | |||
3291 | if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { | ||
3292 | IWL_DEBUG_INFO("Requesting wakeup, GP1 = 0x%x\n", reg); | ||
3293 | iwl_set_bit(priv, CSR_GP_CNTRL, | ||
3294 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); | ||
3295 | return rc; | ||
3296 | } | ||
3297 | |||
3298 | /* restore this queue's parameters in nic hardware. */ | ||
3299 | rc = iwl_grab_nic_access(priv); | ||
3300 | if (rc) | ||
3301 | return rc; | ||
3302 | iwl_write_direct32(priv, HBUS_TARG_WRPTR, | ||
3303 | txq->q.write_ptr | (txq_id << 8)); | ||
3304 | iwl_release_nic_access(priv); | ||
3305 | |||
3306 | /* else not in power-save mode, uCode will never sleep when we're | ||
3307 | * trying to tx (during RFKILL, we're not trying to tx). */ | ||
3308 | } else | ||
3309 | iwl_write32(priv, HBUS_TARG_WRPTR, | ||
3310 | txq->q.write_ptr | (txq_id << 8)); | ||
3311 | |||
3312 | txq->need_update = 0; | ||
3313 | |||
3314 | return rc; | ||
3315 | } | ||
3316 | |||
3317 | #ifdef CONFIG_IWLWIFI_DEBUG | 2130 | #ifdef CONFIG_IWLWIFI_DEBUG |
3318 | static void iwl4965_print_rx_config_cmd(struct iwl_priv *priv) | 2131 | static void iwl4965_print_rx_config_cmd(struct iwl_priv *priv) |
3319 | { | 2132 | { |
3320 | struct iwl4965_rxon_cmd *rxon = &priv->staging_rxon; | 2133 | struct iwl_rxon_cmd *rxon = &priv->staging_rxon; |
3321 | DECLARE_MAC_BUF(mac); | 2134 | DECLARE_MAC_BUF(mac); |
3322 | 2135 | ||
3323 | IWL_DEBUG_RADIO("RX CONFIG:\n"); | 2136 | IWL_DEBUG_RADIO("RX CONFIG:\n"); |
@@ -3367,173 +2180,6 @@ static inline void iwl4965_disable_interrupts(struct iwl_priv *priv) | |||
3367 | IWL_DEBUG_ISR("Disabled interrupts\n"); | 2180 | IWL_DEBUG_ISR("Disabled interrupts\n"); |
3368 | } | 2181 | } |
3369 | 2182 | ||
3370 | static const char *desc_lookup(int i) | ||
3371 | { | ||
3372 | switch (i) { | ||
3373 | case 1: | ||
3374 | return "FAIL"; | ||
3375 | case 2: | ||
3376 | return "BAD_PARAM"; | ||
3377 | case 3: | ||
3378 | return "BAD_CHECKSUM"; | ||
3379 | case 4: | ||
3380 | return "NMI_INTERRUPT"; | ||
3381 | case 5: | ||
3382 | return "SYSASSERT"; | ||
3383 | case 6: | ||
3384 | return "FATAL_ERROR"; | ||
3385 | } | ||
3386 | |||
3387 | return "UNKNOWN"; | ||
3388 | } | ||
3389 | |||
3390 | #define ERROR_START_OFFSET (1 * sizeof(u32)) | ||
3391 | #define ERROR_ELEM_SIZE (7 * sizeof(u32)) | ||
3392 | |||
3393 | static void iwl4965_dump_nic_error_log(struct iwl_priv *priv) | ||
3394 | { | ||
3395 | u32 data2, line; | ||
3396 | u32 desc, time, count, base, data1; | ||
3397 | u32 blink1, blink2, ilink1, ilink2; | ||
3398 | int rc; | ||
3399 | |||
3400 | base = le32_to_cpu(priv->card_alive.error_event_table_ptr); | ||
3401 | |||
3402 | if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { | ||
3403 | IWL_ERROR("Not valid error log pointer 0x%08X\n", base); | ||
3404 | return; | ||
3405 | } | ||
3406 | |||
3407 | rc = iwl_grab_nic_access(priv); | ||
3408 | if (rc) { | ||
3409 | IWL_WARNING("Can not read from adapter at this time.\n"); | ||
3410 | return; | ||
3411 | } | ||
3412 | |||
3413 | count = iwl_read_targ_mem(priv, base); | ||
3414 | |||
3415 | if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { | ||
3416 | IWL_ERROR("Start IWL Error Log Dump:\n"); | ||
3417 | IWL_ERROR("Status: 0x%08lX, count: %d\n", priv->status, count); | ||
3418 | } | ||
3419 | |||
3420 | desc = iwl_read_targ_mem(priv, base + 1 * sizeof(u32)); | ||
3421 | blink1 = iwl_read_targ_mem(priv, base + 3 * sizeof(u32)); | ||
3422 | blink2 = iwl_read_targ_mem(priv, base + 4 * sizeof(u32)); | ||
3423 | ilink1 = iwl_read_targ_mem(priv, base + 5 * sizeof(u32)); | ||
3424 | ilink2 = iwl_read_targ_mem(priv, base + 6 * sizeof(u32)); | ||
3425 | data1 = iwl_read_targ_mem(priv, base + 7 * sizeof(u32)); | ||
3426 | data2 = iwl_read_targ_mem(priv, base + 8 * sizeof(u32)); | ||
3427 | line = iwl_read_targ_mem(priv, base + 9 * sizeof(u32)); | ||
3428 | time = iwl_read_targ_mem(priv, base + 11 * sizeof(u32)); | ||
3429 | |||
3430 | IWL_ERROR("Desc Time " | ||
3431 | "data1 data2 line\n"); | ||
3432 | IWL_ERROR("%-13s (#%d) %010u 0x%08X 0x%08X %u\n", | ||
3433 | desc_lookup(desc), desc, time, data1, data2, line); | ||
3434 | IWL_ERROR("blink1 blink2 ilink1 ilink2\n"); | ||
3435 | IWL_ERROR("0x%05X 0x%05X 0x%05X 0x%05X\n", blink1, blink2, | ||
3436 | ilink1, ilink2); | ||
3437 | |||
3438 | iwl_release_nic_access(priv); | ||
3439 | } | ||
3440 | |||
3441 | #define EVENT_START_OFFSET (4 * sizeof(u32)) | ||
3442 | |||
3443 | /** | ||
3444 | * iwl4965_print_event_log - Dump error event log to syslog | ||
3445 | * | ||
3446 | * NOTE: Must be called with iwl_grab_nic_access() already obtained! | ||
3447 | */ | ||
3448 | static void iwl4965_print_event_log(struct iwl_priv *priv, u32 start_idx, | ||
3449 | u32 num_events, u32 mode) | ||
3450 | { | ||
3451 | u32 i; | ||
3452 | u32 base; /* SRAM byte address of event log header */ | ||
3453 | u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */ | ||
3454 | u32 ptr; /* SRAM byte address of log data */ | ||
3455 | u32 ev, time, data; /* event log data */ | ||
3456 | |||
3457 | if (num_events == 0) | ||
3458 | return; | ||
3459 | |||
3460 | base = le32_to_cpu(priv->card_alive.log_event_table_ptr); | ||
3461 | |||
3462 | if (mode == 0) | ||
3463 | event_size = 2 * sizeof(u32); | ||
3464 | else | ||
3465 | event_size = 3 * sizeof(u32); | ||
3466 | |||
3467 | ptr = base + EVENT_START_OFFSET + (start_idx * event_size); | ||
3468 | |||
3469 | /* "time" is actually "data" for mode 0 (no timestamp). | ||
3470 | * place event id # at far right for easier visual parsing. */ | ||
3471 | for (i = 0; i < num_events; i++) { | ||
3472 | ev = iwl_read_targ_mem(priv, ptr); | ||
3473 | ptr += sizeof(u32); | ||
3474 | time = iwl_read_targ_mem(priv, ptr); | ||
3475 | ptr += sizeof(u32); | ||
3476 | if (mode == 0) | ||
3477 | IWL_ERROR("0x%08x\t%04u\n", time, ev); /* data, ev */ | ||
3478 | else { | ||
3479 | data = iwl_read_targ_mem(priv, ptr); | ||
3480 | ptr += sizeof(u32); | ||
3481 | IWL_ERROR("%010u\t0x%08x\t%04u\n", time, data, ev); | ||
3482 | } | ||
3483 | } | ||
3484 | } | ||
3485 | |||
3486 | static void iwl4965_dump_nic_event_log(struct iwl_priv *priv) | ||
3487 | { | ||
3488 | int rc; | ||
3489 | u32 base; /* SRAM byte address of event log header */ | ||
3490 | u32 capacity; /* event log capacity in # entries */ | ||
3491 | u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ | ||
3492 | u32 num_wraps; /* # times uCode wrapped to top of log */ | ||
3493 | u32 next_entry; /* index of next entry to be written by uCode */ | ||
3494 | u32 size; /* # entries that we'll print */ | ||
3495 | |||
3496 | base = le32_to_cpu(priv->card_alive.log_event_table_ptr); | ||
3497 | if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { | ||
3498 | IWL_ERROR("Invalid event log pointer 0x%08X\n", base); | ||
3499 | return; | ||
3500 | } | ||
3501 | |||
3502 | rc = iwl_grab_nic_access(priv); | ||
3503 | if (rc) { | ||
3504 | IWL_WARNING("Can not read from adapter at this time.\n"); | ||
3505 | return; | ||
3506 | } | ||
3507 | |||
3508 | /* event log header */ | ||
3509 | capacity = iwl_read_targ_mem(priv, base); | ||
3510 | mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32))); | ||
3511 | num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32))); | ||
3512 | next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32))); | ||
3513 | |||
3514 | size = num_wraps ? capacity : next_entry; | ||
3515 | |||
3516 | /* bail out if nothing in log */ | ||
3517 | if (size == 0) { | ||
3518 | IWL_ERROR("Start IWL Event Log Dump: nothing in log\n"); | ||
3519 | iwl_release_nic_access(priv); | ||
3520 | return; | ||
3521 | } | ||
3522 | |||
3523 | IWL_ERROR("Start IWL Event Log Dump: display count %d, wraps %d\n", | ||
3524 | size, num_wraps); | ||
3525 | |||
3526 | /* if uCode has wrapped back to top of log, start at the oldest entry, | ||
3527 | * i.e the next one that uCode would fill. */ | ||
3528 | if (num_wraps) | ||
3529 | iwl4965_print_event_log(priv, next_entry, | ||
3530 | capacity - next_entry, mode); | ||
3531 | |||
3532 | /* (then/else) start at top of log */ | ||
3533 | iwl4965_print_event_log(priv, 0, next_entry, mode); | ||
3534 | |||
3535 | iwl_release_nic_access(priv); | ||
3536 | } | ||
3537 | 2183 | ||
3538 | /** | 2184 | /** |
3539 | * iwl4965_irq_handle_error - called for HW or SW error interrupt from card | 2185 | * iwl4965_irq_handle_error - called for HW or SW error interrupt from card |
@@ -3548,8 +2194,8 @@ static void iwl4965_irq_handle_error(struct iwl_priv *priv) | |||
3548 | 2194 | ||
3549 | #ifdef CONFIG_IWLWIFI_DEBUG | 2195 | #ifdef CONFIG_IWLWIFI_DEBUG |
3550 | if (priv->debug_level & IWL_DL_FW_ERRORS) { | 2196 | if (priv->debug_level & IWL_DL_FW_ERRORS) { |
3551 | iwl4965_dump_nic_error_log(priv); | 2197 | iwl_dump_nic_error_log(priv); |
3552 | iwl4965_dump_nic_event_log(priv); | 2198 | iwl_dump_nic_event_log(priv); |
3553 | iwl4965_print_rx_config_cmd(priv); | 2199 | iwl4965_print_rx_config_cmd(priv); |
3554 | } | 2200 | } |
3555 | #endif | 2201 | #endif |
@@ -3583,7 +2229,7 @@ static void iwl4965_error_recovery(struct iwl_priv *priv) | |||
3583 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 2229 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
3584 | iwl4965_commit_rxon(priv); | 2230 | iwl4965_commit_rxon(priv); |
3585 | 2231 | ||
3586 | iwl4965_rxon_add_station(priv, priv->bssid, 1); | 2232 | iwl_rxon_add_station(priv, priv->bssid, 1); |
3587 | 2233 | ||
3588 | spin_lock_irqsave(&priv->lock, flags); | 2234 | spin_lock_irqsave(&priv->lock, flags); |
3589 | priv->assoc_id = le16_to_cpu(priv->staging_rxon.assoc_id); | 2235 | priv->assoc_id = le16_to_cpu(priv->staging_rxon.assoc_id); |
@@ -3703,12 +2349,12 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) | |||
3703 | if (inta & CSR_INT_BIT_WAKEUP) { | 2349 | if (inta & CSR_INT_BIT_WAKEUP) { |
3704 | IWL_DEBUG_ISR("Wakeup interrupt\n"); | 2350 | IWL_DEBUG_ISR("Wakeup interrupt\n"); |
3705 | iwl_rx_queue_update_write_ptr(priv, &priv->rxq); | 2351 | iwl_rx_queue_update_write_ptr(priv, &priv->rxq); |
3706 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[0]); | 2352 | iwl_txq_update_write_ptr(priv, &priv->txq[0]); |
3707 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[1]); | 2353 | iwl_txq_update_write_ptr(priv, &priv->txq[1]); |
3708 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[2]); | 2354 | iwl_txq_update_write_ptr(priv, &priv->txq[2]); |
3709 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[3]); | 2355 | iwl_txq_update_write_ptr(priv, &priv->txq[3]); |
3710 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[4]); | 2356 | iwl_txq_update_write_ptr(priv, &priv->txq[4]); |
3711 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[5]); | 2357 | iwl_txq_update_write_ptr(priv, &priv->txq[5]); |
3712 | 2358 | ||
3713 | handled |= CSR_INT_BIT_WAKEUP; | 2359 | handled |= CSR_INT_BIT_WAKEUP; |
3714 | } | 2360 | } |
@@ -3724,6 +2370,9 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) | |||
3724 | if (inta & CSR_INT_BIT_FH_TX) { | 2370 | if (inta & CSR_INT_BIT_FH_TX) { |
3725 | IWL_DEBUG_ISR("Tx interrupt\n"); | 2371 | IWL_DEBUG_ISR("Tx interrupt\n"); |
3726 | handled |= CSR_INT_BIT_FH_TX; | 2372 | handled |= CSR_INT_BIT_FH_TX; |
2373 | /* FH finished to write, send event */ | ||
2374 | priv->ucode_write_complete = 1; | ||
2375 | wake_up_interruptible(&priv->wait_command_queue); | ||
3727 | } | 2376 | } |
3728 | 2377 | ||
3729 | if (inta & ~handled) | 2378 | if (inta & ~handled) |
@@ -4162,11 +2811,11 @@ static int iwl4965_read_ucode(struct iwl_priv *priv) | |||
4162 | } | 2811 | } |
4163 | 2812 | ||
4164 | /** | 2813 | /** |
4165 | * iwl4965_alive_start - called after REPLY_ALIVE notification received | 2814 | * iwl_alive_start - called after REPLY_ALIVE notification received |
4166 | * from protocol/runtime uCode (initialization uCode's | 2815 | * from protocol/runtime uCode (initialization uCode's |
4167 | * Alive gets handled by iwl4965_init_alive_start()). | 2816 | * Alive gets handled by iwl_init_alive_start()). |
4168 | */ | 2817 | */ |
4169 | static void iwl4965_alive_start(struct iwl_priv *priv) | 2818 | static void iwl_alive_start(struct iwl_priv *priv) |
4170 | { | 2819 | { |
4171 | int ret = 0; | 2820 | int ret = 0; |
4172 | 2821 | ||
@@ -4190,7 +2839,6 @@ static void iwl4965_alive_start(struct iwl_priv *priv) | |||
4190 | } | 2839 | } |
4191 | 2840 | ||
4192 | iwlcore_clear_stations_table(priv); | 2841 | iwlcore_clear_stations_table(priv); |
4193 | |||
4194 | ret = priv->cfg->ops->lib->alive_notify(priv); | 2842 | ret = priv->cfg->ops->lib->alive_notify(priv); |
4195 | if (ret) { | 2843 | if (ret) { |
4196 | IWL_WARNING("Could not complete ALIVE transition [ntf]: %d\n", | 2844 | IWL_WARNING("Could not complete ALIVE transition [ntf]: %d\n", |
@@ -4207,14 +2855,14 @@ static void iwl4965_alive_start(struct iwl_priv *priv) | |||
4207 | if (iwl_is_rfkill(priv)) | 2855 | if (iwl_is_rfkill(priv)) |
4208 | return; | 2856 | return; |
4209 | 2857 | ||
4210 | ieee80211_start_queues(priv->hw); | 2858 | ieee80211_wake_queues(priv->hw); |
4211 | 2859 | ||
4212 | priv->active_rate = priv->rates_mask; | 2860 | priv->active_rate = priv->rates_mask; |
4213 | priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK; | 2861 | priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK; |
4214 | 2862 | ||
4215 | if (iwl_is_associated(priv)) { | 2863 | if (iwl_is_associated(priv)) { |
4216 | struct iwl4965_rxon_cmd *active_rxon = | 2864 | struct iwl_rxon_cmd *active_rxon = |
4217 | (struct iwl4965_rxon_cmd *)(&priv->active_rxon); | 2865 | (struct iwl_rxon_cmd *)&priv->active_rxon; |
4218 | 2866 | ||
4219 | memcpy(&priv->staging_rxon, &priv->active_rxon, | 2867 | memcpy(&priv->staging_rxon, &priv->active_rxon, |
4220 | sizeof(priv->staging_rxon)); | 2868 | sizeof(priv->staging_rxon)); |
@@ -4228,12 +2876,12 @@ static void iwl4965_alive_start(struct iwl_priv *priv) | |||
4228 | /* Configure Bluetooth device coexistence support */ | 2876 | /* Configure Bluetooth device coexistence support */ |
4229 | iwl4965_send_bt_config(priv); | 2877 | iwl4965_send_bt_config(priv); |
4230 | 2878 | ||
2879 | iwl_reset_run_time_calib(priv); | ||
2880 | |||
4231 | /* Configure the adapter for unassociated operation */ | 2881 | /* Configure the adapter for unassociated operation */ |
4232 | iwl4965_commit_rxon(priv); | 2882 | iwl4965_commit_rxon(priv); |
4233 | 2883 | ||
4234 | /* At this point, the NIC is initialized and operational */ | 2884 | /* At this point, the NIC is initialized and operational */ |
4235 | priv->notif_missed_beacons = 0; | ||
4236 | |||
4237 | iwl4965_rf_kill_ct_config(priv); | 2885 | iwl4965_rf_kill_ct_config(priv); |
4238 | 2886 | ||
4239 | iwl_leds_register(priv); | 2887 | iwl_leds_register(priv); |
@@ -4259,12 +2907,9 @@ static void __iwl4965_down(struct iwl_priv *priv) | |||
4259 | { | 2907 | { |
4260 | unsigned long flags; | 2908 | unsigned long flags; |
4261 | int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status); | 2909 | int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status); |
4262 | struct ieee80211_conf *conf = NULL; | ||
4263 | 2910 | ||
4264 | IWL_DEBUG_INFO(DRV_NAME " is going down\n"); | 2911 | IWL_DEBUG_INFO(DRV_NAME " is going down\n"); |
4265 | 2912 | ||
4266 | conf = ieee80211_get_hw_conf(priv->hw); | ||
4267 | |||
4268 | if (!exit_pending) | 2913 | if (!exit_pending) |
4269 | set_bit(STATUS_EXIT_PENDING, &priv->status); | 2914 | set_bit(STATUS_EXIT_PENDING, &priv->status); |
4270 | 2915 | ||
@@ -4326,8 +2971,8 @@ static void __iwl4965_down(struct iwl_priv *priv) | |||
4326 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); | 2971 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
4327 | spin_unlock_irqrestore(&priv->lock, flags); | 2972 | spin_unlock_irqrestore(&priv->lock, flags); |
4328 | 2973 | ||
4329 | iwl4965_hw_txq_ctx_stop(priv); | 2974 | iwl_txq_ctx_stop(priv); |
4330 | iwl4965_hw_rxq_stop(priv); | 2975 | iwl_rxq_stop(priv); |
4331 | 2976 | ||
4332 | spin_lock_irqsave(&priv->lock, flags); | 2977 | spin_lock_irqsave(&priv->lock, flags); |
4333 | if (!iwl_grab_nic_access(priv)) { | 2978 | if (!iwl_grab_nic_access(priv)) { |
@@ -4339,20 +2984,19 @@ static void __iwl4965_down(struct iwl_priv *priv) | |||
4339 | 2984 | ||
4340 | udelay(5); | 2985 | udelay(5); |
4341 | 2986 | ||
4342 | iwl4965_hw_nic_stop_master(priv); | 2987 | /* FIXME: apm_ops.suspend(priv) */ |
4343 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); | 2988 | priv->cfg->ops->lib->apm_ops.reset(priv); |
4344 | iwl4965_hw_nic_reset(priv); | ||
4345 | priv->cfg->ops->lib->free_shared_mem(priv); | 2989 | priv->cfg->ops->lib->free_shared_mem(priv); |
4346 | 2990 | ||
4347 | exit: | 2991 | exit: |
4348 | memset(&priv->card_alive, 0, sizeof(struct iwl4965_alive_resp)); | 2992 | memset(&priv->card_alive, 0, sizeof(struct iwl_alive_resp)); |
4349 | 2993 | ||
4350 | if (priv->ibss_beacon) | 2994 | if (priv->ibss_beacon) |
4351 | dev_kfree_skb(priv->ibss_beacon); | 2995 | dev_kfree_skb(priv->ibss_beacon); |
4352 | priv->ibss_beacon = NULL; | 2996 | priv->ibss_beacon = NULL; |
4353 | 2997 | ||
4354 | /* clear out any free frames */ | 2998 | /* clear out any free frames */ |
4355 | iwl4965_clear_free_frames(priv); | 2999 | iwl_clear_free_frames(priv); |
4356 | } | 3000 | } |
4357 | 3001 | ||
4358 | static void iwl4965_down(struct iwl_priv *priv) | 3002 | static void iwl4965_down(struct iwl_priv *priv) |
@@ -4477,7 +3121,7 @@ static int __iwl4965_up(struct iwl_priv *priv) | |||
4477 | * | 3121 | * |
4478 | *****************************************************************************/ | 3122 | *****************************************************************************/ |
4479 | 3123 | ||
4480 | static void iwl4965_bg_init_alive_start(struct work_struct *data) | 3124 | static void iwl_bg_init_alive_start(struct work_struct *data) |
4481 | { | 3125 | { |
4482 | struct iwl_priv *priv = | 3126 | struct iwl_priv *priv = |
4483 | container_of(data, struct iwl_priv, init_alive_start.work); | 3127 | container_of(data, struct iwl_priv, init_alive_start.work); |
@@ -4490,7 +3134,7 @@ static void iwl4965_bg_init_alive_start(struct work_struct *data) | |||
4490 | mutex_unlock(&priv->mutex); | 3134 | mutex_unlock(&priv->mutex); |
4491 | } | 3135 | } |
4492 | 3136 | ||
4493 | static void iwl4965_bg_alive_start(struct work_struct *data) | 3137 | static void iwl_bg_alive_start(struct work_struct *data) |
4494 | { | 3138 | { |
4495 | struct iwl_priv *priv = | 3139 | struct iwl_priv *priv = |
4496 | container_of(data, struct iwl_priv, alive_start.work); | 3140 | container_of(data, struct iwl_priv, alive_start.work); |
@@ -4499,7 +3143,7 @@ static void iwl4965_bg_alive_start(struct work_struct *data) | |||
4499 | return; | 3143 | return; |
4500 | 3144 | ||
4501 | mutex_lock(&priv->mutex); | 3145 | mutex_lock(&priv->mutex); |
4502 | iwl4965_alive_start(priv); | 3146 | iwl_alive_start(priv); |
4503 | mutex_unlock(&priv->mutex); | 3147 | mutex_unlock(&priv->mutex); |
4504 | } | 3148 | } |
4505 | 3149 | ||
@@ -4909,8 +3553,8 @@ static void iwl4965_post_associate(struct iwl_priv *priv) | |||
4909 | /* clear out the station table */ | 3553 | /* clear out the station table */ |
4910 | iwlcore_clear_stations_table(priv); | 3554 | iwlcore_clear_stations_table(priv); |
4911 | 3555 | ||
4912 | iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0); | 3556 | iwl_rxon_add_station(priv, iwl_bcast_addr, 0); |
4913 | iwl4965_rxon_add_station(priv, priv->bssid, 0); | 3557 | iwl_rxon_add_station(priv, priv->bssid, 0); |
4914 | iwl4965_rate_scale_init(priv->hw, IWL_STA_ID); | 3558 | iwl4965_rate_scale_init(priv->hw, IWL_STA_ID); |
4915 | iwl4965_send_beacon_cmd(priv); | 3559 | iwl4965_send_beacon_cmd(priv); |
4916 | 3560 | ||
@@ -5021,7 +3665,7 @@ static int iwl4965_mac_start(struct ieee80211_hw *hw) | |||
5021 | /* we should be verifying the device is ready to be opened */ | 3665 | /* we should be verifying the device is ready to be opened */ |
5022 | mutex_lock(&priv->mutex); | 3666 | mutex_lock(&priv->mutex); |
5023 | 3667 | ||
5024 | memset(&priv->staging_rxon, 0, sizeof(struct iwl4965_rxon_cmd)); | 3668 | memset(&priv->staging_rxon, 0, sizeof(struct iwl_rxon_cmd)); |
5025 | /* fetch ucode file from disk, alloc and copy to bus-master buffers ... | 3669 | /* fetch ucode file from disk, alloc and copy to bus-master buffers ... |
5026 | * ucode filename and max sizes are card-specific. */ | 3670 | * ucode filename and max sizes are card-specific. */ |
5027 | 3671 | ||
@@ -5046,21 +3690,23 @@ static int iwl4965_mac_start(struct ieee80211_hw *hw) | |||
5046 | if (test_bit(STATUS_IN_SUSPEND, &priv->status)) | 3690 | if (test_bit(STATUS_IN_SUSPEND, &priv->status)) |
5047 | return 0; | 3691 | return 0; |
5048 | 3692 | ||
5049 | /* Wait for START_ALIVE from ucode. Otherwise callbacks from | 3693 | /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from |
5050 | * mac80211 will not be run successfully. */ | 3694 | * mac80211 will not be run successfully. */ |
5051 | ret = wait_event_interruptible_timeout(priv->wait_command_queue, | 3695 | if (priv->ucode_type == UCODE_RT) { |
5052 | test_bit(STATUS_READY, &priv->status), | 3696 | ret = wait_event_interruptible_timeout(priv->wait_command_queue, |
5053 | UCODE_READY_TIMEOUT); | 3697 | test_bit(STATUS_READY, &priv->status), |
5054 | if (!ret) { | 3698 | UCODE_READY_TIMEOUT); |
5055 | if (!test_bit(STATUS_READY, &priv->status)) { | 3699 | if (!ret) { |
5056 | IWL_ERROR("Wait for START_ALIVE timeout after %dms.\n", | 3700 | if (!test_bit(STATUS_READY, &priv->status)) { |
5057 | jiffies_to_msecs(UCODE_READY_TIMEOUT)); | 3701 | IWL_ERROR("START_ALIVE timeout after %dms.\n", |
5058 | ret = -ETIMEDOUT; | 3702 | jiffies_to_msecs(UCODE_READY_TIMEOUT)); |
5059 | goto out_release_irq; | 3703 | ret = -ETIMEDOUT; |
3704 | goto out_release_irq; | ||
3705 | } | ||
5060 | } | 3706 | } |
5061 | } | ||
5062 | 3707 | ||
5063 | priv->is_open = 1; | 3708 | priv->is_open = 1; |
3709 | } | ||
5064 | IWL_DEBUG_MAC80211("leave\n"); | 3710 | IWL_DEBUG_MAC80211("leave\n"); |
5065 | return 0; | 3711 | return 0; |
5066 | 3712 | ||
@@ -5108,8 +3754,7 @@ static void iwl4965_mac_stop(struct ieee80211_hw *hw) | |||
5108 | IWL_DEBUG_MAC80211("leave\n"); | 3754 | IWL_DEBUG_MAC80211("leave\n"); |
5109 | } | 3755 | } |
5110 | 3756 | ||
5111 | static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | 3757 | static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
5112 | struct ieee80211_tx_control *ctl) | ||
5113 | { | 3758 | { |
5114 | struct iwl_priv *priv = hw->priv; | 3759 | struct iwl_priv *priv = hw->priv; |
5115 | 3760 | ||
@@ -5121,9 +3766,9 @@ static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
5121 | } | 3766 | } |
5122 | 3767 | ||
5123 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, | 3768 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, |
5124 | ctl->tx_rate->bitrate); | 3769 | ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); |
5125 | 3770 | ||
5126 | if (iwl4965_tx_skb(priv, skb, ctl)) | 3771 | if (iwl_tx_skb(priv, skb)) |
5127 | dev_kfree_skb_any(skb); | 3772 | dev_kfree_skb_any(skb); |
5128 | 3773 | ||
5129 | IWL_DEBUG_MAC80211("leave\n"); | 3774 | IWL_DEBUG_MAC80211("leave\n"); |
@@ -5178,6 +3823,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
5178 | const struct iwl_channel_info *ch_info; | 3823 | const struct iwl_channel_info *ch_info; |
5179 | unsigned long flags; | 3824 | unsigned long flags; |
5180 | int ret = 0; | 3825 | int ret = 0; |
3826 | u16 channel; | ||
5181 | 3827 | ||
5182 | mutex_lock(&priv->mutex); | 3828 | mutex_lock(&priv->mutex); |
5183 | IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); | 3829 | IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); |
@@ -5198,22 +3844,21 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
5198 | return 0; | 3844 | return 0; |
5199 | } | 3845 | } |
5200 | 3846 | ||
5201 | spin_lock_irqsave(&priv->lock, flags); | 3847 | channel = ieee80211_frequency_to_channel(conf->channel->center_freq); |
5202 | 3848 | ch_info = iwl_get_channel_info(priv, conf->channel->band, channel); | |
5203 | ch_info = iwl_get_channel_info(priv, conf->channel->band, | ||
5204 | ieee80211_frequency_to_channel(conf->channel->center_freq)); | ||
5205 | if (!is_channel_valid(ch_info)) { | 3849 | if (!is_channel_valid(ch_info)) { |
5206 | IWL_DEBUG_MAC80211("leave - invalid channel\n"); | 3850 | IWL_DEBUG_MAC80211("leave - invalid channel\n"); |
5207 | spin_unlock_irqrestore(&priv->lock, flags); | ||
5208 | ret = -EINVAL; | 3851 | ret = -EINVAL; |
5209 | goto out; | 3852 | goto out; |
5210 | } | 3853 | } |
5211 | 3854 | ||
3855 | spin_lock_irqsave(&priv->lock, flags); | ||
3856 | |||
5212 | #ifdef CONFIG_IWL4965_HT | 3857 | #ifdef CONFIG_IWL4965_HT |
5213 | /* if we are switching from ht to 2.4 clear flags | 3858 | /* if we are switching from ht to 2.4 clear flags |
5214 | * from any ht related info since 2.4 does not | 3859 | * from any ht related info since 2.4 does not |
5215 | * support ht */ | 3860 | * support ht */ |
5216 | if ((le16_to_cpu(priv->staging_rxon.channel) != conf->channel->hw_value) | 3861 | if ((le16_to_cpu(priv->staging_rxon.channel) != channel) |
5217 | #ifdef IEEE80211_CONF_CHANNEL_SWITCH | 3862 | #ifdef IEEE80211_CONF_CHANNEL_SWITCH |
5218 | && !(conf->flags & IEEE80211_CONF_CHANNEL_SWITCH) | 3863 | && !(conf->flags & IEEE80211_CONF_CHANNEL_SWITCH) |
5219 | #endif | 3864 | #endif |
@@ -5221,10 +3866,9 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
5221 | priv->staging_rxon.flags = 0; | 3866 | priv->staging_rxon.flags = 0; |
5222 | #endif /* CONFIG_IWL4965_HT */ | 3867 | #endif /* CONFIG_IWL4965_HT */ |
5223 | 3868 | ||
5224 | iwl_set_rxon_channel(priv, conf->channel->band, | 3869 | iwl_set_rxon_channel(priv, conf->channel->band, channel); |
5225 | ieee80211_frequency_to_channel(conf->channel->center_freq)); | ||
5226 | 3870 | ||
5227 | iwl4965_set_flags_for_phymode(priv, conf->channel->band); | 3871 | iwl_set_flags_for_band(priv, conf->channel->band); |
5228 | 3872 | ||
5229 | /* The list of supported rates and rate mask can be different | 3873 | /* The list of supported rates and rate mask can be different |
5230 | * for each band; since the band may have changed, reset | 3874 | * for each band; since the band may have changed, reset |
@@ -5321,7 +3965,7 @@ static void iwl4965_config_ap(struct iwl_priv *priv) | |||
5321 | priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; | 3965 | priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; |
5322 | iwl4965_commit_rxon(priv); | 3966 | iwl4965_commit_rxon(priv); |
5323 | iwl4965_activate_qos(priv, 1); | 3967 | iwl4965_activate_qos(priv, 1); |
5324 | iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0); | 3968 | iwl_rxon_add_station(priv, iwl_bcast_addr, 0); |
5325 | } | 3969 | } |
5326 | iwl4965_send_beacon_cmd(priv); | 3970 | iwl4965_send_beacon_cmd(priv); |
5327 | 3971 | ||
@@ -5410,7 +4054,7 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw, | |||
5410 | else { | 4054 | else { |
5411 | rc = iwl4965_commit_rxon(priv); | 4055 | rc = iwl4965_commit_rxon(priv); |
5412 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) | 4056 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) |
5413 | iwl4965_rxon_add_station( | 4057 | iwl_rxon_add_station( |
5414 | priv, priv->active_rxon.bssid_addr, 1); | 4058 | priv, priv->active_rxon.bssid_addr, 1); |
5415 | } | 4059 | } |
5416 | 4060 | ||
@@ -5697,7 +4341,8 @@ static int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
5697 | if (cmd == SET_KEY) | 4341 | if (cmd == SET_KEY) |
5698 | is_default_wep_key = !priv->key_mapping_key; | 4342 | is_default_wep_key = !priv->key_mapping_key; |
5699 | else | 4343 | else |
5700 | is_default_wep_key = priv->default_wep_key; | 4344 | is_default_wep_key = |
4345 | (key->hw_key_idx == HW_KEY_DEFAULT); | ||
5701 | } | 4346 | } |
5702 | 4347 | ||
5703 | switch (cmd) { | 4348 | switch (cmd) { |
@@ -5783,7 +4428,7 @@ static int iwl4965_mac_get_tx_stats(struct ieee80211_hw *hw, | |||
5783 | struct iwl_priv *priv = hw->priv; | 4428 | struct iwl_priv *priv = hw->priv; |
5784 | int i, avail; | 4429 | int i, avail; |
5785 | struct iwl_tx_queue *txq; | 4430 | struct iwl_tx_queue *txq; |
5786 | struct iwl4965_queue *q; | 4431 | struct iwl_queue *q; |
5787 | unsigned long flags; | 4432 | unsigned long flags; |
5788 | 4433 | ||
5789 | IWL_DEBUG_MAC80211("enter\n"); | 4434 | IWL_DEBUG_MAC80211("enter\n"); |
@@ -5798,7 +4443,7 @@ static int iwl4965_mac_get_tx_stats(struct ieee80211_hw *hw, | |||
5798 | for (i = 0; i < AC_NUM; i++) { | 4443 | for (i = 0; i < AC_NUM; i++) { |
5799 | txq = &priv->txq[i]; | 4444 | txq = &priv->txq[i]; |
5800 | q = &txq->q; | 4445 | q = &txq->q; |
5801 | avail = iwl4965_queue_space(q); | 4446 | avail = iwl_queue_space(q); |
5802 | 4447 | ||
5803 | stats[i].len = q->n_window - avail; | 4448 | stats[i].len = q->n_window - avail; |
5804 | stats[i].limit = q->n_window - q->high_mark; | 4449 | stats[i].limit = q->n_window - q->high_mark; |
@@ -5904,8 +4549,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw) | |||
5904 | IWL_DEBUG_MAC80211("leave\n"); | 4549 | IWL_DEBUG_MAC80211("leave\n"); |
5905 | } | 4550 | } |
5906 | 4551 | ||
5907 | static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | 4552 | static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
5908 | struct ieee80211_tx_control *control) | ||
5909 | { | 4553 | { |
5910 | struct iwl_priv *priv = hw->priv; | 4554 | struct iwl_priv *priv = hw->priv; |
5911 | unsigned long flags; | 4555 | unsigned long flags; |
@@ -5998,7 +4642,7 @@ static ssize_t show_version(struct device *d, | |||
5998 | struct device_attribute *attr, char *buf) | 4642 | struct device_attribute *attr, char *buf) |
5999 | { | 4643 | { |
6000 | struct iwl_priv *priv = d->driver_data; | 4644 | struct iwl_priv *priv = d->driver_data; |
6001 | struct iwl4965_alive_resp *palive = &priv->card_alive; | 4645 | struct iwl_alive_resp *palive = &priv->card_alive; |
6002 | 4646 | ||
6003 | if (palive->is_valid) | 4647 | if (palive->is_valid) |
6004 | return sprintf(buf, "fw version: 0x%01X.0x%01X.0x%01X.0x%01X\n" | 4648 | return sprintf(buf, "fw version: 0x%01X.0x%01X.0x%01X.0x%01X\n" |
@@ -6368,34 +5012,6 @@ static ssize_t show_status(struct device *d, | |||
6368 | 5012 | ||
6369 | static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); | 5013 | static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); |
6370 | 5014 | ||
6371 | static ssize_t dump_error_log(struct device *d, | ||
6372 | struct device_attribute *attr, | ||
6373 | const char *buf, size_t count) | ||
6374 | { | ||
6375 | char *p = (char *)buf; | ||
6376 | |||
6377 | if (p[0] == '1') | ||
6378 | iwl4965_dump_nic_error_log((struct iwl_priv *)d->driver_data); | ||
6379 | |||
6380 | return strnlen(buf, count); | ||
6381 | } | ||
6382 | |||
6383 | static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, dump_error_log); | ||
6384 | |||
6385 | static ssize_t dump_event_log(struct device *d, | ||
6386 | struct device_attribute *attr, | ||
6387 | const char *buf, size_t count) | ||
6388 | { | ||
6389 | char *p = (char *)buf; | ||
6390 | |||
6391 | if (p[0] == '1') | ||
6392 | iwl4965_dump_nic_event_log((struct iwl_priv *)d->driver_data); | ||
6393 | |||
6394 | return strnlen(buf, count); | ||
6395 | } | ||
6396 | |||
6397 | static DEVICE_ATTR(dump_events, S_IWUSR, NULL, dump_event_log); | ||
6398 | |||
6399 | /***************************************************************************** | 5015 | /***************************************************************************** |
6400 | * | 5016 | * |
6401 | * driver setup and teardown | 5017 | * driver setup and teardown |
@@ -6418,8 +5034,8 @@ static void iwl4965_setup_deferred_work(struct iwl_priv *priv) | |||
6418 | INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); | 5034 | INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); |
6419 | INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor); | 5035 | INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor); |
6420 | INIT_DELAYED_WORK(&priv->post_associate, iwl4965_bg_post_associate); | 5036 | INIT_DELAYED_WORK(&priv->post_associate, iwl4965_bg_post_associate); |
6421 | INIT_DELAYED_WORK(&priv->init_alive_start, iwl4965_bg_init_alive_start); | 5037 | INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start); |
6422 | INIT_DELAYED_WORK(&priv->alive_start, iwl4965_bg_alive_start); | 5038 | INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start); |
6423 | INIT_DELAYED_WORK(&priv->scan_check, iwl4965_bg_scan_check); | 5039 | INIT_DELAYED_WORK(&priv->scan_check, iwl4965_bg_scan_check); |
6424 | 5040 | ||
6425 | iwl4965_hw_setup_deferred_work(priv); | 5041 | iwl4965_hw_setup_deferred_work(priv); |
@@ -6441,8 +5057,6 @@ static void iwl4965_cancel_deferred_work(struct iwl_priv *priv) | |||
6441 | 5057 | ||
6442 | static struct attribute *iwl4965_sysfs_entries[] = { | 5058 | static struct attribute *iwl4965_sysfs_entries[] = { |
6443 | &dev_attr_channels.attr, | 5059 | &dev_attr_channels.attr, |
6444 | &dev_attr_dump_errors.attr, | ||
6445 | &dev_attr_dump_events.attr, | ||
6446 | &dev_attr_flags.attr, | 5060 | &dev_attr_flags.attr, |
6447 | &dev_attr_filter_flags.attr, | 5061 | &dev_attr_filter_flags.attr, |
6448 | #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT | 5062 | #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT |
@@ -6605,7 +5219,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6605 | if (err) | 5219 | if (err) |
6606 | goto out_iounmap; | 5220 | goto out_iounmap; |
6607 | 5221 | ||
6608 | /* MAC Address location in EEPROM same for 3945/4965 */ | 5222 | /* extract MAC Address */ |
6609 | iwl_eeprom_get_mac(priv, priv->mac_addr); | 5223 | iwl_eeprom_get_mac(priv, priv->mac_addr); |
6610 | IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr)); | 5224 | IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr)); |
6611 | SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); | 5225 | SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); |
@@ -6620,10 +5234,10 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6620 | } | 5234 | } |
6621 | 5235 | ||
6622 | /******************* | 5236 | /******************* |
6623 | * 6. Setup hw/priv | 5237 | * 6. Setup priv |
6624 | *******************/ | 5238 | *******************/ |
6625 | 5239 | ||
6626 | err = iwl_setup(priv); | 5240 | err = iwl_init_drv(priv); |
6627 | if (err) | 5241 | if (err) |
6628 | goto out_free_eeprom; | 5242 | goto out_free_eeprom; |
6629 | /* At this point both hw and priv are initialized. */ | 5243 | /* At this point both hw and priv are initialized. */ |
@@ -6638,9 +5252,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6638 | IWL_DEBUG_INFO("Radio disabled.\n"); | 5252 | IWL_DEBUG_INFO("Radio disabled.\n"); |
6639 | } | 5253 | } |
6640 | 5254 | ||
6641 | if (priv->cfg->mod_params->enable_qos) | ||
6642 | priv->qos_data.qos_enable = 1; | ||
6643 | |||
6644 | /******************** | 5255 | /******************** |
6645 | * 8. Setup services | 5256 | * 8. Setup services |
6646 | ********************/ | 5257 | ********************/ |
@@ -6651,14 +5262,9 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6651 | err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group); | 5262 | err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group); |
6652 | if (err) { | 5263 | if (err) { |
6653 | IWL_ERROR("failed to create sysfs device attributes\n"); | 5264 | IWL_ERROR("failed to create sysfs device attributes\n"); |
6654 | goto out_free_eeprom; | 5265 | goto out_uninit_drv; |
6655 | } | 5266 | } |
6656 | 5267 | ||
6657 | err = iwl_dbgfs_register(priv, DRV_NAME); | ||
6658 | if (err) { | ||
6659 | IWL_ERROR("failed to create debugfs files\n"); | ||
6660 | goto out_remove_sysfs; | ||
6661 | } | ||
6662 | 5268 | ||
6663 | iwl4965_setup_deferred_work(priv); | 5269 | iwl4965_setup_deferred_work(priv); |
6664 | iwl4965_setup_rx_handlers(priv); | 5270 | iwl4965_setup_rx_handlers(priv); |
@@ -6669,12 +5275,26 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6669 | pci_save_state(pdev); | 5275 | pci_save_state(pdev); |
6670 | pci_disable_device(pdev); | 5276 | pci_disable_device(pdev); |
6671 | 5277 | ||
5278 | /********************************** | ||
5279 | * 10. Setup and register mac80211 | ||
5280 | **********************************/ | ||
5281 | |||
5282 | err = iwl_setup_mac(priv); | ||
5283 | if (err) | ||
5284 | goto out_remove_sysfs; | ||
5285 | |||
5286 | err = iwl_dbgfs_register(priv, DRV_NAME); | ||
5287 | if (err) | ||
5288 | IWL_ERROR("failed to create debugfs files\n"); | ||
5289 | |||
6672 | /* notify iwlcore to init */ | 5290 | /* notify iwlcore to init */ |
6673 | iwlcore_low_level_notify(priv, IWLCORE_INIT_EVT); | 5291 | iwlcore_low_level_notify(priv, IWLCORE_INIT_EVT); |
6674 | return 0; | 5292 | return 0; |
6675 | 5293 | ||
6676 | out_remove_sysfs: | 5294 | out_remove_sysfs: |
6677 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); | 5295 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); |
5296 | out_uninit_drv: | ||
5297 | iwl_uninit_drv(priv); | ||
6678 | out_free_eeprom: | 5298 | out_free_eeprom: |
6679 | iwl_eeprom_free(priv); | 5299 | iwl_eeprom_free(priv); |
6680 | out_iounmap: | 5300 | out_iounmap: |
@@ -6702,6 +5322,9 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) | |||
6702 | 5322 | ||
6703 | IWL_DEBUG_INFO("*** UNLOAD DRIVER ***\n"); | 5323 | IWL_DEBUG_INFO("*** UNLOAD DRIVER ***\n"); |
6704 | 5324 | ||
5325 | iwl_dbgfs_unregister(priv); | ||
5326 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); | ||
5327 | |||
6705 | if (priv->mac80211_registered) { | 5328 | if (priv->mac80211_registered) { |
6706 | ieee80211_unregister_hw(priv->hw); | 5329 | ieee80211_unregister_hw(priv->hw); |
6707 | priv->mac80211_registered = 0; | 5330 | priv->mac80211_registered = 0; |
@@ -6729,8 +5352,6 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) | |||
6729 | } | 5352 | } |
6730 | 5353 | ||
6731 | iwlcore_low_level_notify(priv, IWLCORE_REMOVE_EVT); | 5354 | iwlcore_low_level_notify(priv, IWLCORE_REMOVE_EVT); |
6732 | iwl_dbgfs_unregister(priv); | ||
6733 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); | ||
6734 | 5355 | ||
6735 | iwl4965_dealloc_ucode_pci(priv); | 5356 | iwl4965_dealloc_ucode_pci(priv); |
6736 | 5357 | ||
@@ -6756,8 +5377,7 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) | |||
6756 | pci_disable_device(pdev); | 5377 | pci_disable_device(pdev); |
6757 | pci_set_drvdata(pdev, NULL); | 5378 | pci_set_drvdata(pdev, NULL); |
6758 | 5379 | ||
6759 | iwl_free_channel_map(priv); | 5380 | iwl_uninit_drv(priv); |
6760 | iwlcore_free_geos(priv); | ||
6761 | 5381 | ||
6762 | if (priv->ibss_beacon) | 5382 | if (priv->ibss_beacon) |
6763 | dev_kfree_skb(priv->ibss_beacon); | 5383 | dev_kfree_skb(priv->ibss_beacon); |
@@ -6848,10 +5468,6 @@ static int __init iwl4965_init(void) | |||
6848 | 5468 | ||
6849 | return ret; | 5469 | return ret; |
6850 | 5470 | ||
6851 | |||
6852 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
6853 | pci_unregister_driver(&iwl_driver); | ||
6854 | #endif | ||
6855 | error_register: | 5471 | error_register: |
6856 | iwl4965_rate_control_unregister(); | 5472 | iwl4965_rate_control_unregister(); |
6857 | return ret; | 5473 | return ret; |