aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEyal Shapira <eyal@wizery.com>2013-11-08 19:11:46 -0500
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>2013-12-09 15:29:02 -0500
commit1a61b3477817e1a1473644b87c9c377dc08f74c4 (patch)
tree6dabb2bedc204fc735ba2a6dd89d082645933a3a
parent6dde8c4837128aa840851bb0b547708868494198 (diff)
iwlwifi: mvm: fix and improve printing of rate scale table
Info about VHT/HT rates wasn't printed properly when dumping the rate scale table. Fix that and print more info. While at it fix some other minor issues in the printing and prevent overflowing the print buffer. Signed-off-by: Eyal Shapira <eyal@wizery.com> Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/rs.c91
1 files changed, 73 insertions, 18 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c
index a0b4cc8d9c3b..f7ac485f85e1 100644
--- a/drivers/net/wireless/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/rs.c
@@ -2566,13 +2566,75 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
2566 return count; 2566 return count;
2567} 2567}
2568 2568
2569static int rs_pretty_print_rate(char *buf, const u32 rate)
2570{
2571 static const char * const ant_name[] = {
2572 [ANT_NONE] = "None",
2573 [ANT_A] = "A",
2574 [ANT_B] = "B",
2575 [ANT_AB] = "AB",
2576 [ANT_C] = "C",
2577 [ANT_AC] = "AC",
2578 [ANT_BC] = "BC",
2579 [ANT_ABC] = "ABC",
2580 };
2581
2582 char *type, *bw;
2583 u8 mcs = 0, nss = 0;
2584 u8 ant = (rate & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS;
2585
2586 if (!(rate & RATE_MCS_HT_MSK) &&
2587 !(rate & RATE_MCS_VHT_MSK)) {
2588 int index = iwl_hwrate_to_plcp_idx(rate);
2589
2590 return sprintf(buf, "Legacy | ANT: %s Rate: %s Mbps\n",
2591 ant_name[ant], iwl_rate_mcs[index].mbps);
2592 }
2593
2594 if (rate & RATE_MCS_VHT_MSK) {
2595 type = "VHT";
2596 mcs = rate & RATE_VHT_MCS_RATE_CODE_MSK;
2597 nss = ((rate & RATE_VHT_MCS_NSS_MSK)
2598 >> RATE_VHT_MCS_NSS_POS) + 1;
2599 } else if (rate & RATE_MCS_HT_MSK) {
2600 type = "HT";
2601 mcs = rate & RATE_HT_MCS_INDEX_MSK;
2602 } else {
2603 type = "Unknown"; /* shouldn't happen */
2604 }
2605
2606 switch (rate & RATE_MCS_CHAN_WIDTH_MSK) {
2607 case RATE_MCS_CHAN_WIDTH_20:
2608 bw = "20Mhz";
2609 break;
2610 case RATE_MCS_CHAN_WIDTH_40:
2611 bw = "40Mhz";
2612 break;
2613 case RATE_MCS_CHAN_WIDTH_80:
2614 bw = "80Mhz";
2615 break;
2616 case RATE_MCS_CHAN_WIDTH_160:
2617 bw = "160Mhz";
2618 break;
2619 default:
2620 bw = "BAD BW";
2621 }
2622
2623 return sprintf(buf, "%s | ANT: %s BW: %s MCS: %d NSS: %d %s%s%s%s%s\n",
2624 type, ant_name[ant], bw, mcs, nss,
2625 (rate & RATE_MCS_SGI_MSK) ? "SGI " : "NGI ",
2626 (rate & RATE_MCS_STBC_MSK) ? "STBC " : "",
2627 (rate & RATE_MCS_LDPC_MSK) ? "LDPC " : "",
2628 (rate & RATE_MCS_BF_MSK) ? "BF " : "",
2629 (rate & RATE_MCS_ZLF_MSK) ? "ZLF " : "");
2630}
2631
2569static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file, 2632static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
2570 char __user *user_buf, size_t count, loff_t *ppos) 2633 char __user *user_buf, size_t count, loff_t *ppos)
2571{ 2634{
2572 char *buff; 2635 char *buff;
2573 int desc = 0; 2636 int desc = 0;
2574 int i = 0; 2637 int i = 0;
2575 int index = 0;
2576 ssize_t ret; 2638 ssize_t ret;
2577 2639
2578 struct iwl_lq_sta *lq_sta = file->private_data; 2640 struct iwl_lq_sta *lq_sta = file->private_data;
@@ -2580,7 +2642,7 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
2580 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); 2642 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
2581 2643
2582 mvm = lq_sta->drv; 2644 mvm = lq_sta->drv;
2583 buff = kmalloc(1024, GFP_KERNEL); 2645 buff = kmalloc(2048, GFP_KERNEL);
2584 if (!buff) 2646 if (!buff)
2585 return -ENOMEM; 2647 return -ENOMEM;
2586 2648
@@ -2597,7 +2659,7 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
2597 desc += sprintf(buff+desc, "lq type %s\n", 2659 desc += sprintf(buff+desc, "lq type %s\n",
2598 (is_legacy(tbl->lq_type)) ? "legacy" : 2660 (is_legacy(tbl->lq_type)) ? "legacy" :
2599 is_vht(tbl->lq_type) ? "VHT" : "HT"); 2661 is_vht(tbl->lq_type) ? "VHT" : "HT");
2600 if (is_ht(tbl->lq_type)) { 2662 if (!is_legacy(tbl->lq_type)) {
2601 desc += sprintf(buff+desc, " %s", 2663 desc += sprintf(buff+desc, " %s",
2602 (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); 2664 (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2");
2603 desc += sprintf(buff+desc, " %s", 2665 desc += sprintf(buff+desc, " %s",
@@ -2605,13 +2667,13 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
2605 (is_ht40(tbl)) ? "40MHz" : 2667 (is_ht40(tbl)) ? "40MHz" :
2606 (is_ht80(tbl)) ? "80Mhz" : "BAD BW"); 2668 (is_ht80(tbl)) ? "80Mhz" : "BAD BW");
2607 desc += sprintf(buff+desc, " %s %s\n", 2669 desc += sprintf(buff+desc, " %s %s\n",
2608 (tbl->is_SGI) ? "SGI" : "", 2670 (tbl->is_SGI) ? "SGI" : "NGI",
2609 (lq_sta->is_agg) ? "AGG on" : ""); 2671 (lq_sta->is_agg) ? "AGG on" : "");
2610 } 2672 }
2611 desc += sprintf(buff+desc, "last tx rate=0x%X\n", 2673 desc += sprintf(buff+desc, "last tx rate=0x%X\n",
2612 lq_sta->last_rate_n_flags); 2674 lq_sta->last_rate_n_flags);
2613 desc += sprintf(buff+desc, 2675 desc += sprintf(buff+desc,
2614 "general: flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", 2676 "general: flags=0x%X mimo-d=%d s-ant=0x%x d-ant=0x%x\n",
2615 lq_sta->lq.flags, 2677 lq_sta->lq.flags,
2616 lq_sta->lq.mimo_delim, 2678 lq_sta->lq.mimo_delim,
2617 lq_sta->lq.single_stream_ant_msk, 2679 lq_sta->lq.single_stream_ant_msk,
@@ -2631,19 +2693,12 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
2631 lq_sta->lq.initial_rate_index[3]); 2693 lq_sta->lq.initial_rate_index[3]);
2632 2694
2633 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { 2695 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
2634 index = iwl_hwrate_to_plcp_idx( 2696 u32 rate = le32_to_cpu(lq_sta->lq.rs_table[i]);
2635 le32_to_cpu(lq_sta->lq.rs_table[i])); 2697 desc += sprintf(buff+desc,
2636 if (is_legacy(tbl->lq_type)) { 2698 " rate[%d] 0x%X ",
2637 desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", 2699 i, rate);
2638 i, le32_to_cpu(lq_sta->lq.rs_table[i]), 2700
2639 iwl_rate_mcs[index].mbps); 2701 desc += rs_pretty_print_rate(buff+desc, rate);
2640 } else {
2641 desc += sprintf(buff+desc,
2642 " rate[%d] 0x%X %smbps (%s)\n",
2643 i, le32_to_cpu(lq_sta->lq.rs_table[i]),
2644 iwl_rate_mcs[index].mbps,
2645 iwl_rate_mcs[index].mcs);
2646 }
2647 } 2702 }
2648 2703
2649 ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); 2704 ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);