scan.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  1. /******************************************************************************
  2. *
  3. * GPL LICENSE SUMMARY
  4. *
  5. * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of version 2 of the GNU General Public License as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  19. * USA
  20. *
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *****************************************************************************/
  28. #include <linux/slab.h>
  29. #include <linux/types.h>
  30. #include <linux/etherdevice.h>
  31. #include <net/mac80211.h>
  32. #include "dev.h"
  33. #include "agn.h"
  34. /* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after
  35. * sending probe req. This should be set long enough to hear probe responses
  36. * from more than one AP. */
  37. #define IWL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */
  38. #define IWL_ACTIVE_DWELL_TIME_52 (20)
  39. #define IWL_ACTIVE_DWELL_FACTOR_24GHZ (3)
  40. #define IWL_ACTIVE_DWELL_FACTOR_52GHZ (2)
  41. /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel.
  42. * Must be set longer than active dwell time.
  43. * For the most reliable scan, set > AP beacon interval (typically 100msec). */
  44. #define IWL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */
  45. #define IWL_PASSIVE_DWELL_TIME_52 (10)
  46. #define IWL_PASSIVE_DWELL_BASE (100)
  47. #define IWL_CHANNEL_TUNE_TIME 5
  48. #define MAX_SCAN_CHANNEL 50
  49. /* For reset radio, need minimal dwell time only */
  50. #define IWL_RADIO_RESET_DWELL_TIME 5
  51. static int iwl_send_scan_abort(struct iwl_priv *priv)
  52. {
  53. int ret;
  54. struct iwl_host_cmd cmd = {
  55. .id = REPLY_SCAN_ABORT_CMD,
  56. .flags = CMD_SYNC | CMD_WANT_SKB,
  57. };
  58. __le32 *status;
  59. /* Exit instantly with error when device is not ready
  60. * to receive scan abort command or it does not perform
  61. * hardware scan currently */
  62. if (!test_bit(STATUS_READY, &priv->status) ||
  63. !test_bit(STATUS_SCAN_HW, &priv->status) ||
  64. test_bit(STATUS_FW_ERROR, &priv->status))
  65. return -EIO;
  66. ret = iwl_dvm_send_cmd(priv, &cmd);
  67. if (ret)
  68. return ret;
  69. status = (void *)cmd.resp_pkt->data;
  70. if (*status != CAN_ABORT_STATUS) {
  71. /* The scan abort will return 1 for success or
  72. * 2 for "failure". A failure condition can be
  73. * due to simply not being in an active scan which
  74. * can occur if we send the scan abort before we
  75. * the microcode has notified us that a scan is
  76. * completed. */
  77. IWL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n",
  78. le32_to_cpu(*status));
  79. ret = -EIO;
  80. }
  81. iwl_free_resp(&cmd);
  82. return ret;
  83. }
  84. static void iwl_complete_scan(struct iwl_priv *priv, bool aborted)
  85. {
  86. /* check if scan was requested from mac80211 */
  87. if (priv->scan_request) {
  88. IWL_DEBUG_SCAN(priv, "Complete scan in mac80211\n");
  89. ieee80211_scan_completed(priv->hw, aborted);
  90. }
  91. if (priv->scan_type == IWL_SCAN_ROC)
  92. iwl_scan_roc_expired(priv);
  93. priv->scan_type = IWL_SCAN_NORMAL;
  94. priv->scan_vif = NULL;
  95. priv->scan_request = NULL;
  96. }
  97. static void iwl_process_scan_complete(struct iwl_priv *priv)
  98. {
  99. bool aborted;
  100. lockdep_assert_held(&priv->mutex);
  101. if (!test_and_clear_bit(STATUS_SCAN_COMPLETE, &priv->status))
  102. return;
  103. IWL_DEBUG_SCAN(priv, "Completed scan.\n");
  104. cancel_delayed_work(&priv->scan_check);
  105. aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &priv->status);
  106. if (aborted)
  107. IWL_DEBUG_SCAN(priv, "Aborted scan completed.\n");
  108. if (!test_and_clear_bit(STATUS_SCANNING, &priv->status)) {
  109. IWL_DEBUG_SCAN(priv, "Scan already completed.\n");
  110. goto out_settings;
  111. }
  112. if (priv->scan_type == IWL_SCAN_ROC)
  113. iwl_scan_roc_expired(priv);
  114. if (priv->scan_type != IWL_SCAN_NORMAL && !aborted) {
  115. int err;
  116. /* Check if mac80211 requested scan during our internal scan */
  117. if (priv->scan_request == NULL)
  118. goto out_complete;
  119. /* If so request a new scan */
  120. err = iwl_scan_initiate(priv, priv->scan_vif, IWL_SCAN_NORMAL,
  121. priv->scan_request->channels[0]->band);
  122. if (err) {
  123. IWL_DEBUG_SCAN(priv,
  124. "failed to initiate pending scan: %d\n", err);
  125. aborted = true;
  126. goto out_complete;
  127. }
  128. return;
  129. }
  130. out_complete:
  131. iwl_complete_scan(priv, aborted);
  132. out_settings:
  133. /* Can we still talk to firmware ? */
  134. if (!iwl_is_ready_rf(priv))
  135. return;
  136. iwlagn_post_scan(priv);
  137. }
  138. void iwl_force_scan_end(struct iwl_priv *priv)
  139. {
  140. lockdep_assert_held(&priv->mutex);
  141. if (!test_bit(STATUS_SCANNING, &priv->status)) {
  142. IWL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n");
  143. return;
  144. }
  145. IWL_DEBUG_SCAN(priv, "Forcing scan end\n");
  146. clear_bit(STATUS_SCANNING, &priv->status);
  147. clear_bit(STATUS_SCAN_HW, &priv->status);
  148. clear_bit(STATUS_SCAN_ABORTING, &priv->status);
  149. clear_bit(STATUS_SCAN_COMPLETE, &priv->status);
  150. iwl_complete_scan(priv, true);
  151. }
  152. static void iwl_do_scan_abort(struct iwl_priv *priv)
  153. {
  154. int ret;
  155. lockdep_assert_held(&priv->mutex);
  156. if (!test_bit(STATUS_SCANNING, &priv->status)) {
  157. IWL_DEBUG_SCAN(priv, "Not performing scan to abort\n");
  158. return;
  159. }
  160. if (test_and_set_bit(STATUS_SCAN_ABORTING, &priv->status)) {
  161. IWL_DEBUG_SCAN(priv, "Scan abort in progress\n");
  162. return;
  163. }
  164. ret = iwl_send_scan_abort(priv);
  165. if (ret) {
  166. IWL_DEBUG_SCAN(priv, "Send scan abort failed %d\n", ret);
  167. iwl_force_scan_end(priv);
  168. } else
  169. IWL_DEBUG_SCAN(priv, "Successfully send scan abort\n");
  170. }
  171. /**
  172. * iwl_scan_cancel - Cancel any currently executing HW scan
  173. */
  174. int iwl_scan_cancel(struct iwl_priv *priv)
  175. {
  176. IWL_DEBUG_SCAN(priv, "Queuing abort scan\n");
  177. queue_work(priv->workqueue, &priv->abort_scan);
  178. return 0;
  179. }
  180. /**
  181. * iwl_scan_cancel_timeout - Cancel any currently executing HW scan
  182. * @ms: amount of time to wait (in milliseconds) for scan to abort
  183. *
  184. */
  185. void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms)
  186. {
  187. unsigned long timeout = jiffies + msecs_to_jiffies(ms);
  188. lockdep_assert_held(&priv->mutex);
  189. IWL_DEBUG_SCAN(priv, "Scan cancel timeout\n");
  190. iwl_do_scan_abort(priv);
  191. while (time_before_eq(jiffies, timeout)) {
  192. if (!test_bit(STATUS_SCAN_HW, &priv->status))
  193. goto finished;
  194. msleep(20);
  195. }
  196. return;
  197. finished:
  198. /*
  199. * Now STATUS_SCAN_HW is clear. This means that the
  200. * device finished, but the background work is going
  201. * to execute at best as soon as we release the mutex.
  202. * Since we need to be able to issue a new scan right
  203. * after this function returns, run the complete here.
  204. * The STATUS_SCAN_COMPLETE bit will then be cleared
  205. * and prevent the background work from "completing"
  206. * a possible new scan.
  207. */
  208. iwl_process_scan_complete(priv);
  209. }
  210. /* Service response to REPLY_SCAN_CMD (0x80) */
  211. static int iwl_rx_reply_scan(struct iwl_priv *priv,
  212. struct iwl_rx_cmd_buffer *rxb,
  213. struct iwl_device_cmd *cmd)
  214. {
  215. #ifdef CONFIG_IWLWIFI_DEBUG
  216. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  217. struct iwl_scanreq_notification *notif = (void *)pkt->data;
  218. IWL_DEBUG_SCAN(priv, "Scan request status = 0x%x\n", notif->status);
  219. #endif
  220. return 0;
  221. }
  222. /* Service SCAN_START_NOTIFICATION (0x82) */
  223. static int iwl_rx_scan_start_notif(struct iwl_priv *priv,
  224. struct iwl_rx_cmd_buffer *rxb,
  225. struct iwl_device_cmd *cmd)
  226. {
  227. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  228. struct iwl_scanstart_notification *notif = (void *)pkt->data;
  229. priv->scan_start_tsf = le32_to_cpu(notif->tsf_low);
  230. IWL_DEBUG_SCAN(priv, "Scan start: "
  231. "%d [802.11%s] "
  232. "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n",
  233. notif->channel,
  234. notif->band ? "bg" : "a",
  235. le32_to_cpu(notif->tsf_high),
  236. le32_to_cpu(notif->tsf_low),
  237. notif->status, notif->beacon_timer);
  238. if (priv->scan_type == IWL_SCAN_ROC &&
  239. !priv->hw_roc_start_notified) {
  240. ieee80211_ready_on_channel(priv->hw);
  241. priv->hw_roc_start_notified = true;
  242. }
  243. return 0;
  244. }
  245. /* Service SCAN_RESULTS_NOTIFICATION (0x83) */
  246. static int iwl_rx_scan_results_notif(struct iwl_priv *priv,
  247. struct iwl_rx_cmd_buffer *rxb,
  248. struct iwl_device_cmd *cmd)
  249. {
  250. #ifdef CONFIG_IWLWIFI_DEBUG
  251. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  252. struct iwl_scanresults_notification *notif = (void *)pkt->data;
  253. IWL_DEBUG_SCAN(priv, "Scan ch.res: "
  254. "%d [802.11%s] "
  255. "probe status: %u:%u "
  256. "(TSF: 0x%08X:%08X) - %d "
  257. "elapsed=%lu usec\n",
  258. notif->channel,
  259. notif->band ? "bg" : "a",
  260. notif->probe_status, notif->num_probe_not_sent,
  261. le32_to_cpu(notif->tsf_high),
  262. le32_to_cpu(notif->tsf_low),
  263. le32_to_cpu(notif->statistics[0]),
  264. le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf);
  265. #endif
  266. return 0;
  267. }
  268. /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */
  269. static int iwl_rx_scan_complete_notif(struct iwl_priv *priv,
  270. struct iwl_rx_cmd_buffer *rxb,
  271. struct iwl_device_cmd *cmd)
  272. {
  273. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  274. struct iwl_scancomplete_notification *scan_notif = (void *)pkt->data;
  275. IWL_DEBUG_SCAN(priv, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n",
  276. scan_notif->scanned_channels,
  277. scan_notif->tsf_low,
  278. scan_notif->tsf_high, scan_notif->status);
  279. IWL_DEBUG_SCAN(priv, "Scan on %sGHz took %dms\n",
  280. (priv->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2",
  281. jiffies_to_msecs(jiffies - priv->scan_start));
  282. /*
  283. * When aborting, we run the scan completed background work inline
  284. * and the background work must then do nothing. The SCAN_COMPLETE
  285. * bit helps implement that logic and thus needs to be set before
  286. * queueing the work. Also, since the scan abort waits for SCAN_HW
  287. * to clear, we need to set SCAN_COMPLETE before clearing SCAN_HW
  288. * to avoid a race there.
  289. */
  290. set_bit(STATUS_SCAN_COMPLETE, &priv->status);
  291. clear_bit(STATUS_SCAN_HW, &priv->status);
  292. queue_work(priv->workqueue, &priv->scan_completed);
  293. if (priv->iw_mode != NL80211_IFTYPE_ADHOC &&
  294. iwl_advanced_bt_coexist(priv) &&
  295. priv->bt_status != scan_notif->bt_status) {
  296. if (scan_notif->bt_status) {
  297. /* BT on */
  298. if (!priv->bt_ch_announce)
  299. priv->bt_traffic_load =
  300. IWL_BT_COEX_TRAFFIC_LOAD_HIGH;
  301. /*
  302. * otherwise, no traffic load information provided
  303. * no changes made
  304. */
  305. } else {
  306. /* BT off */
  307. priv->bt_traffic_load =
  308. IWL_BT_COEX_TRAFFIC_LOAD_NONE;
  309. }
  310. priv->bt_status = scan_notif->bt_status;
  311. queue_work(priv->workqueue,
  312. &priv->bt_traffic_change_work);
  313. }
  314. return 0;
  315. }
  316. void iwl_setup_rx_scan_handlers(struct iwl_priv *priv)
  317. {
  318. /* scan handlers */
  319. priv->rx_handlers[REPLY_SCAN_CMD] = iwl_rx_reply_scan;
  320. priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl_rx_scan_start_notif;
  321. priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] =
  322. iwl_rx_scan_results_notif;
  323. priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] =
  324. iwl_rx_scan_complete_notif;
  325. }
  326. static u16 iwl_get_active_dwell_time(struct iwl_priv *priv,
  327. enum ieee80211_band band, u8 n_probes)
  328. {
  329. if (band == IEEE80211_BAND_5GHZ)
  330. return IWL_ACTIVE_DWELL_TIME_52 +
  331. IWL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1);
  332. else
  333. return IWL_ACTIVE_DWELL_TIME_24 +
  334. IWL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1);
  335. }
  336. static u16 iwl_limit_dwell(struct iwl_priv *priv, u16 dwell_time)
  337. {
  338. struct iwl_rxon_context *ctx;
  339. /*
  340. * If we're associated, we clamp the dwell time 98%
  341. * of the smallest beacon interval (minus 2 * channel
  342. * tune time)
  343. */
  344. for_each_context(priv, ctx) {
  345. u16 value;
  346. switch (ctx->staging.dev_type) {
  347. case RXON_DEV_TYPE_P2P:
  348. /* no timing constraints */
  349. continue;
  350. case RXON_DEV_TYPE_ESS:
  351. default:
  352. /* timing constraints if associated */
  353. if (!iwl_is_associated_ctx(ctx))
  354. continue;
  355. break;
  356. case RXON_DEV_TYPE_CP:
  357. case RXON_DEV_TYPE_2STA:
  358. /*
  359. * These seem to always have timers for TBTT
  360. * active in uCode even when not associated yet.
  361. */
  362. break;
  363. }
  364. value = ctx->beacon_int;
  365. if (!value)
  366. value = IWL_PASSIVE_DWELL_BASE;
  367. value = (value * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2;
  368. dwell_time = min(value, dwell_time);
  369. }
  370. return dwell_time;
  371. }
  372. static u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
  373. enum ieee80211_band band)
  374. {
  375. u16 passive = (band == IEEE80211_BAND_2GHZ) ?
  376. IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 :
  377. IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52;
  378. return iwl_limit_dwell(priv, passive);
  379. }
  380. /* Return valid, unused, channel for a passive scan to reset the RF */
  381. static u8 iwl_get_single_channel_number(struct iwl_priv *priv,
  382. enum ieee80211_band band)
  383. {
  384. struct ieee80211_supported_band *sband = priv->hw->wiphy->bands[band];
  385. struct iwl_rxon_context *ctx;
  386. int i;
  387. for (i = 0; i < sband->n_channels; i++) {
  388. bool busy = false;
  389. for_each_context(priv, ctx) {
  390. busy = sband->channels[i].hw_value ==
  391. le16_to_cpu(ctx->staging.channel);
  392. if (busy)
  393. break;
  394. }
  395. if (busy)
  396. continue;
  397. if (!(sband->channels[i].flags & IEEE80211_CHAN_DISABLED))
  398. return sband->channels[i].hw_value;
  399. }
  400. return 0;
  401. }
  402. static int iwl_get_channel_for_reset_scan(struct iwl_priv *priv,
  403. struct ieee80211_vif *vif,
  404. enum ieee80211_band band,
  405. struct iwl_scan_channel *scan_ch)
  406. {
  407. const struct ieee80211_supported_band *sband;
  408. u16 channel;
  409. sband = iwl_get_hw_mode(priv, band);
  410. if (!sband) {
  411. IWL_ERR(priv, "invalid band\n");
  412. return 0;
  413. }
  414. channel = iwl_get_single_channel_number(priv, band);
  415. if (channel) {
  416. scan_ch->channel = cpu_to_le16(channel);
  417. scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
  418. scan_ch->active_dwell =
  419. cpu_to_le16(IWL_RADIO_RESET_DWELL_TIME);
  420. scan_ch->passive_dwell =
  421. cpu_to_le16(IWL_RADIO_RESET_DWELL_TIME);
  422. /* Set txpower levels to defaults */
  423. scan_ch->dsp_atten = 110;
  424. if (band == IEEE80211_BAND_5GHZ)
  425. scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
  426. else
  427. scan_ch->tx_gain = ((1 << 5) | (5 << 3));
  428. return 1;
  429. }
  430. IWL_ERR(priv, "no valid channel found\n");
  431. return 0;
  432. }
  433. static int iwl_get_channels_for_scan(struct iwl_priv *priv,
  434. struct ieee80211_vif *vif,
  435. enum ieee80211_band band,
  436. u8 is_active, u8 n_probes,
  437. struct iwl_scan_channel *scan_ch)
  438. {
  439. struct ieee80211_channel *chan;
  440. const struct ieee80211_supported_band *sband;
  441. u16 passive_dwell = 0;
  442. u16 active_dwell = 0;
  443. int added, i;
  444. u16 channel;
  445. sband = iwl_get_hw_mode(priv, band);
  446. if (!sband)
  447. return 0;
  448. active_dwell = iwl_get_active_dwell_time(priv, band, n_probes);
  449. passive_dwell = iwl_get_passive_dwell_time(priv, band);
  450. if (passive_dwell <= active_dwell)
  451. passive_dwell = active_dwell + 1;
  452. for (i = 0, added = 0; i < priv->scan_request->n_channels; i++) {
  453. chan = priv->scan_request->channels[i];
  454. if (chan->band != band)
  455. continue;
  456. channel = chan->hw_value;
  457. scan_ch->channel = cpu_to_le16(channel);
  458. if (!is_active || (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN))
  459. scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
  460. else
  461. scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
  462. if (n_probes)
  463. scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
  464. scan_ch->active_dwell = cpu_to_le16(active_dwell);
  465. scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
  466. /* Set txpower levels to defaults */
  467. scan_ch->dsp_atten = 110;
  468. /* NOTE: if we were doing 6Mb OFDM for scans we'd use
  469. * power level:
  470. * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3;
  471. */
  472. if (band == IEEE80211_BAND_5GHZ)
  473. scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
  474. else
  475. scan_ch->tx_gain = ((1 << 5) | (5 << 3));
  476. IWL_DEBUG_SCAN(priv, "Scanning ch=%d prob=0x%X [%s %d]\n",
  477. channel, le32_to_cpu(scan_ch->type),
  478. (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
  479. "ACTIVE" : "PASSIVE",
  480. (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
  481. active_dwell : passive_dwell);
  482. scan_ch++;
  483. added++;
  484. }
  485. IWL_DEBUG_SCAN(priv, "total channels to scan %d\n", added);
  486. return added;
  487. }
  488. /**
  489. * iwl_fill_probe_req - fill in all required fields and IE for probe request
  490. */
  491. static u16 iwl_fill_probe_req(struct ieee80211_mgmt *frame, const u8 *ta,
  492. const u8 *ies, int ie_len, const u8 *ssid,
  493. u8 ssid_len, int left)
  494. {
  495. int len = 0;
  496. u8 *pos = NULL;
  497. /* Make sure there is enough space for the probe request,
  498. * two mandatory IEs and the data */
  499. left -= 24;
  500. if (left < 0)
  501. return 0;
  502. frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
  503. memcpy(frame->da, iwl_bcast_addr, ETH_ALEN);
  504. memcpy(frame->sa, ta, ETH_ALEN);
  505. memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN);
  506. frame->seq_ctrl = 0;
  507. len += 24;
  508. /* ...next IE... */
  509. pos = &frame->u.probe_req.variable[0];
  510. /* fill in our SSID IE */
  511. left -= ssid_len + 2;
  512. if (left < 0)
  513. return 0;
  514. *pos++ = WLAN_EID_SSID;
  515. *pos++ = ssid_len;
  516. if (ssid && ssid_len) {
  517. memcpy(pos, ssid, ssid_len);
  518. pos += ssid_len;
  519. }
  520. len += ssid_len + 2;
  521. if (WARN_ON(left < ie_len))
  522. return len;
  523. if (ies && ie_len) {
  524. memcpy(pos, ies, ie_len);
  525. len += ie_len;
  526. }
  527. return (u16)len;
  528. }
  529. static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
  530. {
  531. struct iwl_host_cmd cmd = {
  532. .id = REPLY_SCAN_CMD,
  533. .len = { sizeof(struct iwl_scan_cmd), },
  534. .flags = CMD_SYNC,
  535. };
  536. struct iwl_scan_cmd *scan;
  537. struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
  538. u32 rate_flags = 0;
  539. u16 cmd_len = 0;
  540. u16 rx_chain = 0;
  541. enum ieee80211_band band;
  542. u8 n_probes = 0;
  543. u8 rx_ant = priv->eeprom_data->valid_rx_ant;
  544. u8 rate;
  545. bool is_active = false;
  546. int chan_mod;
  547. u8 active_chains;
  548. u8 scan_tx_antennas = priv->eeprom_data->valid_tx_ant;
  549. int ret;
  550. int scan_cmd_size = sizeof(struct iwl_scan_cmd) +
  551. MAX_SCAN_CHANNEL * sizeof(struct iwl_scan_channel) +
  552. priv->fw->ucode_capa.max_probe_length;
  553. const u8 *ssid = NULL;
  554. u8 ssid_len = 0;
  555. if (WARN_ON_ONCE(priv->scan_request &&
  556. priv->scan_request->n_channels > MAX_SCAN_CHANNEL))
  557. return -EINVAL;
  558. lockdep_assert_held(&priv->mutex);
  559. if (vif)
  560. ctx = iwl_rxon_ctx_from_vif(vif);
  561. if (!priv->scan_cmd) {
  562. priv->scan_cmd = kmalloc(scan_cmd_size, GFP_KERNEL);
  563. if (!priv->scan_cmd) {
  564. IWL_DEBUG_SCAN(priv,
  565. "fail to allocate memory for scan\n");
  566. return -ENOMEM;
  567. }
  568. }
  569. scan = priv->scan_cmd;
  570. memset(scan, 0, scan_cmd_size);
  571. scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
  572. scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
  573. if (priv->scan_type != IWL_SCAN_ROC &&
  574. iwl_is_any_associated(priv)) {
  575. u16 interval = 0;
  576. u32 extra;
  577. u32 suspend_time = 100;
  578. u32 scan_suspend_time = 100;
  579. IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
  580. switch (priv->scan_type) {
  581. case IWL_SCAN_ROC:
  582. WARN_ON(1);
  583. break;
  584. case IWL_SCAN_RADIO_RESET:
  585. interval = 0;
  586. break;
  587. case IWL_SCAN_NORMAL:
  588. interval = vif->bss_conf.beacon_int;
  589. break;
  590. }
  591. scan->suspend_time = 0;
  592. scan->max_out_time = cpu_to_le32(200 * 1024);
  593. if (!interval)
  594. interval = suspend_time;
  595. extra = (suspend_time / interval) << 22;
  596. scan_suspend_time = (extra |
  597. ((suspend_time % interval) * 1024));
  598. scan->suspend_time = cpu_to_le32(scan_suspend_time);
  599. IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n",
  600. scan_suspend_time, interval);
  601. } else if (priv->scan_type == IWL_SCAN_ROC) {
  602. scan->suspend_time = 0;
  603. scan->max_out_time = 0;
  604. scan->quiet_time = 0;
  605. scan->quiet_plcp_th = 0;
  606. }
  607. switch (priv->scan_type) {
  608. case IWL_SCAN_RADIO_RESET:
  609. IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n");
  610. /*
  611. * Override quiet time as firmware checks that active
  612. * dwell is >= quiet; since we use passive scan it'll
  613. * not actually be used.
  614. */
  615. scan->quiet_time = cpu_to_le16(IWL_RADIO_RESET_DWELL_TIME);
  616. break;
  617. case IWL_SCAN_NORMAL:
  618. if (priv->scan_request->n_ssids) {
  619. int i, p = 0;
  620. IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
  621. /*
  622. * The highest priority SSID is inserted to the
  623. * probe request template.
  624. */
  625. ssid_len = priv->scan_request->ssids[0].ssid_len;
  626. ssid = priv->scan_request->ssids[0].ssid;
  627. /*
  628. * Invert the order of ssids, the firmware will invert
  629. * it back.
  630. */
  631. for (i = priv->scan_request->n_ssids - 1; i >= 1; i--) {
  632. scan->direct_scan[p].id = WLAN_EID_SSID;
  633. scan->direct_scan[p].len =
  634. priv->scan_request->ssids[i].ssid_len;
  635. memcpy(scan->direct_scan[p].ssid,
  636. priv->scan_request->ssids[i].ssid,
  637. priv->scan_request->ssids[i].ssid_len);
  638. n_probes++;
  639. p++;
  640. }
  641. is_active = true;
  642. } else
  643. IWL_DEBUG_SCAN(priv, "Start passive scan.\n");
  644. break;
  645. case IWL_SCAN_ROC:
  646. IWL_DEBUG_SCAN(priv, "Start ROC scan.\n");
  647. break;
  648. }
  649. scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
  650. scan->tx_cmd.sta_id = ctx->bcast_sta_id;
  651. scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
  652. switch (priv->scan_band) {
  653. case IEEE80211_BAND_2GHZ:
  654. scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
  655. chan_mod = le32_to_cpu(
  656. priv->contexts[IWL_RXON_CTX_BSS].active.flags &
  657. RXON_FLG_CHANNEL_MODE_MSK)
  658. >> RXON_FLG_CHANNEL_MODE_POS;
  659. if ((priv->scan_request && priv->scan_request->no_cck) ||
  660. chan_mod == CHANNEL_MODE_PURE_40) {
  661. rate = IWL_RATE_6M_PLCP;
  662. } else {
  663. rate = IWL_RATE_1M_PLCP;
  664. rate_flags = RATE_MCS_CCK_MSK;
  665. }
  666. /*
  667. * Internal scans are passive, so we can indiscriminately set
  668. * the BT ignore flag on 2.4 GHz since it applies to TX only.
  669. */
  670. if (priv->cfg->bt_params &&
  671. priv->cfg->bt_params->advanced_bt_coexist)
  672. scan->tx_cmd.tx_flags |= TX_CMD_FLG_IGNORE_BT;
  673. break;
  674. case IEEE80211_BAND_5GHZ:
  675. rate = IWL_RATE_6M_PLCP;
  676. break;
  677. default:
  678. IWL_WARN(priv, "Invalid scan band\n");
  679. return -EIO;
  680. }
  681. /*
  682. * If active scanning is requested but a certain channel is
  683. * marked passive, we can do active scanning if we detect
  684. * transmissions.
  685. *
  686. * There is an issue with some firmware versions that triggers
  687. * a sysassert on a "good CRC threshold" of zero (== disabled),
  688. * on a radar channel even though this means that we should NOT
  689. * send probes.
  690. *
  691. * The "good CRC threshold" is the number of frames that we
  692. * need to receive during our dwell time on a channel before
  693. * sending out probes -- setting this to a huge value will
  694. * mean we never reach it, but at the same time work around
  695. * the aforementioned issue. Thus use IWL_GOOD_CRC_TH_NEVER
  696. * here instead of IWL_GOOD_CRC_TH_DISABLED.
  697. *
  698. * This was fixed in later versions along with some other
  699. * scan changes, and the threshold behaves as a flag in those
  700. * versions.
  701. */
  702. if (priv->new_scan_threshold_behaviour)
  703. scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT :
  704. IWL_GOOD_CRC_TH_DISABLED;
  705. else
  706. scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT :
  707. IWL_GOOD_CRC_TH_NEVER;
  708. band = priv->scan_band;
  709. if (band == IEEE80211_BAND_2GHZ &&
  710. priv->cfg->bt_params &&
  711. priv->cfg->bt_params->advanced_bt_coexist) {
  712. /* transmit 2.4 GHz probes only on first antenna */
  713. scan_tx_antennas = first_antenna(scan_tx_antennas);
  714. }
  715. priv->scan_tx_ant[band] = iwl_toggle_tx_ant(priv,
  716. priv->scan_tx_ant[band],
  717. scan_tx_antennas);
  718. rate_flags |= iwl_ant_idx_to_flags(priv->scan_tx_ant[band]);
  719. scan->tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags);
  720. /*
  721. * In power save mode while associated use one chain,
  722. * otherwise use all chains
  723. */
  724. if (test_bit(STATUS_POWER_PMI, &priv->status) &&
  725. !(priv->hw->conf.flags & IEEE80211_CONF_IDLE)) {
  726. /* rx_ant has been set to all valid chains previously */
  727. active_chains = rx_ant &
  728. ((u8)(priv->chain_noise_data.active_chains));
  729. if (!active_chains)
  730. active_chains = rx_ant;
  731. IWL_DEBUG_SCAN(priv, "chain_noise_data.active_chains: %u\n",
  732. priv->chain_noise_data.active_chains);
  733. rx_ant = first_antenna(active_chains);
  734. }
  735. if (priv->cfg->bt_params &&
  736. priv->cfg->bt_params->advanced_bt_coexist &&
  737. priv->bt_full_concurrent) {
  738. /* operated as 1x1 in full concurrency mode */
  739. rx_ant = first_antenna(rx_ant);
  740. }
  741. /* MIMO is not used here, but value is required */
  742. rx_chain |=
  743. priv->eeprom_data->valid_rx_ant << RXON_RX_CHAIN_VALID_POS;
  744. rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
  745. rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS;
  746. rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
  747. scan->rx_chain = cpu_to_le16(rx_chain);
  748. switch (priv->scan_type) {
  749. case IWL_SCAN_NORMAL:
  750. cmd_len = iwl_fill_probe_req(
  751. (struct ieee80211_mgmt *)scan->data,
  752. vif->addr,
  753. priv->scan_request->ie,
  754. priv->scan_request->ie_len,
  755. ssid, ssid_len,
  756. scan_cmd_size - sizeof(*scan));
  757. break;
  758. case IWL_SCAN_RADIO_RESET:
  759. case IWL_SCAN_ROC:
  760. /* use bcast addr, will not be transmitted but must be valid */
  761. cmd_len = iwl_fill_probe_req(
  762. (struct ieee80211_mgmt *)scan->data,
  763. iwl_bcast_addr, NULL, 0,
  764. NULL, 0,
  765. scan_cmd_size - sizeof(*scan));
  766. break;
  767. default:
  768. BUG();
  769. }
  770. scan->tx_cmd.len = cpu_to_le16(cmd_len);
  771. scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK |
  772. RXON_FILTER_BCON_AWARE_MSK);
  773. switch (priv->scan_type) {
  774. case IWL_SCAN_RADIO_RESET:
  775. scan->channel_count =
  776. iwl_get_channel_for_reset_scan(priv, vif, band,
  777. (void *)&scan->data[cmd_len]);
  778. break;
  779. case IWL_SCAN_NORMAL:
  780. scan->channel_count =
  781. iwl_get_channels_for_scan(priv, vif, band,
  782. is_active, n_probes,
  783. (void *)&scan->data[cmd_len]);
  784. break;
  785. case IWL_SCAN_ROC: {
  786. struct iwl_scan_channel *scan_ch;
  787. int n_chan, i;
  788. u16 dwell;
  789. dwell = iwl_limit_dwell(priv, priv->hw_roc_duration);
  790. n_chan = DIV_ROUND_UP(priv->hw_roc_duration, dwell);
  791. scan->channel_count = n_chan;
  792. scan_ch = (void *)&scan->data[cmd_len];
  793. for (i = 0; i < n_chan; i++) {
  794. scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
  795. scan_ch->channel =
  796. cpu_to_le16(priv->hw_roc_channel->hw_value);
  797. if (i == n_chan - 1)
  798. dwell = priv->hw_roc_duration - i * dwell;
  799. scan_ch->active_dwell =
  800. scan_ch->passive_dwell = cpu_to_le16(dwell);
  801. /* Set txpower levels to defaults */
  802. scan_ch->dsp_atten = 110;
  803. /* NOTE: if we were doing 6Mb OFDM for scans we'd use
  804. * power level:
  805. * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3;
  806. */
  807. if (priv->hw_roc_channel->band == IEEE80211_BAND_5GHZ)
  808. scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
  809. else
  810. scan_ch->tx_gain = ((1 << 5) | (5 << 3));
  811. scan_ch++;
  812. }
  813. }
  814. break;
  815. }
  816. if (scan->channel_count == 0) {
  817. IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
  818. return -EIO;
  819. }
  820. cmd.len[0] += le16_to_cpu(scan->tx_cmd.len) +
  821. scan->channel_count * sizeof(struct iwl_scan_channel);
  822. cmd.data[0] = scan;
  823. cmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY;
  824. scan->len = cpu_to_le16(cmd.len[0]);
  825. /* set scan bit here for PAN params */
  826. set_bit(STATUS_SCAN_HW, &priv->status);
  827. ret = iwlagn_set_pan_params(priv);
  828. if (ret) {
  829. clear_bit(STATUS_SCAN_HW, &priv->status);
  830. return ret;
  831. }
  832. ret = iwl_dvm_send_cmd(priv, &cmd);
  833. if (ret) {
  834. clear_bit(STATUS_SCAN_HW, &priv->status);
  835. iwlagn_set_pan_params(priv);
  836. }
  837. return ret;
  838. }
  839. void iwl_init_scan_params(struct iwl_priv *priv)
  840. {
  841. u8 ant_idx = fls(priv->eeprom_data->valid_tx_ant) - 1;
  842. if (!priv->scan_tx_ant[IEEE80211_BAND_5GHZ])
  843. priv->scan_tx_ant[IEEE80211_BAND_5GHZ] = ant_idx;
  844. if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ])
  845. priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx;
  846. }
  847. int __must_check iwl_scan_initiate(struct iwl_priv *priv,
  848. struct ieee80211_vif *vif,
  849. enum iwl_scan_type scan_type,
  850. enum ieee80211_band band)
  851. {
  852. int ret;
  853. lockdep_assert_held(&priv->mutex);
  854. cancel_delayed_work(&priv->scan_check);
  855. if (!iwl_is_ready_rf(priv)) {
  856. IWL_WARN(priv, "Request scan called when driver not ready.\n");
  857. return -EIO;
  858. }
  859. if (test_bit(STATUS_SCAN_HW, &priv->status)) {
  860. IWL_DEBUG_SCAN(priv,
  861. "Multiple concurrent scan requests in parallel.\n");
  862. return -EBUSY;
  863. }
  864. if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
  865. IWL_DEBUG_SCAN(priv, "Scan request while abort pending.\n");
  866. return -EBUSY;
  867. }
  868. IWL_DEBUG_SCAN(priv, "Starting %sscan...\n",
  869. scan_type == IWL_SCAN_NORMAL ? "" :
  870. scan_type == IWL_SCAN_ROC ? "remain-on-channel " :
  871. "internal short ");
  872. set_bit(STATUS_SCANNING, &priv->status);
  873. priv->scan_type = scan_type;
  874. priv->scan_start = jiffies;
  875. priv->scan_band = band;
  876. ret = iwlagn_request_scan(priv, vif);
  877. if (ret) {
  878. clear_bit(STATUS_SCANNING, &priv->status);
  879. priv->scan_type = IWL_SCAN_NORMAL;
  880. return ret;
  881. }
  882. queue_delayed_work(priv->workqueue, &priv->scan_check,
  883. IWL_SCAN_CHECK_WATCHDOG);
  884. return 0;
  885. }
  886. /*
  887. * internal short scan, this function should only been called while associated.
  888. * It will reset and tune the radio to prevent possible RF related problem
  889. */
  890. void iwl_internal_short_hw_scan(struct iwl_priv *priv)
  891. {
  892. queue_work(priv->workqueue, &priv->start_internal_scan);
  893. }
  894. static void iwl_bg_start_internal_scan(struct work_struct *work)
  895. {
  896. struct iwl_priv *priv =
  897. container_of(work, struct iwl_priv, start_internal_scan);
  898. IWL_DEBUG_SCAN(priv, "Start internal scan\n");
  899. mutex_lock(&priv->mutex);
  900. if (priv->scan_type == IWL_SCAN_RADIO_RESET) {
  901. IWL_DEBUG_SCAN(priv, "Internal scan already in progress\n");
  902. goto unlock;
  903. }
  904. if (test_bit(STATUS_SCANNING, &priv->status)) {
  905. IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
  906. goto unlock;
  907. }
  908. if (iwl_scan_initiate(priv, NULL, IWL_SCAN_RADIO_RESET, priv->band))
  909. IWL_DEBUG_SCAN(priv, "failed to start internal short scan\n");
  910. unlock:
  911. mutex_unlock(&priv->mutex);
  912. }
  913. static void iwl_bg_scan_check(struct work_struct *data)
  914. {
  915. struct iwl_priv *priv =
  916. container_of(data, struct iwl_priv, scan_check.work);
  917. IWL_DEBUG_SCAN(priv, "Scan check work\n");
  918. /* Since we are here firmware does not finish scan and
  919. * most likely is in bad shape, so we don't bother to
  920. * send abort command, just force scan complete to mac80211 */
  921. mutex_lock(&priv->mutex);
  922. iwl_force_scan_end(priv);
  923. mutex_unlock(&priv->mutex);
  924. }
  925. static void iwl_bg_abort_scan(struct work_struct *work)
  926. {
  927. struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan);
  928. IWL_DEBUG_SCAN(priv, "Abort scan work\n");
  929. /* We keep scan_check work queued in case when firmware will not
  930. * report back scan completed notification */
  931. mutex_lock(&priv->mutex);
  932. iwl_scan_cancel_timeout(priv, 200);
  933. mutex_unlock(&priv->mutex);
  934. }
  935. static void iwl_bg_scan_completed(struct work_struct *work)
  936. {
  937. struct iwl_priv *priv =
  938. container_of(work, struct iwl_priv, scan_completed);
  939. mutex_lock(&priv->mutex);
  940. iwl_process_scan_complete(priv);
  941. mutex_unlock(&priv->mutex);
  942. }
  943. void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
  944. {
  945. INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed);
  946. INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan);
  947. INIT_WORK(&priv->start_internal_scan, iwl_bg_start_internal_scan);
  948. INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check);
  949. }
  950. void iwl_cancel_scan_deferred_work(struct iwl_priv *priv)
  951. {
  952. cancel_work_sync(&priv->start_internal_scan);
  953. cancel_work_sync(&priv->abort_scan);
  954. cancel_work_sync(&priv->scan_completed);
  955. if (cancel_delayed_work_sync(&priv->scan_check)) {
  956. mutex_lock(&priv->mutex);
  957. iwl_force_scan_end(priv);
  958. mutex_unlock(&priv->mutex);
  959. }
  960. }
  961. void iwl_scan_roc_expired(struct iwl_priv *priv)
  962. {
  963. /*
  964. * The status bit should be set here, to prevent a race
  965. * where the atomic_read returns 1, but before the execution continues
  966. * iwl_scan_offchannel_skb_status() checks if the status bit is set
  967. */
  968. set_bit(STATUS_SCAN_ROC_EXPIRED, &priv->status);
  969. if (atomic_read(&priv->num_aux_in_flight) == 0) {
  970. ieee80211_remain_on_channel_expired(priv->hw);
  971. priv->hw_roc_channel = NULL;
  972. schedule_delayed_work(&priv->hw_roc_disable_work,
  973. 10 * HZ);
  974. clear_bit(STATUS_SCAN_ROC_EXPIRED, &priv->status);
  975. } else {
  976. IWL_DEBUG_SCAN(priv, "ROC done with %d frames in aux\n",
  977. atomic_read(&priv->num_aux_in_flight));
  978. }
  979. }
  980. void iwl_scan_offchannel_skb(struct iwl_priv *priv)
  981. {
  982. WARN_ON(!priv->hw_roc_start_notified);
  983. atomic_inc(&priv->num_aux_in_flight);
  984. }
  985. void iwl_scan_offchannel_skb_status(struct iwl_priv *priv)
  986. {
  987. if (atomic_dec_return(&priv->num_aux_in_flight) == 0 &&
  988. test_bit(STATUS_SCAN_ROC_EXPIRED, &priv->status)) {
  989. IWL_DEBUG_SCAN(priv, "0 aux frames. Calling ROC expired\n");
  990. iwl_scan_roc_expired(priv);
  991. }
  992. }