aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-debug.h17
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c231
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h20
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-debug.h16
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-rs.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-rs.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c250
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.h10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c182
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c181
10 files changed, 449 insertions, 466 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-debug.h b/drivers/net/wireless/iwlwifi/iwl-3945-debug.h
index f853c6b9f76e..28ecfe8d39a3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-debug.h
@@ -40,6 +40,15 @@ do { if (iwl3945_debug_level & (level)) \
40do { if ((iwl3945_debug_level & (level)) && net_ratelimit()) \ 40do { if ((iwl3945_debug_level & (level)) && net_ratelimit()) \
41 printk(KERN_ERR DRV_NAME": %c %s " fmt, \ 41 printk(KERN_ERR DRV_NAME": %c %s " fmt, \
42 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 42 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
43
44static inline void iwl3945_print_hex_dump(int level, void *p, u32 len)
45{
46 if (!(iwl3945_debug_level & level))
47 return;
48
49 print_hex_dump(KERN_DEBUG, "iwl data: ", DUMP_PREFIX_OFFSET, 16, 1,
50 p, len, 1);
51}
43#else 52#else
44static inline void IWL_DEBUG(int level, const char *fmt, ...) 53static inline void IWL_DEBUG(int level, const char *fmt, ...)
45{ 54{
@@ -47,7 +56,12 @@ static inline void IWL_DEBUG(int level, const char *fmt, ...)
47static inline void IWL_DEBUG_LIMIT(int level, const char *fmt, ...) 56static inline void IWL_DEBUG_LIMIT(int level, const char *fmt, ...)
48{ 57{
49} 58}
50#endif /* CONFIG_IWL3945_DEBUG */ 59static inline void iwl3945_print_hex_dump(int level, void *p, u32 len)
60{
61}
62#endif /* CONFIG_IWL3945_DEBUG */
63
64
51 65
52/* 66/*
53 * To use the debug system; 67 * To use the debug system;
@@ -143,6 +157,7 @@ static inline void IWL_DEBUG_LIMIT(int level, const char *fmt, ...)
143 IWL_DEBUG_LIMIT(IWL_DL_ASSOC | IWL_DL_INFO, f, ## a) 157 IWL_DEBUG_LIMIT(IWL_DL_ASSOC | IWL_DL_INFO, f, ## a)
144#define IWL_DEBUG_HT(f, a...) IWL_DEBUG(IWL_DL_HT, f, ## a) 158#define IWL_DEBUG_HT(f, a...) IWL_DEBUG(IWL_DL_HT, f, ## a)
145#define IWL_DEBUG_STATS(f, a...) IWL_DEBUG(IWL_DL_STATS, f, ## a) 159#define IWL_DEBUG_STATS(f, a...) IWL_DEBUG(IWL_DL_STATS, f, ## a)
160#define IWL_DEBUG_STATS_LIMIT(f, a...) IWL_DEBUG_LIMIT(IWL_DL_STATS, f, ## a)
146#define IWL_DEBUG_TX_REPLY(f, a...) IWL_DEBUG(IWL_DL_TX_REPLY, f, ## a) 161#define IWL_DEBUG_TX_REPLY(f, a...) IWL_DEBUG(IWL_DL_TX_REPLY, f, ## a)
147#define IWL_DEBUG_QOS(f, a...) IWL_DEBUG(IWL_DL_QOS, f, ## a) 162#define IWL_DEBUG_QOS(f, a...) IWL_DEBUG(IWL_DL_QOS, f, ## a)
148#define IWL_DEBUG_RADIO(f, a...) IWL_DEBUG(IWL_DL_RADIO, f, ## a) 163#define IWL_DEBUG_RADIO(f, a...) IWL_DEBUG(IWL_DL_RADIO, f, ## a)
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 82d282730b75..63e832cdba75 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -183,6 +183,16 @@ void iwl3945_disable_events(struct iwl3945_priv *priv)
183 183
184} 184}
185 185
186static int iwl3945_hwrate_to_plcp_idx(u8 plcp)
187{
188 int idx;
189
190 for (idx = 0; idx < IWL_RATE_COUNT; idx++)
191 if (iwl3945_rates[idx].plcp == plcp)
192 return idx;
193 return -1;
194}
195
186/** 196/**
187 * iwl3945_get_antenna_flags - Get antenna flags for RXON command 197 * iwl3945_get_antenna_flags - Get antenna flags for RXON command
188 * @priv: eeprom and antenna fields are used to determine antenna flags 198 * @priv: eeprom and antenna fields are used to determine antenna flags
@@ -238,6 +248,156 @@ void iwl3945_hw_rx_statistics(struct iwl3945_priv *priv, struct iwl3945_rx_mem_b
238 priv->last_statistics_time = jiffies; 248 priv->last_statistics_time = jiffies;
239} 249}
240 250
251/******************************************************************************
252 *
253 * Misc. internal state and helper functions
254 *
255 ******************************************************************************/
256#ifdef CONFIG_IWL3945_DEBUG
257
258/**
259 * iwl3945_report_frame - dump frame to syslog during debug sessions
260 *
261 * You may hack this function to show different aspects of received frames,
262 * including selective frame dumps.
263 * group100 parameter selects whether to show 1 out of 100 good frames.
264 */
265static void iwl3945_dbg_report_frame(struct iwl3945_priv *priv,
266 struct iwl3945_rx_packet *pkt,
267 struct ieee80211_hdr *header, int group100)
268{
269 u32 to_us;
270 u32 print_summary = 0;
271 u32 print_dump = 0; /* set to 1 to dump all frames' contents */
272 u32 hundred = 0;
273 u32 dataframe = 0;
274 u16 fc;
275 u16 seq_ctl;
276 u16 channel;
277 u16 phy_flags;
278 u16 length;
279 u16 status;
280 u16 bcn_tmr;
281 u32 tsf_low;
282 u64 tsf;
283 u8 rssi;
284 u8 agc;
285 u16 sig_avg;
286 u16 noise_diff;
287 struct iwl3945_rx_frame_stats *rx_stats = IWL_RX_STATS(pkt);
288 struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt);
289 struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt);
290 u8 *data = IWL_RX_DATA(pkt);
291
292 /* MAC header */
293 fc = le16_to_cpu(header->frame_control);
294 seq_ctl = le16_to_cpu(header->seq_ctrl);
295
296 /* metadata */
297 channel = le16_to_cpu(rx_hdr->channel);
298 phy_flags = le16_to_cpu(rx_hdr->phy_flags);
299 length = le16_to_cpu(rx_hdr->len);
300
301 /* end-of-frame status and timestamp */
302 status = le32_to_cpu(rx_end->status);
303 bcn_tmr = le32_to_cpu(rx_end->beacon_timestamp);
304 tsf_low = le64_to_cpu(rx_end->timestamp) & 0x0ffffffff;
305 tsf = le64_to_cpu(rx_end->timestamp);
306
307 /* signal statistics */
308 rssi = rx_stats->rssi;
309 agc = rx_stats->agc;
310 sig_avg = le16_to_cpu(rx_stats->sig_avg);
311 noise_diff = le16_to_cpu(rx_stats->noise_diff);
312
313 to_us = !compare_ether_addr(header->addr1, priv->mac_addr);
314
315 /* if data frame is to us and all is good,
316 * (optionally) print summary for only 1 out of every 100 */
317 if (to_us && (fc & ~IEEE80211_FCTL_PROTECTED) ==
318 (IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) {
319 dataframe = 1;
320 if (!group100)
321 print_summary = 1; /* print each frame */
322 else if (priv->framecnt_to_us < 100) {
323 priv->framecnt_to_us++;
324 print_summary = 0;
325 } else {
326 priv->framecnt_to_us = 0;
327 print_summary = 1;
328 hundred = 1;
329 }
330 } else {
331 /* print summary for all other frames */
332 print_summary = 1;
333 }
334
335 if (print_summary) {
336 char *title;
337 u32 rate;
338
339 if (hundred)
340 title = "100Frames";
341 else if (fc & IEEE80211_FCTL_RETRY)
342 title = "Retry";
343 else if (ieee80211_is_assoc_response(fc))
344 title = "AscRsp";
345 else if (ieee80211_is_reassoc_response(fc))
346 title = "RasRsp";
347 else if (ieee80211_is_probe_response(fc)) {
348 title = "PrbRsp";
349 print_dump = 1; /* dump frame contents */
350 } else if (ieee80211_is_beacon(fc)) {
351 title = "Beacon";
352 print_dump = 1; /* dump frame contents */
353 } else if (ieee80211_is_atim(fc))
354 title = "ATIM";
355 else if (ieee80211_is_auth(fc))
356 title = "Auth";
357 else if (ieee80211_is_deauth(fc))
358 title = "DeAuth";
359 else if (ieee80211_is_disassoc(fc))
360 title = "DisAssoc";
361 else
362 title = "Frame";
363
364 rate = iwl3945_hwrate_to_plcp_idx(rx_hdr->rate);
365 if (rate == -1)
366 rate = 0;
367 else
368 rate = iwl3945_rates[rate].ieee / 2;
369
370 /* print frame summary.
371 * MAC addresses show just the last byte (for brevity),
372 * but you can hack it to show more, if you'd like to. */
373 if (dataframe)
374 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, "
375 "len=%u, rssi=%d, chnl=%d, rate=%u, \n",
376 title, fc, header->addr1[5],
377 length, rssi, channel, rate);
378 else {
379 /* src/dst addresses assume managed mode */
380 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, "
381 "src=0x%02x, rssi=%u, tim=%lu usec, "
382 "phy=0x%02x, chnl=%d\n",
383 title, fc, header->addr1[5],
384 header->addr3[5], rssi,
385 tsf_low - priv->scan_start_tsf,
386 phy_flags, channel);
387 }
388 }
389 if (print_dump)
390 iwl3945_print_hex_dump(IWL_DL_RX, data, length);
391}
392#else
393static inline void iwl3945_dbg_report_frame(struct iwl3945_priv *priv,
394 struct iwl3945_rx_packet *pkt,
395 struct ieee80211_hdr *header, int group100)
396{
397}
398#endif
399
400
241static void iwl3945_add_radiotap(struct iwl3945_priv *priv, 401static void iwl3945_add_radiotap(struct iwl3945_priv *priv,
242 struct sk_buff *skb, 402 struct sk_buff *skb,
243 struct iwl3945_rx_frame_hdr *rx_hdr, 403 struct iwl3945_rx_frame_hdr *rx_hdr,
@@ -376,24 +536,28 @@ static void iwl3945_handle_data_packet(struct iwl3945_priv *priv, int is_data,
376static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv, 536static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
377 struct iwl3945_rx_mem_buffer *rxb) 537 struct iwl3945_rx_mem_buffer *rxb)
378{ 538{
539 struct ieee80211_hdr *header;
540 struct ieee80211_rx_status rx_status;
379 struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data; 541 struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
380 struct iwl3945_rx_frame_stats *rx_stats = IWL_RX_STATS(pkt); 542 struct iwl3945_rx_frame_stats *rx_stats = IWL_RX_STATS(pkt);
381 struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt); 543 struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt);
382 struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt); 544 struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt);
383 struct ieee80211_hdr *header; 545 int snr;
384 u16 rx_stats_sig_avg = le16_to_cpu(rx_stats->sig_avg); 546 u16 rx_stats_sig_avg = le16_to_cpu(rx_stats->sig_avg);
385 u16 rx_stats_noise_diff = le16_to_cpu(rx_stats->noise_diff); 547 u16 rx_stats_noise_diff = le16_to_cpu(rx_stats->noise_diff);
386 struct ieee80211_rx_status stats = {
387 .mactime = le64_to_cpu(rx_end->timestamp),
388 .freq = ieee80211chan2mhz(le16_to_cpu(rx_hdr->channel)),
389 .band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
390 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ,
391 .antenna = 0,
392 .rate_idx = iwl3945_rate_index_from_plcp(rx_hdr->rate),
393 .flag = 0,
394 };
395 u8 network_packet; 548 u8 network_packet;
396 int snr; 549
550 rx_status.antenna = 0;
551 rx_status.flag = 0;
552 rx_status.mactime = le64_to_cpu(rx_end->timestamp);
553 rx_status.freq = ieee80211chan2mhz(le16_to_cpu(rx_hdr->channel));
554 rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
555 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
556
557 rx_status.rate_idx = iwl3945_hwrate_to_plcp_idx(rx_hdr->rate);
558
559 if (rx_status.band == IEEE80211_BAND_5GHZ)
560 rx_status.rate_idx -= IWL_FIRST_OFDM_RATE;
397 561
398 if ((unlikely(rx_stats->phy_count > 20))) { 562 if ((unlikely(rx_stats->phy_count > 20))) {
399 IWL_DEBUG_DROP 563 IWL_DEBUG_DROP
@@ -409,12 +573,12 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
409 } 573 }
410 574
411 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) { 575 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) {
412 iwl3945_handle_data_packet(priv, 1, rxb, &stats); 576 iwl3945_handle_data_packet(priv, 1, rxb, &rx_status);
413 return; 577 return;
414 } 578 }
415 579
416 /* Convert 3945's rssi indicator to dBm */ 580 /* Convert 3945's rssi indicator to dBm */
417 stats.ssi = rx_stats->rssi - IWL_RSSI_OFFSET; 581 rx_status.ssi = rx_stats->rssi - IWL_RSSI_OFFSET;
418 582
419 /* Set default noise value to -127 */ 583 /* Set default noise value to -127 */
420 if (priv->last_rx_noise == 0) 584 if (priv->last_rx_noise == 0)
@@ -430,50 +594,47 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
430 * signal-to-noise ratio (SNR) is (sig_avg / noise_diff). 594 * signal-to-noise ratio (SNR) is (sig_avg / noise_diff).
431 * Convert linear SNR to dB SNR, then subtract that from rssi dBm 595 * Convert linear SNR to dB SNR, then subtract that from rssi dBm
432 * to obtain noise level in dBm. 596 * to obtain noise level in dBm.
433 * Calculate stats.signal (quality indicator in %) based on SNR. */ 597 * Calculate rx_status.signal (quality indicator in %) based on SNR. */
434 if (rx_stats_noise_diff) { 598 if (rx_stats_noise_diff) {
435 snr = rx_stats_sig_avg / rx_stats_noise_diff; 599 snr = rx_stats_sig_avg / rx_stats_noise_diff;
436 stats.noise = stats.ssi - iwl3945_calc_db_from_ratio(snr); 600 rx_status.noise = rx_status.ssi -
437 stats.signal = iwl3945_calc_sig_qual(stats.ssi, stats.noise); 601 iwl3945_calc_db_from_ratio(snr);
602 rx_status.signal = iwl3945_calc_sig_qual(rx_status.ssi,
603 rx_status.noise);
438 604
439 /* If noise info not available, calculate signal quality indicator (%) 605 /* If noise info not available, calculate signal quality indicator (%)
440 * using just the dBm signal level. */ 606 * using just the dBm signal level. */
441 } else { 607 } else {
442 stats.noise = priv->last_rx_noise; 608 rx_status.noise = priv->last_rx_noise;
443 stats.signal = iwl3945_calc_sig_qual(stats.ssi, 0); 609 rx_status.signal = iwl3945_calc_sig_qual(rx_status.ssi, 0);
444 } 610 }
445 611
446 612
447 IWL_DEBUG_STATS("Rssi %d noise %d qual %d sig_avg %d noise_diff %d\n", 613 IWL_DEBUG_STATS("Rssi %d noise %d qual %d sig_avg %d noise_diff %d\n",
448 stats.ssi, stats.noise, stats.signal, 614 rx_status.ssi, rx_status.noise, rx_status.signal,
449 rx_stats_sig_avg, rx_stats_noise_diff); 615 rx_stats_sig_avg, rx_stats_noise_diff);
450 616
451 /* can be covered by iwl3945_report_frame() in most cases */
452/* IWL_DEBUG_RX("RX status: 0x%08X\n", rx_end->status); */
453
454 header = (struct ieee80211_hdr *)IWL_RX_DATA(pkt); 617 header = (struct ieee80211_hdr *)IWL_RX_DATA(pkt);
455 618
456 network_packet = iwl3945_is_network_packet(priv, header); 619 network_packet = iwl3945_is_network_packet(priv, header);
457 620
458#ifdef CONFIG_IWL3945_DEBUG 621 IWL_DEBUG_STATS_LIMIT("[%c] %d RSSI:%d Signal:%u, Noise:%u, Rate:%u\n",
459 if (iwl3945_debug_level & IWL_DL_STATS && net_ratelimit()) 622 network_packet ? '*' : ' ',
460 IWL_DEBUG_STATS 623 le16_to_cpu(rx_hdr->channel),
461 ("[%c] %d RSSI: %d Signal: %u, Noise: %u, Rate: %u\n", 624 rx_status.ssi, rx_status.ssi,
462 network_packet ? '*' : ' ', 625 rx_status.ssi, rx_status.rate_idx);
463 le16_to_cpu(rx_hdr->channel),
464 stats.ssi, stats.ssi,
465 stats.ssi, stats.rate_idx);
466 626
627#ifdef CONFIG_IWL3945_DEBUG
467 if (iwl3945_debug_level & (IWL_DL_RX)) 628 if (iwl3945_debug_level & (IWL_DL_RX))
468 /* Set "1" to report good data frames in groups of 100 */ 629 /* Set "1" to report good data frames in groups of 100 */
469 iwl3945_report_frame(priv, pkt, header, 1); 630 iwl3945_dbg_report_frame(priv, pkt, header, 1);
470#endif 631#endif
471 632
472 if (network_packet) { 633 if (network_packet) {
473 priv->last_beacon_time = le32_to_cpu(rx_end->beacon_timestamp); 634 priv->last_beacon_time = le32_to_cpu(rx_end->beacon_timestamp);
474 priv->last_tsf = le64_to_cpu(rx_end->timestamp); 635 priv->last_tsf = le64_to_cpu(rx_end->timestamp);
475 priv->last_rx_rssi = stats.ssi; 636 priv->last_rx_rssi = rx_status.ssi;
476 priv->last_rx_noise = stats.noise; 637 priv->last_rx_noise = rx_status.noise;
477 } 638 }
478 639
479 switch (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FTYPE) { 640 switch (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FTYPE) {
@@ -560,7 +721,7 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
560 } 721 }
561 } 722 }
562 723
563 iwl3945_handle_data_packet(priv, 0, rxb, &stats); 724 iwl3945_handle_data_packet(priv, 0, rxb, &rx_status);
564 break; 725 break;
565 726
566 case IEEE80211_FTYPE_CTL: 727 case IEEE80211_FTYPE_CTL:
@@ -577,7 +738,7 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
577 print_mac(mac2, header->addr2), 738 print_mac(mac2, header->addr2),
578 print_mac(mac3, header->addr3)); 739 print_mac(mac3, header->addr3));
579 else 740 else
580 iwl3945_handle_data_packet(priv, 1, rxb, &stats); 741 iwl3945_handle_data_packet(priv, 1, rxb, &rx_status);
581 break; 742 break;
582 } 743 }
583 } 744 }
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index d36ae0045c57..d281e42964d5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -558,16 +558,6 @@ extern int iwl3945_is_network_packet(struct iwl3945_priv *priv,
558 struct ieee80211_hdr *header); 558 struct ieee80211_hdr *header);
559extern int iwl3945_power_init_handle(struct iwl3945_priv *priv); 559extern int iwl3945_power_init_handle(struct iwl3945_priv *priv);
560extern int iwl3945_eeprom_init(struct iwl3945_priv *priv); 560extern int iwl3945_eeprom_init(struct iwl3945_priv *priv);
561#ifdef CONFIG_IWL3945_DEBUG
562extern void iwl3945_report_frame(struct iwl3945_priv *priv,
563 struct iwl3945_rx_packet *pkt,
564 struct ieee80211_hdr *header, int group100);
565#else
566static inline void iwl3945_report_frame(struct iwl3945_priv *priv,
567 struct iwl3945_rx_packet *pkt,
568 struct ieee80211_hdr *header,
569 int group100) {}
570#endif
571extern void iwl3945_handle_data_packet_monitor(struct iwl3945_priv *priv, 561extern void iwl3945_handle_data_packet_monitor(struct iwl3945_priv *priv,
572 struct iwl3945_rx_mem_buffer *rxb, 562 struct iwl3945_rx_mem_buffer *rxb,
573 void *data, short len, 563 void *data, short len,
@@ -949,16 +939,6 @@ static inline int is_channel_ibss(const struct iwl3945_channel_info *ch)
949 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0; 939 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
950} 940}
951 941
952static inline int iwl3945_rate_index_from_plcp(int plcp)
953{
954 int i;
955
956 for (i = 0; i < IWL_RATE_COUNT; i++)
957 if (iwl3945_rates[i].plcp == plcp)
958 return i;
959 return -1;
960}
961
962extern const struct iwl3945_channel_info *iwl3945_get_channel_info( 942extern const struct iwl3945_channel_info *iwl3945_get_channel_info(
963 const struct iwl3945_priv *priv, enum ieee80211_band band, u16 channel); 943 const struct iwl3945_priv *priv, enum ieee80211_band band, u16 channel);
964 944
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-debug.h b/drivers/net/wireless/iwlwifi/iwl-4965-debug.h
index 36696bbf170c..baf07c715cf8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-debug.h
@@ -40,15 +40,30 @@ do { if (iwl4965_debug_level & (level)) \
40do { if ((iwl4965_debug_level & (level)) && net_ratelimit()) \ 40do { if ((iwl4965_debug_level & (level)) && net_ratelimit()) \
41 printk(KERN_ERR DRV_NAME": %c %s " fmt, \ 41 printk(KERN_ERR DRV_NAME": %c %s " fmt, \
42 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 42 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
43
44static inline void iwl4965_print_hex_dump(int level, void *p, u32 len)
45{
46 if (!(iwl4965_debug_level & level))
47 return;
48
49 print_hex_dump(KERN_DEBUG, "iwl data: ", DUMP_PREFIX_OFFSET, 16, 1,
50 p, len, 1);
51}
43#else 52#else
53
44static inline void IWL_DEBUG(int level, const char *fmt, ...) 54static inline void IWL_DEBUG(int level, const char *fmt, ...)
45{ 55{
46} 56}
47static inline void IWL_DEBUG_LIMIT(int level, const char *fmt, ...) 57static inline void IWL_DEBUG_LIMIT(int level, const char *fmt, ...)
48{ 58{
49} 59}
60static inline void iwl4965_print_hex_dump(int level, void *p, u32 len)
61{
62}
50#endif /* CONFIG_IWL4965_DEBUG */ 63#endif /* CONFIG_IWL4965_DEBUG */
51 64
65
66
52/* 67/*
53 * To use the debug system; 68 * To use the debug system;
54 * 69 *
@@ -143,6 +158,7 @@ static inline void IWL_DEBUG_LIMIT(int level, const char *fmt, ...)
143 IWL_DEBUG_LIMIT(IWL_DL_ASSOC | IWL_DL_INFO, f, ## a) 158 IWL_DEBUG_LIMIT(IWL_DL_ASSOC | IWL_DL_INFO, f, ## a)
144#define IWL_DEBUG_HT(f, a...) IWL_DEBUG(IWL_DL_HT, f, ## a) 159#define IWL_DEBUG_HT(f, a...) IWL_DEBUG(IWL_DL_HT, f, ## a)
145#define IWL_DEBUG_STATS(f, a...) IWL_DEBUG(IWL_DL_STATS, f, ## a) 160#define IWL_DEBUG_STATS(f, a...) IWL_DEBUG(IWL_DL_STATS, f, ## a)
161#define IWL_DEBUG_STATS_LIMIT(f, a...) IWL_DEBUG_LIMIT(IWL_DL_STATS, f, ## a)
146#define IWL_DEBUG_TX_REPLY(f, a...) IWL_DEBUG(IWL_DL_TX_REPLY, f, ## a) 162#define IWL_DEBUG_TX_REPLY(f, a...) IWL_DEBUG(IWL_DL_TX_REPLY, f, ## a)
147#define IWL_DEBUG_QOS(f, a...) IWL_DEBUG(IWL_DL_QOS, f, ## a) 163#define IWL_DEBUG_QOS(f, a...) IWL_DEBUG(IWL_DL_QOS, f, ## a)
148#define IWL_DEBUG_RADIO(f, a...) IWL_DEBUG(IWL_DL_RADIO, f, ## a) 164#define IWL_DEBUG_RADIO(f, a...) IWL_DEBUG(IWL_DL_RADIO, f, ## a)
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
index 46d85fd07faa..cf7b569a2229 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
@@ -570,7 +570,7 @@ static int rs_get_tbl_info_from_mcs(const struct iwl4965_rate *mcs_rate,
570 int index; 570 int index;
571 u32 ant_msk; 571 u32 ant_msk;
572 572
573 index = iwl4965_rate_index_from_plcp(mcs_rate->rate_n_flags); 573 index = iwl4965_hwrate_to_plcp_idx(mcs_rate->rate_n_flags);
574 574
575 if (index == IWL_RATE_INVALID) { 575 if (index == IWL_RATE_INVALID) {
576 *rate_idx = -1; 576 *rate_idx = -1;
@@ -1921,7 +1921,7 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv,
1921 tbl = &(lq_sta->lq_info[active_tbl]); 1921 tbl = &(lq_sta->lq_info[active_tbl]);
1922 1922
1923 /* Revert to "active" rate and throughput info */ 1923 /* Revert to "active" rate and throughput info */
1924 index = iwl4965_rate_index_from_plcp( 1924 index = iwl4965_hwrate_to_plcp_idx(
1925 tbl->current_rate.rate_n_flags); 1925 tbl->current_rate.rate_n_flags);
1926 current_tpt = lq_sta->last_tpt; 1926 current_tpt = lq_sta->last_tpt;
1927 1927
@@ -2077,7 +2077,7 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv,
2077 rs_rate_scale_clear_window(&(tbl->win[i])); 2077 rs_rate_scale_clear_window(&(tbl->win[i]));
2078 2078
2079 /* Use new "search" start rate */ 2079 /* Use new "search" start rate */
2080 index = iwl4965_rate_index_from_plcp( 2080 index = iwl4965_hwrate_to_plcp_idx(
2081 tbl->current_rate.rate_n_flags); 2081 tbl->current_rate.rate_n_flags);
2082 2082
2083 IWL_DEBUG_HT("Switch current mcs: %X index: %d\n", 2083 IWL_DEBUG_HT("Switch current mcs: %X index: %d\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.h b/drivers/net/wireless/iwlwifi/iwl-4965-rs.h
index 13b6c72eeb73..911f21396fd0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.h
@@ -259,7 +259,7 @@ static inline u8 iwl4965_get_prev_ieee_rate(u8 rate_index)
259 return rate; 259 return rate;
260} 260}
261 261
262extern int iwl4965_rate_index_from_plcp(int plcp); 262extern int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags);
263 263
264/** 264/**
265 * iwl4965_fill_rs_info - Fill an output text buffer with the rate representation 265 * iwl4965_fill_rs_info - Fill an output text buffer with the rate representation
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index a9c30bcb65b8..8b9c419e094e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -122,6 +122,35 @@ static u8 is_single_stream(struct iwl4965_priv *priv)
122 return 0; 122 return 0;
123} 123}
124 124
125int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags)
126{
127 int idx = 0;
128
129 /* 4965 HT rate format */
130 if (rate_n_flags & RATE_MCS_HT_MSK) {
131 idx = (rate_n_flags & 0xff);
132
133 if (idx >= IWL_RATE_MIMO_6M_PLCP)
134 idx = idx - IWL_RATE_MIMO_6M_PLCP;
135
136 idx += IWL_FIRST_OFDM_RATE;
137 /* skip 9M not supported in ht*/
138 if (idx >= IWL_RATE_9M_INDEX)
139 idx += 1;
140 if ((idx >= IWL_FIRST_OFDM_RATE) && (idx <= IWL_LAST_OFDM_RATE))
141 return idx;
142
143 /* 4965 legacy rate format, search for match in table */
144 } else {
145 for (idx = 0; idx < ARRAY_SIZE(iwl4965_rates); idx++)
146 if (iwl4965_rates[idx].plcp == (rate_n_flags & 0xFF))
147 return idx;
148 }
149
150 return -1;
151}
152
153
125/* 154/*
126 * Determine how many receiver/antenna chains to use. 155 * Determine how many receiver/antenna chains to use.
127 * More provides better reception via diversity. Fewer saves power. 156 * More provides better reception via diversity. Fewer saves power.
@@ -3523,6 +3552,160 @@ static void iwl4965_update_ps_mode(struct iwl4965_priv *priv, u16 ps_bit, u8 *ad
3523 } 3552 }
3524 } 3553 }
3525} 3554}
3555#ifdef CONFIG_IWL4965_DEBUG
3556
3557/**
3558 * iwl4965_dbg_report_frame - dump frame to syslog during debug sessions
3559 *
3560 * You may hack this function to show different aspects of received frames,
3561 * including selective frame dumps.
3562 * group100 parameter selects whether to show 1 out of 100 good frames.
3563 *
3564 * TODO: This was originally written for 3945, need to audit for
3565 * proper operation with 4965.
3566 */
3567static void iwl4965_dbg_report_frame(struct iwl4965_priv *priv,
3568 struct iwl4965_rx_packet *pkt,
3569 struct ieee80211_hdr *header, int group100)
3570{
3571 u32 to_us;
3572 u32 print_summary = 0;
3573 u32 print_dump = 0; /* set to 1 to dump all frames' contents */
3574 u32 hundred = 0;
3575 u32 dataframe = 0;
3576 u16 fc;
3577 u16 seq_ctl;
3578 u16 channel;
3579 u16 phy_flags;
3580 int rate_sym;
3581 u16 length;
3582 u16 status;
3583 u16 bcn_tmr;
3584 u32 tsf_low;
3585 u64 tsf;
3586 u8 rssi;
3587 u8 agc;
3588 u16 sig_avg;
3589 u16 noise_diff;
3590 struct iwl4965_rx_frame_stats *rx_stats = IWL_RX_STATS(pkt);
3591 struct iwl4965_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt);
3592 struct iwl4965_rx_frame_end *rx_end = IWL_RX_END(pkt);
3593 u8 *data = IWL_RX_DATA(pkt);
3594
3595 if (likely(!(iwl4965_debug_level & IWL_DL_RX)))
3596 return;
3597
3598 /* MAC header */
3599 fc = le16_to_cpu(header->frame_control);
3600 seq_ctl = le16_to_cpu(header->seq_ctrl);
3601
3602 /* metadata */
3603 channel = le16_to_cpu(rx_hdr->channel);
3604 phy_flags = le16_to_cpu(rx_hdr->phy_flags);
3605 rate_sym = rx_hdr->rate;
3606 length = le16_to_cpu(rx_hdr->len);
3607
3608 /* end-of-frame status and timestamp */
3609 status = le32_to_cpu(rx_end->status);
3610 bcn_tmr = le32_to_cpu(rx_end->beacon_timestamp);
3611 tsf_low = le64_to_cpu(rx_end->timestamp) & 0x0ffffffff;
3612 tsf = le64_to_cpu(rx_end->timestamp);
3613
3614 /* signal statistics */
3615 rssi = rx_stats->rssi;
3616 agc = rx_stats->agc;
3617 sig_avg = le16_to_cpu(rx_stats->sig_avg);
3618 noise_diff = le16_to_cpu(rx_stats->noise_diff);
3619
3620 to_us = !compare_ether_addr(header->addr1, priv->mac_addr);
3621
3622 /* if data frame is to us and all is good,
3623 * (optionally) print summary for only 1 out of every 100 */
3624 if (to_us && (fc & ~IEEE80211_FCTL_PROTECTED) ==
3625 (IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) {
3626 dataframe = 1;
3627 if (!group100)
3628 print_summary = 1; /* print each frame */
3629 else if (priv->framecnt_to_us < 100) {
3630 priv->framecnt_to_us++;
3631 print_summary = 0;
3632 } else {
3633 priv->framecnt_to_us = 0;
3634 print_summary = 1;
3635 hundred = 1;
3636 }
3637 } else {
3638 /* print summary for all other frames */
3639 print_summary = 1;
3640 }
3641
3642 if (print_summary) {
3643 char *title;
3644 int rate_idx;
3645 u32 bitrate;
3646
3647 if (hundred)
3648 title = "100Frames";
3649 else if (fc & IEEE80211_FCTL_RETRY)
3650 title = "Retry";
3651 else if (ieee80211_is_assoc_response(fc))
3652 title = "AscRsp";
3653 else if (ieee80211_is_reassoc_response(fc))
3654 title = "RasRsp";
3655 else if (ieee80211_is_probe_response(fc)) {
3656 title = "PrbRsp";
3657 print_dump = 1; /* dump frame contents */
3658 } else if (ieee80211_is_beacon(fc)) {
3659 title = "Beacon";
3660 print_dump = 1; /* dump frame contents */
3661 } else if (ieee80211_is_atim(fc))
3662 title = "ATIM";
3663 else if (ieee80211_is_auth(fc))
3664 title = "Auth";
3665 else if (ieee80211_is_deauth(fc))
3666 title = "DeAuth";
3667 else if (ieee80211_is_disassoc(fc))
3668 title = "DisAssoc";
3669 else
3670 title = "Frame";
3671
3672 rate_idx = iwl4965_hwrate_to_plcp_idx(rate_sym);
3673 if (unlikely(rate_idx == -1))
3674 bitrate = 0;
3675 else
3676 bitrate = iwl4965_rates[rate_idx].ieee / 2;
3677
3678 /* print frame summary.
3679 * MAC addresses show just the last byte (for brevity),
3680 * but you can hack it to show more, if you'd like to. */
3681 if (dataframe)
3682 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, "
3683 "len=%u, rssi=%d, chnl=%d, rate=%u, \n",
3684 title, fc, header->addr1[5],
3685 length, rssi, channel, bitrate);
3686 else {
3687 /* src/dst addresses assume managed mode */
3688 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, "
3689 "src=0x%02x, rssi=%u, tim=%lu usec, "
3690 "phy=0x%02x, chnl=%d\n",
3691 title, fc, header->addr1[5],
3692 header->addr3[5], rssi,
3693 tsf_low - priv->scan_start_tsf,
3694 phy_flags, channel);
3695 }
3696 }
3697 if (print_dump)
3698 iwl4965_print_hex_dump(IWL_DL_RX, data, length);
3699}
3700#else
3701static inline void iwl4965_dbg_report_frame(struct iwl4965_priv *priv,
3702 struct iwl4965_rx_packet *pkt,
3703 struct ieee80211_hdr *header,
3704 int group100)
3705{
3706}
3707#endif
3708
3526 3709
3527#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) 3710#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
3528 3711
@@ -3531,6 +3714,8 @@ static void iwl4965_update_ps_mode(struct iwl4965_priv *priv, u16 ps_bit, u8 *ad
3531static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv, 3714static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv,
3532 struct iwl4965_rx_mem_buffer *rxb) 3715 struct iwl4965_rx_mem_buffer *rxb)
3533{ 3716{
3717 struct ieee80211_hdr *header;
3718 struct ieee80211_rx_status rx_status;
3534 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data; 3719 struct iwl4965_rx_packet *pkt = (void *)rxb->skb->data;
3535 /* Use phy data (Rx signal strength, etc.) contained within 3720 /* Use phy data (Rx signal strength, etc.) contained within
3536 * this rx packet for legacy frames, 3721 * this rx packet for legacy frames,
@@ -3541,27 +3726,29 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv,
3541 (struct iwl4965_rx_phy_res *)&priv->last_phy_res[1]; 3726 (struct iwl4965_rx_phy_res *)&priv->last_phy_res[1];
3542 __le32 *rx_end; 3727 __le32 *rx_end;
3543 unsigned int len = 0; 3728 unsigned int len = 0;
3544 struct ieee80211_hdr *header;
3545 u16 fc; 3729 u16 fc;
3546 struct ieee80211_rx_status stats = {
3547 .mactime = le64_to_cpu(rx_start->timestamp),
3548 .freq = ieee80211chan2mhz(le16_to_cpu(rx_start->channel)),
3549 .band =
3550 (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
3551 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ,
3552 .antenna = 0,
3553 .rate_idx = iwl4965_rate_index_from_plcp(
3554 le32_to_cpu(rx_start->rate_n_flags)),
3555 .flag = 0,
3556 };
3557 u8 network_packet; 3730 u8 network_packet;
3558 3731
3732 rx_status.mactime = le64_to_cpu(rx_start->timestamp);
3733 rx_status.freq = ieee80211chan2mhz(le16_to_cpu(rx_start->channel));
3734 rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
3735 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
3736 rx_status.rate_idx = iwl4965_hwrate_to_plcp_idx(
3737 le32_to_cpu(rx_start->rate_n_flags));
3738
3739 if (rx_status.band == IEEE80211_BAND_5GHZ)
3740 rx_status.rate_idx -= IWL_FIRST_OFDM_RATE;
3741
3742 rx_status.antenna = 0;
3743 rx_status.flag = 0;
3744
3559 if ((unlikely(rx_start->cfg_phy_cnt > 20))) { 3745 if ((unlikely(rx_start->cfg_phy_cnt > 20))) {
3560 IWL_DEBUG_DROP 3746 IWL_DEBUG_DROP
3561 ("dsp size out of range [0,20]: " 3747 ("dsp size out of range [0,20]: "
3562 "%d/n", rx_start->cfg_phy_cnt); 3748 "%d/n", rx_start->cfg_phy_cnt);
3563 return; 3749 return;
3564 } 3750 }
3751
3565 if (!include_phy) { 3752 if (!include_phy) {
3566 if (priv->last_phy_res[0]) 3753 if (priv->last_phy_res[0])
3567 rx_start = (struct iwl4965_rx_phy_res *) 3754 rx_start = (struct iwl4965_rx_phy_res *)
@@ -3580,7 +3767,7 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv,
3580 + rx_start->cfg_phy_cnt); 3767 + rx_start->cfg_phy_cnt);
3581 3768
3582 len = le16_to_cpu(rx_start->byte_count); 3769 len = le16_to_cpu(rx_start->byte_count);
3583 rx_end = (__le32 *) (pkt->u.raw + rx_start->cfg_phy_cnt + 3770 rx_end = (__le32 *)(pkt->u.raw + rx_start->cfg_phy_cnt +
3584 sizeof(struct iwl4965_rx_phy_res) + len); 3771 sizeof(struct iwl4965_rx_phy_res) + len);
3585 } else { 3772 } else {
3586 struct iwl4965_rx_mpdu_res_start *amsdu = 3773 struct iwl4965_rx_mpdu_res_start *amsdu =
@@ -3603,7 +3790,7 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv,
3603 priv->ucode_beacon_time = le32_to_cpu(rx_start->beacon_time_stamp); 3790 priv->ucode_beacon_time = le32_to_cpu(rx_start->beacon_time_stamp);
3604 3791
3605 /* Find max signal strength (dBm) among 3 antenna/receiver chains */ 3792 /* Find max signal strength (dBm) among 3 antenna/receiver chains */
3606 stats.ssi = iwl4965_calc_rssi(rx_start); 3793 rx_status.ssi = iwl4965_calc_rssi(rx_start);
3607 3794
3608 /* Meaningful noise values are available only from beacon statistics, 3795 /* Meaningful noise values are available only from beacon statistics,
3609 * which are gathered only when associated, and indicate noise 3796 * which are gathered only when associated, and indicate noise
@@ -3611,32 +3798,29 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv,
3611 * Ignore these noise values while scanning (other channels) */ 3798 * Ignore these noise values while scanning (other channels) */
3612 if (iwl4965_is_associated(priv) && 3799 if (iwl4965_is_associated(priv) &&
3613 !test_bit(STATUS_SCANNING, &priv->status)) { 3800 !test_bit(STATUS_SCANNING, &priv->status)) {
3614 stats.noise = priv->last_rx_noise; 3801 rx_status.noise = priv->last_rx_noise;
3615 stats.signal = iwl4965_calc_sig_qual(stats.ssi, stats.noise); 3802 rx_status.signal = iwl4965_calc_sig_qual(rx_status.ssi,
3803 rx_status.noise);
3616 } else { 3804 } else {
3617 stats.noise = IWL_NOISE_MEAS_NOT_AVAILABLE; 3805 rx_status.noise = IWL_NOISE_MEAS_NOT_AVAILABLE;
3618 stats.signal = iwl4965_calc_sig_qual(stats.ssi, 0); 3806 rx_status.signal = iwl4965_calc_sig_qual(rx_status.ssi, 0);
3619 } 3807 }
3620 3808
3621 /* Reset beacon noise level if not associated. */ 3809 /* Reset beacon noise level if not associated. */
3622 if (!iwl4965_is_associated(priv)) 3810 if (!iwl4965_is_associated(priv))
3623 priv->last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE; 3811 priv->last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE;
3624 3812
3625#ifdef CONFIG_IWL4965_DEBUG 3813 /* Set "1" to report good data frames in groups of 100 */
3626 /* TODO: Parts of iwl4965_report_frame are broken for 4965 */ 3814 /* FIXME: need to optimze the call: */
3627 if (iwl4965_debug_level & (IWL_DL_RX)) 3815 iwl4965_dbg_report_frame(priv, pkt, header, 1);
3628 /* Set "1" to report good data frames in groups of 100 */ 3816
3629 iwl4965_report_frame(priv, pkt, header, 1); 3817 IWL_DEBUG_STATS_LIMIT("Rssi %d, noise %d, qual %d, TSF %llu\n",
3630 3818 rx_status.ssi, rx_status.noise, rx_status.signal,
3631 if (iwl4965_debug_level & (IWL_DL_RX | IWL_DL_STATS)) 3819 rx_status.mactime);
3632 IWL_DEBUG_RX("Rssi %d, noise %d, qual %d, TSF %lu\n",
3633 stats.ssi, stats.noise, stats.signal,
3634 (long unsigned int)le64_to_cpu(rx_start->timestamp));
3635#endif
3636 3820
3637 network_packet = iwl4965_is_network_packet(priv, header); 3821 network_packet = iwl4965_is_network_packet(priv, header);
3638 if (network_packet) { 3822 if (network_packet) {
3639 priv->last_rx_rssi = stats.ssi; 3823 priv->last_rx_rssi = rx_status.ssi;
3640 priv->last_beacon_time = priv->ucode_beacon_time; 3824 priv->last_beacon_time = priv->ucode_beacon_time;
3641 priv->last_tsf = le64_to_cpu(rx_start->timestamp); 3825 priv->last_tsf = le64_to_cpu(rx_start->timestamp);
3642 } 3826 }
@@ -3739,7 +3923,7 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv,
3739 return; 3923 return;
3740 } 3924 }
3741 } 3925 }
3742 iwl4965_handle_data_packet(priv, 0, include_phy, rxb, &stats); 3926 iwl4965_handle_data_packet(priv, 0, include_phy, rxb, &rx_status);
3743 break; 3927 break;
3744 3928
3745 case IEEE80211_FTYPE_CTL: 3929 case IEEE80211_FTYPE_CTL:
@@ -3748,7 +3932,7 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv,
3748 case IEEE80211_STYPE_BACK_REQ: 3932 case IEEE80211_STYPE_BACK_REQ:
3749 IWL_DEBUG_HT("IEEE80211_STYPE_BACK_REQ arrived\n"); 3933 IWL_DEBUG_HT("IEEE80211_STYPE_BACK_REQ arrived\n");
3750 iwl4965_handle_data_packet(priv, 0, include_phy, 3934 iwl4965_handle_data_packet(priv, 0, include_phy,
3751 rxb, &stats); 3935 rxb, &rx_status);
3752 break; 3936 break;
3753 default: 3937 default:
3754 break; 3938 break;
@@ -3778,7 +3962,7 @@ static void iwl4965_rx_reply_rx(struct iwl4965_priv *priv,
3778 print_mac(mac3, header->addr3)); 3962 print_mac(mac3, header->addr3));
3779 else 3963 else
3780 iwl4965_handle_data_packet(priv, 1, include_phy, rxb, 3964 iwl4965_handle_data_packet(priv, 1, include_phy, rxb,
3781 &stats); 3965 &rx_status);
3782 break; 3966 break;
3783 } 3967 }
3784 default: 3968 default:
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.h b/drivers/net/wireless/iwlwifi/iwl-4965.h
index cc0745bfd1fb..4b3def31a9c1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.h
@@ -633,16 +633,6 @@ extern int iwl4965_is_network_packet(struct iwl4965_priv *priv,
633 struct ieee80211_hdr *header); 633 struct ieee80211_hdr *header);
634extern int iwl4965_power_init_handle(struct iwl4965_priv *priv); 634extern int iwl4965_power_init_handle(struct iwl4965_priv *priv);
635extern int iwl4965_eeprom_init(struct iwl4965_priv *priv); 635extern int iwl4965_eeprom_init(struct iwl4965_priv *priv);
636#ifdef CONFIG_IWL4965_DEBUG
637extern void iwl4965_report_frame(struct iwl4965_priv *priv,
638 struct iwl4965_rx_packet *pkt,
639 struct ieee80211_hdr *header, int group100);
640#else
641static inline void iwl4965_report_frame(struct iwl4965_priv *priv,
642 struct iwl4965_rx_packet *pkt,
643 struct ieee80211_hdr *header,
644 int group100) {}
645#endif
646extern void iwl4965_handle_data_packet_monitor(struct iwl4965_priv *priv, 636extern void iwl4965_handle_data_packet_monitor(struct iwl4965_priv *priv,
647 struct iwl4965_rx_mem_buffer *rxb, 637 struct iwl4965_rx_mem_buffer *rxb,
648 void *data, short len, 638 void *data, short len,
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 0cafbd42d84c..7a72048b0f42 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -162,17 +162,6 @@ static const char *iwl3945_escape_essid(const char *essid, u8 essid_len)
162 return escaped; 162 return escaped;
163} 163}
164 164
165static void iwl3945_print_hex_dump(int level, void *p, u32 len)
166{
167#ifdef CONFIG_IWL3945_DEBUG
168 if (!(iwl3945_debug_level & level))
169 return;
170
171 print_hex_dump(KERN_DEBUG, "iwl data: ", DUMP_PREFIX_OFFSET, 16, 1,
172 p, len, 1);
173#endif
174}
175
176/*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** 165/*************** DMA-QUEUE-GENERAL-FUNCTIONS *****
177 * DMA services 166 * DMA services
178 * 167 *
@@ -1630,151 +1619,6 @@ int iwl3945_eeprom_init(struct iwl3945_priv *priv)
1630 return 0; 1619 return 0;
1631} 1620}
1632 1621
1633/******************************************************************************
1634 *
1635 * Misc. internal state and helper functions
1636 *
1637 ******************************************************************************/
1638#ifdef CONFIG_IWL3945_DEBUG
1639
1640/**
1641 * iwl3945_report_frame - dump frame to syslog during debug sessions
1642 *
1643 * You may hack this function to show different aspects of received frames,
1644 * including selective frame dumps.
1645 * group100 parameter selects whether to show 1 out of 100 good frames.
1646 */
1647void iwl3945_report_frame(struct iwl3945_priv *priv,
1648 struct iwl3945_rx_packet *pkt,
1649 struct ieee80211_hdr *header, int group100)
1650{
1651 u32 to_us;
1652 u32 print_summary = 0;
1653 u32 print_dump = 0; /* set to 1 to dump all frames' contents */
1654 u32 hundred = 0;
1655 u32 dataframe = 0;
1656 u16 fc;
1657 u16 seq_ctl;
1658 u16 channel;
1659 u16 phy_flags;
1660 int rate_sym;
1661 u16 length;
1662 u16 status;
1663 u16 bcn_tmr;
1664 u32 tsf_low;
1665 u64 tsf;
1666 u8 rssi;
1667 u8 agc;
1668 u16 sig_avg;
1669 u16 noise_diff;
1670 struct iwl3945_rx_frame_stats *rx_stats = IWL_RX_STATS(pkt);
1671 struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt);
1672 struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt);
1673 u8 *data = IWL_RX_DATA(pkt);
1674
1675 /* MAC header */
1676 fc = le16_to_cpu(header->frame_control);
1677 seq_ctl = le16_to_cpu(header->seq_ctrl);
1678
1679 /* metadata */
1680 channel = le16_to_cpu(rx_hdr->channel);
1681 phy_flags = le16_to_cpu(rx_hdr->phy_flags);
1682 rate_sym = rx_hdr->rate;
1683 length = le16_to_cpu(rx_hdr->len);
1684
1685 /* end-of-frame status and timestamp */
1686 status = le32_to_cpu(rx_end->status);
1687 bcn_tmr = le32_to_cpu(rx_end->beacon_timestamp);
1688 tsf_low = le64_to_cpu(rx_end->timestamp) & 0x0ffffffff;
1689 tsf = le64_to_cpu(rx_end->timestamp);
1690
1691 /* signal statistics */
1692 rssi = rx_stats->rssi;
1693 agc = rx_stats->agc;
1694 sig_avg = le16_to_cpu(rx_stats->sig_avg);
1695 noise_diff = le16_to_cpu(rx_stats->noise_diff);
1696
1697 to_us = !compare_ether_addr(header->addr1, priv->mac_addr);
1698
1699 /* if data frame is to us and all is good,
1700 * (optionally) print summary for only 1 out of every 100 */
1701 if (to_us && (fc & ~IEEE80211_FCTL_PROTECTED) ==
1702 (IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) {
1703 dataframe = 1;
1704 if (!group100)
1705 print_summary = 1; /* print each frame */
1706 else if (priv->framecnt_to_us < 100) {
1707 priv->framecnt_to_us++;
1708 print_summary = 0;
1709 } else {
1710 priv->framecnt_to_us = 0;
1711 print_summary = 1;
1712 hundred = 1;
1713 }
1714 } else {
1715 /* print summary for all other frames */
1716 print_summary = 1;
1717 }
1718
1719 if (print_summary) {
1720 char *title;
1721 u32 rate;
1722
1723 if (hundred)
1724 title = "100Frames";
1725 else if (fc & IEEE80211_FCTL_RETRY)
1726 title = "Retry";
1727 else if (ieee80211_is_assoc_response(fc))
1728 title = "AscRsp";
1729 else if (ieee80211_is_reassoc_response(fc))
1730 title = "RasRsp";
1731 else if (ieee80211_is_probe_response(fc)) {
1732 title = "PrbRsp";
1733 print_dump = 1; /* dump frame contents */
1734 } else if (ieee80211_is_beacon(fc)) {
1735 title = "Beacon";
1736 print_dump = 1; /* dump frame contents */
1737 } else if (ieee80211_is_atim(fc))
1738 title = "ATIM";
1739 else if (ieee80211_is_auth(fc))
1740 title = "Auth";
1741 else if (ieee80211_is_deauth(fc))
1742 title = "DeAuth";
1743 else if (ieee80211_is_disassoc(fc))
1744 title = "DisAssoc";
1745 else
1746 title = "Frame";
1747
1748 rate = iwl3945_rate_index_from_plcp(rate_sym);
1749 if (rate == -1)
1750 rate = 0;
1751 else
1752 rate = iwl3945_rates[rate].ieee / 2;
1753
1754 /* print frame summary.
1755 * MAC addresses show just the last byte (for brevity),
1756 * but you can hack it to show more, if you'd like to. */
1757 if (dataframe)
1758 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, "
1759 "len=%u, rssi=%d, chnl=%d, rate=%u, \n",
1760 title, fc, header->addr1[5],
1761 length, rssi, channel, rate);
1762 else {
1763 /* src/dst addresses assume managed mode */
1764 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, "
1765 "src=0x%02x, rssi=%u, tim=%lu usec, "
1766 "phy=0x%02x, chnl=%d\n",
1767 title, fc, header->addr1[5],
1768 header->addr3[5], rssi,
1769 tsf_low - priv->scan_start_tsf,
1770 phy_flags, channel);
1771 }
1772 }
1773 if (print_dump)
1774 iwl3945_print_hex_dump(IWL_DL_RX, data, length);
1775}
1776#endif
1777
1778static void iwl3945_unset_hw_setting(struct iwl3945_priv *priv) 1622static void iwl3945_unset_hw_setting(struct iwl3945_priv *priv)
1779{ 1623{
1780 if (priv->hw_setting.shared_virt) 1624 if (priv->hw_setting.shared_virt)
@@ -7895,31 +7739,6 @@ static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR,
7895 show_measurement, store_measurement); 7739 show_measurement, store_measurement);
7896#endif /* CONFIG_IWL3945_SPECTRUM_MEASUREMENT */ 7740#endif /* CONFIG_IWL3945_SPECTRUM_MEASUREMENT */
7897 7741
7898static ssize_t show_rate(struct device *d,
7899 struct device_attribute *attr, char *buf)
7900{
7901 struct iwl3945_priv *priv = dev_get_drvdata(d);
7902 unsigned long flags;
7903 int i;
7904
7905 spin_lock_irqsave(&priv->sta_lock, flags);
7906 if (priv->iw_mode == IEEE80211_IF_TYPE_STA)
7907 i = priv->stations[IWL_AP_ID].current_rate.s.rate;
7908 else
7909 i = priv->stations[IWL_STA_ID].current_rate.s.rate;
7910 spin_unlock_irqrestore(&priv->sta_lock, flags);
7911
7912 i = iwl3945_rate_index_from_plcp(i);
7913 if (i == -1)
7914 return sprintf(buf, "0\n");
7915
7916 return sprintf(buf, "%d%s\n",
7917 (iwl3945_rates[i].ieee >> 1),
7918 (iwl3945_rates[i].ieee & 0x1) ? ".5" : "");
7919}
7920
7921static DEVICE_ATTR(rate, S_IRUSR, show_rate, NULL);
7922
7923static ssize_t store_retry_rate(struct device *d, 7742static ssize_t store_retry_rate(struct device *d,
7924 struct device_attribute *attr, 7743 struct device_attribute *attr,
7925 const char *buf, size_t count) 7744 const char *buf, size_t count)
@@ -8210,7 +8029,6 @@ static struct attribute *iwl3945_sysfs_entries[] = {
8210 &dev_attr_measurement.attr, 8029 &dev_attr_measurement.attr,
8211#endif 8030#endif
8212 &dev_attr_power_level.attr, 8031 &dev_attr_power_level.attr,
8213 &dev_attr_rate.attr,
8214 &dev_attr_retry_rate.attr, 8032 &dev_attr_retry_rate.attr,
8215 &dev_attr_rf_kill.attr, 8033 &dev_attr_rf_kill.attr,
8216 &dev_attr_rs_window.attr, 8034 &dev_attr_rs_window.attr,
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 46a43ff51526..2ed69376c96e 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -161,17 +161,6 @@ static const char *iwl4965_escape_essid(const char *essid, u8 essid_len)
161 return escaped; 161 return escaped;
162} 162}
163 163
164static void iwl4965_print_hex_dump(int level, void *p, u32 len)
165{
166#ifdef CONFIG_IWL4965_DEBUG
167 if (!(iwl4965_debug_level & level))
168 return;
169
170 print_hex_dump(KERN_DEBUG, "iwl data: ", DUMP_PREFIX_OFFSET, 16, 1,
171 p, len, 1);
172#endif
173}
174
175/*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** 164/*************** DMA-QUEUE-GENERAL-FUNCTIONS *****
176 * DMA services 165 * DMA services
177 * 166 *
@@ -1551,34 +1540,6 @@ unsigned int iwl4965_fill_beacon_frame(struct iwl4965_priv *priv,
1551 return priv->ibss_beacon->len; 1540 return priv->ibss_beacon->len;
1552} 1541}
1553 1542
1554int iwl4965_rate_index_from_plcp(int plcp)
1555{
1556 int i = 0;
1557
1558 /* 4965 HT rate format */
1559 if (plcp & RATE_MCS_HT_MSK) {
1560 i = (plcp & 0xff);
1561
1562 if (i >= IWL_RATE_MIMO_6M_PLCP)
1563 i = i - IWL_RATE_MIMO_6M_PLCP;
1564
1565 i += IWL_FIRST_OFDM_RATE;
1566 /* skip 9M not supported in ht*/
1567 if (i >= IWL_RATE_9M_INDEX)
1568 i += 1;
1569 if ((i >= IWL_FIRST_OFDM_RATE) &&
1570 (i <= IWL_LAST_OFDM_RATE))
1571 return i;
1572
1573 /* 4965 legacy rate format, search for match in table */
1574 } else {
1575 for (i = 0; i < ARRAY_SIZE(iwl4965_rates); i++)
1576 if (iwl4965_rates[i].plcp == (plcp &0xFF))
1577 return i;
1578 }
1579 return -1;
1580}
1581
1582static u8 iwl4965_rate_get_lowest_plcp(int rate_mask) 1543static u8 iwl4965_rate_get_lowest_plcp(int rate_mask)
1583{ 1544{
1584 u8 i; 1545 u8 i;
@@ -1712,148 +1673,6 @@ done:
1712 * Misc. internal state and helper functions 1673 * Misc. internal state and helper functions
1713 * 1674 *
1714 ******************************************************************************/ 1675 ******************************************************************************/
1715#ifdef CONFIG_IWL4965_DEBUG
1716
1717/**
1718 * iwl4965_report_frame - dump frame to syslog during debug sessions
1719 *
1720 * You may hack this function to show different aspects of received frames,
1721 * including selective frame dumps.
1722 * group100 parameter selects whether to show 1 out of 100 good frames.
1723 *
1724 * TODO: This was originally written for 3945, need to audit for
1725 * proper operation with 4965.
1726 */
1727void iwl4965_report_frame(struct iwl4965_priv *priv,
1728 struct iwl4965_rx_packet *pkt,
1729 struct ieee80211_hdr *header, int group100)
1730{
1731 u32 to_us;
1732 u32 print_summary = 0;
1733 u32 print_dump = 0; /* set to 1 to dump all frames' contents */
1734 u32 hundred = 0;
1735 u32 dataframe = 0;
1736 u16 fc;
1737 u16 seq_ctl;
1738 u16 channel;
1739 u16 phy_flags;
1740 int rate_sym;
1741 u16 length;
1742 u16 status;
1743 u16 bcn_tmr;
1744 u32 tsf_low;
1745 u64 tsf;
1746 u8 rssi;
1747 u8 agc;
1748 u16 sig_avg;
1749 u16 noise_diff;
1750 struct iwl4965_rx_frame_stats *rx_stats = IWL_RX_STATS(pkt);
1751 struct iwl4965_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt);
1752 struct iwl4965_rx_frame_end *rx_end = IWL_RX_END(pkt);
1753 u8 *data = IWL_RX_DATA(pkt);
1754
1755 /* MAC header */
1756 fc = le16_to_cpu(header->frame_control);
1757 seq_ctl = le16_to_cpu(header->seq_ctrl);
1758
1759 /* metadata */
1760 channel = le16_to_cpu(rx_hdr->channel);
1761 phy_flags = le16_to_cpu(rx_hdr->phy_flags);
1762 rate_sym = rx_hdr->rate;
1763 length = le16_to_cpu(rx_hdr->len);
1764
1765 /* end-of-frame status and timestamp */
1766 status = le32_to_cpu(rx_end->status);
1767 bcn_tmr = le32_to_cpu(rx_end->beacon_timestamp);
1768 tsf_low = le64_to_cpu(rx_end->timestamp) & 0x0ffffffff;
1769 tsf = le64_to_cpu(rx_end->timestamp);
1770
1771 /* signal statistics */
1772 rssi = rx_stats->rssi;
1773 agc = rx_stats->agc;
1774 sig_avg = le16_to_cpu(rx_stats->sig_avg);
1775 noise_diff = le16_to_cpu(rx_stats->noise_diff);
1776
1777 to_us = !compare_ether_addr(header->addr1, priv->mac_addr);
1778
1779 /* if data frame is to us and all is good,
1780 * (optionally) print summary for only 1 out of every 100 */
1781 if (to_us && (fc & ~IEEE80211_FCTL_PROTECTED) ==
1782 (IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) {
1783 dataframe = 1;
1784 if (!group100)
1785 print_summary = 1; /* print each frame */
1786 else if (priv->framecnt_to_us < 100) {
1787 priv->framecnt_to_us++;
1788 print_summary = 0;
1789 } else {
1790 priv->framecnt_to_us = 0;
1791 print_summary = 1;
1792 hundred = 1;
1793 }
1794 } else {
1795 /* print summary for all other frames */
1796 print_summary = 1;
1797 }
1798
1799 if (print_summary) {
1800 char *title;
1801 u32 rate;
1802
1803 if (hundred)
1804 title = "100Frames";
1805 else if (fc & IEEE80211_FCTL_RETRY)
1806 title = "Retry";
1807 else if (ieee80211_is_assoc_response(fc))
1808 title = "AscRsp";
1809 else if (ieee80211_is_reassoc_response(fc))
1810 title = "RasRsp";
1811 else if (ieee80211_is_probe_response(fc)) {
1812 title = "PrbRsp";
1813 print_dump = 1; /* dump frame contents */
1814 } else if (ieee80211_is_beacon(fc)) {
1815 title = "Beacon";
1816 print_dump = 1; /* dump frame contents */
1817 } else if (ieee80211_is_atim(fc))
1818 title = "ATIM";
1819 else if (ieee80211_is_auth(fc))
1820 title = "Auth";
1821 else if (ieee80211_is_deauth(fc))
1822 title = "DeAuth";
1823 else if (ieee80211_is_disassoc(fc))
1824 title = "DisAssoc";
1825 else
1826 title = "Frame";
1827
1828 rate = iwl4965_rate_index_from_plcp(rate_sym);
1829 if (rate == -1)
1830 rate = 0;
1831 else
1832 rate = iwl4965_rates[rate].ieee / 2;
1833
1834 /* print frame summary.
1835 * MAC addresses show just the last byte (for brevity),
1836 * but you can hack it to show more, if you'd like to. */
1837 if (dataframe)
1838 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, "
1839 "len=%u, rssi=%d, chnl=%d, rate=%u, \n",
1840 title, fc, header->addr1[5],
1841 length, rssi, channel, rate);
1842 else {
1843 /* src/dst addresses assume managed mode */
1844 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, "
1845 "src=0x%02x, rssi=%u, tim=%lu usec, "
1846 "phy=0x%02x, chnl=%d\n",
1847 title, fc, header->addr1[5],
1848 header->addr3[5], rssi,
1849 tsf_low - priv->scan_start_tsf,
1850 phy_flags, channel);
1851 }
1852 }
1853 if (print_dump)
1854 iwl4965_print_hex_dump(IWL_DL_RX, data, length);
1855}
1856#endif
1857 1676
1858static void iwl4965_unset_hw_setting(struct iwl4965_priv *priv) 1677static void iwl4965_unset_hw_setting(struct iwl4965_priv *priv)
1859{ 1678{