aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorEliad Peller <eliad@wizery.com>2014-06-11 08:51:33 -0400
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>2014-07-07 14:41:08 -0400
commitae969afe43273c9bc8d22629efd9c51627837615 (patch)
tree94cbcba9232e7ff4aae63af1c4292614e5dc4dde /drivers/net
parentbdce40f006dc53bfdeeba4a4ff200d4c0cf5aac8 (diff)
iwlwifi: mvm: rs: don't clear persistent fields
iwl_mvm_rs_rate_init() is called multiple times to re-init the rate scaling statistics (e.g. after some idle time). It clears all the lq_sta sta, including some fields that shouldn't be cleared (e.g. debugfs pointers). Fix it by adding a new 'persistent' sub-struct, and avoid clearing it on (re-)init. Move the initialization of the persistent fields to rs_alloc_sta instead. Signed-off-by: Eliad Peller <eliadx.peller@intel.com> Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/rs.c87
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/rs.h24
2 files changed, 59 insertions, 52 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c
index 306a6caa4868..67bd8d79c9d3 100644
--- a/drivers/net/wireless/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/rs.c
@@ -927,7 +927,7 @@ static bool rs_get_lower_rate_in_column(struct iwl_lq_sta *lq_sta,
927 u8 low; 927 u8 low;
928 u16 high_low; 928 u16 high_low;
929 u16 rate_mask; 929 u16 rate_mask;
930 struct iwl_mvm *mvm = lq_sta->drv; 930 struct iwl_mvm *mvm = lq_sta->pers.drv;
931 931
932 rate_mask = rs_get_supported_rates(lq_sta, rate); 932 rate_mask = rs_get_supported_rates(lq_sta, rate);
933 high_low = rs_get_adjacent_rate(mvm, rate->index, rate_mask, 933 high_low = rs_get_adjacent_rate(mvm, rate->index, rate_mask,
@@ -946,7 +946,7 @@ static bool rs_get_lower_rate_in_column(struct iwl_lq_sta *lq_sta,
946static void rs_get_lower_rate_down_column(struct iwl_lq_sta *lq_sta, 946static void rs_get_lower_rate_down_column(struct iwl_lq_sta *lq_sta,
947 struct rs_rate *rate) 947 struct rs_rate *rate)
948{ 948{
949 struct iwl_mvm *mvm = lq_sta->drv; 949 struct iwl_mvm *mvm = lq_sta->pers.drv;
950 950
951 if (is_legacy(rate)) { 951 if (is_legacy(rate)) {
952 /* No column to downgrade from Legacy */ 952 /* No column to downgrade from Legacy */
@@ -1026,14 +1026,14 @@ static void rs_tx_status(void *mvm_r, struct ieee80211_supported_band *sband,
1026 if (!lq_sta) { 1026 if (!lq_sta) {
1027 IWL_DEBUG_RATE(mvm, "Station rate scaling not created yet.\n"); 1027 IWL_DEBUG_RATE(mvm, "Station rate scaling not created yet.\n");
1028 return; 1028 return;
1029 } else if (!lq_sta->drv) { 1029 } else if (!lq_sta->pers.drv) {
1030 IWL_DEBUG_RATE(mvm, "Rate scaling not initialized yet.\n"); 1030 IWL_DEBUG_RATE(mvm, "Rate scaling not initialized yet.\n");
1031 return; 1031 return;
1032 } 1032 }
1033 1033
1034#ifdef CONFIG_MAC80211_DEBUGFS 1034#ifdef CONFIG_MAC80211_DEBUGFS
1035 /* Disable last tx check if we are debugging with fixed rate */ 1035 /* Disable last tx check if we are debugging with fixed rate */
1036 if (lq_sta->dbg_fixed_rate) { 1036 if (lq_sta->pers.dbg_fixed_rate) {
1037 IWL_DEBUG_RATE(mvm, "Fixed rate. avoid rate scaling\n"); 1037 IWL_DEBUG_RATE(mvm, "Fixed rate. avoid rate scaling\n");
1038 return; 1038 return;
1039 } 1039 }
@@ -1405,7 +1405,7 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search)
1405 int flush_interval_passed = 0; 1405 int flush_interval_passed = 0;
1406 struct iwl_mvm *mvm; 1406 struct iwl_mvm *mvm;
1407 1407
1408 mvm = lq_sta->drv; 1408 mvm = lq_sta->pers.drv;
1409 active_tbl = lq_sta->active_tbl; 1409 active_tbl = lq_sta->active_tbl;
1410 1410
1411 tbl = &(lq_sta->lq_info[active_tbl]); 1411 tbl = &(lq_sta->lq_info[active_tbl]);
@@ -1865,11 +1865,11 @@ static bool rs_tpc_perform(struct iwl_mvm *mvm,
1865 int weak_tpt = IWL_INVALID_VALUE, strong_tpt = IWL_INVALID_VALUE; 1865 int weak_tpt = IWL_INVALID_VALUE, strong_tpt = IWL_INVALID_VALUE;
1866 1866
1867#ifdef CONFIG_MAC80211_DEBUGFS 1867#ifdef CONFIG_MAC80211_DEBUGFS
1868 if (lq_sta->dbg_fixed_txp_reduction <= TPC_MAX_REDUCTION) { 1868 if (lq_sta->pers.dbg_fixed_txp_reduction <= TPC_MAX_REDUCTION) {
1869 IWL_DEBUG_RATE(mvm, "fixed tpc: %d\n", 1869 IWL_DEBUG_RATE(mvm, "fixed tpc: %d\n",
1870 lq_sta->dbg_fixed_txp_reduction); 1870 lq_sta->pers.dbg_fixed_txp_reduction);
1871 lq_sta->lq.reduced_tpc = lq_sta->dbg_fixed_txp_reduction; 1871 lq_sta->lq.reduced_tpc = lq_sta->pers.dbg_fixed_txp_reduction;
1872 return cur != lq_sta->dbg_fixed_txp_reduction; 1872 return cur != lq_sta->pers.dbg_fixed_txp_reduction;
1873 } 1873 }
1874#endif 1874#endif
1875 1875
@@ -2382,7 +2382,7 @@ static void rs_get_rate(void *mvm_r, struct ieee80211_sta *sta, void *mvm_sta,
2382 } 2382 }
2383 2383
2384 /* Treat uninitialized rate scaling data same as non-existing. */ 2384 /* Treat uninitialized rate scaling data same as non-existing. */
2385 if (lq_sta && !lq_sta->drv) { 2385 if (lq_sta && !lq_sta->pers.drv) {
2386 IWL_DEBUG_RATE(mvm, "Rate scaling not initialized yet.\n"); 2386 IWL_DEBUG_RATE(mvm, "Rate scaling not initialized yet.\n");
2387 mvm_sta = NULL; 2387 mvm_sta = NULL;
2388 } 2388 }
@@ -2401,12 +2401,18 @@ static void *rs_alloc_sta(void *mvm_rate, struct ieee80211_sta *sta,
2401 gfp_t gfp) 2401 gfp_t gfp)
2402{ 2402{
2403 struct iwl_mvm_sta *sta_priv = (struct iwl_mvm_sta *)sta->drv_priv; 2403 struct iwl_mvm_sta *sta_priv = (struct iwl_mvm_sta *)sta->drv_priv;
2404 struct iwl_op_mode *op_mode __maybe_unused = 2404 struct iwl_op_mode *op_mode = (struct iwl_op_mode *)mvm_rate;
2405 (struct iwl_op_mode *)mvm_rate; 2405 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
2406 struct iwl_mvm *mvm __maybe_unused = IWL_OP_MODE_GET_MVM(op_mode); 2406 struct iwl_lq_sta *lq_sta = &sta_priv->lq_sta;
2407 2407
2408 IWL_DEBUG_RATE(mvm, "create station rate scale window\n"); 2408 IWL_DEBUG_RATE(mvm, "create station rate scale window\n");
2409 2409
2410 lq_sta->pers.drv = mvm;
2411#ifdef CONFIG_MAC80211_DEBUGFS
2412 lq_sta->pers.dbg_fixed_rate = 0;
2413 lq_sta->pers.dbg_fixed_txp_reduction = TPC_INVALID;
2414#endif
2415
2410 return &sta_priv->lq_sta; 2416 return &sta_priv->lq_sta;
2411} 2417}
2412 2418
@@ -2552,7 +2558,9 @@ void iwl_mvm_rs_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
2552 2558
2553 sta_priv = (struct iwl_mvm_sta *)sta->drv_priv; 2559 sta_priv = (struct iwl_mvm_sta *)sta->drv_priv;
2554 lq_sta = &sta_priv->lq_sta; 2560 lq_sta = &sta_priv->lq_sta;
2555 memset(lq_sta, 0, sizeof(*lq_sta)); 2561
2562 /* clear all non-persistent lq data */
2563 memset(lq_sta, 0, offsetof(typeof(*lq_sta), pers));
2556 2564
2557 sband = hw->wiphy->bands[band]; 2565 sband = hw->wiphy->bands[band];
2558 2566
@@ -2630,17 +2638,12 @@ void iwl_mvm_rs_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
2630 2638
2631 /* as default allow aggregation for all tids */ 2639 /* as default allow aggregation for all tids */
2632 lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; 2640 lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID;
2633 lq_sta->drv = mvm;
2634 2641
2635 /* Set last_txrate_idx to lowest rate */ 2642 /* Set last_txrate_idx to lowest rate */
2636 lq_sta->last_txrate_idx = rate_lowest_index(sband, sta); 2643 lq_sta->last_txrate_idx = rate_lowest_index(sband, sta);
2637 if (sband->band == IEEE80211_BAND_5GHZ) 2644 if (sband->band == IEEE80211_BAND_5GHZ)
2638 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 2645 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
2639 lq_sta->is_agg = 0; 2646 lq_sta->is_agg = 0;
2640#ifdef CONFIG_MAC80211_DEBUGFS
2641 lq_sta->dbg_fixed_rate = 0;
2642 lq_sta->dbg_fixed_txp_reduction = TPC_INVALID;
2643#endif
2644#ifdef CONFIG_IWLWIFI_DEBUGFS 2647#ifdef CONFIG_IWLWIFI_DEBUGFS
2645 iwl_mvm_reset_frame_stats(mvm, &mvm->drv_rx_stats); 2648 iwl_mvm_reset_frame_stats(mvm, &mvm->drv_rx_stats);
2646#endif 2649#endif
@@ -2811,12 +2814,12 @@ static void rs_fill_lq_cmd(struct iwl_mvm *mvm,
2811 u8 ant = initial_rate->ant; 2814 u8 ant = initial_rate->ant;
2812 2815
2813#ifdef CONFIG_MAC80211_DEBUGFS 2816#ifdef CONFIG_MAC80211_DEBUGFS
2814 if (lq_sta->dbg_fixed_rate) { 2817 if (lq_sta->pers.dbg_fixed_rate) {
2815 rs_build_rates_table_from_fixed(mvm, lq_cmd, 2818 rs_build_rates_table_from_fixed(mvm, lq_cmd,
2816 lq_sta->band, 2819 lq_sta->band,
2817 lq_sta->dbg_fixed_rate); 2820 lq_sta->pers.dbg_fixed_rate);
2818 lq_cmd->reduced_tpc = 0; 2821 lq_cmd->reduced_tpc = 0;
2819 ant = (lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) >> 2822 ant = (lq_sta->pers.dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) >>
2820 RATE_MCS_ANT_POS; 2823 RATE_MCS_ANT_POS;
2821 } else 2824 } else
2822#endif 2825#endif
@@ -2926,14 +2929,14 @@ static void rs_program_fix_rate(struct iwl_mvm *mvm,
2926 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ 2929 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */
2927 2930
2928 IWL_DEBUG_RATE(mvm, "sta_id %d rate 0x%X\n", 2931 IWL_DEBUG_RATE(mvm, "sta_id %d rate 0x%X\n",
2929 lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); 2932 lq_sta->lq.sta_id, lq_sta->pers.dbg_fixed_rate);
2930 2933
2931 if (lq_sta->dbg_fixed_rate) { 2934 if (lq_sta->pers.dbg_fixed_rate) {
2932 struct rs_rate rate; 2935 struct rs_rate rate;
2933 rs_rate_from_ucode_rate(lq_sta->dbg_fixed_rate, 2936 rs_rate_from_ucode_rate(lq_sta->pers.dbg_fixed_rate,
2934 lq_sta->band, &rate); 2937 lq_sta->band, &rate);
2935 rs_fill_lq_cmd(mvm, NULL, lq_sta, &rate); 2938 rs_fill_lq_cmd(mvm, NULL, lq_sta, &rate);
2936 iwl_mvm_send_lq_cmd(lq_sta->drv, &lq_sta->lq, false); 2939 iwl_mvm_send_lq_cmd(lq_sta->pers.drv, &lq_sta->lq, false);
2937 } 2940 }
2938} 2941}
2939 2942
@@ -2946,16 +2949,16 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
2946 size_t buf_size; 2949 size_t buf_size;
2947 u32 parsed_rate; 2950 u32 parsed_rate;
2948 2951
2949 mvm = lq_sta->drv; 2952 mvm = lq_sta->pers.drv;
2950 memset(buf, 0, sizeof(buf)); 2953 memset(buf, 0, sizeof(buf));
2951 buf_size = min(count, sizeof(buf) - 1); 2954 buf_size = min(count, sizeof(buf) - 1);
2952 if (copy_from_user(buf, user_buf, buf_size)) 2955 if (copy_from_user(buf, user_buf, buf_size))
2953 return -EFAULT; 2956 return -EFAULT;
2954 2957
2955 if (sscanf(buf, "%x", &parsed_rate) == 1) 2958 if (sscanf(buf, "%x", &parsed_rate) == 1)
2956 lq_sta->dbg_fixed_rate = parsed_rate; 2959 lq_sta->pers.dbg_fixed_rate = parsed_rate;
2957 else 2960 else
2958 lq_sta->dbg_fixed_rate = 0; 2961 lq_sta->pers.dbg_fixed_rate = 0;
2959 2962
2960 rs_program_fix_rate(mvm, lq_sta); 2963 rs_program_fix_rate(mvm, lq_sta);
2961 2964
@@ -2974,7 +2977,7 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
2974 struct iwl_mvm *mvm; 2977 struct iwl_mvm *mvm;
2975 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); 2978 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
2976 struct rs_rate *rate = &tbl->rate; 2979 struct rs_rate *rate = &tbl->rate;
2977 mvm = lq_sta->drv; 2980 mvm = lq_sta->pers.drv;
2978 buff = kmalloc(2048, GFP_KERNEL); 2981 buff = kmalloc(2048, GFP_KERNEL);
2979 if (!buff) 2982 if (!buff)
2980 return -ENOMEM; 2983 return -ENOMEM;
@@ -2984,7 +2987,7 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
2984 lq_sta->total_failed, lq_sta->total_success, 2987 lq_sta->total_failed, lq_sta->total_success,
2985 lq_sta->active_legacy_rate); 2988 lq_sta->active_legacy_rate);
2986 desc += sprintf(buff+desc, "fixed rate 0x%X\n", 2989 desc += sprintf(buff+desc, "fixed rate 0x%X\n",
2987 lq_sta->dbg_fixed_rate); 2990 lq_sta->pers.dbg_fixed_rate);
2988 desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", 2991 desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n",
2989 (mvm->fw->valid_tx_ant & ANT_A) ? "ANT_A," : "", 2992 (mvm->fw->valid_tx_ant & ANT_A) ? "ANT_A," : "",
2990 (mvm->fw->valid_tx_ant & ANT_B) ? "ANT_B," : "", 2993 (mvm->fw->valid_tx_ant & ANT_B) ? "ANT_B," : "",
@@ -3182,31 +3185,31 @@ static const struct file_operations rs_sta_dbgfs_drv_tx_stats_ops = {
3182static void rs_add_debugfs(void *mvm, void *mvm_sta, struct dentry *dir) 3185static void rs_add_debugfs(void *mvm, void *mvm_sta, struct dentry *dir)
3183{ 3186{
3184 struct iwl_lq_sta *lq_sta = mvm_sta; 3187 struct iwl_lq_sta *lq_sta = mvm_sta;
3185 lq_sta->rs_sta_dbgfs_scale_table_file = 3188 lq_sta->pers.rs_sta_dbgfs_scale_table_file =
3186 debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, 3189 debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir,
3187 lq_sta, &rs_sta_dbgfs_scale_table_ops); 3190 lq_sta, &rs_sta_dbgfs_scale_table_ops);
3188 lq_sta->rs_sta_dbgfs_stats_table_file = 3191 lq_sta->pers.rs_sta_dbgfs_stats_table_file =
3189 debugfs_create_file("rate_stats_table", S_IRUSR, dir, 3192 debugfs_create_file("rate_stats_table", S_IRUSR, dir,
3190 lq_sta, &rs_sta_dbgfs_stats_table_ops); 3193 lq_sta, &rs_sta_dbgfs_stats_table_ops);
3191 lq_sta->rs_sta_dbgfs_drv_tx_stats_file = 3194 lq_sta->pers.rs_sta_dbgfs_drv_tx_stats_file =
3192 debugfs_create_file("drv_tx_stats", S_IRUSR | S_IWUSR, dir, 3195 debugfs_create_file("drv_tx_stats", S_IRUSR | S_IWUSR, dir,
3193 lq_sta, &rs_sta_dbgfs_drv_tx_stats_ops); 3196 lq_sta, &rs_sta_dbgfs_drv_tx_stats_ops);
3194 lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = 3197 lq_sta->pers.rs_sta_dbgfs_tx_agg_tid_en_file =
3195 debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, 3198 debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir,
3196 &lq_sta->tx_agg_tid_en); 3199 &lq_sta->tx_agg_tid_en);
3197 lq_sta->rs_sta_dbgfs_reduced_txp_file = 3200 lq_sta->pers.rs_sta_dbgfs_reduced_txp_file =
3198 debugfs_create_u8("reduced_tpc", S_IRUSR | S_IWUSR, dir, 3201 debugfs_create_u8("reduced_tpc", S_IRUSR | S_IWUSR, dir,
3199 &lq_sta->dbg_fixed_txp_reduction); 3202 &lq_sta->pers.dbg_fixed_txp_reduction);
3200} 3203}
3201 3204
3202static void rs_remove_debugfs(void *mvm, void *mvm_sta) 3205static void rs_remove_debugfs(void *mvm, void *mvm_sta)
3203{ 3206{
3204 struct iwl_lq_sta *lq_sta = mvm_sta; 3207 struct iwl_lq_sta *lq_sta = mvm_sta;
3205 debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); 3208 debugfs_remove(lq_sta->pers.rs_sta_dbgfs_scale_table_file);
3206 debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); 3209 debugfs_remove(lq_sta->pers.rs_sta_dbgfs_stats_table_file);
3207 debugfs_remove(lq_sta->rs_sta_dbgfs_drv_tx_stats_file); 3210 debugfs_remove(lq_sta->pers.rs_sta_dbgfs_drv_tx_stats_file);
3208 debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file); 3211 debugfs_remove(lq_sta->pers.rs_sta_dbgfs_tx_agg_tid_en_file);
3209 debugfs_remove(lq_sta->rs_sta_dbgfs_reduced_txp_file); 3212 debugfs_remove(lq_sta->pers.rs_sta_dbgfs_reduced_txp_file);
3210} 3213}
3211#endif 3214#endif
3212 3215
diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.h b/drivers/net/wireless/iwlwifi/mvm/rs.h
index 374a83d7db25..2e1a683d0162 100644
--- a/drivers/net/wireless/iwlwifi/mvm/rs.h
+++ b/drivers/net/wireless/iwlwifi/mvm/rs.h
@@ -349,16 +349,6 @@ struct iwl_lq_sta {
349 struct iwl_lq_cmd lq; 349 struct iwl_lq_cmd lq;
350 struct iwl_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ 350 struct iwl_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */
351 u8 tx_agg_tid_en; 351 u8 tx_agg_tid_en;
352#ifdef CONFIG_MAC80211_DEBUGFS
353 struct dentry *rs_sta_dbgfs_scale_table_file;
354 struct dentry *rs_sta_dbgfs_stats_table_file;
355 struct dentry *rs_sta_dbgfs_drv_tx_stats_file;
356 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file;
357 struct dentry *rs_sta_dbgfs_reduced_txp_file;
358 u32 dbg_fixed_rate;
359 u8 dbg_fixed_txp_reduction;
360#endif
361 struct iwl_mvm *drv;
362 352
363 /* used to be in sta_info */ 353 /* used to be in sta_info */
364 int last_txrate_idx; 354 int last_txrate_idx;
@@ -369,6 +359,20 @@ struct iwl_lq_sta {
369 359
370 /* tx power reduce for this sta */ 360 /* tx power reduce for this sta */
371 int tpc_reduce; 361 int tpc_reduce;
362
363 /* persistent fields - initialized only once - keep last! */
364 struct {
365#ifdef CONFIG_MAC80211_DEBUGFS
366 struct dentry *rs_sta_dbgfs_scale_table_file;
367 struct dentry *rs_sta_dbgfs_stats_table_file;
368 struct dentry *rs_sta_dbgfs_drv_tx_stats_file;
369 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file;
370 struct dentry *rs_sta_dbgfs_reduced_txp_file;
371 u32 dbg_fixed_rate;
372 u8 dbg_fixed_txp_reduction;
373#endif
374 struct iwl_mvm *drv;
375 } pers;
372}; 376};
373 377
374/* Initialize station's rate scaling information after adding station */ 378/* Initialize station's rate scaling information after adding station */