diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2011-02-28 08:33:17 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-02-28 14:11:36 -0500 |
commit | 67289941d80f18fd8239e350e015a4b84878412b (patch) | |
tree | acc5e98bfdc1f1fcf19ac0bc7698fa6f581cc5a6 | |
parent | ad6e82a5348e494c0023d77fa55933f23b55711c (diff) |
iwlwifi: move remaining iwl-agn-rx.c code into iwl-rx.c
There is no need to have separate iwl-agn-rx.c file after iwlegacy
split.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 264 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-core.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-rx.c | 226 |
4 files changed, 225 insertions, 269 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index aab7d15bd5ed..9d6ee836426c 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | obj-$(CONFIG_IWLAGN) += iwlagn.o | 2 | obj-$(CONFIG_IWLAGN) += iwlagn.o |
3 | iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o | 3 | iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o |
4 | iwlagn-objs += iwl-agn-ucode.o iwl-agn-tx.o | 4 | iwlagn-objs += iwl-agn-ucode.o iwl-agn-tx.o |
5 | iwlagn-objs += iwl-agn-lib.o iwl-agn-rx.o iwl-agn-calib.o | 5 | iwlagn-objs += iwl-agn-lib.o iwl-agn-calib.o |
6 | iwlagn-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-eeprom.o | 6 | iwlagn-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-eeprom.o |
7 | 7 | ||
8 | iwlagn-objs += iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o | 8 | iwlagn-objs += iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c deleted file mode 100644 index 7a89a55ec316..000000000000 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ /dev/null | |||
@@ -1,264 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * GPL LICENSE SUMMARY | ||
4 | * | ||
5 | * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of version 2 of the GNU General Public License as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, | ||
19 | * USA | ||
20 | * | ||
21 | * The full GNU General Public License is included in this distribution | ||
22 | * in the file called LICENSE.GPL. | ||
23 | * | ||
24 | * Contact Information: | ||
25 | * Intel Linux Wireless <ilw@linux.intel.com> | ||
26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
27 | * | ||
28 | *****************************************************************************/ | ||
29 | |||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/sched.h> | ||
34 | |||
35 | #include "iwl-dev.h" | ||
36 | #include "iwl-core.h" | ||
37 | #include "iwl-agn-calib.h" | ||
38 | #include "iwl-sta.h" | ||
39 | #include "iwl-io.h" | ||
40 | #include "iwl-helpers.h" | ||
41 | #include "iwl-agn-hw.h" | ||
42 | #include "iwl-agn.h" | ||
43 | |||
44 | void iwl_rx_missed_beacon_notif(struct iwl_priv *priv, | ||
45 | struct iwl_rx_mem_buffer *rxb) | ||
46 | |||
47 | { | ||
48 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | ||
49 | struct iwl_missed_beacon_notif *missed_beacon; | ||
50 | |||
51 | missed_beacon = &pkt->u.missed_beacon; | ||
52 | if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > | ||
53 | priv->missed_beacon_threshold) { | ||
54 | IWL_DEBUG_CALIB(priv, | ||
55 | "missed bcn cnsq %d totl %d rcd %d expctd %d\n", | ||
56 | le32_to_cpu(missed_beacon->consecutive_missed_beacons), | ||
57 | le32_to_cpu(missed_beacon->total_missed_becons), | ||
58 | le32_to_cpu(missed_beacon->num_recvd_beacons), | ||
59 | le32_to_cpu(missed_beacon->num_expected_beacons)); | ||
60 | if (!test_bit(STATUS_SCANNING, &priv->status)) | ||
61 | iwl_init_sensitivity(priv); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | /* Calculate noise level, based on measurements during network silence just | ||
66 | * before arriving beacon. This measurement can be done only if we know | ||
67 | * exactly when to expect beacons, therefore only when we're associated. */ | ||
68 | static void iwl_rx_calc_noise(struct iwl_priv *priv) | ||
69 | { | ||
70 | struct statistics_rx_non_phy *rx_info; | ||
71 | int num_active_rx = 0; | ||
72 | int total_silence = 0; | ||
73 | int bcn_silence_a, bcn_silence_b, bcn_silence_c; | ||
74 | int last_rx_noise; | ||
75 | |||
76 | if (iwl_bt_statistics(priv)) | ||
77 | rx_info = &(priv->_agn.statistics_bt.rx.general.common); | ||
78 | else | ||
79 | rx_info = &(priv->_agn.statistics.rx.general); | ||
80 | bcn_silence_a = | ||
81 | le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; | ||
82 | bcn_silence_b = | ||
83 | le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; | ||
84 | bcn_silence_c = | ||
85 | le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; | ||
86 | |||
87 | if (bcn_silence_a) { | ||
88 | total_silence += bcn_silence_a; | ||
89 | num_active_rx++; | ||
90 | } | ||
91 | if (bcn_silence_b) { | ||
92 | total_silence += bcn_silence_b; | ||
93 | num_active_rx++; | ||
94 | } | ||
95 | if (bcn_silence_c) { | ||
96 | total_silence += bcn_silence_c; | ||
97 | num_active_rx++; | ||
98 | } | ||
99 | |||
100 | /* Average among active antennas */ | ||
101 | if (num_active_rx) | ||
102 | last_rx_noise = (total_silence / num_active_rx) - 107; | ||
103 | else | ||
104 | last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE; | ||
105 | |||
106 | IWL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n", | ||
107 | bcn_silence_a, bcn_silence_b, bcn_silence_c, | ||
108 | last_rx_noise); | ||
109 | } | ||
110 | |||
111 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
112 | /* | ||
113 | * based on the assumption of all statistics counter are in DWORD | ||
114 | * FIXME: This function is for debugging, do not deal with | ||
115 | * the case of counters roll-over. | ||
116 | */ | ||
117 | static void iwl_accumulative_statistics(struct iwl_priv *priv, | ||
118 | __le32 *stats) | ||
119 | { | ||
120 | int i, size; | ||
121 | __le32 *prev_stats; | ||
122 | u32 *accum_stats; | ||
123 | u32 *delta, *max_delta; | ||
124 | struct statistics_general_common *general, *accum_general; | ||
125 | struct statistics_tx *tx, *accum_tx; | ||
126 | |||
127 | if (iwl_bt_statistics(priv)) { | ||
128 | prev_stats = (__le32 *)&priv->_agn.statistics_bt; | ||
129 | accum_stats = (u32 *)&priv->_agn.accum_statistics_bt; | ||
130 | size = sizeof(struct iwl_bt_notif_statistics); | ||
131 | general = &priv->_agn.statistics_bt.general.common; | ||
132 | accum_general = &priv->_agn.accum_statistics_bt.general.common; | ||
133 | tx = &priv->_agn.statistics_bt.tx; | ||
134 | accum_tx = &priv->_agn.accum_statistics_bt.tx; | ||
135 | delta = (u32 *)&priv->_agn.delta_statistics_bt; | ||
136 | max_delta = (u32 *)&priv->_agn.max_delta_bt; | ||
137 | } else { | ||
138 | prev_stats = (__le32 *)&priv->_agn.statistics; | ||
139 | accum_stats = (u32 *)&priv->_agn.accum_statistics; | ||
140 | size = sizeof(struct iwl_notif_statistics); | ||
141 | general = &priv->_agn.statistics.general.common; | ||
142 | accum_general = &priv->_agn.accum_statistics.general.common; | ||
143 | tx = &priv->_agn.statistics.tx; | ||
144 | accum_tx = &priv->_agn.accum_statistics.tx; | ||
145 | delta = (u32 *)&priv->_agn.delta_statistics; | ||
146 | max_delta = (u32 *)&priv->_agn.max_delta; | ||
147 | } | ||
148 | for (i = sizeof(__le32); i < size; | ||
149 | i += sizeof(__le32), stats++, prev_stats++, delta++, | ||
150 | max_delta++, accum_stats++) { | ||
151 | if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { | ||
152 | *delta = (le32_to_cpu(*stats) - | ||
153 | le32_to_cpu(*prev_stats)); | ||
154 | *accum_stats += *delta; | ||
155 | if (*delta > *max_delta) | ||
156 | *max_delta = *delta; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | /* reset accumulative statistics for "no-counter" type statistics */ | ||
161 | accum_general->temperature = general->temperature; | ||
162 | accum_general->temperature_m = general->temperature_m; | ||
163 | accum_general->ttl_timestamp = general->ttl_timestamp; | ||
164 | accum_tx->tx_power.ant_a = tx->tx_power.ant_a; | ||
165 | accum_tx->tx_power.ant_b = tx->tx_power.ant_b; | ||
166 | accum_tx->tx_power.ant_c = tx->tx_power.ant_c; | ||
167 | } | ||
168 | #endif | ||
169 | |||
170 | #define REG_RECALIB_PERIOD (60) | ||
171 | |||
172 | void iwl_rx_statistics(struct iwl_priv *priv, | ||
173 | struct iwl_rx_mem_buffer *rxb) | ||
174 | { | ||
175 | int change; | ||
176 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | ||
177 | |||
178 | if (iwl_bt_statistics(priv)) { | ||
179 | IWL_DEBUG_RX(priv, | ||
180 | "Statistics notification received (%d vs %d).\n", | ||
181 | (int)sizeof(struct iwl_bt_notif_statistics), | ||
182 | le32_to_cpu(pkt->len_n_flags) & | ||
183 | FH_RSCSR_FRAME_SIZE_MSK); | ||
184 | |||
185 | change = ((priv->_agn.statistics_bt.general.common.temperature != | ||
186 | pkt->u.stats_bt.general.common.temperature) || | ||
187 | ((priv->_agn.statistics_bt.flag & | ||
188 | STATISTICS_REPLY_FLG_HT40_MODE_MSK) != | ||
189 | (pkt->u.stats_bt.flag & | ||
190 | STATISTICS_REPLY_FLG_HT40_MODE_MSK))); | ||
191 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
192 | iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats_bt); | ||
193 | #endif | ||
194 | |||
195 | } else { | ||
196 | IWL_DEBUG_RX(priv, | ||
197 | "Statistics notification received (%d vs %d).\n", | ||
198 | (int)sizeof(struct iwl_notif_statistics), | ||
199 | le32_to_cpu(pkt->len_n_flags) & | ||
200 | FH_RSCSR_FRAME_SIZE_MSK); | ||
201 | |||
202 | change = ((priv->_agn.statistics.general.common.temperature != | ||
203 | pkt->u.stats.general.common.temperature) || | ||
204 | ((priv->_agn.statistics.flag & | ||
205 | STATISTICS_REPLY_FLG_HT40_MODE_MSK) != | ||
206 | (pkt->u.stats.flag & | ||
207 | STATISTICS_REPLY_FLG_HT40_MODE_MSK))); | ||
208 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
209 | iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); | ||
210 | #endif | ||
211 | |||
212 | } | ||
213 | |||
214 | iwl_recover_from_statistics(priv, pkt); | ||
215 | |||
216 | if (iwl_bt_statistics(priv)) | ||
217 | memcpy(&priv->_agn.statistics_bt, &pkt->u.stats_bt, | ||
218 | sizeof(priv->_agn.statistics_bt)); | ||
219 | else | ||
220 | memcpy(&priv->_agn.statistics, &pkt->u.stats, | ||
221 | sizeof(priv->_agn.statistics)); | ||
222 | |||
223 | set_bit(STATUS_STATISTICS, &priv->status); | ||
224 | |||
225 | /* Reschedule the statistics timer to occur in | ||
226 | * REG_RECALIB_PERIOD seconds to ensure we get a | ||
227 | * thermal update even if the uCode doesn't give | ||
228 | * us one */ | ||
229 | mod_timer(&priv->statistics_periodic, jiffies + | ||
230 | msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); | ||
231 | |||
232 | if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && | ||
233 | (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { | ||
234 | iwl_rx_calc_noise(priv); | ||
235 | queue_work(priv->workqueue, &priv->run_time_calib_work); | ||
236 | } | ||
237 | if (priv->cfg->ops->lib->temp_ops.temperature && change) | ||
238 | priv->cfg->ops->lib->temp_ops.temperature(priv); | ||
239 | } | ||
240 | |||
241 | void iwl_reply_statistics(struct iwl_priv *priv, | ||
242 | struct iwl_rx_mem_buffer *rxb) | ||
243 | { | ||
244 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | ||
245 | |||
246 | if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { | ||
247 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
248 | memset(&priv->_agn.accum_statistics, 0, | ||
249 | sizeof(struct iwl_notif_statistics)); | ||
250 | memset(&priv->_agn.delta_statistics, 0, | ||
251 | sizeof(struct iwl_notif_statistics)); | ||
252 | memset(&priv->_agn.max_delta, 0, | ||
253 | sizeof(struct iwl_notif_statistics)); | ||
254 | memset(&priv->_agn.accum_statistics_bt, 0, | ||
255 | sizeof(struct iwl_bt_notif_statistics)); | ||
256 | memset(&priv->_agn.delta_statistics_bt, 0, | ||
257 | sizeof(struct iwl_bt_notif_statistics)); | ||
258 | memset(&priv->_agn.max_delta_bt, 0, | ||
259 | sizeof(struct iwl_bt_notif_statistics)); | ||
260 | #endif | ||
261 | IWL_DEBUG_RX(priv, "Statistics have been cleared\n"); | ||
262 | } | ||
263 | iwl_rx_statistics(priv, rxb); | ||
264 | } | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 193ca98a6231..d47f3a87fce4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h | |||
@@ -516,8 +516,6 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb); | |||
516 | /* Handlers */ | 516 | /* Handlers */ |
517 | void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv, | 517 | void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv, |
518 | struct iwl_rx_mem_buffer *rxb); | 518 | struct iwl_rx_mem_buffer *rxb); |
519 | void iwl_recover_from_statistics(struct iwl_priv *priv, | ||
520 | struct iwl_rx_packet *pkt); | ||
521 | void iwl_chswitch_done(struct iwl_priv *priv, bool is_success); | 519 | void iwl_chswitch_done(struct iwl_priv *priv, bool is_success); |
522 | void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb); | 520 | void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb); |
523 | 521 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c index feee76181ac5..566e2d979ce3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-rx.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include "iwl-sta.h" | 37 | #include "iwl-sta.h" |
38 | #include "iwl-io.h" | 38 | #include "iwl-io.h" |
39 | #include "iwl-helpers.h" | 39 | #include "iwl-helpers.h" |
40 | #include "iwl-agn-calib.h" | ||
40 | /************************** RX-FUNCTIONS ****************************/ | 41 | /************************** RX-FUNCTIONS ****************************/ |
41 | /* | 42 | /* |
42 | * Rx theory of operation | 43 | * Rx theory of operation |
@@ -210,7 +211,6 @@ err_bd: | |||
210 | return -ENOMEM; | 211 | return -ENOMEM; |
211 | } | 212 | } |
212 | 213 | ||
213 | |||
214 | void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv, | 214 | void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv, |
215 | struct iwl_rx_mem_buffer *rxb) | 215 | struct iwl_rx_mem_buffer *rxb) |
216 | { | 216 | { |
@@ -378,7 +378,7 @@ static bool iwl_good_plcp_health(struct iwl_priv *priv, struct iwl_rx_packet *pk | |||
378 | return rc; | 378 | return rc; |
379 | } | 379 | } |
380 | 380 | ||
381 | void iwl_recover_from_statistics(struct iwl_priv *priv, struct iwl_rx_packet *pkt) | 381 | static void iwl_recover_from_statistics(struct iwl_priv *priv, struct iwl_rx_packet *pkt) |
382 | { | 382 | { |
383 | const struct iwl_mod_params *mod_params = priv->cfg->mod_params; | 383 | const struct iwl_mod_params *mod_params = priv->cfg->mod_params; |
384 | 384 | ||
@@ -396,6 +396,228 @@ void iwl_recover_from_statistics(struct iwl_priv *priv, struct iwl_rx_packet *pk | |||
396 | iwl_force_reset(priv, IWL_RF_RESET, false); | 396 | iwl_force_reset(priv, IWL_RF_RESET, false); |
397 | } | 397 | } |
398 | 398 | ||
399 | /* Calculate noise level, based on measurements during network silence just | ||
400 | * before arriving beacon. This measurement can be done only if we know | ||
401 | * exactly when to expect beacons, therefore only when we're associated. */ | ||
402 | static void iwl_rx_calc_noise(struct iwl_priv *priv) | ||
403 | { | ||
404 | struct statistics_rx_non_phy *rx_info; | ||
405 | int num_active_rx = 0; | ||
406 | int total_silence = 0; | ||
407 | int bcn_silence_a, bcn_silence_b, bcn_silence_c; | ||
408 | int last_rx_noise; | ||
409 | |||
410 | if (iwl_bt_statistics(priv)) | ||
411 | rx_info = &(priv->_agn.statistics_bt.rx.general.common); | ||
412 | else | ||
413 | rx_info = &(priv->_agn.statistics.rx.general); | ||
414 | bcn_silence_a = | ||
415 | le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; | ||
416 | bcn_silence_b = | ||
417 | le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; | ||
418 | bcn_silence_c = | ||
419 | le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; | ||
420 | |||
421 | if (bcn_silence_a) { | ||
422 | total_silence += bcn_silence_a; | ||
423 | num_active_rx++; | ||
424 | } | ||
425 | if (bcn_silence_b) { | ||
426 | total_silence += bcn_silence_b; | ||
427 | num_active_rx++; | ||
428 | } | ||
429 | if (bcn_silence_c) { | ||
430 | total_silence += bcn_silence_c; | ||
431 | num_active_rx++; | ||
432 | } | ||
433 | |||
434 | /* Average among active antennas */ | ||
435 | if (num_active_rx) | ||
436 | last_rx_noise = (total_silence / num_active_rx) - 107; | ||
437 | else | ||
438 | last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE; | ||
439 | |||
440 | IWL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n", | ||
441 | bcn_silence_a, bcn_silence_b, bcn_silence_c, | ||
442 | last_rx_noise); | ||
443 | } | ||
444 | |||
445 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
446 | /* | ||
447 | * based on the assumption of all statistics counter are in DWORD | ||
448 | * FIXME: This function is for debugging, do not deal with | ||
449 | * the case of counters roll-over. | ||
450 | */ | ||
451 | static void iwl_accumulative_statistics(struct iwl_priv *priv, | ||
452 | __le32 *stats) | ||
453 | { | ||
454 | int i, size; | ||
455 | __le32 *prev_stats; | ||
456 | u32 *accum_stats; | ||
457 | u32 *delta, *max_delta; | ||
458 | struct statistics_general_common *general, *accum_general; | ||
459 | struct statistics_tx *tx, *accum_tx; | ||
460 | |||
461 | if (iwl_bt_statistics(priv)) { | ||
462 | prev_stats = (__le32 *)&priv->_agn.statistics_bt; | ||
463 | accum_stats = (u32 *)&priv->_agn.accum_statistics_bt; | ||
464 | size = sizeof(struct iwl_bt_notif_statistics); | ||
465 | general = &priv->_agn.statistics_bt.general.common; | ||
466 | accum_general = &priv->_agn.accum_statistics_bt.general.common; | ||
467 | tx = &priv->_agn.statistics_bt.tx; | ||
468 | accum_tx = &priv->_agn.accum_statistics_bt.tx; | ||
469 | delta = (u32 *)&priv->_agn.delta_statistics_bt; | ||
470 | max_delta = (u32 *)&priv->_agn.max_delta_bt; | ||
471 | } else { | ||
472 | prev_stats = (__le32 *)&priv->_agn.statistics; | ||
473 | accum_stats = (u32 *)&priv->_agn.accum_statistics; | ||
474 | size = sizeof(struct iwl_notif_statistics); | ||
475 | general = &priv->_agn.statistics.general.common; | ||
476 | accum_general = &priv->_agn.accum_statistics.general.common; | ||
477 | tx = &priv->_agn.statistics.tx; | ||
478 | accum_tx = &priv->_agn.accum_statistics.tx; | ||
479 | delta = (u32 *)&priv->_agn.delta_statistics; | ||
480 | max_delta = (u32 *)&priv->_agn.max_delta; | ||
481 | } | ||
482 | for (i = sizeof(__le32); i < size; | ||
483 | i += sizeof(__le32), stats++, prev_stats++, delta++, | ||
484 | max_delta++, accum_stats++) { | ||
485 | if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { | ||
486 | *delta = (le32_to_cpu(*stats) - | ||
487 | le32_to_cpu(*prev_stats)); | ||
488 | *accum_stats += *delta; | ||
489 | if (*delta > *max_delta) | ||
490 | *max_delta = *delta; | ||
491 | } | ||
492 | } | ||
493 | |||
494 | /* reset accumulative statistics for "no-counter" type statistics */ | ||
495 | accum_general->temperature = general->temperature; | ||
496 | accum_general->temperature_m = general->temperature_m; | ||
497 | accum_general->ttl_timestamp = general->ttl_timestamp; | ||
498 | accum_tx->tx_power.ant_a = tx->tx_power.ant_a; | ||
499 | accum_tx->tx_power.ant_b = tx->tx_power.ant_b; | ||
500 | accum_tx->tx_power.ant_c = tx->tx_power.ant_c; | ||
501 | } | ||
502 | #endif | ||
503 | |||
504 | #define REG_RECALIB_PERIOD (60) | ||
505 | |||
506 | void iwl_rx_statistics(struct iwl_priv *priv, | ||
507 | struct iwl_rx_mem_buffer *rxb) | ||
508 | { | ||
509 | int change; | ||
510 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | ||
511 | |||
512 | if (iwl_bt_statistics(priv)) { | ||
513 | IWL_DEBUG_RX(priv, | ||
514 | "Statistics notification received (%d vs %d).\n", | ||
515 | (int)sizeof(struct iwl_bt_notif_statistics), | ||
516 | le32_to_cpu(pkt->len_n_flags) & | ||
517 | FH_RSCSR_FRAME_SIZE_MSK); | ||
518 | |||
519 | change = ((priv->_agn.statistics_bt.general.common.temperature != | ||
520 | pkt->u.stats_bt.general.common.temperature) || | ||
521 | ((priv->_agn.statistics_bt.flag & | ||
522 | STATISTICS_REPLY_FLG_HT40_MODE_MSK) != | ||
523 | (pkt->u.stats_bt.flag & | ||
524 | STATISTICS_REPLY_FLG_HT40_MODE_MSK))); | ||
525 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
526 | iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats_bt); | ||
527 | #endif | ||
528 | |||
529 | } else { | ||
530 | IWL_DEBUG_RX(priv, | ||
531 | "Statistics notification received (%d vs %d).\n", | ||
532 | (int)sizeof(struct iwl_notif_statistics), | ||
533 | le32_to_cpu(pkt->len_n_flags) & | ||
534 | FH_RSCSR_FRAME_SIZE_MSK); | ||
535 | |||
536 | change = ((priv->_agn.statistics.general.common.temperature != | ||
537 | pkt->u.stats.general.common.temperature) || | ||
538 | ((priv->_agn.statistics.flag & | ||
539 | STATISTICS_REPLY_FLG_HT40_MODE_MSK) != | ||
540 | (pkt->u.stats.flag & | ||
541 | STATISTICS_REPLY_FLG_HT40_MODE_MSK))); | ||
542 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
543 | iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); | ||
544 | #endif | ||
545 | |||
546 | } | ||
547 | |||
548 | iwl_recover_from_statistics(priv, pkt); | ||
549 | |||
550 | if (iwl_bt_statistics(priv)) | ||
551 | memcpy(&priv->_agn.statistics_bt, &pkt->u.stats_bt, | ||
552 | sizeof(priv->_agn.statistics_bt)); | ||
553 | else | ||
554 | memcpy(&priv->_agn.statistics, &pkt->u.stats, | ||
555 | sizeof(priv->_agn.statistics)); | ||
556 | |||
557 | set_bit(STATUS_STATISTICS, &priv->status); | ||
558 | |||
559 | /* Reschedule the statistics timer to occur in | ||
560 | * REG_RECALIB_PERIOD seconds to ensure we get a | ||
561 | * thermal update even if the uCode doesn't give | ||
562 | * us one */ | ||
563 | mod_timer(&priv->statistics_periodic, jiffies + | ||
564 | msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); | ||
565 | |||
566 | if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && | ||
567 | (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { | ||
568 | iwl_rx_calc_noise(priv); | ||
569 | queue_work(priv->workqueue, &priv->run_time_calib_work); | ||
570 | } | ||
571 | if (priv->cfg->ops->lib->temp_ops.temperature && change) | ||
572 | priv->cfg->ops->lib->temp_ops.temperature(priv); | ||
573 | } | ||
574 | |||
575 | void iwl_reply_statistics(struct iwl_priv *priv, | ||
576 | struct iwl_rx_mem_buffer *rxb) | ||
577 | { | ||
578 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | ||
579 | |||
580 | if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { | ||
581 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
582 | memset(&priv->_agn.accum_statistics, 0, | ||
583 | sizeof(struct iwl_notif_statistics)); | ||
584 | memset(&priv->_agn.delta_statistics, 0, | ||
585 | sizeof(struct iwl_notif_statistics)); | ||
586 | memset(&priv->_agn.max_delta, 0, | ||
587 | sizeof(struct iwl_notif_statistics)); | ||
588 | memset(&priv->_agn.accum_statistics_bt, 0, | ||
589 | sizeof(struct iwl_bt_notif_statistics)); | ||
590 | memset(&priv->_agn.delta_statistics_bt, 0, | ||
591 | sizeof(struct iwl_bt_notif_statistics)); | ||
592 | memset(&priv->_agn.max_delta_bt, 0, | ||
593 | sizeof(struct iwl_bt_notif_statistics)); | ||
594 | #endif | ||
595 | IWL_DEBUG_RX(priv, "Statistics have been cleared\n"); | ||
596 | } | ||
597 | iwl_rx_statistics(priv, rxb); | ||
598 | } | ||
599 | |||
600 | void iwl_rx_missed_beacon_notif(struct iwl_priv *priv, | ||
601 | struct iwl_rx_mem_buffer *rxb) | ||
602 | |||
603 | { | ||
604 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | ||
605 | struct iwl_missed_beacon_notif *missed_beacon; | ||
606 | |||
607 | missed_beacon = &pkt->u.missed_beacon; | ||
608 | if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > | ||
609 | priv->missed_beacon_threshold) { | ||
610 | IWL_DEBUG_CALIB(priv, | ||
611 | "missed bcn cnsq %d totl %d rcd %d expctd %d\n", | ||
612 | le32_to_cpu(missed_beacon->consecutive_missed_beacons), | ||
613 | le32_to_cpu(missed_beacon->total_missed_becons), | ||
614 | le32_to_cpu(missed_beacon->num_recvd_beacons), | ||
615 | le32_to_cpu(missed_beacon->num_expected_beacons)); | ||
616 | if (!test_bit(STATUS_SCANNING, &priv->status)) | ||
617 | iwl_init_sensitivity(priv); | ||
618 | } | ||
619 | } | ||
620 | |||
399 | /* | 621 | /* |
400 | * returns non-zero if packet should be dropped | 622 | * returns non-zero if packet should be dropped |
401 | */ | 623 | */ |