scan.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /*
  2. * This file is part of wl1271
  3. *
  4. * Copyright (C) 2009-2010 Nokia Corporation
  5. *
  6. * Contact: Luciano Coelho <luciano.coelho@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. */
  23. #include <linux/ieee80211.h>
  24. #include "wl12xx.h"
  25. #include "cmd.h"
  26. #include "scan.h"
  27. #include "acx.h"
  28. #include "ps.h"
  29. void wl1271_scan_complete_work(struct work_struct *work)
  30. {
  31. struct delayed_work *dwork;
  32. struct wl1271 *wl;
  33. int ret;
  34. bool is_sta, is_ibss;
  35. dwork = container_of(work, struct delayed_work, work);
  36. wl = container_of(dwork, struct wl1271, scan_complete_work);
  37. wl1271_debug(DEBUG_SCAN, "Scanning complete");
  38. mutex_lock(&wl->mutex);
  39. if (wl->state == WL1271_STATE_OFF)
  40. goto out;
  41. if (wl->scan.state == WL1271_SCAN_STATE_IDLE)
  42. goto out;
  43. wl->scan.state = WL1271_SCAN_STATE_IDLE;
  44. memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));
  45. wl->scan.req = NULL;
  46. ret = wl1271_ps_elp_wakeup(wl);
  47. if (ret < 0)
  48. goto out;
  49. if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) {
  50. /* restore hardware connection monitoring template */
  51. wl1271_cmd_build_ap_probe_req(wl, wl->probereq);
  52. }
  53. /* return to ROC if needed */
  54. is_sta = (wl->bss_type == BSS_TYPE_STA_BSS);
  55. is_ibss = (wl->bss_type == BSS_TYPE_IBSS);
  56. if ((is_sta && !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) ||
  57. (is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))) {
  58. /* restore remain on channel */
  59. wl12xx_cmd_role_start_dev(wl);
  60. wl12xx_roc(wl, wl->dev_role_id);
  61. }
  62. wl1271_ps_elp_sleep(wl);
  63. if (wl->scan.failed) {
  64. wl1271_info("Scan completed due to error.");
  65. wl12xx_queue_recovery_work(wl);
  66. }
  67. ieee80211_scan_completed(wl->hw, false);
  68. out:
  69. mutex_unlock(&wl->mutex);
  70. }
  71. static int wl1271_get_scan_channels(struct wl1271 *wl,
  72. struct cfg80211_scan_request *req,
  73. struct basic_scan_channel_params *channels,
  74. enum ieee80211_band band, bool passive)
  75. {
  76. struct conf_scan_settings *c = &wl->conf.scan;
  77. int i, j;
  78. u32 flags;
  79. for (i = 0, j = 0;
  80. i < req->n_channels && j < WL1271_SCAN_MAX_CHANNELS;
  81. i++) {
  82. flags = req->channels[i]->flags;
  83. if (!test_bit(i, wl->scan.scanned_ch) &&
  84. !(flags & IEEE80211_CHAN_DISABLED) &&
  85. ((!!(flags & IEEE80211_CHAN_PASSIVE_SCAN)) == passive) &&
  86. (req->channels[i]->band == band)) {
  87. wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
  88. req->channels[i]->band,
  89. req->channels[i]->center_freq);
  90. wl1271_debug(DEBUG_SCAN, "hw_value %d, flags %X",
  91. req->channels[i]->hw_value,
  92. req->channels[i]->flags);
  93. wl1271_debug(DEBUG_SCAN,
  94. "max_antenna_gain %d, max_power %d",
  95. req->channels[i]->max_antenna_gain,
  96. req->channels[i]->max_power);
  97. wl1271_debug(DEBUG_SCAN, "beacon_found %d",
  98. req->channels[i]->beacon_found);
  99. if (!passive) {
  100. channels[j].min_duration =
  101. cpu_to_le32(c->min_dwell_time_active);
  102. channels[j].max_duration =
  103. cpu_to_le32(c->max_dwell_time_active);
  104. } else {
  105. channels[j].min_duration =
  106. cpu_to_le32(c->min_dwell_time_passive);
  107. channels[j].max_duration =
  108. cpu_to_le32(c->max_dwell_time_passive);
  109. }
  110. channels[j].early_termination = 0;
  111. channels[j].tx_power_att = req->channels[i]->max_power;
  112. channels[j].channel = req->channels[i]->hw_value;
  113. memset(&channels[j].bssid_lsb, 0xff, 4);
  114. memset(&channels[j].bssid_msb, 0xff, 2);
  115. /* Mark the channels we already used */
  116. set_bit(i, wl->scan.scanned_ch);
  117. j++;
  118. }
  119. }
  120. return j;
  121. }
  122. #define WL1271_NOTHING_TO_SCAN 1
  123. static int wl1271_scan_send(struct wl1271 *wl, enum ieee80211_band band,
  124. bool passive, u32 basic_rate)
  125. {
  126. struct wl1271_cmd_scan *cmd;
  127. struct wl1271_cmd_trigger_scan_to *trigger;
  128. int ret;
  129. u16 scan_options = 0;
  130. cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
  131. trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
  132. if (!cmd || !trigger) {
  133. ret = -ENOMEM;
  134. goto out;
  135. }
  136. /* We always use high priority scans */
  137. scan_options = WL1271_SCAN_OPT_PRIORITY_HIGH;
  138. /* No SSIDs means that we have a forced passive scan */
  139. if (passive || wl->scan.req->n_ssids == 0)
  140. scan_options |= WL1271_SCAN_OPT_PASSIVE;
  141. if (WARN_ON(wl->role_id == WL12XX_INVALID_ROLE_ID)) {
  142. ret = -EINVAL;
  143. goto out;
  144. }
  145. cmd->params.role_id = wl->role_id;
  146. cmd->params.scan_options = cpu_to_le16(scan_options);
  147. cmd->params.n_ch = wl1271_get_scan_channels(wl, wl->scan.req,
  148. cmd->channels,
  149. band, passive);
  150. if (cmd->params.n_ch == 0) {
  151. ret = WL1271_NOTHING_TO_SCAN;
  152. goto out;
  153. }
  154. cmd->params.tx_rate = cpu_to_le32(basic_rate);
  155. cmd->params.n_probe_reqs = wl->conf.scan.num_probe_reqs;
  156. cmd->params.tx_rate = cpu_to_le32(basic_rate);
  157. cmd->params.tid_trigger = 0;
  158. cmd->params.scan_tag = WL1271_SCAN_DEFAULT_TAG;
  159. if (band == IEEE80211_BAND_2GHZ)
  160. cmd->params.band = WL1271_SCAN_BAND_2_4_GHZ;
  161. else
  162. cmd->params.band = WL1271_SCAN_BAND_5_GHZ;
  163. if (wl->scan.ssid_len && wl->scan.ssid) {
  164. cmd->params.ssid_len = wl->scan.ssid_len;
  165. memcpy(cmd->params.ssid, wl->scan.ssid, wl->scan.ssid_len);
  166. }
  167. memcpy(cmd->addr, wl->mac_addr, ETH_ALEN);
  168. ret = wl1271_cmd_build_probe_req(wl, wl->scan.ssid, wl->scan.ssid_len,
  169. wl->scan.req->ie, wl->scan.req->ie_len,
  170. band);
  171. if (ret < 0) {
  172. wl1271_error("PROBE request template failed");
  173. goto out;
  174. }
  175. /* disable the timeout */
  176. trigger->timeout = 0;
  177. ret = wl1271_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger,
  178. sizeof(*trigger), 0);
  179. if (ret < 0) {
  180. wl1271_error("trigger scan to failed for hw scan");
  181. goto out;
  182. }
  183. wl1271_dump(DEBUG_SCAN, "SCAN: ", cmd, sizeof(*cmd));
  184. ret = wl1271_cmd_send(wl, CMD_SCAN, cmd, sizeof(*cmd), 0);
  185. if (ret < 0) {
  186. wl1271_error("SCAN failed");
  187. goto out;
  188. }
  189. out:
  190. kfree(cmd);
  191. kfree(trigger);
  192. return ret;
  193. }
  194. void wl1271_scan_stm(struct wl1271 *wl)
  195. {
  196. int ret = 0;
  197. switch (wl->scan.state) {
  198. case WL1271_SCAN_STATE_IDLE:
  199. break;
  200. case WL1271_SCAN_STATE_2GHZ_ACTIVE:
  201. ret = wl1271_scan_send(wl, IEEE80211_BAND_2GHZ, false,
  202. wl->conf.tx.basic_rate);
  203. if (ret == WL1271_NOTHING_TO_SCAN) {
  204. wl->scan.state = WL1271_SCAN_STATE_2GHZ_PASSIVE;
  205. wl1271_scan_stm(wl);
  206. }
  207. break;
  208. case WL1271_SCAN_STATE_2GHZ_PASSIVE:
  209. ret = wl1271_scan_send(wl, IEEE80211_BAND_2GHZ, true,
  210. wl->conf.tx.basic_rate);
  211. if (ret == WL1271_NOTHING_TO_SCAN) {
  212. if (wl->enable_11a)
  213. wl->scan.state = WL1271_SCAN_STATE_5GHZ_ACTIVE;
  214. else
  215. wl->scan.state = WL1271_SCAN_STATE_DONE;
  216. wl1271_scan_stm(wl);
  217. }
  218. break;
  219. case WL1271_SCAN_STATE_5GHZ_ACTIVE:
  220. ret = wl1271_scan_send(wl, IEEE80211_BAND_5GHZ, false,
  221. wl->conf.tx.basic_rate_5);
  222. if (ret == WL1271_NOTHING_TO_SCAN) {
  223. wl->scan.state = WL1271_SCAN_STATE_5GHZ_PASSIVE;
  224. wl1271_scan_stm(wl);
  225. }
  226. break;
  227. case WL1271_SCAN_STATE_5GHZ_PASSIVE:
  228. ret = wl1271_scan_send(wl, IEEE80211_BAND_5GHZ, true,
  229. wl->conf.tx.basic_rate_5);
  230. if (ret == WL1271_NOTHING_TO_SCAN) {
  231. wl->scan.state = WL1271_SCAN_STATE_DONE;
  232. wl1271_scan_stm(wl);
  233. }
  234. break;
  235. case WL1271_SCAN_STATE_DONE:
  236. wl->scan.failed = false;
  237. cancel_delayed_work(&wl->scan_complete_work);
  238. ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work,
  239. msecs_to_jiffies(0));
  240. break;
  241. default:
  242. wl1271_error("invalid scan state");
  243. break;
  244. }
  245. if (ret < 0) {
  246. cancel_delayed_work(&wl->scan_complete_work);
  247. ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work,
  248. msecs_to_jiffies(0));
  249. }
  250. }
  251. int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
  252. struct cfg80211_scan_request *req)
  253. {
  254. /*
  255. * cfg80211 should guarantee that we don't get more channels
  256. * than what we have registered.
  257. */
  258. BUG_ON(req->n_channels > WL1271_MAX_CHANNELS);
  259. if (wl->scan.state != WL1271_SCAN_STATE_IDLE)
  260. return -EBUSY;
  261. wl->scan.state = WL1271_SCAN_STATE_2GHZ_ACTIVE;
  262. if (ssid_len && ssid) {
  263. wl->scan.ssid_len = ssid_len;
  264. memcpy(wl->scan.ssid, ssid, ssid_len);
  265. } else {
  266. wl->scan.ssid_len = 0;
  267. }
  268. wl->scan.req = req;
  269. memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));
  270. /* we assume failure so that timeout scenarios are handled correctly */
  271. wl->scan.failed = true;
  272. ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work,
  273. msecs_to_jiffies(WL1271_SCAN_TIMEOUT));
  274. wl1271_scan_stm(wl);
  275. return 0;
  276. }
  277. int wl1271_scan_stop(struct wl1271 *wl)
  278. {
  279. struct wl1271_cmd_header *cmd = NULL;
  280. int ret = 0;
  281. if (WARN_ON(wl->scan.state == WL1271_SCAN_STATE_IDLE))
  282. return -EINVAL;
  283. wl1271_debug(DEBUG_CMD, "cmd scan stop");
  284. cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
  285. if (!cmd) {
  286. ret = -ENOMEM;
  287. goto out;
  288. }
  289. ret = wl1271_cmd_send(wl, CMD_STOP_SCAN, cmd,
  290. sizeof(*cmd), 0);
  291. if (ret < 0) {
  292. wl1271_error("cmd stop_scan failed");
  293. goto out;
  294. }
  295. out:
  296. kfree(cmd);
  297. return ret;
  298. }
  299. static int
  300. wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
  301. struct cfg80211_sched_scan_request *req,
  302. struct conn_scan_ch_params *channels,
  303. u32 band, bool radar, bool passive,
  304. int start, int max_channels)
  305. {
  306. struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
  307. int i, j;
  308. u32 flags;
  309. bool force_passive = !req->n_ssids;
  310. for (i = 0, j = start;
  311. i < req->n_channels && j < max_channels;
  312. i++) {
  313. flags = req->channels[i]->flags;
  314. if (force_passive)
  315. flags |= IEEE80211_CHAN_PASSIVE_SCAN;
  316. if ((req->channels[i]->band == band) &&
  317. !(flags & IEEE80211_CHAN_DISABLED) &&
  318. (!!(flags & IEEE80211_CHAN_RADAR) == radar) &&
  319. /* if radar is set, we ignore the passive flag */
  320. (radar ||
  321. !!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) {
  322. wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
  323. req->channels[i]->band,
  324. req->channels[i]->center_freq);
  325. wl1271_debug(DEBUG_SCAN, "hw_value %d, flags %X",
  326. req->channels[i]->hw_value,
  327. req->channels[i]->flags);
  328. wl1271_debug(DEBUG_SCAN, "max_power %d",
  329. req->channels[i]->max_power);
  330. if (flags & IEEE80211_CHAN_RADAR) {
  331. channels[j].flags |= SCAN_CHANNEL_FLAGS_DFS;
  332. channels[j].passive_duration =
  333. cpu_to_le16(c->dwell_time_dfs);
  334. }
  335. else if (flags & IEEE80211_CHAN_PASSIVE_SCAN) {
  336. channels[j].passive_duration =
  337. cpu_to_le16(c->dwell_time_passive);
  338. } else {
  339. channels[j].min_duration =
  340. cpu_to_le16(c->min_dwell_time_active);
  341. channels[j].max_duration =
  342. cpu_to_le16(c->max_dwell_time_active);
  343. }
  344. channels[j].tx_power_att = req->channels[i]->max_power;
  345. channels[j].channel = req->channels[i]->hw_value;
  346. j++;
  347. }
  348. }
  349. return j - start;
  350. }
  351. static bool
  352. wl1271_scan_sched_scan_channels(struct wl1271 *wl,
  353. struct cfg80211_sched_scan_request *req,
  354. struct wl1271_cmd_sched_scan_config *cfg)
  355. {
  356. cfg->passive[0] =
  357. wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2,
  358. IEEE80211_BAND_2GHZ,
  359. false, true, 0,
  360. MAX_CHANNELS_2GHZ);
  361. cfg->active[0] =
  362. wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2,
  363. IEEE80211_BAND_2GHZ,
  364. false, false,
  365. cfg->passive[0],
  366. MAX_CHANNELS_2GHZ);
  367. cfg->passive[1] =
  368. wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
  369. IEEE80211_BAND_5GHZ,
  370. false, true, 0,
  371. MAX_CHANNELS_5GHZ);
  372. cfg->dfs =
  373. wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
  374. IEEE80211_BAND_5GHZ,
  375. true, true,
  376. cfg->passive[1],
  377. MAX_CHANNELS_5GHZ);
  378. cfg->active[1] =
  379. wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
  380. IEEE80211_BAND_5GHZ,
  381. false, false,
  382. cfg->passive[1] + cfg->dfs,
  383. MAX_CHANNELS_5GHZ);
  384. /* 802.11j channels are not supported yet */
  385. cfg->passive[2] = 0;
  386. cfg->active[2] = 0;
  387. wl1271_debug(DEBUG_SCAN, " 2.4GHz: active %d passive %d",
  388. cfg->active[0], cfg->passive[0]);
  389. wl1271_debug(DEBUG_SCAN, " 5GHz: active %d passive %d",
  390. cfg->active[1], cfg->passive[1]);
  391. wl1271_debug(DEBUG_SCAN, " DFS: %d", cfg->dfs);
  392. return cfg->passive[0] || cfg->active[0] ||
  393. cfg->passive[1] || cfg->active[1] || cfg->dfs ||
  394. cfg->passive[2] || cfg->active[2];
  395. }
  396. int wl1271_scan_sched_scan_config(struct wl1271 *wl,
  397. struct cfg80211_sched_scan_request *req,
  398. struct ieee80211_sched_scan_ies *ies)
  399. {
  400. struct wl1271_cmd_sched_scan_config *cfg = NULL;
  401. struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
  402. int i, ret;
  403. bool force_passive = !req->n_ssids;
  404. wl1271_debug(DEBUG_CMD, "cmd sched_scan scan config");
  405. cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
  406. if (!cfg)
  407. return -ENOMEM;
  408. cfg->rssi_threshold = c->rssi_threshold;
  409. cfg->snr_threshold = c->snr_threshold;
  410. cfg->n_probe_reqs = c->num_probe_reqs;
  411. /* cycles set to 0 it means infinite (until manually stopped) */
  412. cfg->cycles = 0;
  413. /* report APs when at least 1 is found */
  414. cfg->report_after = 1;
  415. /* don't stop scanning automatically when something is found */
  416. cfg->terminate = 0;
  417. cfg->tag = WL1271_SCAN_DEFAULT_TAG;
  418. /* don't filter on BSS type */
  419. cfg->bss_type = SCAN_BSS_TYPE_ANY;
  420. /* currently NL80211 supports only a single interval */
  421. for (i = 0; i < SCAN_MAX_CYCLE_INTERVALS; i++)
  422. cfg->intervals[i] = cpu_to_le32(req->interval);
  423. if (!force_passive && req->ssids[0].ssid_len && req->ssids[0].ssid) {
  424. cfg->filter_type = SCAN_SSID_FILTER_SPECIFIC;
  425. cfg->ssid_len = req->ssids[0].ssid_len;
  426. memcpy(cfg->ssid, req->ssids[0].ssid,
  427. req->ssids[0].ssid_len);
  428. } else {
  429. cfg->filter_type = SCAN_SSID_FILTER_ANY;
  430. cfg->ssid_len = 0;
  431. }
  432. if (!wl1271_scan_sched_scan_channels(wl, req, cfg)) {
  433. wl1271_error("scan channel list is empty");
  434. ret = -EINVAL;
  435. goto out;
  436. }
  437. if (!force_passive && cfg->active[0]) {
  438. ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid,
  439. req->ssids[0].ssid_len,
  440. ies->ie[IEEE80211_BAND_2GHZ],
  441. ies->len[IEEE80211_BAND_2GHZ],
  442. IEEE80211_BAND_2GHZ);
  443. if (ret < 0) {
  444. wl1271_error("2.4GHz PROBE request template failed");
  445. goto out;
  446. }
  447. }
  448. if (!force_passive && cfg->active[1]) {
  449. ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid,
  450. req->ssids[0].ssid_len,
  451. ies->ie[IEEE80211_BAND_5GHZ],
  452. ies->len[IEEE80211_BAND_5GHZ],
  453. IEEE80211_BAND_5GHZ);
  454. if (ret < 0) {
  455. wl1271_error("5GHz PROBE request template failed");
  456. goto out;
  457. }
  458. }
  459. wl1271_dump(DEBUG_SCAN, "SCAN_CFG: ", cfg, sizeof(*cfg));
  460. ret = wl1271_cmd_send(wl, CMD_CONNECTION_SCAN_CFG, cfg,
  461. sizeof(*cfg), 0);
  462. if (ret < 0) {
  463. wl1271_error("SCAN configuration failed");
  464. goto out;
  465. }
  466. out:
  467. kfree(cfg);
  468. return ret;
  469. }
  470. int wl1271_scan_sched_scan_start(struct wl1271 *wl)
  471. {
  472. struct wl1271_cmd_sched_scan_start *start;
  473. int ret = 0;
  474. wl1271_debug(DEBUG_CMD, "cmd periodic scan start");
  475. if (wl->bss_type != BSS_TYPE_STA_BSS)
  476. return -EOPNOTSUPP;
  477. if (!test_bit(WL1271_FLAG_IDLE, &wl->flags))
  478. return -EBUSY;
  479. start = kzalloc(sizeof(*start), GFP_KERNEL);
  480. if (!start)
  481. return -ENOMEM;
  482. start->tag = WL1271_SCAN_DEFAULT_TAG;
  483. ret = wl1271_cmd_send(wl, CMD_START_PERIODIC_SCAN, start,
  484. sizeof(*start), 0);
  485. if (ret < 0) {
  486. wl1271_error("failed to send scan start command");
  487. goto out_free;
  488. }
  489. out_free:
  490. kfree(start);
  491. return ret;
  492. }
  493. void wl1271_scan_sched_scan_results(struct wl1271 *wl)
  494. {
  495. wl1271_debug(DEBUG_SCAN, "got periodic scan results");
  496. ieee80211_sched_scan_results(wl->hw);
  497. }
  498. void wl1271_scan_sched_scan_stop(struct wl1271 *wl)
  499. {
  500. struct wl1271_cmd_sched_scan_stop *stop;
  501. int ret = 0;
  502. wl1271_debug(DEBUG_CMD, "cmd periodic scan stop");
  503. /* FIXME: what to do if alloc'ing to stop fails? */
  504. stop = kzalloc(sizeof(*stop), GFP_KERNEL);
  505. if (!stop) {
  506. wl1271_error("failed to alloc memory to send sched scan stop");
  507. return;
  508. }
  509. stop->tag = WL1271_SCAN_DEFAULT_TAG;
  510. ret = wl1271_cmd_send(wl, CMD_STOP_PERIODIC_SCAN, stop,
  511. sizeof(*stop), 0);
  512. if (ret < 0) {
  513. wl1271_error("failed to send sched scan stop command");
  514. goto out_free;
  515. }
  516. wl->sched_scanning = false;
  517. out_free:
  518. kfree(stop);
  519. }