iwl-rx.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
  4. *
  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:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *
  28. *****************************************************************************/
  29. #include <linux/etherdevice.h>
  30. #include <linux/slab.h>
  31. #include <linux/sched.h>
  32. #include <net/mac80211.h>
  33. #include <asm/unaligned.h>
  34. #include "iwl-eeprom.h"
  35. #include "iwl-dev.h"
  36. #include "iwl-core.h"
  37. #include "iwl-sta.h"
  38. #include "iwl-io.h"
  39. #include "iwl-helpers.h"
  40. #include "iwl-agn-calib.h"
  41. #include "iwl-agn.h"
  42. /******************************************************************************
  43. *
  44. * RX path functions
  45. *
  46. ******************************************************************************/
  47. /*
  48. * Rx theory of operation
  49. *
  50. * Driver allocates a circular buffer of Receive Buffer Descriptors (RBDs),
  51. * each of which point to Receive Buffers to be filled by the NIC. These get
  52. * used not only for Rx frames, but for any command response or notification
  53. * from the NIC. The driver and NIC manage the Rx buffers by means
  54. * of indexes into the circular buffer.
  55. *
  56. * Rx Queue Indexes
  57. * The host/firmware share two index registers for managing the Rx buffers.
  58. *
  59. * The READ index maps to the first position that the firmware may be writing
  60. * to -- the driver can read up to (but not including) this position and get
  61. * good data.
  62. * The READ index is managed by the firmware once the card is enabled.
  63. *
  64. * The WRITE index maps to the last position the driver has read from -- the
  65. * position preceding WRITE is the last slot the firmware can place a packet.
  66. *
  67. * The queue is empty (no good data) if WRITE = READ - 1, and is full if
  68. * WRITE = READ.
  69. *
  70. * During initialization, the host sets up the READ queue position to the first
  71. * INDEX position, and WRITE to the last (READ - 1 wrapped)
  72. *
  73. * When the firmware places a packet in a buffer, it will advance the READ index
  74. * and fire the RX interrupt. The driver can then query the READ index and
  75. * process as many packets as possible, moving the WRITE index forward as it
  76. * resets the Rx queue buffers with new memory.
  77. *
  78. * The management in the driver is as follows:
  79. * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When
  80. * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled
  81. * to replenish the iwl->rxq->rx_free.
  82. * + In iwl_rx_replenish (scheduled) if 'processed' != 'read' then the
  83. * iwl->rxq is replenished and the READ INDEX is updated (updating the
  84. * 'processed' and 'read' driver indexes as well)
  85. * + A received packet is processed and handed to the kernel network stack,
  86. * detached from the iwl->rxq. The driver 'processed' index is updated.
  87. * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free
  88. * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ
  89. * INDEX is not incremented and iwl->status(RX_STALLED) is set. If there
  90. * were enough free buffers and RX_STALLED is set it is cleared.
  91. *
  92. *
  93. * Driver sequence:
  94. *
  95. * iwl_rx_queue_alloc() Allocates rx_free
  96. * iwl_rx_replenish() Replenishes rx_free list from rx_used, and calls
  97. * iwl_rx_queue_restock
  98. * iwl_rx_queue_restock() Moves available buffers from rx_free into Rx
  99. * queue, updates firmware pointers, and updates
  100. * the WRITE index. If insufficient rx_free buffers
  101. * are available, schedules iwl_rx_replenish
  102. *
  103. * -- enable interrupts --
  104. * ISR - iwl_rx() Detach iwl_rx_mem_buffers from pool up to the
  105. * READ INDEX, detaching the SKB from the pool.
  106. * Moves the packet buffer from queue to rx_used.
  107. * Calls iwl_rx_queue_restock to refill any empty
  108. * slots.
  109. * ...
  110. *
  111. */
  112. /**
  113. * iwl_rx_queue_space - Return number of free slots available in queue.
  114. */
  115. int iwl_rx_queue_space(const struct iwl_rx_queue *q)
  116. {
  117. int s = q->read - q->write;
  118. if (s <= 0)
  119. s += RX_QUEUE_SIZE;
  120. /* keep some buffer to not confuse full and empty queue */
  121. s -= 2;
  122. if (s < 0)
  123. s = 0;
  124. return s;
  125. }
  126. /**
  127. * iwl_rx_queue_update_write_ptr - Update the write pointer for the RX queue
  128. */
  129. void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q)
  130. {
  131. unsigned long flags;
  132. u32 reg;
  133. spin_lock_irqsave(&q->lock, flags);
  134. if (q->need_update == 0)
  135. goto exit_unlock;
  136. if (priv->cfg->base_params->shadow_reg_enable) {
  137. /* shadow register enabled */
  138. /* Device expects a multiple of 8 */
  139. q->write_actual = (q->write & ~0x7);
  140. iwl_write32(priv, FH_RSCSR_CHNL0_WPTR, q->write_actual);
  141. } else {
  142. /* If power-saving is in use, make sure device is awake */
  143. if (test_bit(STATUS_POWER_PMI, &priv->status)) {
  144. reg = iwl_read32(priv, CSR_UCODE_DRV_GP1);
  145. if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) {
  146. IWL_DEBUG_INFO(priv,
  147. "Rx queue requesting wakeup,"
  148. " GP1 = 0x%x\n", reg);
  149. iwl_set_bit(priv, CSR_GP_CNTRL,
  150. CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
  151. goto exit_unlock;
  152. }
  153. q->write_actual = (q->write & ~0x7);
  154. iwl_write_direct32(priv, FH_RSCSR_CHNL0_WPTR,
  155. q->write_actual);
  156. /* Else device is assumed to be awake */
  157. } else {
  158. /* Device expects a multiple of 8 */
  159. q->write_actual = (q->write & ~0x7);
  160. iwl_write_direct32(priv, FH_RSCSR_CHNL0_WPTR,
  161. q->write_actual);
  162. }
  163. }
  164. q->need_update = 0;
  165. exit_unlock:
  166. spin_unlock_irqrestore(&q->lock, flags);
  167. }
  168. /******************************************************************************
  169. *
  170. * Generic RX handler implementations
  171. *
  172. ******************************************************************************/
  173. static void iwl_rx_reply_error(struct iwl_priv *priv,
  174. struct iwl_rx_mem_buffer *rxb)
  175. {
  176. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  177. IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) "
  178. "seq 0x%04X ser 0x%08X\n",
  179. le32_to_cpu(pkt->u.err_resp.error_type),
  180. get_cmd_string(pkt->u.err_resp.cmd_id),
  181. pkt->u.err_resp.cmd_id,
  182. le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num),
  183. le32_to_cpu(pkt->u.err_resp.error_info));
  184. }
  185. static void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
  186. {
  187. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  188. struct iwl_csa_notification *csa = &(pkt->u.csa_notif);
  189. /*
  190. * MULTI-FIXME
  191. * See iwl_mac_channel_switch.
  192. */
  193. struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
  194. struct iwl_rxon_cmd *rxon = (void *)&ctx->active;
  195. if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status))
  196. return;
  197. if (!le32_to_cpu(csa->status) && csa->channel == priv->switch_channel) {
  198. rxon->channel = csa->channel;
  199. ctx->staging.channel = csa->channel;
  200. IWL_DEBUG_11H(priv, "CSA notif: channel %d\n",
  201. le16_to_cpu(csa->channel));
  202. iwl_chswitch_done(priv, true);
  203. } else {
  204. IWL_ERR(priv, "CSA notif (fail) : channel %d\n",
  205. le16_to_cpu(csa->channel));
  206. iwl_chswitch_done(priv, false);
  207. }
  208. }
  209. static void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv,
  210. struct iwl_rx_mem_buffer *rxb)
  211. {
  212. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  213. struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif);
  214. if (!report->state) {
  215. IWL_DEBUG_11H(priv,
  216. "Spectrum Measure Notification: Start\n");
  217. return;
  218. }
  219. memcpy(&priv->measure_report, report, sizeof(*report));
  220. priv->measurement_status |= MEASUREMENT_READY;
  221. }
  222. static void iwl_rx_pm_sleep_notif(struct iwl_priv *priv,
  223. struct iwl_rx_mem_buffer *rxb)
  224. {
  225. #ifdef CONFIG_IWLWIFI_DEBUG
  226. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  227. struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif);
  228. IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n",
  229. sleep->pm_sleep_mode, sleep->pm_wakeup_src);
  230. #endif
  231. }
  232. static void iwl_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
  233. struct iwl_rx_mem_buffer *rxb)
  234. {
  235. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  236. u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
  237. IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled "
  238. "notification for %s:\n", len,
  239. get_cmd_string(pkt->hdr.cmd));
  240. iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, len);
  241. }
  242. static void iwl_rx_beacon_notif(struct iwl_priv *priv,
  243. struct iwl_rx_mem_buffer *rxb)
  244. {
  245. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  246. struct iwlagn_beacon_notif *beacon = (void *)pkt->u.raw;
  247. #ifdef CONFIG_IWLWIFI_DEBUG
  248. u16 status = le16_to_cpu(beacon->beacon_notify_hdr.status.status);
  249. u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags);
  250. IWL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d "
  251. "tsf:0x%.8x%.8x rate:%d\n",
  252. status & TX_STATUS_MSK,
  253. beacon->beacon_notify_hdr.failure_frame,
  254. le32_to_cpu(beacon->ibss_mgr_status),
  255. le32_to_cpu(beacon->high_tsf),
  256. le32_to_cpu(beacon->low_tsf), rate);
  257. #endif
  258. priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status);
  259. if (!test_bit(STATUS_EXIT_PENDING, &priv->status))
  260. queue_work(priv->workqueue, &priv->beacon_update);
  261. }
  262. /* the threshold ratio of actual_ack_cnt to expected_ack_cnt in percent */
  263. #define ACK_CNT_RATIO (50)
  264. #define BA_TIMEOUT_CNT (5)
  265. #define BA_TIMEOUT_MAX (16)
  266. /**
  267. * iwl_good_ack_health - checks for ACK count ratios, BA timeout retries.
  268. *
  269. * When the ACK count ratio is low and aggregated BA timeout retries exceeding
  270. * the BA_TIMEOUT_MAX, reload firmware and bring system back to normal
  271. * operation state.
  272. */
  273. static bool iwl_good_ack_health(struct iwl_priv *priv,
  274. struct statistics_tx *cur)
  275. {
  276. int actual_delta, expected_delta, ba_timeout_delta;
  277. struct statistics_tx *old;
  278. if (priv->_agn.agg_tids_count)
  279. return true;
  280. old = &priv->statistics.tx;
  281. actual_delta = le32_to_cpu(cur->actual_ack_cnt) -
  282. le32_to_cpu(old->actual_ack_cnt);
  283. expected_delta = le32_to_cpu(cur->expected_ack_cnt) -
  284. le32_to_cpu(old->expected_ack_cnt);
  285. /* Values should not be negative, but we do not trust the firmware */
  286. if (actual_delta <= 0 || expected_delta <= 0)
  287. return true;
  288. ba_timeout_delta = le32_to_cpu(cur->agg.ba_timeout) -
  289. le32_to_cpu(old->agg.ba_timeout);
  290. if ((actual_delta * 100 / expected_delta) < ACK_CNT_RATIO &&
  291. ba_timeout_delta > BA_TIMEOUT_CNT) {
  292. IWL_DEBUG_RADIO(priv, "deltas: actual %d expected %d ba_timeout %d\n",
  293. actual_delta, expected_delta, ba_timeout_delta);
  294. #ifdef CONFIG_IWLWIFI_DEBUGFS
  295. /*
  296. * This is ifdef'ed on DEBUGFS because otherwise the
  297. * statistics aren't available. If DEBUGFS is set but
  298. * DEBUG is not, these will just compile out.
  299. */
  300. IWL_DEBUG_RADIO(priv, "rx_detected_cnt delta %d\n",
  301. priv->delta_stats.tx.rx_detected_cnt);
  302. IWL_DEBUG_RADIO(priv,
  303. "ack_or_ba_timeout_collision delta %d\n",
  304. priv->delta_stats.tx.ack_or_ba_timeout_collision);
  305. #endif
  306. if (ba_timeout_delta >= BA_TIMEOUT_MAX)
  307. return false;
  308. }
  309. return true;
  310. }
  311. /**
  312. * iwl_good_plcp_health - checks for plcp error.
  313. *
  314. * When the plcp error is exceeding the thresholds, reset the radio
  315. * to improve the throughput.
  316. */
  317. static bool iwl_good_plcp_health(struct iwl_priv *priv,
  318. struct statistics_rx_phy *cur_ofdm,
  319. struct statistics_rx_ht_phy *cur_ofdm_ht,
  320. unsigned int msecs)
  321. {
  322. int delta;
  323. int threshold = priv->cfg->base_params->plcp_delta_threshold;
  324. if (threshold == IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {
  325. IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n");
  326. return true;
  327. }
  328. 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);
  332. /* Can be negative if firmware reset statistics */
  333. if (delta <= 0)
  334. return true;
  335. if ((delta * 100 / msecs) > threshold) {
  336. IWL_DEBUG_RADIO(priv,
  337. "plcp health threshold %u delta %d msecs %u\n",
  338. threshold, delta, msecs);
  339. return false;
  340. }
  341. return true;
  342. }
  343. static void iwl_recover_from_statistics(struct iwl_priv *priv,
  344. struct statistics_rx_phy *cur_ofdm,
  345. struct statistics_rx_ht_phy *cur_ofdm_ht,
  346. struct statistics_tx *tx,
  347. unsigned long stamp)
  348. {
  349. unsigned int msecs;
  350. if (test_bit(STATUS_EXIT_PENDING, &priv->status))
  351. return;
  352. msecs = jiffies_to_msecs(stamp - priv->rx_statistics_jiffies);
  353. /* Only gather statistics and update time stamp when not associated */
  354. if (!iwl_is_any_associated(priv))
  355. return;
  356. /* Do not check/recover when do not have enough statistics data */
  357. if (msecs < 99)
  358. return;
  359. if (iwlagn_mod_params.ack_check && !iwl_good_ack_health(priv, tx)) {
  360. IWL_ERR(priv, "low ack count detected, restart firmware\n");
  361. if (!iwl_force_reset(priv, IWL_FW_RESET, false))
  362. return;
  363. }
  364. if (iwlagn_mod_params.plcp_check &&
  365. !iwl_good_plcp_health(priv, cur_ofdm, cur_ofdm_ht, msecs))
  366. iwl_force_reset(priv, IWL_RF_RESET, false);
  367. }
  368. /* Calculate noise level, based on measurements during network silence just
  369. * before arriving beacon. This measurement can be done only if we know
  370. * exactly when to expect beacons, therefore only when we're associated. */
  371. static void iwl_rx_calc_noise(struct iwl_priv *priv)
  372. {
  373. struct statistics_rx_non_phy *rx_info;
  374. int num_active_rx = 0;
  375. int total_silence = 0;
  376. int bcn_silence_a, bcn_silence_b, bcn_silence_c;
  377. int last_rx_noise;
  378. rx_info = &priv->statistics.rx_non_phy;
  379. bcn_silence_a =
  380. le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER;
  381. bcn_silence_b =
  382. le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER;
  383. bcn_silence_c =
  384. le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER;
  385. if (bcn_silence_a) {
  386. total_silence += bcn_silence_a;
  387. num_active_rx++;
  388. }
  389. if (bcn_silence_b) {
  390. total_silence += bcn_silence_b;
  391. num_active_rx++;
  392. }
  393. if (bcn_silence_c) {
  394. total_silence += bcn_silence_c;
  395. num_active_rx++;
  396. }
  397. /* Average among active antennas */
  398. if (num_active_rx)
  399. last_rx_noise = (total_silence / num_active_rx) - 107;
  400. else
  401. last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE;
  402. IWL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n",
  403. bcn_silence_a, bcn_silence_b, bcn_silence_c,
  404. last_rx_noise);
  405. }
  406. #ifdef CONFIG_IWLWIFI_DEBUGFS
  407. /*
  408. * based on the assumption of all statistics counter are in DWORD
  409. * FIXME: This function is for debugging, do not deal with
  410. * the case of counters roll-over.
  411. */
  412. static void accum_stats(__le32 *prev, __le32 *cur, __le32 *delta,
  413. __le32 *max_delta, __le32 *accum, int size)
  414. {
  415. int i;
  416. for (i = 0;
  417. i < size / sizeof(__le32);
  418. i++, prev++, cur++, delta++, max_delta++, accum++) {
  419. if (le32_to_cpu(*cur) > le32_to_cpu(*prev)) {
  420. *delta = cpu_to_le32(
  421. le32_to_cpu(*cur) - le32_to_cpu(*prev));
  422. le32_add_cpu(accum, le32_to_cpu(*delta));
  423. if (le32_to_cpu(*delta) > le32_to_cpu(*max_delta))
  424. *max_delta = *delta;
  425. }
  426. }
  427. }
  428. static void
  429. iwl_accumulative_statistics(struct iwl_priv *priv,
  430. struct statistics_general_common *common,
  431. struct statistics_rx_non_phy *rx_non_phy,
  432. struct statistics_rx_phy *rx_ofdm,
  433. struct statistics_rx_ht_phy *rx_ofdm_ht,
  434. struct statistics_rx_phy *rx_cck,
  435. struct statistics_tx *tx,
  436. struct statistics_bt_activity *bt_activity)
  437. {
  438. #define ACCUM(_name) \
  439. accum_stats((__le32 *)&priv->statistics._name, \
  440. (__le32 *)_name, \
  441. (__le32 *)&priv->delta_stats._name, \
  442. (__le32 *)&priv->max_delta_stats._name, \
  443. (__le32 *)&priv->accum_stats._name, \
  444. sizeof(*_name));
  445. ACCUM(common);
  446. ACCUM(rx_non_phy);
  447. ACCUM(rx_ofdm);
  448. ACCUM(rx_ofdm_ht);
  449. ACCUM(rx_cck);
  450. ACCUM(tx);
  451. if (bt_activity)
  452. ACCUM(bt_activity);
  453. #undef ACCUM
  454. }
  455. #else
  456. static inline void
  457. iwl_accumulative_statistics(struct iwl_priv *priv,
  458. struct statistics_general_common *common,
  459. struct statistics_rx_non_phy *rx_non_phy,
  460. struct statistics_rx_phy *rx_ofdm,
  461. struct statistics_rx_ht_phy *rx_ofdm_ht,
  462. struct statistics_rx_phy *rx_cck,
  463. struct statistics_tx *tx,
  464. struct statistics_bt_activity *bt_activity)
  465. {
  466. }
  467. #endif
  468. static void iwl_rx_statistics(struct iwl_priv *priv,
  469. struct iwl_rx_mem_buffer *rxb)
  470. {
  471. unsigned long stamp = jiffies;
  472. const int reg_recalib_period = 60;
  473. int change;
  474. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  475. u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
  476. __le32 *flag;
  477. struct statistics_general_common *common;
  478. struct statistics_rx_non_phy *rx_non_phy;
  479. struct statistics_rx_phy *rx_ofdm;
  480. struct statistics_rx_ht_phy *rx_ofdm_ht;
  481. struct statistics_rx_phy *rx_cck;
  482. struct statistics_tx *tx;
  483. struct statistics_bt_activity *bt_activity;
  484. len -= sizeof(struct iwl_cmd_header); /* skip header */
  485. IWL_DEBUG_RX(priv, "Statistics notification received (%d bytes).\n",
  486. len);
  487. if (len == sizeof(struct iwl_bt_notif_statistics)) {
  488. struct iwl_bt_notif_statistics *stats;
  489. stats = &pkt->u.stats_bt;
  490. flag = &stats->flag;
  491. common = &stats->general.common;
  492. rx_non_phy = &stats->rx.general.common;
  493. rx_ofdm = &stats->rx.ofdm;
  494. rx_ofdm_ht = &stats->rx.ofdm_ht;
  495. rx_cck = &stats->rx.cck;
  496. tx = &stats->tx;
  497. bt_activity = &stats->general.activity;
  498. #ifdef CONFIG_IWLWIFI_DEBUGFS
  499. /* handle this exception directly */
  500. priv->statistics.num_bt_kills = stats->rx.general.num_bt_kills;
  501. le32_add_cpu(&priv->statistics.accum_num_bt_kills,
  502. le32_to_cpu(stats->rx.general.num_bt_kills));
  503. #endif
  504. } else if (len == sizeof(struct iwl_notif_statistics)) {
  505. struct iwl_notif_statistics *stats;
  506. stats = &pkt->u.stats;
  507. flag = &stats->flag;
  508. common = &stats->general.common;
  509. rx_non_phy = &stats->rx.general;
  510. rx_ofdm = &stats->rx.ofdm;
  511. rx_ofdm_ht = &stats->rx.ofdm_ht;
  512. rx_cck = &stats->rx.cck;
  513. tx = &stats->tx;
  514. bt_activity = NULL;
  515. } else {
  516. WARN_ONCE(1, "len %d doesn't match BT (%zu) or normal (%zu)\n",
  517. len, sizeof(struct iwl_bt_notif_statistics),
  518. sizeof(struct iwl_notif_statistics));
  519. return;
  520. }
  521. change = common->temperature != priv->statistics.common.temperature ||
  522. (*flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=
  523. (priv->statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK);
  524. iwl_accumulative_statistics(priv, common, rx_non_phy, rx_ofdm,
  525. rx_ofdm_ht, rx_cck, tx, bt_activity);
  526. iwl_recover_from_statistics(priv, rx_ofdm, rx_ofdm_ht, tx, stamp);
  527. priv->statistics.flag = *flag;
  528. memcpy(&priv->statistics.common, common, sizeof(*common));
  529. memcpy(&priv->statistics.rx_non_phy, rx_non_phy, sizeof(*rx_non_phy));
  530. memcpy(&priv->statistics.rx_ofdm, rx_ofdm, sizeof(*rx_ofdm));
  531. memcpy(&priv->statistics.rx_ofdm_ht, rx_ofdm_ht, sizeof(*rx_ofdm_ht));
  532. memcpy(&priv->statistics.rx_cck, rx_cck, sizeof(*rx_cck));
  533. memcpy(&priv->statistics.tx, tx, sizeof(*tx));
  534. #ifdef CONFIG_IWLWIFI_DEBUGFS
  535. if (bt_activity)
  536. memcpy(&priv->statistics.bt_activity, bt_activity,
  537. sizeof(*bt_activity));
  538. #endif
  539. priv->rx_statistics_jiffies = stamp;
  540. set_bit(STATUS_STATISTICS, &priv->status);
  541. /* Reschedule the statistics timer to occur in
  542. * reg_recalib_period seconds to ensure we get a
  543. * thermal update even if the uCode doesn't give
  544. * us one */
  545. mod_timer(&priv->statistics_periodic, jiffies +
  546. msecs_to_jiffies(reg_recalib_period * 1000));
  547. if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) &&
  548. (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) {
  549. iwl_rx_calc_noise(priv);
  550. queue_work(priv->workqueue, &priv->run_time_calib_work);
  551. }
  552. if (priv->cfg->ops->lib->temp_ops.temperature && change)
  553. priv->cfg->ops->lib->temp_ops.temperature(priv);
  554. }
  555. static void iwl_rx_reply_statistics(struct iwl_priv *priv,
  556. struct iwl_rx_mem_buffer *rxb)
  557. {
  558. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  559. if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) {
  560. #ifdef CONFIG_IWLWIFI_DEBUGFS
  561. memset(&priv->accum_stats, 0,
  562. sizeof(priv->accum_stats));
  563. memset(&priv->delta_stats, 0,
  564. sizeof(priv->delta_stats));
  565. memset(&priv->max_delta_stats, 0,
  566. sizeof(priv->max_delta_stats));
  567. #endif
  568. IWL_DEBUG_RX(priv, "Statistics have been cleared\n");
  569. }
  570. iwl_rx_statistics(priv, rxb);
  571. }
  572. /* Handle notification from uCode that card's power state is changing
  573. * due to software, hardware, or critical temperature RFKILL */
  574. static void iwl_rx_card_state_notif(struct iwl_priv *priv,
  575. struct iwl_rx_mem_buffer *rxb)
  576. {
  577. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  578. u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);
  579. unsigned long status = priv->status;
  580. IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n",
  581. (flags & HW_CARD_DISABLED) ? "Kill" : "On",
  582. (flags & SW_CARD_DISABLED) ? "Kill" : "On",
  583. (flags & CT_CARD_DISABLED) ?
  584. "Reached" : "Not reached");
  585. if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED |
  586. CT_CARD_DISABLED)) {
  587. iwl_write32(priv, CSR_UCODE_DRV_GP1_SET,
  588. CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
  589. iwl_write_direct32(priv, HBUS_TARG_MBX_C,
  590. HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
  591. if (!(flags & RXON_CARD_DISABLED)) {
  592. iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
  593. CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
  594. iwl_write_direct32(priv, HBUS_TARG_MBX_C,
  595. HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
  596. }
  597. if (flags & CT_CARD_DISABLED)
  598. iwl_tt_enter_ct_kill(priv);
  599. }
  600. if (!(flags & CT_CARD_DISABLED))
  601. iwl_tt_exit_ct_kill(priv);
  602. if (flags & HW_CARD_DISABLED)
  603. set_bit(STATUS_RF_KILL_HW, &priv->status);
  604. else
  605. clear_bit(STATUS_RF_KILL_HW, &priv->status);
  606. if (!(flags & RXON_CARD_DISABLED))
  607. iwl_scan_cancel(priv);
  608. if ((test_bit(STATUS_RF_KILL_HW, &status) !=
  609. test_bit(STATUS_RF_KILL_HW, &priv->status)))
  610. wiphy_rfkill_set_hw_state(priv->hw->wiphy,
  611. test_bit(STATUS_RF_KILL_HW, &priv->status));
  612. else
  613. wake_up_interruptible(&priv->wait_command_queue);
  614. }
  615. static void iwl_rx_missed_beacon_notif(struct iwl_priv *priv,
  616. struct iwl_rx_mem_buffer *rxb)
  617. {
  618. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  619. struct iwl_missed_beacon_notif *missed_beacon;
  620. missed_beacon = &pkt->u.missed_beacon;
  621. if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) >
  622. priv->missed_beacon_threshold) {
  623. IWL_DEBUG_CALIB(priv,
  624. "missed bcn cnsq %d totl %d rcd %d expctd %d\n",
  625. le32_to_cpu(missed_beacon->consecutive_missed_beacons),
  626. le32_to_cpu(missed_beacon->total_missed_becons),
  627. le32_to_cpu(missed_beacon->num_recvd_beacons),
  628. le32_to_cpu(missed_beacon->num_expected_beacons));
  629. if (!test_bit(STATUS_SCANNING, &priv->status))
  630. iwl_init_sensitivity(priv);
  631. }
  632. }
  633. /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD).
  634. * This will be used later in iwl_rx_reply_rx() for REPLY_RX_MPDU_CMD. */
  635. static void iwl_rx_reply_rx_phy(struct iwl_priv *priv,
  636. struct iwl_rx_mem_buffer *rxb)
  637. {
  638. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  639. priv->_agn.last_phy_res_valid = true;
  640. memcpy(&priv->_agn.last_phy_res, pkt->u.raw,
  641. sizeof(struct iwl_rx_phy_res));
  642. }
  643. /*
  644. * returns non-zero if packet should be dropped
  645. */
  646. static int iwl_set_decrypted_flag(struct iwl_priv *priv,
  647. struct ieee80211_hdr *hdr,
  648. u32 decrypt_res,
  649. struct ieee80211_rx_status *stats)
  650. {
  651. u16 fc = le16_to_cpu(hdr->frame_control);
  652. /*
  653. * All contexts have the same setting here due to it being
  654. * a module parameter, so OK to check any context.
  655. */
  656. if (priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags &
  657. RXON_FILTER_DIS_DECRYPT_MSK)
  658. return 0;
  659. if (!(fc & IEEE80211_FCTL_PROTECTED))
  660. return 0;
  661. IWL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res);
  662. switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) {
  663. case RX_RES_STATUS_SEC_TYPE_TKIP:
  664. /* The uCode has got a bad phase 1 Key, pushes the packet.
  665. * Decryption will be done in SW. */
  666. if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
  667. RX_RES_STATUS_BAD_KEY_TTAK)
  668. break;
  669. case RX_RES_STATUS_SEC_TYPE_WEP:
  670. if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
  671. RX_RES_STATUS_BAD_ICV_MIC) {
  672. /* bad ICV, the packet is destroyed since the
  673. * decryption is inplace, drop it */
  674. IWL_DEBUG_RX(priv, "Packet destroyed\n");
  675. return -1;
  676. }
  677. case RX_RES_STATUS_SEC_TYPE_CCMP:
  678. if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
  679. RX_RES_STATUS_DECRYPT_OK) {
  680. IWL_DEBUG_RX(priv, "hw decrypt successfully!!!\n");
  681. stats->flag |= RX_FLAG_DECRYPTED;
  682. }
  683. break;
  684. default:
  685. break;
  686. }
  687. return 0;
  688. }
  689. static void iwl_pass_packet_to_mac80211(struct iwl_priv *priv,
  690. struct ieee80211_hdr *hdr,
  691. u16 len,
  692. u32 ampdu_status,
  693. struct iwl_rx_mem_buffer *rxb,
  694. struct ieee80211_rx_status *stats)
  695. {
  696. struct sk_buff *skb;
  697. __le16 fc = hdr->frame_control;
  698. struct iwl_rxon_context *ctx;
  699. /* We only process data packets if the interface is open */
  700. if (unlikely(!priv->is_open)) {
  701. IWL_DEBUG_DROP_LIMIT(priv,
  702. "Dropping packet while interface is not open.\n");
  703. return;
  704. }
  705. /* In case of HW accelerated crypto and bad decryption, drop */
  706. if (!iwlagn_mod_params.sw_crypto &&
  707. iwl_set_decrypted_flag(priv, hdr, ampdu_status, stats))
  708. return;
  709. skb = dev_alloc_skb(128);
  710. if (!skb) {
  711. IWL_ERR(priv, "dev_alloc_skb failed\n");
  712. return;
  713. }
  714. skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len);
  715. iwl_update_stats(priv, false, fc, len);
  716. /*
  717. * Wake any queues that were stopped due to a passive channel tx
  718. * failure. This can happen because the regulatory enforcement in
  719. * the device waits for a beacon before allowing transmission,
  720. * sometimes even after already having transmitted frames for the
  721. * association because the new RXON may reset the information.
  722. */
  723. if (unlikely(ieee80211_is_beacon(fc))) {
  724. for_each_context(priv, ctx) {
  725. if (!ctx->last_tx_rejected)
  726. continue;
  727. if (compare_ether_addr(hdr->addr3,
  728. ctx->active.bssid_addr))
  729. continue;
  730. ctx->last_tx_rejected = false;
  731. iwl_wake_any_queue(priv, ctx);
  732. }
  733. }
  734. memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats));
  735. ieee80211_rx(priv->hw, skb);
  736. rxb->page = NULL;
  737. }
  738. static u32 iwl_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in)
  739. {
  740. u32 decrypt_out = 0;
  741. if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) ==
  742. RX_RES_STATUS_STATION_FOUND)
  743. decrypt_out |= (RX_RES_STATUS_STATION_FOUND |
  744. RX_RES_STATUS_NO_STATION_INFO_MISMATCH);
  745. decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK);
  746. /* packet was not encrypted */
  747. if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==
  748. RX_RES_STATUS_SEC_TYPE_NONE)
  749. return decrypt_out;
  750. /* packet was encrypted with unknown alg */
  751. if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==
  752. RX_RES_STATUS_SEC_TYPE_ERR)
  753. return decrypt_out;
  754. /* decryption was not done in HW */
  755. if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) !=
  756. RX_MPDU_RES_STATUS_DEC_DONE_MSK)
  757. return decrypt_out;
  758. switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) {
  759. case RX_RES_STATUS_SEC_TYPE_CCMP:
  760. /* alg is CCM: check MIC only */
  761. if (!(decrypt_in & RX_MPDU_RES_STATUS_MIC_OK))
  762. /* Bad MIC */
  763. decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;
  764. else
  765. decrypt_out |= RX_RES_STATUS_DECRYPT_OK;
  766. break;
  767. case RX_RES_STATUS_SEC_TYPE_TKIP:
  768. if (!(decrypt_in & RX_MPDU_RES_STATUS_TTAK_OK)) {
  769. /* Bad TTAK */
  770. decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK;
  771. break;
  772. }
  773. /* fall through if TTAK OK */
  774. default:
  775. if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK))
  776. decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;
  777. else
  778. decrypt_out |= RX_RES_STATUS_DECRYPT_OK;
  779. break;
  780. }
  781. IWL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n",
  782. decrypt_in, decrypt_out);
  783. return decrypt_out;
  784. }
  785. /* Called for REPLY_RX (legacy ABG frames), or
  786. * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */
  787. static void iwl_rx_reply_rx(struct iwl_priv *priv,
  788. struct iwl_rx_mem_buffer *rxb)
  789. {
  790. struct ieee80211_hdr *header;
  791. struct ieee80211_rx_status rx_status;
  792. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  793. struct iwl_rx_phy_res *phy_res;
  794. __le32 rx_pkt_status;
  795. struct iwl_rx_mpdu_res_start *amsdu;
  796. u32 len;
  797. u32 ampdu_status;
  798. u32 rate_n_flags;
  799. /**
  800. * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently.
  801. * REPLY_RX: physical layer info is in this buffer
  802. * REPLY_RX_MPDU_CMD: physical layer info was sent in separate
  803. * command and cached in priv->last_phy_res
  804. *
  805. * Here we set up local variables depending on which command is
  806. * received.
  807. */
  808. if (pkt->hdr.cmd == REPLY_RX) {
  809. phy_res = (struct iwl_rx_phy_res *)pkt->u.raw;
  810. header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res)
  811. + phy_res->cfg_phy_cnt);
  812. len = le16_to_cpu(phy_res->byte_count);
  813. rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) +
  814. phy_res->cfg_phy_cnt + len);
  815. ampdu_status = le32_to_cpu(rx_pkt_status);
  816. } else {
  817. if (!priv->_agn.last_phy_res_valid) {
  818. IWL_ERR(priv, "MPDU frame without cached PHY data\n");
  819. return;
  820. }
  821. phy_res = &priv->_agn.last_phy_res;
  822. amsdu = (struct iwl_rx_mpdu_res_start *)pkt->u.raw;
  823. header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu));
  824. len = le16_to_cpu(amsdu->byte_count);
  825. rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len);
  826. ampdu_status = iwl_translate_rx_status(priv,
  827. le32_to_cpu(rx_pkt_status));
  828. }
  829. if ((unlikely(phy_res->cfg_phy_cnt > 20))) {
  830. IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n",
  831. phy_res->cfg_phy_cnt);
  832. return;
  833. }
  834. if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) ||
  835. !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) {
  836. IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n",
  837. le32_to_cpu(rx_pkt_status));
  838. return;
  839. }
  840. /* This will be used in several places later */
  841. rate_n_flags = le32_to_cpu(phy_res->rate_n_flags);
  842. /* rx_status carries information about the packet to mac80211 */
  843. rx_status.mactime = le64_to_cpu(phy_res->timestamp);
  844. rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
  845. IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
  846. rx_status.freq =
  847. ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel),
  848. rx_status.band);
  849. rx_status.rate_idx =
  850. iwlagn_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band);
  851. rx_status.flag = 0;
  852. /* TSF isn't reliable. In order to allow smooth user experience,
  853. * this W/A doesn't propagate it to the mac80211 */
  854. /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/
  855. priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp);
  856. /* Find max signal strength (dBm) among 3 antenna/receiver chains */
  857. rx_status.signal = priv->cfg->ops->utils->calc_rssi(priv, phy_res);
  858. iwl_dbg_log_rx_data_frame(priv, len, header);
  859. IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n",
  860. rx_status.signal, (unsigned long long)rx_status.mactime);
  861. /*
  862. * "antenna number"
  863. *
  864. * It seems that the antenna field in the phy flags value
  865. * is actually a bit field. This is undefined by radiotap,
  866. * it wants an actual antenna number but I always get "7"
  867. * for most legacy frames I receive indicating that the
  868. * same frame was received on all three RX chains.
  869. *
  870. * I think this field should be removed in favor of a
  871. * new 802.11n radiotap field "RX chains" that is defined
  872. * as a bitmask.
  873. */
  874. rx_status.antenna =
  875. (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK)
  876. >> RX_RES_PHY_FLAGS_ANTENNA_POS;
  877. /* set the preamble flag if appropriate */
  878. if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK)
  879. rx_status.flag |= RX_FLAG_SHORTPRE;
  880. /* Set up the HT phy flags */
  881. if (rate_n_flags & RATE_MCS_HT_MSK)
  882. rx_status.flag |= RX_FLAG_HT;
  883. if (rate_n_flags & RATE_MCS_HT40_MSK)
  884. rx_status.flag |= RX_FLAG_40MHZ;
  885. if (rate_n_flags & RATE_MCS_SGI_MSK)
  886. rx_status.flag |= RX_FLAG_SHORT_GI;
  887. iwl_pass_packet_to_mac80211(priv, header, len, ampdu_status,
  888. rxb, &rx_status);
  889. }
  890. /**
  891. * iwl_setup_rx_handlers - Initialize Rx handler callbacks
  892. *
  893. * Setup the RX handlers for each of the reply types sent from the uCode
  894. * to the host.
  895. */
  896. void iwl_setup_rx_handlers(struct iwl_priv *priv)
  897. {
  898. void (**handlers)(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
  899. handlers = priv->rx_handlers;
  900. handlers[REPLY_ERROR] = iwl_rx_reply_error;
  901. handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl_rx_csa;
  902. handlers[SPECTRUM_MEASURE_NOTIFICATION] = iwl_rx_spectrum_measure_notif;
  903. handlers[PM_SLEEP_NOTIFICATION] = iwl_rx_pm_sleep_notif;
  904. handlers[PM_DEBUG_STATISTIC_NOTIFIC] = iwl_rx_pm_debug_statistics_notif;
  905. handlers[BEACON_NOTIFICATION] = iwl_rx_beacon_notif;
  906. /*
  907. * The same handler is used for both the REPLY to a discrete
  908. * statistics request from the host as well as for the periodic
  909. * statistics notifications (after received beacons) from the uCode.
  910. */
  911. handlers[REPLY_STATISTICS_CMD] = iwl_rx_reply_statistics;
  912. handlers[STATISTICS_NOTIFICATION] = iwl_rx_statistics;
  913. iwl_setup_rx_scan_handlers(priv);
  914. handlers[CARD_STATE_NOTIFICATION] = iwl_rx_card_state_notif;
  915. handlers[MISSED_BEACONS_NOTIFICATION] = iwl_rx_missed_beacon_notif;
  916. /* Rx handlers */
  917. handlers[REPLY_RX_PHY_CMD] = iwl_rx_reply_rx_phy;
  918. handlers[REPLY_RX_MPDU_CMD] = iwl_rx_reply_rx;
  919. /* block ack */
  920. handlers[REPLY_COMPRESSED_BA] = iwlagn_rx_reply_compressed_ba;
  921. /* Set up hardware specific Rx handlers */
  922. priv->cfg->ops->lib->rx_handler_setup(priv);
  923. }