iwl-rx.c 31 KB

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