aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlegacy
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlegacy')
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-3945-rs.c13
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-3945.c10
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-lib.c79
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-rs.c3
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-rx.c78
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-tx.c3
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965.c18
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-commands.h11
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-core.c93
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-core.h17
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-debugfs.c192
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-dev.h61
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-devtrace.c3
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-devtrace.h60
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-eeprom.c1
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-hcmd.c2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-helpers.h9
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-rx.c21
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-scan.c92
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-tx.c4
-rw-r--r--drivers/net/wireless/iwlegacy/iwl3945-base.c309
-rw-r--r--drivers/net/wireless/iwlegacy/iwl4965-base.c475
22 files changed, 191 insertions, 1363 deletions
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
index 977bd2477c6..164bcae821f 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
@@ -822,12 +822,15 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
822 822
823 out: 823 out:
824 824
825 rs_sta->last_txrate_idx = index; 825 if (sband->band == IEEE80211_BAND_5GHZ) {
826 if (sband->band == IEEE80211_BAND_5GHZ) 826 if (WARN_ON_ONCE(index < IWL_FIRST_OFDM_RATE))
827 info->control.rates[0].idx = rs_sta->last_txrate_idx - 827 index = IWL_FIRST_OFDM_RATE;
828 IWL_FIRST_OFDM_RATE; 828 rs_sta->last_txrate_idx = index;
829 else 829 info->control.rates[0].idx = index - IWL_FIRST_OFDM_RATE;
830 } else {
831 rs_sta->last_txrate_idx = index;
830 info->control.rates[0].idx = rs_sta->last_txrate_idx; 832 info->control.rates[0].idx = rs_sta->last_txrate_idx;
833 }
831 834
832 IWL_DEBUG_RATE(priv, "leave: %d\n", index); 835 IWL_DEBUG_RATE(priv, "leave: %d\n", index);
833} 836}
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c
index d096dc28204..73fe3cdf796 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945.c
+++ b/drivers/net/wireless/iwlegacy/iwl-3945.c
@@ -408,7 +408,6 @@ void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
408#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS 408#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS
409 iwl3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw); 409 iwl3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw);
410#endif 410#endif
411 iwl_legacy_recover_from_statistics(priv, pkt);
412 411
413 memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics)); 412 memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics));
414} 413}
@@ -1747,7 +1746,11 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1747 } 1746 }
1748 1747
1749 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); 1748 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
1750 1749 /*
1750 * We do not commit tx power settings while channel changing,
1751 * do it now if tx power changed.
1752 */
1753 iwl_legacy_set_tx_power(priv, priv->tx_power_next, false);
1751 return 0; 1754 return 0;
1752 } 1755 }
1753 1756
@@ -2640,7 +2643,6 @@ static struct iwl_lib_ops iwl3945_lib = {
2640 .txq_free_tfd = iwl3945_hw_txq_free_tfd, 2643 .txq_free_tfd = iwl3945_hw_txq_free_tfd,
2641 .txq_init = iwl3945_hw_tx_queue_init, 2644 .txq_init = iwl3945_hw_tx_queue_init,
2642 .load_ucode = iwl3945_load_bsm, 2645 .load_ucode = iwl3945_load_bsm,
2643 .dump_nic_event_log = iwl3945_dump_nic_event_log,
2644 .dump_nic_error_log = iwl3945_dump_nic_error_log, 2646 .dump_nic_error_log = iwl3945_dump_nic_error_log,
2645 .apm_ops = { 2647 .apm_ops = {
2646 .init = iwl3945_apm_init, 2648 .init = iwl3945_apm_init,
@@ -2698,9 +2700,7 @@ static struct iwl_base_params iwl3945_base_params = {
2698 .set_l0s = false, 2700 .set_l0s = false,
2699 .use_bsm = true, 2701 .use_bsm = true,
2700 .led_compensation = 64, 2702 .led_compensation = 64,
2701 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
2702 .wd_timeout = IWL_DEF_WD_TIMEOUT, 2703 .wd_timeout = IWL_DEF_WD_TIMEOUT,
2703 .max_event_log_size = 512,
2704}; 2704};
2705 2705
2706static struct iwl_cfg iwl3945_bg_cfg = { 2706static struct iwl_cfg iwl3945_bg_cfg = {
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
index a7a4739880d..2be6d9e3b01 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
@@ -694,47 +694,6 @@ void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv,
694 sizeof(struct iwl_rx_phy_res)); 694 sizeof(struct iwl_rx_phy_res));
695} 695}
696 696
697static int iwl4965_get_single_channel_for_scan(struct iwl_priv *priv,
698 struct ieee80211_vif *vif,
699 enum ieee80211_band band,
700 struct iwl_scan_channel *scan_ch)
701{
702 const struct ieee80211_supported_band *sband;
703 u16 passive_dwell = 0;
704 u16 active_dwell = 0;
705 int added = 0;
706 u16 channel = 0;
707
708 sband = iwl_get_hw_mode(priv, band);
709 if (!sband) {
710 IWL_ERR(priv, "invalid band\n");
711 return added;
712 }
713
714 active_dwell = iwl_legacy_get_active_dwell_time(priv, band, 0);
715 passive_dwell = iwl_legacy_get_passive_dwell_time(priv, band, vif);
716
717 if (passive_dwell <= active_dwell)
718 passive_dwell = active_dwell + 1;
719
720 channel = iwl_legacy_get_single_channel_number(priv, band);
721 if (channel) {
722 scan_ch->channel = cpu_to_le16(channel);
723 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
724 scan_ch->active_dwell = cpu_to_le16(active_dwell);
725 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
726 /* Set txpower levels to defaults */
727 scan_ch->dsp_atten = 110;
728 if (band == IEEE80211_BAND_5GHZ)
729 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
730 else
731 scan_ch->tx_gain = ((1 << 5) | (5 << 3));
732 added++;
733 } else
734 IWL_ERR(priv, "no valid channel found\n");
735 return added;
736}
737
738static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, 697static int iwl4965_get_channels_for_scan(struct iwl_priv *priv,
739 struct ieee80211_vif *vif, 698 struct ieee80211_vif *vif,
740 enum ieee80211_band band, 699 enum ieee80211_band band,
@@ -858,16 +817,13 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
858 scan->quiet_time = IWL_ACTIVE_QUIET_TIME; 817 scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
859 818
860 if (iwl_legacy_is_any_associated(priv)) { 819 if (iwl_legacy_is_any_associated(priv)) {
861 u16 interval = 0; 820 u16 interval;
862 u32 extra; 821 u32 extra;
863 u32 suspend_time = 100; 822 u32 suspend_time = 100;
864 u32 scan_suspend_time = 100; 823 u32 scan_suspend_time = 100;
865 824
866 IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); 825 IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
867 if (priv->is_internal_short_scan) 826 interval = vif->bss_conf.beacon_int;
868 interval = 0;
869 else
870 interval = vif->bss_conf.beacon_int;
871 827
872 scan->suspend_time = 0; 828 scan->suspend_time = 0;
873 scan->max_out_time = cpu_to_le32(200 * 1024); 829 scan->max_out_time = cpu_to_le32(200 * 1024);
@@ -882,9 +838,7 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
882 scan_suspend_time, interval); 838 scan_suspend_time, interval);
883 } 839 }
884 840
885 if (priv->is_internal_short_scan) { 841 if (priv->scan_request->n_ssids) {
886 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n");
887 } else if (priv->scan_request->n_ssids) {
888 int i, p = 0; 842 int i, p = 0;
889 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); 843 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
890 for (i = 0; i < priv->scan_request->n_ssids; i++) { 844 for (i = 0; i < priv->scan_request->n_ssids; i++) {
@@ -981,38 +935,21 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
981 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS; 935 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS;
982 rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; 936 rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
983 scan->rx_chain = cpu_to_le16(rx_chain); 937 scan->rx_chain = cpu_to_le16(rx_chain);
984 if (!priv->is_internal_short_scan) { 938
985 cmd_len = iwl_legacy_fill_probe_req(priv, 939 cmd_len = iwl_legacy_fill_probe_req(priv,
986 (struct ieee80211_mgmt *)scan->data, 940 (struct ieee80211_mgmt *)scan->data,
987 vif->addr, 941 vif->addr,
988 priv->scan_request->ie, 942 priv->scan_request->ie,
989 priv->scan_request->ie_len, 943 priv->scan_request->ie_len,
990 IWL_MAX_SCAN_SIZE - sizeof(*scan)); 944 IWL_MAX_SCAN_SIZE - sizeof(*scan));
991 } else {
992 /* use bcast addr, will not be transmitted but must be valid */
993 cmd_len = iwl_legacy_fill_probe_req(priv,
994 (struct ieee80211_mgmt *)scan->data,
995 iwlegacy_bcast_addr, NULL, 0,
996 IWL_MAX_SCAN_SIZE - sizeof(*scan));
997
998 }
999 scan->tx_cmd.len = cpu_to_le16(cmd_len); 945 scan->tx_cmd.len = cpu_to_le16(cmd_len);
1000 946
1001 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | 947 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK |
1002 RXON_FILTER_BCON_AWARE_MSK); 948 RXON_FILTER_BCON_AWARE_MSK);
1003 949
1004 if (priv->is_internal_short_scan) { 950 scan->channel_count = iwl4965_get_channels_for_scan(priv, vif, band,
1005 scan->channel_count = 951 is_active, n_probes,
1006 iwl4965_get_single_channel_for_scan(priv, vif, band, 952 (void *)&scan->data[cmd_len]);
1007 (void *)&scan->data[le16_to_cpu(
1008 scan->tx_cmd.len)]);
1009 } else {
1010 scan->channel_count =
1011 iwl4965_get_channels_for_scan(priv, vif, band,
1012 is_active, n_probes,
1013 (void *)&scan->data[le16_to_cpu(
1014 scan->tx_cmd.len)]);
1015 }
1016 if (scan->channel_count == 0) { 953 if (scan->channel_count == 0) {
1017 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); 954 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
1018 return -EIO; 955 return -EIO;
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c
index 24d149909ba..9b65153bdd0 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c
@@ -2275,6 +2275,9 @@ iwl4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
2275 if (rate_control_send_low(sta, priv_sta, txrc)) 2275 if (rate_control_send_low(sta, priv_sta, txrc))
2276 return; 2276 return;
2277 2277
2278 if (!lq_sta)
2279 return;
2280
2278 rate_idx = lq_sta->last_txrate_idx; 2281 rate_idx = lq_sta->last_txrate_idx;
2279 2282
2280 if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { 2283 if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) {
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c
index b9fa2f6411a..2b144bbfc3c 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c
@@ -151,81 +151,6 @@ static void iwl4965_accumulative_statistics(struct iwl_priv *priv,
151 151
152#define REG_RECALIB_PERIOD (60) 152#define REG_RECALIB_PERIOD (60)
153 153
154/**
155 * iwl4965_good_plcp_health - checks for plcp error.
156 *
157 * When the plcp error is exceeding the thresholds, reset the radio
158 * to improve the throughput.
159 */
160bool iwl4965_good_plcp_health(struct iwl_priv *priv,
161 struct iwl_rx_packet *pkt)
162{
163 bool rc = true;
164 int combined_plcp_delta;
165 unsigned int plcp_msec;
166 unsigned long plcp_received_jiffies;
167
168 if (priv->cfg->base_params->plcp_delta_threshold ==
169 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {
170 IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n");
171 return rc;
172 }
173
174 /*
175 * check for plcp_err and trigger radio reset if it exceeds
176 * the plcp error threshold plcp_delta.
177 */
178 plcp_received_jiffies = jiffies;
179 plcp_msec = jiffies_to_msecs((long) plcp_received_jiffies -
180 (long) priv->plcp_jiffies);
181 priv->plcp_jiffies = plcp_received_jiffies;
182 /*
183 * check to make sure plcp_msec is not 0 to prevent division
184 * by zero.
185 */
186 if (plcp_msec) {
187 struct statistics_rx_phy *ofdm;
188 struct statistics_rx_ht_phy *ofdm_ht;
189
190 ofdm = &pkt->u.stats.rx.ofdm;
191 ofdm_ht = &pkt->u.stats.rx.ofdm_ht;
192 combined_plcp_delta =
193 (le32_to_cpu(ofdm->plcp_err) -
194 le32_to_cpu(priv->_4965.statistics.
195 rx.ofdm.plcp_err)) +
196 (le32_to_cpu(ofdm_ht->plcp_err) -
197 le32_to_cpu(priv->_4965.statistics.
198 rx.ofdm_ht.plcp_err));
199
200 if ((combined_plcp_delta > 0) &&
201 ((combined_plcp_delta * 100) / plcp_msec) >
202 priv->cfg->base_params->plcp_delta_threshold) {
203 /*
204 * if plcp_err exceed the threshold,
205 * the following data is printed in csv format:
206 * Text: plcp_err exceeded %d,
207 * Received ofdm.plcp_err,
208 * Current ofdm.plcp_err,
209 * Received ofdm_ht.plcp_err,
210 * Current ofdm_ht.plcp_err,
211 * combined_plcp_delta,
212 * plcp_msec
213 */
214 IWL_DEBUG_RADIO(priv, "plcp_err exceeded %u, "
215 "%u, %u, %u, %u, %d, %u mSecs\n",
216 priv->cfg->base_params->plcp_delta_threshold,
217 le32_to_cpu(ofdm->plcp_err),
218 le32_to_cpu(ofdm->plcp_err),
219 le32_to_cpu(ofdm_ht->plcp_err),
220 le32_to_cpu(ofdm_ht->plcp_err),
221 combined_plcp_delta, plcp_msec);
222
223 rc = false;
224 }
225 }
226 return rc;
227}
228
229void iwl4965_rx_statistics(struct iwl_priv *priv, 154void iwl4965_rx_statistics(struct iwl_priv *priv,
230 struct iwl_rx_mem_buffer *rxb) 155 struct iwl_rx_mem_buffer *rxb)
231{ 156{
@@ -248,8 +173,7 @@ void iwl4965_rx_statistics(struct iwl_priv *priv,
248 iwl4965_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); 173 iwl4965_accumulative_statistics(priv, (__le32 *)&pkt->u.stats);
249#endif 174#endif
250 175
251 iwl_legacy_recover_from_statistics(priv, pkt); 176 /* TODO: reading some of statistics is unneeded */
252
253 memcpy(&priv->_4965.statistics, &pkt->u.stats, 177 memcpy(&priv->_4965.statistics, &pkt->u.stats,
254 sizeof(priv->_4965.statistics)); 178 sizeof(priv->_4965.statistics));
255 179
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
index 79ac081832f..ac4f64de136 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
@@ -240,8 +240,7 @@ static void iwl4965_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
240 240
241 case WLAN_CIPHER_SUITE_TKIP: 241 case WLAN_CIPHER_SUITE_TKIP:
242 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; 242 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
243 ieee80211_get_tkip_key(keyconf, skb_frag, 243 ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key);
244 IEEE80211_TKIP_P2_KEY, tx_cmd->key);
245 IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n"); 244 IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n");
246 break; 245 break;
247 246
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c
index facc94e74b0..ecdc6e55742 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965.c
@@ -496,7 +496,7 @@ static s32 iwl4965_get_tx_atten_grp(u16 channel)
496 channel <= CALIB_IWL_TX_ATTEN_GR4_LCH) 496 channel <= CALIB_IWL_TX_ATTEN_GR4_LCH)
497 return CALIB_CH_GROUP_4; 497 return CALIB_CH_GROUP_4;
498 498
499 return -1; 499 return -EINVAL;
500} 500}
501 501
502static u32 iwl4965_get_sub_band(const struct iwl_priv *priv, u32 channel) 502static u32 iwl4965_get_sub_band(const struct iwl_priv *priv, u32 channel)
@@ -915,7 +915,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
915 if (txatten_grp < 0) { 915 if (txatten_grp < 0) {
916 IWL_ERR(priv, "Can't find txatten group for channel %d.\n", 916 IWL_ERR(priv, "Can't find txatten group for channel %d.\n",
917 channel); 917 channel);
918 return -EINVAL; 918 return txatten_grp;
919 } 919 }
920 920
921 IWL_DEBUG_TXPOWER(priv, "channel %d belongs to txatten group %d\n", 921 IWL_DEBUG_TXPOWER(priv, "channel %d belongs to txatten group %d\n",
@@ -1185,8 +1185,6 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv,
1185 1185
1186 ret = iwl_legacy_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, 1186 ret = iwl_legacy_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC,
1187 sizeof(rxon_assoc), &rxon_assoc, NULL); 1187 sizeof(rxon_assoc), &rxon_assoc, NULL);
1188 if (ret)
1189 return ret;
1190 1188
1191 return ret; 1189 return ret;
1192} 1190}
@@ -1237,7 +1235,12 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c
1237 1235
1238 memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); 1236 memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon));
1239 iwl_legacy_print_rx_config_cmd(priv, ctx); 1237 iwl_legacy_print_rx_config_cmd(priv, ctx);
1240 goto set_tx_power; 1238 /*
1239 * We do not commit tx power settings while channel changing,
1240 * do it now if tx power changed.
1241 */
1242 iwl_legacy_set_tx_power(priv, priv->tx_power_next, false);
1243 return 0;
1241 } 1244 }
1242 1245
1243 /* If we are currently associated and the new config requires 1246 /* If we are currently associated and the new config requires
@@ -1317,7 +1320,6 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c
1317 1320
1318 iwl4965_init_sensitivity(priv); 1321 iwl4965_init_sensitivity(priv);
1319 1322
1320set_tx_power:
1321 /* If we issue a new RXON command which required a tune then we must 1323 /* If we issue a new RXON command which required a tune then we must
1322 * send a new TXPOWER command or we won't be able to Tx any frames */ 1324 * send a new TXPOWER command or we won't be able to Tx any frames */
1323 ret = iwl_legacy_set_tx_power(priv, priv->tx_power_next, true); 1325 ret = iwl_legacy_set_tx_power(priv, priv->tx_power_next, true);
@@ -2071,7 +2073,6 @@ static struct iwl_lib_ops iwl4965_lib = {
2071 .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr, 2073 .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr,
2072 .init_alive_start = iwl4965_init_alive_start, 2074 .init_alive_start = iwl4965_init_alive_start,
2073 .load_ucode = iwl4965_load_bsm, 2075 .load_ucode = iwl4965_load_bsm,
2074 .dump_nic_event_log = iwl4965_dump_nic_event_log,
2075 .dump_nic_error_log = iwl4965_dump_nic_error_log, 2076 .dump_nic_error_log = iwl4965_dump_nic_error_log,
2076 .dump_fh = iwl4965_dump_fh, 2077 .dump_fh = iwl4965_dump_fh,
2077 .set_channel_switch = iwl4965_hw_channel_switch, 2078 .set_channel_switch = iwl4965_hw_channel_switch,
@@ -2102,7 +2103,6 @@ static struct iwl_lib_ops iwl4965_lib = {
2102 .tx_stats_read = iwl4965_ucode_tx_stats_read, 2103 .tx_stats_read = iwl4965_ucode_tx_stats_read,
2103 .general_stats_read = iwl4965_ucode_general_stats_read, 2104 .general_stats_read = iwl4965_ucode_general_stats_read,
2104 }, 2105 },
2105 .check_plcp_health = iwl4965_good_plcp_health,
2106}; 2106};
2107 2107
2108static const struct iwl_legacy_ops iwl4965_legacy_ops = { 2108static const struct iwl_legacy_ops iwl4965_legacy_ops = {
@@ -2152,10 +2152,8 @@ static struct iwl_base_params iwl4965_base_params = {
2152 .use_bsm = true, 2152 .use_bsm = true,
2153 .led_compensation = 61, 2153 .led_compensation = 61,
2154 .chain_noise_num_beacons = IWL4965_CAL_NUM_BEACONS, 2154 .chain_noise_num_beacons = IWL4965_CAL_NUM_BEACONS,
2155 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
2156 .wd_timeout = IWL_DEF_WD_TIMEOUT, 2155 .wd_timeout = IWL_DEF_WD_TIMEOUT,
2157 .temperature_kelvin = true, 2156 .temperature_kelvin = true,
2158 .max_event_log_size = 512,
2159 .ucode_tracing = true, 2157 .ucode_tracing = true,
2160 .sensitivity_calib_by_driver = true, 2158 .sensitivity_calib_by_driver = true,
2161 .chain_noise_calib_by_driver = true, 2159 .chain_noise_calib_by_driver = true,
diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h
index 17a1d504348..89904054473 100644
--- a/drivers/net/wireless/iwlegacy/iwl-commands.h
+++ b/drivers/net/wireless/iwlegacy/iwl-commands.h
@@ -2297,14 +2297,7 @@ struct iwl_spectrum_notification {
2297#define IWL_POWER_VEC_SIZE 5 2297#define IWL_POWER_VEC_SIZE 5
2298 2298
2299#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0)) 2299#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0))
2300#define IWL_POWER_POWER_SAVE_ENA_MSK cpu_to_le16(BIT(0))
2301#define IWL_POWER_POWER_MANAGEMENT_ENA_MSK cpu_to_le16(BIT(1))
2302#define IWL_POWER_SLEEP_OVER_DTIM_MSK cpu_to_le16(BIT(2))
2303#define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3)) 2300#define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3))
2304#define IWL_POWER_FAST_PD cpu_to_le16(BIT(4))
2305#define IWL_POWER_BEACON_FILTERING cpu_to_le16(BIT(5))
2306#define IWL_POWER_SHADOW_REG_ENA cpu_to_le16(BIT(6))
2307#define IWL_POWER_CT_KILL_SET cpu_to_le16(BIT(7))
2308 2301
2309struct iwl3945_powertable_cmd { 2302struct iwl3945_powertable_cmd {
2310 __le16 flags; 2303 __le16 flags;
@@ -2624,8 +2617,8 @@ struct iwl_scanstart_notification {
2624 __le32 status; 2617 __le32 status;
2625} __packed; 2618} __packed;
2626 2619
2627#define SCAN_OWNER_STATUS 0x1; 2620#define SCAN_OWNER_STATUS 0x1
2628#define MEASURE_OWNER_STATUS 0x2; 2621#define MEASURE_OWNER_STATUS 0x2
2629 2622
2630#define IWL_PROBE_STATUS_OK 0 2623#define IWL_PROBE_STATUS_OK 0
2631#define IWL_PROBE_STATUS_TX_FAILED BIT(0) 2624#define IWL_PROBE_STATUS_TX_FAILED BIT(0)
diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c
index 3be76bd5499..e5971fe9d16 100644
--- a/drivers/net/wireless/iwlegacy/iwl-core.c
+++ b/drivers/net/wireless/iwlegacy/iwl-core.c
@@ -931,14 +931,13 @@ void iwl_legacy_irq_handle_error(struct iwl_priv *priv)
931 priv->cfg->ops->lib->dump_nic_error_log(priv); 931 priv->cfg->ops->lib->dump_nic_error_log(priv);
932 if (priv->cfg->ops->lib->dump_fh) 932 if (priv->cfg->ops->lib->dump_fh)
933 priv->cfg->ops->lib->dump_fh(priv, NULL, false); 933 priv->cfg->ops->lib->dump_fh(priv, NULL, false);
934 priv->cfg->ops->lib->dump_nic_event_log(priv, false, NULL, false);
935#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG 934#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
936 if (iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) 935 if (iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS)
937 iwl_legacy_print_rx_config_cmd(priv, 936 iwl_legacy_print_rx_config_cmd(priv,
938 &priv->contexts[IWL_RXON_CTX_BSS]); 937 &priv->contexts[IWL_RXON_CTX_BSS]);
939#endif 938#endif
940 939
941 wake_up_interruptible(&priv->wait_command_queue); 940 wake_up(&priv->wait_command_queue);
942 941
943 /* Keep the restart process from trying to send host 942 /* Keep the restart process from trying to send host
944 * commands by clearing the INIT status bit */ 943 * commands by clearing the INIT status bit */
@@ -1707,41 +1706,14 @@ iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len)
1707EXPORT_SYMBOL(iwl_legacy_update_stats); 1706EXPORT_SYMBOL(iwl_legacy_update_stats);
1708#endif 1707#endif
1709 1708
1710static void _iwl_legacy_force_rf_reset(struct iwl_priv *priv) 1709int iwl_legacy_force_reset(struct iwl_priv *priv, bool external)
1711{
1712 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
1713 return;
1714
1715 if (!iwl_legacy_is_any_associated(priv)) {
1716 IWL_DEBUG_SCAN(priv, "force reset rejected: not associated\n");
1717 return;
1718 }
1719 /*
1720 * There is no easy and better way to force reset the radio,
1721 * the only known method is switching channel which will force to
1722 * reset and tune the radio.
1723 * Use internal short scan (single channel) operation to should
1724 * achieve this objective.
1725 * Driver should reset the radio when number of consecutive missed
1726 * beacon, or any other uCode error condition detected.
1727 */
1728 IWL_DEBUG_INFO(priv, "perform radio reset.\n");
1729 iwl_legacy_internal_short_hw_scan(priv);
1730}
1731
1732
1733int iwl_legacy_force_reset(struct iwl_priv *priv, int mode, bool external)
1734{ 1710{
1735 struct iwl_force_reset *force_reset; 1711 struct iwl_force_reset *force_reset;
1736 1712
1737 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 1713 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
1738 return -EINVAL; 1714 return -EINVAL;
1739 1715
1740 if (mode >= IWL_MAX_FORCE_RESET) { 1716 force_reset = &priv->force_reset;
1741 IWL_DEBUG_INFO(priv, "invalid reset request.\n");
1742 return -EINVAL;
1743 }
1744 force_reset = &priv->force_reset[mode];
1745 force_reset->reset_request_count++; 1717 force_reset->reset_request_count++;
1746 if (!external) { 1718 if (!external) {
1747 if (force_reset->last_force_reset_jiffies && 1719 if (force_reset->last_force_reset_jiffies &&
@@ -1754,37 +1726,34 @@ int iwl_legacy_force_reset(struct iwl_priv *priv, int mode, bool external)
1754 } 1726 }
1755 force_reset->reset_success_count++; 1727 force_reset->reset_success_count++;
1756 force_reset->last_force_reset_jiffies = jiffies; 1728 force_reset->last_force_reset_jiffies = jiffies;
1757 IWL_DEBUG_INFO(priv, "perform force reset (%d)\n", mode); 1729
1758 switch (mode) { 1730 /*
1759 case IWL_RF_RESET: 1731 * if the request is from external(ex: debugfs),
1760 _iwl_legacy_force_rf_reset(priv); 1732 * then always perform the request in regardless the module
1761 break; 1733 * parameter setting
1762 case IWL_FW_RESET: 1734 * if the request is from internal (uCode error or driver
1763 /* 1735 * detect failure), then fw_restart module parameter
1764 * if the request is from external(ex: debugfs), 1736 * need to be check before performing firmware reload
1765 * then always perform the request in regardless the module 1737 */
1766 * parameter setting 1738
1767 * if the request is from internal (uCode error or driver 1739 if (!external && !priv->cfg->mod_params->restart_fw) {
1768 * detect failure), then fw_restart module parameter 1740 IWL_DEBUG_INFO(priv, "Cancel firmware reload based on "
1769 * need to be check before performing firmware reload 1741 "module parameter setting\n");
1770 */ 1742 return 0;
1771 if (!external && !priv->cfg->mod_params->restart_fw) {
1772 IWL_DEBUG_INFO(priv, "Cancel firmware reload based on "
1773 "module parameter setting\n");
1774 break;
1775 }
1776 IWL_ERR(priv, "On demand firmware reload\n");
1777 /* Set the FW error flag -- cleared on iwl_down */
1778 set_bit(STATUS_FW_ERROR, &priv->status);
1779 wake_up_interruptible(&priv->wait_command_queue);
1780 /*
1781 * Keep the restart process from trying to send host
1782 * commands by clearing the INIT status bit
1783 */
1784 clear_bit(STATUS_READY, &priv->status);
1785 queue_work(priv->workqueue, &priv->restart);
1786 break;
1787 } 1743 }
1744
1745 IWL_ERR(priv, "On demand firmware reload\n");
1746
1747 /* Set the FW error flag -- cleared on iwl_down */
1748 set_bit(STATUS_FW_ERROR, &priv->status);
1749 wake_up(&priv->wait_command_queue);
1750 /*
1751 * Keep the restart process from trying to send host
1752 * commands by clearing the INIT status bit
1753 */
1754 clear_bit(STATUS_READY, &priv->status);
1755 queue_work(priv->workqueue, &priv->restart);
1756
1788 return 0; 1757 return 0;
1789} 1758}
1790 1759
@@ -1879,7 +1848,7 @@ static int iwl_legacy_check_stuck_queue(struct iwl_priv *priv, int cnt)
1879 if (time_after(jiffies, timeout)) { 1848 if (time_after(jiffies, timeout)) {
1880 IWL_ERR(priv, "Queue %d stuck for %u ms.\n", 1849 IWL_ERR(priv, "Queue %d stuck for %u ms.\n",
1881 q->id, priv->cfg->base_params->wd_timeout); 1850 q->id, priv->cfg->base_params->wd_timeout);
1882 ret = iwl_legacy_force_reset(priv, IWL_FW_RESET, false); 1851 ret = iwl_legacy_force_reset(priv, false);
1883 return (ret == -EAGAIN) ? 0 : 1; 1852 return (ret == -EAGAIN) ? 0 : 1;
1884 } 1853 }
1885 1854
diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h
index c5fbda0760d..84da79376ef 100644
--- a/drivers/net/wireless/iwlegacy/iwl-core.h
+++ b/drivers/net/wireless/iwlegacy/iwl-core.h
@@ -143,8 +143,7 @@ struct iwl_lib_ops {
143 int (*is_valid_rtc_data_addr)(u32 addr); 143 int (*is_valid_rtc_data_addr)(u32 addr);
144 /* 1st ucode load */ 144 /* 1st ucode load */
145 int (*load_ucode)(struct iwl_priv *priv); 145 int (*load_ucode)(struct iwl_priv *priv);
146 int (*dump_nic_event_log)(struct iwl_priv *priv, 146
147 bool full_log, char **buf, bool display);
148 void (*dump_nic_error_log)(struct iwl_priv *priv); 147 void (*dump_nic_error_log)(struct iwl_priv *priv);
149 int (*dump_fh)(struct iwl_priv *priv, char **buf, bool display); 148 int (*dump_fh)(struct iwl_priv *priv, char **buf, bool display);
150 int (*set_channel_switch)(struct iwl_priv *priv, 149 int (*set_channel_switch)(struct iwl_priv *priv,
@@ -161,9 +160,6 @@ struct iwl_lib_ops {
161 160
162 /* temperature */ 161 /* temperature */
163 struct iwl_temp_ops temp_ops; 162 struct iwl_temp_ops temp_ops;
164 /* check for plcp health */
165 bool (*check_plcp_health)(struct iwl_priv *priv,
166 struct iwl_rx_packet *pkt);
167 163
168 struct iwl_debugfs_ops debugfs_ops; 164 struct iwl_debugfs_ops debugfs_ops;
169 165
@@ -207,11 +203,8 @@ struct iwl_mod_params {
207 * to the deviation to achieve the desired led frequency. 203 * to the deviation to achieve the desired led frequency.
208 * The detail algorithm is described in iwl-led.c 204 * The detail algorithm is described in iwl-led.c
209 * @chain_noise_num_beacons: number of beacons used to compute chain noise 205 * @chain_noise_num_beacons: number of beacons used to compute chain noise
210 * @plcp_delta_threshold: plcp error rate threshold used to trigger
211 * radio tuning when there is a high receiving plcp error rate
212 * @wd_timeout: TX queues watchdog timeout 206 * @wd_timeout: TX queues watchdog timeout
213 * @temperature_kelvin: temperature report by uCode in kelvin 207 * @temperature_kelvin: temperature report by uCode in kelvin
214 * @max_event_log_size: size of event log buffer size for ucode event logging
215 * @ucode_tracing: support ucode continuous tracing 208 * @ucode_tracing: support ucode continuous tracing
216 * @sensitivity_calib_by_driver: driver has the capability to perform 209 * @sensitivity_calib_by_driver: driver has the capability to perform
217 * sensitivity calibration operation 210 * sensitivity calibration operation
@@ -229,10 +222,8 @@ struct iwl_base_params {
229 222
230 u16 led_compensation; 223 u16 led_compensation;
231 int chain_noise_num_beacons; 224 int chain_noise_num_beacons;
232 u8 plcp_delta_threshold;
233 unsigned int wd_timeout; 225 unsigned int wd_timeout;
234 bool temperature_kelvin; 226 bool temperature_kelvin;
235 u32 max_event_log_size;
236 const bool ucode_tracing; 227 const bool ucode_tracing;
237 const bool sensitivity_calib_by_driver; 228 const bool sensitivity_calib_by_driver;
238 const bool chain_noise_calib_by_driver; 229 const bool chain_noise_calib_by_driver;
@@ -441,7 +432,7 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw,
441 struct ieee80211_vif *vif, 432 struct ieee80211_vif *vif,
442 struct cfg80211_scan_request *req); 433 struct cfg80211_scan_request *req);
443void iwl_legacy_internal_short_hw_scan(struct iwl_priv *priv); 434void iwl_legacy_internal_short_hw_scan(struct iwl_priv *priv);
444int iwl_legacy_force_reset(struct iwl_priv *priv, int mode, bool external); 435int iwl_legacy_force_reset(struct iwl_priv *priv, bool external);
445u16 iwl_legacy_fill_probe_req(struct iwl_priv *priv, 436u16 iwl_legacy_fill_probe_req(struct iwl_priv *priv,
446 struct ieee80211_mgmt *frame, 437 struct ieee80211_mgmt *frame,
447 const u8 *ta, const u8 *ie, int ie_len, int left); 438 const u8 *ta, const u8 *ie, int ie_len, int left);
@@ -493,7 +484,7 @@ static inline u16 iwl_legacy_pcie_link_ctl(struct iwl_priv *priv)
493{ 484{
494 int pos; 485 int pos;
495 u16 pci_lnk_ctl; 486 u16 pci_lnk_ctl;
496 pos = pci_find_capability(priv->pci_dev, PCI_CAP_ID_EXP); 487 pos = pci_pcie_cap(priv->pci_dev);
497 pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); 488 pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl);
498 return pci_lnk_ctl; 489 return pci_lnk_ctl;
499} 490}
@@ -521,8 +512,6 @@ extern const struct dev_pm_ops iwl_legacy_pm_ops;
521* Error Handling Debugging 512* Error Handling Debugging
522******************************************************/ 513******************************************************/
523void iwl4965_dump_nic_error_log(struct iwl_priv *priv); 514void iwl4965_dump_nic_error_log(struct iwl_priv *priv);
524int iwl4965_dump_nic_event_log(struct iwl_priv *priv,
525 bool full_log, char **buf, bool display);
526#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG 515#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
527void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv, 516void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv,
528 struct iwl_rxon_context *ctx); 517 struct iwl_rxon_context *ctx);
diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c
index 2d32438b4cb..996996a7165 100644
--- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c
@@ -391,48 +391,6 @@ static ssize_t iwl_legacy_dbgfs_nvm_read(struct file *file,
391 return ret; 391 return ret;
392} 392}
393 393
394static ssize_t iwl_legacy_dbgfs_log_event_read(struct file *file,
395 char __user *user_buf,
396 size_t count, loff_t *ppos)
397{
398 struct iwl_priv *priv = file->private_data;
399 char *buf;
400 int pos = 0;
401 ssize_t ret = -ENOMEM;
402
403 ret = pos = priv->cfg->ops->lib->dump_nic_event_log(
404 priv, true, &buf, true);
405 if (buf) {
406 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
407 kfree(buf);
408 }
409 return ret;
410}
411
412static ssize_t iwl_legacy_dbgfs_log_event_write(struct file *file,
413 const char __user *user_buf,
414 size_t count, loff_t *ppos)
415{
416 struct iwl_priv *priv = file->private_data;
417 u32 event_log_flag;
418 char buf[8];
419 int buf_size;
420
421 memset(buf, 0, sizeof(buf));
422 buf_size = min(count, sizeof(buf) - 1);
423 if (copy_from_user(buf, user_buf, buf_size))
424 return -EFAULT;
425 if (sscanf(buf, "%d", &event_log_flag) != 1)
426 return -EFAULT;
427 if (event_log_flag == 1)
428 priv->cfg->ops->lib->dump_nic_event_log(priv, true,
429 NULL, false);
430
431 return count;
432}
433
434
435
436static ssize_t 394static ssize_t
437iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf, 395iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf,
438 size_t count, loff_t *ppos) 396 size_t count, loff_t *ppos)
@@ -706,7 +664,6 @@ static ssize_t iwl_legacy_dbgfs_disable_ht40_read(struct file *file,
706} 664}
707 665
708DEBUGFS_READ_WRITE_FILE_OPS(sram); 666DEBUGFS_READ_WRITE_FILE_OPS(sram);
709DEBUGFS_READ_WRITE_FILE_OPS(log_event);
710DEBUGFS_READ_FILE_OPS(nvm); 667DEBUGFS_READ_FILE_OPS(nvm);
711DEBUGFS_READ_FILE_OPS(stations); 668DEBUGFS_READ_FILE_OPS(stations);
712DEBUGFS_READ_FILE_OPS(channels); 669DEBUGFS_READ_FILE_OPS(channels);
@@ -1098,56 +1055,6 @@ static ssize_t iwl_legacy_dbgfs_clear_ucode_statistics_write(struct file *file,
1098 return count; 1055 return count;
1099} 1056}
1100 1057
1101static ssize_t iwl_legacy_dbgfs_ucode_tracing_read(struct file *file,
1102 char __user *user_buf,
1103 size_t count, loff_t *ppos) {
1104
1105 struct iwl_priv *priv = file->private_data;
1106 int pos = 0;
1107 char buf[128];
1108 const size_t bufsz = sizeof(buf);
1109
1110 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
1111 priv->event_log.ucode_trace ? "On" : "Off");
1112 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
1113 priv->event_log.non_wraps_count);
1114 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
1115 priv->event_log.wraps_once_count);
1116 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
1117 priv->event_log.wraps_more_count);
1118
1119 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1120}
1121
1122static ssize_t iwl_legacy_dbgfs_ucode_tracing_write(struct file *file,
1123 const char __user *user_buf,
1124 size_t count, loff_t *ppos)
1125{
1126 struct iwl_priv *priv = file->private_data;
1127 char buf[8];
1128 int buf_size;
1129 int trace;
1130
1131 memset(buf, 0, sizeof(buf));
1132 buf_size = min(count, sizeof(buf) - 1);
1133 if (copy_from_user(buf, user_buf, buf_size))
1134 return -EFAULT;
1135 if (sscanf(buf, "%d", &trace) != 1)
1136 return -EFAULT;
1137
1138 if (trace) {
1139 priv->event_log.ucode_trace = true;
1140 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
1141 mod_timer(&priv->ucode_trace,
1142 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
1143 } else {
1144 priv->event_log.ucode_trace = false;
1145 del_timer_sync(&priv->ucode_trace);
1146 }
1147
1148 return count;
1149}
1150
1151static ssize_t iwl_legacy_dbgfs_rxon_flags_read(struct file *file, 1058static ssize_t iwl_legacy_dbgfs_rxon_flags_read(struct file *file,
1152 char __user *user_buf, 1059 char __user *user_buf,
1153 size_t count, loff_t *ppos) { 1060 size_t count, loff_t *ppos) {
@@ -1236,72 +1143,31 @@ static ssize_t iwl_legacy_dbgfs_missed_beacon_write(struct file *file,
1236 return count; 1143 return count;
1237} 1144}
1238 1145
1239static ssize_t iwl_legacy_dbgfs_plcp_delta_read(struct file *file,
1240 char __user *user_buf,
1241 size_t count, loff_t *ppos) {
1242
1243 struct iwl_priv *priv = file->private_data;
1244 int pos = 0;
1245 char buf[12];
1246 const size_t bufsz = sizeof(buf);
1247
1248 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
1249 priv->cfg->base_params->plcp_delta_threshold);
1250
1251 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1252}
1253
1254static ssize_t iwl_legacy_dbgfs_plcp_delta_write(struct file *file,
1255 const char __user *user_buf,
1256 size_t count, loff_t *ppos) {
1257
1258 struct iwl_priv *priv = file->private_data;
1259 char buf[8];
1260 int buf_size;
1261 int plcp;
1262
1263 memset(buf, 0, sizeof(buf));
1264 buf_size = min(count, sizeof(buf) - 1);
1265 if (copy_from_user(buf, user_buf, buf_size))
1266 return -EFAULT;
1267 if (sscanf(buf, "%d", &plcp) != 1)
1268 return -EINVAL;
1269 if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
1270 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
1271 priv->cfg->base_params->plcp_delta_threshold =
1272 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE;
1273 else
1274 priv->cfg->base_params->plcp_delta_threshold = plcp;
1275 return count;
1276}
1277
1278static ssize_t iwl_legacy_dbgfs_force_reset_read(struct file *file, 1146static ssize_t iwl_legacy_dbgfs_force_reset_read(struct file *file,
1279 char __user *user_buf, 1147 char __user *user_buf,
1280 size_t count, loff_t *ppos) { 1148 size_t count, loff_t *ppos) {
1281 1149
1282 struct iwl_priv *priv = file->private_data; 1150 struct iwl_priv *priv = file->private_data;
1283 int i, pos = 0; 1151 int pos = 0;
1284 char buf[300]; 1152 char buf[300];
1285 const size_t bufsz = sizeof(buf); 1153 const size_t bufsz = sizeof(buf);
1286 struct iwl_force_reset *force_reset; 1154 struct iwl_force_reset *force_reset;
1287 1155
1288 for (i = 0; i < IWL_MAX_FORCE_RESET; i++) { 1156 force_reset = &priv->force_reset;
1289 force_reset = &priv->force_reset[i]; 1157
1290 pos += scnprintf(buf + pos, bufsz - pos, 1158 pos += scnprintf(buf + pos, bufsz - pos,
1291 "Force reset method %d\n", i); 1159 "\tnumber of reset request: %d\n",
1292 pos += scnprintf(buf + pos, bufsz - pos, 1160 force_reset->reset_request_count);
1293 "\tnumber of reset request: %d\n", 1161 pos += scnprintf(buf + pos, bufsz - pos,
1294 force_reset->reset_request_count); 1162 "\tnumber of reset request success: %d\n",
1295 pos += scnprintf(buf + pos, bufsz - pos, 1163 force_reset->reset_success_count);
1296 "\tnumber of reset request success: %d\n", 1164 pos += scnprintf(buf + pos, bufsz - pos,
1297 force_reset->reset_success_count); 1165 "\tnumber of reset request reject: %d\n",
1298 pos += scnprintf(buf + pos, bufsz - pos, 1166 force_reset->reset_reject_count);
1299 "\tnumber of reset request reject: %d\n", 1167 pos += scnprintf(buf + pos, bufsz - pos,
1300 force_reset->reset_reject_count); 1168 "\treset duration: %lu\n",
1301 pos += scnprintf(buf + pos, bufsz - pos, 1169 force_reset->reset_duration);
1302 "\treset duration: %lu\n", 1170
1303 force_reset->reset_duration);
1304 }
1305 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1171 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1306} 1172}
1307 1173
@@ -1309,25 +1175,11 @@ static ssize_t iwl_legacy_dbgfs_force_reset_write(struct file *file,
1309 const char __user *user_buf, 1175 const char __user *user_buf,
1310 size_t count, loff_t *ppos) { 1176 size_t count, loff_t *ppos) {
1311 1177
1178 int ret;
1312 struct iwl_priv *priv = file->private_data; 1179 struct iwl_priv *priv = file->private_data;
1313 char buf[8];
1314 int buf_size;
1315 int reset, ret;
1316 1180
1317 memset(buf, 0, sizeof(buf)); 1181 ret = iwl_legacy_force_reset(priv, true);
1318 buf_size = min(count, sizeof(buf) - 1); 1182
1319 if (copy_from_user(buf, user_buf, buf_size))
1320 return -EFAULT;
1321 if (sscanf(buf, "%d", &reset) != 1)
1322 return -EINVAL;
1323 switch (reset) {
1324 case IWL_RF_RESET:
1325 case IWL_FW_RESET:
1326 ret = iwl_legacy_force_reset(priv, reset, true);
1327 break;
1328 default:
1329 return -EINVAL;
1330 }
1331 return ret ? ret : count; 1183 return ret ? ret : count;
1332} 1184}
1333 1185
@@ -1367,10 +1219,8 @@ DEBUGFS_READ_FILE_OPS(chain_noise);
1367DEBUGFS_READ_FILE_OPS(power_save_status); 1219DEBUGFS_READ_FILE_OPS(power_save_status);
1368DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); 1220DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
1369DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); 1221DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
1370DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
1371DEBUGFS_READ_FILE_OPS(fh_reg); 1222DEBUGFS_READ_FILE_OPS(fh_reg);
1372DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); 1223DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
1373DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
1374DEBUGFS_READ_WRITE_FILE_OPS(force_reset); 1224DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
1375DEBUGFS_READ_FILE_OPS(rxon_flags); 1225DEBUGFS_READ_FILE_OPS(rxon_flags);
1376DEBUGFS_READ_FILE_OPS(rxon_filter_flags); 1226DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
@@ -1403,7 +1253,6 @@ int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name)
1403 1253
1404 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); 1254 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
1405 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); 1255 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
1406 DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR);
1407 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); 1256 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
1408 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); 1257 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
1409 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); 1258 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
@@ -1420,7 +1269,6 @@ int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name)
1420 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); 1269 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
1421 DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); 1270 DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR);
1422 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); 1271 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
1423 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
1424 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); 1272 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
1425 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); 1273 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
1426 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); 1274 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
@@ -1430,8 +1278,6 @@ int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name)
1430 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); 1278 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
1431 if (priv->cfg->base_params->chain_noise_calib_by_driver) 1279 if (priv->cfg->base_params->chain_noise_calib_by_driver)
1432 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); 1280 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
1433 if (priv->cfg->base_params->ucode_tracing)
1434 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
1435 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); 1281 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
1436 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); 1282 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
1437 DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); 1283 DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR);
diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h
index ea30122669e..9c786edf56f 100644
--- a/drivers/net/wireless/iwlegacy/iwl-dev.h
+++ b/drivers/net/wireless/iwlegacy/iwl-dev.h
@@ -32,6 +32,7 @@
32#ifndef __iwl_legacy_dev_h__ 32#ifndef __iwl_legacy_dev_h__
33#define __iwl_legacy_dev_h__ 33#define __iwl_legacy_dev_h__
34 34
35#include <linux/interrupt.h>
35#include <linux/pci.h> /* for struct pci_device_id */ 36#include <linux/pci.h> /* for struct pci_device_id */
36#include <linux/kernel.h> 37#include <linux/kernel.h>
37#include <linux/leds.h> 38#include <linux/leds.h>
@@ -855,32 +856,6 @@ struct traffic_stats {
855}; 856};
856 857
857/* 858/*
858 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
859 * to perform continuous uCode event logging operation if enabled
860 */
861#define UCODE_TRACE_PERIOD (100)
862
863/*
864 * iwl_event_log: current uCode event log position
865 *
866 * @ucode_trace: enable/disable ucode continuous trace timer
867 * @num_wraps: how many times the event buffer wraps
868 * @next_entry: the entry just before the next one that uCode would fill
869 * @non_wraps_count: counter for no wrap detected when dump ucode events
870 * @wraps_once_count: counter for wrap once detected when dump ucode events
871 * @wraps_more_count: counter for wrap more than once detected
872 * when dump ucode events
873 */
874struct iwl_event_log {
875 bool ucode_trace;
876 u32 num_wraps;
877 u32 next_entry;
878 int non_wraps_count;
879 int wraps_once_count;
880 int wraps_more_count;
881};
882
883/*
884 * host interrupt timeout value 859 * host interrupt timeout value
885 * used with setting interrupt coalescing timer 860 * used with setting interrupt coalescing timer
886 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit 861 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
@@ -895,18 +870,6 @@ struct iwl_event_log {
895#define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) 870#define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
896#define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) 871#define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
897 872
898/*
899 * This is the threshold value of plcp error rate per 100mSecs. It is
900 * used to set and check for the validity of plcp_delta.
901 */
902#define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1)
903#define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
904#define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
905#define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
906#define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
907#define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0)
908
909#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
910#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) 873#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
911 874
912/* TX queue watchdog timeouts in mSecs */ 875/* TX queue watchdog timeouts in mSecs */
@@ -914,12 +877,6 @@ struct iwl_event_log {
914#define IWL_LONG_WD_TIMEOUT (10000) 877#define IWL_LONG_WD_TIMEOUT (10000)
915#define IWL_MAX_WD_TIMEOUT (120000) 878#define IWL_MAX_WD_TIMEOUT (120000)
916 879
917enum iwl_reset {
918 IWL_RF_RESET = 0,
919 IWL_FW_RESET,
920 IWL_MAX_FORCE_RESET,
921};
922
923struct iwl_force_reset { 880struct iwl_force_reset {
924 int reset_request_count; 881 int reset_request_count;
925 int reset_success_count; 882 int reset_success_count;
@@ -1032,11 +989,8 @@ struct iwl_priv {
1032 /* track IBSS manager (last beacon) status */ 989 /* track IBSS manager (last beacon) status */
1033 u32 ibss_manager; 990 u32 ibss_manager;
1034 991
1035 /* storing the jiffies when the plcp error rate is received */
1036 unsigned long plcp_jiffies;
1037
1038 /* force reset */ 992 /* force reset */
1039 struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET]; 993 struct iwl_force_reset force_reset;
1040 994
1041 /* we allocate array of iwl_channel_info for NIC's valid channels. 995 /* we allocate array of iwl_channel_info for NIC's valid channels.
1042 * Access via channel # using indirect index array */ 996 * Access via channel # using indirect index array */
@@ -1057,7 +1011,6 @@ struct iwl_priv {
1057 enum ieee80211_band scan_band; 1011 enum ieee80211_band scan_band;
1058 struct cfg80211_scan_request *scan_request; 1012 struct cfg80211_scan_request *scan_request;
1059 struct ieee80211_vif *scan_vif; 1013 struct ieee80211_vif *scan_vif;
1060 bool is_internal_short_scan;
1061 u8 scan_tx_ant[IEEE80211_NUM_BANDS]; 1014 u8 scan_tx_ant[IEEE80211_NUM_BANDS];
1062 u8 mgmt_tx_ant; 1015 u8 mgmt_tx_ant;
1063 1016
@@ -1212,12 +1165,6 @@ struct iwl_priv {
1212#endif 1165#endif
1213#if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE) 1166#if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE)
1214 struct { 1167 struct {
1215 /*
1216 * reporting the number of tids has AGG on. 0 means
1217 * no AGGREGATION
1218 */
1219 u8 agg_tids_count;
1220
1221 struct iwl_rx_phy_res last_phy_res; 1168 struct iwl_rx_phy_res last_phy_res;
1222 bool last_phy_res_valid; 1169 bool last_phy_res_valid;
1223 1170
@@ -1256,7 +1203,6 @@ struct iwl_priv {
1256 struct iwl_rxon_context *beacon_ctx; 1203 struct iwl_rxon_context *beacon_ctx;
1257 struct sk_buff *beacon_skb; 1204 struct sk_buff *beacon_skb;
1258 1205
1259 struct work_struct start_internal_scan;
1260 struct work_struct tx_flush; 1206 struct work_struct tx_flush;
1261 1207
1262 struct tasklet_struct irq_tasklet; 1208 struct tasklet_struct irq_tasklet;
@@ -1293,12 +1239,9 @@ struct iwl_priv {
1293 u32 disable_tx_power_cal; 1239 u32 disable_tx_power_cal;
1294 struct work_struct run_time_calib_work; 1240 struct work_struct run_time_calib_work;
1295 struct timer_list statistics_periodic; 1241 struct timer_list statistics_periodic;
1296 struct timer_list ucode_trace;
1297 struct timer_list watchdog; 1242 struct timer_list watchdog;
1298 bool hw_ready; 1243 bool hw_ready;
1299 1244
1300 struct iwl_event_log event_log;
1301
1302 struct led_classdev led; 1245 struct led_classdev led;
1303 unsigned long blink_on, blink_off; 1246 unsigned long blink_on, blink_off;
1304 bool led_registered; 1247 bool led_registered;
diff --git a/drivers/net/wireless/iwlegacy/iwl-devtrace.c b/drivers/net/wireless/iwlegacy/iwl-devtrace.c
index 080b852b33b..acec99197ce 100644
--- a/drivers/net/wireless/iwlegacy/iwl-devtrace.c
+++ b/drivers/net/wireless/iwlegacy/iwl-devtrace.c
@@ -38,8 +38,5 @@ EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ioread32);
38EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_iowrite32); 38EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_iowrite32);
39EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_rx); 39EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_rx);
40EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_tx); 40EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_tx);
41EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_event);
42EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_error); 41EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_error);
43EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_cont_event);
44EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_wrap_event);
45#endif 42#endif
diff --git a/drivers/net/wireless/iwlegacy/iwl-devtrace.h b/drivers/net/wireless/iwlegacy/iwl-devtrace.h
index 9612aa0f6ec..a443725ba6b 100644
--- a/drivers/net/wireless/iwlegacy/iwl-devtrace.h
+++ b/drivers/net/wireless/iwlegacy/iwl-devtrace.h
@@ -96,47 +96,6 @@ TRACE_EVENT(iwlwifi_legacy_dev_iowrite32,
96#undef TRACE_SYSTEM 96#undef TRACE_SYSTEM
97#define TRACE_SYSTEM iwlwifi_legacy_ucode 97#define TRACE_SYSTEM iwlwifi_legacy_ucode
98 98
99TRACE_EVENT(iwlwifi_legacy_dev_ucode_cont_event,
100 TP_PROTO(struct iwl_priv *priv, u32 time, u32 data, u32 ev),
101 TP_ARGS(priv, time, data, ev),
102 TP_STRUCT__entry(
103 PRIV_ENTRY
104
105 __field(u32, time)
106 __field(u32, data)
107 __field(u32, ev)
108 ),
109 TP_fast_assign(
110 PRIV_ASSIGN;
111 __entry->time = time;
112 __entry->data = data;
113 __entry->ev = ev;
114 ),
115 TP_printk("[%p] EVT_LOGT:%010u:0x%08x:%04u",
116 __entry->priv, __entry->time, __entry->data, __entry->ev)
117);
118
119TRACE_EVENT(iwlwifi_legacy_dev_ucode_wrap_event,
120 TP_PROTO(struct iwl_priv *priv, u32 wraps, u32 n_entry, u32 p_entry),
121 TP_ARGS(priv, wraps, n_entry, p_entry),
122 TP_STRUCT__entry(
123 PRIV_ENTRY
124
125 __field(u32, wraps)
126 __field(u32, n_entry)
127 __field(u32, p_entry)
128 ),
129 TP_fast_assign(
130 PRIV_ASSIGN;
131 __entry->wraps = wraps;
132 __entry->n_entry = n_entry;
133 __entry->p_entry = p_entry;
134 ),
135 TP_printk("[%p] wraps=#%02d n=0x%X p=0x%X",
136 __entry->priv, __entry->wraps, __entry->n_entry,
137 __entry->p_entry)
138);
139
140#undef TRACE_SYSTEM 99#undef TRACE_SYSTEM
141#define TRACE_SYSTEM iwlwifi 100#define TRACE_SYSTEM iwlwifi
142 101
@@ -242,25 +201,6 @@ TRACE_EVENT(iwlwifi_legacy_dev_ucode_error,
242 __entry->blink2, __entry->ilink1, __entry->ilink2) 201 __entry->blink2, __entry->ilink1, __entry->ilink2)
243); 202);
244 203
245TRACE_EVENT(iwlwifi_legacy_dev_ucode_event,
246 TP_PROTO(struct iwl_priv *priv, u32 time, u32 data, u32 ev),
247 TP_ARGS(priv, time, data, ev),
248 TP_STRUCT__entry(
249 PRIV_ENTRY
250
251 __field(u32, time)
252 __field(u32, data)
253 __field(u32, ev)
254 ),
255 TP_fast_assign(
256 PRIV_ASSIGN;
257 __entry->time = time;
258 __entry->data = data;
259 __entry->ev = ev;
260 ),
261 TP_printk("[%p] EVT_LOGT:%010u:0x%08x:%04u",
262 __entry->priv, __entry->time, __entry->data, __entry->ev)
263);
264#endif /* __IWLWIFI_DEVICE_TRACE */ 204#endif /* __IWLWIFI_DEVICE_TRACE */
265 205
266#undef TRACE_INCLUDE_PATH 206#undef TRACE_INCLUDE_PATH
diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c
index cb346d1a9ff..5bf3f49b74a 100644
--- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c
@@ -316,7 +316,6 @@ static void iwl_legacy_init_band_reference(const struct iwl_priv *priv,
316 break; 316 break;
317 default: 317 default:
318 BUG(); 318 BUG();
319 return;
320 } 319 }
321} 320}
322 321
diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c
index 62b4b09122c..ce1fc9feb61 100644
--- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c
+++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c
@@ -167,7 +167,7 @@ int iwl_legacy_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
167 goto out; 167 goto out;
168 } 168 }
169 169
170 ret = wait_event_interruptible_timeout(priv->wait_command_queue, 170 ret = wait_event_timeout(priv->wait_command_queue,
171 !test_bit(STATUS_HCMD_ACTIVE, &priv->status), 171 !test_bit(STATUS_HCMD_ACTIVE, &priv->status),
172 HOST_COMPLETE_TIMEOUT); 172 HOST_COMPLETE_TIMEOUT);
173 if (!ret) { 173 if (!ret) {
diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h
index a6effdae63f..5cf23eaecbb 100644
--- a/drivers/net/wireless/iwlegacy/iwl-helpers.h
+++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h
@@ -132,7 +132,16 @@ static inline void iwl_legacy_stop_queue(struct iwl_priv *priv,
132 ieee80211_stop_queue(priv->hw, ac); 132 ieee80211_stop_queue(priv->hw, ac);
133} 133}
134 134
135#ifdef ieee80211_stop_queue
136#undef ieee80211_stop_queue
137#endif
138
135#define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue 139#define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue
140
141#ifdef ieee80211_wake_queue
142#undef ieee80211_wake_queue
143#endif
144
136#define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue 145#define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue
137 146
138static inline void iwl_legacy_disable_interrupts(struct iwl_priv *priv) 147static inline void iwl_legacy_disable_interrupts(struct iwl_priv *priv)
diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c
index 654cf233a38..9b5d0abe8be 100644
--- a/drivers/net/wireless/iwlegacy/iwl-rx.c
+++ b/drivers/net/wireless/iwlegacy/iwl-rx.c
@@ -227,27 +227,6 @@ void iwl_legacy_rx_spectrum_measure_notif(struct iwl_priv *priv,
227} 227}
228EXPORT_SYMBOL(iwl_legacy_rx_spectrum_measure_notif); 228EXPORT_SYMBOL(iwl_legacy_rx_spectrum_measure_notif);
229 229
230void iwl_legacy_recover_from_statistics(struct iwl_priv *priv,
231 struct iwl_rx_packet *pkt)
232{
233 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
234 return;
235 if (iwl_legacy_is_any_associated(priv)) {
236 if (priv->cfg->ops->lib->check_plcp_health) {
237 if (!priv->cfg->ops->lib->check_plcp_health(
238 priv, pkt)) {
239 /*
240 * high plcp error detected
241 * reset Radio
242 */
243 iwl_legacy_force_reset(priv,
244 IWL_RF_RESET, false);
245 }
246 }
247 }
248}
249EXPORT_SYMBOL(iwl_legacy_recover_from_statistics);
250
251/* 230/*
252 * returns non-zero if packet should be dropped 231 * returns non-zero if packet should be dropped
253 */ 232 */
diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c
index 353234a02c6..a6b5222fc59 100644
--- a/drivers/net/wireless/iwlegacy/iwl-scan.c
+++ b/drivers/net/wireless/iwlegacy/iwl-scan.c
@@ -101,7 +101,6 @@ static void iwl_legacy_complete_scan(struct iwl_priv *priv, bool aborted)
101 ieee80211_scan_completed(priv->hw, aborted); 101 ieee80211_scan_completed(priv->hw, aborted);
102 } 102 }
103 103
104 priv->is_internal_short_scan = false;
105 priv->scan_vif = NULL; 104 priv->scan_vif = NULL;
106 priv->scan_request = NULL; 105 priv->scan_request = NULL;
107} 106}
@@ -329,10 +328,8 @@ void iwl_legacy_init_scan_params(struct iwl_priv *priv)
329} 328}
330EXPORT_SYMBOL(iwl_legacy_init_scan_params); 329EXPORT_SYMBOL(iwl_legacy_init_scan_params);
331 330
332static int __must_check iwl_legacy_scan_initiate(struct iwl_priv *priv, 331static int iwl_legacy_scan_initiate(struct iwl_priv *priv,
333 struct ieee80211_vif *vif, 332 struct ieee80211_vif *vif)
334 bool internal,
335 enum ieee80211_band band)
336{ 333{
337 int ret; 334 int ret;
338 335
@@ -359,18 +356,14 @@ static int __must_check iwl_legacy_scan_initiate(struct iwl_priv *priv,
359 return -EBUSY; 356 return -EBUSY;
360 } 357 }
361 358
362 IWL_DEBUG_SCAN(priv, "Starting %sscan...\n", 359 IWL_DEBUG_SCAN(priv, "Starting scan...\n");
363 internal ? "internal short " : "");
364 360
365 set_bit(STATUS_SCANNING, &priv->status); 361 set_bit(STATUS_SCANNING, &priv->status);
366 priv->is_internal_short_scan = internal;
367 priv->scan_start = jiffies; 362 priv->scan_start = jiffies;
368 priv->scan_band = band;
369 363
370 ret = priv->cfg->ops->utils->request_scan(priv, vif); 364 ret = priv->cfg->ops->utils->request_scan(priv, vif);
371 if (ret) { 365 if (ret) {
372 clear_bit(STATUS_SCANNING, &priv->status); 366 clear_bit(STATUS_SCANNING, &priv->status);
373 priv->is_internal_short_scan = false;
374 return ret; 367 return ret;
375 } 368 }
376 369
@@ -394,8 +387,7 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw,
394 387
395 mutex_lock(&priv->mutex); 388 mutex_lock(&priv->mutex);
396 389
397 if (test_bit(STATUS_SCANNING, &priv->status) && 390 if (test_bit(STATUS_SCANNING, &priv->status)) {
398 !priv->is_internal_short_scan) {
399 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); 391 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
400 ret = -EAGAIN; 392 ret = -EAGAIN;
401 goto out_unlock; 393 goto out_unlock;
@@ -404,17 +396,9 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw,
404 /* mac80211 will only ask for one band at a time */ 396 /* mac80211 will only ask for one band at a time */
405 priv->scan_request = req; 397 priv->scan_request = req;
406 priv->scan_vif = vif; 398 priv->scan_vif = vif;
399 priv->scan_band = req->channels[0]->band;
407 400
408 /* 401 ret = iwl_legacy_scan_initiate(priv, vif);
409 * If an internal scan is in progress, just set
410 * up the scan_request as per above.
411 */
412 if (priv->is_internal_short_scan) {
413 IWL_DEBUG_SCAN(priv, "SCAN request during internal scan\n");
414 ret = 0;
415 } else
416 ret = iwl_legacy_scan_initiate(priv, vif, false,
417 req->channels[0]->band);
418 402
419 IWL_DEBUG_MAC80211(priv, "leave\n"); 403 IWL_DEBUG_MAC80211(priv, "leave\n");
420 404
@@ -425,40 +409,6 @@ out_unlock:
425} 409}
426EXPORT_SYMBOL(iwl_legacy_mac_hw_scan); 410EXPORT_SYMBOL(iwl_legacy_mac_hw_scan);
427 411
428/*
429 * internal short scan, this function should only been called while associated.
430 * It will reset and tune the radio to prevent possible RF related problem
431 */
432void iwl_legacy_internal_short_hw_scan(struct iwl_priv *priv)
433{
434 queue_work(priv->workqueue, &priv->start_internal_scan);
435}
436
437static void iwl_legacy_bg_start_internal_scan(struct work_struct *work)
438{
439 struct iwl_priv *priv =
440 container_of(work, struct iwl_priv, start_internal_scan);
441
442 IWL_DEBUG_SCAN(priv, "Start internal scan\n");
443
444 mutex_lock(&priv->mutex);
445
446 if (priv->is_internal_short_scan == true) {
447 IWL_DEBUG_SCAN(priv, "Internal scan already in progress\n");
448 goto unlock;
449 }
450
451 if (test_bit(STATUS_SCANNING, &priv->status)) {
452 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
453 goto unlock;
454 }
455
456 if (iwl_legacy_scan_initiate(priv, NULL, true, priv->band))
457 IWL_DEBUG_SCAN(priv, "failed to start internal short scan\n");
458 unlock:
459 mutex_unlock(&priv->mutex);
460}
461
462static void iwl_legacy_bg_scan_check(struct work_struct *data) 412static void iwl_legacy_bg_scan_check(struct work_struct *data)
463{ 413{
464 struct iwl_priv *priv = 414 struct iwl_priv *priv =
@@ -542,8 +492,7 @@ static void iwl_legacy_bg_scan_completed(struct work_struct *work)
542 container_of(work, struct iwl_priv, scan_completed); 492 container_of(work, struct iwl_priv, scan_completed);
543 bool aborted; 493 bool aborted;
544 494
545 IWL_DEBUG_SCAN(priv, "Completed %sscan.\n", 495 IWL_DEBUG_SCAN(priv, "Completed scan.\n");
546 priv->is_internal_short_scan ? "internal short " : "");
547 496
548 cancel_delayed_work(&priv->scan_check); 497 cancel_delayed_work(&priv->scan_check);
549 498
@@ -558,27 +507,6 @@ static void iwl_legacy_bg_scan_completed(struct work_struct *work)
558 goto out_settings; 507 goto out_settings;
559 } 508 }
560 509
561 if (priv->is_internal_short_scan && !aborted) {
562 int err;
563
564 /* Check if mac80211 requested scan during our internal scan */
565 if (priv->scan_request == NULL)
566 goto out_complete;
567
568 /* If so request a new scan */
569 err = iwl_legacy_scan_initiate(priv, priv->scan_vif, false,
570 priv->scan_request->channels[0]->band);
571 if (err) {
572 IWL_DEBUG_SCAN(priv,
573 "failed to initiate pending scan: %d\n", err);
574 aborted = true;
575 goto out_complete;
576 }
577
578 goto out;
579 }
580
581out_complete:
582 iwl_legacy_complete_scan(priv, aborted); 510 iwl_legacy_complete_scan(priv, aborted);
583 511
584out_settings: 512out_settings:
@@ -590,8 +518,7 @@ out_settings:
590 * We do not commit power settings while scan is pending, 518 * We do not commit power settings while scan is pending,
591 * do it now if the settings changed. 519 * do it now if the settings changed.
592 */ 520 */
593 iwl_legacy_power_set_mode(priv, &priv->power_data.sleep_cmd_next, 521 iwl_legacy_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false);
594 false);
595 iwl_legacy_set_tx_power(priv, priv->tx_power_next, false); 522 iwl_legacy_set_tx_power(priv, priv->tx_power_next, false);
596 523
597 priv->cfg->ops->utils->post_scan(priv); 524 priv->cfg->ops->utils->post_scan(priv);
@@ -604,15 +531,12 @@ void iwl_legacy_setup_scan_deferred_work(struct iwl_priv *priv)
604{ 531{
605 INIT_WORK(&priv->scan_completed, iwl_legacy_bg_scan_completed); 532 INIT_WORK(&priv->scan_completed, iwl_legacy_bg_scan_completed);
606 INIT_WORK(&priv->abort_scan, iwl_legacy_bg_abort_scan); 533 INIT_WORK(&priv->abort_scan, iwl_legacy_bg_abort_scan);
607 INIT_WORK(&priv->start_internal_scan,
608 iwl_legacy_bg_start_internal_scan);
609 INIT_DELAYED_WORK(&priv->scan_check, iwl_legacy_bg_scan_check); 534 INIT_DELAYED_WORK(&priv->scan_check, iwl_legacy_bg_scan_check);
610} 535}
611EXPORT_SYMBOL(iwl_legacy_setup_scan_deferred_work); 536EXPORT_SYMBOL(iwl_legacy_setup_scan_deferred_work);
612 537
613void iwl_legacy_cancel_scan_deferred_work(struct iwl_priv *priv) 538void iwl_legacy_cancel_scan_deferred_work(struct iwl_priv *priv)
614{ 539{
615 cancel_work_sync(&priv->start_internal_scan);
616 cancel_work_sync(&priv->abort_scan); 540 cancel_work_sync(&priv->abort_scan);
617 cancel_work_sync(&priv->scan_completed); 541 cancel_work_sync(&priv->scan_completed);
618 542
diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c
index 4fff995c6f3..ef9e268bf8a 100644
--- a/drivers/net/wireless/iwlegacy/iwl-tx.c
+++ b/drivers/net/wireless/iwlegacy/iwl-tx.c
@@ -625,6 +625,8 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
625 cmd = txq->cmd[cmd_index]; 625 cmd = txq->cmd[cmd_index];
626 meta = &txq->meta[cmd_index]; 626 meta = &txq->meta[cmd_index];
627 627
628 txq->time_stamp = jiffies;
629
628 pci_unmap_single(priv->pci_dev, 630 pci_unmap_single(priv->pci_dev,
629 dma_unmap_addr(meta, mapping), 631 dma_unmap_addr(meta, mapping),
630 dma_unmap_len(meta, len), 632 dma_unmap_len(meta, len),
@@ -645,7 +647,7 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
645 clear_bit(STATUS_HCMD_ACTIVE, &priv->status); 647 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
646 IWL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n", 648 IWL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n",
647 iwl_legacy_get_cmd_string(cmd->hdr.cmd)); 649 iwl_legacy_get_cmd_string(cmd->hdr.cmd));
648 wake_up_interruptible(&priv->wait_command_queue); 650 wake_up(&priv->wait_command_queue);
649 } 651 }
650 652
651 /* Mark as unmapped */ 653 /* Mark as unmapped */
diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c
index 0ee6be6a9c5..66ee15629a7 100644
--- a/drivers/net/wireless/iwlegacy/iwl3945-base.c
+++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c
@@ -841,7 +841,7 @@ static void iwl3945_rx_card_state_notif(struct iwl_priv *priv,
841 wiphy_rfkill_set_hw_state(priv->hw->wiphy, 841 wiphy_rfkill_set_hw_state(priv->hw->wiphy,
842 test_bit(STATUS_RF_KILL_HW, &priv->status)); 842 test_bit(STATUS_RF_KILL_HW, &priv->status));
843 else 843 else
844 wake_up_interruptible(&priv->wait_command_queue); 844 wake_up(&priv->wait_command_queue);
845} 845}
846 846
847/** 847/**
@@ -1409,212 +1409,6 @@ void iwl3945_dump_nic_error_log(struct iwl_priv *priv)
1409 } 1409 }
1410} 1410}
1411 1411
1412#define EVENT_START_OFFSET (6 * sizeof(u32))
1413
1414/**
1415 * iwl3945_print_event_log - Dump error event log to syslog
1416 *
1417 */
1418static int iwl3945_print_event_log(struct iwl_priv *priv, u32 start_idx,
1419 u32 num_events, u32 mode,
1420 int pos, char **buf, size_t bufsz)
1421{
1422 u32 i;
1423 u32 base; /* SRAM byte address of event log header */
1424 u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */
1425 u32 ptr; /* SRAM byte address of log data */
1426 u32 ev, time, data; /* event log data */
1427 unsigned long reg_flags;
1428
1429 if (num_events == 0)
1430 return pos;
1431
1432 base = le32_to_cpu(priv->card_alive.log_event_table_ptr);
1433
1434 if (mode == 0)
1435 event_size = 2 * sizeof(u32);
1436 else
1437 event_size = 3 * sizeof(u32);
1438
1439 ptr = base + EVENT_START_OFFSET + (start_idx * event_size);
1440
1441 /* Make sure device is powered up for SRAM reads */
1442 spin_lock_irqsave(&priv->reg_lock, reg_flags);
1443 iwl_grab_nic_access(priv);
1444
1445 /* Set starting address; reads will auto-increment */
1446 _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, ptr);
1447 rmb();
1448
1449 /* "time" is actually "data" for mode 0 (no timestamp).
1450 * place event id # at far right for easier visual parsing. */
1451 for (i = 0; i < num_events; i++) {
1452 ev = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT);
1453 time = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT);
1454 if (mode == 0) {
1455 /* data, ev */
1456 if (bufsz) {
1457 pos += scnprintf(*buf + pos, bufsz - pos,
1458 "0x%08x:%04u\n",
1459 time, ev);
1460 } else {
1461 IWL_ERR(priv, "0x%08x\t%04u\n", time, ev);
1462 trace_iwlwifi_legacy_dev_ucode_event(priv, 0,
1463 time, ev);
1464 }
1465 } else {
1466 data = _iwl_legacy_read_direct32(priv,
1467 HBUS_TARG_MEM_RDAT);
1468 if (bufsz) {
1469 pos += scnprintf(*buf + pos, bufsz - pos,
1470 "%010u:0x%08x:%04u\n",
1471 time, data, ev);
1472 } else {
1473 IWL_ERR(priv, "%010u\t0x%08x\t%04u\n",
1474 time, data, ev);
1475 trace_iwlwifi_legacy_dev_ucode_event(priv, time,
1476 data, ev);
1477 }
1478 }
1479 }
1480
1481 /* Allow device to power down */
1482 iwl_release_nic_access(priv);
1483 spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
1484 return pos;
1485}
1486
1487/**
1488 * iwl3945_print_last_event_logs - Dump the newest # of event log to syslog
1489 */
1490static int iwl3945_print_last_event_logs(struct iwl_priv *priv, u32 capacity,
1491 u32 num_wraps, u32 next_entry,
1492 u32 size, u32 mode,
1493 int pos, char **buf, size_t bufsz)
1494{
1495 /*
1496 * display the newest DEFAULT_LOG_ENTRIES entries
1497 * i.e the entries just before the next ont that uCode would fill.
1498 */
1499 if (num_wraps) {
1500 if (next_entry < size) {
1501 pos = iwl3945_print_event_log(priv,
1502 capacity - (size - next_entry),
1503 size - next_entry, mode,
1504 pos, buf, bufsz);
1505 pos = iwl3945_print_event_log(priv, 0,
1506 next_entry, mode,
1507 pos, buf, bufsz);
1508 } else
1509 pos = iwl3945_print_event_log(priv, next_entry - size,
1510 size, mode,
1511 pos, buf, bufsz);
1512 } else {
1513 if (next_entry < size)
1514 pos = iwl3945_print_event_log(priv, 0,
1515 next_entry, mode,
1516 pos, buf, bufsz);
1517 else
1518 pos = iwl3945_print_event_log(priv, next_entry - size,
1519 size, mode,
1520 pos, buf, bufsz);
1521 }
1522 return pos;
1523}
1524
1525#define DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES (20)
1526
1527int iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
1528 char **buf, bool display)
1529{
1530 u32 base; /* SRAM byte address of event log header */
1531 u32 capacity; /* event log capacity in # entries */
1532 u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */
1533 u32 num_wraps; /* # times uCode wrapped to top of log */
1534 u32 next_entry; /* index of next entry to be written by uCode */
1535 u32 size; /* # entries that we'll print */
1536 int pos = 0;
1537 size_t bufsz = 0;
1538
1539 base = le32_to_cpu(priv->card_alive.log_event_table_ptr);
1540 if (!iwl3945_hw_valid_rtc_data_addr(base)) {
1541 IWL_ERR(priv, "Invalid event log pointer 0x%08X\n", base);
1542 return -EINVAL;
1543 }
1544
1545 /* event log header */
1546 capacity = iwl_legacy_read_targ_mem(priv, base);
1547 mode = iwl_legacy_read_targ_mem(priv, base + (1 * sizeof(u32)));
1548 num_wraps = iwl_legacy_read_targ_mem(priv, base + (2 * sizeof(u32)));
1549 next_entry = iwl_legacy_read_targ_mem(priv, base + (3 * sizeof(u32)));
1550
1551 if (capacity > priv->cfg->base_params->max_event_log_size) {
1552 IWL_ERR(priv, "Log capacity %d is bogus, limit to %d entries\n",
1553 capacity, priv->cfg->base_params->max_event_log_size);
1554 capacity = priv->cfg->base_params->max_event_log_size;
1555 }
1556
1557 if (next_entry > priv->cfg->base_params->max_event_log_size) {
1558 IWL_ERR(priv, "Log write index %d is bogus, limit to %d\n",
1559 next_entry, priv->cfg->base_params->max_event_log_size);
1560 next_entry = priv->cfg->base_params->max_event_log_size;
1561 }
1562
1563 size = num_wraps ? capacity : next_entry;
1564
1565 /* bail out if nothing in log */
1566 if (size == 0) {
1567 IWL_ERR(priv, "Start IWL Event Log Dump: nothing in log\n");
1568 return pos;
1569 }
1570
1571#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
1572 if (!(iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log)
1573 size = (size > DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES)
1574 ? DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES : size;
1575#else
1576 size = (size > DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES)
1577 ? DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES : size;
1578#endif
1579
1580 IWL_ERR(priv, "Start IWL Event Log Dump: display last %d count\n",
1581 size);
1582
1583#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
1584 if (display) {
1585 if (full_log)
1586 bufsz = capacity * 48;
1587 else
1588 bufsz = size * 48;
1589 *buf = kmalloc(bufsz, GFP_KERNEL);
1590 if (!*buf)
1591 return -ENOMEM;
1592 }
1593 if ((iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) || full_log) {
1594 /* if uCode has wrapped back to top of log,
1595 * start at the oldest entry,
1596 * i.e the next one that uCode would fill.
1597 */
1598 if (num_wraps)
1599 pos = iwl3945_print_event_log(priv, next_entry,
1600 capacity - next_entry, mode,
1601 pos, buf, bufsz);
1602
1603 /* (then/else) start at top of log */
1604 pos = iwl3945_print_event_log(priv, 0, next_entry, mode,
1605 pos, buf, bufsz);
1606 } else
1607 pos = iwl3945_print_last_event_logs(priv, capacity, num_wraps,
1608 next_entry, size, mode,
1609 pos, buf, bufsz);
1610#else
1611 pos = iwl3945_print_last_event_logs(priv, capacity, num_wraps,
1612 next_entry, size, mode,
1613 pos, buf, bufsz);
1614#endif
1615 return pos;
1616}
1617
1618static void iwl3945_irq_tasklet(struct iwl_priv *priv) 1412static void iwl3945_irq_tasklet(struct iwl_priv *priv)
1619{ 1413{
1620 u32 inta, handled = 0; 1414 u32 inta, handled = 0;
@@ -1762,49 +1556,6 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
1762#endif 1556#endif
1763} 1557}
1764 1558
1765static int iwl3945_get_single_channel_for_scan(struct iwl_priv *priv,
1766 struct ieee80211_vif *vif,
1767 enum ieee80211_band band,
1768 struct iwl3945_scan_channel *scan_ch)
1769{
1770 const struct ieee80211_supported_band *sband;
1771 u16 passive_dwell = 0;
1772 u16 active_dwell = 0;
1773 int added = 0;
1774 u8 channel = 0;
1775
1776 sband = iwl_get_hw_mode(priv, band);
1777 if (!sband) {
1778 IWL_ERR(priv, "invalid band\n");
1779 return added;
1780 }
1781
1782 active_dwell = iwl_legacy_get_active_dwell_time(priv, band, 0);
1783 passive_dwell = iwl_legacy_get_passive_dwell_time(priv, band, vif);
1784
1785 if (passive_dwell <= active_dwell)
1786 passive_dwell = active_dwell + 1;
1787
1788
1789 channel = iwl_legacy_get_single_channel_number(priv, band);
1790
1791 if (channel) {
1792 scan_ch->channel = channel;
1793 scan_ch->type = 0; /* passive */
1794 scan_ch->active_dwell = cpu_to_le16(active_dwell);
1795 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
1796 /* Set txpower levels to defaults */
1797 scan_ch->tpc.dsp_atten = 110;
1798 if (band == IEEE80211_BAND_5GHZ)
1799 scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3;
1800 else
1801 scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3));
1802 added++;
1803 } else
1804 IWL_ERR(priv, "no valid channel found\n");
1805 return added;
1806}
1807
1808static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, 1559static int iwl3945_get_channels_for_scan(struct iwl_priv *priv,
1809 enum ieee80211_band band, 1560 enum ieee80211_band band,
1810 u8 is_active, u8 n_probes, 1561 u8 is_active, u8 n_probes,
@@ -2518,7 +2269,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2518 iwl3945_reg_txpower_periodic(priv); 2269 iwl3945_reg_txpower_periodic(priv);
2519 2270
2520 IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); 2271 IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
2521 wake_up_interruptible(&priv->wait_command_queue); 2272 wake_up(&priv->wait_command_queue);
2522 2273
2523 return; 2274 return;
2524 2275
@@ -2549,7 +2300,7 @@ static void __iwl3945_down(struct iwl_priv *priv)
2549 iwl_legacy_clear_driver_stations(priv); 2300 iwl_legacy_clear_driver_stations(priv);
2550 2301
2551 /* Unblock any waiting calls */ 2302 /* Unblock any waiting calls */
2552 wake_up_interruptible_all(&priv->wait_command_queue); 2303 wake_up_all(&priv->wait_command_queue);
2553 2304
2554 /* Wipe out the EXIT_PENDING status bit if we are not actually 2305 /* Wipe out the EXIT_PENDING status bit if we are not actually
2555 * exiting the module */ 2306 * exiting the module */
@@ -2816,6 +2567,7 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2816 enum ieee80211_band band; 2567 enum ieee80211_band band;
2817 bool is_active = false; 2568 bool is_active = false;
2818 int ret; 2569 int ret;
2570 u16 len;
2819 2571
2820 lockdep_assert_held(&priv->mutex); 2572 lockdep_assert_held(&priv->mutex);
2821 2573
@@ -2834,17 +2586,14 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2834 scan->quiet_time = IWL_ACTIVE_QUIET_TIME; 2586 scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
2835 2587
2836 if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) { 2588 if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) {
2837 u16 interval = 0; 2589 u16 interval;
2838 u32 extra; 2590 u32 extra;
2839 u32 suspend_time = 100; 2591 u32 suspend_time = 100;
2840 u32 scan_suspend_time = 100; 2592 u32 scan_suspend_time = 100;
2841 2593
2842 IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); 2594 IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
2843 2595
2844 if (priv->is_internal_short_scan) 2596 interval = vif->bss_conf.beacon_int;
2845 interval = 0;
2846 else
2847 interval = vif->bss_conf.beacon_int;
2848 2597
2849 scan->suspend_time = 0; 2598 scan->suspend_time = 0;
2850 scan->max_out_time = cpu_to_le32(200 * 1024); 2599 scan->max_out_time = cpu_to_le32(200 * 1024);
@@ -2866,9 +2615,7 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2866 scan_suspend_time, interval); 2615 scan_suspend_time, interval);
2867 } 2616 }
2868 2617
2869 if (priv->is_internal_short_scan) { 2618 if (priv->scan_request->n_ssids) {
2870 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n");
2871 } else if (priv->scan_request->n_ssids) {
2872 int i, p = 0; 2619 int i, p = 0;
2873 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); 2620 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
2874 for (i = 0; i < priv->scan_request->n_ssids; i++) { 2621 for (i = 0; i < priv->scan_request->n_ssids; i++) {
@@ -2919,36 +2666,17 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2919 scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT : 2666 scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT :
2920 IWL_GOOD_CRC_TH_DISABLED; 2667 IWL_GOOD_CRC_TH_DISABLED;
2921 2668
2922 if (!priv->is_internal_short_scan) { 2669 len = iwl_legacy_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data,
2923 scan->tx_cmd.len = cpu_to_le16( 2670 vif->addr, priv->scan_request->ie,
2924 iwl_legacy_fill_probe_req(priv, 2671 priv->scan_request->ie_len,
2925 (struct ieee80211_mgmt *)scan->data, 2672 IWL_MAX_SCAN_SIZE - sizeof(*scan));
2926 vif->addr, 2673 scan->tx_cmd.len = cpu_to_le16(len);
2927 priv->scan_request->ie, 2674
2928 priv->scan_request->ie_len,
2929 IWL_MAX_SCAN_SIZE - sizeof(*scan)));
2930 } else {
2931 /* use bcast addr, will not be transmitted but must be valid */
2932 scan->tx_cmd.len = cpu_to_le16(
2933 iwl_legacy_fill_probe_req(priv,
2934 (struct ieee80211_mgmt *)scan->data,
2935 iwlegacy_bcast_addr, NULL, 0,
2936 IWL_MAX_SCAN_SIZE - sizeof(*scan)));
2937 }
2938 /* select Rx antennas */ 2675 /* select Rx antennas */
2939 scan->flags |= iwl3945_get_antenna_flags(priv); 2676 scan->flags |= iwl3945_get_antenna_flags(priv);
2940 2677
2941 if (priv->is_internal_short_scan) { 2678 scan->channel_count = iwl3945_get_channels_for_scan(priv, band, is_active, n_probes,
2942 scan->channel_count = 2679 (void *)&scan->data[len], vif);
2943 iwl3945_get_single_channel_for_scan(priv, vif, band,
2944 (void *)&scan->data[le16_to_cpu(
2945 scan->tx_cmd.len)]);
2946 } else {
2947 scan->channel_count =
2948 iwl3945_get_channels_for_scan(priv, band, is_active, n_probes,
2949 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)], vif);
2950 }
2951
2952 if (scan->channel_count == 0) { 2680 if (scan->channel_count == 0) {
2953 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); 2681 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
2954 return -EIO; 2682 return -EIO;
@@ -3125,7 +2853,7 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
3125 2853
3126 /* Wait for START_ALIVE from ucode. Otherwise callbacks from 2854 /* Wait for START_ALIVE from ucode. Otherwise callbacks from
3127 * mac80211 will not be run successfully. */ 2855 * mac80211 will not be run successfully. */
3128 ret = wait_event_interruptible_timeout(priv->wait_command_queue, 2856 ret = wait_event_timeout(priv->wait_command_queue,
3129 test_bit(STATUS_READY, &priv->status), 2857 test_bit(STATUS_READY, &priv->status),
3130 UCODE_READY_TIMEOUT); 2858 UCODE_READY_TIMEOUT);
3131 if (!ret) { 2859 if (!ret) {
@@ -3824,10 +3552,7 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
3824 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; 3552 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF;
3825 3553
3826 /* initialize force reset */ 3554 /* initialize force reset */
3827 priv->force_reset[IWL_RF_RESET].reset_duration = 3555 priv->force_reset.reset_duration = IWL_DELAY_NEXT_FORCE_FW_RELOAD;
3828 IWL_DELAY_NEXT_FORCE_RF_RESET;
3829 priv->force_reset[IWL_FW_RESET].reset_duration =
3830 IWL_DELAY_NEXT_FORCE_FW_RELOAD;
3831 3556
3832 if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { 3557 if (eeprom->version < EEPROM_3945_EEPROM_VERSION) {
3833 IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", 3558 IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n",
diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c
index 7157ba52968..aa0c2539761 100644
--- a/drivers/net/wireless/iwlegacy/iwl4965-base.c
+++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c
@@ -488,134 +488,6 @@ static void iwl4965_bg_statistics_periodic(unsigned long data)
488 iwl_legacy_send_statistics_request(priv, CMD_ASYNC, false); 488 iwl_legacy_send_statistics_request(priv, CMD_ASYNC, false);
489} 489}
490 490
491
492static void iwl4965_print_cont_event_trace(struct iwl_priv *priv, u32 base,
493 u32 start_idx, u32 num_events,
494 u32 mode)
495{
496 u32 i;
497 u32 ptr; /* SRAM byte address of log data */
498 u32 ev, time, data; /* event log data */
499 unsigned long reg_flags;
500
501 if (mode == 0)
502 ptr = base + (4 * sizeof(u32)) + (start_idx * 2 * sizeof(u32));
503 else
504 ptr = base + (4 * sizeof(u32)) + (start_idx * 3 * sizeof(u32));
505
506 /* Make sure device is powered up for SRAM reads */
507 spin_lock_irqsave(&priv->reg_lock, reg_flags);
508 if (iwl_grab_nic_access(priv)) {
509 spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
510 return;
511 }
512
513 /* Set starting address; reads will auto-increment */
514 _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, ptr);
515 rmb();
516
517 /*
518 * "time" is actually "data" for mode 0 (no timestamp).
519 * place event id # at far right for easier visual parsing.
520 */
521 for (i = 0; i < num_events; i++) {
522 ev = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT);
523 time = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT);
524 if (mode == 0) {
525 trace_iwlwifi_legacy_dev_ucode_cont_event(priv,
526 0, time, ev);
527 } else {
528 data = _iwl_legacy_read_direct32(priv,
529 HBUS_TARG_MEM_RDAT);
530 trace_iwlwifi_legacy_dev_ucode_cont_event(priv,
531 time, data, ev);
532 }
533 }
534 /* Allow device to power down */
535 iwl_release_nic_access(priv);
536 spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
537}
538
539static void iwl4965_continuous_event_trace(struct iwl_priv *priv)
540{
541 u32 capacity; /* event log capacity in # entries */
542 u32 base; /* SRAM byte address of event log header */
543 u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */
544 u32 num_wraps; /* # times uCode wrapped to top of log */
545 u32 next_entry; /* index of next entry to be written by uCode */
546
547 if (priv->ucode_type == UCODE_INIT)
548 base = le32_to_cpu(priv->card_alive_init.error_event_table_ptr);
549 else
550 base = le32_to_cpu(priv->card_alive.log_event_table_ptr);
551 if (priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) {
552 capacity = iwl_legacy_read_targ_mem(priv, base);
553 num_wraps = iwl_legacy_read_targ_mem(priv,
554 base + (2 * sizeof(u32)));
555 mode = iwl_legacy_read_targ_mem(priv, base + (1 * sizeof(u32)));
556 next_entry = iwl_legacy_read_targ_mem(priv,
557 base + (3 * sizeof(u32)));
558 } else
559 return;
560
561 if (num_wraps == priv->event_log.num_wraps) {
562 iwl4965_print_cont_event_trace(priv,
563 base, priv->event_log.next_entry,
564 next_entry - priv->event_log.next_entry,
565 mode);
566 priv->event_log.non_wraps_count++;
567 } else {
568 if ((num_wraps - priv->event_log.num_wraps) > 1)
569 priv->event_log.wraps_more_count++;
570 else
571 priv->event_log.wraps_once_count++;
572 trace_iwlwifi_legacy_dev_ucode_wrap_event(priv,
573 num_wraps - priv->event_log.num_wraps,
574 next_entry, priv->event_log.next_entry);
575 if (next_entry < priv->event_log.next_entry) {
576 iwl4965_print_cont_event_trace(priv, base,
577 priv->event_log.next_entry,
578 capacity - priv->event_log.next_entry,
579 mode);
580
581 iwl4965_print_cont_event_trace(priv, base, 0,
582 next_entry, mode);
583 } else {
584 iwl4965_print_cont_event_trace(priv, base,
585 next_entry, capacity - next_entry,
586 mode);
587
588 iwl4965_print_cont_event_trace(priv, base, 0,
589 next_entry, mode);
590 }
591 }
592 priv->event_log.num_wraps = num_wraps;
593 priv->event_log.next_entry = next_entry;
594}
595
596/**
597 * iwl4965_bg_ucode_trace - Timer callback to log ucode event
598 *
599 * The timer is continually set to execute every
600 * UCODE_TRACE_PERIOD milliseconds after the last timer expired
601 * this function is to perform continuous uCode event logging operation
602 * if enabled
603 */
604static void iwl4965_bg_ucode_trace(unsigned long data)
605{
606 struct iwl_priv *priv = (struct iwl_priv *)data;
607
608 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
609 return;
610
611 if (priv->event_log.ucode_trace) {
612 iwl4965_continuous_event_trace(priv);
613 /* Reschedule the timer to occur in UCODE_TRACE_PERIOD */
614 mod_timer(&priv->ucode_trace,
615 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
616 }
617}
618
619static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, 491static void iwl4965_rx_beacon_notif(struct iwl_priv *priv,
620 struct iwl_rx_mem_buffer *rxb) 492 struct iwl_rx_mem_buffer *rxb)
621{ 493{
@@ -704,7 +576,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv,
704 wiphy_rfkill_set_hw_state(priv->hw->wiphy, 576 wiphy_rfkill_set_hw_state(priv->hw->wiphy,
705 test_bit(STATUS_RF_KILL_HW, &priv->status)); 577 test_bit(STATUS_RF_KILL_HW, &priv->status));
706 else 578 else
707 wake_up_interruptible(&priv->wait_command_queue); 579 wake_up(&priv->wait_command_queue);
708} 580}
709 581
710/** 582/**
@@ -1054,7 +926,7 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv)
1054 handled |= CSR_INT_BIT_FH_TX; 926 handled |= CSR_INT_BIT_FH_TX;
1055 /* Wake up uCode load routine, now that load is complete */ 927 /* Wake up uCode load routine, now that load is complete */
1056 priv->ucode_write_complete = 1; 928 priv->ucode_write_complete = 1;
1057 wake_up_interruptible(&priv->wait_command_queue); 929 wake_up(&priv->wait_command_queue);
1058 } 930 }
1059 931
1060 if (inta & ~handled) { 932 if (inta & ~handled) {
@@ -1612,7 +1484,7 @@ static const char * const desc_lookup_text[] = {
1612 "NMI_INTERRUPT_DATA_ACTION_PT", 1484 "NMI_INTERRUPT_DATA_ACTION_PT",
1613 "NMI_TRM_HW_ER", 1485 "NMI_TRM_HW_ER",
1614 "NMI_INTERRUPT_TRM", 1486 "NMI_INTERRUPT_TRM",
1615 "NMI_INTERRUPT_BREAK_POINT" 1487 "NMI_INTERRUPT_BREAK_POINT",
1616 "DEBUG_0", 1488 "DEBUG_0",
1617 "DEBUG_1", 1489 "DEBUG_1",
1618 "DEBUG_2", 1490 "DEBUG_2",
@@ -1711,209 +1583,6 @@ void iwl4965_dump_nic_error_log(struct iwl_priv *priv)
1711 pc, blink1, blink2, ilink1, ilink2, hcmd); 1583 pc, blink1, blink2, ilink1, ilink2, hcmd);
1712} 1584}
1713 1585
1714#define EVENT_START_OFFSET (4 * sizeof(u32))
1715
1716/**
1717 * iwl4965_print_event_log - Dump error event log to syslog
1718 *
1719 */
1720static int iwl4965_print_event_log(struct iwl_priv *priv, u32 start_idx,
1721 u32 num_events, u32 mode,
1722 int pos, char **buf, size_t bufsz)
1723{
1724 u32 i;
1725 u32 base; /* SRAM byte address of event log header */
1726 u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */
1727 u32 ptr; /* SRAM byte address of log data */
1728 u32 ev, time, data; /* event log data */
1729 unsigned long reg_flags;
1730
1731 if (num_events == 0)
1732 return pos;
1733
1734 if (priv->ucode_type == UCODE_INIT) {
1735 base = le32_to_cpu(priv->card_alive_init.log_event_table_ptr);
1736 } else {
1737 base = le32_to_cpu(priv->card_alive.log_event_table_ptr);
1738 }
1739
1740 if (mode == 0)
1741 event_size = 2 * sizeof(u32);
1742 else
1743 event_size = 3 * sizeof(u32);
1744
1745 ptr = base + EVENT_START_OFFSET + (start_idx * event_size);
1746
1747 /* Make sure device is powered up for SRAM reads */
1748 spin_lock_irqsave(&priv->reg_lock, reg_flags);
1749 iwl_grab_nic_access(priv);
1750
1751 /* Set starting address; reads will auto-increment */
1752 _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, ptr);
1753 rmb();
1754
1755 /* "time" is actually "data" for mode 0 (no timestamp).
1756 * place event id # at far right for easier visual parsing. */
1757 for (i = 0; i < num_events; i++) {
1758 ev = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT);
1759 time = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT);
1760 if (mode == 0) {
1761 /* data, ev */
1762 if (bufsz) {
1763 pos += scnprintf(*buf + pos, bufsz - pos,
1764 "EVT_LOG:0x%08x:%04u\n",
1765 time, ev);
1766 } else {
1767 trace_iwlwifi_legacy_dev_ucode_event(priv, 0,
1768 time, ev);
1769 IWL_ERR(priv, "EVT_LOG:0x%08x:%04u\n",
1770 time, ev);
1771 }
1772 } else {
1773 data = _iwl_legacy_read_direct32(priv,
1774 HBUS_TARG_MEM_RDAT);
1775 if (bufsz) {
1776 pos += scnprintf(*buf + pos, bufsz - pos,
1777 "EVT_LOGT:%010u:0x%08x:%04u\n",
1778 time, data, ev);
1779 } else {
1780 IWL_ERR(priv, "EVT_LOGT:%010u:0x%08x:%04u\n",
1781 time, data, ev);
1782 trace_iwlwifi_legacy_dev_ucode_event(priv, time,
1783 data, ev);
1784 }
1785 }
1786 }
1787
1788 /* Allow device to power down */
1789 iwl_release_nic_access(priv);
1790 spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
1791 return pos;
1792}
1793
1794/**
1795 * iwl4965_print_last_event_logs - Dump the newest # of event log to syslog
1796 */
1797static int iwl4965_print_last_event_logs(struct iwl_priv *priv, u32 capacity,
1798 u32 num_wraps, u32 next_entry,
1799 u32 size, u32 mode,
1800 int pos, char **buf, size_t bufsz)
1801{
1802 /*
1803 * display the newest DEFAULT_LOG_ENTRIES entries
1804 * i.e the entries just before the next ont that uCode would fill.
1805 */
1806 if (num_wraps) {
1807 if (next_entry < size) {
1808 pos = iwl4965_print_event_log(priv,
1809 capacity - (size - next_entry),
1810 size - next_entry, mode,
1811 pos, buf, bufsz);
1812 pos = iwl4965_print_event_log(priv, 0,
1813 next_entry, mode,
1814 pos, buf, bufsz);
1815 } else
1816 pos = iwl4965_print_event_log(priv, next_entry - size,
1817 size, mode, pos, buf, bufsz);
1818 } else {
1819 if (next_entry < size) {
1820 pos = iwl4965_print_event_log(priv, 0, next_entry,
1821 mode, pos, buf, bufsz);
1822 } else {
1823 pos = iwl4965_print_event_log(priv, next_entry - size,
1824 size, mode, pos, buf, bufsz);
1825 }
1826 }
1827 return pos;
1828}
1829
1830#define DEFAULT_DUMP_EVENT_LOG_ENTRIES (20)
1831
1832int iwl4965_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
1833 char **buf, bool display)
1834{
1835 u32 base; /* SRAM byte address of event log header */
1836 u32 capacity; /* event log capacity in # entries */
1837 u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */
1838 u32 num_wraps; /* # times uCode wrapped to top of log */
1839 u32 next_entry; /* index of next entry to be written by uCode */
1840 u32 size; /* # entries that we'll print */
1841 int pos = 0;
1842 size_t bufsz = 0;
1843
1844 if (priv->ucode_type == UCODE_INIT) {
1845 base = le32_to_cpu(priv->card_alive_init.log_event_table_ptr);
1846 } else {
1847 base = le32_to_cpu(priv->card_alive.log_event_table_ptr);
1848 }
1849
1850 if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) {
1851 IWL_ERR(priv,
1852 "Invalid event log pointer 0x%08X for %s uCode\n",
1853 base, (priv->ucode_type == UCODE_INIT) ? "Init" : "RT");
1854 return -EINVAL;
1855 }
1856
1857 /* event log header */
1858 capacity = iwl_legacy_read_targ_mem(priv, base);
1859 mode = iwl_legacy_read_targ_mem(priv, base + (1 * sizeof(u32)));
1860 num_wraps = iwl_legacy_read_targ_mem(priv, base + (2 * sizeof(u32)));
1861 next_entry = iwl_legacy_read_targ_mem(priv, base + (3 * sizeof(u32)));
1862
1863 size = num_wraps ? capacity : next_entry;
1864
1865 /* bail out if nothing in log */
1866 if (size == 0) {
1867 IWL_ERR(priv, "Start IWL Event Log Dump: nothing in log\n");
1868 return pos;
1869 }
1870
1871#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
1872 if (!(iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log)
1873 size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
1874 ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
1875#else
1876 size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
1877 ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
1878#endif
1879 IWL_ERR(priv, "Start IWL Event Log Dump: display last %u entries\n",
1880 size);
1881
1882#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
1883 if (display) {
1884 if (full_log)
1885 bufsz = capacity * 48;
1886 else
1887 bufsz = size * 48;
1888 *buf = kmalloc(bufsz, GFP_KERNEL);
1889 if (!*buf)
1890 return -ENOMEM;
1891 }
1892 if ((iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) || full_log) {
1893 /*
1894 * if uCode has wrapped back to top of log,
1895 * start at the oldest entry,
1896 * i.e the next one that uCode would fill.
1897 */
1898 if (num_wraps)
1899 pos = iwl4965_print_event_log(priv, next_entry,
1900 capacity - next_entry, mode,
1901 pos, buf, bufsz);
1902 /* (then/else) start at top of log */
1903 pos = iwl4965_print_event_log(priv, 0,
1904 next_entry, mode, pos, buf, bufsz);
1905 } else
1906 pos = iwl4965_print_last_event_logs(priv, capacity, num_wraps,
1907 next_entry, size, mode,
1908 pos, buf, bufsz);
1909#else
1910 pos = iwl4965_print_last_event_logs(priv, capacity, num_wraps,
1911 next_entry, size, mode,
1912 pos, buf, bufsz);
1913#endif
1914 return pos;
1915}
1916
1917static void iwl4965_rf_kill_ct_config(struct iwl_priv *priv) 1586static void iwl4965_rf_kill_ct_config(struct iwl_priv *priv)
1918{ 1587{
1919 struct iwl_ct_kill_config cmd; 1588 struct iwl_ct_kill_config cmd;
@@ -2126,7 +1795,7 @@ static void iwl4965_alive_start(struct iwl_priv *priv)
2126 iwl4965_rf_kill_ct_config(priv); 1795 iwl4965_rf_kill_ct_config(priv);
2127 1796
2128 IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); 1797 IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
2129 wake_up_interruptible(&priv->wait_command_queue); 1798 wake_up(&priv->wait_command_queue);
2130 1799
2131 iwl_legacy_power_update_mode(priv, true); 1800 iwl_legacy_power_update_mode(priv, true);
2132 IWL_DEBUG_INFO(priv, "Updated power mode\n"); 1801 IWL_DEBUG_INFO(priv, "Updated power mode\n");
@@ -2159,7 +1828,7 @@ static void __iwl4965_down(struct iwl_priv *priv)
2159 iwl_legacy_clear_driver_stations(priv); 1828 iwl_legacy_clear_driver_stations(priv);
2160 1829
2161 /* Unblock any waiting calls */ 1830 /* Unblock any waiting calls */
2162 wake_up_interruptible_all(&priv->wait_command_queue); 1831 wake_up_all(&priv->wait_command_queue);
2163 1832
2164 /* Wipe out the EXIT_PENDING status bit if we are not actually 1833 /* Wipe out the EXIT_PENDING status bit if we are not actually
2165 * exiting the module */ 1834 * exiting the module */
@@ -2597,7 +2266,7 @@ int iwl4965_mac_start(struct ieee80211_hw *hw)
2597 2266
2598 /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from 2267 /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from
2599 * mac80211 will not be run successfully. */ 2268 * mac80211 will not be run successfully. */
2600 ret = wait_event_interruptible_timeout(priv->wait_command_queue, 2269 ret = wait_event_timeout(priv->wait_command_queue,
2601 test_bit(STATUS_READY, &priv->status), 2270 test_bit(STATUS_READY, &priv->status),
2602 UCODE_READY_TIMEOUT); 2271 UCODE_READY_TIMEOUT);
2603 if (!ret) { 2272 if (!ret) {
@@ -2773,20 +2442,10 @@ int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
2773 case IEEE80211_AMPDU_TX_START: 2442 case IEEE80211_AMPDU_TX_START:
2774 IWL_DEBUG_HT(priv, "start Tx\n"); 2443 IWL_DEBUG_HT(priv, "start Tx\n");
2775 ret = iwl4965_tx_agg_start(priv, vif, sta, tid, ssn); 2444 ret = iwl4965_tx_agg_start(priv, vif, sta, tid, ssn);
2776 if (ret == 0) {
2777 priv->_4965.agg_tids_count++;
2778 IWL_DEBUG_HT(priv, "priv->_4965.agg_tids_count = %u\n",
2779 priv->_4965.agg_tids_count);
2780 }
2781 break; 2445 break;
2782 case IEEE80211_AMPDU_TX_STOP: 2446 case IEEE80211_AMPDU_TX_STOP:
2783 IWL_DEBUG_HT(priv, "stop Tx\n"); 2447 IWL_DEBUG_HT(priv, "stop Tx\n");
2784 ret = iwl4965_tx_agg_stop(priv, vif, sta, tid); 2448 ret = iwl4965_tx_agg_stop(priv, vif, sta, tid);
2785 if ((ret == 0) && (priv->_4965.agg_tids_count > 0)) {
2786 priv->_4965.agg_tids_count--;
2787 IWL_DEBUG_HT(priv, "priv->_4965.agg_tids_count = %u\n",
2788 priv->_4965.agg_tids_count);
2789 }
2790 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2449 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2791 ret = 0; 2450 ret = 0;
2792 break; 2451 break;
@@ -2851,7 +2510,6 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw,
2851 2510
2852 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 2511 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
2853 u16 ch; 2512 u16 ch;
2854 unsigned long flags = 0;
2855 2513
2856 IWL_DEBUG_MAC80211(priv, "enter\n"); 2514 IWL_DEBUG_MAC80211(priv, "enter\n");
2857 2515
@@ -2868,64 +2526,64 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw,
2868 if (!iwl_legacy_is_associated_ctx(ctx)) 2526 if (!iwl_legacy_is_associated_ctx(ctx))
2869 goto out; 2527 goto out;
2870 2528
2871 if (priv->cfg->ops->lib->set_channel_switch) { 2529 if (!priv->cfg->ops->lib->set_channel_switch)
2530 goto out;
2872 2531
2873 ch = channel->hw_value; 2532 ch = channel->hw_value;
2874 if (le16_to_cpu(ctx->active.channel) != ch) { 2533 if (le16_to_cpu(ctx->active.channel) == ch)
2875 ch_info = iwl_legacy_get_channel_info(priv, 2534 goto out;
2876 channel->band, 2535
2877 ch); 2536 ch_info = iwl_legacy_get_channel_info(priv, channel->band, ch);
2878 if (!iwl_legacy_is_channel_valid(ch_info)) { 2537 if (!iwl_legacy_is_channel_valid(ch_info)) {
2879 IWL_DEBUG_MAC80211(priv, "invalid channel\n"); 2538 IWL_DEBUG_MAC80211(priv, "invalid channel\n");
2880 goto out; 2539 goto out;
2881 } 2540 }
2882 spin_lock_irqsave(&priv->lock, flags); 2541
2883 2542 spin_lock_irq(&priv->lock);
2884 priv->current_ht_config.smps = conf->smps_mode; 2543
2885 2544 priv->current_ht_config.smps = conf->smps_mode;
2886 /* Configure HT40 channels */ 2545
2887 ctx->ht.enabled = conf_is_ht(conf); 2546 /* Configure HT40 channels */
2888 if (ctx->ht.enabled) { 2547 ctx->ht.enabled = conf_is_ht(conf);
2889 if (conf_is_ht40_minus(conf)) { 2548 if (ctx->ht.enabled) {
2890 ctx->ht.extension_chan_offset = 2549 if (conf_is_ht40_minus(conf)) {
2891 IEEE80211_HT_PARAM_CHA_SEC_BELOW; 2550 ctx->ht.extension_chan_offset =
2892 ctx->ht.is_40mhz = true; 2551 IEEE80211_HT_PARAM_CHA_SEC_BELOW;
2893 } else if (conf_is_ht40_plus(conf)) { 2552 ctx->ht.is_40mhz = true;
2894 ctx->ht.extension_chan_offset = 2553 } else if (conf_is_ht40_plus(conf)) {
2895 IEEE80211_HT_PARAM_CHA_SEC_ABOVE; 2554 ctx->ht.extension_chan_offset =
2896 ctx->ht.is_40mhz = true; 2555 IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
2897 } else { 2556 ctx->ht.is_40mhz = true;
2898 ctx->ht.extension_chan_offset = 2557 } else {
2899 IEEE80211_HT_PARAM_CHA_SEC_NONE; 2558 ctx->ht.extension_chan_offset =
2900 ctx->ht.is_40mhz = false; 2559 IEEE80211_HT_PARAM_CHA_SEC_NONE;
2901 } 2560 ctx->ht.is_40mhz = false;
2902 } else
2903 ctx->ht.is_40mhz = false;
2904
2905 if ((le16_to_cpu(ctx->staging.channel) != ch))
2906 ctx->staging.flags = 0;
2907
2908 iwl_legacy_set_rxon_channel(priv, channel, ctx);
2909 iwl_legacy_set_rxon_ht(priv, ht_conf);
2910 iwl_legacy_set_flags_for_band(priv, ctx, channel->band,
2911 ctx->vif);
2912 spin_unlock_irqrestore(&priv->lock, flags);
2913
2914 iwl_legacy_set_rate(priv);
2915 /*
2916 * at this point, staging_rxon has the
2917 * configuration for channel switch
2918 */
2919 set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
2920 priv->switch_channel = cpu_to_le16(ch);
2921 if (priv->cfg->ops->lib->set_channel_switch(priv, ch_switch)) {
2922 clear_bit(STATUS_CHANNEL_SWITCH_PENDING,
2923 &priv->status);
2924 priv->switch_channel = 0;
2925 ieee80211_chswitch_done(ctx->vif, false);
2926 }
2927 } 2561 }
2562 } else
2563 ctx->ht.is_40mhz = false;
2564
2565 if ((le16_to_cpu(ctx->staging.channel) != ch))
2566 ctx->staging.flags = 0;
2567
2568 iwl_legacy_set_rxon_channel(priv, channel, ctx);
2569 iwl_legacy_set_rxon_ht(priv, ht_conf);
2570 iwl_legacy_set_flags_for_band(priv, ctx, channel->band, ctx->vif);
2571
2572 spin_unlock_irq(&priv->lock);
2573
2574 iwl_legacy_set_rate(priv);
2575 /*
2576 * at this point, staging_rxon has the
2577 * configuration for channel switch
2578 */
2579 set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
2580 priv->switch_channel = cpu_to_le16(ch);
2581 if (priv->cfg->ops->lib->set_channel_switch(priv, ch_switch)) {
2582 clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
2583 priv->switch_channel = 0;
2584 ieee80211_chswitch_done(ctx->vif, false);
2928 } 2585 }
2586
2929out: 2587out:
2930 mutex_unlock(&priv->mutex); 2588 mutex_unlock(&priv->mutex);
2931 IWL_DEBUG_MAC80211(priv, "leave\n"); 2589 IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -3034,10 +2692,6 @@ static void iwl4965_setup_deferred_work(struct iwl_priv *priv)
3034 priv->statistics_periodic.data = (unsigned long)priv; 2692 priv->statistics_periodic.data = (unsigned long)priv;
3035 priv->statistics_periodic.function = iwl4965_bg_statistics_periodic; 2693 priv->statistics_periodic.function = iwl4965_bg_statistics_periodic;
3036 2694
3037 init_timer(&priv->ucode_trace);
3038 priv->ucode_trace.data = (unsigned long)priv;
3039 priv->ucode_trace.function = iwl4965_bg_ucode_trace;
3040
3041 init_timer(&priv->watchdog); 2695 init_timer(&priv->watchdog);
3042 priv->watchdog.data = (unsigned long)priv; 2696 priv->watchdog.data = (unsigned long)priv;
3043 priv->watchdog.function = iwl_legacy_bg_watchdog; 2697 priv->watchdog.function = iwl_legacy_bg_watchdog;
@@ -3056,7 +2710,6 @@ static void iwl4965_cancel_deferred_work(struct iwl_priv *priv)
3056 iwl_legacy_cancel_scan_deferred_work(priv); 2710 iwl_legacy_cancel_scan_deferred_work(priv);
3057 2711
3058 del_timer_sync(&priv->statistics_periodic); 2712 del_timer_sync(&priv->statistics_periodic);
3059 del_timer_sync(&priv->ucode_trace);
3060} 2713}
3061 2714
3062static void iwl4965_init_hw_rates(struct iwl_priv *priv, 2715static void iwl4965_init_hw_rates(struct iwl_priv *priv,
@@ -3132,13 +2785,9 @@ static int iwl4965_init_drv(struct iwl_priv *priv)
3132 priv->iw_mode = NL80211_IFTYPE_STATION; 2785 priv->iw_mode = NL80211_IFTYPE_STATION;
3133 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; 2786 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC;
3134 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; 2787 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF;
3135 priv->_4965.agg_tids_count = 0;
3136 2788
3137 /* initialize force reset */ 2789 /* initialize force reset */
3138 priv->force_reset[IWL_RF_RESET].reset_duration = 2790 priv->force_reset.reset_duration = IWL_DELAY_NEXT_FORCE_FW_RELOAD;
3139 IWL_DELAY_NEXT_FORCE_RF_RESET;
3140 priv->force_reset[IWL_FW_RESET].reset_duration =
3141 IWL_DELAY_NEXT_FORCE_FW_RELOAD;
3142 2791
3143 /* Choose which receivers/antennas to use */ 2792 /* Choose which receivers/antennas to use */
3144 if (priv->cfg->ops->hcmd->set_rxon_chain) 2793 if (priv->cfg->ops->hcmd->set_rxon_chain)