time-event.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. /******************************************************************************
  2. *
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * GPL LICENSE SUMMARY
  7. *
  8. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  22. * USA
  23. *
  24. * The full GNU General Public License is included in this distribution
  25. * in the file called COPYING.
  26. *
  27. * Contact Information:
  28. * Intel Linux Wireless <ilw@linux.intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. *
  40. * * Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * * Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in
  44. * the documentation and/or other materials provided with the
  45. * distribution.
  46. * * Neither the name Intel Corporation nor the names of its
  47. * contributors may be used to endorse or promote products derived
  48. * from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  54. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  55. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  56. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  57. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  58. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  59. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  60. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61. *
  62. *****************************************************************************/
  63. #include <linux/jiffies.h>
  64. #include <net/mac80211.h>
  65. #include "iwl-notif-wait.h"
  66. #include "iwl-trans.h"
  67. #include "fw-api.h"
  68. #include "time-event.h"
  69. #include "mvm.h"
  70. #include "iwl-io.h"
  71. #include "iwl-prph.h"
  72. /* A TimeUnit is 1024 microsecond */
  73. #define MSEC_TO_TU(_msec) (_msec*1000/1024)
  74. /*
  75. * For the high priority TE use a time event type that has similar priority to
  76. * the FW's action scan priority.
  77. */
  78. #define IWL_MVM_ROC_TE_TYPE_NORMAL TE_P2P_DEVICE_DISCOVERABLE
  79. #define IWL_MVM_ROC_TE_TYPE_MGMT_TX TE_P2P_CLIENT_ASSOC
  80. void iwl_mvm_te_clear_data(struct iwl_mvm *mvm,
  81. struct iwl_mvm_time_event_data *te_data)
  82. {
  83. lockdep_assert_held(&mvm->time_event_lock);
  84. if (te_data->id == TE_MAX)
  85. return;
  86. list_del(&te_data->list);
  87. te_data->running = false;
  88. te_data->uid = 0;
  89. te_data->id = TE_MAX;
  90. te_data->vif = NULL;
  91. }
  92. void iwl_mvm_roc_done_wk(struct work_struct *wk)
  93. {
  94. struct iwl_mvm *mvm = container_of(wk, struct iwl_mvm, roc_done_wk);
  95. synchronize_net();
  96. /*
  97. * Flush the offchannel queue -- this is called when the time
  98. * event finishes or is cancelled, so that frames queued for it
  99. * won't get stuck on the queue and be transmitted in the next
  100. * time event.
  101. * We have to send the command asynchronously since this cannot
  102. * be under the mutex for locking reasons, but that's not an
  103. * issue as it will have to complete before the next command is
  104. * executed, and a new time event means a new command.
  105. */
  106. iwl_mvm_flush_tx_path(mvm, BIT(IWL_MVM_OFFCHANNEL_QUEUE), false);
  107. }
  108. static void iwl_mvm_roc_finished(struct iwl_mvm *mvm)
  109. {
  110. /*
  111. * First, clear the ROC_RUNNING status bit. This will cause the TX
  112. * path to drop offchannel transmissions. That would also be done
  113. * by mac80211, but it is racy, in particular in the case that the
  114. * time event actually completed in the firmware (which is handled
  115. * in iwl_mvm_te_handle_notif).
  116. */
  117. clear_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
  118. iwl_mvm_unref(mvm, IWL_MVM_REF_ROC);
  119. /*
  120. * Of course, our status bit is just as racy as mac80211, so in
  121. * addition, fire off the work struct which will drop all frames
  122. * from the hardware queues that made it through the race. First
  123. * it will of course synchronize the TX path to make sure that
  124. * any *new* TX will be rejected.
  125. */
  126. schedule_work(&mvm->roc_done_wk);
  127. }
  128. static bool iwl_mvm_te_check_disconnect(struct iwl_mvm *mvm,
  129. struct ieee80211_vif *vif,
  130. const char *errmsg)
  131. {
  132. if (vif->type != NL80211_IFTYPE_STATION)
  133. return false;
  134. if (vif->bss_conf.assoc && vif->bss_conf.dtim_period)
  135. return false;
  136. if (errmsg)
  137. IWL_ERR(mvm, "%s\n", errmsg);
  138. ieee80211_connection_loss(vif);
  139. return true;
  140. }
  141. /*
  142. * Handles a FW notification for an event that is known to the driver.
  143. *
  144. * @mvm: the mvm component
  145. * @te_data: the time event data
  146. * @notif: the notification data corresponding the time event data.
  147. */
  148. static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm,
  149. struct iwl_mvm_time_event_data *te_data,
  150. struct iwl_time_event_notif *notif)
  151. {
  152. lockdep_assert_held(&mvm->time_event_lock);
  153. IWL_DEBUG_TE(mvm, "Handle time event notif - UID = 0x%x action %d\n",
  154. le32_to_cpu(notif->unique_id),
  155. le32_to_cpu(notif->action));
  156. /*
  157. * The FW sends the start/end time event notifications even for events
  158. * that it fails to schedule. This is indicated in the status field of
  159. * the notification. This happens in cases that the scheduler cannot
  160. * find a schedule that can handle the event (for example requesting a
  161. * P2P Device discoveribility, while there are other higher priority
  162. * events in the system).
  163. */
  164. if (!le32_to_cpu(notif->status)) {
  165. bool start = le32_to_cpu(notif->action) &
  166. TE_V2_NOTIF_HOST_EVENT_START;
  167. IWL_WARN(mvm, "Time Event %s notification failure\n",
  168. start ? "start" : "end");
  169. if (iwl_mvm_te_check_disconnect(mvm, te_data->vif, NULL)) {
  170. iwl_mvm_te_clear_data(mvm, te_data);
  171. return;
  172. }
  173. }
  174. if (le32_to_cpu(notif->action) & TE_V2_NOTIF_HOST_EVENT_END) {
  175. IWL_DEBUG_TE(mvm,
  176. "TE ended - current time %lu, estimated end %lu\n",
  177. jiffies, te_data->end_jiffies);
  178. if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) {
  179. ieee80211_remain_on_channel_expired(mvm->hw);
  180. iwl_mvm_roc_finished(mvm);
  181. }
  182. /*
  183. * By now, we should have finished association
  184. * and know the dtim period.
  185. */
  186. iwl_mvm_te_check_disconnect(mvm, te_data->vif,
  187. "No association and the time event is over already...");
  188. iwl_mvm_te_clear_data(mvm, te_data);
  189. } else if (le32_to_cpu(notif->action) & TE_V2_NOTIF_HOST_EVENT_START) {
  190. te_data->running = true;
  191. te_data->end_jiffies = TU_TO_EXP_TIME(te_data->duration);
  192. if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) {
  193. set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
  194. iwl_mvm_ref(mvm, IWL_MVM_REF_ROC);
  195. ieee80211_ready_on_channel(mvm->hw);
  196. }
  197. } else {
  198. IWL_WARN(mvm, "Got TE with unknown action\n");
  199. }
  200. }
  201. /*
  202. * The Rx handler for time event notifications
  203. */
  204. int iwl_mvm_rx_time_event_notif(struct iwl_mvm *mvm,
  205. struct iwl_rx_cmd_buffer *rxb,
  206. struct iwl_device_cmd *cmd)
  207. {
  208. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  209. struct iwl_time_event_notif *notif = (void *)pkt->data;
  210. struct iwl_mvm_time_event_data *te_data, *tmp;
  211. IWL_DEBUG_TE(mvm, "Time event notification - UID = 0x%x action %d\n",
  212. le32_to_cpu(notif->unique_id),
  213. le32_to_cpu(notif->action));
  214. spin_lock_bh(&mvm->time_event_lock);
  215. list_for_each_entry_safe(te_data, tmp, &mvm->time_event_list, list) {
  216. if (le32_to_cpu(notif->unique_id) == te_data->uid)
  217. iwl_mvm_te_handle_notif(mvm, te_data, notif);
  218. }
  219. spin_unlock_bh(&mvm->time_event_lock);
  220. return 0;
  221. }
  222. static bool iwl_mvm_time_event_response(struct iwl_notif_wait_data *notif_wait,
  223. struct iwl_rx_packet *pkt, void *data)
  224. {
  225. struct iwl_mvm *mvm =
  226. container_of(notif_wait, struct iwl_mvm, notif_wait);
  227. struct iwl_mvm_time_event_data *te_data = data;
  228. struct iwl_time_event_resp *resp;
  229. int resp_len = iwl_rx_packet_payload_len(pkt);
  230. if (WARN_ON(pkt->hdr.cmd != TIME_EVENT_CMD))
  231. return true;
  232. if (WARN_ON_ONCE(resp_len != sizeof(*resp))) {
  233. IWL_ERR(mvm, "Invalid TIME_EVENT_CMD response\n");
  234. return true;
  235. }
  236. resp = (void *)pkt->data;
  237. /* we should never get a response to another TIME_EVENT_CMD here */
  238. if (WARN_ON_ONCE(le32_to_cpu(resp->id) != te_data->id))
  239. return false;
  240. te_data->uid = le32_to_cpu(resp->unique_id);
  241. IWL_DEBUG_TE(mvm, "TIME_EVENT_CMD response - UID = 0x%x\n",
  242. te_data->uid);
  243. return true;
  244. }
  245. static int iwl_mvm_time_event_send_add(struct iwl_mvm *mvm,
  246. struct ieee80211_vif *vif,
  247. struct iwl_mvm_time_event_data *te_data,
  248. struct iwl_time_event_cmd *te_cmd)
  249. {
  250. static const u8 time_event_response[] = { TIME_EVENT_CMD };
  251. struct iwl_notification_wait wait_time_event;
  252. int ret;
  253. lockdep_assert_held(&mvm->mutex);
  254. IWL_DEBUG_TE(mvm, "Add new TE, duration %d TU\n",
  255. le32_to_cpu(te_cmd->duration));
  256. spin_lock_bh(&mvm->time_event_lock);
  257. if (WARN_ON(te_data->id != TE_MAX)) {
  258. spin_unlock_bh(&mvm->time_event_lock);
  259. return -EIO;
  260. }
  261. te_data->vif = vif;
  262. te_data->duration = le32_to_cpu(te_cmd->duration);
  263. te_data->id = le32_to_cpu(te_cmd->id);
  264. list_add_tail(&te_data->list, &mvm->time_event_list);
  265. spin_unlock_bh(&mvm->time_event_lock);
  266. /*
  267. * Use a notification wait, which really just processes the
  268. * command response and doesn't wait for anything, in order
  269. * to be able to process the response and get the UID inside
  270. * the RX path. Using CMD_WANT_SKB doesn't work because it
  271. * stores the buffer and then wakes up this thread, by which
  272. * time another notification (that the time event started)
  273. * might already be processed unsuccessfully.
  274. */
  275. iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event,
  276. time_event_response,
  277. ARRAY_SIZE(time_event_response),
  278. iwl_mvm_time_event_response, te_data);
  279. ret = iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, 0,
  280. sizeof(*te_cmd), te_cmd);
  281. if (ret) {
  282. IWL_ERR(mvm, "Couldn't send TIME_EVENT_CMD: %d\n", ret);
  283. iwl_remove_notification(&mvm->notif_wait, &wait_time_event);
  284. goto out_clear_te;
  285. }
  286. /* No need to wait for anything, so just pass 1 (0 isn't valid) */
  287. ret = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1);
  288. /* should never fail */
  289. WARN_ON_ONCE(ret);
  290. if (ret) {
  291. out_clear_te:
  292. spin_lock_bh(&mvm->time_event_lock);
  293. iwl_mvm_te_clear_data(mvm, te_data);
  294. spin_unlock_bh(&mvm->time_event_lock);
  295. }
  296. return ret;
  297. }
  298. void iwl_mvm_protect_session(struct iwl_mvm *mvm,
  299. struct ieee80211_vif *vif,
  300. u32 duration, u32 min_duration,
  301. u32 max_delay)
  302. {
  303. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  304. struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
  305. struct iwl_time_event_cmd time_cmd = {};
  306. lockdep_assert_held(&mvm->mutex);
  307. if (te_data->running &&
  308. time_after(te_data->end_jiffies, TU_TO_EXP_TIME(min_duration))) {
  309. IWL_DEBUG_TE(mvm, "We have enough time in the current TE: %u\n",
  310. jiffies_to_msecs(te_data->end_jiffies - jiffies));
  311. return;
  312. }
  313. if (te_data->running) {
  314. IWL_DEBUG_TE(mvm, "extend 0x%x: only %u ms left\n",
  315. te_data->uid,
  316. jiffies_to_msecs(te_data->end_jiffies - jiffies));
  317. /*
  318. * we don't have enough time
  319. * cancel the current TE and issue a new one
  320. * Of course it would be better to remove the old one only
  321. * when the new one is added, but we don't care if we are off
  322. * channel for a bit. All we need to do, is not to return
  323. * before we actually begin to be on the channel.
  324. */
  325. iwl_mvm_stop_session_protection(mvm, vif);
  326. }
  327. time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
  328. time_cmd.id_and_color =
  329. cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
  330. time_cmd.id = cpu_to_le32(TE_BSS_STA_AGGRESSIVE_ASSOC);
  331. time_cmd.apply_time =
  332. cpu_to_le32(iwl_read_prph(mvm->trans, DEVICE_SYSTEM_TIME_REG));
  333. time_cmd.max_frags = TE_V2_FRAG_NONE;
  334. time_cmd.max_delay = cpu_to_le32(max_delay);
  335. /* TODO: why do we need to interval = bi if it is not periodic? */
  336. time_cmd.interval = cpu_to_le32(1);
  337. time_cmd.duration = cpu_to_le32(duration);
  338. time_cmd.repeat = 1;
  339. time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START |
  340. TE_V2_NOTIF_HOST_EVENT_END |
  341. T2_V2_START_IMMEDIATELY);
  342. iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd);
  343. }
  344. /*
  345. * Explicit request to remove a time event. The removal of a time event needs to
  346. * be synchronized with the flow of a time event's end notification, which also
  347. * removes the time event from the op mode data structures.
  348. */
  349. void iwl_mvm_remove_time_event(struct iwl_mvm *mvm,
  350. struct iwl_mvm_vif *mvmvif,
  351. struct iwl_mvm_time_event_data *te_data)
  352. {
  353. struct iwl_time_event_cmd time_cmd = {};
  354. u32 id, uid;
  355. int ret;
  356. /*
  357. * It is possible that by the time we got to this point the time
  358. * event was already removed.
  359. */
  360. spin_lock_bh(&mvm->time_event_lock);
  361. /* Save time event uid before clearing its data */
  362. uid = te_data->uid;
  363. id = te_data->id;
  364. /*
  365. * The clear_data function handles time events that were already removed
  366. */
  367. iwl_mvm_te_clear_data(mvm, te_data);
  368. spin_unlock_bh(&mvm->time_event_lock);
  369. /*
  370. * It is possible that by the time we try to remove it, the time event
  371. * has already ended and removed. In such a case there is no need to
  372. * send a removal command.
  373. */
  374. if (id == TE_MAX) {
  375. IWL_DEBUG_TE(mvm, "TE 0x%x has already ended\n", uid);
  376. return;
  377. }
  378. /* When we remove a TE, the UID is to be set in the id field */
  379. time_cmd.id = cpu_to_le32(uid);
  380. time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE);
  381. time_cmd.id_and_color =
  382. cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
  383. IWL_DEBUG_TE(mvm, "Removing TE 0x%x\n", le32_to_cpu(time_cmd.id));
  384. ret = iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, 0,
  385. sizeof(time_cmd), &time_cmd);
  386. if (WARN_ON(ret))
  387. return;
  388. }
  389. void iwl_mvm_stop_session_protection(struct iwl_mvm *mvm,
  390. struct ieee80211_vif *vif)
  391. {
  392. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  393. struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
  394. lockdep_assert_held(&mvm->mutex);
  395. iwl_mvm_remove_time_event(mvm, mvmvif, te_data);
  396. }
  397. int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  398. int duration, enum ieee80211_roc_type type)
  399. {
  400. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  401. struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
  402. struct iwl_time_event_cmd time_cmd = {};
  403. lockdep_assert_held(&mvm->mutex);
  404. if (te_data->running) {
  405. IWL_WARN(mvm, "P2P_DEVICE remain on channel already running\n");
  406. return -EBUSY;
  407. }
  408. /*
  409. * Flush the done work, just in case it's still pending, so that
  410. * the work it does can complete and we can accept new frames.
  411. */
  412. flush_work(&mvm->roc_done_wk);
  413. time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
  414. time_cmd.id_and_color =
  415. cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
  416. switch (type) {
  417. case IEEE80211_ROC_TYPE_NORMAL:
  418. time_cmd.id = cpu_to_le32(IWL_MVM_ROC_TE_TYPE_NORMAL);
  419. break;
  420. case IEEE80211_ROC_TYPE_MGMT_TX:
  421. time_cmd.id = cpu_to_le32(IWL_MVM_ROC_TE_TYPE_MGMT_TX);
  422. break;
  423. default:
  424. WARN_ONCE(1, "Got an invalid ROC type\n");
  425. return -EINVAL;
  426. }
  427. time_cmd.apply_time = cpu_to_le32(0);
  428. time_cmd.interval = cpu_to_le32(1);
  429. /*
  430. * The P2P Device TEs can have lower priority than other events
  431. * that are being scheduled by the driver/fw, and thus it might not be
  432. * scheduled. To improve the chances of it being scheduled, allow them
  433. * to be fragmented, and in addition allow them to be delayed.
  434. */
  435. time_cmd.max_frags = min(MSEC_TO_TU(duration)/50, TE_V2_FRAG_ENDLESS);
  436. time_cmd.max_delay = cpu_to_le32(MSEC_TO_TU(duration/2));
  437. time_cmd.duration = cpu_to_le32(MSEC_TO_TU(duration));
  438. time_cmd.repeat = 1;
  439. time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START |
  440. TE_V2_NOTIF_HOST_EVENT_END |
  441. T2_V2_START_IMMEDIATELY);
  442. return iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd);
  443. }
  444. void iwl_mvm_stop_p2p_roc(struct iwl_mvm *mvm)
  445. {
  446. struct iwl_mvm_vif *mvmvif;
  447. struct iwl_mvm_time_event_data *te_data;
  448. lockdep_assert_held(&mvm->mutex);
  449. /*
  450. * Iterate over the list of time events and find the time event that is
  451. * associated with a P2P_DEVICE interface.
  452. * This assumes that a P2P_DEVICE interface can have only a single time
  453. * event at any given time and this time event coresponds to a ROC
  454. * request
  455. */
  456. mvmvif = NULL;
  457. spin_lock_bh(&mvm->time_event_lock);
  458. list_for_each_entry(te_data, &mvm->time_event_list, list) {
  459. if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) {
  460. mvmvif = iwl_mvm_vif_from_mac80211(te_data->vif);
  461. break;
  462. }
  463. }
  464. spin_unlock_bh(&mvm->time_event_lock);
  465. if (!mvmvif) {
  466. IWL_WARN(mvm, "P2P_DEVICE no remain on channel event\n");
  467. return;
  468. }
  469. iwl_mvm_remove_time_event(mvm, mvmvif, te_data);
  470. iwl_mvm_roc_finished(mvm);
  471. }