blob: daa3c60c6fff1fd56b940daf218f3580bab9a868 [file] [log] [blame]
Tomas Winklera55360e2008-05-05 10:22:28 +08001/******************************************************************************
2 *
Wey-Yi Guy901069c2011-04-05 09:42:00 -07003 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
Tomas Winklera55360e2008-05-05 10:22:28 +08004 *
5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 *
21 * The full GNU General Public License is included in this distribution in the
22 * file called LICENSE.
23 *
24 * Contact Information:
Winkler, Tomas759ef892008-12-09 11:28:58 -080025 * Intel Linux Wireless <ilw@linux.intel.com>
Tomas Winklera55360e2008-05-05 10:22:28 +080026 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
28 *****************************************************************************/
29
Emmanuel Grumbach1781a072008-06-30 17:23:09 +080030#include <linux/etherdevice.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090031#include <linux/slab.h>
Stanislaw Gruszka118253c2011-03-07 09:22:24 +010032#include <linux/sched.h>
Tomas Winklera55360e2008-05-05 10:22:28 +080033#include <net/mac80211.h>
Tomas Winklera05ffd32008-07-10 14:28:42 +030034#include <asm/unaligned.h>
Tomas Winklera55360e2008-05-05 10:22:28 +080035#include "iwl-eeprom.h"
36#include "iwl-dev.h"
37#include "iwl-core.h"
Tomas Winklera55360e2008-05-05 10:22:28 +080038#include "iwl-io.h"
39#include "iwl-helpers.h"
Stanislaw Gruszka67289942011-02-28 14:33:17 +010040#include "iwl-agn-calib.h"
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +010041#include "iwl-agn.h"
Emmanuel Grumbach48f20d32011-08-25 23:10:36 -070042#include "iwl-shared.h"
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +010043
Emmanuel Grumbach522376d2011-09-06 09:31:19 -070044const char *get_cmd_string(u8 cmd)
45{
46 switch (cmd) {
47 IWL_CMD(REPLY_ALIVE);
48 IWL_CMD(REPLY_ERROR);
Wey-Yi Guy7e4005c2011-10-10 07:26:51 -070049 IWL_CMD(REPLY_ECHO);
Emmanuel Grumbach522376d2011-09-06 09:31:19 -070050 IWL_CMD(REPLY_RXON);
51 IWL_CMD(REPLY_RXON_ASSOC);
52 IWL_CMD(REPLY_QOS_PARAM);
53 IWL_CMD(REPLY_RXON_TIMING);
54 IWL_CMD(REPLY_ADD_STA);
55 IWL_CMD(REPLY_REMOVE_STA);
56 IWL_CMD(REPLY_REMOVE_ALL_STA);
57 IWL_CMD(REPLY_TXFIFO_FLUSH);
58 IWL_CMD(REPLY_WEPKEY);
59 IWL_CMD(REPLY_TX);
60 IWL_CMD(REPLY_LEDS_CMD);
61 IWL_CMD(REPLY_TX_LINK_QUALITY_CMD);
62 IWL_CMD(COEX_PRIORITY_TABLE_CMD);
63 IWL_CMD(COEX_MEDIUM_NOTIFICATION);
64 IWL_CMD(COEX_EVENT_CMD);
65 IWL_CMD(REPLY_QUIET_CMD);
66 IWL_CMD(REPLY_CHANNEL_SWITCH);
67 IWL_CMD(CHANNEL_SWITCH_NOTIFICATION);
68 IWL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD);
69 IWL_CMD(SPECTRUM_MEASURE_NOTIFICATION);
70 IWL_CMD(POWER_TABLE_CMD);
71 IWL_CMD(PM_SLEEP_NOTIFICATION);
72 IWL_CMD(PM_DEBUG_STATISTIC_NOTIFIC);
73 IWL_CMD(REPLY_SCAN_CMD);
74 IWL_CMD(REPLY_SCAN_ABORT_CMD);
75 IWL_CMD(SCAN_START_NOTIFICATION);
76 IWL_CMD(SCAN_RESULTS_NOTIFICATION);
77 IWL_CMD(SCAN_COMPLETE_NOTIFICATION);
78 IWL_CMD(BEACON_NOTIFICATION);
79 IWL_CMD(REPLY_TX_BEACON);
80 IWL_CMD(WHO_IS_AWAKE_NOTIFICATION);
81 IWL_CMD(QUIET_NOTIFICATION);
82 IWL_CMD(REPLY_TX_PWR_TABLE_CMD);
83 IWL_CMD(MEASURE_ABORT_NOTIFICATION);
84 IWL_CMD(REPLY_BT_CONFIG);
85 IWL_CMD(REPLY_STATISTICS_CMD);
86 IWL_CMD(STATISTICS_NOTIFICATION);
87 IWL_CMD(REPLY_CARD_STATE_CMD);
88 IWL_CMD(CARD_STATE_NOTIFICATION);
89 IWL_CMD(MISSED_BEACONS_NOTIFICATION);
90 IWL_CMD(REPLY_CT_KILL_CONFIG_CMD);
91 IWL_CMD(SENSITIVITY_CMD);
92 IWL_CMD(REPLY_PHY_CALIBRATION_CMD);
93 IWL_CMD(REPLY_RX_PHY_CMD);
94 IWL_CMD(REPLY_RX_MPDU_CMD);
95 IWL_CMD(REPLY_RX);
96 IWL_CMD(REPLY_COMPRESSED_BA);
97 IWL_CMD(CALIBRATION_CFG_CMD);
98 IWL_CMD(CALIBRATION_RES_NOTIFICATION);
99 IWL_CMD(CALIBRATION_COMPLETE_NOTIFICATION);
100 IWL_CMD(REPLY_TX_POWER_DBM_CMD);
101 IWL_CMD(TEMPERATURE_NOTIFICATION);
102 IWL_CMD(TX_ANT_CONFIGURATION_CMD);
103 IWL_CMD(REPLY_BT_COEX_PROFILE_NOTIF);
104 IWL_CMD(REPLY_BT_COEX_PRIO_TABLE);
105 IWL_CMD(REPLY_BT_COEX_PROT_ENV);
106 IWL_CMD(REPLY_WIPAN_PARAMS);
107 IWL_CMD(REPLY_WIPAN_RXON);
108 IWL_CMD(REPLY_WIPAN_RXON_TIMING);
109 IWL_CMD(REPLY_WIPAN_RXON_ASSOC);
110 IWL_CMD(REPLY_WIPAN_QOS_PARAM);
111 IWL_CMD(REPLY_WIPAN_WEPKEY);
112 IWL_CMD(REPLY_WIPAN_P2P_CHANNEL_SWITCH);
113 IWL_CMD(REPLY_WIPAN_NOA_NOTIFICATION);
114 IWL_CMD(REPLY_WIPAN_DEACTIVATION_COMPLETE);
115 IWL_CMD(REPLY_WOWLAN_PATTERNS);
116 IWL_CMD(REPLY_WOWLAN_WAKEUP_FILTER);
117 IWL_CMD(REPLY_WOWLAN_TSC_RSC_PARAMS);
118 IWL_CMD(REPLY_WOWLAN_TKIP_PARAMS);
119 IWL_CMD(REPLY_WOWLAN_KEK_KCK_MATERIAL);
120 IWL_CMD(REPLY_WOWLAN_GET_STATUS);
121 default:
122 return "UNKNOWN";
123
124 }
125}
Tomas Winklera55360e2008-05-05 10:22:28 +0800126
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100127/******************************************************************************
128 *
129 * Generic RX handler implementations
130 *
131 ******************************************************************************/
132
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700133static int iwlagn_rx_reply_error(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700134 struct iwl_rx_mem_buffer *rxb,
135 struct iwl_device_cmd *cmd)
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100136{
137 struct iwl_rx_packet *pkt = rxb_addr(rxb);
138
139 IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) "
140 "seq 0x%04X ser 0x%08X\n",
141 le32_to_cpu(pkt->u.err_resp.error_type),
142 get_cmd_string(pkt->u.err_resp.cmd_id),
143 pkt->u.err_resp.cmd_id,
144 le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num),
145 le32_to_cpu(pkt->u.err_resp.error_info));
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700146 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100147}
148
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700149static int iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700150 struct iwl_device_cmd *cmd)
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100151{
152 struct iwl_rx_packet *pkt = rxb_addr(rxb);
153 struct iwl_csa_notification *csa = &(pkt->u.csa_notif);
154 /*
155 * MULTI-FIXME
Wey-Yi Guyade4c642011-10-10 07:27:11 -0700156 * See iwlagn_mac_channel_switch.
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100157 */
158 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
159 struct iwl_rxon_cmd *rxon = (void *)&ctx->active;
160
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700161 if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status))
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700162 return 0;
Stanislaw Gruszka6f213ff2011-06-02 18:17:15 +0200163
164 if (!le32_to_cpu(csa->status) && csa->channel == priv->switch_channel) {
165 rxon->channel = csa->channel;
166 ctx->staging.channel = csa->channel;
167 IWL_DEBUG_11H(priv, "CSA notif: channel %d\n",
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100168 le16_to_cpu(csa->channel));
Stanislaw Gruszka6f213ff2011-06-02 18:17:15 +0200169 iwl_chswitch_done(priv, true);
170 } else {
171 IWL_ERR(priv, "CSA notif (fail) : channel %d\n",
172 le16_to_cpu(csa->channel));
173 iwl_chswitch_done(priv, false);
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100174 }
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700175 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100176}
177
178
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700179static int iwlagn_rx_spectrum_measure_notif(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700180 struct iwl_rx_mem_buffer *rxb,
181 struct iwl_device_cmd *cmd)
Reinette Chatre81963d62010-01-22 14:22:57 -0800182{
183 struct iwl_rx_packet *pkt = rxb_addr(rxb);
184 struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif);
185
186 if (!report->state) {
187 IWL_DEBUG_11H(priv,
188 "Spectrum Measure Notification: Start\n");
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700189 return 0;
Reinette Chatre81963d62010-01-22 14:22:57 -0800190 }
191
192 memcpy(&priv->measure_report, report, sizeof(*report));
193 priv->measurement_status |= MEASUREMENT_READY;
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700194 return 0;
Reinette Chatre81963d62010-01-22 14:22:57 -0800195}
Reinette Chatre81963d62010-01-22 14:22:57 -0800196
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700197static int iwlagn_rx_pm_sleep_notif(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700198 struct iwl_rx_mem_buffer *rxb,
199 struct iwl_device_cmd *cmd)
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100200{
201#ifdef CONFIG_IWLWIFI_DEBUG
202 struct iwl_rx_packet *pkt = rxb_addr(rxb);
203 struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif);
204 IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n",
205 sleep->pm_sleep_mode, sleep->pm_wakeup_src);
206#endif
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700207 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100208}
209
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700210static int iwlagn_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700211 struct iwl_rx_mem_buffer *rxb,
212 struct iwl_device_cmd *cmd)
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100213{
214 struct iwl_rx_packet *pkt = rxb_addr(rxb);
Emmanuel Grumbach44856c62011-08-25 23:10:45 -0700215 u32 __maybe_unused len =
216 le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100217 IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled "
218 "notification for %s:\n", len,
219 get_cmd_string(pkt->hdr.cmd));
220 iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, len);
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700221 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100222}
223
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700224static int iwlagn_rx_beacon_notif(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700225 struct iwl_rx_mem_buffer *rxb,
226 struct iwl_device_cmd *cmd)
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100227{
228 struct iwl_rx_packet *pkt = rxb_addr(rxb);
229 struct iwlagn_beacon_notif *beacon = (void *)pkt->u.raw;
230#ifdef CONFIG_IWLWIFI_DEBUG
231 u16 status = le16_to_cpu(beacon->beacon_notify_hdr.status.status);
232 u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags);
233
234 IWL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d "
235 "tsf:0x%.8x%.8x rate:%d\n",
236 status & TX_STATUS_MSK,
237 beacon->beacon_notify_hdr.failure_frame,
238 le32_to_cpu(beacon->ibss_mgr_status),
239 le32_to_cpu(beacon->high_tsf),
240 le32_to_cpu(beacon->low_tsf), rate);
241#endif
242
243 priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status);
244
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700245 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100246}
247
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100248/* the threshold ratio of actual_ack_cnt to expected_ack_cnt in percent */
249#define ACK_CNT_RATIO (50)
250#define BA_TIMEOUT_CNT (5)
251#define BA_TIMEOUT_MAX (16)
252
253/**
254 * iwl_good_ack_health - checks for ACK count ratios, BA timeout retries.
255 *
256 * When the ACK count ratio is low and aggregated BA timeout retries exceeding
257 * the BA_TIMEOUT_MAX, reload firmware and bring system back to normal
258 * operation state.
259 */
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700260static bool iwlagn_good_ack_health(struct iwl_priv *priv,
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700261 struct statistics_tx *cur)
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100262{
263 int actual_delta, expected_delta, ba_timeout_delta;
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700264 struct statistics_tx *old;
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100265
Wey-Yi Guy898ed672011-07-13 08:38:57 -0700266 if (priv->agg_tids_count)
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100267 return true;
268
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700269 old = &priv->statistics.tx;
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100270
271 actual_delta = le32_to_cpu(cur->actual_ack_cnt) -
272 le32_to_cpu(old->actual_ack_cnt);
273 expected_delta = le32_to_cpu(cur->expected_ack_cnt) -
274 le32_to_cpu(old->expected_ack_cnt);
275
276 /* Values should not be negative, but we do not trust the firmware */
277 if (actual_delta <= 0 || expected_delta <= 0)
278 return true;
279
280 ba_timeout_delta = le32_to_cpu(cur->agg.ba_timeout) -
281 le32_to_cpu(old->agg.ba_timeout);
282
283 if ((actual_delta * 100 / expected_delta) < ACK_CNT_RATIO &&
284 ba_timeout_delta > BA_TIMEOUT_CNT) {
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700285 IWL_DEBUG_RADIO(priv,
286 "deltas: actual %d expected %d ba_timeout %d\n",
287 actual_delta, expected_delta, ba_timeout_delta);
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100288
289#ifdef CONFIG_IWLWIFI_DEBUGFS
290 /*
291 * This is ifdef'ed on DEBUGFS because otherwise the
292 * statistics aren't available. If DEBUGFS is set but
293 * DEBUG is not, these will just compile out.
294 */
295 IWL_DEBUG_RADIO(priv, "rx_detected_cnt delta %d\n",
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700296 priv->delta_stats.tx.rx_detected_cnt);
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100297 IWL_DEBUG_RADIO(priv,
298 "ack_or_ba_timeout_collision delta %d\n",
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700299 priv->delta_stats.tx.ack_or_ba_timeout_collision);
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100300#endif
301
302 if (ba_timeout_delta >= BA_TIMEOUT_MAX)
303 return false;
304 }
305
306 return true;
307}
308
309/**
310 * iwl_good_plcp_health - checks for plcp error.
311 *
312 * When the plcp error is exceeding the thresholds, reset the radio
313 * to improve the throughput.
314 */
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700315static bool iwlagn_good_plcp_health(struct iwl_priv *priv,
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700316 struct statistics_rx_phy *cur_ofdm,
317 struct statistics_rx_ht_phy *cur_ofdm_ht,
318 unsigned int msecs)
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100319{
Stanislaw Gruszka6198c382011-03-04 17:51:50 +0100320 int delta;
321 int threshold = priv->cfg->base_params->plcp_delta_threshold;
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100322
Stanislaw Gruszka6198c382011-03-04 17:51:50 +0100323 if (threshold == IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100324 IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n");
Stanislaw Gruszka6198c382011-03-04 17:51:50 +0100325 return true;
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100326 }
327
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700328 delta = le32_to_cpu(cur_ofdm->plcp_err) -
329 le32_to_cpu(priv->statistics.rx_ofdm.plcp_err) +
330 le32_to_cpu(cur_ofdm_ht->plcp_err) -
331 le32_to_cpu(priv->statistics.rx_ofdm_ht.plcp_err);
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100332
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700333 /* Can be negative if firmware reset statistics */
Stanislaw Gruszka6198c382011-03-04 17:51:50 +0100334 if (delta <= 0)
335 return true;
336
337 if ((delta * 100 / msecs) > threshold) {
338 IWL_DEBUG_RADIO(priv,
339 "plcp health threshold %u delta %d msecs %u\n",
340 threshold, delta, msecs);
341 return false;
342 }
343
344 return true;
Stanislaw Gruszkaad6e82a2011-02-28 14:33:16 +0100345}
346
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700347static void iwlagn_recover_from_statistics(struct iwl_priv *priv,
348 struct statistics_rx_phy *cur_ofdm,
349 struct statistics_rx_ht_phy *cur_ofdm_ht,
350 struct statistics_tx *tx,
351 unsigned long stamp)
Wey-Yi Guyfa8f1302010-03-05 14:22:46 -0800352{
Stanislaw Gruszka410f2bb2011-03-04 17:51:51 +0100353 unsigned int msecs;
Stanislaw Gruszkab7977ff2011-02-28 14:33:15 +0100354
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700355 if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
Stanislaw Gruszka410f2bb2011-03-04 17:51:51 +0100356 return;
357
Stanislaw Gruszka410f2bb2011-03-04 17:51:51 +0100358 msecs = jiffies_to_msecs(stamp - priv->rx_statistics_jiffies);
359
360 /* Only gather statistics and update time stamp when not associated */
361 if (!iwl_is_any_associated(priv))
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700362 return;
Stanislaw Gruszka410f2bb2011-03-04 17:51:51 +0100363
364 /* Do not check/recover when do not have enough statistics data */
365 if (msecs < 99)
Wey-Yi Guyfa8f1302010-03-05 14:22:46 -0800366 return;
Stanislaw Gruszkaca3d9382011-02-08 09:31:55 +0100367
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700368 if (iwlagn_mod_params.ack_check && !iwlagn_good_ack_health(priv, tx)) {
Stanislaw Gruszkaca3d9382011-02-08 09:31:55 +0100369 IWL_ERR(priv, "low ack count detected, restart firmware\n");
370 if (!iwl_force_reset(priv, IWL_FW_RESET, false))
371 return;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -0800372 }
Stanislaw Gruszkaca3d9382011-02-08 09:31:55 +0100373
Don Fry9d143e92011-04-20 15:23:57 -0700374 if (iwlagn_mod_params.plcp_check &&
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700375 !iwlagn_good_plcp_health(priv, cur_ofdm, cur_ofdm_ht, msecs))
Stanislaw Gruszkaca3d9382011-02-08 09:31:55 +0100376 iwl_force_reset(priv, IWL_RF_RESET, false);
Wey-Yi Guybeac5492010-03-04 13:38:58 -0800377}
Wey-Yi Guybeac5492010-03-04 13:38:58 -0800378
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100379/* Calculate noise level, based on measurements during network silence just
380 * before arriving beacon. This measurement can be done only if we know
381 * exactly when to expect beacons, therefore only when we're associated. */
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700382static void iwlagn_rx_calc_noise(struct iwl_priv *priv)
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100383{
384 struct statistics_rx_non_phy *rx_info;
385 int num_active_rx = 0;
386 int total_silence = 0;
387 int bcn_silence_a, bcn_silence_b, bcn_silence_c;
388 int last_rx_noise;
389
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700390 rx_info = &priv->statistics.rx_non_phy;
391
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100392 bcn_silence_a =
393 le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER;
394 bcn_silence_b =
395 le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER;
396 bcn_silence_c =
397 le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER;
398
399 if (bcn_silence_a) {
400 total_silence += bcn_silence_a;
401 num_active_rx++;
402 }
403 if (bcn_silence_b) {
404 total_silence += bcn_silence_b;
405 num_active_rx++;
406 }
407 if (bcn_silence_c) {
408 total_silence += bcn_silence_c;
409 num_active_rx++;
410 }
411
412 /* Average among active antennas */
413 if (num_active_rx)
414 last_rx_noise = (total_silence / num_active_rx) - 107;
415 else
416 last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE;
417
418 IWL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n",
419 bcn_silence_a, bcn_silence_b, bcn_silence_c,
420 last_rx_noise);
421}
422
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700423#ifdef CONFIG_IWLWIFI_DEBUGFS
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100424/*
425 * based on the assumption of all statistics counter are in DWORD
426 * FIXME: This function is for debugging, do not deal with
427 * the case of counters roll-over.
428 */
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700429static void accum_stats(__le32 *prev, __le32 *cur, __le32 *delta,
430 __le32 *max_delta, __le32 *accum, int size)
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100431{
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700432 int i;
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100433
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700434 for (i = 0;
435 i < size / sizeof(__le32);
436 i++, prev++, cur++, delta++, max_delta++, accum++) {
437 if (le32_to_cpu(*cur) > le32_to_cpu(*prev)) {
438 *delta = cpu_to_le32(
439 le32_to_cpu(*cur) - le32_to_cpu(*prev));
440 le32_add_cpu(accum, le32_to_cpu(*delta));
441 if (le32_to_cpu(*delta) > le32_to_cpu(*max_delta))
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100442 *max_delta = *delta;
443 }
444 }
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100445}
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100446
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700447static void
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700448iwlagn_accumulative_statistics(struct iwl_priv *priv,
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700449 struct statistics_general_common *common,
450 struct statistics_rx_non_phy *rx_non_phy,
451 struct statistics_rx_phy *rx_ofdm,
452 struct statistics_rx_ht_phy *rx_ofdm_ht,
453 struct statistics_rx_phy *rx_cck,
454 struct statistics_tx *tx,
455 struct statistics_bt_activity *bt_activity)
456{
457#define ACCUM(_name) \
458 accum_stats((__le32 *)&priv->statistics._name, \
459 (__le32 *)_name, \
460 (__le32 *)&priv->delta_stats._name, \
461 (__le32 *)&priv->max_delta_stats._name, \
462 (__le32 *)&priv->accum_stats._name, \
463 sizeof(*_name));
464
465 ACCUM(common);
466 ACCUM(rx_non_phy);
467 ACCUM(rx_ofdm);
468 ACCUM(rx_ofdm_ht);
469 ACCUM(rx_cck);
470 ACCUM(tx);
471 if (bt_activity)
472 ACCUM(bt_activity);
473#undef ACCUM
474}
475#else
476static inline void
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700477iwlagn_accumulative_statistics(struct iwl_priv *priv,
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700478 struct statistics_general_common *common,
479 struct statistics_rx_non_phy *rx_non_phy,
480 struct statistics_rx_phy *rx_ofdm,
481 struct statistics_rx_ht_phy *rx_ofdm_ht,
482 struct statistics_rx_phy *rx_cck,
483 struct statistics_tx *tx,
484 struct statistics_bt_activity *bt_activity)
485{
486}
487#endif
488
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700489static int iwlagn_rx_statistics(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700490 struct iwl_rx_mem_buffer *rxb,
491 struct iwl_device_cmd *cmd)
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100492{
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700493 unsigned long stamp = jiffies;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100494 const int reg_recalib_period = 60;
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100495 int change;
496 struct iwl_rx_packet *pkt = rxb_addr(rxb);
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700497 u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
498 __le32 *flag;
499 struct statistics_general_common *common;
500 struct statistics_rx_non_phy *rx_non_phy;
501 struct statistics_rx_phy *rx_ofdm;
502 struct statistics_rx_ht_phy *rx_ofdm_ht;
503 struct statistics_rx_phy *rx_cck;
504 struct statistics_tx *tx;
505 struct statistics_bt_activity *bt_activity;
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100506
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700507 len -= sizeof(struct iwl_cmd_header); /* skip header */
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100508
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700509 IWL_DEBUG_RX(priv, "Statistics notification received (%d bytes).\n",
510 len);
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100511
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700512 if (len == sizeof(struct iwl_bt_notif_statistics)) {
513 struct iwl_bt_notif_statistics *stats;
514 stats = &pkt->u.stats_bt;
515 flag = &stats->flag;
516 common = &stats->general.common;
517 rx_non_phy = &stats->rx.general.common;
518 rx_ofdm = &stats->rx.ofdm;
519 rx_ofdm_ht = &stats->rx.ofdm_ht;
520 rx_cck = &stats->rx.cck;
521 tx = &stats->tx;
522 bt_activity = &stats->general.activity;
523
524#ifdef CONFIG_IWLWIFI_DEBUGFS
525 /* handle this exception directly */
526 priv->statistics.num_bt_kills = stats->rx.general.num_bt_kills;
527 le32_add_cpu(&priv->statistics.accum_num_bt_kills,
528 le32_to_cpu(stats->rx.general.num_bt_kills));
529#endif
530 } else if (len == sizeof(struct iwl_notif_statistics)) {
531 struct iwl_notif_statistics *stats;
532 stats = &pkt->u.stats;
533 flag = &stats->flag;
534 common = &stats->general.common;
535 rx_non_phy = &stats->rx.general;
536 rx_ofdm = &stats->rx.ofdm;
537 rx_ofdm_ht = &stats->rx.ofdm_ht;
538 rx_cck = &stats->rx.cck;
539 tx = &stats->tx;
540 bt_activity = NULL;
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100541 } else {
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700542 WARN_ONCE(1, "len %d doesn't match BT (%zu) or normal (%zu)\n",
543 len, sizeof(struct iwl_bt_notif_statistics),
544 sizeof(struct iwl_notif_statistics));
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700545 return 0;
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100546 }
547
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700548 change = common->temperature != priv->statistics.common.temperature ||
549 (*flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=
550 (priv->statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK);
551
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700552 iwlagn_accumulative_statistics(priv, common, rx_non_phy, rx_ofdm,
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700553 rx_ofdm_ht, rx_cck, tx, bt_activity);
554
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700555 iwlagn_recover_from_statistics(priv, rx_ofdm, rx_ofdm_ht, tx, stamp);
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700556
557 priv->statistics.flag = *flag;
558 memcpy(&priv->statistics.common, common, sizeof(*common));
559 memcpy(&priv->statistics.rx_non_phy, rx_non_phy, sizeof(*rx_non_phy));
560 memcpy(&priv->statistics.rx_ofdm, rx_ofdm, sizeof(*rx_ofdm));
561 memcpy(&priv->statistics.rx_ofdm_ht, rx_ofdm_ht, sizeof(*rx_ofdm_ht));
562 memcpy(&priv->statistics.rx_cck, rx_cck, sizeof(*rx_cck));
563 memcpy(&priv->statistics.tx, tx, sizeof(*tx));
564#ifdef CONFIG_IWLWIFI_DEBUGFS
565 if (bt_activity)
566 memcpy(&priv->statistics.bt_activity, bt_activity,
567 sizeof(*bt_activity));
568#endif
569
570 priv->rx_statistics_jiffies = stamp;
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100571
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700572 set_bit(STATUS_STATISTICS, &priv->shrd->status);
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100573
574 /* Reschedule the statistics timer to occur in
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100575 * reg_recalib_period seconds to ensure we get a
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100576 * thermal update even if the uCode doesn't give
577 * us one */
578 mod_timer(&priv->statistics_periodic, jiffies +
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100579 msecs_to_jiffies(reg_recalib_period * 1000));
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100580
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700581 if (unlikely(!test_bit(STATUS_SCANNING, &priv->shrd->status)) &&
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100582 (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) {
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700583 iwlagn_rx_calc_noise(priv);
Emmanuel Grumbach74e28e42011-08-25 23:10:41 -0700584 queue_work(priv->shrd->workqueue, &priv->run_time_calib_work);
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100585 }
Wey-Yi Guy90c300c2011-07-07 08:33:01 -0700586 if (priv->cfg->lib->temperature && change)
587 priv->cfg->lib->temperature(priv);
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700588 return 0;
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100589}
590
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700591static int iwlagn_rx_reply_statistics(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700592 struct iwl_rx_mem_buffer *rxb,
593 struct iwl_device_cmd *cmd)
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100594{
595 struct iwl_rx_packet *pkt = rxb_addr(rxb);
596
597 if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) {
598#ifdef CONFIG_IWLWIFI_DEBUGFS
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700599 memset(&priv->accum_stats, 0,
600 sizeof(priv->accum_stats));
601 memset(&priv->delta_stats, 0,
602 sizeof(priv->delta_stats));
603 memset(&priv->max_delta_stats, 0,
604 sizeof(priv->max_delta_stats));
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100605#endif
606 IWL_DEBUG_RX(priv, "Statistics have been cleared\n");
607 }
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700608 iwlagn_rx_statistics(priv, rxb, cmd);
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700609 return 0;
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100610}
611
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100612/* Handle notification from uCode that card's power state is changing
613 * due to software, hardware, or critical temperature RFKILL */
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700614static int iwlagn_rx_card_state_notif(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700615 struct iwl_rx_mem_buffer *rxb,
616 struct iwl_device_cmd *cmd)
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100617{
618 struct iwl_rx_packet *pkt = rxb_addr(rxb);
619 u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700620 unsigned long status = priv->shrd->status;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100621
622 IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n",
623 (flags & HW_CARD_DISABLED) ? "Kill" : "On",
624 (flags & SW_CARD_DISABLED) ? "Kill" : "On",
625 (flags & CT_CARD_DISABLED) ?
626 "Reached" : "Not reached");
627
628 if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED |
629 CT_CARD_DISABLED)) {
630
Emmanuel Grumbach83ed9012011-08-25 23:11:14 -0700631 iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET,
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100632 CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
633
Emmanuel Grumbach83ed9012011-08-25 23:11:14 -0700634 iwl_write_direct32(bus(priv), HBUS_TARG_MBX_C,
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100635 HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
636
637 if (!(flags & RXON_CARD_DISABLED)) {
Emmanuel Grumbach83ed9012011-08-25 23:11:14 -0700638 iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR,
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100639 CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
Emmanuel Grumbach83ed9012011-08-25 23:11:14 -0700640 iwl_write_direct32(bus(priv), HBUS_TARG_MBX_C,
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100641 HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
642 }
643 if (flags & CT_CARD_DISABLED)
644 iwl_tt_enter_ct_kill(priv);
645 }
646 if (!(flags & CT_CARD_DISABLED))
647 iwl_tt_exit_ct_kill(priv);
648
649 if (flags & HW_CARD_DISABLED)
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700650 set_bit(STATUS_RF_KILL_HW, &priv->shrd->status);
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100651 else
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700652 clear_bit(STATUS_RF_KILL_HW, &priv->shrd->status);
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100653
654
655 if (!(flags & RXON_CARD_DISABLED))
656 iwl_scan_cancel(priv);
657
658 if ((test_bit(STATUS_RF_KILL_HW, &status) !=
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700659 test_bit(STATUS_RF_KILL_HW, &priv->shrd->status)))
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100660 wiphy_rfkill_set_hw_state(priv->hw->wiphy,
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700661 test_bit(STATUS_RF_KILL_HW, &priv->shrd->status));
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100662 else
Johannes Bergeffd4d92011-09-15 11:46:52 -0700663 wake_up(&priv->shrd->wait_command_queue);
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700664 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100665}
666
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700667static int iwlagn_rx_missed_beacon_notif(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700668 struct iwl_rx_mem_buffer *rxb,
669 struct iwl_device_cmd *cmd)
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100670
671{
672 struct iwl_rx_packet *pkt = rxb_addr(rxb);
673 struct iwl_missed_beacon_notif *missed_beacon;
674
675 missed_beacon = &pkt->u.missed_beacon;
676 if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) >
677 priv->missed_beacon_threshold) {
678 IWL_DEBUG_CALIB(priv,
679 "missed bcn cnsq %d totl %d rcd %d expctd %d\n",
680 le32_to_cpu(missed_beacon->consecutive_missed_beacons),
681 le32_to_cpu(missed_beacon->total_missed_becons),
682 le32_to_cpu(missed_beacon->num_recvd_beacons),
683 le32_to_cpu(missed_beacon->num_expected_beacons));
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700684 if (!test_bit(STATUS_SCANNING, &priv->shrd->status))
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100685 iwl_init_sensitivity(priv);
686 }
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700687 return 0;
Stanislaw Gruszka67289942011-02-28 14:33:17 +0100688}
689
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100690/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD).
691 * This will be used later in iwl_rx_reply_rx() for REPLY_RX_MPDU_CMD. */
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700692static int iwlagn_rx_reply_rx_phy(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700693 struct iwl_rx_mem_buffer *rxb,
694 struct iwl_device_cmd *cmd)
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100695{
696 struct iwl_rx_packet *pkt = rxb_addr(rxb);
697
Wey-Yi Guy898ed672011-07-13 08:38:57 -0700698 priv->last_phy_res_valid = true;
699 memcpy(&priv->last_phy_res, pkt->u.raw,
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100700 sizeof(struct iwl_rx_phy_res));
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700701 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100702}
703
Emmanuel Grumbach1781a072008-06-30 17:23:09 +0800704/*
705 * returns non-zero if packet should be dropped
706 */
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700707static int iwlagn_set_decrypted_flag(struct iwl_priv *priv,
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100708 struct ieee80211_hdr *hdr,
709 u32 decrypt_res,
710 struct ieee80211_rx_status *stats)
Emmanuel Grumbach1781a072008-06-30 17:23:09 +0800711{
712 u16 fc = le16_to_cpu(hdr->frame_control);
713
Johannes Berg246ed352010-08-23 10:46:32 +0200714 /*
715 * All contexts have the same setting here due to it being
716 * a module parameter, so OK to check any context.
717 */
718 if (priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags &
719 RXON_FILTER_DIS_DECRYPT_MSK)
Emmanuel Grumbach1781a072008-06-30 17:23:09 +0800720 return 0;
721
722 if (!(fc & IEEE80211_FCTL_PROTECTED))
723 return 0;
724
Tomas Winklere1623442009-01-27 14:27:56 -0800725 IWL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res);
Emmanuel Grumbach1781a072008-06-30 17:23:09 +0800726 switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) {
727 case RX_RES_STATUS_SEC_TYPE_TKIP:
728 /* The uCode has got a bad phase 1 Key, pushes the packet.
729 * Decryption will be done in SW. */
730 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
731 RX_RES_STATUS_BAD_KEY_TTAK)
732 break;
733
734 case RX_RES_STATUS_SEC_TYPE_WEP:
735 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
736 RX_RES_STATUS_BAD_ICV_MIC) {
737 /* bad ICV, the packet is destroyed since the
738 * decryption is inplace, drop it */
Tomas Winklere1623442009-01-27 14:27:56 -0800739 IWL_DEBUG_RX(priv, "Packet destroyed\n");
Emmanuel Grumbach1781a072008-06-30 17:23:09 +0800740 return -1;
741 }
742 case RX_RES_STATUS_SEC_TYPE_CCMP:
743 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
744 RX_RES_STATUS_DECRYPT_OK) {
Tomas Winklere1623442009-01-27 14:27:56 -0800745 IWL_DEBUG_RX(priv, "hw decrypt successfully!!!\n");
Emmanuel Grumbach1781a072008-06-30 17:23:09 +0800746 stats->flag |= RX_FLAG_DECRYPTED;
747 }
748 break;
749
750 default:
751 break;
752 }
753 return 0;
754}
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100755
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700756static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100757 struct ieee80211_hdr *hdr,
758 u16 len,
759 u32 ampdu_status,
760 struct iwl_rx_mem_buffer *rxb,
761 struct ieee80211_rx_status *stats)
762{
763 struct sk_buff *skb;
764 __le16 fc = hdr->frame_control;
Garen Tamrazian68b99312011-03-30 02:29:32 -0700765 struct iwl_rxon_context *ctx;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100766
767 /* We only process data packets if the interface is open */
768 if (unlikely(!priv->is_open)) {
769 IWL_DEBUG_DROP_LIMIT(priv,
770 "Dropping packet while interface is not open.\n");
771 return;
772 }
773
774 /* In case of HW accelerated crypto and bad decryption, drop */
Don Fry9d143e92011-04-20 15:23:57 -0700775 if (!iwlagn_mod_params.sw_crypto &&
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700776 iwlagn_set_decrypted_flag(priv, hdr, ampdu_status, stats))
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100777 return;
778
779 skb = dev_alloc_skb(128);
780 if (!skb) {
781 IWL_ERR(priv, "dev_alloc_skb failed\n");
782 return;
783 }
784
785 skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len);
786
787 iwl_update_stats(priv, false, fc, len);
Garen Tamrazian68b99312011-03-30 02:29:32 -0700788
789 /*
790 * Wake any queues that were stopped due to a passive channel tx
791 * failure. This can happen because the regulatory enforcement in
792 * the device waits for a beacon before allowing transmission,
793 * sometimes even after already having transmitted frames for the
794 * association because the new RXON may reset the information.
795 */
796 if (unlikely(ieee80211_is_beacon(fc))) {
797 for_each_context(priv, ctx) {
798 if (!ctx->last_tx_rejected)
799 continue;
800 if (compare_ether_addr(hdr->addr3,
801 ctx->active.bssid_addr))
802 continue;
803 ctx->last_tx_rejected = false;
Emmanuel Grumbache13c0c52011-08-25 23:11:24 -0700804 iwl_trans_wake_any_queue(trans(priv), ctx->ctxid);
Garen Tamrazian68b99312011-03-30 02:29:32 -0700805 }
806 }
807
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100808 memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats));
809
810 ieee80211_rx(priv->hw, skb);
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100811 rxb->page = NULL;
812}
813
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700814static u32 iwlagn_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in)
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100815{
816 u32 decrypt_out = 0;
817
818 if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) ==
819 RX_RES_STATUS_STATION_FOUND)
820 decrypt_out |= (RX_RES_STATUS_STATION_FOUND |
821 RX_RES_STATUS_NO_STATION_INFO_MISMATCH);
822
823 decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK);
824
825 /* packet was not encrypted */
826 if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==
827 RX_RES_STATUS_SEC_TYPE_NONE)
828 return decrypt_out;
829
830 /* packet was encrypted with unknown alg */
831 if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==
832 RX_RES_STATUS_SEC_TYPE_ERR)
833 return decrypt_out;
834
835 /* decryption was not done in HW */
836 if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) !=
837 RX_MPDU_RES_STATUS_DEC_DONE_MSK)
838 return decrypt_out;
839
840 switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) {
841
842 case RX_RES_STATUS_SEC_TYPE_CCMP:
843 /* alg is CCM: check MIC only */
844 if (!(decrypt_in & RX_MPDU_RES_STATUS_MIC_OK))
845 /* Bad MIC */
846 decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;
847 else
848 decrypt_out |= RX_RES_STATUS_DECRYPT_OK;
849
850 break;
851
852 case RX_RES_STATUS_SEC_TYPE_TKIP:
853 if (!(decrypt_in & RX_MPDU_RES_STATUS_TTAK_OK)) {
854 /* Bad TTAK */
855 decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK;
856 break;
857 }
858 /* fall through if TTAK OK */
859 default:
860 if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK))
861 decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;
862 else
863 decrypt_out |= RX_RES_STATUS_DECRYPT_OK;
864 break;
865 }
866
867 IWL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n",
868 decrypt_in, decrypt_out);
869
870 return decrypt_out;
871}
872
Don Fry5c3d29f2011-07-08 08:46:29 -0700873/* Calc max signal level (dBm) among 3 possible receivers */
874static int iwlagn_calc_rssi(struct iwl_priv *priv,
875 struct iwl_rx_phy_res *rx_resp)
876{
877 /* data from PHY/DSP regarding signal strength, etc.,
878 * contents are always there, not configurable by host
879 */
880 struct iwlagn_non_cfg_phy *ncphy =
881 (struct iwlagn_non_cfg_phy *)rx_resp->non_cfg_phy_buf;
882 u32 val, rssi_a, rssi_b, rssi_c, max_rssi;
883 u8 agc;
884
885 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_AGC_IDX]);
886 agc = (val & IWLAGN_OFDM_AGC_MSK) >> IWLAGN_OFDM_AGC_BIT_POS;
887
888 /* Find max rssi among 3 possible receivers.
889 * These values are measured by the digital signal processor (DSP).
890 * They should stay fairly constant even as the signal strength varies,
891 * if the radio's automatic gain control (AGC) is working right.
892 * AGC value (see below) will provide the "interesting" info.
893 */
894 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_AB_IDX]);
895 rssi_a = (val & IWLAGN_OFDM_RSSI_INBAND_A_BITMSK) >>
896 IWLAGN_OFDM_RSSI_A_BIT_POS;
897 rssi_b = (val & IWLAGN_OFDM_RSSI_INBAND_B_BITMSK) >>
898 IWLAGN_OFDM_RSSI_B_BIT_POS;
899 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_C_IDX]);
900 rssi_c = (val & IWLAGN_OFDM_RSSI_INBAND_C_BITMSK) >>
901 IWLAGN_OFDM_RSSI_C_BIT_POS;
902
903 max_rssi = max_t(u32, rssi_a, rssi_b);
904 max_rssi = max_t(u32, max_rssi, rssi_c);
905
906 IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n",
907 rssi_a, rssi_b, rssi_c, max_rssi, agc);
908
909 /* dBm = max_rssi dB - agc dB - constant.
910 * Higher AGC (higher radio gain) means lower signal. */
911 return max_rssi - agc - IWLAGN_RSSI_OFFSET;
912}
913
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100914/* Called for REPLY_RX (legacy ABG frames), or
915 * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700916static int iwlagn_rx_reply_rx(struct iwl_priv *priv,
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700917 struct iwl_rx_mem_buffer *rxb,
918 struct iwl_device_cmd *cmd)
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100919{
920 struct ieee80211_hdr *header;
921 struct ieee80211_rx_status rx_status;
922 struct iwl_rx_packet *pkt = rxb_addr(rxb);
923 struct iwl_rx_phy_res *phy_res;
924 __le32 rx_pkt_status;
925 struct iwl_rx_mpdu_res_start *amsdu;
926 u32 len;
927 u32 ampdu_status;
928 u32 rate_n_flags;
929
930 /**
931 * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently.
932 * REPLY_RX: physical layer info is in this buffer
933 * REPLY_RX_MPDU_CMD: physical layer info was sent in separate
934 * command and cached in priv->last_phy_res
935 *
936 * Here we set up local variables depending on which command is
937 * received.
938 */
939 if (pkt->hdr.cmd == REPLY_RX) {
940 phy_res = (struct iwl_rx_phy_res *)pkt->u.raw;
941 header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res)
942 + phy_res->cfg_phy_cnt);
943
944 len = le16_to_cpu(phy_res->byte_count);
945 rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) +
946 phy_res->cfg_phy_cnt + len);
947 ampdu_status = le32_to_cpu(rx_pkt_status);
948 } else {
Wey-Yi Guy898ed672011-07-13 08:38:57 -0700949 if (!priv->last_phy_res_valid) {
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100950 IWL_ERR(priv, "MPDU frame without cached PHY data\n");
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700951 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100952 }
Wey-Yi Guy898ed672011-07-13 08:38:57 -0700953 phy_res = &priv->last_phy_res;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100954 amsdu = (struct iwl_rx_mpdu_res_start *)pkt->u.raw;
955 header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu));
956 len = le16_to_cpu(amsdu->byte_count);
957 rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len);
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -0700958 ampdu_status = iwlagn_translate_rx_status(priv,
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100959 le32_to_cpu(rx_pkt_status));
960 }
961
962 if ((unlikely(phy_res->cfg_phy_cnt > 20))) {
963 IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n",
964 phy_res->cfg_phy_cnt);
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700965 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100966 }
967
968 if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) ||
969 !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) {
970 IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n",
971 le32_to_cpu(rx_pkt_status));
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -0700972 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100973 }
974
975 /* This will be used in several places later */
976 rate_n_flags = le32_to_cpu(phy_res->rate_n_flags);
977
978 /* rx_status carries information about the packet to mac80211 */
979 rx_status.mactime = le64_to_cpu(phy_res->timestamp);
980 rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
981 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
982 rx_status.freq =
983 ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel),
984 rx_status.band);
985 rx_status.rate_idx =
986 iwlagn_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band);
987 rx_status.flag = 0;
988
989 /* TSF isn't reliable. In order to allow smooth user experience,
990 * this W/A doesn't propagate it to the mac80211 */
991 /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/
992
993 priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp);
994
995 /* Find max signal strength (dBm) among 3 antenna/receiver chains */
Don Fry5c3d29f2011-07-08 08:46:29 -0700996 rx_status.signal = iwlagn_calc_rssi(priv, phy_res);
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +0100997
998 iwl_dbg_log_rx_data_frame(priv, len, header);
999 IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n",
1000 rx_status.signal, (unsigned long long)rx_status.mactime);
1001
1002 /*
1003 * "antenna number"
1004 *
1005 * It seems that the antenna field in the phy flags value
1006 * is actually a bit field. This is undefined by radiotap,
1007 * it wants an actual antenna number but I always get "7"
1008 * for most legacy frames I receive indicating that the
1009 * same frame was received on all three RX chains.
1010 *
1011 * I think this field should be removed in favor of a
1012 * new 802.11n radiotap field "RX chains" that is defined
1013 * as a bitmask.
1014 */
1015 rx_status.antenna =
1016 (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK)
1017 >> RX_RES_PHY_FLAGS_ANTENNA_POS;
1018
1019 /* set the preamble flag if appropriate */
1020 if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK)
1021 rx_status.flag |= RX_FLAG_SHORTPRE;
1022
1023 /* Set up the HT phy flags */
1024 if (rate_n_flags & RATE_MCS_HT_MSK)
1025 rx_status.flag |= RX_FLAG_HT;
1026 if (rate_n_flags & RATE_MCS_HT40_MSK)
1027 rx_status.flag |= RX_FLAG_40MHZ;
1028 if (rate_n_flags & RATE_MCS_SGI_MSK)
1029 rx_status.flag |= RX_FLAG_SHORT_GI;
1030
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -07001031 iwlagn_pass_packet_to_mac80211(priv, header, len, ampdu_status,
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +01001032 rxb, &rx_status);
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -07001033 return 0;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +01001034}
1035
1036/**
1037 * iwl_setup_rx_handlers - Initialize Rx handler callbacks
1038 *
1039 * Setup the RX handlers for each of the reply types sent from the uCode
1040 * to the host.
1041 */
1042void iwl_setup_rx_handlers(struct iwl_priv *priv)
1043{
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -07001044 int (**handlers)(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
1045 struct iwl_device_cmd *cmd);
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +01001046
1047 handlers = priv->rx_handlers;
1048
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -07001049 handlers[REPLY_ERROR] = iwlagn_rx_reply_error;
1050 handlers[CHANNEL_SWITCH_NOTIFICATION] = iwlagn_rx_csa;
1051 handlers[SPECTRUM_MEASURE_NOTIFICATION] =
1052 iwlagn_rx_spectrum_measure_notif;
1053 handlers[PM_SLEEP_NOTIFICATION] = iwlagn_rx_pm_sleep_notif;
1054 handlers[PM_DEBUG_STATISTIC_NOTIFIC] =
1055 iwlagn_rx_pm_debug_statistics_notif;
1056 handlers[BEACON_NOTIFICATION] = iwlagn_rx_beacon_notif;
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -07001057 handlers[REPLY_ADD_STA] = iwl_add_sta_callback;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +01001058
1059 /*
1060 * The same handler is used for both the REPLY to a discrete
1061 * statistics request from the host as well as for the periodic
1062 * statistics notifications (after received beacons) from the uCode.
1063 */
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -07001064 handlers[REPLY_STATISTICS_CMD] = iwlagn_rx_reply_statistics;
1065 handlers[STATISTICS_NOTIFICATION] = iwlagn_rx_statistics;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +01001066
1067 iwl_setup_rx_scan_handlers(priv);
1068
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -07001069 handlers[CARD_STATE_NOTIFICATION] = iwlagn_rx_card_state_notif;
1070 handlers[MISSED_BEACONS_NOTIFICATION] =
1071 iwlagn_rx_missed_beacon_notif;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +01001072
1073 /* Rx handlers */
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -07001074 handlers[REPLY_RX_PHY_CMD] = iwlagn_rx_reply_rx_phy;
1075 handlers[REPLY_RX_MPDU_CMD] = iwlagn_rx_reply_rx;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +01001076
1077 /* block ack */
Wey-Yi Guy3246c4e2011-10-10 07:27:13 -07001078 handlers[REPLY_COMPRESSED_BA] =
1079 iwlagn_rx_reply_compressed_ba;
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +01001080
Emmanuel Grumbach8d301192011-07-03 15:45:34 +03001081 /* init calibration handlers */
1082 priv->rx_handlers[CALIBRATION_RES_NOTIFICATION] =
1083 iwlagn_rx_calib_result;
1084 priv->rx_handlers[REPLY_TX] = iwlagn_rx_reply_tx;
1085
1086 /* set up notification wait support */
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001087 spin_lock_init(&priv->notif_wait_lock);
1088 INIT_LIST_HEAD(&priv->notif_waits);
1089 init_waitqueue_head(&priv->notif_waitq);
Emmanuel Grumbach8d301192011-07-03 15:45:34 +03001090
1091 /* Set up BT Rx handlers */
1092 if (priv->cfg->lib->bt_rx_handler_setup)
1093 priv->cfg->lib->bt_rx_handler_setup(priv);
1094
Stanislaw Gruszka466a19a2011-03-04 17:51:49 +01001095}
Emmanuel Grumbach1ab9f6c2011-07-07 07:59:02 -07001096
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -07001097int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
1098 struct iwl_device_cmd *cmd)
Emmanuel Grumbach1ab9f6c2011-07-07 07:59:02 -07001099{
1100 struct iwl_rx_packet *pkt = rxb_addr(rxb);
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -07001101 int err = 0;
Emmanuel Grumbach1ab9f6c2011-07-07 07:59:02 -07001102
1103 /*
1104 * Do the notification wait before RX handlers so
1105 * even if the RX handler consumes the RXB we have
1106 * access to it in the notification wait entry.
1107 */
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001108 if (!list_empty(&priv->notif_waits)) {
Emmanuel Grumbach1ab9f6c2011-07-07 07:59:02 -07001109 struct iwl_notification_wait *w;
1110
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001111 spin_lock(&priv->notif_wait_lock);
1112 list_for_each_entry(w, &priv->notif_waits, list) {
Emmanuel Grumbach1ab9f6c2011-07-07 07:59:02 -07001113 if (w->cmd != pkt->hdr.cmd)
1114 continue;
1115 IWL_DEBUG_RX(priv,
1116 "Notif: %s, 0x%02x - wake the callers up\n",
1117 get_cmd_string(pkt->hdr.cmd),
1118 pkt->hdr.cmd);
1119 w->triggered = true;
1120 if (w->fn)
1121 w->fn(priv, pkt, w->fn_data);
1122 }
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001123 spin_unlock(&priv->notif_wait_lock);
Emmanuel Grumbach1ab9f6c2011-07-07 07:59:02 -07001124
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001125 wake_up_all(&priv->notif_waitq);
Emmanuel Grumbach1ab9f6c2011-07-07 07:59:02 -07001126 }
1127
1128 if (priv->pre_rx_handler)
1129 priv->pre_rx_handler(priv, rxb);
1130
1131 /* Based on type of command response or notification,
1132 * handle those that need handling via function in
1133 * rx_handlers table. See iwl_setup_rx_handlers() */
1134 if (priv->rx_handlers[pkt->hdr.cmd]) {
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -07001135 priv->rx_handlers_stats[pkt->hdr.cmd]++;
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -07001136 err = priv->rx_handlers[pkt->hdr.cmd] (priv, rxb, cmd);
Emmanuel Grumbach1ab9f6c2011-07-07 07:59:02 -07001137 } else {
1138 /* No handling needed */
1139 IWL_DEBUG_RX(priv,
1140 "No handler needed for %s, 0x%02x\n",
1141 get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
1142 }
Emmanuel Grumbach247c61d2011-09-20 15:37:23 -07001143 return err;
Emmanuel Grumbach1ab9f6c2011-07-07 07:59:02 -07001144}